forked from xuos/xiuos
Format rtc and watchdog driver for hc32
This commit is contained in:
parent
e6fa8a2603
commit
bfe1e72378
|
@ -174,8 +174,8 @@ int HwRtcInit(void)
|
||||||
(void)RTC_StructInit(&stcRtcInit);
|
(void)RTC_StructInit(&stcRtcInit);
|
||||||
|
|
||||||
/* Configuration RTC structure */
|
/* Configuration RTC structure */
|
||||||
stcRtcInit.u8ClockSrc = RTC_CLK_SRC_XTAL32;
|
stcRtcInit.u8ClockSrc = RTC_CLK_SRC_XTAL32;
|
||||||
stcRtcInit.u8HourFormat = RTC_HOUR_FMT_24H;
|
stcRtcInit.u8HourFormat= RTC_HOUR_FMT_24H;
|
||||||
stcRtcInit.u8IntPeriod = RTC_INT_PERIOD_PER_SEC;
|
stcRtcInit.u8IntPeriod = RTC_INT_PERIOD_PER_SEC;
|
||||||
(void)RTC_Init(&stcRtcInit);
|
(void)RTC_Init(&stcRtcInit);
|
||||||
|
|
||||||
|
|
|
@ -27,10 +27,10 @@ static uint32 WdtOpen(void *dev)
|
||||||
NULL_PARAM_CHECK(dev);
|
NULL_PARAM_CHECK(dev);
|
||||||
|
|
||||||
stc_wdt_init_t stcWdtInit;
|
stc_wdt_init_t stcWdtInit;
|
||||||
stcWdtInit.u32CountPeriod = WDT_CNT_PERIOD65536;
|
stcWdtInit.u32CountPeriod = WDT_CNT_PERIOD65536;
|
||||||
stcWdtInit.u32ClockDiv = WDT_CLK_DIV1024;
|
stcWdtInit.u32ClockDiv = WDT_CLK_DIV1024;
|
||||||
stcWdtInit.u32RefreshRange = WDT_RANGE_0TO25PCT;
|
stcWdtInit.u32RefreshRange = WDT_RANGE_0TO25PCT;
|
||||||
stcWdtInit.u32LPMCount = WDT_LPM_CNT_STOP;
|
stcWdtInit.u32LPMCount = WDT_LPM_CNT_STOP;
|
||||||
stcWdtInit.u32ExceptionType = WDT_EXP_TYPE_RST;
|
stcWdtInit.u32ExceptionType = WDT_EXP_TYPE_RST;
|
||||||
(void)WDT_Init(&stcWdtInit);
|
(void)WDT_Init(&stcWdtInit);
|
||||||
return EOK;
|
return EOK;
|
||||||
|
@ -42,13 +42,25 @@ static uint32 WdtConfigure(void *drv, struct BusConfigureInfo *args)
|
||||||
NULL_PARAM_CHECK(args);
|
NULL_PARAM_CHECK(args);
|
||||||
|
|
||||||
stc_wdt_init_t stcWdtInit;
|
stc_wdt_init_t stcWdtInit;
|
||||||
|
|
||||||
|
int period_option = *((int*)args->private_data);
|
||||||
|
if(period_option<=256){
|
||||||
|
period_option = WDT_CNT_PERIOD256;
|
||||||
|
}else if(period_option<=4096){
|
||||||
|
period_option = WDT_CNT_PERIOD4096;
|
||||||
|
}else if(period_option<=16384){
|
||||||
|
period_option = WDT_CNT_PERIOD16384;
|
||||||
|
}else{
|
||||||
|
period_option = WDT_CNT_PERIOD65536;
|
||||||
|
}
|
||||||
|
|
||||||
switch (args->configure_cmd)
|
switch (args->configure_cmd)
|
||||||
{
|
{
|
||||||
case OPER_WDT_SET_TIMEOUT:
|
case OPER_WDT_SET_TIMEOUT:
|
||||||
stcWdtInit.u32CountPeriod = WDT_CNT_PERIOD65536;
|
stcWdtInit.u32CountPeriod = period_option;
|
||||||
stcWdtInit.u32ClockDiv = WDT_CLK_DIV1024;
|
stcWdtInit.u32ClockDiv = WDT_CLK_DIV1024;
|
||||||
stcWdtInit.u32RefreshRange = WDT_RANGE_0TO25PCT;
|
stcWdtInit.u32RefreshRange = WDT_RANGE_0TO25PCT;
|
||||||
stcWdtInit.u32LPMCount = WDT_LPM_CNT_STOP;
|
stcWdtInit.u32LPMCount = WDT_LPM_CNT_STOP;
|
||||||
stcWdtInit.u32ExceptionType = WDT_EXP_TYPE_RST;
|
stcWdtInit.u32ExceptionType = WDT_EXP_TYPE_RST;
|
||||||
if (WDT_Init(&stcWdtInit) != 0) {
|
if (WDT_Init(&stcWdtInit) != 0) {
|
||||||
return ERROR;
|
return ERROR;
|
||||||
|
|
Loading…
Reference in New Issue