【BIGTREETECH PI开发板】 GPIO输出控制
本帖最后由 TL-LED 于 2023-7-7 17:38 编辑<p>这款开发板针对外设的操作资料不是很多,下面来使用第三方的wiringPI库来测试下外设的使用。</p>
<p> </p>
<p><strong>一、下载和安装wiringOP</strong></p>
<p>wiringOP是在wiringPI的基础上针对开发板的端口进行封装。</p>
<p>下载地址: git clone <a href="https://github.com/orangepi-xunlong/wiringOP" target="_blank">https://github.com/orangepi-xunlong/wiringOP</a></p>
<p>命令:biqu@BTT-CB1:/opt$ sudo git clone <a href="https://github.com/orangepi-xunlong/wiringOP" target="_blank">https://github.com/orangepi-xunlong/wiringOP</a><br />
命令:biqu@BTT-CB1:/opt$ cd wiringOP/</p>
<p>命令:biqu@BTT-CB1:/opt/wiringOP$ ./build clean</p>
<p>命令:biqu@BTT-CB1:/opt/wiringOP$ ./build </p>
<p>安装完成后,测试下</p>
<p>执行命令:biqu@BTT-CB1:/opt/wiringOP$ gpio readall</p>
<p>读取到设备端口号,这个是其他型号的开发板端口外设引脚定义,和测试使用的板卡引脚定义不一样,使用的处理器型号都是H616,可以在这个库的基础上进行修改和测试。</p>
<p> </p>
<p><strong>二、测试GPIO端口</strong></p>
<p> </p>
<p>2.1、测试板卡引脚定义</p>
<table>
<tbody>
<tr>
<td align="center" rowspan="2">in</td>
<td align="center" colspan="2">BTT Pi</td>
<td align="center" colspan="2">CB1 eMMC</td>
<td align="center" colspan="2">CB1</td>
<td align="center" colspan="2">CM4</td>
<td align="center" colspan="2">CM4</td>
<td align="center" colspan="2">CB1</td>
<td align="center" colspan="2">CB1 eMMC</td>
<td align="center" colspan="2">BTT Pi</td>
<td align="center" rowspan="2">Pin</td>
</tr>
<tr>
<td>Signal</td>
<td align="center">Description</td>
<td align="center">Signal</td>
<td align="center">Description</td>
<td align="center">Signal</td>
<td align="center">Description</td>
<td align="center">Signal</td>
<td align="center">Description</td>
<td align="center">Signal</td>
<td align="center">Description</td>
<td align="center">Signal</td>
<td align="center">Description</td>
<td align="center">Signal</td>
<td align="center">Description</td>
<td align="center">Signal</td>
<td align="center">Description</td>
</tr>
<tr>
<td>1</td>
<td align="center" colspan="2">3.3V</td>
<td align="center" colspan="2">3.3V</td>
<td align="center" colspan="2">3.3V</td>
<td align="center" colspan="2">3.3V</td>
<td align="center" colspan="2">5V</td>
<td align="center" colspan="2">5V</td>
<td align="center" colspan="2">5V</td>
<td align="center" colspan="2">5V</td>
<td>2</td>
</tr>
<tr>
<td>3</td>
<td>PC3</td>
<td align="center">GPIO67</td>
<td align="center" colspan="2">NC</td>
<td align="center" colspan="2">NC</td>
<td align="center">GPIO2</td>
<td align="center">I2C1 SDA</td>
<td align="center" colspan="2">5V</td>
<td align="center" colspan="2">5V</td>
<td align="center" colspan="2">5V</td>
<td align="center" colspan="2">5V</td>
<td>4</td>
</tr>
<tr>
<td>5</td>
<td>PC0</td>
<td align="center">GPIO64</td>
<td align="center" colspan="2">NC</td>
<td align="center" colspan="2">NC</td>
<td align="center">GPIO3</td>
<td align="center">I2C1 SCL</td>
<td align="center" colspan="2">GND</td>
<td align="center" colspan="2">GND</td>
<td align="center" colspan="2">GND</td>
<td align="center" colspan="2">GND</td>
<td>6</td>
</tr>
<tr>
<td>7</td>
<td>PC7</td>
<td align="center">GPIO71</td>
<td align="center">PI14</td>
<td align="center">GPIO170</td>
<td align="center">PC7</td>
<td align="center">GPIO71</td>
<td align="center">GPIO4</td>
<td align="center">GPCLK0</td>
<td align="center">GPIO14</td>
<td align="center">UART TX</td>
<td align="center">PH0</td>
<td align="center">GPIO224, UART0_TX</td>
<td align="center">PH0</td>
<td align="center">GPIO224, UART0_TX</td>
<td align="center">PH0</td>
<td align="center">GPIO224, UART0_TX</td>
<td>8</td>
</tr>
<tr>
<td>9</td>
<td align="center" colspan="2">GND</td>
<td align="center" colspan="2">GND</td>
<td align="center" colspan="2">GND</td>
<td align="center" colspan="2">GND</td>
<td align="center">GPIO15</td>
<td align="center">UART RX</td>
<td align="center">PH1</td>
<td align="center">GPIO225, UART0_RX</td>
<td align="center">PH1</td>
<td align="center">GPIO225, UART0_RX</td>
<td align="center">PH1</td>
<td align="center">GPIO225, UART0_RX</td>
<td>10</td>
</tr>
<tr>
<td>11</td>
<td>PC14</td>
<td align="center">GPIO78</td>
<td align="center">PI15</td>
<td align="center">GPIO271</td>
<td align="center">PC14</td>
<td align="center">GPIO78</td>
<td align="center">GPIO17</td>
<td align="center">SPI1 CE1</td>
<td align="center">GPIO18</td>
<td align="center">PCM CLK</td>
<td align="center">PC13</td>
<td align="center">GPIO77</td>
<td align="center">PI7</td>
<td align="center">GPIO263</td>
<td align="center">PC13</td>
<td align="center">GPIO77</td>
<td>12</td>
</tr>
<tr>
<td>13</td>
<td>PC12</td>
<td align="center">GPIO76</td>
<td align="center">PI6</td>
<td align="center">GPIO262</td>
<td align="center">PC12</td>
<td align="center">GPIO76</td>
<td align="center">GPIO27</td>
<td align="center"> </td>
<td align="center" colspan="2">GND</td>
<td align="center" colspan="2">GND</td>
<td align="center" colspan="2">GND</td>
<td align="center" colspan="2">GND</td>
<td>14</td>
</tr>
<tr>
<td>15</td>
<td>PC10</td>
<td align="center">74</td>
<td align="center">PI4</td>
<td align="center">GPIO260</td>
<td align="center">PC10</td>
<td align="center">GPIO74</td>
<td align="center">GPIO22</td>
<td align="center"> </td>
<td align="center">GPIO23</td>
<td align="center"> </td>
<td align="center">PC11</td>
<td align="center">GPIO75</td>
<td align="center">PI5</td>
<td align="center">GPIO261</td>
<td align="center">PC11</td>
<td align="center">GPIO75</td>
<td>16</td>
</tr>
<tr>
<td>17</td>
<td align="center" colspan="2">3.3V</td>
<td align="center" colspan="2">3.3V</td>
<td align="center" colspan="2">3.3V</td>
<td align="center" colspan="2">3.3V</td>
<td align="center">GPIO24</td>
<td align="center"> </td>
<td align="center">PC9</td>
<td align="center">GPIO73</td>
<td align="center">PI3</td>
<td align="center">GPIO259</td>
<td align="center">PC9</td>
<td align="center">GPIO73</td>
<td>18</td>
</tr>
<tr>
<td>19</td>
<td>PH7</td>
<td align="center">GPIO231, SPI1_MOSI</td>
<td align="center">PH7</td>
<td align="center">GPIO231, SPI1_MOSI</td>
<td align="center">PH7</td>
<td align="center">GPIO231, SPI1_MOSI</td>
<td align="center">GPIO10</td>
<td align="center">SPI0 MOSI</td>
<td align="center" colspan="2">GND</td>
<td align="center" colspan="2">GND</td>
<td align="center" colspan="2">GND</td>
<td align="center" colspan="2">GND</td>
<td>20</td>
</tr>
<tr>
<td>21</td>
<td>PH8</td>
<td align="center">GPIO232, SPI1_MISO</td>
<td align="center">PH8</td>
<td align="center">GPIO232, SPI1_MISO</td>
<td align="center">PH8</td>
<td align="center">GPIO232, SPI1_MISO</td>
<td align="center">GPIO9</td>
<td align="center">SPI0 MISO</td>
<td align="center">GPIO25</td>
<td align="center"> </td>
<td align="center" colspan="2">NC</td>
<td align="center" colspan="2">NC</td>
<td align="center">PG13</td>
<td align="center">GPIO205</td>
<td>22</td>
</tr>
<tr>
<td>23</td>
<td>PH6</td>
<td align="center">GPIO230, SPI1_CLK</td>
<td align="center">PH6</td>
<td align="center">GPIO230, SPI1_CLK</td>
<td align="center">PH6</td>
<td align="center">GPIO230, SPI1_CLK</td>
<td align="center">GPIO11</td>
<td align="center">SPI0 SCLK</td>
<td align="center">GPIO8</td>
<td align="center">SPI0 CE0</td>
<td align="center" colspan="2">NC</td>
<td align="center" colspan="2">NC</td>
<td align="center">PG12</td>
<td align="center">GPIO204</td>
<td>24</td>
</tr>
<tr>
<td>25</td>
<td align="center" colspan="2">GND</td>
<td align="center" colspan="2">GND</td>
<td align="center" colspan="2">GND</td>
<td align="center" colspan="2">GND</td>
<td align="center">GPIO7</td>
<td align="center">SPI0 CE1</td>
<td align="center">PG8</td>
<td align="center">GPIO200</td>
<td align="center">PI11</td>
<td align="center">GPIO267</td>
<td align="center">PI9</td>
<td align="center">GPIO265</td>
<td>26</td>
</tr>
<tr>
<td>27</td>
<td>PC2</td>
<td align="center">GPIO66</td>
<td align="center" colspan="2">NC</td>
<td align="center" colspan="2">NC</td>
<td align="center">GPIO0</td>
<td align="center">EEPROM SDA</td>
<td align="center">GPIO1</td>
<td align="center">EEPROM SCL</td>
<td align="center">PG7</td>
<td align="center">GPIO199</td>
<td align="center">PI10</td>
<td align="center">GPIO266</td>
<td align="center">PI10</td>
<td align="center">GPIO266</td>
<td>28</td>
</tr>
<tr>
<td>29</td>
<td>PC4</td>
<td align="center">GPIO68</td>
<td align="center" colspan="2">NC</td>
<td align="center" colspan="2">NC</td>
<td align="center">GPIO5</td>
<td align="center">GPCLK1</td>
<td align="center" colspan="2">GND</td>
<td align="center" colspan="2">GND</td>
<td align="center" colspan="2">GND</td>
<td align="center" colspan="2">GND</td>
<td>30</td>
</tr>
<tr>
<td>31</td>
<td>PI5</td>
<td align="center">GPIO261</td>
<td align="center">PI9</td>
<td align="center">GPIO265</td>
<td align="center">PG6</td>
<td align="center">GPIO198</td>
<td align="center">GPIO6</td>
<td align="center">GPCLK2</td>
<td align="center">GPIO12</td>
<td align="center">PWM0</td>
<td align="center">PG9</td>
<td align="center">GPIO201</td>
<td align="center">PI12</td>
<td align="center">GPIO268</td>
<td align="center">PI6</td>
<td align="center">GPIO262</td>
<td>32</td>
</tr>
<tr>
<td>33</td>
<td>PI14</td>
<td align="center">GPIO270</td>
<td align="center" colspan="2">NC</td>
<td align="center" colspan="2">NC</td>
<td align="center">GPIO13</td>
<td align="center">PWM1</td>
<td align="center" colspan="2">GND</td>
<td align="center" colspan="2">GND</td>
<td align="center" colspan="2">GND</td>
<td align="center" colspan="2">GND</td>
<td>34</td>
</tr>
<tr>
<td>35</td>
<td>PC6</td>
<td align="center">GPIO70</td>
<td align="center">PI1</td>
<td align="center">GPIO257</td>
<td align="center">PC6</td>
<td align="center">GPIO70</td>
<td align="center">GPIO19</td>
<td align="center">PCM FS</td>
<td align="center">GPIO16</td>
<td align="center">SPI1 CE2</td>
<td align="center" colspan="2">NC</td>
<td align="center" colspan="2">NC</td>
<td align="center">PG11</td>
<td align="center">GPIO203</td>
<td>36</td>
</tr>
<tr>
<td>37</td>
<td>PC15</td>
<td align="center">GPIO79</td>
<td align="center">PI13</td>
<td align="center">GPIO269</td>
<td align="center">PC15</td>
<td align="center">GPIO79</td>
<td align="center">GPIO26</td>
<td align="center"> </td>
<td align="center">GPIO20</td>
<td align="center">PCM DIN</td>
<td align="center">PH10</td>
<td align="center">GPIO234, IR_RX</td>
<td align="center">PH10</td>
<td align="center">GPIO234, IR_RX</td>
<td align="center">PH4</td>
<td align="center">GPIO228</td>
<td>38</td>
</tr>
<tr>
<td>39</td>
<td align="center" colspan="2">GND</td>
<td align="center" colspan="2">GND</td>
<td align="center" colspan="2">GND</td>
<td align="center" colspan="2">GND</td>
<td align="center">GPIO21</td>
<td align="center">PCM DOUT</td>
<td align="center">PC8</td>
<td align="center">GPIO72</td>
<td align="center">PI2</td>
<td align="center">GPIO258</td>
<td align="center">PC8</td>
<td align="center">GPIO72</td>
<td>40</td>
</tr>
</tbody>
</table>
<p> </p>
<p></p>
<p> </p>
<p>2.2、使用PC7端口,来测试下输出</p>
<p>程序部分:</p>
<p>pc_test.c</p>
<pre>
<code>#include <stdio.h>
#include <wiringPi.h>
#define NUM 13
int main (void)
{
wiringPiSetup () ;
pinMode (NUM, OUTPUT) ;
for ( ;; )
{
digitalWrite (NUM, HIGH) ;
printf("pc7 -> high!\r\n");
delay (1000) ; // mS
digitalWrite (NUM, LOW) ;
printf("pc7 -> low!\r\n");
delay (1000) ;
}
return 0;
}</code></pre>
<p> </p>
<p>2.3、编译</p>
<p>命令:biqu@BTT-CB1:/opt/wiringOP/examples$ sudo make pc7_test</p>
<p></p>
<p> </p>
<p><strong>三、运行程序</strong></p>
<p> </p>
<p>3.1、执行命令</p>
<p>biqu@BTT-CB1:/opt/wiringOP/examples$ sudo ./pc7_test</p>
<p></p>
<p> </p>
<p>3.2、运行视频</p>
<p>8588c8a3276a43355f4ea122580d990e<br />
</p>
<p>读取到设备端口号,这个是其他型号的开发板端口外设引脚定义和测试使用的板卡引脚定义不一样</p>
<p>这个确实需要修改</p>
<p>orangepi?</p>
Unable to open /etc/orangepi-release or /etc/armbian-release
页:
[1]