Skip to content

Commit 6545336

Browse files
author
Daniel Campora
committed
cc3200: Make the WDT aware of the servers sleep/wake state.
1 parent 5cd34ac commit 6545336

3 files changed

Lines changed: 13 additions & 6 deletions

File tree

cc3200/mods/pybwdt.c

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -54,27 +54,27 @@
5454
******************************************************************************/
5555
typedef struct {
5656
bool servers;
57+
bool servers_sleeping;
5758
bool simplelink;
5859
bool running;
5960
}pybwdt_data_t;
6061

6162
/******************************************************************************
6263
DECLARE PRIVATE DATA
6364
******************************************************************************/
64-
static pybwdt_data_t pybwdt_data;
65+
static pybwdt_data_t pybwdt_data = {.servers = false, .servers_sleeping = false, .simplelink = false, .running = false};
6566

6667
/******************************************************************************
6768
DEFINE PUBLIC FUNCTIONS
6869
******************************************************************************/
6970
// must be called in main.c just after initializing the hal
7071
__attribute__ ((section (".boot")))
7172
void pybwdt_init0 (void) {
72-
pybwdt_data.running = false;
7373
}
7474

7575
void pybwdt_kick (void) {
7676
// check that the servers and simplelink are running fine
77-
if (pybwdt_data.servers && pybwdt_data.simplelink && pybwdt_data.running) {
77+
if ((pybwdt_data.servers || pybwdt_data.servers_sleeping) && pybwdt_data.simplelink && pybwdt_data.running) {
7878
pybwdt_data.servers = false;
7979
pybwdt_data.simplelink = false;
8080
MAP_WatchdogIntClear(WDT_BASE);
@@ -85,6 +85,10 @@ void pybwdt_srv_alive (void) {
8585
pybwdt_data.servers = true;
8686
}
8787

88+
void pybwdt_srv_sleeping (bool state) {
89+
pybwdt_data.servers_sleeping = state;
90+
}
91+
8892
void pybwdt_sl_alive (void) {
8993
pybwdt_data.simplelink = true;
9094
}

cc3200/mods/pybwdt.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@ extern const mp_obj_base_t pyb_wdt_obj;
3434
void pybwdt_init0 (void);
3535
void pybwdt_kick (void);
3636
void pybwdt_srv_alive (void);
37+
void pybwdt_srv_sleeping (bool state);
3738
void pybwdt_sl_alive (void);
3839

3940
#endif /* PYBWDT_H_ */

cc3200/serverstask.c

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -121,14 +121,16 @@ void TASK_Servers (void *pvParameters) {
121121
}
122122
}
123123

124-
// set the alive flag for the wdt
125-
pybwdt_srv_alive();
126-
127124
if (sleep_sockets) {
128125
sleep_sockets = false;
126+
pybwdt_srv_sleeping(true);
129127
modusocket_enter_sleep();
128+
pybwdt_srv_sleeping(false);
130129
}
131130

131+
// set the alive flag for the wdt
132+
pybwdt_srv_alive();
133+
132134
// move to the next cycle
133135
cycle = cycle ? false : true;
134136
HAL_Delay(SERVERS_CYCLE_TIME_MS);

0 commit comments

Comments
 (0)