summaryrefslogtreecommitdiffstatshomepage
diff options
context:
space:
mode:
authorDaniel Campora <daniel@wipy.io>2015-03-25 14:14:25 +0100
committerDaniel Campora <daniel@wipy.io>2015-03-25 15:22:32 +0100
commit26d230419c37a9b28a3b76f3e20af6799d0098c4 (patch)
treec4fbe0618110fc6376870a0fe6328fd920da9d8e
parent4729a212b18678e278a9135e728acd6067aa46d9 (diff)
downloadmicropython-26d230419c37a9b28a3b76f3e20af6799d0098c4.tar.gz
micropython-26d230419c37a9b28a3b76f3e20af6799d0098c4.zip
cc3200: Add GPIO25 to the pins list of the WiPy and the WiPy-SD.
This allows to properly initialize the system led and add it to the sleep module so that it can be restored when resuming from suspended mode.
-rw-r--r--cc3200/boards/LAUNCHXL/mpconfigboard.h1
-rw-r--r--cc3200/boards/WIPY-SD/mpconfigboard.h9
-rw-r--r--cc3200/boards/WIPY-SD/pins.csv1
-rw-r--r--cc3200/boards/WIPY/mpconfigboard.h9
-rw-r--r--cc3200/boards/WIPY/pins.csv1
-rw-r--r--cc3200/misc/mperror.c49
-rw-r--r--cc3200/misc/mperror.h1
-rw-r--r--cc3200/mods/pybsleep.c7
-rw-r--r--cc3200/mptask.c2
9 files changed, 43 insertions, 37 deletions
diff --git a/cc3200/boards/LAUNCHXL/mpconfigboard.h b/cc3200/boards/LAUNCHXL/mpconfigboard.h
index f3fa0d6479..9fcccc8e8b 100644
--- a/cc3200/boards/LAUNCHXL/mpconfigboard.h
+++ b/cc3200/boards/LAUNCHXL/mpconfigboard.h
@@ -41,6 +41,7 @@
#define MICROPY_SAFE_BOOT_PRCM PRCM_GPIOA2
#define MICROPY_SYS_LED_PORT GPIOA1_BASE
#define MICROPY_SAFE_BOOT_PORT GPIOA2_BASE
+#define MICROPY_SYS_LED_GPIO pin_GPIO9
#define MICROPY_SYS_LED_PIN_NUM PIN_64 // GPIO9
#define MICROPY_SAFE_BOOT_PIN_NUM PIN_15 // GPIO22
#define MICROPY_SYS_LED_PORT_PIN GPIO_PIN_1
diff --git a/cc3200/boards/WIPY-SD/mpconfigboard.h b/cc3200/boards/WIPY-SD/mpconfigboard.h
index 165e8c49f2..ab920b7182 100644
--- a/cc3200/boards/WIPY-SD/mpconfigboard.h
+++ b/cc3200/boards/WIPY-SD/mpconfigboard.h
@@ -41,9 +41,10 @@
#define MICROPY_SAFE_BOOT_PRCM PRCM_GPIOA3
#define MICROPY_SYS_LED_PORT GPIOA3_BASE
#define MICROPY_SAFE_BOOT_PORT GPIOA3_BASE
-#define MICROPY_SYS_LED_PIN_NUM PIN_21
-#define MICROPY_SAFE_BOOT_PIN_NUM PIN_18
-#define MICROPY_SYS_LED_PORT_PIN GPIO_PIN_1 // GPIO25 (SOP2)
-#define MICROPY_SAFE_BOOT_PORT_PIN GPIO_PIN_4 // GPIO28
+#define MICROPY_SYS_LED_GPIO pin_GPIO25
+#define MICROPY_SYS_LED_PIN_NUM PIN_21 // GPIO25 (SOP2)
+#define MICROPY_SAFE_BOOT_PIN_NUM PIN_18 // GPIO28
+#define MICROPY_SYS_LED_PORT_PIN GPIO_PIN_1
+#define MICROPY_SAFE_BOOT_PORT_PIN GPIO_PIN_4
#define MICROPY_PORT_SFLASH_BLOCK_COUNT 96
diff --git a/cc3200/boards/WIPY-SD/pins.csv b/cc3200/boards/WIPY-SD/pins.csv
index 5294181f31..760bb15f98 100644
--- a/cc3200/boards/WIPY-SD/pins.csv
+++ b/cc3200/boards/WIPY-SD/pins.csv
@@ -22,3 +22,4 @@ R11,GPIO3
R12,GPIO0
R13,GPIO4
R14,GPIO5
+HBL,GPIO25
diff --git a/cc3200/boards/WIPY/mpconfigboard.h b/cc3200/boards/WIPY/mpconfigboard.h
index 1eb37221fe..700e343041 100644
--- a/cc3200/boards/WIPY/mpconfigboard.h
+++ b/cc3200/boards/WIPY/mpconfigboard.h
@@ -41,9 +41,10 @@
#define MICROPY_SAFE_BOOT_PRCM PRCM_GPIOA3
#define MICROPY_SYS_LED_PORT GPIOA3_BASE
#define MICROPY_SAFE_BOOT_PORT GPIOA3_BASE
-#define MICROPY_SYS_LED_PIN_NUM PIN_21
-#define MICROPY_SAFE_BOOT_PIN_NUM PIN_18
-#define MICROPY_SYS_LED_PORT_PIN GPIO_PIN_1 // GPIO25 (SOP2)
-#define MICROPY_SAFE_BOOT_PORT_PIN GPIO_PIN_4 // GPIO28
+#define MICROPY_SYS_LED_GPIO pin_GPIO25
+#define MICROPY_SYS_LED_PIN_NUM PIN_21 // GPIO25 (SOP2)
+#define MICROPY_SAFE_BOOT_PIN_NUM PIN_18 // GPIO28
+#define MICROPY_SYS_LED_PORT_PIN GPIO_PIN_1
+#define MICROPY_SAFE_BOOT_PORT_PIN GPIO_PIN_4
#define MICROPY_PORT_SFLASH_BLOCK_COUNT 96
diff --git a/cc3200/boards/WIPY/pins.csv b/cc3200/boards/WIPY/pins.csv
index 5294181f31..760bb15f98 100644
--- a/cc3200/boards/WIPY/pins.csv
+++ b/cc3200/boards/WIPY/pins.csv
@@ -22,3 +22,4 @@ R11,GPIO3
R12,GPIO0
R13,GPIO4
R14,GPIO5
+HBL,GPIO25
diff --git a/cc3200/misc/mperror.c b/cc3200/misc/mperror.c
index 85ed0a6466..1f77f06929 100644
--- a/cc3200/misc/mperror.c
+++ b/cc3200/misc/mperror.c
@@ -40,6 +40,10 @@
#include "hw_common_reg.h"
#include "pin.h"
#include "gpio.h"
+#ifndef BOOTLOADER
+#include "pybpin.h"
+#include "pins.h"
+#endif
#include "rom.h"
#include "rom_map.h"
#include "prcm.h"
@@ -64,40 +68,29 @@ struct mperror_heart_beat {
uint32_t on_time;
bool beating;
bool enabled;
-} mperror_heart_beat;
-
-/******************************************************************************
- DEFINE PRIVATE FUNCTIONS
- ******************************************************************************/
-STATIC void mperror_heartbeat_switch_off (void) {
- MAP_GPIOPinWrite(MICROPY_SYS_LED_PORT, MICROPY_SYS_LED_PORT_PIN, 0);
-}
+} mperror_heart_beat = {.off_time = 0, .on_time = 0, .beating = false, .enabled = false};
/******************************************************************************
DEFINE PUBLIC FUNCTIONS
******************************************************************************/
void mperror_init0 (void) {
- // Enable SYS GPIOs peripheral clocks
- MAP_PRCMPeripheralClkEnable(MICROPY_SYS_LED_PRCM, PRCM_RUN_MODE_CLK | PRCM_SLP_MODE_CLK);
#ifdef BOOTLOADER
+ // enable the system led and the safe boot pin peripheral clocks
+ MAP_PRCMPeripheralClkEnable(MICROPY_SYS_LED_PRCM, PRCM_RUN_MODE_CLK | PRCM_SLP_MODE_CLK);
MAP_PRCMPeripheralClkEnable(MICROPY_SAFE_BOOT_PRCM, PRCM_RUN_MODE_CLK | PRCM_SLP_MODE_CLK);
-#endif
-
- // Configure the bld
- MAP_PinTypeGPIO(MICROPY_SYS_LED_PIN_NUM, PIN_MODE_0, false);
- MAP_PinConfigSet(MICROPY_SYS_LED_PIN_NUM, PIN_STRENGTH_6MA, PIN_TYPE_STD);
- MAP_GPIODirModeSet(MICROPY_SYS_LED_PORT, MICROPY_SYS_LED_PORT_PIN, GPIO_DIR_MODE_OUT);
-
-#ifdef BOOTLOADER
- // Configure the safe boot pin
+ // configure the safe boot pin
MAP_PinTypeGPIO(MICROPY_SAFE_BOOT_PIN_NUM, PIN_MODE_0, false);
MAP_PinConfigSet(MICROPY_SAFE_BOOT_PIN_NUM, PIN_STRENGTH_4MA, PIN_TYPE_STD_PD);
MAP_GPIODirModeSet(MICROPY_SAFE_BOOT_PORT, MICROPY_SAFE_BOOT_PORT_PIN, GPIO_DIR_MODE_IN);
+ // configure the bld
+ MAP_PinTypeGPIO(MICROPY_SYS_LED_PIN_NUM, PIN_MODE_0, false);
+ MAP_PinConfigSet(MICROPY_SYS_LED_PIN_NUM, PIN_STRENGTH_6MA, PIN_TYPE_STD);
+ MAP_GPIODirModeSet(MICROPY_SYS_LED_PORT, MICROPY_SYS_LED_PORT_PIN, GPIO_DIR_MODE_OUT);
+#else
+ // configure the system led
+ pin_config ((pin_obj_t *)&MICROPY_SYS_LED_GPIO, PIN_MODE_0, GPIO_DIR_MODE_OUT, PIN_TYPE_STD, PIN_STRENGTH_6MA);
#endif
-
- mperror_heart_beat.on_time = 0;
- mperror_heart_beat.off_time = 0;
- mperror_heart_beat.beating = false;
+ mperror_heartbeat_switch_off();
}
void mperror_bootloader_check_reset_cause (void) {
@@ -114,7 +107,7 @@ void mperror_bootloader_check_reset_cause (void) {
HWREG(0x4402F024) &= 0xF7FFFFFF;
// since the reset cause will be changed, we must store the right reason
- // so that the application knows we booting the next time
+ // so that the application knows it when booting for the next time
PRCMSignalWDTReset();
MAP_PRCMHibernateWakeupSourceEnable(PRCM_HIB_SLOW_CLK_CTR);
@@ -142,6 +135,12 @@ void mperror_enable_heartbeat (void) {
mperror_heart_beat.enabled = true;
}
+void mperror_heartbeat_switch_off (void) {
+ mperror_heart_beat.on_time = 0;
+ mperror_heart_beat.off_time = 0;
+ MAP_GPIOPinWrite(MICROPY_SYS_LED_PORT, MICROPY_SYS_LED_PORT_PIN, 0);
+}
+
void mperror_disable_heartbeat (void) {
mperror_heart_beat.enabled = false;
mperror_heartbeat_switch_off();
@@ -157,7 +156,7 @@ void mperror_heartbeat_signal (void) {
}
else {
if ((mperror_heart_beat.off_time = HAL_GetTick()) - mperror_heart_beat.on_time > MPERROR_HEARTBEAT_ON_MS) {
- mperror_heartbeat_switch_off();
+ MAP_GPIOPinWrite(MICROPY_SYS_LED_PORT, MICROPY_SYS_LED_PORT_PIN, 0);
mperror_heart_beat.beating = false;
}
}
diff --git a/cc3200/misc/mperror.h b/cc3200/misc/mperror.h
index 06dd549496..2c443f449e 100644
--- a/cc3200/misc/mperror.h
+++ b/cc3200/misc/mperror.h
@@ -39,6 +39,7 @@ void mperror_bootloader_check_reset_cause (void);
void mperror_deinit_sfe_pin (void);
void mperror_signal_error (void);
void mperror_enable_heartbeat (void);
+void mperror_heartbeat_switch_off (void);
void mperror_disable_heartbeat (void);
void mperror_heartbeat_signal (void);
diff --git a/cc3200/mods/pybsleep.c b/cc3200/mods/pybsleep.c
index d93c09fa49..449c9c55f7 100644
--- a/cc3200/mods/pybsleep.c
+++ b/cc3200/mods/pybsleep.c
@@ -325,6 +325,9 @@ STATIC NORETURN void pybsleep_suspend_enter (void) {
// park the gpio pins
pybsleep_iopark();
+ // turn-off the heartbeat led
+ mperror_heartbeat_switch_off();
+
// store the cpu registers
sleep_store();
@@ -384,9 +387,6 @@ void pybsleep_suspend_exit (void) {
// reinitialize simplelink's bus
sl_IfOpen (NULL, 0);
- // initialize the system led
- mperror_init0();
-
// restore the configuration of all active peripherals
pybsleep_obj_wakeup();
@@ -610,6 +610,7 @@ STATIC mp_obj_t pyb_sleep_hibernate (mp_obj_t self_in) {
}
}
wlan_stop(SL_STOP_TIMEOUT);
+ mperror_heartbeat_switch_off();
pybsleep_flash_powerdown();
MAP_PRCMHibernateEnter();
return mp_const_none;
diff --git a/cc3200/mptask.c b/cc3200/mptask.c
index b0b44ec5ed..05843c3dc5 100644
--- a/cc3200/mptask.c
+++ b/cc3200/mptask.c
@@ -118,10 +118,10 @@ soft_reset:
mp_obj_list_append(mp_sys_path, MP_OBJ_NEW_QSTR(MP_QSTR_)); // current dir (or base dir of the script)
// execute all basic initializations
- mperror_init0();
mpexception_init0();
mpcallback_init0();
pybsleep_init0();
+ mperror_init0();
uart_init0();
pin_init0();
readline_init0();