Skip to content

Commit 689dae1

Browse files
committed
cc3200: Use standard implementation of keyboard interrupt.
1 parent ab9d761 commit 689dae1

File tree

7 files changed

+7
-69
lines changed

7 files changed

+7
-69
lines changed

cc3200/application.mk

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -147,6 +147,7 @@ APP_LIB_SRC_C = $(addprefix lib/,\
147147
netutils/netutils.c \
148148
timeutils/timeutils.c \
149149
utils/pyexec.c \
150+
utils/interrupt_char.c \
150151
utils/sys_stdio_mphal.c \
151152
)
152153

cc3200/hal/cc3200_hal.c

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -143,10 +143,6 @@ void mp_hal_delay_ms(mp_uint_t delay) {
143143
}
144144
}
145145

146-
void mp_hal_set_interrupt_char (int c) {
147-
mpexception_set_interrupt_char (c);
148-
}
149-
150146
void mp_hal_stdout_tx_str(const char *str) {
151147
mp_hal_stdout_tx_strn(str, strlen(str));
152148
}

cc3200/misc/mpexception.c

Lines changed: 0 additions & 51 deletions
Original file line numberDiff line numberDiff line change
@@ -32,60 +32,9 @@
3232
#include "mpexception.h"
3333

3434

35-
/******************************************************************************
36-
DECLARE PRIVATE FUNCTIONS
37-
******************************************************************************/
38-
STATIC void mpexception_set_user_interrupt (int chr, void *data);
39-
4035
/******************************************************************************
4136
DECLARE EXPORTED DATA
4237
******************************************************************************/
4338
const char mpexception_value_invalid_arguments[] = "invalid argument(s) value";
4439
const char mpexception_num_type_invalid_arguments[] = "invalid argument(s) num/type";
4540
const char mpexception_uncaught[] = "uncaught exception";
46-
47-
int user_interrupt_char = -1;
48-
49-
/******************************************************************************
50-
DECLARE PRIVATE DATA
51-
******************************************************************************/
52-
STATIC void *user_interrupt_data = NULL;
53-
54-
/******************************************************************************
55-
DEFINE PUBLIC FUNCTIONS
56-
******************************************************************************/
57-
58-
void mpexception_init0 (void) {
59-
// Create an exception object for interrupting through the stdin uart
60-
MP_STATE_PORT(mp_const_user_interrupt) = mp_obj_new_exception(&mp_type_KeyboardInterrupt);
61-
mpexception_set_user_interrupt (-1, MP_STATE_PORT(mp_const_user_interrupt));
62-
}
63-
64-
void mpexception_set_interrupt_char (int c) {
65-
if (c != -1) {
66-
mp_obj_exception_clear_traceback(MP_STATE_PORT(mp_const_user_interrupt));
67-
}
68-
mpexception_set_user_interrupt(c, MP_STATE_PORT(mp_const_user_interrupt));
69-
}
70-
71-
// Call this function to raise a pending exception during an interrupt.
72-
// It will try to raise the exception "softly" by setting the
73-
// mp_pending_exception variable hoping that the VM will notice it.
74-
void mpexception_nlr_jump (void *o) {
75-
if (MP_STATE_PORT(mp_pending_exception) == MP_OBJ_NULL) {
76-
MP_STATE_PORT(mp_pending_exception) = o;
77-
}
78-
}
79-
80-
void mpexception_keyboard_nlr_jump (void) {
81-
mpexception_nlr_jump (user_interrupt_data);
82-
}
83-
84-
/******************************************************************************
85-
DEFINE PRIVATE FUNCTIONS
86-
******************************************************************************/
87-
88-
STATIC void mpexception_set_user_interrupt (int chr, void *data) {
89-
user_interrupt_char = chr;
90-
user_interrupt_data = data;
91-
}

cc3200/misc/mpexception.h

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -31,12 +31,4 @@ extern const char mpexception_value_invalid_arguments[];
3131
extern const char mpexception_num_type_invalid_arguments[];
3232
extern const char mpexception_uncaught[];
3333

34-
extern int user_interrupt_char;
35-
36-
37-
extern void mpexception_init0 (void);
38-
extern void mpexception_set_interrupt_char (int c);
39-
extern void mpexception_nlr_jump (void *o);
40-
extern void mpexception_keyboard_nlr_jump (void);
41-
4234
#endif // MICROPY_INCLUDED_CC3200_MISC_MPEXCEPTION_H

cc3200/mods/pybuart.c

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@
3535
#include "py/objlist.h"
3636
#include "py/stream.h"
3737
#include "py/mphal.h"
38+
#include "lib/utils/interrupt_char.h"
3839
#include "inc/hw_types.h"
3940
#include "inc/hw_ints.h"
4041
#include "inc/hw_memmap.h"
@@ -251,9 +252,9 @@ STATIC void UARTGenericIntHandler(uint32_t uart_id) {
251252
MAP_UARTIntClear(self->reg, UART_INT_RX | UART_INT_RT);
252253
while (UARTCharsAvail(self->reg)) {
253254
int data = MAP_UARTCharGetNonBlocking(self->reg);
254-
if (MP_STATE_PORT(os_term_dup_obj) && MP_STATE_PORT(os_term_dup_obj)->stream_o == self && data == user_interrupt_char) {
255+
if (MP_STATE_PORT(os_term_dup_obj) && MP_STATE_PORT(os_term_dup_obj)->stream_o == self && data == mp_interrupt_char) {
255256
// raise an exception when interrupts are finished
256-
mpexception_keyboard_nlr_jump();
257+
mp_keyboard_interrupt();
257258
} else { // there's always a read buffer available
258259
uint16_t next_head = (self->read_buf_head + 1) % PYBUART_RX_BUFFER_LEN;
259260
if (next_head != self->read_buf_tail) {

cc3200/mptask.c

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,6 @@
6161
#include "telnet.h"
6262
#include "debug.h"
6363
#include "sflash_diskio.h"
64-
#include "mpexception.h"
6564
#include "random.h"
6665
#include "pybi2c.h"
6766
#include "pins.h"
@@ -143,7 +142,6 @@ void TASK_MicroPython (void *pvParameters) {
143142
mp_obj_list_append(mp_sys_path, MP_OBJ_NEW_QSTR(MP_QSTR_)); // current dir (or base dir of the script)
144143

145144
// execute all basic initializations
146-
mpexception_init0();
147145
mp_irq_init0();
148146
pyb_sleep_init0();
149147
pin_init0();

cc3200/telnet/telnet.c

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@
2929
#include "py/mpconfig.h"
3030
#include "py/obj.h"
3131
#include "py/mphal.h"
32+
#include "lib/utils/interrupt_char.h"
3233
#include "telnet.h"
3334
#include "simplelink.h"
3435
#include "modnetwork.h"
@@ -445,9 +446,9 @@ static void telnet_parse_input (uint8_t *str, int16_t *len) {
445446

446447
for (uint8_t *_str = b_str; _str < b_str + b_len; ) {
447448
if (*_str <= 127) {
448-
if (telnet_data.state == E_TELNET_STE_LOGGED_IN && *_str == user_interrupt_char) {
449+
if (telnet_data.state == E_TELNET_STE_LOGGED_IN && *_str == mp_interrupt_char) {
449450
// raise a keyboard exception
450-
mpexception_keyboard_nlr_jump();
451+
mp_keyboard_interrupt();
451452
(*len)--;
452453
_str++;
453454
}

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy