19#include "core_cmFunc.h"
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"
101 "LDMIA R0!, {R4-R11} \n"
124 "CBZ R0, OS_CPU_PendSVHandler_nosave \n"
126 "SUBS R0, R0, #0x20 \n"
127 "STM R0, {R4-R11} \n"
129 "LDR R1, =tcb_curr_ptr \n"
135 "OS_CPU_PendSVHandler_nosave: \n"
136 "LDR R0, =tcb_curr_ptr \n"
137 "LDR R1, =tcb_high_rdy_ptr \n"
142 "LDM R0, {R4-R11} \n"
143 "ADDS R0, R0, #0x20 \n"
145 "ORR LR, LR, #0x04 \n"
163 port_disable_interrupts
169 port_trigger_PendSV();
171 port_enable_interrupts
Build-time configuration macros for AK-mOS.
Kernel control and critical-section API.
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.