Skip to content

Commit f48b700

Browse files
committed
merge finished
1 parent bc760dd commit f48b700

File tree

19 files changed

+66
-68
lines changed

19 files changed

+66
-68
lines changed

extmod/moduhashlib.c

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -29,14 +29,6 @@
2929

3030
#include "py/runtime.h"
3131

32-
static void check_not_unicode(const mp_obj_t arg) {
33-
#if MICROPY_CPYTHON_COMPAT
34-
if (MP_OBJ_IS_STR(arg)) {
35-
mp_raise_TypeError("a bytes-like object is required");
36-
}
37-
#endif
38-
}
39-
4032
#if MICROPY_PY_UHASHLIB
4133

4234
#if MICROPY_PY_UHASHLIB_SHA256
@@ -102,6 +94,14 @@ STATIC mp_obj_t uhashlib_sha256_digest(mp_obj_t self_in) {
10294

10395
#else
10496

97+
static void check_not_unicode(const mp_obj_t arg) {
98+
#if MICROPY_CPYTHON_COMPAT
99+
if (MP_OBJ_IS_STR(arg)) {
100+
mp_raise_TypeError("a bytes-like object is required");
101+
}
102+
#endif
103+
}
104+
105105
STATIC mp_obj_t uhashlib_sha256_make_new(const mp_obj_type_t *type, size_t n_args, size_t n_kw, const mp_obj_t *args) {
106106
mp_arg_check_num(n_args, n_kw, 0, 1, false);
107107
mp_obj_hash_t *o = m_new_obj_var(mp_obj_hash_t, char, sizeof(CRYAL_SHA256_CTX));

extmod/vfs_fat.h

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -60,15 +60,6 @@ typedef struct _pyb_file_obj_t {
6060
FIL fp;
6161
} pyb_file_obj_t;
6262

63-
64-
// These should be general types (mpy TOOD says so). In micropython, these are defined in
65-
// mpconfigport.h.
66-
////////////#define mp_type_fileio mp_type_vfs_fat_fileio
67-
////////////#define mp_type_textio mp_type_vfs_fat_textio
68-
69-
////////////extern const mp_obj_type_t mp_type_fileio;
70-
////////////extern const mp_obj_type_t mp_type_textio;
71-
7263
extern const byte fresult_to_errno_table[20];
7364
extern const mp_obj_type_t mp_fat_vfs_type;
7465
extern const mp_obj_type_t mp_type_vfs_fat_fileio;

extmod/vfs_fat_diskio.c

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -75,8 +75,9 @@ DRESULT disk_read (
7575
return RES_ERROR;
7676
}
7777
} else {
78+
mp_obj_array_t ar = {{&mp_type_bytearray}, BYTEARRAY_TYPECODE, 0, count * SECSIZE(&vfs->fatfs), buff};
7879
vfs->readblocks[2] = MP_OBJ_NEW_SMALL_INT(sector);
79-
vfs->readblocks[3] = mp_obj_new_bytearray_by_ref(count * SECSIZE(&vfs->fatfs), buff);
80+
vfs->readblocks[3] = MP_OBJ_FROM_PTR(&ar);
8081
nlr_buf_t nlr;
8182
if (nlr_push(&nlr) == 0) {
8283
mp_obj_t ret = mp_call_method_n_kw(2, 0, vfs->readblocks);
@@ -120,8 +121,9 @@ DRESULT disk_write (
120121
return RES_ERROR;
121122
}
122123
} else {
124+
mp_obj_array_t ar = {{&mp_type_bytearray}, BYTEARRAY_TYPECODE, 0, count * SECSIZE(&vfs->fatfs), (void*)buff};
123125
vfs->writeblocks[2] = MP_OBJ_NEW_SMALL_INT(sector);
124-
vfs->writeblocks[3] = mp_obj_new_bytearray_by_ref(count * SECSIZE(&vfs->fatfs), (void*)buff);
126+
vfs->writeblocks[3] = MP_OBJ_FROM_PTR(&ar);
125127
nlr_buf_t nlr;
126128
if (nlr_push(&nlr) == 0) {
127129
mp_obj_t ret = mp_call_method_n_kw(2, 0, vfs->writeblocks);

lib/mp-readline/readline.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,8 @@
2626
#ifndef MICROPY_INCLUDED_LIB_MP_READLINE_READLINE_H
2727
#define MICROPY_INCLUDED_LIB_MP_READLINE_READLINE_H
2828

29+
#include "py/misc.h"
30+
2931
#define CHAR_CTRL_A (1)
3032
#define CHAR_CTRL_B (2)
3133
#define CHAR_CTRL_C (3)

ports/atmel-samd/mpconfigport.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -123,6 +123,9 @@ typedef long mp_off_t;
123123

124124
#define MP_PLAT_PRINT_STRN(str, len) mp_hal_stdout_tx_strn_cooked(str, len)
125125

126+
#define mp_type_fileio mp_type_vfs_fat_fileio
127+
#define mp_type_textio mp_type_vfs_fat_textio
128+
126129
#define mp_import_stat mp_vfs_import_stat
127130
#define mp_builtin_open_obj mp_vfs_open_obj
128131

ports/esp8266/common-hal/neopixel_write/__init__.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,5 +29,5 @@
2929
#include "espneopixel.h"
3030

3131
void common_hal_neopixel_write(const digitalio_digitalinout_obj_t* digitalinout, uint8_t *pixels, uint32_t numBytes) {
32-
esp_neopixel_write(digitalinout->pin->gpio_number, pixels, numBytes);
32+
esp_neopixel_write(digitalinout->pin->gpio_number, pixels, numBytes, true /*800 kHz*/);
3333
}

ports/esp8266/esp_mphal.c

Lines changed: 15 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -35,18 +35,15 @@
3535
#include "extmod/misc.h"
3636
#include "lib/utils/pyexec.h"
3737

38-
STATIC byte stdin_ringbuf_array[256];
39-
ringbuf_t stdin_ringbuf = {stdin_ringbuf_array, sizeof(stdin_ringbuf_array), 0, 0};
38+
STATIC byte input_buf_array[256];
39+
ringbuf_t stdin_ringbuf = {input_buf_array, sizeof(input_buf_array)};
4040
void mp_hal_debug_tx_strn_cooked(void *env, const char *str, uint32_t len);
4141
const mp_print_t mp_debug_print = {NULL, mp_hal_debug_tx_strn_cooked};
4242

43-
int uart_attached_to_dupterm;
44-
4543
void mp_hal_init(void) {
4644
//ets_wdt_disable(); // it's a pain while developing
4745
mp_hal_rtc_init();
4846
uart_init(UART_BIT_RATE_115200, UART_BIT_RATE_115200);
49-
uart_attached_to_dupterm = 0;
5047
}
5148

5249
void mp_hal_delay_us(uint32_t us) {
@@ -87,11 +84,19 @@ void mp_hal_debug_str(const char *str) {
8784
#endif
8885

8986
void mp_hal_stdout_tx_str(const char *str) {
90-
mp_uos_dupterm_tx_strn(str, strlen(str));
87+
const char *last = str;
88+
while (*str) {
89+
uart_tx_one_char(UART0, *str++);
90+
}
91+
mp_uos_dupterm_tx_strn(last, str - last);
9192
}
9293

9394
void mp_hal_stdout_tx_strn(const char *str, uint32_t len) {
94-
mp_uos_dupterm_tx_strn(str, len);
95+
const char *last = str;
96+
while (len--) {
97+
uart_tx_one_char(UART0, *str++);
98+
}
99+
mp_uos_dupterm_tx_strn(last, str - last);
95100
}
96101

97102
void mp_hal_stdout_tx_strn_cooked(const char *str, uint32_t len) {
@@ -101,11 +106,13 @@ void mp_hal_stdout_tx_strn_cooked(const char *str, uint32_t len) {
101106
if (str > last) {
102107
mp_uos_dupterm_tx_strn(last, str - last);
103108
}
109+
uart_tx_one_char(UART0, '\r');
110+
uart_tx_one_char(UART0, '\n');
104111
mp_uos_dupterm_tx_strn("\r\n", 2);
105112
++str;
106113
last = str;
107114
} else {
108-
++str;
115+
uart_tx_one_char(UART0, *str++);
109116
}
110117
}
111118
if (str > last) {

ports/esp8266/esp_mphal.h

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -40,9 +40,6 @@ void mp_hal_signal_input(void);
4040
// Call this when data is available in dupterm object
4141
void mp_hal_signal_dupterm_input(void);
4242

43-
// This variable counts how many times the UART is attached to dupterm
44-
extern int uart_attached_to_dupterm;
45-
4643
void mp_hal_init(void);
4744
void mp_hal_rtc_init(void);
4845

ports/esp8266/uart.c

Lines changed: 9 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -34,11 +34,6 @@ static int uart_os = UART_OS;
3434
static os_event_t uart_evt_queue[16];
3535
#endif
3636

37-
// A small, static ring buffer for incoming chars
38-
// This will only be populated if the UART is not attached to dupterm
39-
static byte uart_ringbuf_array[16];
40-
static ringbuf_t uart_ringbuf = {uart_ringbuf_array, sizeof(uart_ringbuf_array), 0, 0};
41-
4237
static void uart0_rx_intr_handler(void *para);
4338

4439
void soft_reset(void);
@@ -175,26 +170,18 @@ static void uart0_rx_intr_handler(void *para) {
175170

176171
while (READ_PERI_REG(UART_STATUS(uart_no)) & (UART_RXFIFO_CNT << UART_RXFIFO_CNT_S)) {
177172
uint8 RcvChar = READ_PERI_REG(UART_FIFO(uart_no)) & 0xff;
178-
// For efficiency, when connected to dupterm we put incoming chars
179-
// directly on stdin_ringbuf, rather than going via uart_ringbuf
180-
if (uart_attached_to_dupterm) {
181-
if (RcvChar == mp_interrupt_char) {
182-
mp_keyboard_interrupt();
183-
} else {
184-
ringbuf_put(&stdin_ringbuf, RcvChar);
185-
}
173+
if (RcvChar == mp_interrupt_char) {
174+
mp_keyboard_interrupt();
186175
} else {
187-
ringbuf_put(&uart_ringbuf, RcvChar);
176+
ringbuf_put(&stdin_ringbuf, RcvChar);
188177
}
189178
}
190179

180+
mp_hal_signal_input();
181+
191182
// Clear pending FIFO interrupts
192183
WRITE_PERI_REG(UART_INT_CLR(UART_REPL), UART_RXFIFO_TOUT_INT_CLR | UART_RXFIFO_FULL_INT_ST);
193184
ETS_UART_INTR_ENABLE();
194-
195-
if (uart_attached_to_dupterm) {
196-
mp_hal_signal_input();
197-
}
198185
}
199186
}
200187

@@ -203,7 +190,7 @@ static void uart0_rx_intr_handler(void *para) {
203190
bool uart_rx_wait(uint32_t timeout_us) {
204191
uint32_t start = system_get_time();
205192
for (;;) {
206-
if (uart_ringbuf.iget != uart_ringbuf.iput) {
193+
if (stdin_ringbuf.iget != stdin_ringbuf.iput) {
207194
return true; // have at least 1 char ready for reading
208195
}
209196
if (system_get_time() - start >= timeout_us) {
@@ -214,7 +201,7 @@ bool uart_rx_wait(uint32_t timeout_us) {
214201
}
215202

216203
int uart_rx_any(uint8 uart) {
217-
if (uart_ringbuf.iget != uart_ringbuf.iput) {
204+
if (stdin_ringbuf.iget != stdin_ringbuf.iput) {
218205
return true; // have at least 1 char ready for reading
219206
}
220207
return false;
@@ -230,7 +217,7 @@ int uart_tx_any_room(uint8 uart) {
230217

231218
// Returns char from the input buffer, else -1 if buffer is empty.
232219
int uart_rx_char(void) {
233-
return ringbuf_get(&uart_ringbuf);
220+
return ringbuf_get(&stdin_ringbuf);
234221
}
235222

236223
int uart_rx_one_char(uint8 uart_no) {
@@ -288,7 +275,7 @@ void uart_task_handler(os_event_t *evt) {
288275
}
289276

290277
int c, ret = 0;
291-
while ((c = ringbuf_get(&input_buf)) >= 0) {
278+
while ((c = ringbuf_get(&stdin_ringbuf)) >= 0) {
292279
if (c == mp_interrupt_char) {
293280
mp_keyboard_interrupt();
294281
}

ports/nrf/modules/ubluepy/ubluepy_scan_entry.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -109,7 +109,7 @@ STATIC mp_obj_t scan_entry_get_scan_data(mp_obj_t self_in) {
109109
vstr_t vstr;
110110
vstr_init(&vstr, len);
111111
vstr_printf(&vstr, "%s", text);
112-
description = mp_obj_new_str(vstr.buf, vstr.len, false);
112+
description = mp_obj_new_str(vstr.buf, vstr.len);
113113
vstr_clear(&vstr);
114114
}
115115
}

0 commit comments

Comments
 (0)