aboutsummaryrefslogtreecommitdiff
path: root/cc3200/misc
diff options
context:
space:
mode:
authordanicampora2015-02-06 15:35:48 +0100
committerDamien George2015-02-06 22:10:11 +0000
commit8785645a952c03315dbf93667b5f7c7eec49762f (patch)
tree267e2d572d87e92bfc0bfabf83859231152a2162 /cc3200/misc
parent97f14606f528180d1482cffbe3571163a1dd9273 (diff)
cc3200: Add cc3200 port of MicroPython.
The port currently implements support for GPIO, RTC, ExtInt and the WiFi subsystem. A small file system is available in the serial flash. A bootloader which makes OTA updates possible, is also part of this initial implementation.
Diffstat (limited to 'cc3200/misc')
-rw-r--r--cc3200/misc/FreeRTOSHooks.c122
-rw-r--r--cc3200/misc/gpio_named_pins.c62
-rw-r--r--cc3200/misc/help.c85
-rw-r--r--cc3200/misc/mperror.c70
-rw-r--r--cc3200/misc/mperror.h32
-rw-r--r--cc3200/misc/mpexception.c100
-rw-r--r--cc3200/misc/mpexception.h46
-rw-r--r--cc3200/misc/pin_defs_cc3200.c70
-rw-r--r--cc3200/misc/pin_defs_cc3200.h41
9 files changed, 628 insertions, 0 deletions
diff --git a/cc3200/misc/FreeRTOSHooks.c b/cc3200/misc/FreeRTOSHooks.c
new file mode 100644
index 000000000..85dc2f373
--- /dev/null
+++ b/cc3200/misc/FreeRTOSHooks.c
@@ -0,0 +1,122 @@
+/*
+ * This file is part of the Micro Python 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 "mpconfig.h"
+#include MICROPY_HAL_H
+#include "misc.h"
+#include "qstr.h"
+#include "obj.h"
+#include "inc/hw_memmap.h"
+#include "pybuart.h"
+#include "pybstdio.h"
+#include "osi.h"
+
+
+#ifdef USE_FREERTOS
+
+//*****************************************************************************
+//
+//! \brief Application defined idle task hook
+//!
+//! \param none
+//!
+//! \return none
+//!
+//*****************************************************************************
+void
+vApplicationIdleHook( void)
+{
+ //Handle Idle Hook for Profiling, Power Management etc
+ __WFI();
+}
+
+//*****************************************************************************
+//
+//! \brief Application defined malloc failed hook
+//!
+//! \param none
+//!
+//! \return none
+//!
+//*****************************************************************************
+void vApplicationMallocFailedHook()
+{
+#ifdef DEBUG
+ // Break into the debugger
+ __asm volatile ("bkpt #0 \n");
+
+ printf("\nFATAL ERROR: FreeRTOS malloc failed!\n");
+#endif
+
+ //Handle Memory Allocation Errors
+ while(1)
+ {
+ }
+}
+
+//*****************************************************************************
+//
+//! \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");
+
+ printf("\nFATAL ERROR: Application: %s stack overflow!\n", pcTaskName);
+#endif
+
+ //Handle FreeRTOS Stack Overflow
+ while(1)
+ {
+ }
+}
+
+//*****************************************************************************
+//
+//! \brief Application defined tick hook
+//!
+//! \param none
+//!
+//! \return none
+//!
+//*****************************************************************************
+void vApplicationTickHook( void )
+{
+ HAL_IncrementTick();
+}
+
+#endif //USE_FREERTOS
diff --git a/cc3200/misc/gpio_named_pins.c b/cc3200/misc/gpio_named_pins.c
new file mode 100644
index 000000000..884a46293
--- /dev/null
+++ b/cc3200/misc/gpio_named_pins.c
@@ -0,0 +1,62 @@
+/*
+ * This file is part of the Micro Python 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 "mpconfig.h"
+#include "misc.h"
+#include "qstr.h"
+#include "obj.h"
+#include "inc/hw_types.h"
+#include "inc/hw_ints.h"
+#include "inc/hw_memmap.h"
+#include "pybgpio.h"
+#include "runtime.h"
+#include MICROPY_HAL_H
+
+STATIC void gpio_named_pins_obj_print(void (*print)(void *env, const char *fmt, ...), void *env, mp_obj_t self_in, mp_print_kind_t kind) {
+ gpio_named_pins_obj_t *self = self_in;
+ print(env, "<Pin.%s>", qstr_str(self->name));
+}
+
+const mp_obj_type_t gpio_cpu_pins_obj_type = {
+ { &mp_type_type },
+ .name = MP_QSTR_cpu,
+ .print = gpio_named_pins_obj_print,
+ .locals_dict = (mp_obj_t)&gpio_cpu_pins_locals_dict,
+};
+
+const gpio_obj_t *gpio_find_named_pin(const mp_obj_dict_t *named_pins, mp_obj_t name) {
+ mp_map_t *named_map = mp_obj_dict_get_map((mp_obj_t)named_pins);
+ mp_map_elem_t *named_elem = mp_map_lookup(named_map, name, MP_MAP_LOOKUP);
+ if (named_elem != NULL && named_elem->value != NULL) {
+ return named_elem->value;
+ }
+ return NULL;
+}
diff --git a/cc3200/misc/help.c b/cc3200/misc/help.c
new file mode 100644
index 000000000..67e800e05
--- /dev/null
+++ b/cc3200/misc/help.c
@@ -0,0 +1,85 @@
+/*
+ * This file is part of the Micro Python 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 "mpconfig.h"
+#include "nlr.h"
+#include "misc.h"
+#include "qstr.h"
+#include "obj.h"
+
+STATIC const char help_text[] = "Welcome to Micro Python!\n"
+ "For online help please visit http://micropython.org/help/.\n"
+ "For further help on a specific object, type help(obj)\n";
+
+STATIC void pyb_help_print_info_about_object(mp_obj_t name_o, mp_obj_t value) {
+ printf(" ");
+ mp_obj_print(name_o, PRINT_STR);
+ printf(" -- ");
+ mp_obj_print(value, PRINT_STR);
+ printf("\n");
+}
+
+STATIC mp_obj_t pyb_help(uint n_args, const mp_obj_t *args) {
+ if (n_args == 0) {
+ // print a general help message
+ printf("%s", help_text);
+
+ } else {
+ // try to print something sensible about the given object
+
+ printf("object ");
+ mp_obj_print(args[0], PRINT_STR);
+ printf(" is of type %s\n", mp_obj_get_type_str(args[0]));
+
+ mp_map_t *map = NULL;
+ if (MP_OBJ_IS_TYPE(args[0], &mp_type_module)) {
+ map = mp_obj_dict_get_map(mp_obj_module_get_globals(args[0]));
+ } else {
+ mp_obj_type_t *type;
+ if (MP_OBJ_IS_TYPE(args[0], &mp_type_type)) {
+ type = args[0];
+ } else {
+ type = mp_obj_get_type(args[0]);
+ }
+ if (type->locals_dict != MP_OBJ_NULL && MP_OBJ_IS_TYPE(type->locals_dict, &mp_type_dict)) {
+ map = mp_obj_dict_get_map(type->locals_dict);
+ }
+ }
+ if (map != NULL) {
+ for (uint i = 0; i < map->alloc; i++) {
+ if (map->table[i].key != MP_OBJ_NULL) {
+ pyb_help_print_info_about_object(map->table[i].key, map->table[i].value);
+ }
+ }
+ }
+ }
+
+ return mp_const_none;
+}
+MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(mp_builtin_help_obj, 0, 1, pyb_help);
diff --git a/cc3200/misc/mperror.c b/cc3200/misc/mperror.c
new file mode 100644
index 000000000..d85881340
--- /dev/null
+++ b/cc3200/misc/mperror.c
@@ -0,0 +1,70 @@
+/*
+ * This file is part of the Micro Python 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 <std.h>
+#include <stdint.h>
+#include <string.h>
+
+#include "mpconfig.h"
+#include MICROPY_HAL_H
+#include "nlr.h"
+#include "misc.h"
+#include "qstr.h"
+#include "obj.h"
+#include "inc/hw_memmap.h"
+#include "pybuart.h"
+#include "pybstdio.h"
+#include "utils.h"
+
+
+void NORETURN __fatal_error(const char *msg) {
+ if (msg != NULL) {
+ // wait for 20ms
+ UtilsDelay(UTILS_DELAY_US_TO_COUNT(20000));
+ stdout_tx_str("\r\nFATAL ERROR:");
+ stdout_tx_str(msg);
+ stdout_tx_str("\r\n");
+ }
+ 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
+}
+
diff --git a/cc3200/misc/mperror.h b/cc3200/misc/mperror.h
new file mode 100644
index 000000000..89a2abe8e
--- /dev/null
+++ b/cc3200/misc/mperror.h
@@ -0,0 +1,32 @@
+/*
+ * This file is part of the Micro Python 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.
+ */
+
+#ifdef DEBUG
+extern void NORETURN __fatal_error(const char *msg);
+#else
+#define __fatal_error(...) for ( ;; ) {__WFI();}
+#endif
diff --git a/cc3200/misc/mpexception.c b/cc3200/misc/mpexception.c
new file mode 100644
index 000000000..91cd99786
--- /dev/null
+++ b/cc3200/misc/mpexception.c
@@ -0,0 +1,100 @@
+/*
+ * This file is part of the Micro Python 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 <std.h>
+
+#include "py/mpstate.h"
+#include "mpconfig.h"
+#include "misc.h"
+#include "qstr.h"
+#include "obj.h"
+#include "runtime.h"
+#include "mpexception.h"
+
+
+/******************************************************************************
+DECLARE PRIVATE FUNCTIONS
+ ******************************************************************************/
+STATIC void mpexception_set_user_interrupt (int chr, void *data);
+
+/******************************************************************************
+DECLARE EXPORTED DATA
+ ******************************************************************************/
+const char mpexception_os_resource_not_avaliable[] = "resource not available";
+const char mpexception_os_operation_failed[] = "the requested operation failed";
+const char mpexception_os_request_not_possible[] = "the requested operation is not possible";
+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";
+
+int user_interrupt_char = -1;
+
+/******************************************************************************
+DECLARE PRIVATE DATA
+ ******************************************************************************/
+STATIC void *user_interrupt_data = NULL;
+
+/******************************************************************************
+DEFINE PUBLIC FUNCTIONS
+ ******************************************************************************/
+
+void mpexception_init0 (void) {
+ // Create an exception object for interrupting through the stdin uart
+ MP_STATE_PORT(mp_const_user_interrupt) = mp_obj_new_exception(&mp_type_KeyboardInterrupt);
+ mpexception_set_user_interrupt (-1, MP_STATE_PORT(mp_const_user_interrupt));
+}
+
+void mpexception_set_interrupt_char (int c) {
+ if (c != -1) {
+ mp_obj_exception_clear_traceback(MP_STATE_PORT(mp_const_user_interrupt));
+ }
+ mpexception_set_user_interrupt(c, MP_STATE_PORT(mp_const_user_interrupt));
+}
+
+// Call this function to raise a pending exception during an interrupt.
+// It will try to raise the exception "softly" by setting the
+// mp_pending_exception variable hoping that the VM will notice it.
+void mpexception_nlr_jump (void *o) {
+ if (MP_STATE_PORT(mp_pending_exception) == MP_OBJ_NULL) {
+ MP_STATE_PORT(mp_pending_exception) = o;
+ }
+}
+
+void mpexception_keyboard_nlr_jump (void) {
+ mpexception_nlr_jump (user_interrupt_data);
+}
+
+/******************************************************************************
+DEFINE PRIVATE FUNCTIONS
+ ******************************************************************************/
+
+STATIC void mpexception_set_user_interrupt (int chr, void *data) {
+ user_interrupt_char = chr;
+ user_interrupt_data = data;
+}
diff --git a/cc3200/misc/mpexception.h b/cc3200/misc/mpexception.h
new file mode 100644
index 000000000..f55aa739e
--- /dev/null
+++ b/cc3200/misc/mpexception.h
@@ -0,0 +1,46 @@
+/*
+ * This file is part of the Micro Python 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 MPEXCEPTION_H_
+#define MPEXCEPTION_H_
+
+extern const char mpexception_os_resource_not_avaliable[];
+extern const char mpexception_os_operation_failed[];
+extern const char mpexception_os_request_not_possible[];
+extern const char mpexception_value_invalid_arguments[];
+extern const char mpexception_num_type_invalid_arguments[];
+extern const char mpexception_uncaught[];
+
+extern int user_interrupt_char;
+
+
+extern void mpexception_init0 (void);
+extern void mpexception_set_interrupt_char (int c);
+extern void mpexception_nlr_jump (void *o);
+extern void mpexception_keyboard_nlr_jump (void);
+
+#endif /* MPEXCEPTION_H_ */
diff --git a/cc3200/misc/pin_defs_cc3200.c b/cc3200/misc/pin_defs_cc3200.c
new file mode 100644
index 000000000..a9fb793c5
--- /dev/null
+++ b/cc3200/misc/pin_defs_cc3200.c
@@ -0,0 +1,70 @@
+/*
+ * This file is part of the Micro Python 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 "mpconfig.h"
+#include "nlr.h"
+#include "misc.h"
+#include "qstr.h"
+#include "obj.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 "gpio.h"
+#include "pin.h"
+#include "pybgpio.h"
+#include "runtime.h"
+#include MICROPY_HAL_H
+
+
+// Returns the pin mode. This value returned by this macro should be one of:
+// GPIO_DIR_MODE_IN or GPIO_DIR_MODE_OUT
+uint32_t gpio_get_mode(const gpio_obj_t *self) {
+ return MAP_GPIODirModeGet(self->port, self->bit);
+}
+
+uint32_t gpio_get_type(const gpio_obj_t *self) {
+
+ uint32_t strenght;
+ uint32_t type;
+
+ MAP_PinConfigGet(self->pin_num, &strenght, &type);
+
+ return type;
+}
+
+uint32_t gpio_get_strenght (const gpio_obj_t *self) {
+
+ uint32_t strenght;
+ uint32_t type;
+
+ MAP_PinConfigGet(self->pin_num, &strenght, &type);
+
+ return strenght;
+}
+
diff --git a/cc3200/misc/pin_defs_cc3200.h b/cc3200/misc/pin_defs_cc3200.h
new file mode 100644
index 000000000..6ba1640d6
--- /dev/null
+++ b/cc3200/misc/pin_defs_cc3200.h
@@ -0,0 +1,41 @@
+/*
+ * This file is part of the Micro Python 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.
+ */
+
+// This file contains pin definitions that are specific to the cc3200 port.
+// This file should only ever be #included by pybgpio.h and not directly.
+
+
+//*****************************************************************************
+// Define types
+//*****************************************************************************
+
+enum {
+ PORT_A0 = GPIOA0_BASE,
+ PORT_A1 = GPIOA1_BASE,
+ PORT_A2 = GPIOA2_BASE,
+ PORT_A3 = GPIOA3_BASE
+};