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.
This commit is contained in:
Daniel Campora 2015-03-25 14:14:25 +01:00
parent 4729a212b1
commit 26d230419c
9 changed files with 43 additions and 37 deletions

View File

@ -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

View File

@ -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

View File

@ -22,3 +22,4 @@ R11,GPIO3
R12,GPIO0
R13,GPIO4
R14,GPIO5
HBL,GPIO25

1 L2 GPIO2
22 R12 GPIO0
23 R13 GPIO4
24 R14 GPIO5
25 HBL GPIO25

View File

@ -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

View File

@ -22,3 +22,4 @@ R11,GPIO3
R12,GPIO0
R13,GPIO4
R14,GPIO5
HBL,GPIO25

1 L2 GPIO2
22 R12 GPIO0
23 R13 GPIO4
24 R14 GPIO5
25 HBL GPIO25

View File

@ -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 +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;
}
}

View File

@ -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);

View File

@ -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;

View File

@ -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();