Follow+Star Public Account Number, don’t miss wonderful content
Author | strongerHuang
cm3.h and cm85.h
Although there are more left-side “red” parts, most of them are additional lines and macro definitions. Upon careful comparison, many are actually the same, such as the commonly used system reset function:
__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 */}
Cortex-M85 Microcontroller SysTick
while(1){ R_PORT10->PODR ^= 1<<(BSP_IO_PORT_10_PIN_01 & 0xFF); //PA01 toggle R_BSP_SoftwareDelay(1, BSP_DELAY_UNITS_MILLISECONDS); //SysTick delay}
R_PORT10->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;
Leave a Comment
Your email address will not be published. Required fields are marked *