trucy 发表于 2020-9-28 09:24

GD32307E-START上电+led控制

<p>接上一篇开箱https://bbs.eeworld.com.cn/thread-1143008-1-1.html</p>

<p>今天来一个上电</p>

<p>首先,我们从原理图看到LED连接的IO为PC6</p>

<p>代码如下:</p>

<p>#define LED1_PIN &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; GPIO_PIN_6<br />
#define LED1_GPIO_PORT &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; GPIOC<br />
#define LED1_GPIO_CLK &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;RCU_GPIOC</p>

<p>void &nbsp;gd_eval_led_init (led_typedef_enum lednum)<br />
{<br />
&nbsp; &nbsp; /* enable the led clock */<br />
&nbsp; &nbsp; rcu_periph_clock_enable(GPIO_CLK);<br />
&nbsp; &nbsp; /* configure led GPIO port */&nbsp;<br />
&nbsp; &nbsp; gpio_init(GPIO_PORT, GPIO_MODE_OUT_PP, GPIO_OSPEED_50MHZ,GPIO_PIN);</p>

<p>&nbsp; &nbsp; GPIO_BC(GPIO_PORT) = GPIO_PIN;<br />
}</p>

<p>void gd_eval_led_on(led_typedef_enum lednum)<br />
{<br />
&nbsp; &nbsp; GPIO_BOP(GPIO_PORT) = GPIO_PIN;<br />
}</p>

<p>void gd_eval_led_off(led_typedef_enum lednum)<br />
{<br />
&nbsp; &nbsp; GPIO_BC(GPIO_PORT) = GPIO_PIN;<br />
}</p>

<p>void led_init(void)<br />
{<br />
&nbsp; &nbsp; gd_eval_led_init(LED1);<br />
}</p>

<p>void led_flash(int times)<br />
{<br />
&nbsp; &nbsp; int i;<br />
&nbsp; &nbsp; for(i=0; i&lt;times; i++)<br />
&nbsp;&nbsp; &nbsp;{<br />
&nbsp; &nbsp; &nbsp; &nbsp; delay_1ms(400);<br />
&nbsp; &nbsp; &nbsp; &nbsp; /* turn on LEDs */<br />
&nbsp; &nbsp; &nbsp; &nbsp; gd_eval_led_on(LED1);<br />
&nbsp; &nbsp; &nbsp; &nbsp; delay_1ms(400);<br />
&nbsp; &nbsp; &nbsp; &nbsp; /* turn off LEDs */<br />
&nbsp; &nbsp; &nbsp; &nbsp; gd_eval_led_off(LED1);<br />
&nbsp; &nbsp; }<br />
}</p>

<p>接下来上一个测试效果,循环10次哦</p>

<p><br />
<br />
&nbsp;</p>

<p>上电测试LED闪烁完成</p>

<p>&nbsp;</p>

<p>&nbsp;</p>

powerlove 发表于 2020-10-2 21:25

看不懂,不知道说什么,还是感谢楼主的分享,谢谢。。。。

okhxyyo 发表于 2020-10-9 15:27

<p>兆易GD32307E-START测评汇总<br />
<a href="https://bbs.eeworld.com.cn/thread-1143008-1-1.html" target="_blank">https://bbs.eeworld.com.cn/thread-1143008-1-1.html</a></p>

okhxyyo 发表于 2020-10-19 10:14

<p><a href="https://bbs.eeworld.com.cn/thread-1143008-1-1.html" target="_blank">兆易GD32307E-START测评汇总</a></p>

<p>汇总贴:<a href="https://bbs.eeworld.com.cn/thread-1143008-1-1.html" target="_blank">https://bbs.eeworld.com.cn/thread-1143008-1-1.html</a></p>
页: [1]
查看完整版本: GD32307E-START上电+led控制