我在编写ESP8266硬件定时器相关的程序时,发现驱动hw_timer.c文件中没有关闭硬件定时器的函数,然后查阅芯片寄存器手册,自己编写了一个hw_timer的开启和关闭的函数,函数如下:
参数说明:当cmd=0时,关闭hw_timer;
cmd=1时,开启定时器。
void hw_timer_cmd( uint8 cmd )
{
uint32 ReadValue , Value;
ReadValue = READ_PERI_REG( FRC1_CTRL_ADDRESS );
if( cmd == 0 )
{
Value = ReadValue & ( ~FRC1_ENABLE_TIMER );
}
else
{
Value = ReadValue | FRC1_ENABLE_TIMER;
}
RTC_REG_WRITE( FRC1_CTRL_ADDRESS , Value );
}
ReadValue = READ_PERI_REG( FRC1_CTRL_ADDRESS );
if( cmd == 0 )
{
Value = ReadValue & ( ~FRC1_ENABLE_TIMER );
}
else
{
Value = ReadValue | FRC1_ENABLE_TIMER;
}
RTC_REG_WRITE( FRC1_CTRL_ADDRESS , Value );
}