找到STM32F407的demos程序(chibiosdemosSTM32RT-STM32F407-DISCOVERY)
/*
* 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) {
palSetPad(GPIOD, GPIOD_LED3); /* Orange. 根据个人开发板配置*/
chThdSleepMilliseconds(500);
palClearPad(GPIOD, GPIOD_LED3); /* Orange. */
chThdSleepMilliseconds(500);
}
}
/*
* 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();
/*
* Activates the serial driver 2 using the driver default configuration.
* PA2(TX) and PA3(RX) are routed to USART2.
*/
sdStart(&SD2, NULL); //SD2,代表UART2
palSetPadMode(GPIOA, 2, PAL_MODE_ALTERNATE(7)); //UART TX
palSetPadMode(GPIOA, 3, PAL_MODE_ALTERNATE(7)); //UART RX
/*
* Creates the example thread. 创建线程
*/
chThdCreateStatic(waThread1, sizeof(waThread1), NORMALPRIO, 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 (palReadPad(GPIOA, GPIOA_BUTTON))
TestThread(&SD2);
chThdSleepMilliseconds(500);
}
}
使用烧写工具烧写。效果是串口不断打印TestThread中的信息,LED不断闪烁
上一篇:stm32 CAN过滤器组
下一篇:zubax_gnss移植到STM32F407
推荐阅读最新更新时间:2024-11-12 10:21
设计资源 培训 开发板 精华推荐
- 用于开/关控制应用的 AM2G-2415SZ 15V 2 瓦 DC-DC 转换器的典型应用
- AZ1117E 1.0A LOW DROPOUT LINEAR REGULATOR For Adjustable Version 典型应用
- 使用 Analog Devices 的 LTC1538IG-AUX 的参考设计
- NCP301LSN45T1 4.5V 窗口电压检测器的典型应用
- TWR-IND-IO: 工业I/O塔式系统模块
- SY58013U,用于 SONET 的 6000MHz 时钟缓冲器的评估板
- ARDUINO NANO GRBL1.1F:基于arduino的三轴写字机
- LTC3125EDCB 演示板,具有输入电流限制的 1.5A 同步升压型 DC/DC 转换器
- NCV8402AMNWT1GEVB:NCV8402A DFN6 WF 评估板
- 使用 AD9051、10 位、60 Msps A/D 转换器实现单电源、单端、直流耦合的典型应用