很好的一個(gè)DIY,不敢獨(dú)享,特分享給大家!
一、硬件: 某寶搜索“stm32f103c8t6最小系統(tǒng)板”,實(shí)物如下圖所示: 二、軟件: 2.1、從arduino官網(wǎng)https://www.下載Arduino IDE,我下載的是zip免安裝版本,文件名:arduino-1.8.7-windows.zip; 2.2、從https://github.com/rogerclarkmelbourne/Arduino_STM32下載stm32的arduino硬件庫(kù),文件名:Arduino_STM32-master.zip; 2.3、從https://github.com/rogerclarkmelbourne/STM32duino-bootloader下載bootloader文件,文件名:STM32duino-bootloader-master.zip; 2.4、從https://developer./open-source/gnu-toolchain/gnu-rm下載GNU Arm Embedded Toolchain,文件名:gcc-arm-none-eabi-7-2018-q2-update-win32.zip
2.5、解壓以上四個(gè)壓縮包; 2.6、把Arduino_STM32-master文件夾改名為Arduino_STM32并移動(dòng)到arduino-1.8.7\hardware目錄下; 2.7、把gcc-arm-none-eabi-7-2018-q2-update-win32移動(dòng)到arduino-1.8.7\hardware\Arduino_STM32\tools目錄下; 2.8、在arduino-1.8.7\hardware\Arduino_STM32\STM32F1\platform.txt中添加目錄定義,如下兩行: runtime.hardware.path=./hardware/Arduino_STM32 runtime.tools.arm-none-eabi-gcc.path=./hardware/Arduino_STM32/tools/gcc-arm-none-eabi-7-2018-q2-update-win32 2.9、把a(bǔ)rduino-1.8.7\hardware\Arduino_STM32\tools\gcc-arm-none-eabi-7-2018-q2-update-win32\arm-none-eabi\include\sys\cdefs.h中的宏定義__always_inline改為: //#define __always_inline __inline__ __attribute__((__always_inline__)) #define __always_inline __attribute__((__always_inline__)) 2.10、運(yùn)行arduino-1.8.7\hardware\Arduino_STM32\drivers\win\install_drivers.bat安裝驅(qū)動(dòng),驅(qū)動(dòng)包括Maple DFU driver和Maple Serial driver, 其中Maple DFU driver用于更新程序,Maple Serial driver用于USB轉(zhuǎn)串口。 三、操作: 3.1、使用串口或仿真器stlink燒錄"STM32duino-bootloader-master.zip\STM32duino-bootloader-master\bootloader_only_binaries\generic_boot20_pc13.bin"文件到stm32f103c8t6最小系統(tǒng)板; 3.2、使用usb數(shù)據(jù)線直接連接stm32f103c8t6最小系統(tǒng)板的Micro USB接口,根據(jù)提示安裝驅(qū)動(dòng);
3.3、運(yùn)行arduino ide,文件\新建,并設(shè)置開(kāi)發(fā)板,如下圖所示: 3.4、添加程序: #include <MapleFreeRTOS900.h>
#define BOARD_LED_PIN PC13
static void vLEDFlashTask(void *pvParameters) { for (;;) { vTaskDelay(500); digitalWrite(BOARD_LED_PIN, HIGH); vTaskDelay(500); digitalWrite(BOARD_LED_PIN, LOW); } }
static void vSerialTask(void *pvParameters) { for (;;) { Serial.println("LED OFF"); while(!(digitalRead(BOARD_LED_PIN))); Serial.println("LED ON"); while((digitalRead(BOARD_LED_PIN))); } }
void setup() { // initialize the digital pin as an output: pinMode(BOARD_LED_PIN, OUTPUT); Serial.begin(9600); xTaskCreate(vLEDFlashTask, "Task1", configMINIMAL_STACK_SIZE, NULL, tskIDLE_PRIORITY + 2, NULL); xTaskCreate(vSerialTask, "Task2", configMINIMAL_STACK_SIZE, NULL, tskIDLE_PRIORITY + 2, NULL); vTaskStartScheduler(); }
void loop() { // Insert background code here } 3.5、驗(yàn)證/編譯并上傳,運(yùn)行效果如下:
|