27 volatile uint32_t ticks = cpu_freq / 1000u;
29 SysTick->LOAD = ticks - 1u;
31 SysTick->CTRL = SysTick_CTRL_CLKSOURCE_Msk |
32 SysTick_CTRL_TICKINT_Msk |
33 SysTick_CTRL_ENABLE_Msk;
35 *(
volatile uint32_t *)0xE000ED20UL &= ~(0xFFUL << 24);
36 *(
volatile uint32_t *)0xE000ED20UL |= ((uint32_t)1u << (8U - __NVIC_PRIO_BITS)) << 24;
45 " ldr r0, =0xE000ED08 \n"
69 void (*pf_task)(
void *),
72 uint32_t *p_stack_ptr;
74 p_stack_ptr = &p_stack[stack_size - (uint32_t)1];
75 p_stack_ptr = (uint32_t *)(((uint32_t)p_stack_ptr) & (~((uint32_t)0x007)));
77 *(--p_stack_ptr) = (uint32_t)0x01000000UL;
78 *(--p_stack_ptr) = ((uint32_t)pf_task) & ((uint32_t)0xfffffffeUL);
79 *(--p_stack_ptr) = (uint32_t)0x0000000EUL;
81 *p_stack_ptr = (uint32_t)p_arg;
98 "ldr r1, =tcb_curr_ptr \n"
103 "ldmia r0!, {r4-r7} \n"
112 "ldmia r0!, {r4-r7} \n"
137 "cbz r0, OS_CPU_PendSVHandler_nosave \n"
140 "stmia r0!, {r4-r7} \n"
145 "stmia r0!, {r4-r7} \n"
148 "ldr r1, =tcb_curr_ptr \n"
154 "OS_CPU_PendSVHandler_nosave: \n"
155 "ldr r0, =tcb_curr_ptr \n"
156 "ldr r1, =tcb_high_rdy_ptr \n"
162 "ldmia r0!, {r4-r7} \n"
171 "ldmia r0!, {r4-r7} \n"
193 port_disable_interrupts
199 port_trigger_PendSV();
201 port_enable_interrupts
Build-time configuration macros for AK-mOS.
Kernel control and critical-section API.
CMSIS Cortex-M Core Function Access Header File.
uint32_t * akos_port_task_stack_init(uint32_t *p_stack, size_t stack_size, void(*pf_task)(void *), void *p_arg)
Build the initial Cortex-M thread stack frame.
void port_PendSVHandler(void)
PendSV handler used for context switching between threads.
void port_SVCHandler(void)
SVC handler used to restore the first thread context.
void port_SysTickHandler()
SysTick ISR hook for scheduler tick updates.
void akos_port_start_first_task(void)
Start the first thread by restoring the initial exception context.
void akos_port_systick_init_freq(uint32_t cpu_freq)
Initialize SysTick to generate 1ms OS ticks.
Cortex-M3 port API for AKOS.
Thread scheduling and thread messaging APIs.
uint8_t akos_thread_increment_tick(void)
Tick handler routine called from SysTick.