Skip to content

Commit f714f53

Browse files
committed
Merge remote-tracking branch 'adafruit/main' into ble_hci
2 parents 097f93a + ba2db85 commit f714f53

File tree

25 files changed

+347
-62
lines changed

25 files changed

+347
-62
lines changed

lib/mp-readline/readline.c

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -144,7 +144,7 @@ int readline_process_char(int c) {
144144
goto right_arrow_key;
145145
} else if (c == CHAR_CTRL_K) {
146146
// CTRL-K is kill from cursor to end-of-line, inclusive
147-
vstr_cut_tail_bytes(rl.line, last_line_len - rl.cursor_pos);
147+
vstr_cut_tail_bytes(rl.line, rl.line->len - rl.cursor_pos);
148148
// set redraw parameters
149149
redraw_from_cursor = true;
150150
} else if (c == CHAR_CTRL_N) {
@@ -155,6 +155,7 @@ int readline_process_char(int c) {
155155
goto up_arrow_key;
156156
} else if (c == CHAR_CTRL_U) {
157157
// CTRL-U is kill from beginning-of-line up to cursor
158+
cont_chars = count_cont_bytes(rl.line->buf+rl.orig_line_len, rl.line->buf+rl.cursor_pos);
158159
vstr_cut_out_bytes(rl.line, rl.orig_line_len, rl.cursor_pos - rl.orig_line_len);
159160
// set redraw parameters
160161
redraw_step_back = rl.cursor_pos - rl.orig_line_len;
@@ -342,6 +343,7 @@ int readline_process_char(int c) {
342343
if (c == '~') {
343344
if (rl.escape_seq_buf[0] == '1' || rl.escape_seq_buf[0] == '7') {
344345
home_key:
346+
cont_chars = count_cont_bytes(rl.line->buf+rl.orig_line_len, rl.line->buf+rl.cursor_pos);
345347
redraw_step_back = rl.cursor_pos - rl.orig_line_len;
346348
} else if (rl.escape_seq_buf[0] == '4' || rl.escape_seq_buf[0] == '8') {
347349
end_key:
@@ -352,7 +354,12 @@ int readline_process_char(int c) {
352354
delete_key:
353355
#endif
354356
if (rl.cursor_pos < rl.line->len) {
355-
vstr_cut_out_bytes(rl.line, rl.cursor_pos, 1);
357+
size_t len = 1;
358+
while (UTF8_IS_CONT(rl.line->buf[rl.cursor_pos+len]) &&
359+
rl.cursor_pos+len < rl.line->len) {
360+
len++;
361+
}
362+
vstr_cut_out_bytes(rl.line, rl.cursor_pos, len);
356363
redraw_from_cursor = true;
357364
}
358365
} else {

locale/circuitpython.pot

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ msgid ""
88
msgstr ""
99
"Project-Id-Version: PACKAGE VERSION\n"
1010
"Report-Msgid-Bugs-To: \n"
11-
"POT-Creation-Date: 2020-08-14 09:36-0400\n"
11+
"POT-Creation-Date: 2020-08-18 11:19-0400\n"
1212
"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
1313
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
1414
"Language-Team: LANGUAGE <[email protected]>\n"
@@ -744,7 +744,7 @@ msgstr ""
744744

745745
#: shared-bindings/aesio/aes.c shared-bindings/busio/SPI.c
746746
#: shared-bindings/microcontroller/Pin.c
747-
#: shared-bindings/neopixel_write/__init__.c shared-bindings/pulseio/PulseOut.c
747+
#: shared-bindings/neopixel_write/__init__.c
748748
#: shared-bindings/terminalio/Terminal.c
749749
msgid "Expected a %q"
750750
msgstr ""
@@ -1328,6 +1328,15 @@ msgstr ""
13281328
msgid "Polygon needs at least 3 points"
13291329
msgstr ""
13301330

1331+
#: ports/atmel-samd/common-hal/pulseio/PulseOut.c
1332+
#: ports/cxd56/common-hal/pulseio/PulseOut.c
1333+
#: ports/nrf/common-hal/pulseio/PulseOut.c
1334+
#: ports/stm/common-hal/pulseio/PulseOut.c
1335+
msgid ""
1336+
"Port does not accept pins or frequency. "
1337+
"Construct and pass a PWMOut Carrier instead"
1338+
msgstr ""
1339+
13311340
#: shared-bindings/_bleio/Adapter.c
13321341
msgid "Prefix buffer must be on the heap"
13331342
msgstr ""
@@ -1340,6 +1349,10 @@ msgstr ""
13401349
msgid "Pull not used when direction is output."
13411350
msgstr ""
13421351

1352+
#: ports/stm/ref/pulseout-pre-timeralloc.c
1353+
msgid "PulseOut not supported on this chip"
1354+
msgstr ""
1355+
13431356
#: ports/stm/common-hal/os/__init__.c
13441357
msgid "RNG DeInit Error"
13451358
msgstr ""

ports/atmel-samd/Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,7 @@ ifeq ($(CHIP_FAMILY), same54)
103103
PERIPHERALS_CHIP_FAMILY=sam_d5x_e5x
104104
OPTIMIZATION_FLAGS ?= -O2
105105
# TinyUSB defines
106-
CFLAGS += -DCFG_TUSB_MCU=OPT_MCU_SAMD51 -DCFG_TUD_MIDI_RX_BUFSIZE=128 -DCFG_TUD_CDC_RX_BUFSIZE=256 -DCFG_TUD_MIDI_TX_BUFSIZE=128 -DCFG_TUD_CDC_TX_BUFSIZE=256 -DCFG_TUD_MSC_BUFSIZE=1024
106+
CFLAGS += -DCFG_TUSB_MCU=OPT_MCU_SAME5X -DCFG_TUD_MIDI_RX_BUFSIZE=128 -DCFG_TUD_CDC_RX_BUFSIZE=256 -DCFG_TUD_MIDI_TX_BUFSIZE=128 -DCFG_TUD_CDC_TX_BUFSIZE=256 -DCFG_TUD_MSC_BUFSIZE=1024
107107
endif
108108

109109
# option to override default optimization level, set in boards/$(BOARD)/mpconfigboard.mk

ports/atmel-samd/boards/mini_sam_m4/mpconfigboard.mk

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,8 @@ CHIP_VARIANT = SAMD51G19A
77
CHIP_FAMILY = samd51
88

99
QSPI_FLASH_FILESYSTEM = 1
10-
EXTERNAL_FLASH_DEVICE_COUNT = 1
11-
EXTERNAL_FLASH_DEVICES = "W25Q16JV_IM"
10+
EXTERNAL_FLASH_DEVICE_COUNT = 2
11+
EXTERNAL_FLASH_DEVICES = "W25Q16JV_IM, W25Q16JV_IQ"
1212
LONGINT_IMPL = MPZ
1313

1414
# No I2S on SAMD51G

ports/atmel-samd/common-hal/pulseio/PulseOut.c

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,15 @@ void pulseout_reset() {
9696
}
9797

9898
void common_hal_pulseio_pulseout_construct(pulseio_pulseout_obj_t* self,
99-
const pulseio_pwmout_obj_t* carrier) {
99+
const pulseio_pwmout_obj_t* carrier,
100+
const mcu_pin_obj_t* pin,
101+
uint32_t frequency,
102+
uint16_t duty_cycle) {
103+
if (!carrier || pin || frequency) {
104+
mp_raise_NotImplementedError(translate("Port does not accept pins or frequency. \
105+
Construct and pass a PWMOut Carrier instead"));
106+
}
107+
100108
if (refcount == 0) {
101109
// Find a spare timer.
102110
Tc *tc = NULL;

ports/atmel-samd/mpconfigport.mk

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -91,3 +91,5 @@ endif # samd51
9191
INTERNAL_LIBM = 1
9292

9393
USB_SERIAL_NUMBER_LENGTH = 32
94+
95+
USB_NUM_EP = 8

ports/cxd56/common-hal/pulseio/PulseOut.c

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -58,8 +58,16 @@ static bool pulseout_timer_handler(unsigned int *next_interval_us, void *arg)
5858
return true;
5959
}
6060

61-
void common_hal_pulseio_pulseout_construct(pulseio_pulseout_obj_t *self,
62-
const pulseio_pwmout_obj_t *carrier) {
61+
void common_hal_pulseio_pulseout_construct(pulseio_pulseout_obj_t* self,
62+
const pulseio_pwmout_obj_t* carrier,
63+
const mcu_pin_obj_t* pin,
64+
uint32_t frequency,
65+
uint16_t duty_cycle) {
66+
if (!carrier || pin || frequency) {
67+
mp_raise_NotImplementedError(translate("Port does not accept pins or frequency. \
68+
Construct and pass a PWMOut Carrier instead"));
69+
}
70+
6371
if (pulse_fd < 0) {
6472
pulse_fd = open("/dev/timer0", O_RDONLY);
6573
}

ports/cxd56/supervisor/port.c

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,8 @@
3636
#include "boards/board.h"
3737

3838
#include "supervisor/port.h"
39+
#include "supervisor/background_callback.h"
40+
#include "supervisor/usb.h"
3941
#include "supervisor/shared/tick.h"
4042

4143
#include "common-hal/microcontroller/Pin.h"
@@ -114,13 +116,20 @@ uint32_t port_get_saved_word(void) {
114116
return _ebss;
115117
}
116118

119+
static background_callback_t callback;
120+
static void usb_background_do(void* unused) {
121+
usb_background();
122+
}
123+
117124
volatile bool _tick_enabled;
118125
void board_timerhook(void)
119126
{
120127
// Do things common to all ports when the tick occurs
121128
if (_tick_enabled) {
122129
supervisor_tick();
123130
}
131+
132+
background_callback_add(&callback, usb_background_do, NULL);
124133
}
125134

126135
uint64_t port_get_raw_ticks(uint8_t* subticks) {

ports/esp32s2/background.c

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,10 +35,17 @@
3535
#include "shared-module/displayio/__init__.h"
3636
#endif
3737

38+
#if CIRCUITPY_PULSEIO
39+
#include "common-hal/pulseio/PulseIn.h"
40+
#endif
41+
3842

3943
void port_background_task(void) {
4044
// Zero delay in case FreeRTOS wants to switch to something else.
4145
vTaskDelay(0);
46+
#if CIRCUITPY_PULSEIO
47+
pulsein_background();
48+
#endif
4249
}
4350

4451
void port_start_background_task(void) {}

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

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -93,6 +93,9 @@ void common_hal_neopixel_write (const digitalio_digitalinout_obj_t* digitalinout
9393
// Reserve channel
9494
uint8_t number = digitalinout->pin->number;
9595
rmt_channel_t channel = esp32s2_peripherals_find_and_reserve_rmt();
96+
if (channel == RMT_CHANNEL_MAX) {
97+
mp_raise_RuntimeError(translate("All timers in use"));
98+
}
9699

97100
// Configure Channel
98101
rmt_config_t config = RMT_DEFAULT_CONFIG_TX(number, channel);

0 commit comments

Comments
 (0)