summaryrefslogtreecommitdiffstatshomepage
diff options
context:
space:
mode:
authorDaniel Campora <daniel@wipy.io>2015-05-25 18:54:43 +0200
committerDaniel Campora <daniel@wipy.io>2015-05-25 21:14:54 +0200
commit654533620670fcf8fa685f83b79fa500b6cd9856 (patch)
treeede418476ec772ea51763497c1307d6145547f75
parent5cd34aca27a9f2847a0441eac16fb8940a2a0fab (diff)
downloadmicropython-654533620670fcf8fa685f83b79fa500b6cd9856.tar.gz
micropython-654533620670fcf8fa685f83b79fa500b6cd9856.zip
cc3200: Make the WDT aware of the servers sleep/wake state.
-rw-r--r--cc3200/mods/pybwdt.c10
-rw-r--r--cc3200/mods/pybwdt.h1
-rw-r--r--cc3200/serverstask.c8
3 files changed, 13 insertions, 6 deletions
diff --git a/cc3200/mods/pybwdt.c b/cc3200/mods/pybwdt.c
index 68213de6e6..9770a7c47e 100644
--- a/cc3200/mods/pybwdt.c
+++ b/cc3200/mods/pybwdt.c
@@ -54,6 +54,7 @@
******************************************************************************/
typedef struct {
bool servers;
+ bool servers_sleeping;
bool simplelink;
bool running;
}pybwdt_data_t;
@@ -61,7 +62,7 @@ typedef struct {
/******************************************************************************
DECLARE PRIVATE DATA
******************************************************************************/
-static pybwdt_data_t pybwdt_data;
+static pybwdt_data_t pybwdt_data = {.servers = false, .servers_sleeping = false, .simplelink = false, .running = false};
/******************************************************************************
DEFINE PUBLIC FUNCTIONS
@@ -69,12 +70,11 @@ static pybwdt_data_t pybwdt_data;
// must be called in main.c just after initializing the hal
__attribute__ ((section (".boot")))
void pybwdt_init0 (void) {
- pybwdt_data.running = false;
}
void pybwdt_kick (void) {
// check that the servers and simplelink are running fine
- if (pybwdt_data.servers && pybwdt_data.simplelink && pybwdt_data.running) {
+ if ((pybwdt_data.servers || pybwdt_data.servers_sleeping) && pybwdt_data.simplelink && pybwdt_data.running) {
pybwdt_data.servers = false;
pybwdt_data.simplelink = false;
MAP_WatchdogIntClear(WDT_BASE);
@@ -85,6 +85,10 @@ void pybwdt_srv_alive (void) {
pybwdt_data.servers = true;
}
+void pybwdt_srv_sleeping (bool state) {
+ pybwdt_data.servers_sleeping = state;
+}
+
void pybwdt_sl_alive (void) {
pybwdt_data.simplelink = true;
}
diff --git a/cc3200/mods/pybwdt.h b/cc3200/mods/pybwdt.h
index e2e6d8d33a..9687101c3a 100644
--- a/cc3200/mods/pybwdt.h
+++ b/cc3200/mods/pybwdt.h
@@ -34,6 +34,7 @@ extern const mp_obj_base_t pyb_wdt_obj;
void pybwdt_init0 (void);
void pybwdt_kick (void);
void pybwdt_srv_alive (void);
+void pybwdt_srv_sleeping (bool state);
void pybwdt_sl_alive (void);
#endif /* PYBWDT_H_ */
diff --git a/cc3200/serverstask.c b/cc3200/serverstask.c
index 732e6bbcca..94ef8c8ec8 100644
--- a/cc3200/serverstask.c
+++ b/cc3200/serverstask.c
@@ -121,14 +121,16 @@ void TASK_Servers (void *pvParameters) {
}
}
- // set the alive flag for the wdt
- pybwdt_srv_alive();
-
if (sleep_sockets) {
sleep_sockets = false;
+ pybwdt_srv_sleeping(true);
modusocket_enter_sleep();
+ pybwdt_srv_sleeping(false);
}
+ // set the alive flag for the wdt
+ pybwdt_srv_alive();
+
// move to the next cycle
cycle = cycle ? false : true;
HAL_Delay(SERVERS_CYCLE_TIME_MS);