diff options
| author | Damien George | 2017-09-06 13:40:51 +1000 |
|---|---|---|
| committer | Damien George | 2017-09-06 13:40:51 +1000 |
| commit | 01dd7804b87d60b2deab16712eccb3b97351a9b7 (patch) | |
| tree | 1aa21f38a872b8e62a3d4e4f74f68033c6f827e4 /cc3200/misc | |
| parent | a9862b30068fc9df1022f08019fb35aaa5085f64 (diff) | |
ports: Make new ports/ sub-directory and move all ports there.
This is to keep the top-level directory clean, to make it clear what is
core and what is a port, and to allow the repository to grow with new ports
in a sustainable way.
Diffstat (limited to 'cc3200/misc')
| -rw-r--r-- | cc3200/misc/FreeRTOSHooks.c | 107 | ||||
| -rw-r--r-- | cc3200/misc/antenna.c | 97 | ||||
| -rw-r--r-- | cc3200/misc/antenna.h | 37 | ||||
| -rw-r--r-- | cc3200/misc/help.c | 32 | ||||
| -rw-r--r-- | cc3200/misc/mperror.c | 210 | ||||
| -rw-r--r-- | cc3200/misc/mperror.h | 41 | ||||
| -rw-r--r-- | cc3200/misc/mpexception.c | 40 | ||||
| -rw-r--r-- | cc3200/misc/mpexception.h | 34 | ||||
| -rw-r--r-- | cc3200/misc/mpirq.c | 201 | ||||
| -rw-r--r-- | cc3200/misc/mpirq.h | 74 |
10 files changed, 0 insertions, 873 deletions
diff --git a/cc3200/misc/FreeRTOSHooks.c b/cc3200/misc/FreeRTOSHooks.c deleted file mode 100644 index c618279b7..000000000 --- a/cc3200/misc/FreeRTOSHooks.c +++ /dev/null @@ -1,107 +0,0 @@ -/* - * This file is part of the MicroPython project, http://micropython.org/ - * - * The MIT License (MIT) - * - * Copyright (c) 2015 Daniel Campora - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - * THE SOFTWARE. - */ - -#include <stdint.h> -#include <stdio.h> -#include <string.h> - -#include "py/mpconfig.h" -#include "py/mphal.h" -#include "py/obj.h" -#include "inc/hw_memmap.h" -#include "pybuart.h" -#include "osi.h" -#include "mperror.h" - - -//***************************************************************************** -// -//! \brief Application defined idle task hook -//! -//! \param none -//! -//! \return none -//! -//***************************************************************************** -void vApplicationIdleHook (void) -{ - // signal that we are alive and kicking - mperror_heartbeat_signal(); - // gate the processor's clock to save power - __WFI(); -} - -//***************************************************************************** -// -//! \brief Application defined malloc failed hook -//! -//! \param none -//! -//! \return none -//! -//***************************************************************************** -void vApplicationMallocFailedHook (void) -{ -#ifdef DEBUG - // break into the debugger - __asm volatile ("bkpt #0 \n"); -#endif - - __fatal_error("FreeRTOS malloc failed!"); -} - -//***************************************************************************** -// -//! \brief Application defined stack overflow hook -//! -//! \param none -//! -//! \return none -//! -//***************************************************************************** -void vApplicationStackOverflowHook (OsiTaskHandle *pxTask, signed char *pcTaskName) -{ -#ifdef DEBUG - // Break into the debugger - __asm volatile ("bkpt #0 \n"); -#endif - - __fatal_error("Stack overflow!"); -} - -//***************************************************************************** -// -//! \brief Application defined tick hook -//! -//! \param none -//! -//! \return none -//! -//***************************************************************************** -void vApplicationTickHook (void) -{ - HAL_IncrementTick(); -} diff --git a/cc3200/misc/antenna.c b/cc3200/misc/antenna.c deleted file mode 100644 index afeed85e1..000000000 --- a/cc3200/misc/antenna.c +++ /dev/null @@ -1,97 +0,0 @@ -/* - * This file is part of the MicroPython project, http://micropython.org/ - * - * The MIT License (MIT) - * - * Copyright (c) 2015 Daniel Campora - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - * THE SOFTWARE. - */ - -#include <stdint.h> - -#include "mpconfigboard.h" -#include "inc/hw_types.h" -#include "inc/hw_gpio.h" -#include "inc/hw_ints.h" -#include "inc/hw_memmap.h" -#include "rom_map.h" -#include "pin.h" -#include "prcm.h" -#include "gpio.h" -#include "antenna.h" - - -#if MICROPY_HW_ANTENNA_DIVERSITY - -/****************************************************************************** -DEFINE CONSTANTS -******************************************************************************/ -#define REG_PAD_CONFIG_26 (0x4402E108) -#define REG_PAD_CONFIG_27 (0x4402E10C) - -/****************************************************************************** -DEFINE PRIVATE DATA -******************************************************************************/ -static antenna_type_t antenna_type_selected = ANTENNA_TYPE_INTERNAL; - -/****************************************************************************** -DEFINE PUBLIC FUNCTIONS -******************************************************************************/ -void antenna_init0(void) { - // enable the peripheral clock and set the gpio direction for - // both antenna 1 and antenna 2 pins - MAP_PRCMPeripheralClkEnable(PRCM_GPIOA3, PRCM_RUN_MODE_CLK | PRCM_SLP_MODE_CLK); - MAP_GPIODirModeSet(GPIOA3_BASE, 0x0C, GPIO_DIR_MODE_OUT); - - // configure antenna 1 pin type and strength - HWREG(REG_PAD_CONFIG_26) = ((HWREG(REG_PAD_CONFIG_26) & ~(PAD_STRENGTH_MASK | PAD_TYPE_MASK)) | (0x00000020 | 0x00000000)); - // set the mode - HWREG(REG_PAD_CONFIG_26) = ((HWREG(REG_PAD_CONFIG_26) & ~PAD_MODE_MASK) | 0x00000000) & ~(3 << 10); - // set the direction - HWREG(REG_PAD_CONFIG_26) = ((HWREG(REG_PAD_CONFIG_26) & ~0xC00) | 0x00000800); - - // configure antenna 2 pin type and strength - HWREG(REG_PAD_CONFIG_27) = ((HWREG(REG_PAD_CONFIG_27) & ~(PAD_STRENGTH_MASK | PAD_TYPE_MASK)) | (0x00000020 | 0x00000000)); - // set the mode - HWREG(REG_PAD_CONFIG_27) = ((HWREG(REG_PAD_CONFIG_27) & ~PAD_MODE_MASK) | 0x00000000) & ~(3 << 10); - // set the direction - HWREG(REG_PAD_CONFIG_27) = ((HWREG(REG_PAD_CONFIG_27) & ~0xC00) | 0x00000800); - - // select the currently active antenna - antenna_select(antenna_type_selected); -} - -void antenna_select (antenna_type_t _antenna) { - if (_antenna == ANTENNA_TYPE_INTERNAL) { - MAP_GPIOPinWrite(GPIOA3_BASE, 0x0C, 0x04); - // also configure the pull-up and pull-down accordingly - HWREG(REG_PAD_CONFIG_26) = ((HWREG(REG_PAD_CONFIG_26) & ~PAD_TYPE_MASK)) | PIN_TYPE_STD_PU; - HWREG(REG_PAD_CONFIG_27) = ((HWREG(REG_PAD_CONFIG_27) & ~PAD_TYPE_MASK)) | PIN_TYPE_STD_PD; - } else { - MAP_GPIOPinWrite(GPIOA3_BASE, 0x0C, 0x08); - // also configure the pull-up and pull-down accordingly - HWREG(REG_PAD_CONFIG_26) = ((HWREG(REG_PAD_CONFIG_26) & ~PAD_TYPE_MASK)) | PIN_TYPE_STD_PD; - HWREG(REG_PAD_CONFIG_27) = ((HWREG(REG_PAD_CONFIG_27) & ~PAD_TYPE_MASK)) | PIN_TYPE_STD_PU; - } - antenna_type_selected = _antenna; -} - -#endif - diff --git a/cc3200/misc/antenna.h b/cc3200/misc/antenna.h deleted file mode 100644 index c9d845453..000000000 --- a/cc3200/misc/antenna.h +++ /dev/null @@ -1,37 +0,0 @@ -/* - * This file is part of the MicroPython project, http://micropython.org/ - * - * The MIT License (MIT) - * - * Copyright (c) 2015 Daniel Campora - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - * THE SOFTWARE. - */ -#ifndef MICROPY_INCLUDED_CC3200_MISC_ANTENNA_H -#define MICROPY_INCLUDED_CC3200_MISC_ANTENNA_H - -typedef enum { - ANTENNA_TYPE_INTERNAL = 0, - ANTENNA_TYPE_EXTERNAL -} antenna_type_t; - -extern void antenna_init0 (void); -extern void antenna_select (antenna_type_t antenna_type); - -#endif // MICROPY_INCLUDED_CC3200_MISC_ANTENNA_H diff --git a/cc3200/misc/help.c b/cc3200/misc/help.c deleted file mode 100644 index 739303e19..000000000 --- a/cc3200/misc/help.c +++ /dev/null @@ -1,32 +0,0 @@ -/* - * This file is part of the MicroPython project, http://micropython.org/ - * - * The MIT License (MIT) - * - * Copyright (c) 2013, 2014 Damien P. George - * Copyright (c) 2015 Daniel Campora - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - * THE SOFTWARE. - */ - -#include "py/builtin.h" - -const char *cc3200_help_text = "Welcome to MicroPython!\n" - "For online help please visit http://micropython.org/help/.\n" - "For further help on a specific object, type help(obj)\n"; diff --git a/cc3200/misc/mperror.c b/cc3200/misc/mperror.c deleted file mode 100644 index 082d940e2..000000000 --- a/cc3200/misc/mperror.c +++ /dev/null @@ -1,210 +0,0 @@ -/* - * This file is part of the MicroPython project, http://micropython.org/ - * - * The MIT License (MIT) - * - * Copyright (c) 2013, 2014 Damien P. George - * Copyright (c) 2015 Daniel Campora - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - * THE SOFTWARE. - */ - -#include <stdio.h> -#include <stdint.h> -#include <string.h> - -#include "py/mpconfig.h" -#include "py/obj.h" -#include "py/runtime.h" -#include "py/mphal.h" -#include "hw_ints.h" -#include "hw_types.h" -#include "hw_gpio.h" -#include "hw_memmap.h" -#include "hw_gprcm.h" -#include "hw_common_reg.h" -#include "pin.h" -#include "gpio.h" -#ifndef BOOTLOADER -#include "pybpin.h" -#include "pins.h" -#endif -#include "rom_map.h" -#include "prcm.h" -#include "pybuart.h" -#include "utils.h" -#include "mperror.h" - - -/****************************************************************************** - DEFINE CONSTANTS - ******************************************************************************/ -#define MPERROR_TOOGLE_MS (50) -#define MPERROR_SIGNAL_ERROR_MS (1200) -#define MPERROR_HEARTBEAT_ON_MS (80) -#define MPERROR_HEARTBEAT_OFF_MS (3920) - -/****************************************************************************** - DECLARE PRIVATE DATA - ******************************************************************************/ -struct mperror_heart_beat { - uint32_t off_time; - uint32_t on_time; - bool beating; - bool enabled; - bool do_disable; -} mperror_heart_beat = {.off_time = 0, .on_time = 0, .beating = false, .enabled = false, .do_disable = false}; - -/****************************************************************************** - DEFINE PUBLIC FUNCTIONS - ******************************************************************************/ -void mperror_init0 (void) { -#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); - // 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, 0, PIN_STRENGTH_6MA); -#endif - mperror_heart_beat.enabled = true; - mperror_heartbeat_switch_off(); -} - -void mperror_bootloader_check_reset_cause (void) { - // if we are recovering from a WDT reset, trigger - // a hibernate cycle for a clean boot - if (MAP_PRCMSysResetCauseGet() == PRCM_WDT_RESET) { - HWREG(0x400F70B8) = 1; - UtilsDelay(800000/5); - HWREG(0x400F70B0) = 1; - UtilsDelay(800000/5); - - HWREG(0x4402E16C) |= 0x2; - UtilsDelay(800); - HWREG(0x4402F024) &= 0xF7FFFFFF; - - // since the reset cause will be changed, we must store the right reason - // so that the application knows it when booting for the next time - PRCMSetSpecialBit(PRCM_WDT_RESET_BIT); - - MAP_PRCMHibernateWakeupSourceEnable(PRCM_HIB_SLOW_CLK_CTR); - // set the sleep interval to 10ms - MAP_PRCMHibernateIntervalSet(330); - MAP_PRCMHibernateEnter(); - } -} - -void mperror_deinit_sfe_pin (void) { - // disable the pull-down - MAP_PinConfigSet(MICROPY_SAFE_BOOT_PIN_NUM, PIN_STRENGTH_4MA, PIN_TYPE_STD); -} - -void mperror_signal_error (void) { - uint32_t count = 0; - while ((MPERROR_TOOGLE_MS * count++) < MPERROR_SIGNAL_ERROR_MS) { - // toogle the led - MAP_GPIOPinWrite(MICROPY_SYS_LED_PORT, MICROPY_SYS_LED_PORT_PIN, ~MAP_GPIOPinRead(MICROPY_SYS_LED_PORT, MICROPY_SYS_LED_PORT_PIN)); - UtilsDelay(UTILS_DELAY_US_TO_COUNT(MPERROR_TOOGLE_MS * 1000)); - } -} - -void mperror_heartbeat_switch_off (void) { - if (mperror_heart_beat.enabled) { - 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_heartbeat_signal (void) { - if (mperror_heart_beat.do_disable) { - mperror_heart_beat.do_disable = false; - } else if (mperror_heart_beat.enabled) { - if (!mperror_heart_beat.beating) { - if ((mperror_heart_beat.on_time = mp_hal_ticks_ms()) - mperror_heart_beat.off_time > MPERROR_HEARTBEAT_OFF_MS) { - MAP_GPIOPinWrite(MICROPY_SYS_LED_PORT, MICROPY_SYS_LED_PORT_PIN, MICROPY_SYS_LED_PORT_PIN); - mperror_heart_beat.beating = true; - } - } else { - if ((mperror_heart_beat.off_time = mp_hal_ticks_ms()) - mperror_heart_beat.on_time > MPERROR_HEARTBEAT_ON_MS) { - MAP_GPIOPinWrite(MICROPY_SYS_LED_PORT, MICROPY_SYS_LED_PORT_PIN, 0); - mperror_heart_beat.beating = false; - } - } - } -} - -void NORETURN __fatal_error(const char *msg) { -#ifdef DEBUG - if (msg != NULL) { - // wait for 20ms - UtilsDelay(UTILS_DELAY_US_TO_COUNT(20000)); - mp_hal_stdout_tx_str("\r\nFATAL ERROR:"); - mp_hal_stdout_tx_str(msg); - mp_hal_stdout_tx_str("\r\n"); - } -#endif - // signal the crash with the system led - MAP_GPIOPinWrite(MICROPY_SYS_LED_PORT, MICROPY_SYS_LED_PORT_PIN, MICROPY_SYS_LED_PORT_PIN); - for ( ;; ) {__WFI();} -} - -void __assert_func(const char *file, int line, const char *func, const char *expr) { - (void) func; - printf("Assertion failed: %s, file %s, line %d\n", expr, file, line); - __fatal_error(NULL); -} - -void nlr_jump_fail(void *val) { -#ifdef DEBUG - char msg[64]; - snprintf(msg, sizeof(msg), "uncaught exception %p\n", val); - __fatal_error(msg); -#else - __fatal_error(NULL); -#endif -} - -void mperror_enable_heartbeat (bool enable) { - if (enable) { - #ifndef BOOTLOADER - // configure the led again - pin_config ((pin_obj_t *)&MICROPY_SYS_LED_GPIO, PIN_MODE_0, GPIO_DIR_MODE_OUT, PIN_TYPE_STD, 0, PIN_STRENGTH_6MA); - #endif - mperror_heart_beat.enabled = true; - mperror_heart_beat.do_disable = false; - mperror_heartbeat_switch_off(); - } else { - mperror_heart_beat.do_disable = true; - mperror_heart_beat.enabled = false; - } -} - -bool mperror_is_heartbeat_enabled (void) { - return mperror_heart_beat.enabled; -} diff --git a/cc3200/misc/mperror.h b/cc3200/misc/mperror.h deleted file mode 100644 index 1c3eb6269..000000000 --- a/cc3200/misc/mperror.h +++ /dev/null @@ -1,41 +0,0 @@ -/* - * This file is part of the MicroPython project, http://micropython.org/ - * - * The MIT License (MIT) - * - * Copyright (c) 2013, 2014 Damien P. George - * Copyright (c) 2015 Daniel Campora - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - * THE SOFTWARE. - */ -#ifndef MICROPY_INCLUDED_CC3200_MISC_MPERROR_H -#define MICROPY_INCLUDED_CC3200_MISC_MPERROR_H - -extern void NORETURN __fatal_error(const char *msg); - -void mperror_init0 (void); -void mperror_bootloader_check_reset_cause (void); -void mperror_deinit_sfe_pin (void); -void mperror_signal_error (void); -void mperror_heartbeat_switch_off (void); -void mperror_heartbeat_signal (void); -void mperror_enable_heartbeat (bool enable); -bool mperror_is_heartbeat_enabled (void); - -#endif // MICROPY_INCLUDED_CC3200_MISC_MPERROR_H diff --git a/cc3200/misc/mpexception.c b/cc3200/misc/mpexception.c deleted file mode 100644 index 2dfcbfdef..000000000 --- a/cc3200/misc/mpexception.c +++ /dev/null @@ -1,40 +0,0 @@ -/* - * This file is part of the MicroPython project, http://micropython.org/ - * - * The MIT License (MIT) - * - * Copyright (c) 2013, 2014 Damien P. George - * Copyright (c) 2015 Daniel Campora - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - * THE SOFTWARE. - */ - -#include <stdint.h> -#include <string.h> - -#include "py/mpstate.h" -#include "mpexception.h" - - -/****************************************************************************** -DECLARE EXPORTED DATA - ******************************************************************************/ -const char mpexception_value_invalid_arguments[] = "invalid argument(s) value"; -const char mpexception_num_type_invalid_arguments[] = "invalid argument(s) num/type"; -const char mpexception_uncaught[] = "uncaught exception"; diff --git a/cc3200/misc/mpexception.h b/cc3200/misc/mpexception.h deleted file mode 100644 index e84a1edb2..000000000 --- a/cc3200/misc/mpexception.h +++ /dev/null @@ -1,34 +0,0 @@ -/* - * This file is part of the MicroPython project, http://micropython.org/ - * - * The MIT License (MIT) - * - * Copyright (c) 2013, 2014 Damien P. George - * Copyright (c) 2015 Daniel Campora - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - * THE SOFTWARE. - */ -#ifndef MICROPY_INCLUDED_CC3200_MISC_MPEXCEPTION_H -#define MICROPY_INCLUDED_CC3200_MISC_MPEXCEPTION_H - -extern const char mpexception_value_invalid_arguments[]; -extern const char mpexception_num_type_invalid_arguments[]; -extern const char mpexception_uncaught[]; - -#endif // MICROPY_INCLUDED_CC3200_MISC_MPEXCEPTION_H diff --git a/cc3200/misc/mpirq.c b/cc3200/misc/mpirq.c deleted file mode 100644 index d54e7465b..000000000 --- a/cc3200/misc/mpirq.c +++ /dev/null @@ -1,201 +0,0 @@ -/* - * This file is part of the MicroPython project, http://micropython.org/ - * - * The MIT License (MIT) - * - * Copyright (c) 2015 Daniel Campora - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - * THE SOFTWARE. - */ - -#include <stdio.h> - -#include "py/mpconfig.h" -#include "py/obj.h" -#include "py/runtime.h" -#include "py/gc.h" -#include "inc/hw_types.h" -#include "interrupt.h" -#include "pybsleep.h" -#include "mpexception.h" -#include "mperror.h" -#include "mpirq.h" - - -/****************************************************************************** - DECLARE PUBLIC DATA - ******************************************************************************/ -const mp_arg_t mp_irq_init_args[] = { - { MP_QSTR_trigger, MP_ARG_KW_ONLY | MP_ARG_OBJ, {.u_obj = mp_const_none} }, - { MP_QSTR_priority, MP_ARG_KW_ONLY | MP_ARG_INT, {.u_int = 1} }, // the lowest priority - { MP_QSTR_handler, MP_ARG_KW_ONLY | MP_ARG_OBJ, {.u_obj = mp_const_none} }, - { MP_QSTR_wake, MP_ARG_KW_ONLY | MP_ARG_OBJ, {.u_obj = mp_const_none} }, -}; - -/****************************************************************************** - DECLARE PRIVATE DATA - ******************************************************************************/ -STATIC uint8_t mp_irq_priorities[] = { INT_PRIORITY_LVL_7, INT_PRIORITY_LVL_6, INT_PRIORITY_LVL_5, INT_PRIORITY_LVL_4, - INT_PRIORITY_LVL_3, INT_PRIORITY_LVL_2, INT_PRIORITY_LVL_1 }; - -/****************************************************************************** - DEFINE PUBLIC FUNCTIONS - ******************************************************************************/ -void mp_irq_init0 (void) { - // initialize the callback objects list - mp_obj_list_init(&MP_STATE_PORT(mp_irq_obj_list), 0); -} - -mp_obj_t mp_irq_new (mp_obj_t parent, mp_obj_t handler, const mp_irq_methods_t *methods) { - mp_irq_obj_t *self = m_new_obj(mp_irq_obj_t); - self->base.type = &mp_irq_type; - self->handler = handler; - self->parent = parent; - self->methods = (mp_irq_methods_t *)methods; - self->isenabled = true; - // remove it in case it was already registered - mp_irq_remove(parent); - mp_obj_list_append(&MP_STATE_PORT(mp_irq_obj_list), self); - return self; -} - -mp_irq_obj_t *mp_irq_find (mp_obj_t parent) { - for (mp_uint_t i = 0; i < MP_STATE_PORT(mp_irq_obj_list).len; i++) { - mp_irq_obj_t *callback_obj = ((mp_irq_obj_t *)(MP_STATE_PORT(mp_irq_obj_list).items[i])); - if (callback_obj->parent == parent) { - return callback_obj; - } - } - return NULL; -} - -void mp_irq_wake_all (void) { - // re-enable all active callback objects one by one - for (mp_uint_t i = 0; i < MP_STATE_PORT(mp_irq_obj_list).len; i++) { - mp_irq_obj_t *callback_obj = ((mp_irq_obj_t *)(MP_STATE_PORT(mp_irq_obj_list).items[i])); - if (callback_obj->isenabled) { - callback_obj->methods->enable(callback_obj->parent); - } - } -} - -void mp_irq_disable_all (void) { - // re-enable all active callback objects one by one - for (mp_uint_t i = 0; i < MP_STATE_PORT(mp_irq_obj_list).len; i++) { - mp_irq_obj_t *callback_obj = ((mp_irq_obj_t *)(MP_STATE_PORT(mp_irq_obj_list).items[i])); - callback_obj->methods->disable(callback_obj->parent); - } -} - -void mp_irq_remove (const mp_obj_t parent) { - mp_irq_obj_t *callback_obj; - if ((callback_obj = mp_irq_find(parent))) { - mp_obj_list_remove(&MP_STATE_PORT(mp_irq_obj_list), callback_obj); - } -} - -uint mp_irq_translate_priority (uint priority) { - if (priority < 1 || priority > MP_ARRAY_SIZE(mp_irq_priorities)) { - mp_raise_ValueError(mpexception_value_invalid_arguments); - } - return mp_irq_priorities[priority - 1]; -} - -void mp_irq_handler (mp_obj_t self_in) { - mp_irq_obj_t *self = self_in; - if (self && self->handler != mp_const_none) { - // when executing code within a handler we must lock the GC to prevent - // any memory allocations. - gc_lock(); - nlr_buf_t nlr; - if (nlr_push(&nlr) == 0) { - mp_call_function_1(self->handler, self->parent); - nlr_pop(); - } - else { - // uncaught exception; disable the callback so that it doesn't run again - self->methods->disable (self->parent); - self->handler = mp_const_none; - // signal the error using the heart beat led and - // by printing a message - printf("Uncaught exception in callback handler\n"); - mp_obj_print_exception(&mp_plat_print, (mp_obj_t)nlr.ret_val); - mperror_signal_error(); - } - gc_unlock(); - } -} - -/******************************************************************************/ -// MicroPython bindings - -STATIC mp_obj_t mp_irq_init(size_t n_args, const mp_obj_t *pos_args, mp_map_t *kw_args) { - mp_irq_obj_t *self = pos_args[0]; - // this is a bit of a hack, but it let us reuse the callback_create method from our parent - ((mp_obj_t *)pos_args)[0] = self->parent; - self->methods->init (n_args, pos_args, kw_args); - return mp_const_none; -} -MP_DEFINE_CONST_FUN_OBJ_KW(mp_irq_init_obj, 1, mp_irq_init); - -STATIC mp_obj_t mp_irq_enable (mp_obj_t self_in) { - mp_irq_obj_t *self = self_in; - self->methods->enable(self->parent); - self->isenabled = true; - return mp_const_none; -} -STATIC MP_DEFINE_CONST_FUN_OBJ_1(mp_irq_enable_obj, mp_irq_enable); - -STATIC mp_obj_t mp_irq_disable (mp_obj_t self_in) { - mp_irq_obj_t *self = self_in; - self->methods->disable(self->parent); - self->isenabled = false; - return mp_const_none; -} -STATIC MP_DEFINE_CONST_FUN_OBJ_1(mp_irq_disable_obj, mp_irq_disable); - -STATIC mp_obj_t mp_irq_flags (mp_obj_t self_in) { - mp_irq_obj_t *self = self_in; - return mp_obj_new_int(self->methods->flags(self->parent)); -} -STATIC MP_DEFINE_CONST_FUN_OBJ_1(mp_irq_flags_obj, mp_irq_flags); - -STATIC mp_obj_t mp_irq_call(mp_obj_t self_in, size_t n_args, size_t n_kw, const mp_obj_t *args) { - mp_arg_check_num(n_args, n_kw, 0, 0, false); - mp_irq_handler (self_in); - return mp_const_none; -} - -STATIC const mp_rom_map_elem_t mp_irq_locals_dict_table[] = { - // instance methods - { MP_ROM_QSTR(MP_QSTR_init), MP_ROM_PTR(&mp_irq_init_obj) }, - { MP_ROM_QSTR(MP_QSTR_enable), MP_ROM_PTR(&mp_irq_enable_obj) }, - { MP_ROM_QSTR(MP_QSTR_disable), MP_ROM_PTR(&mp_irq_disable_obj) }, - { MP_ROM_QSTR(MP_QSTR_flags), MP_ROM_PTR(&mp_irq_flags_obj) }, -}; - -STATIC MP_DEFINE_CONST_DICT(mp_irq_locals_dict, mp_irq_locals_dict_table); - -const mp_obj_type_t mp_irq_type = { - { &mp_type_type }, - .name = MP_QSTR_irq, - .call = mp_irq_call, - .locals_dict = (mp_obj_t)&mp_irq_locals_dict, -}; - diff --git a/cc3200/misc/mpirq.h b/cc3200/misc/mpirq.h deleted file mode 100644 index 223a34cae..000000000 --- a/cc3200/misc/mpirq.h +++ /dev/null @@ -1,74 +0,0 @@ -/* - * This file is part of the MicroPython project, http://micropython.org/ - * - * The MIT License (MIT) - * - * Copyright (c) 2015 Daniel Campora - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - * THE SOFTWARE. - */ -#ifndef MICROPY_INCLUDED_CC3200_MISC_MPIRQ_H -#define MICROPY_INCLUDED_CC3200_MISC_MPIRQ_H - -/****************************************************************************** - DEFINE CONSTANTS - ******************************************************************************/ -#define mp_irq_INIT_NUM_ARGS 4 - -/****************************************************************************** - DEFINE TYPES - ******************************************************************************/ -typedef mp_obj_t (*mp_irq_init_t) (size_t n_args, const mp_obj_t *pos_args, mp_map_t *kw_args); -typedef void (*mp_irq_void_method_t) (mp_obj_t self); -typedef int (*mp_irq_int_method_t) (mp_obj_t self); - -typedef struct { - mp_irq_init_t init; - mp_irq_void_method_t enable; - mp_irq_void_method_t disable; - mp_irq_int_method_t flags; -} mp_irq_methods_t; - -typedef struct { - mp_obj_base_t base; - mp_obj_t parent; - mp_obj_t handler; - mp_irq_methods_t *methods; - bool isenabled; -} mp_irq_obj_t; - -/****************************************************************************** - DECLARE EXPORTED DATA - ******************************************************************************/ -extern const mp_arg_t mp_irq_init_args[]; -extern const mp_obj_type_t mp_irq_type; - -/****************************************************************************** - DECLARE PUBLIC FUNCTIONS - ******************************************************************************/ -void mp_irq_init0 (void); -mp_obj_t mp_irq_new (mp_obj_t parent, mp_obj_t handler, const mp_irq_methods_t *methods); -mp_irq_obj_t *mp_irq_find (mp_obj_t parent); -void mp_irq_wake_all (void); -void mp_irq_disable_all (void); -void mp_irq_remove (const mp_obj_t parent); -void mp_irq_handler (mp_obj_t self_in); -uint mp_irq_translate_priority (uint priority); - -#endif // MICROPY_INCLUDED_CC3200_MISC_MPIRQ_H |
