Kaynağa Gözat

[stm32f401 nucleo] update main.c revert blinking LED

Meco Man 2 yıl önce
ebeveyn
işleme
560166477e

+ 12 - 3
bsp/stm32/stm32f401-st-nucleo/applications/main.c

@@ -6,16 +6,25 @@
  * Change Logs:
  * Date           Author       Notes
  * 2018-11-06     SummerGift   first version
- * 2022-04-19     Meco Man     solve LED interferes with SPI
  */
 
 #include <rtthread.h>
+#include <rtdevice.h>
+#include <board.h>
+
+/* defined the LD2 (user LED) pin: PB1 */
+#define LED2_PIN    GET_PIN(A, 5)
 
 int main(void)
 {
+    /* set LED0 pin mode to output */
+    rt_pin_mode(LED2_PIN, PIN_MODE_OUTPUT);
+
     while (1)
     {
-        rt_kprintf("Hello RT-Thread!\n");
-        rt_thread_mdelay(1000);
+        rt_pin_write(LED2_PIN, PIN_HIGH);
+        rt_thread_mdelay(500);
+        rt_pin_write(LED2_PIN, PIN_LOW);
+        rt_thread_mdelay(500);
     }
 }