移植chibios系统到STM32F723开发板。
一、软件下载
1.1、chibios官网地址:
http://www.chibios.org/dokuwiki/doku.php
1.2、chibistudio开发软件
下载地址:https://nchc.dl.sourceforge.net/project/chibios/ChibiStudio%20Windows/ChibiStudio_Windows_2023-02.7z
将下载的软件解压到C盘
点击Chibi_studio GCC图标即可打开软件
二、打开工程
2.1、打开工程
这里面有的STM32开发型号的,可以直接打开运行,没有的型号,就需要自己创建功能。
2.2、STM32F723工程
已有的工程项目中没有找到STM32F723型号的开发板,就需要自己创建相应的型号,可以在已有型号比较接近的开发中,复制再修改。打开创建的STM32F723的工程。
2.3、根据开发板硬件的接口,修改要测试端口。
main.c
#include "ch.h"
#include "hal.h"
#include "rt_test_root.h"
#include "oslib_test_root.h"
/*
* This is a periodic thread that does absolutely nothing except flashing
* a LED.
*/
static THD_WORKING_AREA(waThread1, 128);
static THD_FUNCTION(Thread1, arg) {
(void)arg;
chRegSetThreadName("blinker");
while (true) {
palSetLine(LINE_LED5);
chThdSleepMilliseconds(100);
palClearLine(LINE_LED5);
chThdSleepMilliseconds(100);
palSetLine(LINE_LED6);
chThdSleepMilliseconds(100);
palClearLine(LINE_LED6);
chThdSleepMilliseconds(100);
}
}
/*
* Application entry point.
*/
int main(void) {
/*
* System initializations.
* - HAL initialization, this also initializes the configured device drivers
* and performs the board-specific initializations.
* - Kernel initialization, the main() function becomes a thread and the
* RTOS is active.
*/
halInit();
chSysInit();
/*
* ARD_D13 is programmed as output (board LED).
*/
palSetLine(LINE_LED6);
palSetLineMode(LINE_LED6, PAL_MODE_OUTPUT_PUSHPULL);
/*
* Activates the serial driver 1 using the driver default configuration.
*/
sdStart(&SD6, NULL);
/*
* Creates the example thread.
*/
chThdCreateStatic(waThread1, sizeof(waThread1), NORMALPRIO+1, Thread1, NULL);
/*
* Normal main() thread activity, in this demo it does nothing except
* sleeping in a loop and check the button state.
*/
while (true) {
if (palReadLine(LINE_BUTTON_USER)) {
test_execute((BaseSequentialStream *)&SD6, &rt_test_suite);
test_execute((BaseSequentialStream *)&SD6, &oslib_test_suite);
}
chThdSleepMilliseconds(500);
}
}
2.4、编译项目
编译完成后,会生成ch.hex文件,可以烧写到开发板运行
三、程序运行
烧写到开发板后,复位开发板运行
LD5和LD6轮询点亮。
按下按键B1,串口输出
|
再接再厉