先上源代码:
文件为portmacro.h,来源于Dynasty项目中的底层代码(NVIC中断控制部分)
1 #define portNVIC_INT_CTRL_REG ( * ( ( volatile uint32_t * ) 0xe000ed04UL ) )
2 #define portNVIC_PENDSVSET_BIT ( 1UL << 28UL )
3
4
5 void vPortYield( void )
6 {
7 /* Set a PendSV to request a context switch. */
8 portNVIC_INT_CTRL_REG = portNVIC_PENDSVSET_BIT;
9
10 /* Barriers are normally not required but do ensure the code is completely
11 within the specified behaviour for the architecture. */
12 __DSB();
13 __ISB();
14 }