Add a watchdog timer of 10 seconds when using scratch ROM

This commit is contained in:
Jeremy Soller
2020-04-06 14:11:57 -06:00
parent 2d17acd919
commit dc246237c6
11 changed files with 83 additions and 9 deletions

View File

@ -2,6 +2,7 @@
#define _BOARD_SMFI_H #define _BOARD_SMFI_H
void smfi_init(void); void smfi_init(void);
void smfi_watchdog(void);
void smfi_event(void); void smfi_event(void);
void smfi_debug(unsigned char byte); void smfi_debug(unsigned char byte);

View File

@ -1,6 +1,7 @@
#include <8051.h> #include <8051.h>
#include <stdint.h> #include <stdint.h>
#include <board/smfi.h>
#include <common/macro.h> #include <common/macro.h>
// Include scratch ROM // Include scratch ROM
@ -15,6 +16,8 @@ volatile uint8_t __xdata __at(0x1045) SCAR1H;
// Enter or exit scratch ROM // Enter or exit scratch ROM
void scratch_trampoline(void) { void scratch_trampoline(void) {
smfi_watchdog();
// Disable interrupts // Disable interrupts
EA = 0; EA = 0;

View File

@ -9,6 +9,7 @@
#include <common/command.h> #include <common/command.h>
#include <common/macro.h> #include <common/macro.h>
#include <common/version.h> #include <common/version.h>
#include <ec/etwd.h>
#include <ec/pwm.h> #include <ec/pwm.h>
// Shared memory host semaphore // Shared memory host semaphore
@ -33,9 +34,6 @@ volatile uint8_t __xdata __at(0x103D) ECINDAR2;
volatile uint8_t __xdata __at(0x103E) ECINDAR3; volatile uint8_t __xdata __at(0x103E) ECINDAR3;
volatile uint8_t __xdata __at(0x103F) ECINDDR; volatile uint8_t __xdata __at(0x103F) ECINDDR;
volatile uint8_t __xdata __at(0x1F01) ETWCFG;
volatile uint8_t __xdata __at(0x1F07) EWDKEYR;
static volatile uint8_t __xdata __at(0xE00) smfi_cmd[256]; static volatile uint8_t __xdata __at(0xE00) smfi_cmd[256];
static volatile uint8_t __xdata __at(0xF00) smfi_dbg[256]; static volatile uint8_t __xdata __at(0xF00) smfi_dbg[256];
@ -144,6 +142,7 @@ static enum Result cmd_reset(void) {
return RES_ERR; return RES_ERR;
} }
#ifndef __SCRATCH__
static enum Result cmd_fan_get(void) { static enum Result cmd_fan_get(void) {
// If setting fan 0 // If setting fan 0
if (smfi_cmd[2] == 0) { if (smfi_cmd[2] == 0) {
@ -167,9 +166,22 @@ static enum Result cmd_fan_set(void) {
// Failed if fan not found // Failed if fan not found
return RES_ERR; return RES_ERR;
} }
#endif
// Set a watchdog timer of 10 seconds
void smfi_watchdog(void) {
ET1CNTLLR = 0xFF;
EWDCNTLLR = 0xFF;
EWDCNTLHR = 0x04;
}
void smfi_event(void) { void smfi_event(void) {
if (smfi_cmd[0]) { if (smfi_cmd[0]) {
#ifdef __SCRATCH__
// If in scratch ROM, restart watchdog timer when command received
smfi_watchdog();
#endif
switch (smfi_cmd[0]) { switch (smfi_cmd[0]) {
case CMD_PROBE: case CMD_PROBE:
// Signature // Signature

View File

@ -2,6 +2,7 @@
#define _BOARD_SMFI_H #define _BOARD_SMFI_H
void smfi_init(void); void smfi_init(void);
void smfi_watchdog(void);
void smfi_event(void); void smfi_event(void);
void smfi_debug(unsigned char byte); void smfi_debug(unsigned char byte);

View File

@ -1,6 +1,7 @@
#include <8051.h> #include <8051.h>
#include <stdint.h> #include <stdint.h>
#include <board/smfi.h>
#include <common/macro.h> #include <common/macro.h>
// Include scratch ROM // Include scratch ROM
@ -15,6 +16,8 @@ volatile uint8_t __xdata __at(0x1045) SCAR1H;
// Enter or exit scratch ROM // Enter or exit scratch ROM
void scratch_trampoline(void) { void scratch_trampoline(void) {
smfi_watchdog();
// Disable interrupts // Disable interrupts
EA = 0; EA = 0;

View File

@ -9,6 +9,7 @@
#include <common/command.h> #include <common/command.h>
#include <common/macro.h> #include <common/macro.h>
#include <common/version.h> #include <common/version.h>
#include <ec/etwd.h>
#include <ec/pwm.h> #include <ec/pwm.h>
// Shared memory host semaphore // Shared memory host semaphore
@ -33,9 +34,6 @@ volatile uint8_t __xdata __at(0x103D) ECINDAR2;
volatile uint8_t __xdata __at(0x103E) ECINDAR3; volatile uint8_t __xdata __at(0x103E) ECINDAR3;
volatile uint8_t __xdata __at(0x103F) ECINDDR; volatile uint8_t __xdata __at(0x103F) ECINDDR;
volatile uint8_t __xdata __at(0x1F01) ETWCFG;
volatile uint8_t __xdata __at(0x1F07) EWDKEYR;
static volatile uint8_t __xdata __at(0xE00) smfi_cmd[256]; static volatile uint8_t __xdata __at(0xE00) smfi_cmd[256];
static volatile uint8_t __xdata __at(0xF00) smfi_dbg[256]; static volatile uint8_t __xdata __at(0xF00) smfi_dbg[256];
@ -144,6 +142,7 @@ static enum Result cmd_reset(void) {
return RES_ERR; return RES_ERR;
} }
#ifndef __SCRATCH__
static enum Result cmd_fan_get(void) { static enum Result cmd_fan_get(void) {
// If setting fan 0 // If setting fan 0
if (smfi_cmd[2] == 0) { if (smfi_cmd[2] == 0) {
@ -167,9 +166,22 @@ static enum Result cmd_fan_set(void) {
// Failed if fan not found // Failed if fan not found
return RES_ERR; return RES_ERR;
} }
#endif
// Set a watchdog timer of 10 seconds
void smfi_watchdog(void) {
ET1CNTLLR = 0xFF;
EWDCNTLLR = 0xFF;
EWDCNTLHR = 0x04;
}
void smfi_event(void) { void smfi_event(void) {
if (smfi_cmd[0]) { if (smfi_cmd[0]) {
#ifdef __SCRATCH__
// If in scratch ROM, restart watchdog timer when command received
smfi_watchdog();
#endif
switch (smfi_cmd[0]) { switch (smfi_cmd[0]) {
case CMD_PROBE: case CMD_PROBE:
// Signature // Signature

View File

@ -2,6 +2,7 @@
#define _BOARD_SMFI_H #define _BOARD_SMFI_H
void smfi_init(void); void smfi_init(void);
void smfi_watchdog(void);
void smfi_event(void); void smfi_event(void);
void smfi_debug(unsigned char byte); void smfi_debug(unsigned char byte);

View File

@ -1,6 +1,7 @@
#include <8051.h> #include <8051.h>
#include <stdint.h> #include <stdint.h>
#include <board/smfi.h>
#include <common/macro.h> #include <common/macro.h>
// Include scratch ROM // Include scratch ROM
@ -15,6 +16,8 @@ volatile uint8_t __xdata __at(0x1042) SCAR0H;
// Enter or exit scratch ROM // Enter or exit scratch ROM
void scratch_trampoline(void) { void scratch_trampoline(void) {
smfi_watchdog();
// Disable interrupts // Disable interrupts
EA = 0; EA = 0;

View File

@ -9,6 +9,7 @@
#include <common/command.h> #include <common/command.h>
#include <common/macro.h> #include <common/macro.h>
#include <common/version.h> #include <common/version.h>
#include <ec/etwd.h>
#include <ec/pwm.h> #include <ec/pwm.h>
// Shared memory host semaphore // Shared memory host semaphore
@ -33,9 +34,6 @@ volatile uint8_t __xdata __at(0x103D) ECINDAR2;
volatile uint8_t __xdata __at(0x103E) ECINDAR3; volatile uint8_t __xdata __at(0x103E) ECINDAR3;
volatile uint8_t __xdata __at(0x103F) ECINDDR; volatile uint8_t __xdata __at(0x103F) ECINDDR;
volatile uint8_t __xdata __at(0x1F01) ETWCFG;
volatile uint8_t __xdata __at(0x1F07) EWDKEYR;
static volatile uint8_t __xdata __at(0xE00) smfi_cmd[256]; static volatile uint8_t __xdata __at(0xE00) smfi_cmd[256];
static volatile uint8_t __xdata __at(0xF00) smfi_dbg[256]; static volatile uint8_t __xdata __at(0xF00) smfi_dbg[256];
@ -144,6 +142,7 @@ static enum Result cmd_reset(void) {
return RES_ERR; return RES_ERR;
} }
#ifndef __SCRATCH__
static enum Result cmd_fan_get(void) { static enum Result cmd_fan_get(void) {
// If setting fan 0 // If setting fan 0
if (smfi_cmd[2] == 0) { if (smfi_cmd[2] == 0) {
@ -167,9 +166,22 @@ static enum Result cmd_fan_set(void) {
// Failed if fan not found // Failed if fan not found
return RES_ERR; return RES_ERR;
} }
#endif
// Set a watchdog timer of 10 seconds
void smfi_watchdog(void) {
ET1CNTLLR = 0xFF;
EWDCNTLLR = 0xFF;
EWDCNTLHR = 0x04;
}
void smfi_event(void) { void smfi_event(void) {
if (smfi_cmd[0]) { if (smfi_cmd[0]) {
#ifdef __SCRATCH__
// If in scratch ROM, restart watchdog timer when command received
smfi_watchdog();
#endif
switch (smfi_cmd[0]) { switch (smfi_cmd[0]) {
case CMD_PROBE: case CMD_PROBE:
// Signature // Signature

View File

@ -0,0 +1,13 @@
#ifndef _EC_ECWD_H
#define _EC_ECWD_H
#include <stdint.h>
volatile uint8_t __xdata __at(0x1F01) ETWCFG;
volatile uint8_t __xdata __at(0x1F02) ET1PSR;
volatile uint8_t __xdata __at(0x1F04) ET1CNTLLR;
volatile uint8_t __xdata __at(0x1F06) EWDCNTLLR;
volatile uint8_t __xdata __at(0x1F07) EWDKEYR;
volatile uint8_t __xdata __at(0x1F09) EWDCNTLHR;
#endif // _EC_ECWD_H

View File

@ -0,0 +1,13 @@
#ifndef _EC_ECWD_H
#define _EC_ECWD_H
#include <stdint.h>
volatile uint8_t __xdata __at(0x1F01) ETWCFG;
volatile uint8_t __xdata __at(0x1F02) ET1PSR;
volatile uint8_t __xdata __at(0x1F04) ET1CNTLLR;
volatile uint8_t __xdata __at(0x1F06) EWDCNTLLR;
volatile uint8_t __xdata __at(0x1F07) EWDKEYR;
volatile uint8_t __xdata __at(0x1F09) EWDCNTLHR;
#endif // _EC_ECWD_H