18#include "core_cmFunc.h"
19#include "stm32f030x6.h"
28 volatile uint32_t ticks = cpu_freq / 1000u;
30 SysTick->LOAD = ticks - 1u;
32 SysTick->CTRL = SysTick_CTRL_CLKSOURCE_Msk | SysTick_CTRL_TICKINT_Msk |
33 SysTick_CTRL_ENABLE_Msk;
35 *(
volatile uint32_t*)0xE000ED20UL &= ~(0xFFUL << 24);
36 *(
volatile uint32_t*)0xE000ED20UL |= ((1 << __NVIC_PRIO_BITS) - 2)
37 << (32 - __NVIC_PRIO_BITS);
46 " ldr r0, =0xE000ED08 \n"
70 void (*pf_task)(
void*),
void* p_arg)
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;
99 "ldr r1, =tcb_curr_ptr \n"
105 "ldmia r0!, {r4-r7} \n"
114 "ldmia r0!, {r4-r7} \n"
143 "beq OS_CPU_PendSVHandler_nosave \n"
148 "stmia r0!, {r4-r7} \n"
153 "stmia r0!, {r4-r7} \n"
156 "ldr r1, =tcb_curr_ptr \n"
164 "OS_CPU_PendSVHandler_nosave: \n"
165 "ldr r0, =tcb_curr_ptr \n"
167 "ldr r1, =tcb_high_rdy_ptr \n"
175 "ldmia r0!, {r4-r7} \n"
186 "ldmia r0!, {r4-r7} \n"
212 port_disable_interrupts
218 port_trigger_PendSV();
220 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.