-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* How to build details * Backmerge (#14) * Own watchdog file, wd delay helper, disable charger wakeup, SdFileExists to helper
- Loading branch information
Showing
8 changed files
with
127 additions
and
72 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
#include "watchdog.h" | ||
|
||
#include "hw_types.h" | ||
#include "hw_ints.h" | ||
#include "hw_memmap.h" | ||
#include "prcm.h" | ||
#include "wdt.h" | ||
#include "rom.h" | ||
#include "rom_map.h" | ||
#include "interrupt.h" | ||
|
||
volatile uint8_t watchdog_feed_state; | ||
|
||
void watchdog_feed(void) { | ||
watchdog_feed_state = WATCHDOG_TIMEOUT_S; | ||
} | ||
static void watchdog_unfeed(void) { | ||
watchdog_feed_state = 0; | ||
} | ||
void watchdog_eat(void) { | ||
if (watchdog_feed_state > WATCHDOG_CHECK_S) { | ||
watchdog_feed_state -= WATCHDOG_CHECK_S; | ||
} else { | ||
watchdog_feed_state = 0; | ||
} | ||
} | ||
static void watchdog_handler(void) { | ||
if (watchdog_feed_state > 0) { | ||
MAP_WatchdogIntClear(WDT_BASE); | ||
watchdog_eat(); | ||
} | ||
} | ||
static bool initWatchdog(unsigned long ulLoadVal, void (*pfnHandler)(void)) { | ||
#ifndef DISABLE_WATCHDOG | ||
watchdog_feed(); | ||
|
||
MAP_PRCMPeripheralClkEnable(PRCM_WDT, PRCM_RUN_MODE_CLK); | ||
MAP_WatchdogUnlock(WDT_BASE); | ||
MAP_IntPrioritySet(INT_WDT, INT_PRIORITY_LVL_1); | ||
MAP_WatchdogStallEnable(WDT_BASE); //Allow Debugging | ||
MAP_WatchdogIntRegister(WDT_BASE, pfnHandler); | ||
MAP_WatchdogReloadSet(WDT_BASE, ulLoadVal); | ||
MAP_WatchdogEnable(WDT_BASE); | ||
|
||
return MAP_WatchdogRunning(WDT_BASE); | ||
#endif | ||
} | ||
|
||
bool watchdog_start(void) { | ||
return initWatchdog(MILLISECONDS_TO_TICKS(1000*WATCHDOG_CHECK_S), watchdog_handler); | ||
} | ||
|
||
static void watchdog_handler_always(void) { | ||
MAP_WatchdogIntClear(WDT_BASE); | ||
} | ||
void watchdog_stop(void) { | ||
initWatchdog(0xFFFFFFFF, watchdog_handler_always); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
#ifndef __WATCHDOG_H__ | ||
#define __WATCHDOG_H__ | ||
#ifdef __cplusplus | ||
extern "C" | ||
{ | ||
#endif | ||
#include <stdint.h> | ||
#include <stdbool.h> | ||
|
||
#include "globalDefines.h" | ||
|
||
void watchdog_feed(void); | ||
bool watchdog_start(void); | ||
void watchdog_stop(void); | ||
|
||
#ifdef __cplusplus | ||
} | ||
#endif | ||
#endif |