<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0"><channel><title><![CDATA[【R128】软件配置——配置引脚复用]]></title><description><![CDATA[<h1>配置引脚复用</h1>
<h2>本文中的约定</h2>
<ul>
<li>描述 GPIO 配置的形式：<code>Port:端口 + 组内序号&lt;功能分配&gt;&lt;内部电阻状态&gt;&lt;驱动能力&gt;&lt;输出电平状态&gt;</code></li>
<li>文中的 <code>&lt;X&gt;=0,1,2,3,4,5…..</code>，如 twi0，twi1….；uart0，uart1….。</li>
<li>文中的 <code>{PROJECT}</code> 代表不同的方案，例如 <code>module</code> 方案。</li>
</ul>
<h2>引脚配置文件配置复用</h2>
<p dir="auto">R128 平台使用 <code>sys_config.fex</code> 作为引脚配置文件，他会在打包时打包编译进入系统，在系统运行时会解析并配置，系统解析 <code>sys_config.fex</code> 的驱动配置位于 <code>lichee\rtos-components\aw\sys_config_script</code> 中。</p>
<p dir="auto">对于配置引脚复用，只需要修改  <code>board\r128s2\{PROJECT}\config\sys_config.fex</code>  文件即可。</p>
<h3>GPIO描述格式</h3>
<pre><code>Port:端口 + 组内序号&lt;功能分配&gt;&lt;内部电阻状态&gt;&lt;驱动能力&gt;&lt;输出电平状态&gt;
</code></pre>
<p dir="auto">示例</p>
<pre><code class="language-ini">uart_tx = port:PA16&lt;5&gt;&lt;1&gt;&lt;2&gt;&lt;0&gt;
                |----------------------&gt; 端口号 PA
                  |--------------------&gt; 序号 19
                    |------------------&gt; 功能分配 5 （参考 PINMUX）
                       |---------------&gt; 内部电阻状态为 1  
                          |------------&gt; 驱动能力为 2
                             |---------&gt; 默认输出电平 0
</code></pre>
<h3>[product]</h3>
<p dir="auto">配置文件信息</p>
<table class="table table-bordered table-striped">
<thead>
<tr>
<th>配置项</th>
<th>配置项含义</th>
</tr>
</thead>
<tbody>
<tr>
<td>version</td>
<td>配置的版本号</td>
</tr>
<tr>
<td>machine</td>
<td>方案名字</td>
</tr>
</tbody>
</table>
<p dir="auto">示例</p>
<pre><code class="language-ini">[product]
version = "100"
machine = "module"
</code></pre>
<h3>[target]</h3>
<p dir="auto">启动介质配置</p>
<table class="table table-bordered table-striped">
<thead>
<tr>
<th>配置项</th>
<th>配置项含义</th>
</tr>
</thead>
<tbody>
<tr>
<td>storage_type</td>
<td>启动介质选择 &lt;br /&gt;0:nand &lt;br /&gt;1:sd&lt;br /&gt;2:emmc&lt;br /&gt;3:spinor &lt;br /&gt;4:emmc &lt;br /&gt;5:spinand &lt;br /&gt;6:sd &lt;br /&gt;-1:(defualt) 自动扫描启动介质</td>
</tr>
</tbody>
</table>
<p dir="auto">示例</p>
<pre><code class="language-ini">[target]
storage_type    = 3
</code></pre>
<blockquote>
<p dir="auto">对于内置 SPI NOR 的 R128 平台，请配置为 <code>3</code></p>
</blockquote>
<h3>[platform]</h3>
<p dir="auto">配置 boot0 调试信息打印</p>
<table class="table table-bordered table-striped">
<thead>
<tr>
<th>配置项</th>
<th>配置项含义</th>
</tr>
</thead>
<tbody>
<tr>
<td>debug_mode</td>
<td>配置0时，boot0 不打印调试信息，配置不为0时打印</td>
</tr>
</tbody>
</table>
<p dir="auto">示例</p>
<pre><code class="language-ini">[platform]
debug_mode = 2
</code></pre>
<h3>[uart_para]</h3>
<p dir="auto">boot0 调试串口配置</p>
<table class="table table-bordered table-striped">
<thead>
<tr>
<th>配置项</th>
<th>配置项含义</th>
</tr>
</thead>
<tbody>
<tr>
<td>uart_debug_port</td>
<td>boot0 调试输出串口使用的串口号</td>
</tr>
<tr>
<td>uart_debug_tx</td>
<td>boot0 调试串口 tx 使用的引脚</td>
</tr>
<tr>
<td>uart_debug_rx</td>
<td>boot0 调试串口 rx 使用的引脚</td>
</tr>
</tbody>
</table>
<p dir="auto">示例</p>
<pre><code class="language-ini">[uart_para]
uart_debug_port = 0
uart_debug_tx   = port:PA16&lt;5&gt;&lt;1&gt;&lt;default&gt;&lt;default&gt;
uart_debug_rx   = port:PA17&lt;5&gt;&lt;1&gt;&lt;default&gt;&lt;default&gt;
</code></pre>
<h3>[uartX]</h3>
<p dir="auto">UART 引脚配置</p>
<table class="table table-bordered table-striped">
<thead>
<tr>
<th>配置项</th>
<th>配置项含义</th>
</tr>
</thead>
<tbody>
<tr>
<td>uart_tx</td>
<td>UART TX 的 GPIO 配置</td>
</tr>
<tr>
<td>uart_rx</td>
<td>UART RX 的 GPIO 配置</td>
</tr>
<tr>
<td>uart_type</td>
<td>UART 类型，有效值为：2/4/8; 表示 2/4/8 线模式</td>
</tr>
</tbody>
</table>
<p dir="auto">示例</p>
<pre><code class="language-ini">[uart0]
uart_tx         = port:PA16&lt;5&gt;&lt;1&gt;&lt;default&gt;&lt;default&gt;
uart_rx         = port:PA17&lt;5&gt;&lt;1&gt;&lt;default&gt;&lt;default&gt;
</code></pre>
<h3>[twiX]</h3>
<p dir="auto">TWI 引脚配置</p>
<table class="table table-bordered table-striped">
<thead>
<tr>
<th>配置项</th>
<th>配置项含义</th>
</tr>
</thead>
<tbody>
<tr>
<td>twiX_sck</td>
<td>TWI 的时钟的 GPIO 配置</td>
</tr>
<tr>
<td>twiX_sda</td>
<td>TWI 的数据的 GPIO 配置</td>
</tr>
</tbody>
</table>
<h3>[sdcX]</h3>
<p dir="auto">SDIO，MMC 引脚配置</p>
<table class="table table-bordered table-striped">
<thead>
<tr>
<th>配置项</th>
<th>配置项含义</th>
</tr>
</thead>
<tbody>
<tr>
<td>card_ctrl</td>
<td>控制器</td>
</tr>
<tr>
<td>card_high_speed</td>
<td>速度模式 0 为低速，1 为高速</td>
</tr>
<tr>
<td>card_line</td>
<td>1，4 线卡可以选择</td>
</tr>
<tr>
<td>sdc_d1</td>
<td>sdc 卡数据 1 线信号的 GPIO 配置</td>
</tr>
<tr>
<td>sdc_d0</td>
<td>sdc 卡数据 2 线信号的 GPIO 配置</td>
</tr>
<tr>
<td>sdc_clk</td>
<td>sdc 卡时钟信号的 GPIO 配置</td>
</tr>
<tr>
<td>sdc_cmd</td>
<td>sdc 命令信号的 GPIO 配置</td>
</tr>
<tr>
<td>sdc_d3</td>
<td>sdc 卡数据 3 线信号的 GPIO 配置</td>
</tr>
<tr>
<td>sdc_d2</td>
<td>sdc 卡数据 4 线信号的 GPIO 配置</td>
</tr>
</tbody>
</table>
<p dir="auto">示例</p>
<pre><code class="language-ini">[sdc0]
card_ctrl       = 0
card_high_speed = 0
card_line       = 4
sdc_d1          = port:PA27&lt;2&gt;&lt;1&gt;&lt;3&gt;&lt;default&gt;
sdc_d0          = port:PA26&lt;2&gt;&lt;1&gt;&lt;3&gt;&lt;default&gt;
sdc_clk         = port:PA29&lt;2&gt;&lt;1&gt;&lt;3&gt;&lt;default&gt;
sdc_cmd         = port:PA25&lt;2&gt;&lt;1&gt;&lt;3&gt;&lt;default&gt;
sdc_d3          = port:PA24&lt;2&gt;&lt;1&gt;&lt;3&gt;&lt;default&gt;
sdc_d2          = port:PA28&lt;2&gt;&lt;1&gt;&lt;3&gt;&lt;default&gt;
</code></pre>
<h3>[sdcXdet_para]</h3>
<p dir="auto">卡检测引脚配置</p>
<table class="table table-bordered table-striped">
<thead>
<tr>
<th>配置项</th>
<th>配置项含义</th>
</tr>
</thead>
<tbody>
<tr>
<td>sdcX_det</td>
<td>卡插入检测脚</td>
</tr>
</tbody>
</table>
<p dir="auto">示例</p>
<pre><code class="language-ini">[sdc0det_para]
sdc0_det        = port:PA23&lt;0&gt;&lt;1&gt;&lt;3&gt;&lt;default&gt;
</code></pre>
<h3>[usbX]</h3>
<p dir="auto">USB 配置</p>
<table class="table table-bordered table-striped">
<thead>
<tr>
<th>配置项</th>
<th>配置项含义</th>
</tr>
</thead>
<tbody>
<tr>
<td>usb_used</td>
<td>USB使能标志。置1，表示系统中USB模块可用,置0,则表示系统USB禁用。</td>
</tr>
<tr>
<td>usb_port_type</td>
<td>USB端口的使用情况。 0: device only;1: host only;2: OTG</td>
</tr>
<tr>
<td>usb_detect_type</td>
<td>USB端口的检查方式。0: 不做检测;1: vbus/id检查;2: id/dpdm检查</td>
</tr>
<tr>
<td>usb_detect_mode</td>
<td>USB端口的检查方式。0: 线程轮询;1: id中断触发</td>
</tr>
<tr>
<td>usb_id_gpio</td>
<td>USB ID pin脚配置</td>
</tr>
<tr>
<td>usb_det_vbus_gpio</td>
<td>USB DET_VBUS pin脚配置</td>
</tr>
<tr>
<td>usb_drv_vbus_type</td>
<td>vbus设置方式。0: 无; 1: gpio; 2: axp。</td>
</tr>
<tr>
<td>usb_det_vbus_gpio</td>
<td>"axp_ctrl",表示 axp 提供。</td>
</tr>
<tr>
<td>usbh_driver_level</td>
<td>usb驱动能力等级</td>
</tr>
<tr>
<td>usbh_irq_flag</td>
<td>usb中断标志</td>
</tr>
</tbody>
</table>
<p dir="auto">示例</p>
<pre><code class="language-ini">[usbc0]
usb_used                = 1
usb_port_type           = 2
usb_detect_type         = 1
usb_detect_mode         = 0
usb_id_gpio             = port:PB04&lt;0&gt;&lt;0&gt;&lt;default&gt;&lt;default&gt;
usb_det_vbus_gpio       = port:PA24&lt;0&gt;&lt;0&gt;&lt;default&gt;&lt;default&gt;
usb_drv_vbus_gpio       = port:PA29&lt;0&gt;&lt;0&gt;&lt;default&gt;&lt;default&gt;
usb_drv_vbus_type       = 1
usbh_driver_level       = 5
usbh_irq_flag           = 0
</code></pre>
<h3>[audiocodec]</h3>
<p dir="auto">内置 audiocodec 配置</p>
<table class="table table-bordered table-striped">
<thead>
<tr>
<th>配置项</th>
<th>配置项含义</th>
</tr>
</thead>
<tbody>
<tr>
<td>dacl_vol</td>
<td>DAC L 音量</td>
</tr>
<tr>
<td>dacr_vol</td>
<td>DAC R 音量</td>
</tr>
<tr>
<td>lineout_vol</td>
<td>LINEOUT 音量</td>
</tr>
<tr>
<td>lineoutl_en</td>
<td>LINEOUTL 使能</td>
</tr>
<tr>
<td>lineoutr_en</td>
<td>LINEOUTR 使能</td>
</tr>
<tr>
<td>mic1_gain</td>
<td>MIC1 增益</td>
</tr>
<tr>
<td>mic2_gain</td>
<td>MIC2 增益</td>
</tr>
<tr>
<td>mic3_gain</td>
<td>MIC3 增益</td>
</tr>
<tr>
<td>mic1_en</td>
<td>MIC1 启用</td>
</tr>
<tr>
<td>mic2_en</td>
<td>MIC2 启用</td>
</tr>
<tr>
<td>mic3_en</td>
<td>MIC3 启用</td>
</tr>
<tr>
<td>mad_bind_en</td>
<td>MAD 模块绑定</td>
</tr>
<tr>
<td>pa_pin_msleep</td>
<td>功放使能引脚延时</td>
</tr>
<tr>
<td>pa_pin</td>
<td>功放使能引脚</td>
</tr>
</tbody>
</table>
<p dir="auto">示例</p>
<pre><code class="language-ini">[audiocodec]
dacl_vol	= 129
dacr_vol	= 129
lineout_vol	= 5
lineoutl_en	= 1
lineoutr_en	= 0
mic1_gain	= 19
mic2_gain	= 19
mic3_gain	= 0
mic1_en		= 1
mic2_en		= 1
mic3_en		= 1
mad_bind_en	= 0
pa_pin_msleep	= 10
pa_pin		= port:PB3&lt;1&gt;&lt;default&gt;&lt;1&gt;&lt;1&gt;
</code></pre>
<h3>[daudio0]</h3>
<p dir="auto">数字音频配置</p>
<table class="table table-bordered table-striped">
<thead>
<tr>
<th>配置项</th>
<th>配置项含义</th>
</tr>
</thead>
<tbody>
<tr>
<td>i2s_mclk</td>
<td>I2S MCLK 引脚配置</td>
</tr>
<tr>
<td>i2s_bclk</td>
<td>I2S BCLK 引脚配置</td>
</tr>
<tr>
<td>i2s_lrck</td>
<td>I2S LRCK 引脚配置</td>
</tr>
<tr>
<td>i2s_dout0</td>
<td>I2S DOUT0 引脚配置</td>
</tr>
<tr>
<td>i2s_din0</td>
<td>I2S DIN0 引脚配置</td>
</tr>
</tbody>
</table>
<p dir="auto">示例</p>
<pre><code class="language-ini">[daudio0]
i2s_mclk                    = port:PA23&lt;2&gt;&lt;0&gt;&lt;1&gt;&lt;default&gt;
i2s_bclk                    = port:PA20&lt;2&gt;&lt;0&gt;&lt;1&gt;&lt;default&gt;
i2s_lrck                    = port:PA19&lt;2&gt;&lt;0&gt;&lt;1&gt;&lt;default&gt;
i2s_dout0                   = port:PA22&lt;2&gt;&lt;0&gt;&lt;1&gt;&lt;default&gt;
i2s_din0                    = port:PA21&lt;2&gt;&lt;0&gt;&lt;1&gt;&lt;default&gt;
</code></pre>
<h3>[dram_para]</h3>
<blockquote>
<p dir="auto">此项配置仅为兼容配置，实际有用配置项为 <code>dram_clk</code>，<code>dram_no_lpsram</code> ，其余 <code>dram_para</code> 参数没有实际意义。</p>
</blockquote>
<table class="table table-bordered table-striped">
<thead>
<tr>
<th>配置项</th>
<th>配置项含义</th>
</tr>
</thead>
<tbody>
<tr>
<td>dram_clk</td>
<td>如果不为 0，初始化 hspsram</td>
</tr>
<tr>
<td>dram_no_lpsram</td>
<td>如果为 0，初始化 lspsram</td>
</tr>
</tbody>
</table>
<pre><code class="language-ini">[dram_para]
dram_clk       = 800
dram_type      = 0xB
dram_zq        = 0x3dbdfda0
dram_odt_en    = 0x1
dram_para1     = 0x000010f2
dram_para2     = 0x02000000
dram_mr0       = 0x1c70
dram_mr1       = 0x42
dram_mr2       = 0x8
dram_mr3       = 0x0
dram_tpr0      = 0x004A2195
dram_tpr1      = 0x02423190
dram_tpr2      = 0x0008B061
dram_tpr3      = 0xB4787896
dram_tpr4      = 0x0
dram_tpr5      = 0x48484848
dram_tpr6      = 0x48
dram_tpr7      = 0x1
dram_tpr8      = 0x0
dram_tpr9      = 0x00
dram_tpr10     = 0x0
dram_tpr11     = 0x00000000
dram_tpr12     = 0x00000000
dram_tpr13     = 0x34050f00
dram_no_lpsram = 0x0
</code></pre>
<h3>[lcd_fb0]</h3>
<p dir="auto">SPI LCD  配置</p>
<blockquote>
<p dir="auto">SPI LCD 配置项目较多，部分详细描述可以参照 <a href="/sdk_base/disp">显示框架</a></p>
</blockquote>
<table class="table table-bordered table-striped">
<thead>
<tr>
<th>配置项</th>
<th>配置项含义</th>
</tr>
</thead>
<tbody>
<tr>
<td>lcd_used</td>
<td>启用 LCD</td>
</tr>
<tr>
<td>lcd_model_name</td>
<td>lcd 屏模型名字，非必须，可以用于同个屏驱动中进一步区分不同屏。</td>
</tr>
<tr>
<td>lcd_driver_name</td>
<td>lcd面板驱动名称，必须与屏驱动中<code>strcut __lcd_panel</code>变量的<code>name</code>成员一致。</td>
</tr>
<tr>
<td>lcd_x</td>
<td>lcd X像素</td>
</tr>
<tr>
<td>lcd_y</td>
<td>lcd Y像素</td>
</tr>
<tr>
<td>lcd_width</td>
<td>lcd 物理宽度（单位mm）</td>
</tr>
<tr>
<td>lcd_height</td>
<td>lcd 物理高度（单位mm）</td>
</tr>
<tr>
<td>lcd_data_speed</td>
<td>lcd 数据速率</td>
</tr>
<tr>
<td>lcd_pwm_used</td>
<td>lcd 背光使用 pwm</td>
</tr>
<tr>
<td>lcd_pwm_ch</td>
<td>lcd 背光使用的 pwm 通道</td>
</tr>
<tr>
<td>lcd_pwm_freq</td>
<td>lcd 背光使用的频率</td>
</tr>
<tr>
<td>lcd_pwm_pol</td>
<td>lcd 背光使用的相位</td>
</tr>
<tr>
<td>lcd_if</td>
<td>0：SPI接口（spi 接口就是俗称的 4 线模式，这是因为发送数据时需要额外借助 DC 线来区分命令和数据，与sclk，cs 和 sda 共四线）&lt;br /&gt;1：DBI接口（如果设置了 dbi 接口，那么还需要进一步区分 dbi 接口，需要设置lcd_dbi_if）</td>
</tr>
<tr>
<td>lcd_pixel_fmt</td>
<td>选择传输数据的像素格式</td>
</tr>
<tr>
<td>lcd_dbi_fmt</td>
<td>0：RGB111&lt;br /&gt;1：RGB444&lt;br /&gt;2：RGB565&lt;br /&gt;3：RGB666&lt;br /&gt;4：RGB888</td>
</tr>
<tr>
<td>lcd_dbi_clk_mode</td>
<td>选择 dbi 时钟的行为模式</td>
</tr>
<tr>
<td>lcd_dbi_te</td>
<td>使能 te 触发</td>
</tr>
<tr>
<td>fb_buffer_num</td>
<td>显示 framebuffer 数量，为了平滑显示，这里一般是 2 个，为了省内存也可以改成 1。</td>
</tr>
<tr>
<td>lcd_dbi_if</td>
<td>0：L3I1&lt;br /&gt;1：L3I2&lt;br /&gt;2：L4I1&lt;br /&gt;3：L4I2&lt;br /&gt;4：D2L1</td>
</tr>
<tr>
<td>lcd_rgb_order</td>
<td>输入图像数据 rgb 顺序识别设置</td>
</tr>
<tr>
<td>lcd_fps</td>
<td>设置屏的刷新率，单位 Hz</td>
</tr>
<tr>
<td>lcd_spi_bus_num</td>
<td>选择 spi 总线 id</td>
</tr>
<tr>
<td>lcd_frm</td>
<td>frm抖动控制</td>
</tr>
<tr>
<td>lcd_gamma_en</td>
<td>gamma控制使能</td>
</tr>
<tr>
<td>lcd_backlight</td>
<td>背光</td>
</tr>
<tr>
<td>lcd_gpio_0</td>
<td>用户定义IO定义，一般作为RST</td>
</tr>
</tbody>
</table>
]]></description><link>https://bbs.aw-ol.com/topic/4406/r128-软件配置-配置引脚复用</link><generator>RSS for Node</generator><lastBuildDate>Sun, 17 May 2026 15:54:25 GMT</lastBuildDate><atom:link href="https://bbs.aw-ol.com/topic/4406.rss" rel="self" type="application/rss+xml"/><pubDate>Fri, 13 Oct 2023 03:32:34 GMT</pubDate><ttl>60</ttl></channel></rss>