Browse Source

[bsp][stm32] optimize main func

SummerGift 6 years ago
parent
commit
938bbb030d
27 changed files with 91 additions and 161 deletions
  1. 10 1
      bsp/stm32/libraries/templates/stm32f10x/applications/main.c
  2. 0 9
      bsp/stm32/libraries/templates/stm32f10x/board/board.c
  3. 0 6
      bsp/stm32/libraries/templates/stm32f10x/board/board.h
  4. 10 1
      bsp/stm32/libraries/templates/stm32f4xx/applications/main.c
  5. 0 9
      bsp/stm32/libraries/templates/stm32f4xx/board/board.c
  6. 0 6
      bsp/stm32/libraries/templates/stm32f4xx/board/board.h
  7. 10 1
      bsp/stm32/libraries/templates/stm32l4xx/applications/main.c
  8. 0 9
      bsp/stm32/libraries/templates/stm32l4xx/board/board.c
  9. 0 6
      bsp/stm32/libraries/templates/stm32l4xx/board/board.h
  10. 10 1
      bsp/stm32/stm32f103-atk-nano/applications/main.c
  11. 1 8
      bsp/stm32/stm32f103-atk-nano/board/board.c
  12. 0 7
      bsp/stm32/stm32f103-atk-nano/board/board.h
  13. 10 1
      bsp/stm32/stm32f103-fire-arbitrary/applications/main.c
  14. 0 11
      bsp/stm32/stm32f103-fire-arbitrary/board/board.c
  15. 0 7
      bsp/stm32/stm32f103-fire-arbitrary/board/board.h
  16. 10 1
      bsp/stm32/stm32f407-atk-explorer/applications/main.c
  17. 0 11
      bsp/stm32/stm32f407-atk-explorer/board/board.c
  18. 0 7
      bsp/stm32/stm32f407-atk-explorer/board/board.h
  19. 10 1
      bsp/stm32/stm32f429-atk-apollo/applications/main.c
  20. 0 11
      bsp/stm32/stm32f429-atk-apollo/board/board.c
  21. 0 9
      bsp/stm32/stm32f429-atk-apollo/board/board.h
  22. 10 1
      bsp/stm32/stm32f429-fire-challenger/applications/main.c
  23. 0 11
      bsp/stm32/stm32f429-fire-challenger/board/board.c
  24. 0 8
      bsp/stm32/stm32f429-fire-challenger/board/board.h
  25. 10 1
      bsp/stm32/stm32l475-atk-pandora/applications/main.c
  26. 0 9
      bsp/stm32/stm32l475-atk-pandora/board/board.c
  27. 0 8
      bsp/stm32/stm32l475-atk-pandora/board/board.h

+ 10 - 1
bsp/stm32/libraries/templates/stm32f10x/applications/main.c

@@ -11,14 +11,23 @@
 #include <rtthread.h>
 #include <rtdevice.h>
 #include <board.h>
+#include "drv_gpio.h"
+/* defined the LED0 pin: PB1 */
+#define LED0_PIN    GET_PIN(B, 1)
 
 int main(void)
 {
     int count = 1;
+    /* set LED0 pin mode to output */
+    rt_pin_mode(LED0_PIN, PIN_MODE_OUTPUT);
+
     while (count++)
     {
-        // rt_pin_write(LED0_PIN, !rt_pin_read(LED0_PIN));
+        rt_pin_write(LED0_PIN, PIN_HIGH);
+        rt_thread_mdelay(500);
+        rt_pin_write(LED0_PIN, PIN_LOW);
         rt_thread_mdelay(500);
     }
+
     return RT_EOK;
 }

+ 0 - 9
bsp/stm32/libraries/templates/stm32f10x/board/board.c

@@ -51,12 +51,3 @@ void MX_GPIO_Init(void)
   __HAL_RCC_GPIOA_CLK_ENABLE();
 
 }
-
-#ifdef RT_USING_PIN
-// int board_pin_init(void)
-// {
-//     rt_pin_mode(LED0_PIN, PIN_MODE_OUTPUT);
-//     return 0;
-// }
-// INIT_BOARD_EXPORT(board_pin_init);
-#endif /* RT_USING_PIN */

+ 0 - 6
bsp/stm32/libraries/templates/stm32f10x/board/board.h

@@ -15,12 +15,6 @@
 #include <stm32f1xx.h>
 #include "drv_common.h"
 
-#ifdef BSP_USING_GPIO
-#include "drv_gpio.h"
-/* Board Pin definitions */
-// #define LED0_PIN                       GET_PIN(C,  0)
-#endif
-
 /* Internal SRAM memory size[Kbytes] <8-64>, Default: 64*/
 #define STM32_SRAM_SIZE      20
 #define STM32_SRAM_END       (0x20000000 + STM32_SRAM_SIZE * 1024)

+ 10 - 1
bsp/stm32/libraries/templates/stm32f4xx/applications/main.c

@@ -11,14 +11,23 @@
 #include <rtthread.h>
 #include <rtdevice.h>
 #include <board.h>
+#include "drv_gpio.h"
+/* defined the LED0 pin: PB1 */
+#define LED0_PIN    GET_PIN(B, 1)
 
 int main(void)
 {
     int count = 1;
+    /* set LED0 pin mode to output */
+    rt_pin_mode(LED0_PIN, PIN_MODE_OUTPUT);
+
     while (count++)
     {
-        // rt_pin_write(LED0_PIN, !rt_pin_read(LED0_PIN));
+        rt_pin_write(LED0_PIN, PIN_HIGH);
+        rt_thread_mdelay(500);
+        rt_pin_write(LED0_PIN, PIN_LOW);
         rt_thread_mdelay(500);
     }
+
     return RT_EOK;
 }

+ 0 - 9
bsp/stm32/libraries/templates/stm32f4xx/board/board.c

@@ -56,12 +56,3 @@ void MX_GPIO_Init(void)
   __HAL_RCC_GPIOA_CLK_ENABLE();
 
 }
-
-#ifdef RT_USING_PIN
-// int board_pin_init(void)
-// {
-//     rt_pin_mode(LED0_PIN, PIN_MODE_OUTPUT);
-//     return 0;
-// }
-// INIT_BOARD_EXPORT(board_pin_init);
-#endif /* RT_USING_PIN */

+ 0 - 6
bsp/stm32/libraries/templates/stm32f4xx/board/board.h

@@ -15,12 +15,6 @@
 #include <stm32f4xx.h>
 #include "drv_common.h"
 
-#ifdef BSP_USING_GPIO
-#include "drv_gpio.h"
-/* Board Pin definitions */
-// #define LED0_PIN                       GET_PIN(C,  0)
-#endif
-
 #define STM32_SRAM_SIZE           128
 #define STM32_SRAM_END            (0x20000000 + STM32_SRAM_SIZE * 1024)
 

+ 10 - 1
bsp/stm32/libraries/templates/stm32l4xx/applications/main.c

@@ -11,14 +11,23 @@
 #include <rtthread.h>
 #include <rtdevice.h>
 #include <board.h>
+#include "drv_gpio.h"
+/* defined the LED0 pin: PB1 */
+#define LED0_PIN    GET_PIN(B, 1)
 
 int main(void)
 {
     int count = 1;
+    /* set LED0 pin mode to output */
+    rt_pin_mode(LED0_PIN, PIN_MODE_OUTPUT);
+
     while (count++)
     {
-        // rt_pin_write(LED0_PIN, !rt_pin_read(LED0_PIN));
+        rt_pin_write(LED0_PIN, PIN_HIGH);
+        rt_thread_mdelay(500);
+        rt_pin_write(LED0_PIN, PIN_LOW);
         rt_thread_mdelay(500);
     }
+
     return RT_EOK;
 }

+ 0 - 9
bsp/stm32/libraries/templates/stm32l4xx/board/board.c

@@ -66,12 +66,3 @@ void MX_GPIO_Init(void)
   __HAL_RCC_GPIOA_CLK_ENABLE();
 
 }
-
-#ifdef RT_USING_PIN
-// int board_pin_init(void)
-// {
-//     rt_pin_mode(LED0_PIN, PIN_MODE_OUTPUT);
-//     return 0;
-// }
-// INIT_BOARD_EXPORT(board_pin_init);
-#endif /* RT_USING_PIN */

+ 0 - 6
bsp/stm32/libraries/templates/stm32l4xx/board/board.h

@@ -15,12 +15,6 @@
 #include <stm32l4xx.h>
 #include "drv_common.h"
 
-#ifdef BSP_USING_GPIO
-#include "drv_gpio.h"
-/* Board Pin definitions */
-// #define LED0_PIN                       GET_PIN(C,  0)
-#endif
-
 #define STM32_SRAM_SIZE         96
 #define STM32_SRAM_END          (0x20000000 + STM32_SRAM_SIZE * 1024)
 

+ 10 - 1
bsp/stm32/stm32f103-atk-nano/applications/main.c

@@ -11,14 +11,23 @@
 #include <rtthread.h>
 #include <rtdevice.h>
 #include <board.h>
+#include "drv_gpio.h"
+/* defined the LED0 pin: PC0 */
+#define LED0_PIN    GET_PIN(C, 0)
 
 int main(void)
 {
     int count = 1;
+    /* set LED0 pin mode to output */
+    rt_pin_mode(LED0_PIN, PIN_MODE_OUTPUT);
+
     while (count++)
     {
-        rt_pin_write(LED0_PIN, !rt_pin_read(LED0_PIN));
+        rt_pin_write(LED0_PIN, PIN_HIGH);
+        rt_thread_mdelay(500);
+        rt_pin_write(LED0_PIN, PIN_LOW);
         rt_thread_mdelay(500);
     }
+
     return RT_EOK;
 }

+ 1 - 8
bsp/stm32/stm32f103-atk-nano/board/board.c

@@ -62,11 +62,4 @@ void MX_GPIO_Init(void)
   __HAL_RCC_GPIOA_CLK_ENABLE();
 
 }
-#ifdef RT_USING_PIN
-int board_pin_init(void)
-{
-    rt_pin_mode(LED0_PIN, PIN_MODE_OUTPUT);
-    return 0;
-}
-INIT_BOARD_EXPORT(board_pin_init);
-#endif /* RT_USING_PIN */
+

+ 0 - 7
bsp/stm32/stm32f103-atk-nano/board/board.h

@@ -15,13 +15,6 @@
 #include <stm32f1xx.h>
 #include "drv_common.h"
 
-#ifdef BSP_USING_GPIO
-#include "drv_gpio.h"
-/* Board Pin definitions */
-#define LED0_PIN                       GET_PIN(C,  0)
-#define LED1_PIN                       GET_PIN(C,  1)
-#endif
-
 #define STM32_FLASH_START_ADRESS     ((uint32_t)0x08000000)
 #define STM32_FLASH_SIZE             (128 * 1024)
 #define STM32_FLASH_END_ADDRESS      ((uint32_t)(STM32_FLASH_START_ADRESS + STM32_FLASH_SIZE))

+ 10 - 1
bsp/stm32/stm32f103-fire-arbitrary/applications/main.c

@@ -11,14 +11,23 @@
 #include <rtthread.h>
 #include <rtdevice.h>
 #include <board.h>
+#include "drv_gpio.h"
+/* defined the LED0 pin: PF7 */
+#define LED0_PIN    GET_PIN(F, 7)
 
 int main(void)
 {
     int count = 1;
+    /* set LED0 pin mode to output */
+    rt_pin_mode(LED0_PIN, PIN_MODE_OUTPUT);
+
     while (count++)
     {
-        rt_pin_write(LED0_PIN, !rt_pin_read(LED0_PIN));
+        rt_pin_write(LED0_PIN, PIN_HIGH);
+        rt_thread_mdelay(500);
+        rt_pin_write(LED0_PIN, PIN_LOW);
         rt_thread_mdelay(500);
     }
+
     return RT_EOK;
 }

+ 0 - 11
bsp/stm32/stm32f103-fire-arbitrary/board/board.c

@@ -63,14 +63,3 @@ void MX_GPIO_Init(void)
     __HAL_RCC_GPIOC_CLK_ENABLE();
     __HAL_RCC_GPIOD_CLK_ENABLE();
 }
-
-#ifdef RT_USING_PIN
-int board_pin_init(void)
-{
-    rt_pin_mode(LED0_PIN, PIN_MODE_OUTPUT);
-    rt_pin_mode(LED1_PIN, PIN_MODE_OUTPUT);
-
-    return 0;
-}
-INIT_BOARD_EXPORT(board_pin_init);
-#endif /* RT_USING_PIN */

+ 0 - 7
bsp/stm32/stm32f103-fire-arbitrary/board/board.h

@@ -15,13 +15,6 @@
 #include <stm32f1xx.h>
 #include "drv_common.h"
 
-#ifdef BSP_USING_GPIO
-#include "drv_gpio.h"
-/* Board Pin definitions */
-#define LED0_PIN                       GET_PIN(F, 7)
-#define LED1_PIN                       GET_PIN(F, 8)
-#endif
-
 /* Internal SRAM memory size[Kbytes] <8-64>, Default: 64*/
 #define STM32_SRAM_SIZE      64
 #define STM32_SRAM_END       (0x20000000 + STM32_SRAM_SIZE * 1024)

+ 10 - 1
bsp/stm32/stm32f407-atk-explorer/applications/main.c

@@ -12,14 +12,23 @@
 #include <rtthread.h>
 #include <rtdevice.h>
 #include <board.h>
+#include "drv_gpio.h"
+/* defined the LED0 pin: PF9 */
+#define LED0_PIN    GET_PIN(F, 9)
 
 int main(void)
 {
     int count = 1;
+    /* set LED0 pin mode to output */
+    rt_pin_mode(LED0_PIN, PIN_MODE_OUTPUT);
+
     while (count++)
     {
-        rt_pin_write(LED1_PIN, !rt_pin_read(LED1_PIN));
+        rt_pin_write(LED0_PIN, PIN_HIGH);
+        rt_thread_mdelay(500);
+        rt_pin_write(LED0_PIN, PIN_LOW);
         rt_thread_mdelay(500);
     }
+
     return RT_EOK;
 }

+ 0 - 11
bsp/stm32/stm32f407-atk-explorer/board/board.c

@@ -67,14 +67,3 @@ void MX_GPIO_Init(void)
   __HAL_RCC_GPIOB_CLK_ENABLE();
 
 }
-
-#ifdef RT_USING_PIN
-int board_pin_init(void)
-{
-    rt_pin_mode(LED0_PIN, PIN_MODE_OUTPUT);
-    rt_pin_mode(LED1_PIN, PIN_MODE_OUTPUT);
-
-    return 0;
-}
-INIT_BOARD_EXPORT(board_pin_init);
-#endif /* RT_USING_PIN */

+ 0 - 7
bsp/stm32/stm32f407-atk-explorer/board/board.h

@@ -15,13 +15,6 @@
 #include <stm32f4xx.h>
 #include "drv_common.h"
 
-#ifdef BSP_USING_GPIO
-#include "drv_gpio.h"
-/* Board Pin definitions */
-#define LED0_PIN                       GET_PIN(F,  9)
-#define LED1_PIN                       GET_PIN(F, 10)
-#endif
-
 #define STM32_SRAM_SIZE        (128)
 #define STM32_SRAM_END         (0x20000000 + STM32_SRAM_SIZE * 1024)
 

+ 10 - 1
bsp/stm32/stm32f429-atk-apollo/applications/main.c

@@ -11,14 +11,23 @@
 #include <rtthread.h>
 #include <rtdevice.h>
 #include <board.h>
+#include "drv_gpio.h"
+/* defined the LED0 pin: PB1 */
+#define LED0_PIN    GET_PIN(B, 1)
 
 int main(void)
 {
     int count = 1;
+    /* set LED0 pin mode to output */
+    rt_pin_mode(LED0_PIN, PIN_MODE_OUTPUT);
+
     while (count++)
     {
-        rt_pin_write(LED1_PIN, !rt_pin_read(LED1_PIN));
+        rt_pin_write(LED0_PIN, PIN_HIGH);
+        rt_thread_mdelay(500);
+        rt_pin_write(LED0_PIN, PIN_LOW);
         rt_thread_mdelay(500);
     }
+
     return RT_EOK;
 }

+ 0 - 11
bsp/stm32/stm32f429-atk-apollo/board/board.c

@@ -77,14 +77,3 @@ void MX_GPIO_Init(void)
     __HAL_RCC_GPIOD_CLK_ENABLE();
     __HAL_RCC_GPIOG_CLK_ENABLE();
 }
-
-#ifdef RT_USING_PIN
-int board_pin_init(void)
-{
-    rt_pin_mode(LED0_PIN, PIN_MODE_OUTPUT);
-    rt_pin_mode(LED1_PIN, PIN_MODE_OUTPUT);
-
-    return 0;
-}
-INIT_BOARD_EXPORT(board_pin_init);
-#endif /* RT_USING_PIN */

+ 0 - 9
bsp/stm32/stm32f429-atk-apollo/board/board.h

@@ -15,10 +15,6 @@
 #include <stm32f4xx.h>
 #include "drv_common.h"
 
-#ifdef BSP_USING_GPIO
-#include "drv_gpio.h"
-#endif
-
 #define STM32_SRAM_SIZE           (192)
 #define STM32_SRAM_END            (0x20000000 + STM32_SRAM_SIZE * 1024)
 
@@ -39,12 +35,7 @@ extern int __bss_end;
 
 #define HEAP_END        STM32_SRAM_END
 
-/* Board Pin definitions */
-#define LED0_PIN                       GET_PIN(B, 1)
-#define LED1_PIN                       GET_PIN(B, 0)
-
 void SystemClock_Config(void);
 void MX_GPIO_Init(void);
 
 #endif
-

+ 10 - 1
bsp/stm32/stm32f429-fire-challenger/applications/main.c

@@ -12,14 +12,23 @@
 #include <rtthread.h>
 #include <rtdevice.h>
 #include <board.h>
+#include "drv_gpio.h"
+/* defined the LED0 pin: PH10 */
+#define LED0_PIN    GET_PIN(H, 10)
 
 int main(void)
 {
     int count = 1;
+    /* set LED0 pin mode to output */
+    rt_pin_mode(LED0_PIN, PIN_MODE_OUTPUT);
+
     while (count++)
     {
-        rt_pin_write(LED1_PIN, !rt_pin_read(LED1_PIN));
+        rt_pin_write(LED0_PIN, PIN_HIGH);
+        rt_thread_mdelay(500);
+        rt_pin_write(LED0_PIN, PIN_LOW);
         rt_thread_mdelay(500);
     }
+
     return RT_EOK;
 }

+ 0 - 11
bsp/stm32/stm32f429-fire-challenger/board/board.c

@@ -76,14 +76,3 @@ void MX_GPIO_Init(void)
   __HAL_RCC_GPIOG_CLK_ENABLE();
 
 }
-
-#ifdef RT_USING_PIN
-int board_pin_init(void)
-{
-    rt_pin_mode(LED0_PIN, PIN_MODE_OUTPUT);
-    rt_pin_mode(LED1_PIN, PIN_MODE_OUTPUT);
-
-    return 0;
-}
-INIT_BOARD_EXPORT(board_pin_init);
-#endif /* RT_USING_PIN */

+ 0 - 8
bsp/stm32/stm32f429-fire-challenger/board/board.h

@@ -15,10 +15,6 @@
 #include <stm32f4xx.h>
 #include "drv_common.h"
 
-#ifdef BSP_USING_GPIO
-#include "drv_gpio.h"
-#endif
-
 #define STM32_SRAM_SIZE           (192)
 #define STM32_SRAM_END            (0x20000000 + STM32_SRAM_SIZE * 1024)
 
@@ -39,10 +35,6 @@ extern int __bss_end;
 
 #define HEAP_END        STM32_SRAM_END
 
-/* Board Pin definitions */
-#define LED0_PIN                       GET_PIN(H, 10)
-#define LED1_PIN                       GET_PIN(H, 11)
-
 void SystemClock_Config(void);
 void MX_GPIO_Init(void);
 

+ 10 - 1
bsp/stm32/stm32l475-atk-pandora/applications/main.c

@@ -11,14 +11,23 @@
 #include <rtthread.h>
 #include <rtdevice.h>
 #include <board.h>
+#include "drv_gpio.h"
+/* defined the LED0 pin: PE7 */
+#define LED0_PIN    GET_PIN(E, 7)
 
 int main(void)
 {
     int count = 1;
+    /* set LED0 pin mode to output */
+    rt_pin_mode(LED0_PIN, PIN_MODE_OUTPUT);
+
     while (count++)
     {
-        rt_pin_write(LED0_PIN, !rt_pin_read(LED0_PIN));
+        rt_pin_write(LED0_PIN, PIN_HIGH);
+        rt_thread_mdelay(500);
+        rt_pin_write(LED0_PIN, PIN_LOW);
         rt_thread_mdelay(500);
     }
+
     return RT_EOK;
 }

+ 0 - 9
bsp/stm32/stm32l475-atk-pandora/board/board.c

@@ -74,12 +74,3 @@ void MX_GPIO_Init(void)
   __HAL_RCC_GPIOB_CLK_ENABLE();
 
 }
-
-#ifdef RT_USING_PIN
-int board_pin_init(void)
-{
-    rt_pin_mode(LED0_PIN, PIN_MODE_OUTPUT);
-    return 0;
-}
-INIT_BOARD_EXPORT(board_pin_init);
-#endif /* RT_USING_PIN */

+ 0 - 8
bsp/stm32/stm32l475-atk-pandora/board/board.h

@@ -15,10 +15,6 @@
 #include <stm32l4xx.h>
 #include "drv_common.h"
 
-#ifdef BSP_USING_GPIO
-#include "drv_gpio.h"
-#endif
-
 #define STM32_SRAM1_SIZE               (96)
 #define STM32_SRAM1_START              (0x20000000)
 #define STM32_SRAM1_END                (STM32_SRAM1_START + STM32_SRAM1_SIZE * 1024)
@@ -30,10 +26,6 @@
 #define HEAP_BEGIN                     STM32_SRAM1_START
 #define HEAP_END                       STM32_SRAM1_END
 
-/* Board Pin definitions */
-#define LED0_PIN                       GET_PIN(E, 7)
-#define LED1_PIN                       GET_PIN(E, 8)
-
 void SystemClock_Config(void);
 void MX_GPIO_Init(void);