77 #ifndef configKERNEL_INTERRUPT_PRIORITY
78 #define configKERNEL_INTERRUPT_PRIORITY 255
81 #ifndef configSYSTICK_CLOCK_HZ
82 #define configSYSTICK_CLOCK_HZ configCPU_CLOCK_HZ
84 #define portNVIC_SYSTICK_CLK_BIT ( 1UL << 2UL )
88 #define portNVIC_SYSTICK_CLK_BIT ( 0 )
92 #define portNVIC_SYSTICK_CTRL_REG ( * ( ( volatile uint32_t * ) 0xe000e010 ) )
93 #define portNVIC_SYSTICK_LOAD_REG ( * ( ( volatile uint32_t * ) 0xe000e014 ) )
94 #define portNVIC_SYSTICK_CURRENT_VALUE_REG ( * ( ( volatile uint32_t * ) 0xe000e018 ) )
95 #define portNVIC_SYSPRI2_REG ( * ( ( volatile uint32_t * ) 0xe000ed20 ) )
97 #define portNVIC_SYSTICK_INT_BIT ( 1UL << 1UL )
98 #define portNVIC_SYSTICK_ENABLE_BIT ( 1UL << 0UL )
99 #define portNVIC_SYSTICK_COUNT_FLAG_BIT ( 1UL << 16UL )
100 #define portNVIC_PENDSVCLEAR_BIT ( 1UL << 27UL )
101 #define portNVIC_PEND_SYSTICK_CLEAR_BIT ( 1UL << 25UL )
103 #define portNVIC_PENDSV_PRI ( ( ( uint32_t ) configKERNEL_INTERRUPT_PRIORITY ) << 16UL )
104 #define portNVIC_SYSTICK_PRI ( ( ( uint32_t ) configKERNEL_INTERRUPT_PRIORITY ) << 24UL )
107 #define portFIRST_USER_INTERRUPT_NUMBER ( 16 )
108 #define portNVIC_IP_REGISTERS_OFFSET_16 ( 0xE000E3F0 )
109 #define portAIRCR_REG ( * ( ( volatile uint32_t * ) 0xE000ED0C ) )
110 #define portMAX_8_BIT_VALUE ( ( uint8_t ) 0xff )
111 #define portTOP_BIT_OF_BYTE ( ( uint8_t ) 0x80 )
112 #define portMAX_PRIGROUP_BITS ( ( uint8_t ) 7 )
113 #define portPRIORITY_GROUP_MASK ( 0x07UL << 8UL )
114 #define portPRIGROUP_SHIFT ( 8UL )
117 #define portINITIAL_XPSR ( 0x01000000UL )
120 #define portMAX_24_BIT_NUMBER ( 0xffffffUL )
125 #define portMISSED_COUNTS_FACTOR ( 45UL )
130 #ifdef configTASK_RETURN_ADDRESS
131 #define portTASK_RETURN_ADDRESS configTASK_RETURN_ADDRESS
133 #define portTASK_RETURN_ADDRESS prvTaskExitError
157 static
void prvPortStartFirstTask(
void )
__attribute__ (( naked ));
162 static
void prvTaskExitError(
void );
169 #if configUSE_TICKLESS_IDLE == 1
170 static uint32_t ulTimerCountsForOneTick = 0;
177 #if configUSE_TICKLESS_IDLE == 1
178 static uint32_t xMaximumPossibleSuppressedTicks = 0;
185 #if configUSE_TICKLESS_IDLE == 1
186 static uint32_t ulStoppedTimerCompensation = 0;
194 #if ( configASSERT_DEFINED == 1 )
195 static uint8_t ucMaxSysCallPriority = 0;
196 static uint32_t ulMaxPRIGROUPValue = 0;
223 static void prvTaskExitError(
void )
240 " ldr r3, pxCurrentTCBConst2 \n"
243 " ldmia r0!, {r4-r11} \n"
247 " msr basepri, r0 \n"
252 "pxCurrentTCBConst2: .word pxCurrentTCB \n"
257 static void prvPortStartFirstTask(
void )
260 " ldr r0, =0xE000ED08 \n"
282 #if( configASSERT_DEFINED == 1 )
284 volatile uint32_t ulOriginalPriority;
286 volatile uint8_t ucMaxPriorityValue;
294 ulOriginalPriority = *pucFirstUserPriorityRegister;
301 ucMaxPriorityValue = *pucFirstUserPriorityRegister;
311 ulMaxPRIGROUPValue--;
312 ucMaxPriorityValue <<= ( uint8_t ) 0x01;
322 *pucFirstUserPriorityRegister = ulOriginalPriority;
335 uxCriticalNesting = 0;
338 prvPortStartFirstTask();
366 __asm
volatile(
"dsb" );
367 __asm
volatile(
"isb" );
375 __asm
volatile(
"dsb" );
376 __asm
volatile(
"isb" );
384 if( uxCriticalNesting == 0 )
395 " mrs r0, basepri \n" \
397 " msr basepri, r1 \n" \
412 " msr basepri, r0 \n" \
418 ( void ) ulNewMaskValue;
431 " ldr r3, pxCurrentTCBConst \n"
434 " stmdb r0!, {r4-r11} \n"
437 " stmdb sp!, {r3, r14} \n"
439 " msr basepri, r0 \n"
440 " bl vTaskSwitchContext \n"
442 " msr basepri, r0 \n"
443 " ldmia sp!, {r3, r14} \n"
447 " ldmia r0!, {r4-r11} \n"
453 "pxCurrentTCBConst: .word pxCurrentTCB \n"
479 #if configUSE_TICKLESS_IDLE == 1
483 uint32_t ulReloadValue, ulCompleteTickPeriods, ulCompletedSysTickDecrements, ulSysTickCTRL;
487 if( xExpectedIdleTime > xMaximumPossibleSuppressedTicks )
489 xExpectedIdleTime = xMaximumPossibleSuppressedTicks;
502 if( ulReloadValue > ulStoppedTimerCompensation )
504 ulReloadValue -= ulStoppedTimerCompensation;
509 __asm
volatile(
"cpsid i" );
528 __asm
volatile(
"cpsie i" );
547 xModifiableIdleTime = xExpectedIdleTime;
549 if( xModifiableIdleTime > 0 )
551 __asm
volatile(
"dsb" );
552 __asm
volatile(
"wfi" );
553 __asm
volatile(
"isb" );
566 __asm
volatile(
"cpsie i" );
570 uint32_t ulCalculatedLoadValue;
581 if( ( ulCalculatedLoadValue < ulStoppedTimerCompensation ) || ( ulCalculatedLoadValue > ulTimerCountsForOneTick ) )
583 ulCalculatedLoadValue = ( ulTimerCountsForOneTick - 1UL );
593 ulCompleteTickPeriods = xExpectedIdleTime - 1UL;
605 ulCompleteTickPeriods = ulCompletedSysTickDecrements / ulTimerCountsForOneTick;
638 #if configUSE_TICKLESS_IDLE == 1
652 #if( configASSERT_DEFINED == 1 )
654 void vPortValidateInterruptPriority(
void )
656 uint32_t ulCurrentInterrupt;
657 uint8_t ucCurrentPriority;
660 __asm
volatile(
"mrs %0, ipsr" :
"=r"( ulCurrentInterrupt ) );
666 ucCurrentPriority = pcInterruptPriorityRegisters[ ulCurrentInterrupt ];
691 configASSERT( ucCurrentPriority >= ucMaxSysCallPriority );
#define portNVIC_SYSTICK_CLK_BIT
BaseType_t xPortStartScheduler(void)
void xPortPendSVHandler(void xPortSysTickHandler void)
#define portMISSED_COUNTS_FACTOR
void xPortSysTickHandler(void)
#define portENABLE_INTERRUPTS()
void vPortClearInterruptMask(uint32_t ulNewMaskValue)
#define portDISABLE_INTERRUPTS()
#define portPRIGROUP_SHIFT
#define portCLEAR_INTERRUPT_MASK_FROM_ISR(uxSavedStatusValue)
#define portTOP_BIT_OF_BYTE
void vPortEnterCritical(void)
#define portNVIC_SYSPRI2_REG
void vPortSVCHandler(void)
unsigned long UBaseType_t
void vPortEndScheduler(void)
#define portNVIC_SYSTICK_PRI
void vPortSuppressTicksAndSleep(TickType_t xExpectedIdleTime)
void vTaskStepTick(const TickType_t xTicksToJump) PRIVILEGED_FUNCTION
#define portSET_INTERRUPT_MASK_FROM_ISR()
#define configPOST_SLEEP_PROCESSING(x)
#define portPRIORITY_GROUP_MASK
StackType_t * pxPortInitialiseStack(StackType_t *pxTopOfStack, TaskFunction_t pxCode, void *pvParameters) PRIVILEGED_FUNCTION
#define configCPU_CLOCK_HZ
#define portNVIC_PENDSV_PRI
#define configMAX_SYSCALL_INTERRUPT_PRIORITY
#define portNVIC_SYSTICK_LOAD_REG
#define portNVIC_SYSTICK_CURRENT_VALUE_REG
#define configTICK_RATE_HZ
#define portMAX_PRIGROUP_BITS
#define portEXIT_CRITICAL()
#define portFIRST_USER_INTERRUPT_NUMBER
#define configPRE_SLEEP_PROCESSING(x)
#define configSYSTICK_CLOCK_HZ
#define portTASK_RETURN_ADDRESS
BaseType_t xTaskIncrementTick(void) PRIVILEGED_FUNCTION
#define portENTER_CRITICAL()
void(* TaskFunction_t)(void *)
#define portNVIC_SYSTICK_INT_BIT
void vPortSetupTimerInterrupt(void)
eSleepModeStatus eTaskConfirmSleepModeStatus(void) PRIVILEGED_FUNCTION
#define portNVIC_SYSTICK_COUNT_FLAG_BIT
#define portNVIC_SYSTICK_CTRL_REG
#define portNVIC_IP_REGISTERS_OFFSET_16
#define portMAX_8_BIT_VALUE
#define portNVIC_SYSTICK_ENABLE_BIT
#define portMAX_24_BIT_NUMBER
portSTACK_TYPE StackType_t
#define portNVIC_PENDSVSET_BIT
#define portNVIC_INT_CTRL_REG
uint32_t ulPortSetInterruptMask(void)
void vPortExitCritical(void)