summaryrefslogtreecommitdiff
path: root/ports
diff options
context:
space:
mode:
authorDan Halbert <halbert@halwitz.org>2018-07-28 13:29:47 -0400
committerDan Halbert <halbert@halwitz.org>2018-07-28 13:29:47 -0400
commitf48b70050e3e4122eaae3eee47d35fc30bda2a4c (patch)
tree7d2dacc3c137276e9d0838b571c84c09e78acc42 /ports
parentbc760dd34100099c352a0f185ec54ceae23d036d (diff)
merge finished
Diffstat (limited to 'ports')
-rw-r--r--ports/atmel-samd/mpconfigport.h3
-rw-r--r--ports/esp8266/common-hal/neopixel_write/__init__.c2
-rw-r--r--ports/esp8266/esp_mphal.c23
-rw-r--r--ports/esp8266/esp_mphal.h3
-rw-r--r--ports/esp8266/uart.c31
-rw-r--r--ports/nrf/modules/ubluepy/ubluepy_scan_entry.c2
-rw-r--r--ports/nrf/modules/ubluepy/ubluepy_scanner.c2
-rw-r--r--ports/unix/Makefile3
-rw-r--r--ports/unix/coverage.c2
9 files changed, 34 insertions, 37 deletions
diff --git a/ports/atmel-samd/mpconfigport.h b/ports/atmel-samd/mpconfigport.h
index 6324e7a93..49f71b221 100644
--- a/ports/atmel-samd/mpconfigport.h
+++ b/ports/atmel-samd/mpconfigport.h
@@ -123,6 +123,9 @@ typedef long mp_off_t;
#define MP_PLAT_PRINT_STRN(str, len) mp_hal_stdout_tx_strn_cooked(str, len)
+#define mp_type_fileio mp_type_vfs_fat_fileio
+#define mp_type_textio mp_type_vfs_fat_textio
+
#define mp_import_stat mp_vfs_import_stat
#define mp_builtin_open_obj mp_vfs_open_obj
diff --git a/ports/esp8266/common-hal/neopixel_write/__init__.c b/ports/esp8266/common-hal/neopixel_write/__init__.c
index 84a743d11..25fb0dcea 100644
--- a/ports/esp8266/common-hal/neopixel_write/__init__.c
+++ b/ports/esp8266/common-hal/neopixel_write/__init__.c
@@ -29,5 +29,5 @@
#include "espneopixel.h"
void common_hal_neopixel_write(const digitalio_digitalinout_obj_t* digitalinout, uint8_t *pixels, uint32_t numBytes) {
- esp_neopixel_write(digitalinout->pin->gpio_number, pixels, numBytes);
+ esp_neopixel_write(digitalinout->pin->gpio_number, pixels, numBytes, true /*800 kHz*/);
}
diff --git a/ports/esp8266/esp_mphal.c b/ports/esp8266/esp_mphal.c
index be284c8f3..fe669265e 100644
--- a/ports/esp8266/esp_mphal.c
+++ b/ports/esp8266/esp_mphal.c
@@ -35,18 +35,15 @@
#include "extmod/misc.h"
#include "lib/utils/pyexec.h"
-STATIC byte stdin_ringbuf_array[256];
-ringbuf_t stdin_ringbuf = {stdin_ringbuf_array, sizeof(stdin_ringbuf_array), 0, 0};
+STATIC byte input_buf_array[256];
+ringbuf_t stdin_ringbuf = {input_buf_array, sizeof(input_buf_array)};
void mp_hal_debug_tx_strn_cooked(void *env, const char *str, uint32_t len);
const mp_print_t mp_debug_print = {NULL, mp_hal_debug_tx_strn_cooked};
-int uart_attached_to_dupterm;
-
void mp_hal_init(void) {
//ets_wdt_disable(); // it's a pain while developing
mp_hal_rtc_init();
uart_init(UART_BIT_RATE_115200, UART_BIT_RATE_115200);
- uart_attached_to_dupterm = 0;
}
void mp_hal_delay_us(uint32_t us) {
@@ -87,11 +84,19 @@ void mp_hal_debug_str(const char *str) {
#endif
void mp_hal_stdout_tx_str(const char *str) {
- mp_uos_dupterm_tx_strn(str, strlen(str));
+ const char *last = str;
+ while (*str) {
+ uart_tx_one_char(UART0, *str++);
+ }
+ mp_uos_dupterm_tx_strn(last, str - last);
}
void mp_hal_stdout_tx_strn(const char *str, uint32_t len) {
- mp_uos_dupterm_tx_strn(str, len);
+ const char *last = str;
+ while (len--) {
+ uart_tx_one_char(UART0, *str++);
+ }
+ mp_uos_dupterm_tx_strn(last, str - last);
}
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) {
if (str > last) {
mp_uos_dupterm_tx_strn(last, str - last);
}
+ uart_tx_one_char(UART0, '\r');
+ uart_tx_one_char(UART0, '\n');
mp_uos_dupterm_tx_strn("\r\n", 2);
++str;
last = str;
} else {
- ++str;
+ uart_tx_one_char(UART0, *str++);
}
}
if (str > last) {
diff --git a/ports/esp8266/esp_mphal.h b/ports/esp8266/esp_mphal.h
index 56d9fa35f..5ecd392a6 100644
--- a/ports/esp8266/esp_mphal.h
+++ b/ports/esp8266/esp_mphal.h
@@ -40,9 +40,6 @@ void mp_hal_signal_input(void);
// Call this when data is available in dupterm object
void mp_hal_signal_dupterm_input(void);
-// This variable counts how many times the UART is attached to dupterm
-extern int uart_attached_to_dupterm;
-
void mp_hal_init(void);
void mp_hal_rtc_init(void);
diff --git a/ports/esp8266/uart.c b/ports/esp8266/uart.c
index 52707f981..4a8405337 100644
--- a/ports/esp8266/uart.c
+++ b/ports/esp8266/uart.c
@@ -34,11 +34,6 @@ static int uart_os = UART_OS;
static os_event_t uart_evt_queue[16];
#endif
-// A small, static ring buffer for incoming chars
-// This will only be populated if the UART is not attached to dupterm
-static byte uart_ringbuf_array[16];
-static ringbuf_t uart_ringbuf = {uart_ringbuf_array, sizeof(uart_ringbuf_array), 0, 0};
-
static void uart0_rx_intr_handler(void *para);
void soft_reset(void);
@@ -175,26 +170,18 @@ static void uart0_rx_intr_handler(void *para) {
while (READ_PERI_REG(UART_STATUS(uart_no)) & (UART_RXFIFO_CNT << UART_RXFIFO_CNT_S)) {
uint8 RcvChar = READ_PERI_REG(UART_FIFO(uart_no)) & 0xff;
- // For efficiency, when connected to dupterm we put incoming chars
- // directly on stdin_ringbuf, rather than going via uart_ringbuf
- if (uart_attached_to_dupterm) {
- if (RcvChar == mp_interrupt_char) {
- mp_keyboard_interrupt();
- } else {
- ringbuf_put(&stdin_ringbuf, RcvChar);
- }
+ if (RcvChar == mp_interrupt_char) {
+ mp_keyboard_interrupt();
} else {
- ringbuf_put(&uart_ringbuf, RcvChar);
+ ringbuf_put(&stdin_ringbuf, RcvChar);
}
}
+ mp_hal_signal_input();
+
// Clear pending FIFO interrupts
WRITE_PERI_REG(UART_INT_CLR(UART_REPL), UART_RXFIFO_TOUT_INT_CLR | UART_RXFIFO_FULL_INT_ST);
ETS_UART_INTR_ENABLE();
-
- if (uart_attached_to_dupterm) {
- mp_hal_signal_input();
- }
}
}
@@ -203,7 +190,7 @@ static void uart0_rx_intr_handler(void *para) {
bool uart_rx_wait(uint32_t timeout_us) {
uint32_t start = system_get_time();
for (;;) {
- if (uart_ringbuf.iget != uart_ringbuf.iput) {
+ if (stdin_ringbuf.iget != stdin_ringbuf.iput) {
return true; // have at least 1 char ready for reading
}
if (system_get_time() - start >= timeout_us) {
@@ -214,7 +201,7 @@ bool uart_rx_wait(uint32_t timeout_us) {
}
int uart_rx_any(uint8 uart) {
- if (uart_ringbuf.iget != uart_ringbuf.iput) {
+ if (stdin_ringbuf.iget != stdin_ringbuf.iput) {
return true; // have at least 1 char ready for reading
}
return false;
@@ -230,7 +217,7 @@ int uart_tx_any_room(uint8 uart) {
// Returns char from the input buffer, else -1 if buffer is empty.
int uart_rx_char(void) {
- return ringbuf_get(&uart_ringbuf);
+ return ringbuf_get(&stdin_ringbuf);
}
int uart_rx_one_char(uint8 uart_no) {
@@ -288,7 +275,7 @@ void uart_task_handler(os_event_t *evt) {
}
int c, ret = 0;
- while ((c = ringbuf_get(&input_buf)) >= 0) {
+ while ((c = ringbuf_get(&stdin_ringbuf)) >= 0) {
if (c == mp_interrupt_char) {
mp_keyboard_interrupt();
}
diff --git a/ports/nrf/modules/ubluepy/ubluepy_scan_entry.c b/ports/nrf/modules/ubluepy/ubluepy_scan_entry.c
index 8a936d592..773070b08 100644
--- a/ports/nrf/modules/ubluepy/ubluepy_scan_entry.c
+++ b/ports/nrf/modules/ubluepy/ubluepy_scan_entry.c
@@ -109,7 +109,7 @@ STATIC mp_obj_t scan_entry_get_scan_data(mp_obj_t self_in) {
vstr_t vstr;
vstr_init(&vstr, len);
vstr_printf(&vstr, "%s", text);
- description = mp_obj_new_str(vstr.buf, vstr.len, false);
+ description = mp_obj_new_str(vstr.buf, vstr.len);
vstr_clear(&vstr);
}
}
diff --git a/ports/nrf/modules/ubluepy/ubluepy_scanner.c b/ports/nrf/modules/ubluepy/ubluepy_scanner.c
index c92b7fd87..1cde3d551 100644
--- a/ports/nrf/modules/ubluepy/ubluepy_scanner.c
+++ b/ports/nrf/modules/ubluepy/ubluepy_scanner.c
@@ -49,7 +49,7 @@ STATIC void adv_event_handler(mp_obj_t self_in, uint16_t event_id, ble_drv_adv_d
data->p_peer_addr[5], data->p_peer_addr[4], data->p_peer_addr[3],
data->p_peer_addr[2], data->p_peer_addr[1], data->p_peer_addr[0]);
- item->addr = mp_obj_new_str(vstr.buf, vstr.len, false);
+ item->addr = mp_obj_new_str(vstr.buf, vstr.len);
vstr_clear(&vstr);
diff --git a/ports/unix/Makefile b/ports/unix/Makefile
index 1136c42b6..104ad3e5d 100644
--- a/ports/unix/Makefile
+++ b/ports/unix/Makefile
@@ -261,6 +261,9 @@ coverage_test: coverage
gcov -o build-coverage/py $(TOP)/py/*.c
gcov -o build-coverage/extmod $(TOP)/extmod/*.c
+coverage_clean:
+ $(MAKE) V=2 BUILD=build-coverage PROG=micropython_coverage clean
+
# Value of configure's --host= option (required for cross-compilation).
# Deduce it from CROSS_COMPILE by default, but can be overridden.
ifneq ($(CROSS_COMPILE),)
diff --git a/ports/unix/coverage.c b/ports/unix/coverage.c
index 7820f6d73..841924c58 100644
--- a/ports/unix/coverage.c
+++ b/ports/unix/coverage.c
@@ -173,7 +173,7 @@ STATIC mp_obj_t extra_coverage(void) {
gc_unlock();
// using gc_realloc to resize to 0, which means free the memory
- void *p = gc_alloc(4, false);
+ void *p = gc_alloc(4, false, false);
mp_printf(&mp_plat_print, "%p\n", gc_realloc(p, 0, false));
// calling gc_nbytes with a non-heap pointer