diff options
| author | danicampora | 2015-02-20 16:31:30 +0100 |
|---|---|---|
| committer | danicampora | 2015-02-20 16:41:55 +0100 |
| commit | 6b21c3fdd6aaee3266b1ac69017e6c1ffaa2c99b (patch) | |
| tree | 2e0e410b5f4a38cf6071a30e8a2c48fbb5e2a944 /cc3200/hal | |
| parent | 7807da20ab1e5f91d26d93553545235d3b443044 (diff) | |
cc3200: Refactor UART and I2C object creation.
I2C objects can be freed by the GC and a __del__ method is provided
in order to de-init the peripheral prior to being garbage collected.
UART objects are now added to a local list and this list is now part
of the VM_STATE.
Diffstat (limited to 'cc3200/hal')
| -rw-r--r-- | cc3200/hal/cc3200_hal.c | 20 | ||||
| -rw-r--r-- | cc3200/hal/cc3200_hal.h | 5 |
2 files changed, 18 insertions, 7 deletions
diff --git a/cc3200/hal/cc3200_hal.c b/cc3200/hal/cc3200_hal.c index 75b0dca03..7932d9e06 100644 --- a/cc3200/hal/cc3200_hal.c +++ b/cc3200/hal/cc3200_hal.c @@ -70,11 +70,16 @@ static void hal_EnableSdCard (void); #endif /****************************************************************************** - DECLARE LOCAL VARIABLES + DECLARE LOCAL DATA ******************************************************************************/ static volatile uint32_t HAL_tickCount; /****************************************************************************** + DECLARE PUBLIC DATA + ******************************************************************************/ +struct _pyb_uart_obj_t *pyb_stdio_uart; + +/****************************************************************************** DECLARE IMPORTED DATA ******************************************************************************/ extern void (* const g_pfnVectors[256])(void); @@ -134,8 +139,9 @@ void mp_hal_stdout_tx_str(const char *str) { } void mp_hal_stdout_tx_strn(const char *str, uint32_t len) { - if (MP_STATE_PORT(pyb_stdio_uart) != NULL) { - uart_tx_strn(MP_STATE_PORT(pyb_stdio_uart), str, len); + // send stdout to UART + if (pyb_stdio_uart != NULL) { + uart_tx_strn(pyb_stdio_uart, str, len); } // and also to telnet if (telnet_is_active()) { @@ -145,8 +151,8 @@ void mp_hal_stdout_tx_strn(const char *str, uint32_t len) { void mp_hal_stdout_tx_strn_cooked(const char *str, uint32_t len) { // send stdout to UART - if (MP_STATE_PORT(pyb_stdio_uart) != NULL) { - uart_tx_strn_cooked(MP_STATE_PORT(pyb_stdio_uart), str, len); + if (pyb_stdio_uart != NULL) { + uart_tx_strn_cooked(pyb_stdio_uart, str, len); } // and also to telnet if (telnet_is_active()) { @@ -159,8 +165,8 @@ int mp_hal_stdin_rx_chr(void) { if (telnet_rx_any()) { return telnet_rx_char(); } - else if (MP_STATE_PORT(pyb_stdio_uart) != NULL && uart_rx_any(MP_STATE_PORT(pyb_stdio_uart))) { - return uart_rx_char(MP_STATE_PORT(pyb_stdio_uart)); + else if (pyb_stdio_uart != NULL && uart_rx_any(pyb_stdio_uart)) { + return uart_rx_char(pyb_stdio_uart); } HAL_Delay(1); } diff --git a/cc3200/hal/cc3200_hal.h b/cc3200/hal/cc3200_hal.h index ecf500b63..71b644239 100644 --- a/cc3200/hal/cc3200_hal.h +++ b/cc3200/hal/cc3200_hal.h @@ -53,6 +53,11 @@ } /****************************************************************************** + DECLARE PUBLIC DATA + ******************************************************************************/ +extern struct _pyb_uart_obj_t *pyb_stdio_uart; + +/****************************************************************************** DECLARE PUBLIC FUNCTIONS ******************************************************************************/ |
