diff --git a/board/STM8L052R8T6/USER/main.c b/board/STM8L052R8T6/USER/main.c index 0edb4729..eea2cc79 100644 --- a/board/STM8L052R8T6/USER/main.c +++ b/board/STM8L052R8T6/USER/main.c @@ -5,37 +5,34 @@ #include "rtc.h" #include "tim.h" +// this is a stm8 rtc demo UART1 print,the baud rate is 57600. +// LED GPIOB0 -//this is a stm8 rtc demo UART1 print,the baud rate is 57600. -//LED GPIOB0 - -//Init LED IO +// Init LED IO void LED_GPIO_Init(void) { GPIO_Init(GPIOB, GPIO_Pin_0, GPIO_Mode_Out_PP_Low_Slow); } -//set the GPIOB0 Pin to high +// set the GPIOB0 Pin to high void LED_On(void) { GPIO_SetBits(GPIOB, GPIO_Pin_0); } -//set the GPIOB0 Pin to low +// set the GPIOB0 Pin to low void LED_Off(void) { GPIO_ResetBits(GPIOB, GPIO_Pin_0); } -//About 1 second, not exactly, just for demonstration purposes +// About 1 second, not exactly, just for demonstration purposes void Delay(unsigned int time) { unsigned int i; - while (time--) - { - for (i = 300; i > 0; i--) - { + while (time--) { + for (i = 300; i > 0; --i) { asm("nop"); } } @@ -60,45 +57,6 @@ void disp_rtc(void) UART1_Send_String(" \r\n"); } -#if 0 -int main(void) -{ - LED_GPIO_Init(); - LED_On(); - - UART1_Init(57600); //Init the UART1 and the baud rate is 57600 - UART1_Send_String("RTC Demo Code\r\n"); - - RTC_Setting_Init(); //Init RTC - - while (1) - { - - RTC_Get_Time(); - UART1_Send_String("Current Time:"); - UART1_Send_Dec(clock.cYear, 2); //YY-MM-DD - UART1_Send_String("-"); - UART1_Send_Dec(clock.cMonth, 2); - UART1_Send_String("-"); - UART1_Send_Dec(clock.cDay, 2); - - UART1_Send_String(" "); //HH:MM:SS - UART1_Send_Dec(clock.cHour, 2); - UART1_Send_String(":"); - UART1_Send_Dec(clock.cMinute, 2); - UART1_Send_String(":"); - UART1_Send_Dec(clock.cSecond, 2); - UART1_Send_String(" "); - - LED_On(); - Delay(200); - LED_Off(); - Delay(200); - } -} - -#endif - void task1_entry(void *arg) { while (1) { @@ -139,12 +97,11 @@ int main(void) 4, task1_stack, sizeof(task1_stack), 0); -#if 1 + tos_task_create(&task2, "task2", task2_entry, NULL, 4, task2_stack, sizeof(task2_stack), 0); -#endif tos_knl_start();