123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596 |
- #include "yc_timer.h"
- #include "yc11xx.h"
- #include "core_cm0.h"
- #include "LH_TaskManager.h"
- uint32_t sys_tick_count;
- uint8_t sys_Timer_Check_Flag;
- uint32_t gSystemTimerAdjustClknbt;
- static unsigned int sys_run_tickms=0;
- static unsigned int sys_run_ticks=0;
-
- void SYS_TimerExpireDefaultHandle(int params)
- {
-
- while(0);
- }
- void SYS_TimerInit()
- {
- SysTick_Config(SYSTEM_CLOCK/CLOCK_DIVISOR);
- }
- extern uint32_t UserCnt;
- static unsigned int system_time_get_run_tickms(void)
- {
- return sys_run_tickms;
- }
- static unsigned int system_time_get_run_ticks(void)
- {
- return sys_run_ticks;
- }
- static unsigned short MsCnt = 0;
- void SYStick_handle()
- {
-
-
- if(++MsCnt>999)
- {
- MsCnt=0;
- sys_run_ticks++;
-
- }
- sys_run_tickms++;
- TaskManager_Scheduling();
- }
- void SYS_delay_ms(uint32_t nms)
- {
- SYS_delay_us(nms*1000);
- }
- void SYS_delay_us(uint32_t nus){
- uint32_t ticks;
- uint32_t told,tnow,tcnt=0;
- uint32_t reload=SysTick->LOAD;
- ticks=nus*(SYSTEM_CLOCK/1000000);
- tcnt=0;
- told=SysTick->VAL;
- while(1){
- tnow=SysTick->VAL;
- if(tnow!=told){
- if(tnow<told)
- tcnt+=told-tnow;
- else
- tcnt+=reload-tnow+told;
- told=tnow;
- if(tcnt>=ticks)
- break;
- }
- };
- }
- sys_time_handle_t sys_time_handle={
- .init= SYS_TimerInit,
- .get_run_ticks=system_time_get_run_ticks,
- .get_run_tickms=system_time_get_run_tickms
- } ;
|