关注+星标公众号,不错过精彩内容
作者 | strongerHuang
cm3.h与cm85.h
虽然,左侧“红色”比较多,但大部分都是多出来的行数以及宏定义。仔细对比,其实很多都是一样的,比如我们常用的系统复位函数:
__NO_RETURN __STATIC_INLINE void __NVIC_SystemReset(void)
{
__DSB(); /* Ensure all outstanding memory accesses included
buffered write are completed before reset */
SCB->AIRCR = (uint32_t)((0x5FAUL << SCB_AIRCR_VECTKEY_Pos) |
(SCB->AIRCR & SCB_AIRCR_PRIGROUP_Msk) |
SCB_AIRCR_SYSRESETREQ_Msk ); /* Keep priority group unchanged */
__DSB(); /* Ensure completion of memory access */
for(;;) /* wait until reset */
{
__NOP();
}
}
__STATIC_INLINE uint32_t SysTick_Config(uint32_t ticks)
{
if ((ticks - 1UL) > SysTick_LOAD_RELOAD_Msk)
{
return (1UL); /* Reload value impossible */
}
SysTick->LOAD = (uint32_t)(ticks - 1UL); /* set reload register */
NVIC_SetPriority (SysTick_IRQn, (1UL << __NVIC_PRIO_BITS) - 1UL); /* set Priority for Systick Interrupt */
SysTick->VAL = 0UL; /* Load the SysTick Counter Value */
SysTick->CTRL = SysTick_CTRL_CLKSOURCE_Msk |
SysTick_CTRL_TICKINT_Msk |
SysTick_CTRL_ENABLE_Msk; /* Enable SysTick IRQ and SysTick Timer */
return (0UL); /* Function successful */
}
RA8单片机SysTick使用描述
while(1)
{
R_PORT10->PODR ^= 1<<(BSP_IO_PORT_10_PIN_01 & 0xFF); //PA01亮灭翻转
R_BSP_SoftwareDelay(1, BSP_DELAY_UNITS_MILLISECONDS); //SysTick延时
}
PODR ^= 1<<(BSP_IO_PORT_10_PIN_01 & 0xFF);
R_BSP_SoftwareDelay(1, BSP_DELAY_UNITS_MILLISECONDS);
typedef enum
{
BSP_DELAY_UNITS_SECONDS = 1000000, ///< Requested delay amount is in seconds
BSP_DELAY_UNITS_MILLISECONDS = 1000, ///< Requested delay amount is in milliseconds
BSP_DELAY_UNITS_MICROSECONDS = 1 ///< Requested delay amount is in microseconds
} bsp_delay_units_t;