| 1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374 |
- #include "gd32f4xx.h"
- #include "systick.h"
- #include "FreeRTOS.h"
- __IO uint32_t uwTick;
- #define SYS_SUPPORT_OS 1
- volatile static uint32_t delay;
- /*!
- \brief configure systick
- \param[in] none
- \param[out] none
- \retval none
- */
- void systick_config(void)
- {
- /* setup systick timer for 1000Hz interrupts */
- if(SysTick_Config(SystemCoreClock / 1000U)) {
- /* capture error */
- while(1) {
- }
- }
- /* configure the systick handler priority */
- NVIC_SetPriority(SysTick_IRQn, 0x15U);
- }
- /*!
- \brief delay a time in milliseconds
- \param[in] count: count in milliseconds
- \param[out] none
- \retval none
- */
- void delay_1ms(uint32_t count)
- {
- delay = count;
- while(0U != delay) {
- }
- }
- /*!
- \brief delay decrement
- \param[in] none
- \param[out] none
- \retval none
- */
- void delay_decrement(void)
- {
- if(0U != delay) {
- delay--;
- }
- uwTick += 1;
- }
- void delay_us(uint32_t nus)
- {
- uint32_t j = 0;
- uint8_t i = 0;
- for(j = 0 ;j < nus;j++)
- {
- for(i=0;i<255;i++);
- }
- }
- uint32_t systick_get()
- {
- return uwTick;
- }
|