summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--ports/cc3200/ftp/ftp.c1
-rw-r--r--ports/cc3200/hal/cc3200_hal.c33
-rw-r--r--ports/cc3200/mods/modos.c48
-rw-r--r--ports/cc3200/mods/modos.h47
-rw-r--r--ports/cc3200/mods/pybuart.c3
-rw-r--r--ports/cc3200/mpconfigport.h1
-rw-r--r--ports/cc3200/mptask.c4
7 files changed, 13 insertions, 124 deletions
diff --git a/ports/cc3200/ftp/ftp.c b/ports/cc3200/ftp/ftp.c
index 5d4fc6fb5..fc071fc95 100644
--- a/ports/cc3200/ftp/ftp.c
+++ b/ports/cc3200/ftp/ftp.c
@@ -48,7 +48,6 @@
#include "fifo.h"
#include "socketfifo.h"
#include "updater.h"
-#include "modos.h"
/******************************************************************************
DEFINE PRIVATE CONSTANTS
diff --git a/ports/cc3200/hal/cc3200_hal.c b/ports/cc3200/hal/cc3200_hal.c
index 4d9d7647d..b75a40151 100644
--- a/ports/cc3200/hal/cc3200_hal.c
+++ b/ports/cc3200/hal/cc3200_hal.c
@@ -36,6 +36,7 @@
#include "py/mphal.h"
#include "py/runtime.h"
#include "py/objstr.h"
+#include "extmod/misc.h"
#include "inc/hw_types.h"
#include "inc/hw_ints.h"
#include "inc/hw_nvic.h"
@@ -49,7 +50,6 @@
#include "pybuart.h"
#include "utils.h"
#include "irq.h"
-#include "modos.h"
#ifdef USE_FREERTOS
#include "FreeRTOS.h"
@@ -142,14 +142,7 @@ void mp_hal_delay_ms(mp_uint_t delay) {
}
void mp_hal_stdout_tx_strn(const char *str, size_t len) {
- if (MP_STATE_PORT(os_term_dup_obj)) {
- if (mp_obj_is_type(MP_STATE_PORT(os_term_dup_obj)->stream_o, &pyb_uart_type)) {
- uart_tx_strn(MP_STATE_PORT(os_term_dup_obj)->stream_o, str, len);
- } else {
- MP_STATE_PORT(os_term_dup_obj)->write[2] = mp_obj_new_str_of_type(&mp_type_str, (const byte *)str, len);
- mp_call_method_n_kw(1, 0, MP_STATE_PORT(os_term_dup_obj)->write);
- }
- }
+ mp_os_dupterm_tx_strn(str, len);
// and also to telnet
telnet_tx_strn(str, len);
}
@@ -159,22 +152,14 @@ int mp_hal_stdin_rx_chr(void) {
// read telnet first
if (telnet_rx_any()) {
return telnet_rx_char();
- } else if (MP_STATE_PORT(os_term_dup_obj)) { // then the stdio_dup
- if (mp_obj_is_type(MP_STATE_PORT(os_term_dup_obj)->stream_o, &pyb_uart_type)) {
- if (uart_rx_any(MP_STATE_PORT(os_term_dup_obj)->stream_o)) {
- return uart_rx_char(MP_STATE_PORT(os_term_dup_obj)->stream_o);
- }
- } else {
- MP_STATE_PORT(os_term_dup_obj)->read[2] = mp_obj_new_int(1);
- mp_obj_t data = mp_call_method_n_kw(1, 0, MP_STATE_PORT(os_term_dup_obj)->read);
- // data len is > 0
- if (mp_obj_is_true(data)) {
- mp_buffer_info_t bufinfo;
- mp_get_buffer_raise(data, &bufinfo, MP_BUFFER_READ);
- return ((int *)(bufinfo.buf))[0];
- }
- }
}
+
+ // then dupterm
+ int dupterm_c = mp_os_dupterm_rx_chr();
+ if (dupterm_c >= 0) {
+ return dupterm_c;
+ }
+
mp_hal_delay_ms(1);
}
}
diff --git a/ports/cc3200/mods/modos.c b/ports/cc3200/mods/modos.c
index 1a854750f..5228d1f4b 100644
--- a/ports/cc3200/mods/modos.c
+++ b/ports/cc3200/mods/modos.c
@@ -35,8 +35,8 @@
#include "lib/oofatfs/ff.h"
#include "lib/oofatfs/diskio.h"
#include "genhdr/mpversion.h"
-#include "modos.h"
#include "sflash_diskio.h"
+#include "extmod/misc.h"
#include "extmod/vfs.h"
#include "extmod/vfs_fat.h"
#include "random.h"
@@ -55,25 +55,6 @@
///
/// On boot up, the current directory is `/flash`.
-/******************************************************************************
- DECLARE PRIVATE DATA
- ******************************************************************************/
-STATIC os_term_dup_obj_t os_term_dup_obj;
-
-/******************************************************************************
- DEFINE PUBLIC FUNCTIONS
- ******************************************************************************/
-
-void osmount_unmount_all (void) {
- //TODO
- /*
- for (mp_uint_t i = 0; i < MP_STATE_PORT(mount_obj_list).len; i++) {
- os_fs_mount_t *mount_obj = ((os_fs_mount_t *)(MP_STATE_PORT(mount_obj_list).items[i]));
- unmount(mount_obj);
- }
- */
-}
-
/******************************************************************************/
// MicroPython bindings
//
@@ -120,31 +101,6 @@ STATIC mp_obj_t os_urandom(mp_obj_t num) {
}
STATIC MP_DEFINE_CONST_FUN_OBJ_1(os_urandom_obj, os_urandom);
-STATIC mp_obj_t os_dupterm(uint n_args, const mp_obj_t *args) {
- if (n_args == 0) {
- if (MP_STATE_PORT(os_term_dup_obj) == MP_OBJ_NULL) {
- return mp_const_none;
- } else {
- return MP_STATE_PORT(os_term_dup_obj)->stream_o;
- }
- } else {
- mp_obj_t stream_o = args[0];
- if (stream_o == mp_const_none) {
- MP_STATE_PORT(os_term_dup_obj) = MP_OBJ_NULL;
- } else {
- if (!mp_obj_is_type(stream_o, &pyb_uart_type)) {
- // must be a stream-like object providing at least read and write methods
- mp_load_method(stream_o, MP_QSTR_read, os_term_dup_obj.read);
- mp_load_method(stream_o, MP_QSTR_write, os_term_dup_obj.write);
- }
- os_term_dup_obj.stream_o = stream_o;
- MP_STATE_PORT(os_term_dup_obj) = &os_term_dup_obj;
- }
- return mp_const_none;
- }
-}
-STATIC MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(os_dupterm_obj, 0, 1, os_dupterm);
-
STATIC const mp_rom_map_elem_t os_module_globals_table[] = {
{ MP_ROM_QSTR(MP_QSTR___name__), MP_ROM_QSTR(MP_QSTR_os) },
@@ -170,7 +126,7 @@ STATIC const mp_rom_map_elem_t os_module_globals_table[] = {
{ MP_ROM_QSTR(MP_QSTR_mount), MP_ROM_PTR(&mp_vfs_mount_obj) },
{ MP_ROM_QSTR(MP_QSTR_umount), MP_ROM_PTR(&mp_vfs_umount_obj) },
{ MP_ROM_QSTR(MP_QSTR_VfsFat), MP_ROM_PTR(&mp_fat_vfs_type) },
- { MP_ROM_QSTR(MP_QSTR_dupterm), MP_ROM_PTR(&os_dupterm_obj) },
+ { MP_ROM_QSTR(MP_QSTR_dupterm), MP_ROM_PTR(&mp_os_dupterm_obj) },
};
STATIC MP_DEFINE_CONST_DICT(os_module_globals, os_module_globals_table);
diff --git a/ports/cc3200/mods/modos.h b/ports/cc3200/mods/modos.h
deleted file mode 100644
index 5fa2a967d..000000000
--- a/ports/cc3200/mods/modos.h
+++ /dev/null
@@ -1,47 +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_MODS_MODOS_H
-#define MICROPY_INCLUDED_CC3200_MODS_MODOS_H
-
-#include "py/obj.h"
-
-/******************************************************************************
- DEFINE PUBLIC TYPES
- ******************************************************************************/
-
-typedef struct _os_term_dup_obj_t {
- mp_obj_t stream_o;
- mp_obj_t read[3];
- mp_obj_t write[3];
-} os_term_dup_obj_t;
-
-/******************************************************************************
- DECLARE PUBLIC FUNCTIONS
- ******************************************************************************/
-void osmount_unmount_all (void);
-
-#endif // MICROPY_INCLUDED_CC3200_MODS_MODOS_H
diff --git a/ports/cc3200/mods/pybuart.c b/ports/cc3200/mods/pybuart.c
index 5d6ad0752..c9a753da0 100644
--- a/ports/cc3200/mods/pybuart.c
+++ b/ports/cc3200/mods/pybuart.c
@@ -50,7 +50,6 @@
#include "pin.h"
#include "pybpin.h"
#include "pins.h"
-#include "modos.h"
/// \moduleref pyb
/// \class UART - duplex serial communication bus
@@ -249,7 +248,7 @@ STATIC void UARTGenericIntHandler(uint32_t uart_id) {
MAP_UARTIntClear(self->reg, UART_INT_RX | UART_INT_RT);
while (UARTCharsAvail(self->reg)) {
int data = MAP_UARTCharGetNonBlocking(self->reg);
- if (MP_STATE_PORT(os_term_dup_obj) && MP_STATE_PORT(os_term_dup_obj)->stream_o == self && data == mp_interrupt_char) {
+ if (MP_STATE_VM(dupterm_objs[0]) == MP_OBJ_FROM_PTR(self) && data == mp_interrupt_char) {
// raise an exception when interrupts are finished
mp_sched_keyboard_interrupt();
} else { // there's always a read buffer available
diff --git a/ports/cc3200/mpconfigport.h b/ports/cc3200/mpconfigport.h
index 64098c3fc..cb0167ae0 100644
--- a/ports/cc3200/mpconfigport.h
+++ b/ports/cc3200/mpconfigport.h
@@ -115,6 +115,7 @@
#define MICROPY_PY_RE (1)
#define MICROPY_PY_HEAPQ (0)
#define MICROPY_PY_HASHLIB (0)
+#define MICROPY_PY_OS_DUPTERM (1)
#define MICROPY_PY_SELECT (1)
#define MICROPY_PY_TIME (1)
#define MICROPY_PY_TIME_GMTIME_LOCALTIME_MKTIME (1)
diff --git a/ports/cc3200/mptask.c b/ports/cc3200/mptask.c
index abf8484b0..83b5c091b 100644
--- a/ports/cc3200/mptask.c
+++ b/ports/cc3200/mptask.c
@@ -70,7 +70,6 @@
#include "cryptohash.h"
#include "mpirq.h"
#include "updater.h"
-#include "modos.h"
#include "antenna.h"
#include "task.h"
@@ -247,9 +246,6 @@ soft_reset_exit:
// clean-up the user socket space
modusocket_close_all_user_sockets();
- // unmount all user file systems
- osmount_unmount_all();
-
// wait for pending transactions to complete
mp_hal_delay_ms(20);