void OS_CPU_SysTickInit (void) { INT32U cnts; cnts = OS_CPU_SysTickClkFreq() / OS_TICKS_PER_SEC; OS_CPU_CM3_NVIC_ST_RELOAD = (cnts - 1); /* Enable timer. */ OS_CPU_CM3_NVIC_ST_CTRL |= OS_CPU_CM3_NVIC_ST_CTRL_CLK_SRC | OS_CPU_CM3_NVIC_ST_CTRL_ENABLE; /* Enable timer interrupt. */ OS_CPU_CM3_NVIC_ST_CTRL |= OS_CPU_CM3_NVIC_ST_CTRL_INTEN; }
void OS_CPU_SysTickInit (void) { INT32U cnts; cnts = OS_CPU_SysTickClkFreq() / OS_TICKS_PER_SEC; OS_CPU_CM3_NVIC_ST_RELOAD = (cnts - 1); /* Set prio of SysTick handler to min prio. */ OS_CPU_CM3_NVIC_PRIO_ST = OS_CPU_CM3_NVIC_PRIO_MIN; /* Enable timer. */ OS_CPU_CM3_NVIC_ST_CTRL |= OS_CPU_CM3_NVIC_ST_CTRL_CLK_SRC | OS_CPU_CM3_NVIC_ST_CTRL_ENABLE; /* Enable timer interrupt. */ OS_CPU_CM3_NVIC_ST_CTRL |= OS_CPU_CM3_NVIC_ST_CTRL_INTEN; }
/* ********************************************************************************************************* * AppTaskStart() * * Description : The startup task. The uC/OS-III ticker should only be initialize once multitasking starts. * * Argument(s) : p_arg Argument passed to 'AppTaskStart()' by 'OSTaskCreate()'. * * Return(s) : none. * * Note(s) : (1) The first line of code is used to prevent a compiler warning because 'p_arg' is not * used. The compiler should not generate any code for this statement. * * (2) Interrupts are enabled once the task starts because the I-bit of the CCR register was * set to 0 by 'OSTaskCreate()'. ********************************************************************************************************* */ static void App_TaskStart(void *p_arg) { uint16_t osVersion1, osVersion2, osVersion3; OS_ERR err = OS_ERR_NONE; (void)p_arg; /* Note(1) */ /* Initialize BSP functions */ BSPOS_Init(); /* Initialize the uC/OS-III ticker */ OS_CPU_SysTickInit(OS_CPU_SysTickClkFreq() / OS_CFG_TICK_RATE_HZ); #if (OS_TASK_STAT_EN > 0U) /* Determine CPU capacity */ OSStatInit(); #endif /* Create application tasks */ App_TaskCreate(); /* Create application mailboxes */ App_MailboxCreate(); /* Enable RS232A peripheral */ BSP_PeripheralAccess(BSP_RS232A, true); /* Initialize Serial */ RETARGET_SerialInit(); /* Map LF to CRLF */ RETARGET_SerialCrLf(1); /* Initialize LCD */ SegmentLCD_Init(true); /* Turn gecko symbol ON */ SegmentLCD_Symbol(LCD_SYMBOL_GECKO, 1); /* Turn EFM32 symbol ON */ SegmentLCD_Symbol(LCD_SYMBOL_EFM32, 1); /* Write welcome message on LCD */ SegmentLCD_Write("uC/OS-3"); osVersion3 = OSVersion( &err ); osVersion1 = osVersion3 / 10000; osVersion3 -= osVersion1 * 10000; osVersion2 = osVersion3 / 100; osVersion3 -= osVersion2 * 100; osVersion3 %= 100; /* Write welcome message on serial */ printf("\n*****************************************************************************"); printf("\n uC/OS-III v%d.%02d.%02d on Energy Micro EFM32 DVK ", osVersion1, osVersion2, osVersion3 ); printf("\n Demo Application \n"); printf("\n uC/OS-III "); printf("\n \"The real time kernel\" "); printf("\n www.micrium.com "); printf("\n\n is running on "); printf("\n\n Energy Micro EFM32 "); printf("\n \"The world's most energy friendly microcontrollers\" "); printf("\n www.energymicro.com \n"); printf("\nDescription:"); printf("\nTask1: LED blink task"); printf("\nTask2: Receives characters from serial and posts message to Task3"); printf("\nTask3: Receives message from Task2 and writes it on LCD and serial "); printf("\n*****************************************************************************\n"); printf("\nStart typing...\n"); /* Suspend this task as it is only used once in one Reset cycle */ OSTaskSuspend(&AppTaskStartTCB, &err); /* Error had occured if code execution reached this point as suspend calls the scheduler * that performs a context switch */ while (1U) ; }
/* ********************************************************************************************************* * AppTaskStart() * * Description : The startup task. The uC/OS-III ticker should only be initialize once multitasking starts. * * Argument(s) : p_arg Argument passed to 'AppTaskStart()' by 'OSTaskCreate()'. * * Return(s) : none. * * Note(s) : (1) The first line of code is used to prevent a compiler warning because 'p_arg' is not * used. The compiler should not generate any code for this statement. * * (2) Interrupts are enabled once the task starts because the I-bit of the CCR register was * set to 0 by 'OSTaskCreate()'. ********************************************************************************************************* */ static void App_TaskStart(void *p_arg) { uint16_t osVersion1, osVersion2, osVersion3; OS_ERR err = OS_ERR_NONE; (void)p_arg; /* Note(1) */ /* Initialize BSP functions */ BSPOS_Init(); /* Initialize the uC/OS-III ticker */ OS_CPU_SysTickInit(OS_CPU_SysTickClkFreq() / OS_CFG_TICK_RATE_HZ); #if (OS_TASK_STAT_EN > 0U) /* Determine CPU capacity */ OSStatInit(); #endif /* Create application tasks */ App_TaskCreate(); /* Create application mailboxes */ App_MailboxCreate(); /* Initialize LCD */ SegmentLCD_Init(true); /* Turn gecko symbol ON */ SegmentLCD_Symbol(LCD_SYMBOL_GECKO, 1); /* Turn EFM32 symbol ON */ SegmentLCD_Symbol(LCD_SYMBOL_EFM32, 1); /* Write welcome message on LCD */ SegmentLCD_Write("uC/OS-3"); /* As USART connectors are not available on the STK by default, * therefore printf() functions are turned off. * Uncomment the macro definition in includes.h if serial * is connected to your STK board (USART1 or LEUART0)! */ #ifdef USART_CONNECTED /* Initialize serial port */ RETARGET_SerialInit(); RETARGET_SerialCrLf(1); osVersion3 = OSVersion( &err ); osVersion1 = osVersion3 / 10000; osVersion3 -= osVersion1 * 10000; osVersion2 = osVersion3 / 100; osVersion3 -= osVersion2 * 100; osVersion3 %= 100; /* Write welcome message on serial */ printf("\n*****************************************************************************"); printf("\n uC/OS-III v%d.%02d.%02d on Energy Micro EFM32 STK ", osVersion1, osVersion2, osVersion3 ); printf("\n Demo Application \n"); printf("\n uC/OS-III "); printf("\n \"The real time kernel\" "); printf("\n www.micrium.com "); printf("\n\n is running on "); printf("\n\n Energy Micro EFM32 "); printf("\n \"The world's most energy friendly microcontrollers\" "); printf("\n www.energymicro.com \n"); printf("\nDescription:"); printf("\nTask1: LED blink task"); printf("\nTask2: Receives characters from serial and posts message to Task3"); printf("\nTask3: Receives message from Task2 and writes it on LCD and serial."); printf("\n*****************************************************************************\n"); printf("\nStart typing...\n"); #endif /* end of #ifndef USART_CONNECTED */ /* Suspend this task as it is only used once in one Reset cycle */ OSTaskSuspend(&AppTaskStartTCB, &err); /* Error had occured if code execution reached this point as suspend calls the scheduler * that performs a context switch */ while (1U) ; }