Files
TencentOS-tiny/board/NXP_Kinetis_K64/BSP/Src/main.c
2019-09-29 15:31:28 +08:00

89 lines
2.1 KiB
C
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
#include "gpio.h"
#include "common.h"
#include "uart.h"
#include "cmsis_os.h"
/* CH Kinetis固件库 V2.50 版本 */
/* 修改主频 请使用 CMSIS标准文件 system_MKxxxx.c 中的 CLOCK_SETUP 宏 */
/* UART 快速初始化结构所支持的引脚* 使用时还是推荐标准初始化 */
/*
UART1_RX_PE01_TX_PE00
UART0_RX_PF17_TX_PF18
UART3_RX_PE05_TX_PE04
UART5_RX_PF19_TX_PF20
UART5_RX_PE09_TX_PE08
UART2_RX_PE17_TX_PE16
UART4_RX_PE25_TX_PE24
UART0_RX_PA01_TX_PA02
UART0_RX_PA15_TX_PA14
UART3_RX_PB10_TX_PB11
UART0_RX_PB16_TX_PB17
UART1_RX_PC03_TX_PC04
UART4_RX_PC14_TX_PC15
UART3_RX_PC16_TX_PC17
UART2_RX_PD02_TX_PD03
UART0_RX_PD06_TX_PD07
UART2_RX_PF13_TX_PF14
UART5_RX_PD08_TX_PD09
*/
#define APPLICATION_TASK_STK_SIZE 1024
extern void application_entry(void *arg);
osThreadDef(application_entry, osPriorityNormal, 1, APPLICATION_TASK_STK_SIZE);
#define TASK1_STK_SIZE 512
void task1(void *arg);
osThreadDef(task1, osPriorityNormal, 1, TASK1_STK_SIZE);
#define TASK2_STK_SIZE 512
void task2(void *arg);
osThreadDef(task2, osPriorityNormal, 1, TASK2_STK_SIZE);
void SysTick_Handler(void)
{
if(tos_knl_is_running())
{
tos_knl_irq_enter();
tos_tick_handler();
tos_knl_irq_leave();
}
}
void task1(void *arg)
{
int count = 1;
while (1) {
printf("###This is task1, %d\r\n", count++);
osDelay(2000);
}
}
void task2(void *arg)
{
int count = 1;
while (1) {
printf("***This is task2, %d\r\n", count++);
osDelay(1000);
}
}
void application_entry(void *arg)
{
osThreadCreate(osThread(task1), NULL); // Create task1
osThreadCreate(osThread(task2), NULL); // Create task2
}
int main(void)
{
DelayInit();
/* 初始化一个引脚 设置为推挽输出 */
GPIO_QuickInit(HW_GPIOE, 6, kGPIO_Mode_OPP);
/* 初始化一个串口 使用UART0端口的PTD6引脚和PTD7引脚作为接收和发送默认设置 baud 115200 */
UART_QuickInit(UART0_RX_PD06_TX_PD07, 115200);
printf("Welcome to TencentOS tiny\r\n");
osKernelInitialize();
osThreadCreate(osThread(application_entry), NULL);
osKernelStart();
}