cc3200: Use standard implementation of keyboard interrupt.

crypto-aes
Damien George 6 years ago
parent ab9d7619fc
commit 689dae1211

@ -147,6 +147,7 @@ APP_LIB_SRC_C = $(addprefix lib/,\
netutils/netutils.c \
timeutils/timeutils.c \
utils/pyexec.c \
utils/interrupt_char.c \
utils/sys_stdio_mphal.c \
)

@ -143,10 +143,6 @@ void mp_hal_delay_ms(mp_uint_t delay) {
}
}
void mp_hal_set_interrupt_char (int c) {
mpexception_set_interrupt_char (c);
}
void mp_hal_stdout_tx_str(const char *str) {
mp_hal_stdout_tx_strn(str, strlen(str));
}

@ -32,60 +32,9 @@
#include "mpexception.h"
/******************************************************************************
DECLARE PRIVATE FUNCTIONS
******************************************************************************/
STATIC void mpexception_set_user_interrupt (int chr, void *data);
/******************************************************************************
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";
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;
}

@ -31,12 +31,4 @@ 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 // MICROPY_INCLUDED_CC3200_MISC_MPEXCEPTION_H

@ -35,6 +35,7 @@
#include "py/objlist.h"
#include "py/stream.h"
#include "py/mphal.h"
#include "lib/utils/interrupt_char.h"
#include "inc/hw_types.h"
#include "inc/hw_ints.h"
#include "inc/hw_memmap.h"
@ -251,9 +252,9 @@ 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 == user_interrupt_char) {
if (MP_STATE_PORT(os_term_dup_obj) && MP_STATE_PORT(os_term_dup_obj)->stream_o == self && data == mp_interrupt_char) {
// raise an exception when interrupts are finished
mpexception_keyboard_nlr_jump();
mp_keyboard_interrupt();
} else { // there's always a read buffer available
uint16_t next_head = (self->read_buf_head + 1) % PYBUART_RX_BUFFER_LEN;
if (next_head != self->read_buf_tail) {

@ -61,7 +61,6 @@
#include "telnet.h"
#include "debug.h"
#include "sflash_diskio.h"
#include "mpexception.h"
#include "random.h"
#include "pybi2c.h"
#include "pins.h"
@ -143,7 +142,6 @@ 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
mpexception_init0();
mp_irq_init0();
pyb_sleep_init0();
pin_init0();

@ -29,6 +29,7 @@
#include "py/mpconfig.h"
#include "py/obj.h"
#include "py/mphal.h"
#include "lib/utils/interrupt_char.h"
#include "telnet.h"
#include "simplelink.h"
#include "modnetwork.h"
@ -445,9 +446,9 @@ static void telnet_parse_input (uint8_t *str, int16_t *len) {
for (uint8_t *_str = b_str; _str < b_str + b_len; ) {
if (*_str <= 127) {
if (telnet_data.state == E_TELNET_STE_LOGGED_IN && *_str == user_interrupt_char) {
if (telnet_data.state == E_TELNET_STE_LOGGED_IN && *_str == mp_interrupt_char) {
// raise a keyboard exception
mpexception_keyboard_nlr_jump();
mp_keyboard_interrupt();
(*len)--;
_str++;
}

Loading…
Cancel
Save