From 26d230419c37a9b28a3b76f3e20af6799d0098c4 Mon Sep 17 00:00:00 2001 From: Daniel Campora Date: Wed, 25 Mar 2015 14:14:25 +0100 Subject: [PATCH] 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. --- cc3200/boards/LAUNCHXL/mpconfigboard.h | 1 + cc3200/boards/WIPY-SD/mpconfigboard.h | 9 ++--- cc3200/boards/WIPY-SD/pins.csv | 1 + cc3200/boards/WIPY/mpconfigboard.h | 9 ++--- cc3200/boards/WIPY/pins.csv | 1 + cc3200/misc/mperror.c | 49 +++++++++++++------------- cc3200/misc/mperror.h | 1 + cc3200/mods/pybsleep.c | 7 ++-- cc3200/mptask.c | 2 +- 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 +#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); -#ifdef BOOTLOADER 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 +15