pikapython/package/CH582/ch582_time.c
2022-03-26 20:46:22 +08:00

35 lines
599 B
C

#include "CH58x_common.h"
#include "CH582_Time.h"
void mdelay1ms()
{
R32_TMR0_CNT_END = (FREQ_SYS / 1000);
R8_TMR0_CTRL_MOD = RB_TMR_ALL_CLEAR;
R8_TMR0_CTRL_MOD = RB_TMR_COUNT_EN;
while ((R8_TMR0_INT_FLAG & TMR0_3_IT_CYC_END) == 0)
;
R8_TMR0_INT_FLAG = TMR0_3_IT_CYC_END;
}
void mdelaym(uint32_t ms)
{
for (uint32_t i = 0; i < ms; i++)
{
mdelay1ms();
}
}
void CH582_Time_sleep_ms(PikaObj *self, int ms)
{
mdelaym(ms);
}
void CH582_Time_sleep_s(PikaObj *self, int s)
{
for (uint32_t i = 0; i < s; i++)
{
mdelaym(1000);
}
}