Merge branch 'master' into new-pixelbuf-api

This commit is contained in:
Roy Hooper 2019-12-10 20:44:43 -05:00
commit 0326c98fd5
158 changed files with 2732 additions and 623 deletions

View File

@ -129,6 +129,7 @@ jobs:
- "pewpew10" - "pewpew10"
- "pewpew_m4" - "pewpew_m4"
- "pirkey_m0" - "pirkey_m0"
- "pyb_nano_v2"
- "pybadge" - "pybadge"
- "pybadge_airlift" - "pybadge_airlift"
- "pyboard_v11" - "pyboard_v11"
@ -169,7 +170,8 @@ jobs:
run: | run: |
sudo apt-get install -y gettext sudo apt-get install -y gettext
pip install requests sh click setuptools awscli pip install requests sh click setuptools awscli
wget https://s3.amazonaws.com/adafruit-circuit-python/gcc-arm-embedded_7-2018q2-1~xenial1_amd64.deb && sudo dpkg -i gcc-arm-embedded*_amd64.deb wget https://developer.arm.com/-/media/Files/downloads/gnu-rm/9-2019q4/RC2.1/gcc-arm-none-eabi-9-2019-q4-major-x86_64-linux.tar.bz2
sudo tar -C /usr --strip-components=1 -xaf gcc-arm-none-eabi-9-2019-q4-major-x86_64-linux.tar.bz2
- name: Versions - name: Versions
run: | run: |
gcc --version gcc --version

6
.gitmodules vendored
View File

@ -76,7 +76,8 @@
[submodule "lib/tinyusb"] [submodule "lib/tinyusb"]
path = lib/tinyusb path = lib/tinyusb
url = https://github.com/hathach/tinyusb.git url = https://github.com/hathach/tinyusb.git
branch = develop branch = master
fetchRecurseSubmodules = false
[submodule "tools/huffman"] [submodule "tools/huffman"]
path = tools/huffman path = tools/huffman
url = https://github.com/tannewt/huffman.git url = https://github.com/tannewt/huffman.git
@ -101,3 +102,6 @@
[submodule "ports/cxd56/spresense-exported-sdk"] [submodule "ports/cxd56/spresense-exported-sdk"]
path = ports/cxd56/spresense-exported-sdk path = ports/cxd56/spresense-exported-sdk
url = https://github.com/sonydevworld/spresense-exported-sdk.git url = https://github.com/sonydevworld/spresense-exported-sdk.git
[submodule "lib/mp3"]
path = lib/mp3
url = https://github.com/adafruit/Adafruit_MP3

View File

@ -52,7 +52,7 @@
#include <string.h> #include <string.h>
#include <stdlib.h> #include <stdlib.h>
#include "tick.h" #include "supervisor/shared/tick.h"
//#include "Ethernet/socket.h" //#include "Ethernet/socket.h"
//#include "Internet/DNS/dns.h" //#include "Internet/DNS/dns.h"
@ -125,7 +125,7 @@ uint16_t DNS_MSGID; // DNS message ID
uint32_t HAL_GetTick(void) { uint32_t HAL_GetTick(void) {
return ticks_ms; return supervisor_ticks_ms32();
} }
uint32_t hal_sys_tick; uint32_t hal_sys_tick;

View File

@ -318,7 +318,7 @@ MP_DEFINE_CONST_FUN_OBJ_KW(machine_i2c_init_obj, 1, machine_i2c_obj_init);
STATIC mp_obj_t machine_i2c_scan(mp_obj_t self_in) { STATIC mp_obj_t machine_i2c_scan(mp_obj_t self_in) {
mp_obj_base_t *self = MP_OBJ_TO_PTR(self_in); mp_obj_base_t *self = MP_OBJ_TO_PTR(self_in);
mp_machine_i2c_p_t *i2c_p = (mp_machine_i2c_p_t*)self->type->protocol; mp_machine_i2c_p_t *i2c_p = (mp_machine_i2c_p_t*)mp_proto_get(self, QSTR_protocol_i2c);
mp_obj_t list = mp_obj_new_list(0, NULL); mp_obj_t list = mp_obj_new_list(0, NULL);
// 7-bit addresses 0b0000xxx and 0b1111xxx are reserved // 7-bit addresses 0b0000xxx and 0b1111xxx are reserved
for (int addr = 0x08; addr < 0x78; ++addr) { for (int addr = 0x08; addr < 0x78; ++addr) {
@ -333,7 +333,7 @@ MP_DEFINE_CONST_FUN_OBJ_1(machine_i2c_scan_obj, machine_i2c_scan);
STATIC mp_obj_t machine_i2c_start(mp_obj_t self_in) { STATIC mp_obj_t machine_i2c_start(mp_obj_t self_in) {
mp_obj_base_t *self = (mp_obj_base_t*)MP_OBJ_TO_PTR(self_in); mp_obj_base_t *self = (mp_obj_base_t*)MP_OBJ_TO_PTR(self_in);
mp_machine_i2c_p_t *i2c_p = (mp_machine_i2c_p_t*)self->type->protocol; mp_machine_i2c_p_t *i2c_p = (mp_machine_i2c_p_t*)mp_proto_get(self, QSTR_protocol_i2c);
if (i2c_p->start == NULL) { if (i2c_p->start == NULL) {
mp_raise_msg(&mp_type_OSError, translate("I2C operation not supported")); mp_raise_msg(&mp_type_OSError, translate("I2C operation not supported"));
} }
@ -347,7 +347,7 @@ MP_DEFINE_CONST_FUN_OBJ_1(machine_i2c_start_obj, machine_i2c_start);
STATIC mp_obj_t machine_i2c_stop(mp_obj_t self_in) { STATIC mp_obj_t machine_i2c_stop(mp_obj_t self_in) {
mp_obj_base_t *self = (mp_obj_base_t*)MP_OBJ_TO_PTR(self_in); mp_obj_base_t *self = (mp_obj_base_t*)MP_OBJ_TO_PTR(self_in);
mp_machine_i2c_p_t *i2c_p = (mp_machine_i2c_p_t*)self->type->protocol; mp_machine_i2c_p_t *i2c_p = (mp_machine_i2c_p_t*)mp_proto_get(self, QSTR_protocol_i2c);
if (i2c_p->stop == NULL) { if (i2c_p->stop == NULL) {
mp_raise_msg(&mp_type_OSError, translate("I2C operation not supported")); mp_raise_msg(&mp_type_OSError, translate("I2C operation not supported"));
} }
@ -361,7 +361,7 @@ MP_DEFINE_CONST_FUN_OBJ_1(machine_i2c_stop_obj, machine_i2c_stop);
STATIC mp_obj_t machine_i2c_readinto(size_t n_args, const mp_obj_t *args) { STATIC mp_obj_t machine_i2c_readinto(size_t n_args, const mp_obj_t *args) {
mp_obj_base_t *self = (mp_obj_base_t*)MP_OBJ_TO_PTR(args[0]); mp_obj_base_t *self = (mp_obj_base_t*)MP_OBJ_TO_PTR(args[0]);
mp_machine_i2c_p_t *i2c_p = (mp_machine_i2c_p_t*)self->type->protocol; mp_machine_i2c_p_t *i2c_p = (mp_machine_i2c_p_t*)mp_proto_get(self, QSTR_protocol_i2c);
if (i2c_p->read == NULL) { if (i2c_p->read == NULL) {
mp_raise_msg(&mp_type_OSError, translate("I2C operation not supported")); mp_raise_msg(&mp_type_OSError, translate("I2C operation not supported"));
} }
@ -385,7 +385,7 @@ MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(machine_i2c_readinto_obj, 2, 3, machine_i2c_
STATIC mp_obj_t machine_i2c_write(mp_obj_t self_in, mp_obj_t buf_in) { STATIC mp_obj_t machine_i2c_write(mp_obj_t self_in, mp_obj_t buf_in) {
mp_obj_base_t *self = (mp_obj_base_t*)MP_OBJ_TO_PTR(self_in); mp_obj_base_t *self = (mp_obj_base_t*)MP_OBJ_TO_PTR(self_in);
mp_machine_i2c_p_t *i2c_p = (mp_machine_i2c_p_t*)self->type->protocol; mp_machine_i2c_p_t *i2c_p = (mp_machine_i2c_p_t*)mp_proto_get(self, QSTR_protocol_i2c);
if (i2c_p->write == NULL) { if (i2c_p->write == NULL) {
mp_raise_msg(&mp_type_OSError, translate("I2C operation not supported")); mp_raise_msg(&mp_type_OSError, translate("I2C operation not supported"));
} }
@ -407,7 +407,7 @@ MP_DEFINE_CONST_FUN_OBJ_2(machine_i2c_write_obj, machine_i2c_write);
STATIC mp_obj_t machine_i2c_readfrom(size_t n_args, const mp_obj_t *args) { STATIC mp_obj_t machine_i2c_readfrom(size_t n_args, const mp_obj_t *args) {
mp_obj_base_t *self = (mp_obj_base_t*)MP_OBJ_TO_PTR(args[0]); mp_obj_base_t *self = (mp_obj_base_t*)MP_OBJ_TO_PTR(args[0]);
mp_machine_i2c_p_t *i2c_p = (mp_machine_i2c_p_t*)self->type->protocol; mp_machine_i2c_p_t *i2c_p = (mp_machine_i2c_p_t*)mp_proto_get(self, QSTR_protocol_i2c);
mp_int_t addr = mp_obj_get_int(args[1]); mp_int_t addr = mp_obj_get_int(args[1]);
vstr_t vstr; vstr_t vstr;
vstr_init_len(&vstr, mp_obj_get_int(args[2])); vstr_init_len(&vstr, mp_obj_get_int(args[2]));
@ -422,7 +422,7 @@ MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(machine_i2c_readfrom_obj, 3, 4, machine_i2c_
STATIC mp_obj_t machine_i2c_readfrom_into(size_t n_args, const mp_obj_t *args) { STATIC mp_obj_t machine_i2c_readfrom_into(size_t n_args, const mp_obj_t *args) {
mp_obj_base_t *self = (mp_obj_base_t*)MP_OBJ_TO_PTR(args[0]); mp_obj_base_t *self = (mp_obj_base_t*)MP_OBJ_TO_PTR(args[0]);
mp_machine_i2c_p_t *i2c_p = (mp_machine_i2c_p_t*)self->type->protocol; mp_machine_i2c_p_t *i2c_p = (mp_machine_i2c_p_t*)mp_proto_get(self, QSTR_protocol_i2c);
mp_int_t addr = mp_obj_get_int(args[1]); mp_int_t addr = mp_obj_get_int(args[1]);
mp_buffer_info_t bufinfo; mp_buffer_info_t bufinfo;
mp_get_buffer_raise(args[2], &bufinfo, MP_BUFFER_WRITE); mp_get_buffer_raise(args[2], &bufinfo, MP_BUFFER_WRITE);
@ -437,7 +437,7 @@ MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(machine_i2c_readfrom_into_obj, 3, 4, machine
STATIC mp_obj_t machine_i2c_writeto(size_t n_args, const mp_obj_t *args) { STATIC mp_obj_t machine_i2c_writeto(size_t n_args, const mp_obj_t *args) {
mp_obj_base_t *self = (mp_obj_base_t*)MP_OBJ_TO_PTR(args[0]); mp_obj_base_t *self = (mp_obj_base_t*)MP_OBJ_TO_PTR(args[0]);
mp_machine_i2c_p_t *i2c_p = (mp_machine_i2c_p_t*)self->type->protocol; mp_machine_i2c_p_t *i2c_p = (mp_machine_i2c_p_t*)mp_proto_get(self, QSTR_protocol_i2c);
mp_int_t addr = mp_obj_get_int(args[1]); mp_int_t addr = mp_obj_get_int(args[1]);
mp_buffer_info_t bufinfo; mp_buffer_info_t bufinfo;
mp_get_buffer_raise(args[2], &bufinfo, MP_BUFFER_READ); mp_get_buffer_raise(args[2], &bufinfo, MP_BUFFER_READ);
@ -453,7 +453,7 @@ STATIC MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(machine_i2c_writeto_obj, 3, 4, machin
STATIC int read_mem(mp_obj_t self_in, uint16_t addr, uint32_t memaddr, uint8_t addrsize, uint8_t *buf, size_t len) { STATIC int read_mem(mp_obj_t self_in, uint16_t addr, uint32_t memaddr, uint8_t addrsize, uint8_t *buf, size_t len) {
mp_obj_base_t *self = (mp_obj_base_t*)MP_OBJ_TO_PTR(self_in); mp_obj_base_t *self = (mp_obj_base_t*)MP_OBJ_TO_PTR(self_in);
mp_machine_i2c_p_t *i2c_p = (mp_machine_i2c_p_t*)self->type->protocol; mp_machine_i2c_p_t *i2c_p = (mp_machine_i2c_p_t*)mp_proto_get(self, QSTR_protocol_i2c);
uint8_t memaddr_buf[4]; uint8_t memaddr_buf[4];
size_t memaddr_len = 0; size_t memaddr_len = 0;
for (int16_t i = addrsize - 8; i >= 0; i -= 8) { for (int16_t i = addrsize - 8; i >= 0; i -= 8) {
@ -473,7 +473,7 @@ STATIC int read_mem(mp_obj_t self_in, uint16_t addr, uint32_t memaddr, uint8_t a
STATIC int write_mem(mp_obj_t self_in, uint16_t addr, uint32_t memaddr, uint8_t addrsize, const uint8_t *buf, size_t len) { STATIC int write_mem(mp_obj_t self_in, uint16_t addr, uint32_t memaddr, uint8_t addrsize, const uint8_t *buf, size_t len) {
mp_obj_base_t *self = (mp_obj_base_t*)MP_OBJ_TO_PTR(self_in); mp_obj_base_t *self = (mp_obj_base_t*)MP_OBJ_TO_PTR(self_in);
mp_machine_i2c_p_t *i2c_p = (mp_machine_i2c_p_t*)self->type->protocol; mp_machine_i2c_p_t *i2c_p = (mp_machine_i2c_p_t*)mp_proto_get(self, QSTR_protocol_i2c);
// need some memory to create the buffer to send; try to use stack if possible // need some memory to create the buffer to send; try to use stack if possible
uint8_t buf2_stack[MAX_MEMADDR_SIZE + BUF_STACK_SIZE]; uint8_t buf2_stack[MAX_MEMADDR_SIZE + BUF_STACK_SIZE];
@ -621,6 +621,7 @@ int mp_machine_soft_i2c_write(mp_obj_base_t *self_in, const uint8_t *src, size_t
} }
STATIC const mp_machine_i2c_p_t mp_machine_soft_i2c_p = { STATIC const mp_machine_i2c_p_t mp_machine_soft_i2c_p = {
MP_PROTO_IMPLEMENT(MP_QSTR_protocol_i2c)
.start = (int(*)(mp_obj_base_t*))mp_hal_i2c_start, .start = (int(*)(mp_obj_base_t*))mp_hal_i2c_start,
.stop = (int(*)(mp_obj_base_t*))mp_hal_i2c_stop, .stop = (int(*)(mp_obj_base_t*))mp_hal_i2c_stop,
.read = mp_machine_soft_i2c_read, .read = mp_machine_soft_i2c_read,

View File

@ -27,10 +27,12 @@
#define MICROPY_INCLUDED_EXTMOD_MACHINE_I2C_H #define MICROPY_INCLUDED_EXTMOD_MACHINE_I2C_H
#include "py/obj.h" #include "py/obj.h"
#include "py/proto.h"
// I2C protocol // I2C protocol
// the first 4 methods can be NULL, meaning operation is not supported // the first 4 methods can be NULL, meaning operation is not supported
typedef struct _mp_machine_i2c_p_t { typedef struct _mp_machine_i2c_p_t {
MP_PROTOCOL_HEAD
int (*start)(mp_obj_base_t *obj); int (*start)(mp_obj_base_t *obj);
int (*stop)(mp_obj_base_t *obj); int (*stop)(mp_obj_base_t *obj);
int (*read)(mp_obj_base_t *obj, uint8_t *dest, size_t len, bool nack); int (*read)(mp_obj_base_t *obj, uint8_t *dest, size_t len, bool nack);

View File

@ -74,6 +74,7 @@ mp_uint_t pinbase_ioctl(mp_obj_t obj, mp_uint_t request, uintptr_t arg, int *err
} }
STATIC const mp_pin_p_t pinbase_pin_p = { STATIC const mp_pin_p_t pinbase_pin_p = {
MP_PROTO_IMPLEMENT(MP_QSTR_protocol_pin)
.ioctl = pinbase_ioctl, .ioctl = pinbase_ioctl,
}; };

View File

@ -47,12 +47,7 @@ STATIC mp_obj_t signal_make_new(const mp_obj_type_t *type, size_t n_args, const
bool invert = false; bool invert = false;
#if defined(MICROPY_PY_MACHINE_PIN_MAKE_NEW) #if defined(MICROPY_PY_MACHINE_PIN_MAKE_NEW)
mp_pin_p_t *pin_p = NULL; mp_pin_p_t *pin_p = (mp_pin_t*)mp_proto_get(QSTR_pin_protocol, pin);
if (MP_OBJ_IS_OBJ(pin)) {
mp_obj_base_t *pin_base = (mp_obj_base_t*)MP_OBJ_TO_PTR(args[0]);
pin_p = (mp_pin_p_t*)pin_base->type->protocol;
}
if (pin_p == NULL) { if (pin_p == NULL) {
// If first argument isn't a Pin-like object, we filter out "invert" // If first argument isn't a Pin-like object, we filter out "invert"
@ -170,6 +165,7 @@ STATIC const mp_rom_map_elem_t signal_locals_dict_table[] = {
STATIC MP_DEFINE_CONST_DICT(signal_locals_dict, signal_locals_dict_table); STATIC MP_DEFINE_CONST_DICT(signal_locals_dict, signal_locals_dict_table);
STATIC const mp_pin_p_t signal_pin_p = { STATIC const mp_pin_p_t signal_pin_p = {
MP_PROTO_IMPLEMENT(MP_QSTR_protocol_pin)
.ioctl = signal_ioctl, .ioctl = signal_ioctl,
}; };

View File

@ -67,7 +67,7 @@ mp_obj_t mp_machine_spi_make_new(const mp_obj_type_t *type, size_t n_args, const
STATIC mp_obj_t machine_spi_init(size_t n_args, const mp_obj_t *args, mp_map_t *kw_args) { STATIC mp_obj_t machine_spi_init(size_t n_args, const mp_obj_t *args, mp_map_t *kw_args) {
mp_obj_base_t *s = (mp_obj_base_t*)MP_OBJ_TO_PTR(args[0]); mp_obj_base_t *s = (mp_obj_base_t*)MP_OBJ_TO_PTR(args[0]);
mp_machine_spi_p_t *spi_p = (mp_machine_spi_p_t*)s->type->protocol; mp_machine_spi_p_t *spi_p = (mp_machine_spi_p_t*)mp_proto_get(QSTR_protocol_spi, s);
spi_p->init(s, n_args - 1, args + 1, kw_args); spi_p->init(s, n_args - 1, args + 1, kw_args);
return mp_const_none; return mp_const_none;
} }
@ -75,7 +75,7 @@ STATIC MP_DEFINE_CONST_FUN_OBJ_KW(machine_spi_init_obj, 1, machine_spi_init);
STATIC mp_obj_t machine_spi_deinit(mp_obj_t self) { STATIC mp_obj_t machine_spi_deinit(mp_obj_t self) {
mp_obj_base_t *s = (mp_obj_base_t*)MP_OBJ_TO_PTR(self); mp_obj_base_t *s = (mp_obj_base_t*)MP_OBJ_TO_PTR(self);
mp_machine_spi_p_t *spi_p = (mp_machine_spi_p_t*)s->type->protocol; mp_machine_spi_p_t *spi_p = (mp_machine_spi_p_t*)mp_proto_get(QSTR_protocol_spi, s);
if (spi_p->deinit != NULL) { if (spi_p->deinit != NULL) {
spi_p->deinit(s); spi_p->deinit(s);
} }
@ -85,7 +85,7 @@ STATIC MP_DEFINE_CONST_FUN_OBJ_1(machine_spi_deinit_obj, machine_spi_deinit);
STATIC void mp_machine_spi_transfer(mp_obj_t self, size_t len, const void *src, void *dest) { STATIC void mp_machine_spi_transfer(mp_obj_t self, size_t len, const void *src, void *dest) {
mp_obj_base_t *s = (mp_obj_base_t*)MP_OBJ_TO_PTR(self); mp_obj_base_t *s = (mp_obj_base_t*)MP_OBJ_TO_PTR(self);
mp_machine_spi_p_t *spi_p = (mp_machine_spi_p_t*)s->type->protocol; mp_machine_spi_p_t *spi_p = (mp_machine_spi_p_t*)mp_proto_get(QSTR_protocol_spi, s);
spi_p->transfer(s, len, src, dest); spi_p->transfer(s, len, src, dest);
} }
@ -268,6 +268,7 @@ STATIC void mp_machine_soft_spi_transfer(mp_obj_base_t *self_in, size_t len, con
} }
const mp_machine_spi_p_t mp_machine_soft_spi_p = { const mp_machine_spi_p_t mp_machine_soft_spi_p = {
MP_PROTO_IMPLEMENT(MP_QSTR_protocol_spi)
.init = mp_machine_soft_spi_init, .init = mp_machine_soft_spi_init,
.deinit = NULL, .deinit = NULL,
.transfer = mp_machine_soft_spi_transfer, .transfer = mp_machine_soft_spi_transfer,

View File

@ -27,11 +27,13 @@
#define MICROPY_INCLUDED_EXTMOD_MACHINE_SPI_H #define MICROPY_INCLUDED_EXTMOD_MACHINE_SPI_H
#include "py/obj.h" #include "py/obj.h"
#include "py/proto.h"
#include "py/mphal.h" #include "py/mphal.h"
#include "drivers/bus/spi.h" #include "drivers/bus/spi.h"
// SPI protocol // SPI protocol
typedef struct _mp_machine_spi_p_t { typedef struct _mp_machine_spi_p_t {
MP_PROTOCOL_HEAD
void (*init)(mp_obj_base_t *obj, size_t n_args, const mp_obj_t *pos_args, mp_map_t *kw_args); void (*init)(mp_obj_base_t *obj, size_t n_args, const mp_obj_t *pos_args, mp_map_t *kw_args);
void (*deinit)(mp_obj_base_t *obj); // can be NULL void (*deinit)(mp_obj_base_t *obj); // can be NULL
void (*transfer)(mp_obj_base_t *obj, size_t len, const uint8_t *src, uint8_t *dest); void (*transfer)(mp_obj_base_t *obj, size_t len, const uint8_t *src, uint8_t *dest);

View File

@ -28,6 +28,7 @@
#include <string.h> #include <string.h>
#include "py/runtime.h" #include "py/runtime.h"
#include "py/proto.h"
#if MICROPY_PY_FRAMEBUF #if MICROPY_PY_FRAMEBUF
@ -46,6 +47,7 @@ typedef uint32_t (*getpixel_t)(const mp_obj_framebuf_t*, int, int);
typedef void (*fill_rect_t)(const mp_obj_framebuf_t *, int, int, int, int, uint32_t); typedef void (*fill_rect_t)(const mp_obj_framebuf_t *, int, int, int, int, uint32_t);
typedef struct _mp_framebuf_p_t { typedef struct _mp_framebuf_p_t {
MP_PROTOCOL_HEAD
setpixel_t setpixel; setpixel_t setpixel;
getpixel_t getpixel; getpixel_t getpixel;
fill_rect_t fill_rect; fill_rect_t fill_rect;
@ -227,13 +229,13 @@ STATIC void gs8_fill_rect(const mp_obj_framebuf_t *fb, int x, int y, int w, int
} }
STATIC mp_framebuf_p_t formats[] = { STATIC mp_framebuf_p_t formats[] = {
[FRAMEBUF_MVLSB] = {mvlsb_setpixel, mvlsb_getpixel, mvlsb_fill_rect}, [FRAMEBUF_MVLSB] = {MP_PROTO_IMPLEMENT(MP_QSTR_protocol_framebuf) mvlsb_setpixel, mvlsb_getpixel, mvlsb_fill_rect},
[FRAMEBUF_RGB565] = {rgb565_setpixel, rgb565_getpixel, rgb565_fill_rect}, [FRAMEBUF_RGB565] = {MP_PROTO_IMPLEMENT(MP_QSTR_protocol_framebuf) rgb565_setpixel, rgb565_getpixel, rgb565_fill_rect},
[FRAMEBUF_GS2_HMSB] = {gs2_hmsb_setpixel, gs2_hmsb_getpixel, gs2_hmsb_fill_rect}, [FRAMEBUF_GS2_HMSB] = {MP_PROTO_IMPLEMENT(MP_QSTR_protocol_framebuf) gs2_hmsb_setpixel, gs2_hmsb_getpixel, gs2_hmsb_fill_rect},
[FRAMEBUF_GS4_HMSB] = {gs4_hmsb_setpixel, gs4_hmsb_getpixel, gs4_hmsb_fill_rect}, [FRAMEBUF_GS4_HMSB] = {MP_PROTO_IMPLEMENT(MP_QSTR_protocol_framebuf) gs4_hmsb_setpixel, gs4_hmsb_getpixel, gs4_hmsb_fill_rect},
[FRAMEBUF_GS8] = {gs8_setpixel, gs8_getpixel, gs8_fill_rect}, [FRAMEBUF_GS8] = {MP_PROTO_IMPLEMENT(MP_QSTR_protocol_framebuf) gs8_setpixel, gs8_getpixel, gs8_fill_rect},
[FRAMEBUF_MHLSB] = {mono_horiz_setpixel, mono_horiz_getpixel, mono_horiz_fill_rect}, [FRAMEBUF_MHLSB] = {MP_PROTO_IMPLEMENT(MP_QSTR_protocol_framebuf) mono_horiz_setpixel, mono_horiz_getpixel, mono_horiz_fill_rect},
[FRAMEBUF_MHMSB] = {mono_horiz_setpixel, mono_horiz_getpixel, mono_horiz_fill_rect}, [FRAMEBUF_MHMSB] = {MP_PROTO_IMPLEMENT(MP_QSTR_protocol_framebuf) mono_horiz_setpixel, mono_horiz_getpixel, mono_horiz_fill_rect},
}; };
static inline void setpixel(const mp_obj_framebuf_t *fb, int x, int y, uint32_t col) { static inline void setpixel(const mp_obj_framebuf_t *fb, int x, int y, uint32_t col) {

View File

@ -1261,6 +1261,7 @@ STATIC const mp_rom_map_elem_t lwip_socket_locals_dict_table[] = {
STATIC MP_DEFINE_CONST_DICT(lwip_socket_locals_dict, lwip_socket_locals_dict_table); STATIC MP_DEFINE_CONST_DICT(lwip_socket_locals_dict, lwip_socket_locals_dict_table);
STATIC const mp_stream_p_t lwip_socket_stream_p = { STATIC const mp_stream_p_t lwip_socket_stream_p = {
MP_PROTO_IMPLEMENT(MP_QSTR_protocol_stream)
.read = lwip_socket_read, .read = lwip_socket_read,
.write = lwip_socket_write, .write = lwip_socket_write,
.ioctl = lwip_socket_ioctl, .ioctl = lwip_socket_ioctl,

View File

@ -221,6 +221,7 @@ STATIC const mp_rom_map_elem_t ussl_socket_locals_dict_table[] = {
STATIC MP_DEFINE_CONST_DICT(ussl_socket_locals_dict, ussl_socket_locals_dict_table); STATIC MP_DEFINE_CONST_DICT(ussl_socket_locals_dict, ussl_socket_locals_dict_table);
STATIC const mp_stream_p_t ussl_socket_stream_p = { STATIC const mp_stream_p_t ussl_socket_stream_p = {
MP_PROTO_IMPLEMENT(MP_QSTR_protocol_stream)
.read = socket_read, .read = socket_read,
.write = socket_write, .write = socket_write,
.ioctl = socket_ioctl, .ioctl = socket_ioctl,

View File

@ -305,6 +305,7 @@ STATIC const mp_rom_map_elem_t ussl_socket_locals_dict_table[] = {
STATIC MP_DEFINE_CONST_DICT(ussl_socket_locals_dict, ussl_socket_locals_dict_table); STATIC MP_DEFINE_CONST_DICT(ussl_socket_locals_dict, ussl_socket_locals_dict_table);
STATIC const mp_stream_p_t ussl_socket_stream_p = { STATIC const mp_stream_p_t ussl_socket_stream_p = {
MP_PROTO_IMPLEMENT(MP_QSTR_protocol_stream)
.read = socket_read, .read = socket_read,
.write = socket_write, .write = socket_write,
.ioctl = socket_ioctl, .ioctl = socket_ioctl,

View File

@ -134,6 +134,7 @@ STATIC const mp_rom_map_elem_t decompio_locals_dict_table[] = {
STATIC MP_DEFINE_CONST_DICT(decompio_locals_dict, decompio_locals_dict_table); STATIC MP_DEFINE_CONST_DICT(decompio_locals_dict, decompio_locals_dict_table);
STATIC const mp_stream_p_t decompio_stream_p = { STATIC const mp_stream_p_t decompio_stream_p = {
MP_PROTO_IMPLEMENT(MP_QSTR_protocol_stream)
.read = decompio_read, .read = decompio_read,
}; };

View File

@ -331,6 +331,7 @@ STATIC const mp_rom_map_elem_t webrepl_locals_dict_table[] = {
STATIC MP_DEFINE_CONST_DICT(webrepl_locals_dict, webrepl_locals_dict_table); STATIC MP_DEFINE_CONST_DICT(webrepl_locals_dict, webrepl_locals_dict_table);
STATIC const mp_stream_p_t webrepl_stream_p = { STATIC const mp_stream_p_t webrepl_stream_p = {
MP_PROTO_IMPLEMENT(MP_QSTR_protocol_stream)
.read = webrepl_read, .read = webrepl_read,
.write = webrepl_write, .write = webrepl_write,
.ioctl = webrepl_ioctl, .ioctl = webrepl_ioctl,

View File

@ -286,6 +286,7 @@ STATIC const mp_rom_map_elem_t websocket_locals_dict_table[] = {
STATIC MP_DEFINE_CONST_DICT(websocket_locals_dict, websocket_locals_dict_table); STATIC MP_DEFINE_CONST_DICT(websocket_locals_dict, websocket_locals_dict_table);
STATIC const mp_stream_p_t websocket_stream_p = { STATIC const mp_stream_p_t websocket_stream_p = {
MP_PROTO_IMPLEMENT(MP_QSTR_protocol_stream)
.read = websocket_read, .read = websocket_read,
.write = websocket_write, .write = websocket_write,
.ioctl = websocket_ioctl, .ioctl = websocket_ioctl,

View File

@ -126,7 +126,7 @@ mp_import_stat_t mp_vfs_import_stat(const char *path) {
} }
// If the mounted object has the VFS protocol, call its import_stat helper // If the mounted object has the VFS protocol, call its import_stat helper
const mp_vfs_proto_t *proto = mp_obj_get_type(vfs->obj)->protocol; const mp_vfs_proto_t *proto = (mp_vfs_proto_t*)mp_proto_get(MP_QSTR_protocol_vfs, vfs->obj);
if (proto != NULL) { if (proto != NULL) {
return proto->import_stat(MP_OBJ_TO_PTR(vfs->obj), path_out); return proto->import_stat(MP_OBJ_TO_PTR(vfs->obj), path_out);
} }

View File

@ -28,6 +28,7 @@
#include "py/lexer.h" #include "py/lexer.h"
#include "py/obj.h" #include "py/obj.h"
#include "py/proto.h"
// return values of mp_vfs_lookup_path // return values of mp_vfs_lookup_path
// ROOT is 0 so that the default current directory is the root directory // ROOT is 0 so that the default current directory is the root directory
@ -47,6 +48,7 @@
// At the moment the VFS protocol just has import_stat, but could be extended to other methods // At the moment the VFS protocol just has import_stat, but could be extended to other methods
typedef struct _mp_vfs_proto_t { typedef struct _mp_vfs_proto_t {
MP_PROTOCOL_HEAD
mp_import_stat_t (*import_stat)(void *self, const char *path); mp_import_stat_t (*import_stat)(void *self, const char *path);
} mp_vfs_proto_t; } mp_vfs_proto_t;

View File

@ -488,6 +488,7 @@ STATIC const mp_rom_map_elem_t fat_vfs_locals_dict_table[] = {
STATIC MP_DEFINE_CONST_DICT(fat_vfs_locals_dict, fat_vfs_locals_dict_table); STATIC MP_DEFINE_CONST_DICT(fat_vfs_locals_dict, fat_vfs_locals_dict_table);
STATIC const mp_vfs_proto_t fat_vfs_proto = { STATIC const mp_vfs_proto_t fat_vfs_proto = {
MP_PROTO_IMPLEMENT(MP_QSTR_protocol_vfs)
.import_stat = fat_vfs_import_stat, .import_stat = fat_vfs_import_stat,
}; };

View File

@ -254,6 +254,7 @@ STATIC MP_DEFINE_CONST_DICT(rawfile_locals_dict, rawfile_locals_dict_table);
#if MICROPY_PY_IO_FILEIO #if MICROPY_PY_IO_FILEIO
STATIC const mp_stream_p_t fileio_stream_p = { STATIC const mp_stream_p_t fileio_stream_p = {
MP_PROTO_IMPLEMENT(MP_QSTR_protocol_stream)
.read = file_obj_read, .read = file_obj_read,
.write = file_obj_write, .write = file_obj_write,
.ioctl = file_obj_ioctl, .ioctl = file_obj_ioctl,
@ -272,6 +273,7 @@ const mp_obj_type_t mp_type_vfs_fat_fileio = {
#endif #endif
STATIC const mp_stream_p_t textio_stream_p = { STATIC const mp_stream_p_t textio_stream_p = {
MP_PROTO_IMPLEMENT(MP_QSTR_protocol_stream)
.read = file_obj_read, .read = file_obj_read,
.write = file_obj_write, .write = file_obj_write,
.ioctl = file_obj_ioctl, .ioctl = file_obj_ioctl,

View File

@ -350,6 +350,7 @@ STATIC const mp_rom_map_elem_t vfs_posix_locals_dict_table[] = {
STATIC MP_DEFINE_CONST_DICT(vfs_posix_locals_dict, vfs_posix_locals_dict_table); STATIC MP_DEFINE_CONST_DICT(vfs_posix_locals_dict, vfs_posix_locals_dict_table);
STATIC const mp_vfs_proto_t vfs_posix_proto = { STATIC const mp_vfs_proto_t vfs_posix_proto = {
MP_PROTO_IMPLEMENT(MP_QSTR_protocol_vfs)
.import_stat = mp_vfs_posix_import_stat, .import_stat = mp_vfs_posix_import_stat,
}; };

View File

@ -220,6 +220,7 @@ STATIC MP_DEFINE_CONST_DICT(rawfile_locals_dict, rawfile_locals_dict_table);
#if MICROPY_PY_IO_FILEIO #if MICROPY_PY_IO_FILEIO
STATIC const mp_stream_p_t fileio_stream_p = { STATIC const mp_stream_p_t fileio_stream_p = {
MP_PROTO_IMPLEMENT(MP_QSTR_protocol_stream)
.read = vfs_posix_file_read, .read = vfs_posix_file_read,
.write = vfs_posix_file_write, .write = vfs_posix_file_write,
.ioctl = vfs_posix_file_ioctl, .ioctl = vfs_posix_file_ioctl,
@ -238,6 +239,7 @@ const mp_obj_type_t mp_type_vfs_posix_fileio = {
#endif #endif
STATIC const mp_stream_p_t textio_stream_p = { STATIC const mp_stream_p_t textio_stream_p = {
MP_PROTO_IMPLEMENT(MP_QSTR_protocol_stream)
.read = vfs_posix_file_read, .read = vfs_posix_file_read,
.write = vfs_posix_file_write, .write = vfs_posix_file_write,
.ioctl = vfs_posix_file_ioctl, .ioctl = vfs_posix_file_ioctl,

View File

@ -25,15 +25,16 @@
*/ */
#include "extmod/virtpin.h" #include "extmod/virtpin.h"
#include "py/proto.h"
int mp_virtual_pin_read(mp_obj_t pin) { int mp_virtual_pin_read(mp_obj_t pin) {
mp_obj_base_t* s = (mp_obj_base_t*)MP_OBJ_TO_PTR(pin); mp_obj_base_t* s = (mp_obj_base_t*)MP_OBJ_TO_PTR(pin);
mp_pin_p_t *pin_p = (mp_pin_p_t*)s->type->protocol; const mp_pin_p_t *pin_p = mp_proto_get(MP_QSTR_protocol_pin, s);
return pin_p->ioctl(pin, MP_PIN_READ, 0, NULL); return pin_p->ioctl(pin, MP_PIN_READ, 0, NULL);
} }
void mp_virtual_pin_write(mp_obj_t pin, int value) { void mp_virtual_pin_write(mp_obj_t pin, int value) {
mp_obj_base_t* s = (mp_obj_base_t*)MP_OBJ_TO_PTR(pin); mp_obj_base_t* s = (mp_obj_base_t*)MP_OBJ_TO_PTR(pin);
mp_pin_p_t *pin_p = (mp_pin_p_t*)s->type->protocol; const mp_pin_p_t *pin_p = mp_proto_get(MP_QSTR_protocol_pin, s);
pin_p->ioctl(pin, MP_PIN_WRITE, value, NULL); pin_p->ioctl(pin, MP_PIN_WRITE, value, NULL);
} }

View File

@ -27,6 +27,7 @@
#define MICROPY_INCLUDED_EXTMOD_VIRTPIN_H #define MICROPY_INCLUDED_EXTMOD_VIRTPIN_H
#include "py/obj.h" #include "py/obj.h"
#include "py/proto.h"
#define MP_PIN_READ (1) #define MP_PIN_READ (1)
#define MP_PIN_WRITE (2) #define MP_PIN_WRITE (2)
@ -35,6 +36,7 @@
// Pin protocol // Pin protocol
typedef struct _mp_pin_p_t { typedef struct _mp_pin_p_t {
MP_PROTOCOL_HEAD
mp_uint_t (*ioctl)(mp_obj_t obj, mp_uint_t request, uintptr_t arg, int *errcode); mp_uint_t (*ioctl)(mp_obj_t obj, mp_uint_t request, uintptr_t arg, int *errcode);
} mp_pin_p_t; } mp_pin_p_t;

1
lib/mp3 Submodule

@ -0,0 +1 @@
Subproject commit 2a3cc7873b5c642d4bb60043dc14d2555e3377a5

View File

@ -3382,7 +3382,11 @@ FRESULT f_read (
if (!sect) ABORT(fs, FR_INT_ERR); if (!sect) ABORT(fs, FR_INT_ERR);
sect += csect; sect += csect;
cc = btr / SS(fs); /* When remaining bytes >= sector size, */ cc = btr / SS(fs); /* When remaining bytes >= sector size, */
if (cc) { /* Read maximum contiguous sectors directly */ if (cc
#if _FS_DISK_READ_ALIGNED
&& (((int)rbuff & 3) == 0)
#endif
) {/* Read maximum contiguous sectors directly */
if (csect + cc > fs->csize) { /* Clip at cluster boundary */ if (csect + cc > fs->csize) { /* Clip at cluster boundary */
cc = fs->csize - csect; cc = fs->csize - csect;
} }

View File

@ -343,6 +343,12 @@
/ SemaphoreHandle_t and etc.. A header file for O/S definitions needs to be / SemaphoreHandle_t and etc.. A header file for O/S definitions needs to be
/ included somewhere in the scope of ff.h. */ / included somewhere in the scope of ff.h. */
// Set to nonzero if buffers passed to disk_read have a word alignment
// restriction
#ifndef _FS_DISK_READ_ALIGNED
#define _FS_DISK_READ_ALIGNED 0
#endif
/* #include <windows.h> // O/S definitions */ /* #include <windows.h> // O/S definitions */

View File

@ -123,6 +123,7 @@ STATIC const mp_rom_map_elem_t stdio_locals_dict_table[] = {
STATIC MP_DEFINE_CONST_DICT(stdio_locals_dict, stdio_locals_dict_table); STATIC MP_DEFINE_CONST_DICT(stdio_locals_dict, stdio_locals_dict_table);
STATIC const mp_stream_p_t stdio_obj_stream_p = { STATIC const mp_stream_p_t stdio_obj_stream_p = {
MP_PROTO_IMPLEMENT(MP_QSTR_protocol_stream)
.read = stdio_read, .read = stdio_read,
.write = stdio_write, .write = stdio_write,
.ioctl = stdio_ioctl, .ioctl = stdio_ioctl,
@ -158,6 +159,7 @@ STATIC mp_uint_t stdio_buffer_write(mp_obj_t self_in, const void *buf, mp_uint_t
} }
STATIC const mp_stream_p_t stdio_buffer_obj_stream_p = { STATIC const mp_stream_p_t stdio_buffer_obj_stream_p = {
MP_PROTO_IMPLEMENT(MP_QSTR_protocol_stream)
.read = stdio_buffer_read, .read = stdio_buffer_read,
.write = stdio_buffer_write, .write = stdio_buffer_write,
.is_text = false, .is_text = false,

View File

@ -8,7 +8,7 @@ msgid ""
msgstr "" msgstr ""
"Project-Id-Version: PACKAGE VERSION\n" "Project-Id-Version: PACKAGE VERSION\n"
"Report-Msgid-Bugs-To: \n" "Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2019-11-27 14:54-0500\n" "POT-Creation-Date: 2019-12-10 13:55-0600\n"
"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n" "Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
"Language-Team: LANGUAGE <LL@li.org>\n" "Language-Team: LANGUAGE <LL@li.org>\n"
@ -120,6 +120,10 @@ msgstr ""
msgid "'%s' integer 0x%x does not fit in mask 0x%x" msgid "'%s' integer 0x%x does not fit in mask 0x%x"
msgstr "'%s' integer 0x%x tidak cukup didalam mask 0x%x" msgstr "'%s' integer 0x%x tidak cukup didalam mask 0x%x"
#: py/proto.c
msgid "'%s' object does not support '%q'"
msgstr ""
#: py/obj.c #: py/obj.c
#, c-format #, c-format
msgid "'%s' object does not support item assignment" msgid "'%s' object does not support item assignment"
@ -487,11 +491,21 @@ msgstr ""
msgid "Could not initialize UART" msgid "Could not initialize UART"
msgstr "Tidak dapat menginisialisasi UART" msgstr "Tidak dapat menginisialisasi UART"
#: shared-module/audiocore/WaveFile.c shared-module/audiomixer/Mixer.c #: shared-module/audiomp3/MP3File.c
msgid "Couldn't allocate first buffer" msgid "Couldn't allocate decoder"
msgstr "" msgstr ""
#: shared-module/audiocore/WaveFile.c shared-module/audiomixer/Mixer.c #: shared-module/audiocore/WaveFile.c shared-module/audiomixer/Mixer.c
#: shared-module/audiomp3/MP3File.c
msgid "Couldn't allocate first buffer"
msgstr ""
#: shared-module/audiomp3/MP3File.c
msgid "Couldn't allocate input buffer"
msgstr ""
#: shared-module/audiocore/WaveFile.c shared-module/audiomixer/Mixer.c
#: shared-module/audiomp3/MP3File.c
msgid "Couldn't allocate second buffer" msgid "Couldn't allocate second buffer"
msgstr "" msgstr ""
@ -604,6 +618,10 @@ msgstr ""
msgid "Failed to connect: timeout" msgid "Failed to connect: timeout"
msgstr "" msgstr ""
#: shared-module/audiomp3/MP3File.c
msgid "Failed to parse MP3 file"
msgstr ""
#: ports/nrf/sd_mutex.c #: ports/nrf/sd_mutex.c
#, fuzzy, c-format #, fuzzy, c-format
msgid "Failed to release mutex, err 0x%04x" msgid "Failed to release mutex, err 0x%04x"
@ -1773,7 +1791,7 @@ msgstr "argumen keyword ekstra telah diberikan"
msgid "extra positional arguments given" msgid "extra positional arguments given"
msgstr "argumen posisi ekstra telah diberikan" msgstr "argumen posisi ekstra telah diberikan"
#: shared-bindings/audiocore/WaveFile.c #: shared-bindings/audiocore/WaveFile.c shared-bindings/audiomp3/MP3File.c
#: shared-bindings/displayio/OnDiskBitmap.c #: shared-bindings/displayio/OnDiskBitmap.c
msgid "file must be a file opened in byte mode" msgid "file must be a file opened in byte mode"
msgstr "" msgstr ""

View File

@ -119,6 +119,10 @@ msgstr ""
msgid "'%s' integer 0x%x does not fit in mask 0x%x" msgid "'%s' integer 0x%x does not fit in mask 0x%x"
msgstr "" msgstr ""
#: py/proto.c
msgid "'%s' object does not support '%q'"
msgstr ""
#: py/obj.c #: py/obj.c
#, c-format #, c-format
msgid "'%s' object does not support item assignment" msgid "'%s' object does not support item assignment"
@ -477,11 +481,21 @@ msgstr ""
msgid "Could not initialize UART" msgid "Could not initialize UART"
msgstr "" msgstr ""
#: shared-module/audiocore/WaveFile.c shared-module/audiomixer/Mixer.c #: shared-module/audiomp3/MP3File.c
msgid "Couldn't allocate first buffer" msgid "Couldn't allocate decoder"
msgstr "" msgstr ""
#: shared-module/audiocore/WaveFile.c shared-module/audiomixer/Mixer.c #: shared-module/audiocore/WaveFile.c shared-module/audiomixer/Mixer.c
#: shared-module/audiomp3/MP3File.c
msgid "Couldn't allocate first buffer"
msgstr ""
#: shared-module/audiomp3/MP3File.c
msgid "Couldn't allocate input buffer"
msgstr ""
#: shared-module/audiocore/WaveFile.c shared-module/audiomixer/Mixer.c
#: shared-module/audiomp3/MP3File.c
msgid "Couldn't allocate second buffer" msgid "Couldn't allocate second buffer"
msgstr "" msgstr ""
@ -593,6 +607,10 @@ msgstr ""
msgid "Failed to connect: timeout" msgid "Failed to connect: timeout"
msgstr "" msgstr ""
#: shared-module/audiomp3/MP3File.c
msgid "Failed to parse MP3 file"
msgstr ""
#: ports/nrf/sd_mutex.c #: ports/nrf/sd_mutex.c
#, c-format #, c-format
msgid "Failed to release mutex, err 0x%04x" msgid "Failed to release mutex, err 0x%04x"
@ -1743,7 +1761,7 @@ msgstr ""
msgid "extra positional arguments given" msgid "extra positional arguments given"
msgstr "" msgstr ""
#: shared-bindings/audiocore/WaveFile.c #: shared-bindings/audiocore/WaveFile.c shared-bindings/audiomp3/MP3File.c
#: shared-bindings/displayio/OnDiskBitmap.c #: shared-bindings/displayio/OnDiskBitmap.c
msgid "file must be a file opened in byte mode" msgid "file must be a file opened in byte mode"
msgstr "" msgstr ""

View File

@ -7,7 +7,7 @@ msgid ""
msgstr "" msgstr ""
"Project-Id-Version: \n" "Project-Id-Version: \n"
"Report-Msgid-Bugs-To: \n" "Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2019-11-27 14:54-0500\n" "POT-Creation-Date: 2019-12-10 13:55-0600\n"
"PO-Revision-Date: 2018-07-27 11:55-0700\n" "PO-Revision-Date: 2018-07-27 11:55-0700\n"
"Last-Translator: Pascal Deneaux\n" "Last-Translator: Pascal Deneaux\n"
"Language-Team: Sebastian Plamauer, Pascal Deneaux\n" "Language-Team: Sebastian Plamauer, Pascal Deneaux\n"
@ -121,6 +121,10 @@ msgstr "'%s' integer %d ist nicht im Bereich %d..%d"
msgid "'%s' integer 0x%x does not fit in mask 0x%x" msgid "'%s' integer 0x%x does not fit in mask 0x%x"
msgstr "'%s' Integer 0x%x passt nicht in Maske 0x%x" msgstr "'%s' Integer 0x%x passt nicht in Maske 0x%x"
#: py/proto.c
msgid "'%s' object does not support '%q'"
msgstr ""
#: py/obj.c #: py/obj.c
#, c-format #, c-format
msgid "'%s' object does not support item assignment" msgid "'%s' object does not support item assignment"
@ -481,11 +485,21 @@ msgstr "Beschädigter raw code"
msgid "Could not initialize UART" msgid "Could not initialize UART"
msgstr "Konnte UART nicht initialisieren" msgstr "Konnte UART nicht initialisieren"
#: shared-module/audiomp3/MP3File.c
msgid "Couldn't allocate decoder"
msgstr ""
#: shared-module/audiocore/WaveFile.c shared-module/audiomixer/Mixer.c #: shared-module/audiocore/WaveFile.c shared-module/audiomixer/Mixer.c
#: shared-module/audiomp3/MP3File.c
msgid "Couldn't allocate first buffer" msgid "Couldn't allocate first buffer"
msgstr "Konnte first buffer nicht zuteilen" msgstr "Konnte first buffer nicht zuteilen"
#: shared-module/audiomp3/MP3File.c
msgid "Couldn't allocate input buffer"
msgstr ""
#: shared-module/audiocore/WaveFile.c shared-module/audiomixer/Mixer.c #: shared-module/audiocore/WaveFile.c shared-module/audiomixer/Mixer.c
#: shared-module/audiomp3/MP3File.c
msgid "Couldn't allocate second buffer" msgid "Couldn't allocate second buffer"
msgstr "Konnte second buffer nicht zuteilen" msgstr "Konnte second buffer nicht zuteilen"
@ -597,6 +611,10 @@ msgstr ""
msgid "Failed to connect: timeout" msgid "Failed to connect: timeout"
msgstr "Verbindung nicht erfolgreich: timeout" msgstr "Verbindung nicht erfolgreich: timeout"
#: shared-module/audiomp3/MP3File.c
msgid "Failed to parse MP3 file"
msgstr ""
#: ports/nrf/sd_mutex.c #: ports/nrf/sd_mutex.c
#, c-format #, c-format
msgid "Failed to release mutex, err 0x%04x" msgid "Failed to release mutex, err 0x%04x"
@ -1792,7 +1810,7 @@ msgstr "Es wurden zusätzliche Keyword-Argumente angegeben"
msgid "extra positional arguments given" msgid "extra positional arguments given"
msgstr "Es wurden zusätzliche Argumente ohne Keyword angegeben" msgstr "Es wurden zusätzliche Argumente ohne Keyword angegeben"
#: shared-bindings/audiocore/WaveFile.c #: shared-bindings/audiocore/WaveFile.c shared-bindings/audiomp3/MP3File.c
#: shared-bindings/displayio/OnDiskBitmap.c #: shared-bindings/displayio/OnDiskBitmap.c
msgid "file must be a file opened in byte mode" msgid "file must be a file opened in byte mode"
msgstr "Die Datei muss eine im Byte-Modus geöffnete Datei sein" msgstr "Die Datei muss eine im Byte-Modus geöffnete Datei sein"

View File

@ -7,7 +7,7 @@ msgid ""
msgstr "" msgstr ""
"Project-Id-Version: \n" "Project-Id-Version: \n"
"Report-Msgid-Bugs-To: \n" "Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2019-11-27 14:54-0500\n" "POT-Creation-Date: 2019-12-10 13:55-0600\n"
"PO-Revision-Date: 2018-07-27 11:55-0700\n" "PO-Revision-Date: 2018-07-27 11:55-0700\n"
"Last-Translator: \n" "Last-Translator: \n"
"Language-Team: \n" "Language-Team: \n"
@ -119,6 +119,10 @@ msgstr ""
msgid "'%s' integer 0x%x does not fit in mask 0x%x" msgid "'%s' integer 0x%x does not fit in mask 0x%x"
msgstr "" msgstr ""
#: py/proto.c
msgid "'%s' object does not support '%q'"
msgstr ""
#: py/obj.c #: py/obj.c
#, c-format #, c-format
msgid "'%s' object does not support item assignment" msgid "'%s' object does not support item assignment"
@ -477,11 +481,21 @@ msgstr ""
msgid "Could not initialize UART" msgid "Could not initialize UART"
msgstr "" msgstr ""
#: shared-module/audiocore/WaveFile.c shared-module/audiomixer/Mixer.c #: shared-module/audiomp3/MP3File.c
msgid "Couldn't allocate first buffer" msgid "Couldn't allocate decoder"
msgstr "" msgstr ""
#: shared-module/audiocore/WaveFile.c shared-module/audiomixer/Mixer.c #: shared-module/audiocore/WaveFile.c shared-module/audiomixer/Mixer.c
#: shared-module/audiomp3/MP3File.c
msgid "Couldn't allocate first buffer"
msgstr ""
#: shared-module/audiomp3/MP3File.c
msgid "Couldn't allocate input buffer"
msgstr ""
#: shared-module/audiocore/WaveFile.c shared-module/audiomixer/Mixer.c
#: shared-module/audiomp3/MP3File.c
msgid "Couldn't allocate second buffer" msgid "Couldn't allocate second buffer"
msgstr "" msgstr ""
@ -593,6 +607,10 @@ msgstr ""
msgid "Failed to connect: timeout" msgid "Failed to connect: timeout"
msgstr "" msgstr ""
#: shared-module/audiomp3/MP3File.c
msgid "Failed to parse MP3 file"
msgstr ""
#: ports/nrf/sd_mutex.c #: ports/nrf/sd_mutex.c
#, c-format #, c-format
msgid "Failed to release mutex, err 0x%04x" msgid "Failed to release mutex, err 0x%04x"
@ -1743,7 +1761,7 @@ msgstr ""
msgid "extra positional arguments given" msgid "extra positional arguments given"
msgstr "" msgstr ""
#: shared-bindings/audiocore/WaveFile.c #: shared-bindings/audiocore/WaveFile.c shared-bindings/audiomp3/MP3File.c
#: shared-bindings/displayio/OnDiskBitmap.c #: shared-bindings/displayio/OnDiskBitmap.c
msgid "file must be a file opened in byte mode" msgid "file must be a file opened in byte mode"
msgstr "" msgstr ""

View File

@ -7,7 +7,7 @@ msgid ""
msgstr "" msgstr ""
"Project-Id-Version: \n" "Project-Id-Version: \n"
"Report-Msgid-Bugs-To: \n" "Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2019-11-27 14:54-0500\n" "POT-Creation-Date: 2019-12-10 13:55-0600\n"
"PO-Revision-Date: 2018-07-27 11:55-0700\n" "PO-Revision-Date: 2018-07-27 11:55-0700\n"
"Last-Translator: \n" "Last-Translator: \n"
"Language-Team: @sommersoft, @MrCertainly\n" "Language-Team: @sommersoft, @MrCertainly\n"
@ -121,6 +121,10 @@ msgstr ""
msgid "'%s' integer 0x%x does not fit in mask 0x%x" msgid "'%s' integer 0x%x does not fit in mask 0x%x"
msgstr "" msgstr ""
#: py/proto.c
msgid "'%s' object does not support '%q'"
msgstr ""
#: py/obj.c #: py/obj.c
#, c-format #, c-format
msgid "'%s' object does not support item assignment" msgid "'%s' object does not support item assignment"
@ -481,11 +485,21 @@ msgstr ""
msgid "Could not initialize UART" msgid "Could not initialize UART"
msgstr "" msgstr ""
#: shared-module/audiocore/WaveFile.c shared-module/audiomixer/Mixer.c #: shared-module/audiomp3/MP3File.c
msgid "Couldn't allocate first buffer" msgid "Couldn't allocate decoder"
msgstr "" msgstr ""
#: shared-module/audiocore/WaveFile.c shared-module/audiomixer/Mixer.c #: shared-module/audiocore/WaveFile.c shared-module/audiomixer/Mixer.c
#: shared-module/audiomp3/MP3File.c
msgid "Couldn't allocate first buffer"
msgstr ""
#: shared-module/audiomp3/MP3File.c
msgid "Couldn't allocate input buffer"
msgstr ""
#: shared-module/audiocore/WaveFile.c shared-module/audiomixer/Mixer.c
#: shared-module/audiomp3/MP3File.c
msgid "Couldn't allocate second buffer" msgid "Couldn't allocate second buffer"
msgstr "" msgstr ""
@ -597,6 +611,10 @@ msgstr ""
msgid "Failed to connect: timeout" msgid "Failed to connect: timeout"
msgstr "" msgstr ""
#: shared-module/audiomp3/MP3File.c
msgid "Failed to parse MP3 file"
msgstr ""
#: ports/nrf/sd_mutex.c #: ports/nrf/sd_mutex.c
#, c-format #, c-format
msgid "Failed to release mutex, err 0x%04x" msgid "Failed to release mutex, err 0x%04x"
@ -1747,7 +1765,7 @@ msgstr ""
msgid "extra positional arguments given" msgid "extra positional arguments given"
msgstr "" msgstr ""
#: shared-bindings/audiocore/WaveFile.c #: shared-bindings/audiocore/WaveFile.c shared-bindings/audiomp3/MP3File.c
#: shared-bindings/displayio/OnDiskBitmap.c #: shared-bindings/displayio/OnDiskBitmap.c
msgid "file must be a file opened in byte mode" msgid "file must be a file opened in byte mode"
msgstr "" msgstr ""

View File

@ -7,7 +7,7 @@ msgid ""
msgstr "" msgstr ""
"Project-Id-Version: \n" "Project-Id-Version: \n"
"Report-Msgid-Bugs-To: \n" "Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2019-11-27 14:54-0500\n" "POT-Creation-Date: 2019-12-10 13:55-0600\n"
"PO-Revision-Date: 2018-08-24 22:56-0500\n" "PO-Revision-Date: 2018-08-24 22:56-0500\n"
"Last-Translator: \n" "Last-Translator: \n"
"Language-Team: \n" "Language-Team: \n"
@ -121,6 +121,10 @@ msgstr "'%s' entero %d no esta dentro del rango %d..%d"
msgid "'%s' integer 0x%x does not fit in mask 0x%x" msgid "'%s' integer 0x%x does not fit in mask 0x%x"
msgstr "'%s' entero 0x%x no cabe en la máscara 0x%x" msgstr "'%s' entero 0x%x no cabe en la máscara 0x%x"
#: py/proto.c
msgid "'%s' object does not support '%q'"
msgstr ""
#: py/obj.c #: py/obj.c
#, c-format #, c-format
msgid "'%s' object does not support item assignment" msgid "'%s' object does not support item assignment"
@ -485,11 +489,21 @@ msgstr ""
msgid "Could not initialize UART" msgid "Could not initialize UART"
msgstr "No se puede inicializar la UART" msgstr "No se puede inicializar la UART"
#: shared-module/audiomp3/MP3File.c
msgid "Couldn't allocate decoder"
msgstr ""
#: shared-module/audiocore/WaveFile.c shared-module/audiomixer/Mixer.c #: shared-module/audiocore/WaveFile.c shared-module/audiomixer/Mixer.c
#: shared-module/audiomp3/MP3File.c
msgid "Couldn't allocate first buffer" msgid "Couldn't allocate first buffer"
msgstr "No se pudo asignar el primer buffer" msgstr "No se pudo asignar el primer buffer"
#: shared-module/audiomp3/MP3File.c
msgid "Couldn't allocate input buffer"
msgstr ""
#: shared-module/audiocore/WaveFile.c shared-module/audiomixer/Mixer.c #: shared-module/audiocore/WaveFile.c shared-module/audiomixer/Mixer.c
#: shared-module/audiomp3/MP3File.c
msgid "Couldn't allocate second buffer" msgid "Couldn't allocate second buffer"
msgstr "No se pudo asignar el segundo buffer" msgstr "No se pudo asignar el segundo buffer"
@ -601,6 +615,10 @@ msgstr ""
msgid "Failed to connect: timeout" msgid "Failed to connect: timeout"
msgstr "" msgstr ""
#: shared-module/audiomp3/MP3File.c
msgid "Failed to parse MP3 file"
msgstr ""
#: ports/nrf/sd_mutex.c #: ports/nrf/sd_mutex.c
#, c-format #, c-format
msgid "Failed to release mutex, err 0x%04x" msgid "Failed to release mutex, err 0x%04x"
@ -1795,7 +1813,7 @@ msgstr "argumento(s) por palabra clave adicionales fueron dados"
msgid "extra positional arguments given" msgid "extra positional arguments given"
msgstr "argumento posicional adicional dado" msgstr "argumento posicional adicional dado"
#: shared-bindings/audiocore/WaveFile.c #: shared-bindings/audiocore/WaveFile.c shared-bindings/audiomp3/MP3File.c
#: shared-bindings/displayio/OnDiskBitmap.c #: shared-bindings/displayio/OnDiskBitmap.c
msgid "file must be a file opened in byte mode" msgid "file must be a file opened in byte mode"
msgstr "el archivo deberia ser una archivo abierto en modo byte" msgstr "el archivo deberia ser una archivo abierto en modo byte"

View File

@ -7,7 +7,7 @@ msgid ""
msgstr "" msgstr ""
"Project-Id-Version: \n" "Project-Id-Version: \n"
"Report-Msgid-Bugs-To: \n" "Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2019-11-27 14:54-0500\n" "POT-Creation-Date: 2019-12-10 13:55-0600\n"
"PO-Revision-Date: 2018-12-20 22:15-0800\n" "PO-Revision-Date: 2018-12-20 22:15-0800\n"
"Last-Translator: Timothy <me@timothygarcia.ca>\n" "Last-Translator: Timothy <me@timothygarcia.ca>\n"
"Language-Team: fil\n" "Language-Team: fil\n"
@ -122,6 +122,10 @@ msgstr "'%s' integer %d ay wala sa sakop ng %d..%d"
msgid "'%s' integer 0x%x does not fit in mask 0x%x" msgid "'%s' integer 0x%x does not fit in mask 0x%x"
msgstr "'%s' integer 0x%x ay wala sa mask na sakop ng 0x%x" msgstr "'%s' integer 0x%x ay wala sa mask na sakop ng 0x%x"
#: py/proto.c
msgid "'%s' object does not support '%q'"
msgstr ""
#: py/obj.c #: py/obj.c
#, c-format #, c-format
msgid "'%s' object does not support item assignment" msgid "'%s' object does not support item assignment"
@ -486,11 +490,21 @@ msgstr ""
msgid "Could not initialize UART" msgid "Could not initialize UART"
msgstr "Hindi ma-initialize ang UART" msgstr "Hindi ma-initialize ang UART"
#: shared-module/audiomp3/MP3File.c
msgid "Couldn't allocate decoder"
msgstr ""
#: shared-module/audiocore/WaveFile.c shared-module/audiomixer/Mixer.c #: shared-module/audiocore/WaveFile.c shared-module/audiomixer/Mixer.c
#: shared-module/audiomp3/MP3File.c
msgid "Couldn't allocate first buffer" msgid "Couldn't allocate first buffer"
msgstr "Hindi ma-iallocate ang first buffer" msgstr "Hindi ma-iallocate ang first buffer"
#: shared-module/audiomp3/MP3File.c
msgid "Couldn't allocate input buffer"
msgstr ""
#: shared-module/audiocore/WaveFile.c shared-module/audiomixer/Mixer.c #: shared-module/audiocore/WaveFile.c shared-module/audiomixer/Mixer.c
#: shared-module/audiomp3/MP3File.c
msgid "Couldn't allocate second buffer" msgid "Couldn't allocate second buffer"
msgstr "Hindi ma-iallocate ang second buffer" msgstr "Hindi ma-iallocate ang second buffer"
@ -607,6 +621,10 @@ msgstr ""
msgid "Failed to connect: timeout" msgid "Failed to connect: timeout"
msgstr "" msgstr ""
#: shared-module/audiomp3/MP3File.c
msgid "Failed to parse MP3 file"
msgstr ""
#: ports/nrf/sd_mutex.c #: ports/nrf/sd_mutex.c
#, fuzzy, c-format #, fuzzy, c-format
msgid "Failed to release mutex, err 0x%04x" msgid "Failed to release mutex, err 0x%04x"
@ -1803,7 +1821,7 @@ msgstr "dagdag na keyword argument na ibinigay"
msgid "extra positional arguments given" msgid "extra positional arguments given"
msgstr "dagdag na positional argument na ibinigay" msgstr "dagdag na positional argument na ibinigay"
#: shared-bindings/audiocore/WaveFile.c #: shared-bindings/audiocore/WaveFile.c shared-bindings/audiomp3/MP3File.c
#: shared-bindings/displayio/OnDiskBitmap.c #: shared-bindings/displayio/OnDiskBitmap.c
msgid "file must be a file opened in byte mode" msgid "file must be a file opened in byte mode"
msgstr "file ay dapat buksan sa byte mode" msgstr "file ay dapat buksan sa byte mode"

View File

@ -8,7 +8,7 @@ msgid ""
msgstr "" msgstr ""
"Project-Id-Version: 0.1\n" "Project-Id-Version: 0.1\n"
"Report-Msgid-Bugs-To: \n" "Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2019-11-27 14:54-0500\n" "POT-Creation-Date: 2019-12-10 13:55-0600\n"
"PO-Revision-Date: 2019-04-14 20:05+0100\n" "PO-Revision-Date: 2019-04-14 20:05+0100\n"
"Last-Translator: Pierrick Couturier <arofarn@arofarn.info>\n" "Last-Translator: Pierrick Couturier <arofarn@arofarn.info>\n"
"Language-Team: fr\n" "Language-Team: fr\n"
@ -123,6 +123,10 @@ msgstr "'%s' l'entier %d n'est pas dans la gamme %d..%d"
msgid "'%s' integer 0x%x does not fit in mask 0x%x" msgid "'%s' integer 0x%x does not fit in mask 0x%x"
msgstr "'%s' l'entier 0x%x ne correspond pas au masque 0x%x" msgstr "'%s' l'entier 0x%x ne correspond pas au masque 0x%x"
#: py/proto.c
msgid "'%s' object does not support '%q'"
msgstr ""
#: py/obj.c #: py/obj.c
#, c-format #, c-format
msgid "'%s' object does not support item assignment" msgid "'%s' object does not support item assignment"
@ -492,11 +496,21 @@ msgstr ""
msgid "Could not initialize UART" msgid "Could not initialize UART"
msgstr "L'UART n'a pu être initialisé" msgstr "L'UART n'a pu être initialisé"
#: shared-module/audiomp3/MP3File.c
msgid "Couldn't allocate decoder"
msgstr ""
#: shared-module/audiocore/WaveFile.c shared-module/audiomixer/Mixer.c #: shared-module/audiocore/WaveFile.c shared-module/audiomixer/Mixer.c
#: shared-module/audiomp3/MP3File.c
msgid "Couldn't allocate first buffer" msgid "Couldn't allocate first buffer"
msgstr "Impossible d'allouer le 1er tampon" msgstr "Impossible d'allouer le 1er tampon"
#: shared-module/audiomp3/MP3File.c
msgid "Couldn't allocate input buffer"
msgstr ""
#: shared-module/audiocore/WaveFile.c shared-module/audiomixer/Mixer.c #: shared-module/audiocore/WaveFile.c shared-module/audiomixer/Mixer.c
#: shared-module/audiomp3/MP3File.c
msgid "Couldn't allocate second buffer" msgid "Couldn't allocate second buffer"
msgstr "Impossible d'allouer le 2e tampon" msgstr "Impossible d'allouer le 2e tampon"
@ -611,6 +625,10 @@ msgstr ""
msgid "Failed to connect: timeout" msgid "Failed to connect: timeout"
msgstr "" msgstr ""
#: shared-module/audiomp3/MP3File.c
msgid "Failed to parse MP3 file"
msgstr ""
#: ports/nrf/sd_mutex.c #: ports/nrf/sd_mutex.c
#, fuzzy, c-format #, fuzzy, c-format
msgid "Failed to release mutex, err 0x%04x" msgid "Failed to release mutex, err 0x%04x"
@ -1835,7 +1853,7 @@ msgstr "argument(s) nommé(s) supplémentaire(s) donné(s)"
msgid "extra positional arguments given" msgid "extra positional arguments given"
msgstr "argument(s) positionnel(s) supplémentaire(s) donné(s)" msgstr "argument(s) positionnel(s) supplémentaire(s) donné(s)"
#: shared-bindings/audiocore/WaveFile.c #: shared-bindings/audiocore/WaveFile.c shared-bindings/audiomp3/MP3File.c
#: shared-bindings/displayio/OnDiskBitmap.c #: shared-bindings/displayio/OnDiskBitmap.c
msgid "file must be a file opened in byte mode" msgid "file must be a file opened in byte mode"
msgstr "le fichier doit être un fichier ouvert en mode 'byte'" msgstr "le fichier doit être un fichier ouvert en mode 'byte'"

View File

@ -8,7 +8,7 @@ msgid ""
msgstr "" msgstr ""
"Project-Id-Version: PACKAGE VERSION\n" "Project-Id-Version: PACKAGE VERSION\n"
"Report-Msgid-Bugs-To: \n" "Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2019-11-27 14:54-0500\n" "POT-Creation-Date: 2019-12-10 13:55-0600\n"
"PO-Revision-Date: 2018-10-02 16:27+0200\n" "PO-Revision-Date: 2018-10-02 16:27+0200\n"
"Last-Translator: Enrico Paganin <enrico.paganin@mail.com>\n" "Last-Translator: Enrico Paganin <enrico.paganin@mail.com>\n"
"Language-Team: \n" "Language-Team: \n"
@ -121,6 +121,10 @@ msgstr "intero '%s' non è nell'intervallo %d..%d"
msgid "'%s' integer 0x%x does not fit in mask 0x%x" msgid "'%s' integer 0x%x does not fit in mask 0x%x"
msgstr "intero '%s' non è nell'intervallo %d..%d" msgstr "intero '%s' non è nell'intervallo %d..%d"
#: py/proto.c
msgid "'%s' object does not support '%q'"
msgstr ""
#: py/obj.c #: py/obj.c
#, c-format #, c-format
msgid "'%s' object does not support item assignment" msgid "'%s' object does not support item assignment"
@ -487,11 +491,21 @@ msgstr ""
msgid "Could not initialize UART" msgid "Could not initialize UART"
msgstr "Impossibile inizializzare l'UART" msgstr "Impossibile inizializzare l'UART"
#: shared-module/audiomp3/MP3File.c
msgid "Couldn't allocate decoder"
msgstr ""
#: shared-module/audiocore/WaveFile.c shared-module/audiomixer/Mixer.c #: shared-module/audiocore/WaveFile.c shared-module/audiomixer/Mixer.c
#: shared-module/audiomp3/MP3File.c
msgid "Couldn't allocate first buffer" msgid "Couldn't allocate first buffer"
msgstr "Impossibile allocare il primo buffer" msgstr "Impossibile allocare il primo buffer"
#: shared-module/audiomp3/MP3File.c
msgid "Couldn't allocate input buffer"
msgstr ""
#: shared-module/audiocore/WaveFile.c shared-module/audiomixer/Mixer.c #: shared-module/audiocore/WaveFile.c shared-module/audiomixer/Mixer.c
#: shared-module/audiomp3/MP3File.c
msgid "Couldn't allocate second buffer" msgid "Couldn't allocate second buffer"
msgstr "Impossibile allocare il secondo buffer" msgstr "Impossibile allocare il secondo buffer"
@ -607,6 +621,10 @@ msgstr ""
msgid "Failed to connect: timeout" msgid "Failed to connect: timeout"
msgstr "" msgstr ""
#: shared-module/audiomp3/MP3File.c
msgid "Failed to parse MP3 file"
msgstr ""
#: ports/nrf/sd_mutex.c #: ports/nrf/sd_mutex.c
#, fuzzy, c-format #, fuzzy, c-format
msgid "Failed to release mutex, err 0x%04x" msgid "Failed to release mutex, err 0x%04x"
@ -1796,7 +1814,7 @@ msgstr "argomento nominato aggiuntivo fornito"
msgid "extra positional arguments given" msgid "extra positional arguments given"
msgstr "argomenti posizonali extra dati" msgstr "argomenti posizonali extra dati"
#: shared-bindings/audiocore/WaveFile.c #: shared-bindings/audiocore/WaveFile.c shared-bindings/audiomp3/MP3File.c
#: shared-bindings/displayio/OnDiskBitmap.c #: shared-bindings/displayio/OnDiskBitmap.c
msgid "file must be a file opened in byte mode" msgid "file must be a file opened in byte mode"
msgstr "" msgstr ""

View File

@ -8,7 +8,7 @@ msgid ""
msgstr "" msgstr ""
"Project-Id-Version: PACKAGE VERSION\n" "Project-Id-Version: PACKAGE VERSION\n"
"Report-Msgid-Bugs-To: \n" "Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2019-11-27 14:54-0500\n" "POT-Creation-Date: 2019-12-10 13:55-0600\n"
"PO-Revision-Date: 2019-05-06 14:22-0700\n" "PO-Revision-Date: 2019-05-06 14:22-0700\n"
"Last-Translator: \n" "Last-Translator: \n"
"Language-Team: LANGUAGE <LL@li.org>\n" "Language-Team: LANGUAGE <LL@li.org>\n"
@ -121,6 +121,10 @@ msgstr ""
msgid "'%s' integer 0x%x does not fit in mask 0x%x" msgid "'%s' integer 0x%x does not fit in mask 0x%x"
msgstr "" msgstr ""
#: py/proto.c
msgid "'%s' object does not support '%q'"
msgstr ""
#: py/obj.c #: py/obj.c
#, c-format #, c-format
msgid "'%s' object does not support item assignment" msgid "'%s' object does not support item assignment"
@ -481,11 +485,21 @@ msgstr ""
msgid "Could not initialize UART" msgid "Could not initialize UART"
msgstr "" msgstr ""
#: shared-module/audiocore/WaveFile.c shared-module/audiomixer/Mixer.c #: shared-module/audiomp3/MP3File.c
msgid "Couldn't allocate first buffer" msgid "Couldn't allocate decoder"
msgstr "" msgstr ""
#: shared-module/audiocore/WaveFile.c shared-module/audiomixer/Mixer.c #: shared-module/audiocore/WaveFile.c shared-module/audiomixer/Mixer.c
#: shared-module/audiomp3/MP3File.c
msgid "Couldn't allocate first buffer"
msgstr ""
#: shared-module/audiomp3/MP3File.c
msgid "Couldn't allocate input buffer"
msgstr ""
#: shared-module/audiocore/WaveFile.c shared-module/audiomixer/Mixer.c
#: shared-module/audiomp3/MP3File.c
msgid "Couldn't allocate second buffer" msgid "Couldn't allocate second buffer"
msgstr "" msgstr ""
@ -597,6 +611,10 @@ msgstr ""
msgid "Failed to connect: timeout" msgid "Failed to connect: timeout"
msgstr "" msgstr ""
#: shared-module/audiomp3/MP3File.c
msgid "Failed to parse MP3 file"
msgstr ""
#: ports/nrf/sd_mutex.c #: ports/nrf/sd_mutex.c
#, c-format #, c-format
msgid "Failed to release mutex, err 0x%04x" msgid "Failed to release mutex, err 0x%04x"
@ -1748,7 +1766,7 @@ msgstr ""
msgid "extra positional arguments given" msgid "extra positional arguments given"
msgstr "" msgstr ""
#: shared-bindings/audiocore/WaveFile.c #: shared-bindings/audiocore/WaveFile.c shared-bindings/audiomp3/MP3File.c
#: shared-bindings/displayio/OnDiskBitmap.c #: shared-bindings/displayio/OnDiskBitmap.c
msgid "file must be a file opened in byte mode" msgid "file must be a file opened in byte mode"
msgstr "" msgstr ""

View File

@ -120,6 +120,10 @@ msgstr "'%s' liczba %d poza zakresem %d..%d"
msgid "'%s' integer 0x%x does not fit in mask 0x%x" msgid "'%s' integer 0x%x does not fit in mask 0x%x"
msgstr "'%s' liczba 0x%x nie pasuje do maski 0x%x" msgstr "'%s' liczba 0x%x nie pasuje do maski 0x%x"
#: py/proto.c
msgid "'%s' object does not support '%q'"
msgstr ""
#: py/obj.c #: py/obj.c
#, c-format #, c-format
msgid "'%s' object does not support item assignment" msgid "'%s' object does not support item assignment"
@ -480,11 +484,21 @@ msgstr ""
msgid "Could not initialize UART" msgid "Could not initialize UART"
msgstr "Ustawienie UART nie powiodło się" msgstr "Ustawienie UART nie powiodło się"
#: shared-module/audiomp3/MP3File.c
msgid "Couldn't allocate decoder"
msgstr ""
#: shared-module/audiocore/WaveFile.c shared-module/audiomixer/Mixer.c #: shared-module/audiocore/WaveFile.c shared-module/audiomixer/Mixer.c
#: shared-module/audiomp3/MP3File.c
msgid "Couldn't allocate first buffer" msgid "Couldn't allocate first buffer"
msgstr "Nie udała się alokacja pierwszego bufora" msgstr "Nie udała się alokacja pierwszego bufora"
#: shared-module/audiomp3/MP3File.c
msgid "Couldn't allocate input buffer"
msgstr ""
#: shared-module/audiocore/WaveFile.c shared-module/audiomixer/Mixer.c #: shared-module/audiocore/WaveFile.c shared-module/audiomixer/Mixer.c
#: shared-module/audiomp3/MP3File.c
msgid "Couldn't allocate second buffer" msgid "Couldn't allocate second buffer"
msgstr "Nie udała się alokacja drugiego bufora" msgstr "Nie udała się alokacja drugiego bufora"
@ -596,6 +610,10 @@ msgstr ""
msgid "Failed to connect: timeout" msgid "Failed to connect: timeout"
msgstr "" msgstr ""
#: shared-module/audiomp3/MP3File.c
msgid "Failed to parse MP3 file"
msgstr ""
#: ports/nrf/sd_mutex.c #: ports/nrf/sd_mutex.c
#, c-format #, c-format
msgid "Failed to release mutex, err 0x%04x" msgid "Failed to release mutex, err 0x%04x"
@ -1768,7 +1786,7 @@ msgstr "nadmiarowe argumenty nazwane"
msgid "extra positional arguments given" msgid "extra positional arguments given"
msgstr "nadmiarowe argumenty pozycyjne" msgstr "nadmiarowe argumenty pozycyjne"
#: shared-bindings/audiocore/WaveFile.c #: shared-bindings/audiocore/WaveFile.c shared-bindings/audiomp3/MP3File.c
#: shared-bindings/displayio/OnDiskBitmap.c #: shared-bindings/displayio/OnDiskBitmap.c
msgid "file must be a file opened in byte mode" msgid "file must be a file opened in byte mode"
msgstr "file musi być otwarte w trybie bajtowym" msgstr "file musi być otwarte w trybie bajtowym"

View File

@ -8,7 +8,7 @@ msgid ""
msgstr "" msgstr ""
"Project-Id-Version: PACKAGE VERSION\n" "Project-Id-Version: PACKAGE VERSION\n"
"Report-Msgid-Bugs-To: \n" "Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2019-11-27 14:54-0500\n" "POT-Creation-Date: 2019-12-10 13:55-0600\n"
"PO-Revision-Date: 2018-10-02 21:14-0000\n" "PO-Revision-Date: 2018-10-02 21:14-0000\n"
"Last-Translator: \n" "Last-Translator: \n"
"Language-Team: \n" "Language-Team: \n"
@ -121,6 +121,10 @@ msgstr ""
msgid "'%s' integer 0x%x does not fit in mask 0x%x" msgid "'%s' integer 0x%x does not fit in mask 0x%x"
msgstr "" msgstr ""
#: py/proto.c
msgid "'%s' object does not support '%q'"
msgstr ""
#: py/obj.c #: py/obj.c
#, c-format #, c-format
msgid "'%s' object does not support item assignment" msgid "'%s' object does not support item assignment"
@ -483,11 +487,21 @@ msgstr ""
msgid "Could not initialize UART" msgid "Could not initialize UART"
msgstr "Não foi possível inicializar o UART" msgstr "Não foi possível inicializar o UART"
#: shared-module/audiomp3/MP3File.c
msgid "Couldn't allocate decoder"
msgstr ""
#: shared-module/audiocore/WaveFile.c shared-module/audiomixer/Mixer.c #: shared-module/audiocore/WaveFile.c shared-module/audiomixer/Mixer.c
#: shared-module/audiomp3/MP3File.c
msgid "Couldn't allocate first buffer" msgid "Couldn't allocate first buffer"
msgstr "Não pôde alocar primeiro buffer" msgstr "Não pôde alocar primeiro buffer"
#: shared-module/audiomp3/MP3File.c
msgid "Couldn't allocate input buffer"
msgstr ""
#: shared-module/audiocore/WaveFile.c shared-module/audiomixer/Mixer.c #: shared-module/audiocore/WaveFile.c shared-module/audiomixer/Mixer.c
#: shared-module/audiomp3/MP3File.c
msgid "Couldn't allocate second buffer" msgid "Couldn't allocate second buffer"
msgstr "Não pôde alocar segundo buffer" msgstr "Não pôde alocar segundo buffer"
@ -602,6 +616,10 @@ msgstr ""
msgid "Failed to connect: timeout" msgid "Failed to connect: timeout"
msgstr "" msgstr ""
#: shared-module/audiomp3/MP3File.c
msgid "Failed to parse MP3 file"
msgstr ""
#: ports/nrf/sd_mutex.c #: ports/nrf/sd_mutex.c
#, fuzzy, c-format #, fuzzy, c-format
msgid "Failed to release mutex, err 0x%04x" msgid "Failed to release mutex, err 0x%04x"
@ -1765,7 +1783,7 @@ msgstr "argumentos extras de palavras-chave passados"
msgid "extra positional arguments given" msgid "extra positional arguments given"
msgstr "argumentos extra posicionais passados" msgstr "argumentos extra posicionais passados"
#: shared-bindings/audiocore/WaveFile.c #: shared-bindings/audiocore/WaveFile.c shared-bindings/audiomp3/MP3File.c
#: shared-bindings/displayio/OnDiskBitmap.c #: shared-bindings/displayio/OnDiskBitmap.c
msgid "file must be a file opened in byte mode" msgid "file must be a file opened in byte mode"
msgstr "" msgstr ""

View File

@ -7,7 +7,7 @@ msgid ""
msgstr "" msgstr ""
"Project-Id-Version: circuitpython-cn\n" "Project-Id-Version: circuitpython-cn\n"
"Report-Msgid-Bugs-To: \n" "Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2019-11-27 14:54-0500\n" "POT-Creation-Date: 2019-12-10 13:55-0600\n"
"PO-Revision-Date: 2019-04-13 10:10-0700\n" "PO-Revision-Date: 2019-04-13 10:10-0700\n"
"Last-Translator: hexthat\n" "Last-Translator: hexthat\n"
"Language-Team: Chinese Hanyu Pinyin\n" "Language-Team: Chinese Hanyu Pinyin\n"
@ -121,6 +121,10 @@ msgstr "'%s' zhěngshù %d bùzài fànwéi nèi %d.%d"
msgid "'%s' integer 0x%x does not fit in mask 0x%x" msgid "'%s' integer 0x%x does not fit in mask 0x%x"
msgstr "'%s' zhěngshù 0x%x bù shìyòng yú yǎn mǎ 0x%x" msgstr "'%s' zhěngshù 0x%x bù shìyòng yú yǎn mǎ 0x%x"
#: py/proto.c
msgid "'%s' object does not support '%q'"
msgstr ""
#: py/obj.c #: py/obj.c
#, c-format #, c-format
msgid "'%s' object does not support item assignment" msgid "'%s' object does not support item assignment"
@ -481,11 +485,21 @@ msgstr "Sǔnhuài de yuánshǐ dàimǎ"
msgid "Could not initialize UART" msgid "Could not initialize UART"
msgstr "Wúfǎ chūshǐhuà UART" msgstr "Wúfǎ chūshǐhuà UART"
#: shared-module/audiomp3/MP3File.c
msgid "Couldn't allocate decoder"
msgstr ""
#: shared-module/audiocore/WaveFile.c shared-module/audiomixer/Mixer.c #: shared-module/audiocore/WaveFile.c shared-module/audiomixer/Mixer.c
#: shared-module/audiomp3/MP3File.c
msgid "Couldn't allocate first buffer" msgid "Couldn't allocate first buffer"
msgstr "Wúfǎ fēnpèi dì yī gè huǎnchōng qū" msgstr "Wúfǎ fēnpèi dì yī gè huǎnchōng qū"
#: shared-module/audiomp3/MP3File.c
msgid "Couldn't allocate input buffer"
msgstr ""
#: shared-module/audiocore/WaveFile.c shared-module/audiomixer/Mixer.c #: shared-module/audiocore/WaveFile.c shared-module/audiomixer/Mixer.c
#: shared-module/audiomp3/MP3File.c
msgid "Couldn't allocate second buffer" msgid "Couldn't allocate second buffer"
msgstr "Wúfǎ fēnpèi dì èr gè huǎnchōng qū" msgstr "Wúfǎ fēnpèi dì èr gè huǎnchōng qū"
@ -597,6 +611,10 @@ msgstr ""
msgid "Failed to connect: timeout" msgid "Failed to connect: timeout"
msgstr "Liánjiē shībài: Chāoshí" msgstr "Liánjiē shībài: Chāoshí"
#: shared-module/audiomp3/MP3File.c
msgid "Failed to parse MP3 file"
msgstr ""
#: ports/nrf/sd_mutex.c #: ports/nrf/sd_mutex.c
#, c-format #, c-format
msgid "Failed to release mutex, err 0x%04x" msgid "Failed to release mutex, err 0x%04x"
@ -668,11 +686,11 @@ msgstr "Shūrù/shūchū cuòwù"
#: ports/nrf/common-hal/_bleio/__init__.c #: ports/nrf/common-hal/_bleio/__init__.c
msgid "Insufficient authentication" msgid "Insufficient authentication"
msgstr "" msgstr "Rènzhèng bùzú"
#: ports/nrf/common-hal/_bleio/__init__.c #: ports/nrf/common-hal/_bleio/__init__.c
msgid "Insufficient encryption" msgid "Insufficient encryption"
msgstr "" msgstr "Jiāmì bùzú"
#: ports/atmel-samd/common-hal/audiobusio/I2SOut.c #: ports/atmel-samd/common-hal/audiobusio/I2SOut.c
#: ports/atmel-samd/common-hal/audiobusio/PDMIn.c #: ports/atmel-samd/common-hal/audiobusio/PDMIn.c
@ -1779,7 +1797,7 @@ msgstr "éwài de guānjiàn cí cānshù"
msgid "extra positional arguments given" msgid "extra positional arguments given"
msgstr "gěi chūle éwài de wèizhì cānshù" msgstr "gěi chūle éwài de wèizhì cānshù"
#: shared-bindings/audiocore/WaveFile.c #: shared-bindings/audiocore/WaveFile.c shared-bindings/audiomp3/MP3File.c
#: shared-bindings/displayio/OnDiskBitmap.c #: shared-bindings/displayio/OnDiskBitmap.c
msgid "file must be a file opened in byte mode" msgid "file must be a file opened in byte mode"
msgstr "wénjiàn bìxū shì zài zì jié móshì xià dǎkāi de wénjiàn" msgstr "wénjiàn bìxū shì zài zì jié móshì xià dǎkāi de wénjiàn"
@ -2459,7 +2477,7 @@ msgstr "time.struct_time() xūyào 9 xùliè"
#: shared-bindings/busio/UART.c #: shared-bindings/busio/UART.c
msgid "timeout must be 0.0-100.0 seconds" msgid "timeout must be 0.0-100.0 seconds"
msgstr "" msgstr "Chāo shí shíjiān bìxū wèi 0.0 Dào 100.0 Miǎo"
#: shared-bindings/_bleio/CharacteristicBuffer.c #: shared-bindings/_bleio/CharacteristicBuffer.c
msgid "timeout must be >= 0.0" msgid "timeout must be >= 0.0"

View File

@ -122,7 +122,16 @@ else
ifdef CFLAGS_INLINE_LIMIT ifdef CFLAGS_INLINE_LIMIT
CFLAGS += -finline-limit=$(CFLAGS_INLINE_LIMIT) CFLAGS += -finline-limit=$(CFLAGS_INLINE_LIMIT)
endif endif
CFLAGS += -flto -flto-partition=none CFLAGS += -flto -flto-partition=none
ifeq ($(CIRCUITPY_SMALL_BUILD),1)
CFLAGS += --param inline-unit-growth=15 --param max-inline-insns-auto=20
endif
ifdef CFLAGS_BOARD
CFLAGS += $(CFLAGS_BOARD)
endif
endif endif
CFLAGS += $(INC) -Wall -Werror -std=gnu11 -nostdlib $(BASE_CFLAGS) $(CFLAGS_MOD) $(COPT) CFLAGS += $(INC) -Wall -Werror -std=gnu11 -nostdlib $(BASE_CFLAGS) $(CFLAGS_MOD) $(COPT)

View File

@ -28,6 +28,7 @@
#include "audio_dma.h" #include "audio_dma.h"
#include "tick.h" #include "tick.h"
#include "supervisor/filesystem.h" #include "supervisor/filesystem.h"
#include "supervisor/shared/tick.h"
#include "supervisor/usb.h" #include "supervisor/usb.h"
#include "py/runtime.h" #include "py/runtime.h"
@ -44,6 +45,23 @@ bool stack_ok_so_far = true;
static bool running_background_tasks = false; static bool running_background_tasks = false;
#ifdef MONITOR_BACKGROUND_TASKS
// PB03 is physical pin "SCL" on the Metro M4 express
// so you can't use this code AND an i2c peripheral
// at the same time unless you change this
STATIC void start_background_task(void) {
REG_PORT_DIRSET1 = (1<<3);
REG_PORT_OUTSET1 = (1<<3);
}
STATIC void finish_background_task(void) {
REG_PORT_OUTCLR1 = (1<<3);
}
#else
STATIC void start_background_task(void) {}
STATIC void finish_background_task(void) {}
#endif
void background_tasks_reset(void) { void background_tasks_reset(void) {
running_background_tasks = false; running_background_tasks = false;
} }
@ -53,6 +71,9 @@ void run_background_tasks(void) {
if (running_background_tasks) { if (running_background_tasks) {
return; return;
} }
start_background_task();
assert_heap_ok(); assert_heap_ok();
running_background_tasks = true; running_background_tasks = true;
@ -71,9 +92,10 @@ void run_background_tasks(void) {
running_background_tasks = false; running_background_tasks = false;
assert_heap_ok(); assert_heap_ok();
last_finished_tick = ticks_ms; last_finished_tick = supervisor_ticks_ms64();
finish_background_task();
} }
bool background_tasks_ok(void) { bool background_tasks_ok(void) {
return ticks_ms - last_finished_tick < 1000; return supervisor_ticks_ms64() - last_finished_tick < 1000;
} }

View File

@ -16,3 +16,4 @@ CIRCUITPY_AUDIOBUSIO = 0
CIRCUITPY_DISPLAYIO = 0 CIRCUITPY_DISPLAYIO = 0
CIRCUITPY_NETWORK = 0 CIRCUITPY_NETWORK = 0
CIRCUITPY_PS2IO = 0 CIRCUITPY_PS2IO = 0
CIRCUITPY_AUDIOMP3 = 0

View File

@ -23,3 +23,5 @@ CIRCUITPY_USB_MIDI = 0
SUPEROPT_GC = 0 SUPEROPT_GC = 0
FROZEN_MPY_DIRS += $(TOP)/frozen/pew-pewpew-standalone-10.x FROZEN_MPY_DIRS += $(TOP)/frozen/pew-pewpew-standalone-10.x
CFLAGS_BOARD = --param max-inline-insns-auto=15

View File

@ -29,3 +29,5 @@ SUPEROPT_GC = 0
# FROZEN_MPY_DIRS += $(TOP)/frozen/Adafruit_CircuitPython_DotStar # FROZEN_MPY_DIRS += $(TOP)/frozen/Adafruit_CircuitPython_DotStar
FROZEN_MPY_DIRS += $(TOP)/frozen/Adafruit_CircuitPython_HID FROZEN_MPY_DIRS += $(TOP)/frozen/Adafruit_CircuitPython_HID
FROZEN_MPY_DIRS += $(TOP)/frozen/Adafruit_CircuitPython_IRRemote FROZEN_MPY_DIRS += $(TOP)/frozen/Adafruit_CircuitPython_IRRemote
CFLAGS_BOARD = --param max-inline-insns-auto=12

View File

@ -13,6 +13,7 @@ CIRCUITPY_SMALL_BUILD = 1
SUPEROPT_GC = 0 SUPEROPT_GC = 0
CFLAGS_BOARD = --param max-inline-insns-auto=15
ifeq ($(TRANSLATION), zh_Latn_pinyin) ifeq ($(TRANSLATION), zh_Latn_pinyin)
CFLAGS_INLINE_LIMIT = 35 CFLAGS_INLINE_LIMIT = 35
endif endif

View File

@ -12,3 +12,9 @@ LONGINT_IMPL = NONE
CIRCUITPY_SMALL_BUILD = 1 CIRCUITPY_SMALL_BUILD = 1
SUPEROPT_GC = 0 SUPEROPT_GC = 0
CFLAGS_BOARD = --param max-inline-insns-auto=15
ifeq ($(TRANSLATION), zh_Latn_pinyin)
CFLAGS_INLINE_LIMIT = 35
endif

View File

@ -34,8 +34,7 @@
#include "py/runtime.h" #include "py/runtime.h"
#include "py/stream.h" #include "py/stream.h"
#include "supervisor/shared/translate.h" #include "supervisor/shared/translate.h"
#include "supervisor/shared/tick.h"
#include "tick.h"
#include "hpl_sercom_config.h" #include "hpl_sercom_config.h"
#include "peripheral_clk_config.h" #include "peripheral_clk_config.h"
@ -272,10 +271,10 @@ size_t common_hal_busio_uart_read(busio_uart_obj_t *self, uint8_t *data, size_t
usart_async_get_io_descriptor(usart_desc_p, &io); usart_async_get_io_descriptor(usart_desc_p, &io);
size_t total_read = 0; size_t total_read = 0;
uint64_t start_ticks = ticks_ms; uint64_t start_ticks = supervisor_ticks_ms64();
// Busy-wait until timeout or until we've read enough chars. // Busy-wait until timeout or until we've read enough chars.
while (ticks_ms - start_ticks <= self->timeout_ms) { while (supervisor_ticks_ms64() - start_ticks <= self->timeout_ms) {
// Read as many chars as we can right now, up to len. // Read as many chars as we can right now, up to len.
size_t num_read = io_read(io, data, len); size_t num_read = io_read(io, data, len);
@ -289,7 +288,7 @@ size_t common_hal_busio_uart_read(busio_uart_obj_t *self, uint8_t *data, size_t
} }
if (num_read > 0) { if (num_read > 0) {
// Reset the timeout on every character read. // Reset the timeout on every character read.
start_ticks = ticks_ms; start_ticks = supervisor_ticks_ms64();
} }
RUN_BACKGROUND_TASKS; RUN_BACKGROUND_TASKS;
// Allow user to break out of a timeout with a KeyboardInterrupt. // Allow user to break out of a timeout with a KeyboardInterrupt.

View File

@ -34,24 +34,62 @@
#ifdef SAMD51 #ifdef SAMD51
#include "hri/hri_cmcc_d51.h" #include "hri/hri_cmcc_d51.h"
#include "hri/hri_nvmctrl_d51.h" #include "hri/hri_nvmctrl_d51.h"
// This magical macro makes sure the delay isn't optimized out and is the
// minimal three instructions.
#define delay_cycles(cycles) \
{ \
uint32_t t; \
asm volatile ( \
"movs %[t], %[c]\n\t" \
"loop%=:\n\t" \
"subs %[t], #1\n\t" \
"bne.n loop%=" : [t] "=r"(t) : [c] "I" (cycles)); \
}
#endif #endif
// Ensure this code is compiled with -Os. Any other optimization level may change the timing of it __attribute__((naked,noinline,aligned(16)))
// and break neopixels. static void neopixel_send_buffer_core(volatile uint32_t *clraddr, uint32_t pinMask,
#pragma GCC push_options const uint8_t *ptr, int numBytes);
#pragma GCC optimize ("Os")
static void neopixel_send_buffer_core(volatile uint32_t *clraddr, uint32_t pinMask,
const uint8_t *ptr, int numBytes) {
asm volatile(" push {r4, r5, r6, lr};"
" add r3, r2, r3;"
"loopLoad:"
" ldrb r5, [r2, #0];" // r5 := *ptr
" add r2, #1;" // ptr++
" movs r4, #128;" // r4-mask, 0x80
"loopBit:"
" str r1, [r0, #4];" // set
#ifdef SAMD21
" movs r6, #3; d2: sub r6, #1; bne d2;" // delay 3
#endif
#ifdef SAMD51
" movs r6, #3; d2: subs r6, #1; bne d2;" // delay 3
#endif
" tst r4, r5;" // mask&r5
" bne skipclr;"
" str r1, [r0, #0];" // clr
"skipclr:"
#ifdef SAMD21
" movs r6, #6; d0: sub r6, #1; bne d0;" // delay 6
#endif
#ifdef SAMD51
" movs r6, #6; d0: subs r6, #1; bne d0;" // delay 6
#endif
" str r1, [r0, #0];" // clr (possibly again, doesn't matter)
#ifdef SAMD21
" asr r4, r4, #1;" // mask >>= 1
#endif
#ifdef SAMD51
" asrs r4, r4, #1;" // mask >>= 1
#endif
" beq nextbyte;"
" uxtb r4, r4;"
#ifdef SAMD21
" movs r6, #2; d1: sub r6, #1; bne d1;" // delay 2
#endif
#ifdef SAMD51
" movs r6, #2; d1: subs r6, #1; bne d1;" // delay 2
#endif
" b loopBit;"
"nextbyte:"
" cmp r2, r3;"
" bcs neopixel_stop;"
" b loopLoad;"
"neopixel_stop:"
" pop {r4, r5, r6, pc};"
"");
}
uint64_t next_start_tick_ms = 0; uint64_t next_start_tick_ms = 0;
uint32_t next_start_tick_us = 1000; uint32_t next_start_tick_us = 1000;
@ -59,7 +97,7 @@ uint32_t next_start_tick_us = 1000;
void common_hal_neopixel_write(const digitalio_digitalinout_obj_t* digitalinout, uint8_t *pixels, uint32_t numBytes) { void common_hal_neopixel_write(const digitalio_digitalinout_obj_t* digitalinout, uint8_t *pixels, uint32_t numBytes) {
// This is adapted directly from the Adafruit NeoPixel library SAMD21G18A code: // This is adapted directly from the Adafruit NeoPixel library SAMD21G18A code:
// https://github.com/adafruit/Adafruit_NeoPixel/blob/master/Adafruit_NeoPixel.cpp // https://github.com/adafruit/Adafruit_NeoPixel/blob/master/Adafruit_NeoPixel.cpp
uint8_t *ptr, *end, p, bitMask; // and the asm version from https://github.com/microsoft/uf2-samdx1/blob/master/inc/neopixel.h
uint32_t pinMask; uint32_t pinMask;
PortGroup* port; PortGroup* port;
@ -71,21 +109,18 @@ void common_hal_neopixel_write(const digitalio_digitalinout_obj_t* digitalinout,
mp_hal_disable_all_interrupts(); mp_hal_disable_all_interrupts();
#ifdef SAMD21
// Make sure the NVM cache is consistently timed.
NVMCTRL->CTRLB.bit.READMODE = NVMCTRL_CTRLB_READMODE_DETERMINISTIC_Val;
#endif
#ifdef SAMD51 #ifdef SAMD51
// When this routine is positioned at certain addresses, the timing logic // When this routine is positioned at certain addresses, the timing logic
// below can be too fast by about 2.5x. This is some kind of (un)fortunate code // below can be too fast by about 2.5x. This is some kind of (un)fortunate code
// positiong with respect to a cache line. // positioning with respect to a cache line.
// Theoretically we should turn on off the CMCC caches and the // Theoretically we should turn on off the CMCC caches and the
// NVM caches to ensure consistent timing. Testing shows the the NVMCTRL // NVM caches to ensure consistent timing. Testing shows the the NVMCTRL
// cache disabling seems to make the difference. But turn both off to make sure. // cache disabling seems to make the difference. But turn both off to make sure.
// It's difficult to test because additions to the code before the timing loop // It's difficult to test because additions to the code before the timing loop
// below change instruction placement. Testing was done by adding cache changes // below change instruction placement. (though this should be less true now that
// below the loop (so only the first time through is wrong). // the main code is in the cache-aligned function neopixel_send_buffer_core)
// Testing was done by adding cache changes below the loop (so only the
// first time through is wrong).
// //
// Turn off instruction, data, and NVM caches to force consistent timing. // Turn off instruction, data, and NVM caches to force consistent timing.
// Invalidate existing cache entries. // Invalidate existing cache entries.
@ -93,78 +128,13 @@ void common_hal_neopixel_write(const digitalio_digitalinout_obj_t* digitalinout,
hri_cmcc_write_MAINT0_reg(CMCC, CMCC_MAINT0_INVALL); hri_cmcc_write_MAINT0_reg(CMCC, CMCC_MAINT0_INVALL);
hri_nvmctrl_set_CTRLA_CACHEDIS0_bit(NVMCTRL); hri_nvmctrl_set_CTRLA_CACHEDIS0_bit(NVMCTRL);
hri_nvmctrl_set_CTRLA_CACHEDIS1_bit(NVMCTRL); hri_nvmctrl_set_CTRLA_CACHEDIS1_bit(NVMCTRL);
#endif #endif
uint32_t pin = digitalinout->pin->number; uint32_t pin = digitalinout->pin->number;
port = &PORT->Group[GPIO_PORT(pin)]; // Convert GPIO # to port register port = &PORT->Group[GPIO_PORT(pin)]; // Convert GPIO # to port register
pinMask = (1UL << (pin % 32)); // From port_pin_set_output_level ASF code. pinMask = (1UL << (pin % 32)); // From port_pin_set_output_level ASF code.
ptr = pixels; volatile uint32_t *clr = &(port->OUTCLR.reg);
end = ptr + numBytes; neopixel_send_buffer_core(clr, pinMask, pixels, numBytes);
p = *ptr++;
bitMask = 0x80;
volatile uint32_t *set = &(port->OUTSET.reg),
*clr = &(port->OUTCLR.reg);
for(;;) {
*set = pinMask;
// This is the time where the line is always high regardless of the bit.
// For the SK6812 its 0.3us +- 0.15us
#ifdef SAMD21
asm("nop; nop;");
#endif
#ifdef SAMD51
delay_cycles(2);
#endif
if((p & bitMask) != 0) {
// This is the high delay unique to a one bit.
// For the SK6812 its 0.3us
#ifdef SAMD21
asm("nop; nop; nop; nop; nop; nop; nop;");
#endif
#ifdef SAMD51
delay_cycles(3);
#endif
*clr = pinMask;
} else {
*clr = pinMask;
// This is the low delay unique to a zero bit.
// For the SK6812 its 0.3us
#ifdef SAMD21
asm("nop; nop;");
#endif
#ifdef SAMD51
delay_cycles(2);
#endif
}
if((bitMask >>= 1) != 0) {
// This is the delay between bits in a byte and is the 1 code low
// level time from the datasheet.
// For the SK6812 its 0.6us +- 0.15us
#ifdef SAMD21
asm("nop; nop; nop; nop; nop;");
#endif
#ifdef SAMD51
delay_cycles(4);
#endif
} else {
if(ptr >= end) break;
p = *ptr++;
bitMask = 0x80;
// This is the delay between bytes. It's similar to the other branch
// in the if statement except its tuned to account for the time the
// above operations take.
// For the SK6812 its 0.6us +- 0.15us
#ifdef SAMD51
delay_cycles(3);
#endif
}
}
#ifdef SAMD21
// Speed up! (But inconsistent timing.)
NVMCTRL->CTRLB.bit.READMODE = NVMCTRL_CTRLB_READMODE_NO_MISS_PENALTY_Val;
#endif
#ifdef SAMD51 #ifdef SAMD51
// Turn instruction, data, and NVM caches back on. // Turn instruction, data, and NVM caches back on.
@ -189,4 +159,3 @@ void common_hal_neopixel_write(const digitalio_digitalinout_obj_t* digitalinout,
} }
#pragma GCC pop_options

View File

@ -28,10 +28,10 @@
#include "shared-bindings/time/__init__.h" #include "shared-bindings/time/__init__.h"
#include "tick.h" #include "supervisor/shared/tick.h"
inline uint64_t common_hal_time_monotonic() { inline uint64_t common_hal_time_monotonic() {
return ticks_ms; return supervisor_ticks_ms64();
} }
void common_hal_time_delay_ms(uint32_t delay) { void common_hal_time_delay_ms(uint32_t delay) {

View File

@ -21,6 +21,10 @@ ifndef CIRCUITPY_AUDIOMIXER
CIRCUITPY_AUDIOMIXER = 0 CIRCUITPY_AUDIOMIXER = 0
endif endif
ifndef CIRCUITPY_AUDIOMP3
CIRCUITPY_AUDIOMP3 = 0
endif
ifndef CIRCUITPY_FREQUENCYIO ifndef CIRCUITPY_FREQUENCYIO
CIRCUITPY_FREQUENCYIO = 0 CIRCUITPY_FREQUENCYIO = 0
endif endif

View File

@ -45,12 +45,12 @@
#include "mpconfigboard.h" #include "mpconfigboard.h"
#include "mphalport.h" #include "mphalport.h"
#include "reset.h" #include "reset.h"
#include "tick.h" #include "supervisor/shared/tick.h"
extern uint32_t common_hal_mcu_processor_get_frequency(void); extern uint32_t common_hal_mcu_processor_get_frequency(void);
void mp_hal_delay_ms(mp_uint_t delay) { void mp_hal_delay_ms(mp_uint_t delay) {
uint64_t start_tick = ticks_ms; uint64_t start_tick = supervisor_ticks_ms64();
uint64_t duration = 0; uint64_t duration = 0;
while (duration < delay) { while (duration < delay) {
RUN_BACKGROUND_TASKS; RUN_BACKGROUND_TASKS;
@ -59,7 +59,7 @@ void mp_hal_delay_ms(mp_uint_t delay) {
MP_STATE_VM(mp_pending_exception) == MP_OBJ_FROM_PTR(&MP_STATE_VM(mp_reload_exception))) { MP_STATE_VM(mp_pending_exception) == MP_OBJ_FROM_PTR(&MP_STATE_VM(mp_reload_exception))) {
break; break;
} }
duration = (ticks_ms - start_tick); duration = (supervisor_ticks_ms64() - start_tick);
// TODO(tannewt): Go to sleep for a little while while we wait. // TODO(tannewt): Go to sleep for a little while while we wait.
} }
} }

View File

@ -31,11 +31,11 @@
#include "lib/oofatfs/ff.h" #include "lib/oofatfs/ff.h"
// Global millisecond tick count (driven by SysTick interrupt). #include "supervisor/shared/tick.h"
extern volatile uint64_t ticks_ms;
// Global millisecond tick count (driven by SysTick interrupt).
static inline mp_uint_t mp_hal_ticks_ms(void) { static inline mp_uint_t mp_hal_ticks_ms(void) {
return ticks_ms; return supervisor_ticks_ms32();
} }
// Number of bytes in receive buffer // Number of bytes in receive buffer
volatile uint8_t usb_rx_count; volatile uint8_t usb_rx_count;

View File

@ -28,47 +28,21 @@
#include "peripheral_clk_config.h" #include "peripheral_clk_config.h"
#include "supervisor/shared/autoreload.h" #include "supervisor/shared/tick.h"
#include "supervisor/filesystem.h"
#include "shared-bindings/microcontroller/__init__.h" #include "shared-bindings/microcontroller/__init__.h"
#include "shared-bindings/microcontroller/Processor.h" #include "shared-bindings/microcontroller/Processor.h"
#if CIRCUITPY_GAMEPAD
#include "shared-module/gamepad/__init__.h"
#endif
#if CIRCUITPY_GAMEPADSHIFT
#include "shared-module/gamepadshift/__init__.h"
#endif
// Global millisecond tick count
volatile uint64_t ticks_ms = 0;
void SysTick_Handler(void) { void SysTick_Handler(void) {
// SysTick interrupt handler called when the SysTick timer reaches zero // SysTick interrupt handler called when the SysTick timer reaches zero
// (every millisecond). // (every millisecond).
common_hal_mcu_disable_interrupts(); common_hal_mcu_disable_interrupts();
ticks_ms += 1;
// Read the control register to reset the COUNTFLAG. // Read the control register to reset the COUNTFLAG.
(void) SysTick->CTRL; (void) SysTick->CTRL;
common_hal_mcu_enable_interrupts(); common_hal_mcu_enable_interrupts();
#if CIRCUITPY_FILESYSTEM_FLUSH_INTERVAL_MS > 0 // Do things common to all ports when the tick occurs
filesystem_tick(); supervisor_tick();
#endif
#ifdef CIRCUITPY_AUTORELOAD_DELAY_MS
autoreload_tick();
#endif
#ifdef CIRCUITPY_GAMEPAD_TICKS
if (!(ticks_ms & CIRCUITPY_GAMEPAD_TICKS)) {
#if CIRCUITPY_GAMEPAD
gamepad_tick();
#endif
#if CIRCUITPY_GAMEPADSHIFT
gamepadshift_tick();
#endif
}
#endif
} }
void tick_init() { void tick_init() {
@ -115,7 +89,7 @@ void current_tick(uint64_t* ms, uint32_t* us_until_ms) {
uint32_t tick_status = SysTick->CTRL; uint32_t tick_status = SysTick->CTRL;
uint32_t current_us = SysTick->VAL; uint32_t current_us = SysTick->VAL;
uint32_t tick_status2 = SysTick->CTRL; uint32_t tick_status2 = SysTick->CTRL;
uint64_t current_ms = ticks_ms; uint64_t current_ms = supervisor_ticks_ms64();
// The second clause ensures our value actually rolled over. Its possible it hit zero between // The second clause ensures our value actually rolled over. Its possible it hit zero between
// the VAL read and CTRL read. // the VAL read and CTRL read.
if ((tick_status & SysTick_CTRL_COUNTFLAG_Msk) != 0 || if ((tick_status & SysTick_CTRL_COUNTFLAG_Msk) != 0 ||
@ -129,5 +103,5 @@ void current_tick(uint64_t* ms, uint32_t* us_until_ms) {
void wait_until(uint64_t ms, uint32_t us_until_ms) { void wait_until(uint64_t ms, uint32_t us_until_ms) {
uint32_t ticks_per_us = common_hal_mcu_processor_get_frequency() / 1000 / 1000; uint32_t ticks_per_us = common_hal_mcu_processor_get_frequency() / 1000 / 1000;
while (ticks_ms <= ms && SysTick->VAL / ticks_per_us >= us_until_ms) {} while (supervisor_ticks_ms64() <= ms && SysTick->VAL / ticks_per_us >= us_until_ms) {}
} }

View File

@ -28,8 +28,6 @@
#include "py/mpconfig.h" #include "py/mpconfig.h"
extern volatile uint64_t ticks_ms;
extern struct timer_descriptor ms_timer; extern struct timer_descriptor ms_timer;
void tick_init(void); void tick_init(void);

View File

@ -26,10 +26,10 @@
#include "py/mphal.h" #include "py/mphal.h"
#include "tick.h" #include "supervisor/shared/tick.h"
uint64_t common_hal_time_monotonic(void) { uint64_t common_hal_time_monotonic(void) {
return ticks_ms; return supervisor_ticks_ms64();
} }
void common_hal_time_delay_ms(uint32_t delay) { void common_hal_time_delay_ms(uint32_t delay) {

View File

@ -31,7 +31,7 @@
#include "py/mpstate.h" #include "py/mpstate.h"
#include "tick.h" #include "supervisor/shared/tick.h"
#define DELAY_CORRECTION (700) #define DELAY_CORRECTION (700)
#define DELAY_INTERVAL (50) #define DELAY_INTERVAL (50)
@ -57,7 +57,7 @@ mp_uint_t mp_hal_ticks_cpu(void) {
} }
void mp_hal_delay_ms(mp_uint_t delay) { void mp_hal_delay_ms(mp_uint_t delay) {
uint64_t start_tick = ticks_ms; uint64_t start_tick = supervisor_ticks_ms64();
uint64_t duration = 0; uint64_t duration = 0;
while (duration < delay) { while (duration < delay) {
#ifdef MICROPY_VM_HOOK_LOOP #ifdef MICROPY_VM_HOOK_LOOP
@ -68,7 +68,7 @@ void mp_hal_delay_ms(mp_uint_t delay) {
MP_STATE_VM(mp_pending_exception) == MP_OBJ_FROM_PTR(&MP_STATE_VM(mp_reload_exception))) { MP_STATE_VM(mp_pending_exception) == MP_OBJ_FROM_PTR(&MP_STATE_VM(mp_reload_exception))) {
break; break;
} }
duration = (ticks_ms - start_tick); duration = (supervisor_ticks_ms64() - start_tick);
// TODO(tannewt): Go to sleep for a little while while we wait. // TODO(tannewt): Go to sleep for a little while while we wait.
} }
} }

View File

@ -31,6 +31,4 @@
#include "lib/utils/interrupt_char.h" #include "lib/utils/interrupt_char.h"
extern volatile uint64_t ticks_ms;
#endif // MICROPY_INCLUDED_CXD56_MPHALPORT_H #endif // MICROPY_INCLUDED_CXD56_MPHALPORT_H

View File

@ -27,19 +27,10 @@
#include "tick.h" #include "tick.h"
#include "supervisor/shared/autoreload.h" #include "supervisor/shared/autoreload.h"
#include "supervisor/filesystem.h" #include "supervisor/shared/tick.h"
// Global millisecond tick count
volatile uint64_t ticks_ms = 0;
void board_timerhook(void) void board_timerhook(void)
{ {
ticks_ms += 1; // Do things common to all ports when the tick occurs
supervisor_tick();
#if CIRCUITPY_FILESYSTEM_FLUSH_INTERVAL_MS > 0
filesystem_tick();
#endif
#ifdef CIRCUITPY_AUTORELOAD_DELAY_MS
autoreload_tick();
#endif
} }

View File

@ -29,6 +29,4 @@
#include "py/mpconfig.h" #include "py/mpconfig.h"
extern volatile uint64_t ticks_ms;
#endif // MICROPY_INCLUDED_CXD56_TICK_H #endif // MICROPY_INCLUDED_CXD56_TICK_H

View File

@ -106,6 +106,7 @@ CFLAGS += -Wno-undef
CFLAGS += -Wno-cast-align CFLAGS += -Wno-cast-align
NRF_DEFINES += -DCONFIG_GPIO_AS_PINRESET NRF_DEFINES += -DCONFIG_GPIO_AS_PINRESET
NRF_DEFINES += -D_FS_DISK_READ_ALIGNED=1
CFLAGS += $(NRF_DEFINES) CFLAGS += $(NRF_DEFINES)
CFLAGS += \ CFLAGS += \

View File

@ -134,6 +134,9 @@ void SD_EVT_IRQHandler(void) {
} }
ble_evt_t* event = (ble_evt_t *)m_ble_evt_buf; ble_evt_t* event = (ble_evt_t *)m_ble_evt_buf;
#if CIRCUITPY_VERBOSE_BLE
mp_printf(&mp_plat_print, "BLE event: 0x%04x\n", event->header.evt_id);
#endif
if (supervisor_bluetooth_hook(event)) { if (supervisor_bluetooth_hook(event)) {
continue; continue;
@ -145,8 +148,11 @@ void SD_EVT_IRQHandler(void) {
done = it->func(event, it->param) || done; done = it->func(event, it->param) || done;
it = it->next; it = it->next;
} }
if (!done) { #if CIRCUITPY_VERBOSE_BLE
//mp_printf(&mp_plat_print, "Unhandled ble event: 0x%04x\n", event->header.evt_id); if (event->header.evt_id == BLE_GATTS_EVT_WRITE) {
ble_gatts_evt_write_t* write_evt = &event->evt.gatts_evt.params.write;
mp_printf(&mp_plat_print, "Write to: UUID(0x%04x) handle %x of length %d auth %x\n", write_evt->uuid.uuid, write_evt->handle, write_evt->len, write_evt->auth_required);
} }
#endif
} }
} }

View File

@ -25,6 +25,11 @@
*/ */
#include "boards/board.h" #include "boards/board.h"
#include "mpconfigboard.h"
#include "py/obj.h"
#include "peripherals/nrf/pins.h"
#include "nrf_gpio.h"
void board_init(void) { void board_init(void) {
} }
@ -34,5 +39,12 @@ bool board_requests_safe_mode(void) {
} }
void reset_board(void) { void reset_board(void) {
// Turn off board.POWER_SWITCH (power-saving switch) on each soft reload, to prevent confusion.
nrf_gpio_cfg(POWER_SWITCH_PIN->number,
NRF_GPIO_PIN_DIR_OUTPUT,
NRF_GPIO_PIN_INPUT_DISCONNECT,
NRF_GPIO_PIN_NOPULL,
NRF_GPIO_PIN_S0S1,
NRF_GPIO_PIN_NOSENSE);
nrf_gpio_pin_write(POWER_SWITCH_PIN->number, false);
} }

View File

@ -54,6 +54,9 @@
#define SPI_FLASH_CS_PIN &pin_P0_15 #define SPI_FLASH_CS_PIN &pin_P0_15
#endif #endif
// Disables onboard peripherals and neopixels to save power.
#define POWER_SWITCH_PIN (&pin_P0_06)
#define CIRCUITPY_AUTORELOAD_DELAY_MS 500 #define CIRCUITPY_AUTORELOAD_DELAY_MS 500
#define CIRCUITPY_INTERNAL_NVM_SIZE (4096) #define CIRCUITPY_INTERNAL_NVM_SIZE (4096)

View File

@ -48,8 +48,12 @@ STATIC const mp_rom_map_elem_t board_module_globals_table[] = {
{ MP_ROM_QSTR(MP_QSTR_SLIDE_SWITCH), MP_ROM_PTR(&pin_P1_06) }, { MP_ROM_QSTR(MP_QSTR_SLIDE_SWITCH), MP_ROM_PTR(&pin_P1_06) },
{ MP_ROM_QSTR(MP_QSTR_D7), MP_ROM_PTR(&pin_P1_06) }, { MP_ROM_QSTR(MP_QSTR_D7), MP_ROM_PTR(&pin_P1_06) },
{ MP_ROM_QSTR(MP_QSTR_D13), MP_ROM_PTR(&pin_P1_14) }, // If high, turns off NeoPixels, LIS3DH, sound sensor, light sensor, temp sensor.
{ MP_ROM_QSTR(MP_QSTR_POWER_SWITCH), MP_ROM_PTR(&pin_P0_06) },
{ MP_ROM_QSTR(MP_QSTR_D35), MP_ROM_PTR(&pin_P0_06) },
{ MP_ROM_QSTR(MP_QSTR_L), MP_ROM_PTR(&pin_P1_14) }, { MP_ROM_QSTR(MP_QSTR_L), MP_ROM_PTR(&pin_P1_14) },
{ MP_ROM_QSTR(MP_QSTR_D13), MP_ROM_PTR(&pin_P1_14) },
{ MP_ROM_QSTR(MP_QSTR_NEOPIXEL), MP_ROM_PTR(&pin_P0_13) }, { MP_ROM_QSTR(MP_QSTR_NEOPIXEL), MP_ROM_PTR(&pin_P0_13) },
{ MP_ROM_QSTR(MP_QSTR_D8), MP_ROM_PTR(&pin_P0_13) }, { MP_ROM_QSTR(MP_QSTR_D8), MP_ROM_PTR(&pin_P0_13) },

View File

@ -40,6 +40,7 @@
#include "py/objstr.h" #include "py/objstr.h"
#include "py/runtime.h" #include "py/runtime.h"
#include "supervisor/shared/safe_mode.h" #include "supervisor/shared/safe_mode.h"
#include "supervisor/shared/tick.h"
#include "supervisor/usb.h" #include "supervisor/usb.h"
#include "shared-bindings/_bleio/__init__.h" #include "shared-bindings/_bleio/__init__.h"
#include "shared-bindings/_bleio/Adapter.h" #include "shared-bindings/_bleio/Adapter.h"
@ -179,9 +180,18 @@ STATIC bool adapter_on_ble_evt(ble_evt_t *ble_evt, void *self_in) {
connection->conn_handle = ble_evt->evt.gap_evt.conn_handle; connection->conn_handle = ble_evt->evt.gap_evt.conn_handle;
connection->connection_obj = mp_const_none; connection->connection_obj = mp_const_none;
connection->pair_status = PAIR_NOT_PAIRED; connection->pair_status = PAIR_NOT_PAIRED;
ble_drv_add_event_handler_entry(&connection->handler_entry, connection_on_ble_evt, connection); ble_drv_add_event_handler_entry(&connection->handler_entry, connection_on_ble_evt, connection);
self->connection_objs = NULL; self->connection_objs = NULL;
// Save the current connection parameters.
memcpy(&connection->conn_params, &connected->conn_params, sizeof(ble_gap_conn_params_t));
#if CIRCUITPY_VERBOSE_BLE
ble_gap_conn_params_t *cp = &connected->conn_params;
mp_printf(&mp_plat_print, "conn params: min_ci %d max_ci %d s_l %d sup_timeout %d\n", cp->min_conn_interval, cp->max_conn_interval, cp->slave_latency, cp->conn_sup_timeout);
#endif
// See if connection interval set by Central is out of range. // See if connection interval set by Central is out of range.
// If so, negotiate our preferred range. // If so, negotiate our preferred range.
ble_gap_conn_params_t conn_params; ble_gap_conn_params_t conn_params;
@ -343,7 +353,7 @@ STATIC bool scan_on_ble_evt(ble_evt_t *ble_evt, void *scan_results_in) {
ble_gap_evt_adv_report_t *report = &ble_evt->evt.gap_evt.params.adv_report; ble_gap_evt_adv_report_t *report = &ble_evt->evt.gap_evt.params.adv_report;
shared_module_bleio_scanresults_append(scan_results, shared_module_bleio_scanresults_append(scan_results,
ticks_ms, supervisor_ticks_ms64(),
report->type.connectable, report->type.connectable,
report->type.scan_response, report->type.scan_response,
report->rssi, report->rssi,
@ -498,8 +508,9 @@ mp_obj_t common_hal_bleio_adapter_connect(bleio_adapter_obj_t *self, bleio_addre
// The nRF SD 6.1.0 can only do one concurrent advertisement so share the advertising handle. // The nRF SD 6.1.0 can only do one concurrent advertisement so share the advertising handle.
uint8_t adv_handle = BLE_GAP_ADV_SET_HANDLE_NOT_SET; uint8_t adv_handle = BLE_GAP_ADV_SET_HANDLE_NOT_SET;
STATIC void check_data_fit(size_t data_len) { STATIC void check_data_fit(size_t data_len, bool connectable) {
if (data_len > BLE_GAP_ADV_SET_DATA_SIZE_MAX) { if (data_len > BLE_GAP_ADV_SET_DATA_SIZE_EXTENDED_MAX_SUPPORTED ||
(connectable && data_len > BLE_GAP_ADV_SET_DATA_SIZE_EXTENDED_CONNECTABLE_MAX_SUPPORTED)) {
mp_raise_ValueError(translate("Data too large for advertisement packet")); mp_raise_ValueError(translate("Data too large for advertisement packet"));
} }
} }
@ -515,11 +526,31 @@ uint32_t _common_hal_bleio_adapter_start_advertising(bleio_adapter_obj_t *self,
common_hal_bleio_adapter_stop_advertising(self); common_hal_bleio_adapter_stop_advertising(self);
} }
bool extended = advertising_data_len > BLE_GAP_ADV_SET_DATA_SIZE_MAX ||
scan_response_data_len > BLE_GAP_ADV_SET_DATA_SIZE_MAX;
uint8_t adv_type;
if (extended) {
if (connectable) {
adv_type = BLE_GAP_ADV_TYPE_EXTENDED_CONNECTABLE_NONSCANNABLE_UNDIRECTED;
} else if (scan_response_data_len > 0) {
adv_type = BLE_GAP_ADV_TYPE_EXTENDED_NONCONNECTABLE_SCANNABLE_UNDIRECTED;
} else {
adv_type = BLE_GAP_ADV_TYPE_EXTENDED_NONCONNECTABLE_NONSCANNABLE_UNDIRECTED;
}
} else if (connectable) {
adv_type = BLE_GAP_ADV_TYPE_CONNECTABLE_SCANNABLE_UNDIRECTED;
} else if (scan_response_data_len > 0) {
adv_type = BLE_GAP_ADV_TYPE_NONCONNECTABLE_SCANNABLE_UNDIRECTED;
} else {
adv_type = BLE_GAP_ADV_TYPE_NONCONNECTABLE_NONSCANNABLE_UNDIRECTED;
}
uint32_t err_code; uint32_t err_code;
ble_gap_adv_params_t adv_params = { ble_gap_adv_params_t adv_params = {
.interval = SEC_TO_UNITS(interval, UNIT_0_625_MS), .interval = SEC_TO_UNITS(interval, UNIT_0_625_MS),
.properties.type = connectable ? BLE_GAP_ADV_TYPE_CONNECTABLE_SCANNABLE_UNDIRECTED .properties.type = adv_type,
: BLE_GAP_ADV_TYPE_NONCONNECTABLE_NONSCANNABLE_UNDIRECTED,
.duration = BLE_GAP_ADV_TIMEOUT_GENERAL_UNLIMITED, .duration = BLE_GAP_ADV_TIMEOUT_GENERAL_UNLIMITED,
.filter_policy = BLE_GAP_ADV_FP_ANY, .filter_policy = BLE_GAP_ADV_FP_ANY,
.primary_phy = BLE_GAP_PHY_1MBPS, .primary_phy = BLE_GAP_PHY_1MBPS,
@ -552,15 +583,15 @@ void common_hal_bleio_adapter_start_advertising(bleio_adapter_obj_t *self, bool
} }
// interval value has already been validated. // interval value has already been validated.
check_data_fit(advertising_data_bufinfo->len); check_data_fit(advertising_data_bufinfo->len, connectable);
check_data_fit(scan_response_data_bufinfo->len); check_data_fit(scan_response_data_bufinfo->len, connectable);
// The advertising data buffers must not move, because the SoftDevice depends on them. // The advertising data buffers must not move, because the SoftDevice depends on them.
// So make them long-lived and reuse them onwards. // So make them long-lived and reuse them onwards.
if (self->advertising_data == NULL) { if (self->advertising_data == NULL) {
self->advertising_data = (uint8_t *) gc_alloc(BLE_GAP_ADV_SET_DATA_SIZE_MAX * sizeof(uint8_t), false, true); self->advertising_data = (uint8_t *) gc_alloc(BLE_GAP_ADV_SET_DATA_SIZE_EXTENDED_MAX_SUPPORTED * sizeof(uint8_t), false, true);
} }
if (self->scan_response_data == NULL) { if (self->scan_response_data == NULL) {
self->scan_response_data = (uint8_t *) gc_alloc(BLE_GAP_ADV_SET_DATA_SIZE_MAX * sizeof(uint8_t), false, true); self->scan_response_data = (uint8_t *) gc_alloc(BLE_GAP_ADV_SET_DATA_SIZE_EXTENDED_MAX_SUPPORTED * sizeof(uint8_t), false, true);
} }
memcpy(self->advertising_data, advertising_data_bufinfo->buf, advertising_data_bufinfo->len); memcpy(self->advertising_data, advertising_data_bufinfo->buf, advertising_data_bufinfo->len);

View File

@ -39,6 +39,7 @@
#include "shared-bindings/_bleio/__init__.h" #include "shared-bindings/_bleio/__init__.h"
#include "shared-bindings/_bleio/Connection.h" #include "shared-bindings/_bleio/Connection.h"
#include "supervisor/shared/tick.h"
#include "common-hal/_bleio/CharacteristicBuffer.h" #include "common-hal/_bleio/CharacteristicBuffer.h"
STATIC void write_to_ringbuf(bleio_characteristic_buffer_obj_t *self, uint8_t *data, uint16_t len) { STATIC void write_to_ringbuf(bleio_characteristic_buffer_obj_t *self, uint8_t *data, uint16_t len) {
@ -100,10 +101,10 @@ void common_hal_bleio_characteristic_buffer_construct(bleio_characteristic_buffe
} }
int common_hal_bleio_characteristic_buffer_read(bleio_characteristic_buffer_obj_t *self, uint8_t *data, size_t len, int *errcode) { int common_hal_bleio_characteristic_buffer_read(bleio_characteristic_buffer_obj_t *self, uint8_t *data, size_t len, int *errcode) {
uint64_t start_ticks = ticks_ms; uint64_t start_ticks = supervisor_ticks_ms64();
// Wait for all bytes received or timeout // Wait for all bytes received or timeout
while ( (ringbuf_count(&self->ringbuf) < len) && (ticks_ms - start_ticks < self->timeout_ms) ) { while ( (ringbuf_count(&self->ringbuf) < len) && (supervisor_ticks_ms64() - start_ticks < self->timeout_ms) ) {
RUN_BACKGROUND_TASKS; RUN_BACKGROUND_TASKS;
// Allow user to break out of a timeout with a KeyboardInterrupt. // Allow user to break out of a timeout with a KeyboardInterrupt.
if ( mp_hal_is_interrupted() ) { if ( mp_hal_is_interrupted() ) {

View File

@ -70,8 +70,6 @@ static volatile bool m_discovery_successful;
static bleio_service_obj_t *m_char_discovery_service; static bleio_service_obj_t *m_char_discovery_service;
static bleio_characteristic_obj_t *m_desc_discovery_characteristic; static bleio_characteristic_obj_t *m_desc_discovery_characteristic;
bool dump_events = false;
bool connection_on_ble_evt(ble_evt_t *ble_evt, void *self_in) { bool connection_on_ble_evt(ble_evt_t *ble_evt, void *self_in) {
bleio_connection_internal_t *self = (bleio_connection_internal_t*)self_in; bleio_connection_internal_t *self = (bleio_connection_internal_t*)self_in;
@ -84,16 +82,9 @@ bool connection_on_ble_evt(ble_evt_t *ble_evt, void *self_in) {
return false; return false;
} }
// For debugging.
if (dump_events) {
mp_printf(&mp_plat_print, "Connection event: 0x%04x\n", ble_evt->header.evt_id);
}
switch (ble_evt->header.evt_id) { switch (ble_evt->header.evt_id) {
case BLE_GAP_EVT_DISCONNECTED: case BLE_GAP_EVT_DISCONNECTED:
break; break;
case BLE_GAP_EVT_CONN_PARAM_UPDATE: // 0x12
break;
case BLE_GAP_EVT_PHY_UPDATE_REQUEST: { case BLE_GAP_EVT_PHY_UPDATE_REQUEST: {
ble_gap_phys_t const phys = { ble_gap_phys_t const phys = {
.rx_phys = BLE_GAP_PHY_AUTO, .rx_phys = BLE_GAP_PHY_AUTO,
@ -124,15 +115,61 @@ bool connection_on_ble_evt(ble_evt_t *ble_evt, void *self_in) {
sd_ble_gatts_sys_attr_set(self->conn_handle, NULL, 0, 0); sd_ble_gatts_sys_attr_set(self->conn_handle, NULL, 0, 0);
break; break;
#if CIRCUITPY_VERBOSE_BLE
// Use read authorization to snoop on all reads when doing verbose debugging.
case BLE_GATTS_EVT_RW_AUTHORIZE_REQUEST: {
ble_gatts_evt_rw_authorize_request_t *request =
&ble_evt->evt.gatts_evt.params.authorize_request;
mp_printf(&mp_plat_print, "Read %x offset %d ", request->request.read.handle, request->request.read.offset);
uint8_t value_bytes[22];
ble_gatts_value_t value;
value.offset = request->request.read.offset;
value.len = 22;
value.p_value = value_bytes;
sd_ble_gatts_value_get(self->conn_handle, request->request.read.handle, &value);
size_t len = value.len;
if (len > 22) {
len = 22;
}
for (uint8_t i = 0; i < len; i++) {
mp_printf(&mp_plat_print, " %02x", value_bytes[i]);
}
mp_printf(&mp_plat_print, "\n");
ble_gatts_rw_authorize_reply_params_t reply;
reply.type = request->type;
reply.params.read.gatt_status = BLE_GATT_STATUS_SUCCESS;
reply.params.read.update = false;
reply.params.read.offset = request->request.read.offset;
sd_ble_gatts_rw_authorize_reply(self->conn_handle, &reply);
break;
}
#endif
case BLE_GATTS_EVT_HVN_TX_COMPLETE: // Capture this for now. 0x55 case BLE_GATTS_EVT_HVN_TX_COMPLETE: // Capture this for now. 0x55
break; break;
case BLE_GAP_EVT_CONN_PARAM_UPDATE_REQUEST: { case BLE_GAP_EVT_CONN_PARAM_UPDATE_REQUEST: {
self->conn_params_updating = true;
ble_gap_evt_conn_param_update_request_t *request = ble_gap_evt_conn_param_update_request_t *request =
&ble_evt->evt.gap_evt.params.conn_param_update_request; &ble_evt->evt.gap_evt.params.conn_param_update_request;
sd_ble_gap_conn_param_update(self->conn_handle, &request->conn_params); sd_ble_gap_conn_param_update(self->conn_handle, &request->conn_params);
break; break;
} }
case BLE_GAP_EVT_CONN_PARAM_UPDATE: { // 0x12
ble_gap_evt_conn_param_update_t *result =
&ble_evt->evt.gap_evt.params.conn_param_update;
#if CIRCUITPY_VERBOSE_BLE
ble_gap_conn_params_t *cp = &ble_evt->evt.gap_evt.params.conn_param_update.conn_params;
mp_printf(&mp_plat_print, "conn params updated: min_ci %d max_ci %d s_l %d sup_timeout %d\n", cp->min_conn_interval, cp->max_conn_interval, cp->slave_latency, cp->conn_sup_timeout);
#endif
memcpy(&self->conn_params, &result->conn_params, sizeof(ble_gap_conn_params_t));
self->conn_params_updating = false;
break;
}
case BLE_GAP_EVT_SEC_PARAMS_REQUEST: { case BLE_GAP_EVT_SEC_PARAMS_REQUEST: {
ble_gap_sec_keyset_t keyset = { ble_gap_sec_keyset_t keyset = {
.keys_own = { .keys_own = {
@ -211,11 +248,6 @@ bool connection_on_ble_evt(ble_evt_t *ble_evt, void *self_in) {
default: default:
// For debugging.
if (dump_events) {
mp_printf(&mp_plat_print, "Unhandled connection event: 0x%04x\n", ble_evt->header.evt_id);
}
return false; return false;
} }
return true; return true;
@ -262,6 +294,25 @@ void common_hal_bleio_connection_pair(bleio_connection_internal_t *self, bool bo
check_sec_status(self->sec_status); check_sec_status(self->sec_status);
} }
mp_float_t common_hal_bleio_connection_get_connection_interval(bleio_connection_internal_t *self) {
while (self->conn_params_updating && !mp_hal_is_interrupted()) {
RUN_BACKGROUND_TASKS;
}
return 1.25f * self->conn_params.min_conn_interval;
}
void common_hal_bleio_connection_set_connection_interval(bleio_connection_internal_t *self, mp_float_t new_interval) {
self->conn_params_updating = true;
uint16_t interval = new_interval / 1.25f;
self->conn_params.min_conn_interval = interval;
self->conn_params.max_conn_interval = interval;
uint32_t status = NRF_ERROR_BUSY;
while (status == NRF_ERROR_BUSY) {
status = sd_ble_gap_conn_param_update(self->conn_handle, &self->conn_params);
RUN_BACKGROUND_TASKS;
}
check_nrf_error(status);
}
// service_uuid may be NULL, to discover all services. // service_uuid may be NULL, to discover all services.
STATIC bool discover_next_services(bleio_connection_internal_t* connection, uint16_t start_handle, ble_uuid_t *service_uuid) { STATIC bool discover_next_services(bleio_connection_internal_t* connection, uint16_t start_handle, ble_uuid_t *service_uuid) {
@ -600,8 +651,10 @@ STATIC void discover_remote_services(bleio_connection_internal_t *self, mp_obj_t
ble_drv_remove_event_handler(discovery_on_ble_evt, self); ble_drv_remove_event_handler(discovery_on_ble_evt, self);
} }
mp_obj_tuple_t *common_hal_bleio_connection_discover_remote_services(bleio_connection_obj_t *self, mp_obj_t service_uuids_whitelist) { mp_obj_tuple_t *common_hal_bleio_connection_discover_remote_services(bleio_connection_obj_t *self, mp_obj_t service_uuids_whitelist) {
discover_remote_services(self->connection, service_uuids_whitelist); discover_remote_services(self->connection, service_uuids_whitelist);
bleio_connection_ensure_connected(self);
// Convert to a tuple and then clear the list so the callee will take ownership. // Convert to a tuple and then clear the list so the callee will take ownership.
mp_obj_tuple_t *services_tuple = service_linked_list_to_tuple(self->connection->remote_service_list); mp_obj_tuple_t *services_tuple = service_linked_list_to_tuple(self->connection->remote_service_list);
self->connection->remote_service_list = NULL; self->connection->remote_service_list = NULL;
@ -609,7 +662,6 @@ mp_obj_tuple_t *common_hal_bleio_connection_discover_remote_services(bleio_conne
return services_tuple; return services_tuple;
} }
uint16_t bleio_connection_get_conn_handle(bleio_connection_obj_t *self) { uint16_t bleio_connection_get_conn_handle(bleio_connection_obj_t *self) {
if (self == NULL || self->connection == NULL) { if (self == NULL || self->connection == NULL) {
return BLE_CONN_HANDLE_INVALID; return BLE_CONN_HANDLE_INVALID;

View File

@ -63,6 +63,8 @@ typedef struct {
uint8_t sec_status; // Internal security status. uint8_t sec_status; // Internal security status.
mp_obj_t connection_obj; mp_obj_t connection_obj;
ble_drv_evt_handler_entry_t handler_entry; ble_drv_evt_handler_entry_t handler_entry;
ble_gap_conn_params_t conn_params;
volatile bool conn_params_updating;
} bleio_connection_internal_t; } bleio_connection_internal_t;
typedef struct { typedef struct {

View File

@ -119,6 +119,10 @@ void common_hal_bleio_service_add_characteristic(bleio_service_obj_t *self,
bleio_attribute_gatts_set_security_mode(&char_attr_md.read_perm, characteristic->read_perm); bleio_attribute_gatts_set_security_mode(&char_attr_md.read_perm, characteristic->read_perm);
bleio_attribute_gatts_set_security_mode(&char_attr_md.write_perm, characteristic->write_perm); bleio_attribute_gatts_set_security_mode(&char_attr_md.write_perm, characteristic->write_perm);
#if CIRCUITPY_VERBOSE_BLE
// Turn on read authorization so that we receive an event to print on every read.
char_attr_md.rd_auth = true;
#endif
ble_gatts_attr_t char_attr = { ble_gatts_attr_t char_attr = {
.p_uuid = &char_uuid, .p_uuid = &char_uuid,
@ -137,6 +141,9 @@ void common_hal_bleio_service_add_characteristic(bleio_service_obj_t *self,
characteristic->cccd_handle = char_handles.cccd_handle; characteristic->cccd_handle = char_handles.cccd_handle;
characteristic->sccd_handle = char_handles.sccd_handle; characteristic->sccd_handle = char_handles.sccd_handle;
characteristic->handle = char_handles.value_handle; characteristic->handle = char_handles.value_handle;
#if CIRCUITPY_VERBOSE_BLE
mp_printf(&mp_plat_print, "Char handle %x user %x cccd %x sccd %x\n", characteristic->handle, characteristic->user_desc_handle, characteristic->cccd_handle, characteristic->sccd_handle);
#endif
mp_obj_list_append(self->characteristic_list, MP_OBJ_FROM_PTR(characteristic)); mp_obj_list_append(self->characteristic_list, MP_OBJ_FROM_PTR(characteristic));
} }

View File

@ -187,7 +187,11 @@ size_t common_hal_bleio_gattc_read(uint16_t handle, uint16_t conn_handle, uint8_
read_info.done = false; read_info.done = false;
ble_drv_add_event_handler(_on_gattc_read_rsp_evt, &read_info); ble_drv_add_event_handler(_on_gattc_read_rsp_evt, &read_info);
check_nrf_error(sd_ble_gattc_read(conn_handle, handle, 0)); uint32_t nrf_error = NRF_ERROR_BUSY;
while (nrf_error == NRF_ERROR_BUSY) {
nrf_error = sd_ble_gattc_read(conn_handle, handle, 0);
}
check_nrf_error(nrf_error);
while (!read_info.done) { while (!read_info.done) {
RUN_BACKGROUND_TASKS; RUN_BACKGROUND_TASKS;

View File

@ -97,27 +97,28 @@ STATIC void fill_buffers(audiopwmio_pwmaudioout_obj_t *self, int buf) {
common_hal_audiopwmio_pwmaudioout_stop(self); common_hal_audiopwmio_pwmaudioout_stop(self);
return; return;
} }
uint32_t num_samples = buffer_length / self->bytes_per_sample / self->spacing; uint32_t num_samples = buffer_length / self->bytes_per_sample / self->sample_channel_count;
uint16_t *end_dev_buffer = dev_buffer + 2 * num_samples;
if (self->bytes_per_sample == 1) { if (self->bytes_per_sample == 1) {
uint8_t offset = self->signed_to_unsigned ? 0x80 : 0; uint8_t offset = self->signed_to_unsigned ? 0x80 : 0;
uint16_t scale = self->scale; uint16_t scale = self->scale;
for (uint32_t i=0; i<buffer_length/self->spacing; i++) { while (dev_buffer < end_dev_buffer) {
uint8_t rawval = (*buffer++ + offset); uint8_t rawval = (*buffer++ + offset);
uint16_t val = (uint16_t)(((uint32_t)rawval * (uint32_t)scale) >> 8); uint16_t val = (uint16_t)(((uint32_t)rawval * (uint32_t)scale) >> 8);
*dev_buffer++ = val; *dev_buffer++ = val;
if (self->spacing == 1) if (self->sample_channel_count == 1)
*dev_buffer++ = val; *dev_buffer++ = val;
} }
} else { } else {
uint16_t offset = self->signed_to_unsigned ? 0x8000 : 0; uint16_t offset = self->signed_to_unsigned ? 0x8000 : 0;
uint16_t scale = self->scale; uint16_t scale = self->scale;
uint16_t *buffer16 = (uint16_t*)buffer; uint16_t *buffer16 = (uint16_t*)buffer;
for (uint32_t i=0; i<buffer_length/2/self->spacing; i++) { while (dev_buffer < end_dev_buffer) {
uint16_t rawval = (*buffer16++ + offset); uint16_t rawval = (*buffer16++ + offset);
uint16_t val = (uint16_t)((rawval * (uint32_t)scale) >> 16); uint16_t val = (uint16_t)((rawval * (uint32_t)scale) >> 16);
*dev_buffer++ = val; *dev_buffer++ = val;
if (self->spacing == 1) if (self->sample_channel_count == 1)
*dev_buffer++ = val; *dev_buffer++ = val;
} }
} }
@ -231,9 +232,12 @@ void common_hal_audiopwmio_pwmaudioout_play(audiopwmio_pwmaudioout_obj_t* self,
self->bytes_per_sample = audiosample_bits_per_sample(sample) / 8; self->bytes_per_sample = audiosample_bits_per_sample(sample) / 8;
uint32_t max_buffer_length; uint32_t max_buffer_length;
uint8_t spacing;
audiosample_get_buffer_structure(sample, /* single channel */ false, audiosample_get_buffer_structure(sample, /* single channel */ false,
&self->single_buffer, &self->signed_to_unsigned, &max_buffer_length, &self->single_buffer, &self->signed_to_unsigned, &max_buffer_length,
&self->spacing); &spacing);
self->sample_channel_count = audiosample_channel_count(sample);
if (max_buffer_length > UINT16_MAX) { if (max_buffer_length > UINT16_MAX) {
mp_raise_ValueError_varg(translate("Buffer length %d too big. It must be less than %d"), max_buffer_length, UINT16_MAX); mp_raise_ValueError_varg(translate("Buffer length %d too big. It must be less than %d"), max_buffer_length, UINT16_MAX);
} }

View File

@ -41,7 +41,7 @@ typedef struct {
uint8_t left_channel_number; uint8_t left_channel_number;
uint8_t right_channel_number; uint8_t right_channel_number;
uint8_t spacing; uint8_t sample_channel_count;
uint8_t bytes_per_sample; uint8_t bytes_per_sample;
bool playing; bool playing;

View File

@ -231,10 +231,10 @@ size_t common_hal_busio_uart_read(busio_uart_obj_t *self, uint8_t *data, size_t
} }
size_t rx_bytes = 0; size_t rx_bytes = 0;
uint64_t start_ticks = ticks_ms; uint64_t start_ticks = supervisor_ticks_ms64();
// Wait for all bytes received or timeout // Wait for all bytes received or timeout
while ( (ringbuf_count(&self->rbuf) < len) && (ticks_ms - start_ticks < self->timeout_ms) ) { while ( (ringbuf_count(&self->rbuf) < len) && (supervisor_ticks_ms64() - start_ticks < self->timeout_ms) ) {
RUN_BACKGROUND_TASKS; RUN_BACKGROUND_TASKS;
// Allow user to break out of a timeout with a KeyboardInterrupt. // Allow user to break out of a timeout with a KeyboardInterrupt.
if ( mp_hal_is_interrupted() ) { if ( mp_hal_is_interrupted() ) {

View File

@ -29,7 +29,7 @@
#include "tick.h" #include "tick.h"
uint64_t common_hal_time_monotonic(void) { uint64_t common_hal_time_monotonic(void) {
return ticks_ms; return supervisor_ticks_ms64();
} }
void common_hal_time_delay_ms(uint32_t delay) { void common_hal_time_delay_ms(uint32_t delay) {

View File

@ -31,12 +31,13 @@
#include "py/mphal.h" #include "py/mphal.h"
#include "py/mpstate.h" #include "py/mpstate.h"
#include "py/gc.h" #include "py/gc.h"
#include "supervisor/shared/tick.h"
/*------------------------------------------------------------------*/ /*------------------------------------------------------------------*/
/* delay /* delay
*------------------------------------------------------------------*/ *------------------------------------------------------------------*/
void mp_hal_delay_ms(mp_uint_t delay) { void mp_hal_delay_ms(mp_uint_t delay) {
uint64_t start_tick = ticks_ms; uint64_t start_tick = supervisor_ticks_ms64();
uint64_t duration = 0; uint64_t duration = 0;
while (duration < delay) { while (duration < delay) {
RUN_BACKGROUND_TASKS; RUN_BACKGROUND_TASKS;
@ -45,7 +46,7 @@ void mp_hal_delay_ms(mp_uint_t delay) {
MP_STATE_VM(mp_pending_exception) == MP_OBJ_FROM_PTR(&MP_STATE_VM(mp_reload_exception))) { MP_STATE_VM(mp_pending_exception) == MP_OBJ_FROM_PTR(&MP_STATE_VM(mp_reload_exception))) {
break; break;
} }
duration = (ticks_ms - start_tick); duration = (supervisor_ticks_ms64() - start_tick);
// TODO(tannewt): Go to sleep for a little while while we wait. // TODO(tannewt): Go to sleep for a little while while we wait.
} }
} }

View File

@ -33,12 +33,11 @@
#include "lib/utils/interrupt_char.h" #include "lib/utils/interrupt_char.h"
#include "nrfx_uarte.h" #include "nrfx_uarte.h"
#include "py/mpconfig.h" #include "py/mpconfig.h"
#include "supervisor/shared/tick.h"
extern nrfx_uarte_t serial_instance; extern nrfx_uarte_t serial_instance;
extern volatile uint64_t ticks_ms; #define mp_hal_ticks_ms() ((mp_uint_t) supervisor_ticks_ms32())
#define mp_hal_ticks_ms() ((mp_uint_t) ticks_ms)
#define mp_hal_delay_us(us) NRFX_DELAY_US((uint32_t) (us)) #define mp_hal_delay_us(us) NRFX_DELAY_US((uint32_t) (us))
bool mp_hal_stdin_any(void); bool mp_hal_stdin_any(void);

View File

@ -26,31 +26,14 @@
#include "tick.h" #include "tick.h"
#include "supervisor/shared/autoreload.h" #include "supervisor/shared/tick.h"
#include "supervisor/filesystem.h"
#include "shared-module/gamepad/__init__.h" #include "shared-module/gamepad/__init__.h"
#include "shared-bindings/microcontroller/Processor.h" #include "shared-bindings/microcontroller/Processor.h"
#include "nrf.h" #include "nrf.h"
// Global millisecond tick count
volatile uint64_t ticks_ms = 0;
void SysTick_Handler(void) { void SysTick_Handler(void) {
// SysTick interrupt handler called when the SysTick timer reaches zero // Do things common to all ports when the tick occurs
// (every millisecond). supervisor_tick();
ticks_ms += 1;
#if CIRCUITPY_FILESYSTEM_FLUSH_INTERVAL_MS > 0
filesystem_tick();
#endif
#ifdef CIRCUITPY_AUTORELOAD_DELAY_MS
autoreload_tick();
#endif
#ifdef CIRCUITPY_GAMEPAD_TICKS
if (!(ticks_ms & CIRCUITPY_GAMEPAD_TICKS)) {
gamepad_tick();
}
#endif
} }
void tick_init() { void tick_init() {
@ -61,11 +44,11 @@ void tick_init() {
void tick_delay(uint32_t us) { void tick_delay(uint32_t us) {
uint32_t ticks_per_us = common_hal_mcu_processor_get_frequency() / 1000 / 1000; uint32_t ticks_per_us = common_hal_mcu_processor_get_frequency() / 1000 / 1000;
uint32_t us_between_ticks = SysTick->VAL / ticks_per_us; uint32_t us_between_ticks = SysTick->VAL / ticks_per_us;
uint64_t start_ms = ticks_ms; uint64_t start_ms = supervisor_ticks_ms64();
while (us > 1000) { while (us > 1000) {
while (ticks_ms == start_ms) {} while (supervisor_ticks_ms64() == start_ms) {}
us -= us_between_ticks; us -= us_between_ticks;
start_ms = ticks_ms; start_ms = supervisor_ticks_ms64();
us_between_ticks = 1000; us_between_ticks = 1000;
} }
while (SysTick->VAL > ((us_between_ticks - us) * ticks_per_us)) {} while (SysTick->VAL > ((us_between_ticks - us) * ticks_per_us)) {}
@ -74,11 +57,11 @@ void tick_delay(uint32_t us) {
// us counts down! // us counts down!
void current_tick(uint64_t* ms, uint32_t* us_until_ms) { void current_tick(uint64_t* ms, uint32_t* us_until_ms) {
uint32_t ticks_per_us = common_hal_mcu_processor_get_frequency() / 1000 / 1000; uint32_t ticks_per_us = common_hal_mcu_processor_get_frequency() / 1000 / 1000;
*ms = ticks_ms; *ms = supervisor_ticks_ms64();
*us_until_ms = SysTick->VAL / ticks_per_us; *us_until_ms = SysTick->VAL / ticks_per_us;
} }
void wait_until(uint64_t ms, uint32_t us_until_ms) { void wait_until(uint64_t ms, uint32_t us_until_ms) {
uint32_t ticks_per_us = common_hal_mcu_processor_get_frequency() / 1000 / 1000; uint32_t ticks_per_us = common_hal_mcu_processor_get_frequency() / 1000 / 1000;
while(ticks_ms <= ms && SysTick->VAL / ticks_per_us >= us_until_ms) {} while(supervisor_ticks_ms64() <= ms && SysTick->VAL / ticks_per_us >= us_until_ms) {}
} }

View File

@ -30,8 +30,6 @@
#include <stdint.h> #include <stdint.h>
extern volatile uint64_t ticks_ms;
extern struct timer_descriptor ms_timer; extern struct timer_descriptor ms_timer;
void tick_init(void); void tick_init(void);

View File

@ -0,0 +1,39 @@
/*
* This file is part of the MicroPython project, http://micropython.org/
*
* The MIT License (MIT)
*
* Copyright (c) 2017 Scott Shawcroft for Adafruit Industries
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
* THE SOFTWARE.
*/
#include "boards/board.h"
#include "mpconfigboard.h"
void board_init(void) {
}
bool board_requests_safe_mode(void) {
return false;
}
void reset_board(void) {
}

View File

@ -0,0 +1,47 @@
/*
* This file is part of the MicroPython project, http://micropython.org/
*
* The MIT License (MIT)
*
* Copyright (c) 2019 Lucian Copeland for Adafruit Industries
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
* THE SOFTWARE.
*/
//Micropython setup
#define MICROPY_HW_BOARD_NAME "PYB LR Nano V2"
#define MICROPY_HW_MCU_NAME "STM32F411CE"
#define FLASH_SIZE (0x80000)
#define FLASH_PAGE_SIZE (0x4000)
#define BOARD_OSC_DIV 8
// On-board flash
#define SPI_FLASH_MOSI_PIN (&pin_PB15)
#define SPI_FLASH_MISO_PIN (&pin_PB14)
#define SPI_FLASH_SCK_PIN (&pin_PB13)
#define SPI_FLASH_CS_PIN (&pin_PB12)
#define CIRCUITPY_AUTORELOAD_DELAY_MS 500
#define BOARD_FLASH_SIZE (FLASH_SIZE - 0x2000 - 0xC000)
#define AUTORESET_DELAY_MS 500

View File

@ -0,0 +1,19 @@
USB_VID = 0x239A
USB_PID = 0x8068
USB_PRODUCT = "PYB LR Nano V2"
USB_MANUFACTURER = "MicroPython Chinese Community"
USB_DEVICES = "CDC,MSC"
SPI_FLASH_FILESYSTEM = 1
EXTERNAL_FLASH_DEVICE_COUNT = 1
EXTERNAL_FLASH_DEVICES = W25Q64JV_IQ
LONGINT_IMPL = MPZ
MCU_SERIES = m4
MCU_VARIANT = stm32f4
MCU_SUB_VARIANT = stm32f411xe
MCU_PACKAGE = 48
CMSIS_MCU = STM32F411xE
LD_FILE = boards/STM32F411VETx_FLASH.ld
TEXT0_ADDR = 0x08000000
TEXT1_ADDR = 0x08020000

View File

@ -0,0 +1,59 @@
#include "shared-bindings/board/__init__.h"
STATIC const mp_rom_map_elem_t board_module_globals_table[] = {
{ MP_ROM_QSTR(MP_QSTR_Y10), MP_ROM_PTR(&pin_PA10) },
{ MP_ROM_QSTR(MP_QSTR_Y9), MP_ROM_PTR(&pin_PA13) },
{ MP_ROM_QSTR(MP_QSTR_Y8), MP_ROM_PTR(&pin_PA14) },
{ MP_ROM_QSTR(MP_QSTR_Y7), MP_ROM_PTR(&pin_PA15) },
{ MP_ROM_QSTR(MP_QSTR_Y6), MP_ROM_PTR(&pin_PB03) },
{ MP_ROM_QSTR(MP_QSTR_Y5), MP_ROM_PTR(&pin_PB04) },
{ MP_ROM_QSTR(MP_QSTR_Y4), MP_ROM_PTR(&pin_PB05) },
{ MP_ROM_QSTR(MP_QSTR_Y3), MP_ROM_PTR(&pin_PB06) },
{ MP_ROM_QSTR(MP_QSTR_Y2), MP_ROM_PTR(&pin_PB07) },
{ MP_ROM_QSTR(MP_QSTR_Y1), MP_ROM_PTR(&pin_PB08) },
{ MP_ROM_QSTR(MP_QSTR_Y0), MP_ROM_PTR(&pin_PB09) },
{ MP_ROM_QSTR(MP_QSTR_X15), MP_ROM_PTR(&pin_PA08) },
{ MP_ROM_QSTR(MP_QSTR_X14), MP_ROM_PTR(&pin_PB15) },
{ MP_ROM_QSTR(MP_QSTR_X13), MP_ROM_PTR(&pin_PB14) },
{ MP_ROM_QSTR(MP_QSTR_X12), MP_ROM_PTR(&pin_PB13) },
{ MP_ROM_QSTR(MP_QSTR_X11), MP_ROM_PTR(&pin_PB12) },
{ MP_ROM_QSTR(MP_QSTR_X10), MP_ROM_PTR(&pin_PB10) },
{ MP_ROM_QSTR(MP_QSTR_X9), MP_ROM_PTR(&pin_PB01) },
{ MP_ROM_QSTR(MP_QSTR_X8), MP_ROM_PTR(&pin_PB00) },
{ MP_ROM_QSTR(MP_QSTR_X7), MP_ROM_PTR(&pin_PA07) },
{ MP_ROM_QSTR(MP_QSTR_X6), MP_ROM_PTR(&pin_PA06) },
{ MP_ROM_QSTR(MP_QSTR_X5), MP_ROM_PTR(&pin_PA05) },
{ MP_ROM_QSTR(MP_QSTR_X4), MP_ROM_PTR(&pin_PA04) },
{ MP_ROM_QSTR(MP_QSTR_X3), MP_ROM_PTR(&pin_PA03) },
{ MP_ROM_QSTR(MP_QSTR_X2), MP_ROM_PTR(&pin_PA02) },
{ MP_ROM_QSTR(MP_QSTR_X1), MP_ROM_PTR(&pin_PA01) },
{ MP_ROM_QSTR(MP_QSTR_X0), MP_ROM_PTR(&pin_PA00) },
{ MP_ROM_QSTR(MP_QSTR_SDA1), MP_ROM_PTR(&pin_PB09) },
{ MP_ROM_QSTR(MP_QSTR_SCL1), MP_ROM_PTR(&pin_PB08) },
{ MP_ROM_QSTR(MP_QSTR_SDA2), MP_ROM_PTR(&pin_PB03) },
{ MP_ROM_QSTR(MP_QSTR_SCL2), MP_ROM_PTR(&pin_PB10) },
{ MP_ROM_QSTR(MP_QSTR_SDA3), MP_ROM_PTR(&pin_PB04) },
{ MP_ROM_QSTR(MP_QSTR_SCL3), MP_ROM_PTR(&pin_PA08) },
{ MP_ROM_QSTR(MP_QSTR_SCK1), MP_ROM_PTR(&pin_PA05) },
{ MP_ROM_QSTR(MP_QSTR_MISO1), MP_ROM_PTR(&pin_PA06) },
{ MP_ROM_QSTR(MP_QSTR_MOSI1), MP_ROM_PTR(&pin_PA07) },
{ MP_ROM_QSTR(MP_QSTR_SCK2), MP_ROM_PTR(&pin_PB13) },
{ MP_ROM_QSTR(MP_QSTR_MISO2), MP_ROM_PTR(&pin_PB14) },
{ MP_ROM_QSTR(MP_QSTR_MOSI2), MP_ROM_PTR(&pin_PB15) },
{ MP_ROM_QSTR(MP_QSTR_TX1), MP_ROM_PTR(&pin_PB07) },
{ MP_ROM_QSTR(MP_QSTR_RX1), MP_ROM_PTR(&pin_PB06) },
{ MP_ROM_QSTR(MP_QSTR_TX2), MP_ROM_PTR(&pin_PA02) },
{ MP_ROM_QSTR(MP_QSTR_RX2), MP_ROM_PTR(&pin_PA03) },
{ MP_ROM_QSTR(MP_QSTR_LED_RED), MP_ROM_PTR(&pin_PA00) },
{ MP_ROM_QSTR(MP_QSTR_LED_GREEN), MP_ROM_PTR(&pin_PA01) },
{ MP_ROM_QSTR(MP_QSTR_LED_YELLOW), MP_ROM_PTR(&pin_PA02) },
{ MP_ROM_QSTR(MP_QSTR_LED_BLUE), MP_ROM_PTR(&pin_PA03) },
{ MP_ROM_QSTR(MP_QSTR_SW), MP_ROM_PTR(&pin_PC13) },
};
MP_DEFINE_CONST_DICT(board_module_globals, board_module_globals_table);

View File

@ -0,0 +1,440 @@
/**
******************************************************************************
* @file stm32f4xx_hal_conf_template.h
* @author MCD Application Team
* @brief HAL configuration template file.
* This file should be copied to the application folder and renamed
* to stm32f4xx_hal_conf.h.
******************************************************************************
* @attention
*
* <h2><center>&copy; Copyright (c) 2017 STMicroelectronics.
* All rights reserved.</center></h2>
*
* This software component is licensed by ST under BSD 3-Clause license,
* the "License"; You may not use this file except in compliance with the
* License. You may obtain a copy of the License at:
* opensource.org/licenses/BSD-3-Clause
*
******************************************************************************
*/
/* Define to prevent recursive inclusion -------------------------------------*/
#ifndef __STM32F4xx_HAL_CONF_H
#define __STM32F4xx_HAL_CONF_H
#ifdef __cplusplus
extern "C" {
#endif
/* Exported types ------------------------------------------------------------*/
/* Exported constants --------------------------------------------------------*/
/* ########################## Module Selection ############################## */
/**
* @brief This is the list of modules to be used in the HAL driver
*/
#define HAL_MODULE_ENABLED
#define HAL_ADC_MODULE_ENABLED
/* #define HAL_CRYP_MODULE_ENABLED */
/* #define HAL_CAN_MODULE_ENABLED */
/* #define HAL_CRC_MODULE_ENABLED */
/* #define HAL_CRYP_MODULE_ENABLED */
#define HAL_DAC_MODULE_ENABLED
/* #define HAL_DCMI_MODULE_ENABLED */
/* #define HAL_DMA2D_MODULE_ENABLED */
/* #define HAL_ETH_MODULE_ENABLED */
/* #define HAL_NAND_MODULE_ENABLED */
/* #define HAL_NOR_MODULE_ENABLED */
/* #define HAL_PCCARD_MODULE_ENABLED */
/* #define HAL_SRAM_MODULE_ENABLED */
/* #define HAL_SDRAM_MODULE_ENABLED */
/* #define HAL_HASH_MODULE_ENABLED */
#define HAL_I2C_MODULE_ENABLED
#define HAL_I2S_MODULE_ENABLED
/* #define HAL_IWDG_MODULE_ENABLED */
/* #define HAL_LTDC_MODULE_ENABLED */
/* #define HAL_RNG_MODULE_ENABLED */
/* #define HAL_RTC_MODULE_ENABLED */
/* #define HAL_SAI_MODULE_ENABLED */
/* #define HAL_SD_MODULE_ENABLED */
/* #define HAL_MMC_MODULE_ENABLED */
#define HAL_SPI_MODULE_ENABLED
#define HAL_TIM_MODULE_ENABLED
#define HAL_UART_MODULE_ENABLED
#define HAL_USART_MODULE_ENABLED
/* #define HAL_IRDA_MODULE_ENABLED */
/* #define HAL_SMARTCARD_MODULE_ENABLED */
/* #define HAL_WWDG_MODULE_ENABLED */
#define HAL_PCD_MODULE_ENABLED
/* #define HAL_HCD_MODULE_ENABLED */
/* #define HAL_DSI_MODULE_ENABLED */
/* #define HAL_QSPI_MODULE_ENABLED */
/* #define HAL_QSPI_MODULE_ENABLED */
/* #define HAL_CEC_MODULE_ENABLED */
/* #define HAL_FMPI2C_MODULE_ENABLED */
/* #define HAL_SPDIFRX_MODULE_ENABLED */
/* #define HAL_DFSDM_MODULE_ENABLED */
/* #define HAL_LPTIM_MODULE_ENABLED */
/* #define HAL_EXTI_MODULE_ENABLED */
#define HAL_GPIO_MODULE_ENABLED
#define HAL_EXTI_MODULE_ENABLED
#define HAL_DMA_MODULE_ENABLED
#define HAL_RCC_MODULE_ENABLED
#define HAL_FLASH_MODULE_ENABLED
#define HAL_PWR_MODULE_ENABLED
#define HAL_CORTEX_MODULE_ENABLED
/* ########################## HSE/HSI Values adaptation ##################### */
/**
* @brief Adjust the value of External High Speed oscillator (HSE) used in your application.
* This value is used by the RCC HAL module to compute the system frequency
* (when HSE is used as system clock source, directly or through the PLL).
*/
#if !defined (HSE_VALUE)
#define HSE_VALUE ((uint32_t)8000000) /*!< Value of the External oscillator in Hz */
#endif /* HSE_VALUE */
#if !defined (HSE_STARTUP_TIMEOUT)
#define HSE_STARTUP_TIMEOUT ((uint32_t)100U) /*!< Time out for HSE start up, in ms */
#endif /* HSE_STARTUP_TIMEOUT */
/**
* @brief Internal High Speed oscillator (HSI) value.
* This value is used by the RCC HAL module to compute the system frequency
* (when HSI is used as system clock source, directly or through the PLL).
*/
#if !defined (HSI_VALUE)
#define HSI_VALUE ((uint32_t)16000000) /*!< Value of the Internal oscillator in Hz*/
#endif /* HSI_VALUE */
/**
* @brief Internal Low Speed oscillator (LSI) value.
*/
#if !defined (LSI_VALUE)
#define LSI_VALUE ((uint32_t)40000)
#endif /* LSI_VALUE */ /*!< Value of the Internal Low Speed oscillator in Hz
The real value may vary depending on the variations
in voltage and temperature. */
/**
* @brief External Low Speed oscillator (LSE) value.
*/
#if !defined (LSE_VALUE)
#define LSE_VALUE ((uint32_t)32768) /*!< Value of the External Low Speed oscillator in Hz */
#endif /* LSE_VALUE */
#if !defined (LSE_STARTUP_TIMEOUT)
#define LSE_STARTUP_TIMEOUT ((uint32_t)5000U) /*!< Time out for LSE start up, in ms */
#endif /* LSE_STARTUP_TIMEOUT */
/**
* @brief External clock source for I2S peripheral
* This value is used by the I2S HAL module to compute the I2S clock source
* frequency, this source is inserted directly through I2S_CKIN pad.
*/
#if !defined (EXTERNAL_CLOCK_VALUE)
#define EXTERNAL_CLOCK_VALUE ((uint32_t)12288000U) /*!< Value of the External audio frequency in Hz*/
#endif /* EXTERNAL_CLOCK_VALUE */
/* Tip: To avoid modifying this file each time you need to use different HSE,
=== you can define the HSE value in your toolchain compiler preprocessor. */
/* ########################### System Configuration ######################### */
/**
* @brief This is the HAL system configuration section
*/
#define VDD_VALUE ((uint32_t)3300U) /*!< Value of VDD in mv */
#define TICK_INT_PRIORITY ((uint32_t)0U) /*!< tick interrupt priority */
#define USE_RTOS 0U
#define PREFETCH_ENABLE 1U
#define INSTRUCTION_CACHE_ENABLE 1U
#define DATA_CACHE_ENABLE 1U
/* ########################## Assert Selection ############################## */
/**
* @brief Uncomment the line below to expanse the "assert_param" macro in the
* HAL drivers code
*/
/* #define USE_FULL_ASSERT 1U */
/* ################## Ethernet peripheral configuration ##################### */
/* Section 1 : Ethernet peripheral configuration */
/* MAC ADDRESS: MAC_ADDR0:MAC_ADDR1:MAC_ADDR2:MAC_ADDR3:MAC_ADDR4:MAC_ADDR5 */
#define MAC_ADDR0 2U
#define MAC_ADDR1 0U
#define MAC_ADDR2 0U
#define MAC_ADDR3 0U
#define MAC_ADDR4 0U
#define MAC_ADDR5 0U
/* Definition of the Ethernet driver buffers size and count */
#define ETH_RX_BUF_SIZE ETH_MAX_PACKET_SIZE /* buffer size for receive */
#define ETH_TX_BUF_SIZE ETH_MAX_PACKET_SIZE /* buffer size for transmit */
#define ETH_RXBUFNB ((uint32_t)4U) /* 4 Rx buffers of size ETH_RX_BUF_SIZE */
#define ETH_TXBUFNB ((uint32_t)4U) /* 4 Tx buffers of size ETH_TX_BUF_SIZE */
/* Section 2: PHY configuration section */
/* DP83848_PHY_ADDRESS Address*/
#define DP83848_PHY_ADDRESS 0x01U
/* PHY Reset delay these values are based on a 1 ms Systick interrupt*/
#define PHY_RESET_DELAY ((uint32_t)0x000000FFU)
/* PHY Configuration delay */
#define PHY_CONFIG_DELAY ((uint32_t)0x00000FFFU)
#define PHY_READ_TO ((uint32_t)0x0000FFFFU)
#define PHY_WRITE_TO ((uint32_t)0x0000FFFFU)
/* Section 3: Common PHY Registers */
#define PHY_BCR ((uint16_t)0x0000U) /*!< Transceiver Basic Control Register */
#define PHY_BSR ((uint16_t)0x0001U) /*!< Transceiver Basic Status Register */
#define PHY_RESET ((uint16_t)0x8000U) /*!< PHY Reset */
#define PHY_LOOPBACK ((uint16_t)0x4000U) /*!< Select loop-back mode */
#define PHY_FULLDUPLEX_100M ((uint16_t)0x2100U) /*!< Set the full-duplex mode at 100 Mb/s */
#define PHY_HALFDUPLEX_100M ((uint16_t)0x2000U) /*!< Set the half-duplex mode at 100 Mb/s */
#define PHY_FULLDUPLEX_10M ((uint16_t)0x0100U) /*!< Set the full-duplex mode at 10 Mb/s */
#define PHY_HALFDUPLEX_10M ((uint16_t)0x0000U) /*!< Set the half-duplex mode at 10 Mb/s */
#define PHY_AUTONEGOTIATION ((uint16_t)0x1000U) /*!< Enable auto-negotiation function */
#define PHY_RESTART_AUTONEGOTIATION ((uint16_t)0x0200U) /*!< Restart auto-negotiation function */
#define PHY_POWERDOWN ((uint16_t)0x0800U) /*!< Select the power down mode */
#define PHY_ISOLATE ((uint16_t)0x0400U) /*!< Isolate PHY from MII */
#define PHY_AUTONEGO_COMPLETE ((uint16_t)0x0020U) /*!< Auto-Negotiation process completed */
#define PHY_LINKED_STATUS ((uint16_t)0x0004U) /*!< Valid link established */
#define PHY_JABBER_DETECTION ((uint16_t)0x0002U) /*!< Jabber condition detected */
/* Section 4: Extended PHY Registers */
#define PHY_SR ((uint16_t)0x10U) /*!< PHY status register Offset */
#define PHY_SPEED_STATUS ((uint16_t)0x0002U) /*!< PHY Speed mask */
#define PHY_DUPLEX_STATUS ((uint16_t)0x0004U) /*!< PHY Duplex mask */
/* ################## SPI peripheral configuration ########################## */
/* CRC FEATURE: Use to activate CRC feature inside HAL SPI Driver
* Activated: CRC code is present inside driver
* Deactivated: CRC code cleaned from driver
*/
#define USE_SPI_CRC 0U
/* Includes ------------------------------------------------------------------*/
/**
* @brief Include module's header file
*/
#ifdef HAL_RCC_MODULE_ENABLED
#include "stm32f4xx_hal_rcc.h"
#endif /* HAL_RCC_MODULE_ENABLED */
#ifdef HAL_EXTI_MODULE_ENABLED
#include "stm32f4xx_hal_exti.h"
#endif /* HAL_EXTI_MODULE_ENABLED */
#ifdef HAL_GPIO_MODULE_ENABLED
#include "stm32f4xx_hal_gpio.h"
#endif /* HAL_GPIO_MODULE_ENABLED */
#ifdef HAL_DMA_MODULE_ENABLED
#include "stm32f4xx_hal_dma.h"
#endif /* HAL_DMA_MODULE_ENABLED */
#ifdef HAL_CORTEX_MODULE_ENABLED
#include "stm32f4xx_hal_cortex.h"
#endif /* HAL_CORTEX_MODULE_ENABLED */
#ifdef HAL_ADC_MODULE_ENABLED
#include "stm32f4xx_hal_adc.h"
#endif /* HAL_ADC_MODULE_ENABLED */
#ifdef HAL_CAN_MODULE_ENABLED
#include "stm32f4xx_hal_can.h"
#endif /* HAL_CAN_MODULE_ENABLED */
#ifdef HAL_CRC_MODULE_ENABLED
#include "stm32f4xx_hal_crc.h"
#endif /* HAL_CRC_MODULE_ENABLED */
#ifdef HAL_CRYP_MODULE_ENABLED
#include "stm32f4xx_hal_cryp.h"
#endif /* HAL_CRYP_MODULE_ENABLED */
#ifdef HAL_DMA2D_MODULE_ENABLED
#include "stm32f4xx_hal_dma2d.h"
#endif /* HAL_DMA2D_MODULE_ENABLED */
#ifdef HAL_DAC_MODULE_ENABLED
#include "stm32f4xx_hal_dac.h"
#endif /* HAL_DAC_MODULE_ENABLED */
#ifdef HAL_DCMI_MODULE_ENABLED
#include "stm32f4xx_hal_dcmi.h"
#endif /* HAL_DCMI_MODULE_ENABLED */
#ifdef HAL_ETH_MODULE_ENABLED
#include "stm32f4xx_hal_eth.h"
#endif /* HAL_ETH_MODULE_ENABLED */
#ifdef HAL_FLASH_MODULE_ENABLED
#include "stm32f4xx_hal_flash.h"
#endif /* HAL_FLASH_MODULE_ENABLED */
#ifdef HAL_SRAM_MODULE_ENABLED
#include "stm32f4xx_hal_sram.h"
#endif /* HAL_SRAM_MODULE_ENABLED */
#ifdef HAL_NOR_MODULE_ENABLED
#include "stm32f4xx_hal_nor.h"
#endif /* HAL_NOR_MODULE_ENABLED */
#ifdef HAL_NAND_MODULE_ENABLED
#include "stm32f4xx_hal_nand.h"
#endif /* HAL_NAND_MODULE_ENABLED */
#ifdef HAL_PCCARD_MODULE_ENABLED
#include "stm32f4xx_hal_pccard.h"
#endif /* HAL_PCCARD_MODULE_ENABLED */
#ifdef HAL_SDRAM_MODULE_ENABLED
#include "stm32f4xx_hal_sdram.h"
#endif /* HAL_SDRAM_MODULE_ENABLED */
#ifdef HAL_HASH_MODULE_ENABLED
#include "stm32f4xx_hal_hash.h"
#endif /* HAL_HASH_MODULE_ENABLED */
#ifdef HAL_I2C_MODULE_ENABLED
#include "stm32f4xx_hal_i2c.h"
#endif /* HAL_I2C_MODULE_ENABLED */
#ifdef HAL_I2S_MODULE_ENABLED
#include "stm32f4xx_hal_i2s.h"
#endif /* HAL_I2S_MODULE_ENABLED */
#ifdef HAL_IWDG_MODULE_ENABLED
#include "stm32f4xx_hal_iwdg.h"
#endif /* HAL_IWDG_MODULE_ENABLED */
#ifdef HAL_LTDC_MODULE_ENABLED
#include "stm32f4xx_hal_ltdc.h"
#endif /* HAL_LTDC_MODULE_ENABLED */
#ifdef HAL_PWR_MODULE_ENABLED
#include "stm32f4xx_hal_pwr.h"
#endif /* HAL_PWR_MODULE_ENABLED */
#ifdef HAL_RNG_MODULE_ENABLED
#include "stm32f4xx_hal_rng.h"
#endif /* HAL_RNG_MODULE_ENABLED */
#ifdef HAL_RTC_MODULE_ENABLED
#include "stm32f4xx_hal_rtc.h"
#endif /* HAL_RTC_MODULE_ENABLED */
#ifdef HAL_SAI_MODULE_ENABLED
#include "stm32f4xx_hal_sai.h"
#endif /* HAL_SAI_MODULE_ENABLED */
#ifdef HAL_SD_MODULE_ENABLED
#include "stm32f4xx_hal_sd.h"
#endif /* HAL_SD_MODULE_ENABLED */
#ifdef HAL_MMC_MODULE_ENABLED
#include "stm32f4xx_hal_mmc.h"
#endif /* HAL_MMC_MODULE_ENABLED */
#ifdef HAL_SPI_MODULE_ENABLED
#include "stm32f4xx_hal_spi.h"
#endif /* HAL_SPI_MODULE_ENABLED */
#ifdef HAL_TIM_MODULE_ENABLED
#include "stm32f4xx_hal_tim.h"
#endif /* HAL_TIM_MODULE_ENABLED */
#ifdef HAL_UART_MODULE_ENABLED
#include "stm32f4xx_hal_uart.h"
#endif /* HAL_UART_MODULE_ENABLED */
#ifdef HAL_USART_MODULE_ENABLED
#include "stm32f4xx_hal_usart.h"
#endif /* HAL_USART_MODULE_ENABLED */
#ifdef HAL_IRDA_MODULE_ENABLED
#include "stm32f4xx_hal_irda.h"
#endif /* HAL_IRDA_MODULE_ENABLED */
#ifdef HAL_SMARTCARD_MODULE_ENABLED
#include "stm32f4xx_hal_smartcard.h"
#endif /* HAL_SMARTCARD_MODULE_ENABLED */
#ifdef HAL_WWDG_MODULE_ENABLED
#include "stm32f4xx_hal_wwdg.h"
#endif /* HAL_WWDG_MODULE_ENABLED */
#ifdef HAL_PCD_MODULE_ENABLED
#include "stm32f4xx_hal_pcd.h"
#endif /* HAL_PCD_MODULE_ENABLED */
#ifdef HAL_HCD_MODULE_ENABLED
#include "stm32f4xx_hal_hcd.h"
#endif /* HAL_HCD_MODULE_ENABLED */
#ifdef HAL_DSI_MODULE_ENABLED
#include "stm32f4xx_hal_dsi.h"
#endif /* HAL_DSI_MODULE_ENABLED */
#ifdef HAL_QSPI_MODULE_ENABLED
#include "stm32f4xx_hal_qspi.h"
#endif /* HAL_QSPI_MODULE_ENABLED */
#ifdef HAL_CEC_MODULE_ENABLED
#include "stm32f4xx_hal_cec.h"
#endif /* HAL_CEC_MODULE_ENABLED */
#ifdef HAL_FMPI2C_MODULE_ENABLED
#include "stm32f4xx_hal_fmpi2c.h"
#endif /* HAL_FMPI2C_MODULE_ENABLED */
#ifdef HAL_SPDIFRX_MODULE_ENABLED
#include "stm32f4xx_hal_spdifrx.h"
#endif /* HAL_SPDIFRX_MODULE_ENABLED */
#ifdef HAL_DFSDM_MODULE_ENABLED
#include "stm32f4xx_hal_dfsdm.h"
#endif /* HAL_DFSDM_MODULE_ENABLED */
#ifdef HAL_LPTIM_MODULE_ENABLED
#include "stm32f4xx_hal_lptim.h"
#endif /* HAL_LPTIM_MODULE_ENABLED */
/* Exported macro ------------------------------------------------------------*/
#ifdef USE_FULL_ASSERT
/**
* @brief The assert_param macro is used for function's parameters check.
* @param expr: If expr is false, it calls assert_failed function
* which reports the name of the source file and the source
* line number of the call that failed.
* If expr is true, it returns no value.
* @retval None
*/
#define assert_param(expr) ((expr) ? (void)0U : assert_failed((uint8_t *)__FILE__, __LINE__))
/* Exported functions ------------------------------------------------------- */
void assert_failed(uint8_t* file, uint32_t line);
#else
#define assert_param(expr) ((void)0U)
#endif /* USE_FULL_ASSERT */
#ifdef __cplusplus
}
#endif
#endif /* __STM32F4xx_HAL_CONF_H */
/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/

View File

@ -32,6 +32,8 @@
#define FLASH_SIZE (0x80000) //512K #define FLASH_SIZE (0x80000) //512K
#define FLASH_PAGE_SIZE (0x4000) //16K #define FLASH_PAGE_SIZE (0x4000) //16K
#define BOARD_OSC_DIV 8
#define CIRCUITPY_AUTORELOAD_DELAY_MS 500 #define CIRCUITPY_AUTORELOAD_DELAY_MS 500
#define BOARD_FLASH_SIZE (FLASH_SIZE - 0x2000 - 0xC000) #define BOARD_FLASH_SIZE (FLASH_SIZE - 0x2000 - 0xC000)

View File

@ -36,6 +36,7 @@
#include "common-hal/microcontroller/Pin.h" #include "common-hal/microcontroller/Pin.h"
STATIC bool reserved_i2c[3]; STATIC bool reserved_i2c[3];
STATIC bool never_reset[3];
void i2c_reset(void) { void i2c_reset(void) {
//Note: I2Cs are also forcibly reset in construct, due to silicon error //Note: I2Cs are also forcibly reset in construct, due to silicon error
@ -48,11 +49,24 @@ void i2c_reset(void) {
__HAL_RCC_I2C2_CLK_DISABLE(); __HAL_RCC_I2C2_CLK_DISABLE();
#endif #endif
#ifdef I2C3 #ifdef I2C3
reserved_i2c[3] = false; reserved_i2c[2] = false;
__HAL_RCC_I2C3_CLK_DISABLE(); __HAL_RCC_I2C3_CLK_DISABLE();
#endif #endif
} }
void common_hal_busio_i2c_never_reset(busio_i2c_obj_t *self) {
for (size_t i = 0 ; i < MP_ARRAY_SIZE(mcu_i2c_banks); i++) {
if (self->handle.Instance == mcu_i2c_banks[i]) {
never_reset[i] = true;
never_reset_pin_number(self->scl->pin->port, self->scl->pin->number);
never_reset_pin_number(self->sda->pin->port, self->scl->pin->number);
break;
}
}
}
void common_hal_busio_i2c_construct(busio_i2c_obj_t *self, void common_hal_busio_i2c_construct(busio_i2c_obj_t *self,
const mcu_pin_obj_t* scl, const mcu_pin_obj_t* sda, uint32_t frequency, uint32_t timeout) { const mcu_pin_obj_t* scl, const mcu_pin_obj_t* sda, uint32_t frequency, uint32_t timeout) {
@ -166,19 +180,22 @@ void common_hal_busio_i2c_deinit(busio_i2c_obj_t *self) {
} }
#ifdef I2C1 #ifdef I2C1
if(self->handle.Instance==I2C1) { if(self->handle.Instance==I2C1) {
reserved_i2c[0] = 0; never_reset[0] = false;
reserved_i2c[0] = false;
__HAL_RCC_I2C1_CLK_DISABLE(); __HAL_RCC_I2C1_CLK_DISABLE();
} }
#endif #endif
#ifdef I2C2 #ifdef I2C2
if(self->handle.Instance==I2C2) { if(self->handle.Instance==I2C2) {
reserved_i2c[1] = 0; never_reset[1] = false;
reserved_i2c[1] = false;
__HAL_RCC_I2C2_CLK_DISABLE(); __HAL_RCC_I2C2_CLK_DISABLE();
} }
#endif #endif
#ifdef I2C3 #ifdef I2C3
if(self->handle.Instance==I2C3) { if(self->handle.Instance==I2C3) {
reserved_i2c[3] = 0; never_reset[2] = false;
reserved_i2c[2] = false;
__HAL_RCC_I2C3_CLK_DISABLE(); __HAL_RCC_I2C3_CLK_DISABLE();
} }
#endif #endif

View File

@ -165,7 +165,7 @@ void common_hal_busio_spi_construct(busio_spi_obj_t *self,
self->baudrate = (get_busclock(SPIx)/16); self->baudrate = (get_busclock(SPIx)/16);
self->prescaler = 16; self->prescaler = 16;
self->polarity = 0; self->polarity = 0;
self->phase = 1; self->phase = 0;
self->bits = 8; self->bits = 8;
claim_pin(sck); claim_pin(sck);
@ -191,7 +191,8 @@ bool common_hal_busio_spi_deinited(busio_spi_obj_t *self) {
void common_hal_busio_spi_deinit(busio_spi_obj_t *self) { void common_hal_busio_spi_deinit(busio_spi_obj_t *self) {
spi_clock_disable(1<<(self->sck->spi_index - 1)); spi_clock_disable(1<<(self->sck->spi_index - 1));
reserved_spi[self->sck->spi_index - 1] = true; reserved_spi[self->sck->spi_index - 1] = false;
never_reset_spi[self->sck->spi_index - 1] = false;
reset_pin_number(self->sck->pin->port,self->sck->pin->number); reset_pin_number(self->sck->pin->port,self->sck->pin->number);
reset_pin_number(self->mosi->pin->port,self->mosi->pin->number); reset_pin_number(self->mosi->pin->port,self->mosi->pin->number);

View File

@ -250,10 +250,10 @@ size_t common_hal_busio_uart_read(busio_uart_obj_t *self, uint8_t *data, size_t
} }
size_t rx_bytes = 0; size_t rx_bytes = 0;
uint64_t start_ticks = ticks_ms; uint64_t start_ticks = supervisor_ticks_ms64();
// Wait for all bytes received or timeout, same as nrf // Wait for all bytes received or timeout, same as nrf
while ( (ringbuf_count(&self->rbuf) < len) && (ticks_ms - start_ticks < self->timeout_ms) ) { while ( (ringbuf_count(&self->rbuf) < len) && (supervisor_ticks_ms64() - start_ticks < self->timeout_ms) ) {
RUN_BACKGROUND_TASKS; RUN_BACKGROUND_TASKS;
//restart if it failed in the callback //restart if it failed in the callback
if (errflag != HAL_OK) { if (errflag != HAL_OK) {

View File

@ -47,7 +47,7 @@ digitalinout_result_t common_hal_digitalio_digitalinout_construct(
GPIO_InitStruct.Pin = pin_mask(self->pin->number); GPIO_InitStruct.Pin = pin_mask(self->pin->number);
GPIO_InitStruct.Mode = GPIO_MODE_INPUT; GPIO_InitStruct.Mode = GPIO_MODE_INPUT;
GPIO_InitStruct.Pull = GPIO_NOPULL; GPIO_InitStruct.Pull = GPIO_NOPULL;
GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_LOW; GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_VERY_HIGH;
HAL_GPIO_Init(pin_port(self->pin->port), &GPIO_InitStruct); HAL_GPIO_Init(pin_port(self->pin->port), &GPIO_InitStruct);
return DIGITALINOUT_OK; return DIGITALINOUT_OK;
@ -73,7 +73,7 @@ void common_hal_digitalio_digitalinout_switch_to_input(
GPIO_InitStruct.Pin = pin_mask(self->pin->number); GPIO_InitStruct.Pin = pin_mask(self->pin->number);
GPIO_InitStruct.Mode = GPIO_MODE_INPUT; GPIO_InitStruct.Mode = GPIO_MODE_INPUT;
GPIO_InitStruct.Pull = GPIO_NOPULL; GPIO_InitStruct.Pull = GPIO_NOPULL;
GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_LOW; GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_VERY_HIGH;
HAL_GPIO_Init(pin_port(self->pin->port), &GPIO_InitStruct); HAL_GPIO_Init(pin_port(self->pin->port), &GPIO_InitStruct);
common_hal_digitalio_digitalinout_set_pull(self, pull); common_hal_digitalio_digitalinout_set_pull(self, pull);
@ -114,7 +114,7 @@ void common_hal_digitalio_digitalinout_set_drive_mode(
GPIO_InitStruct.Mode = (drive_mode == DRIVE_MODE_OPEN_DRAIN ? GPIO_InitStruct.Mode = (drive_mode == DRIVE_MODE_OPEN_DRAIN ?
GPIO_MODE_OUTPUT_OD : GPIO_MODE_OUTPUT_PP); GPIO_MODE_OUTPUT_OD : GPIO_MODE_OUTPUT_PP);
GPIO_InitStruct.Pull = GPIO_NOPULL; GPIO_InitStruct.Pull = GPIO_NOPULL;
GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_LOW; GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_VERY_HIGH;
HAL_GPIO_Init(pin_port(self->pin->port), &GPIO_InitStruct); HAL_GPIO_Init(pin_port(self->pin->port), &GPIO_InitStruct);
} }

View File

@ -0,0 +1,68 @@
/*
* This file is part of the MicroPython project, http://micropython.org/
*
* The MIT License (MIT)
*
* Copyright (c) 2019 Lucian Copeland for Adafruit Industries
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
* THE SOFTWARE.
*/
#include "shared-bindings/displayio/ParallelBus.h"
#include <stdint.h>
#include "common-hal/microcontroller/Pin.h"
#include "py/runtime.h"
#include "shared-bindings/digitalio/DigitalInOut.h"
#include "shared-bindings/microcontroller/__init__.h"
#include "tick.h"
void common_hal_displayio_parallelbus_construct(displayio_parallelbus_obj_t* self,
const mcu_pin_obj_t* data0, const mcu_pin_obj_t* command, const mcu_pin_obj_t* chip_select,
const mcu_pin_obj_t* write, const mcu_pin_obj_t* read, const mcu_pin_obj_t* reset) {
mp_raise_NotImplementedError(translate("ParallelBus not yet supported"));
}
void common_hal_displayio_parallelbus_deinit(displayio_parallelbus_obj_t* self) {
}
bool common_hal_displayio_parallelbus_reset(mp_obj_t obj) {
return false;
}
bool common_hal_displayio_parallelbus_bus_free(mp_obj_t obj) {
return false;
}
bool common_hal_displayio_parallelbus_begin_transaction(mp_obj_t obj) {
return false;
}
void common_hal_displayio_parallelbus_send(mp_obj_t obj, display_byte_type_t byte_type, display_chip_select_behavior_t chip_select, uint8_t *data, uint32_t data_length) {
}
void common_hal_displayio_parallelbus_end_transaction(mp_obj_t obj) {
}

View File

@ -0,0 +1,36 @@
/*
* This file is part of the MicroPython project, http://micropython.org/
*
* The MIT License (MIT)
*
* Copyright (c) 2019 Lucian Copeland for Adafruit Industries
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
* THE SOFTWARE.
*/
#ifndef MICROPY_INCLUDED_STM32F4_COMMON_HAL_DISPLAYIO_PARALLELBUS_H
#define MICROPY_INCLUDED_STM32F4_COMMON_HAL_DISPLAYIO_PARALLELBUS_H
#include "common-hal/digitalio/DigitalInOut.h"
typedef struct {
mp_obj_base_t base;
} displayio_parallelbus_obj_t;
#endif // MICROPY_INCLUDED_STM32F4_COMMON_HAL_DISPLAYIO_PARALLELBUS_H

View File

@ -46,8 +46,12 @@ bool neopixel_in_use;
#elif MCU_PACKAGE == 64 #elif MCU_PACKAGE == 64
#define GPIO_PORT_COUNT 3 #define GPIO_PORT_COUNT 3
GPIO_TypeDef * ports[GPIO_PORT_COUNT] = {GPIOA, GPIOB, GPIOC}; GPIO_TypeDef * ports[GPIO_PORT_COUNT] = {GPIOA, GPIOB, GPIOC};
#elif MCU_PACKAGE == 48
#define GPIO_PORT_COUNT 3
GPIO_TypeDef * ports[GPIO_PORT_COUNT] = {GPIOA, GPIOB, GPIOC};
#endif #endif
STATIC uint16_t claimed_pins[GPIO_PORT_COUNT]; STATIC uint16_t claimed_pins[GPIO_PORT_COUNT];
STATIC uint16_t never_reset_pins[GPIO_PORT_COUNT]; STATIC uint16_t never_reset_pins[GPIO_PORT_COUNT];

View File

@ -48,9 +48,9 @@ STATIC uint32_t get_us(void) {
uint32_t ticks_per_us = HAL_RCC_GetSysClockFreq()/1000000; uint32_t ticks_per_us = HAL_RCC_GetSysClockFreq()/1000000;
uint32_t micros, sys_cycles; uint32_t micros, sys_cycles;
do { do {
micros = ticks_ms; micros = supervisor_ticks_ms32();
sys_cycles = SysTick->VAL; //counts backwards sys_cycles = SysTick->VAL; //counts backwards
} while (micros != ticks_ms); //try again if ticks_ms rolled over } while (micros != supervisor_ticks_ms32()); //try again if ticks_ms rolled over
return (micros * 1000) + (ticks_per_us * 1000 - sys_cycles) / ticks_per_us; return (micros * 1000) + (ticks_per_us * 1000 - sys_cycles) / ticks_per_us;
} }
@ -169,7 +169,7 @@ STATIC const mp_rom_map_elem_t mcu_pin_globals_table[] = {
{ MP_ROM_QSTR(MP_QSTR_PE15), MP_ROM_PTR(&pin_PE15) }, { MP_ROM_QSTR(MP_QSTR_PE15), MP_ROM_PTR(&pin_PE15) },
#endif #endif
{ MP_ROM_QSTR(MP_QSTR_PB10), MP_ROM_PTR(&pin_PB10) }, { MP_ROM_QSTR(MP_QSTR_PB10), MP_ROM_PTR(&pin_PB10) },
#if MCU_PACKAGE != 100 #if MCU_PACKAGE == 144
{ MP_ROM_QSTR(MP_QSTR_PB11), MP_ROM_PTR(&pin_PB11) }, { MP_ROM_QSTR(MP_QSTR_PB11), MP_ROM_PTR(&pin_PB11) },
#endif #endif
{ MP_ROM_QSTR(MP_QSTR_PB12), MP_ROM_PTR(&pin_PB12) }, { MP_ROM_QSTR(MP_QSTR_PB12), MP_ROM_PTR(&pin_PB12) },

View File

@ -28,6 +28,8 @@
#include "shared-bindings/neopixel_write/__init__.h" #include "shared-bindings/neopixel_write/__init__.h"
#include "tick.h" #include "tick.h"
#include "py/mperrno.h"
#include "py/runtime.h"
#include "common-hal/microcontroller/Pin.h" #include "common-hal/microcontroller/Pin.h"
#include "stm32f4xx_hal.h" #include "stm32f4xx_hal.h"
#include "stm32f4xx_ll_gpio.h" #include "stm32f4xx_ll_gpio.h"
@ -40,6 +42,9 @@ uint32_t next_start_tick_us = 1000;
#define MAGIC_800_T0H 2800000 // ~0.36 us -> 0.44 field #define MAGIC_800_T0H 2800000 // ~0.36 us -> 0.44 field
#define MAGIC_800_T1H 1350000 // ~0.74 us -> 0.84 field #define MAGIC_800_T1H 1350000 // ~0.74 us -> 0.84 field
#pragma GCC push_options
#pragma GCC optimize ("Os")
void common_hal_neopixel_write (const digitalio_digitalinout_obj_t* digitalinout, uint8_t *pixels, void common_hal_neopixel_write (const digitalio_digitalinout_obj_t* digitalinout, uint8_t *pixels,
uint32_t numBytes) { uint32_t numBytes) {
uint8_t *p = pixels, *end = p + numBytes, pix = *p++, mask = 0x80; uint8_t *p = pixels, *end = p + numBytes, pix = *p++, mask = 0x80;
@ -48,7 +53,7 @@ void common_hal_neopixel_write (const digitalio_digitalinout_obj_t* digitalinout
//assumes 800_000Hz frequency //assumes 800_000Hz frequency
//Theoretical values here are 800_000 -> 1.25us, 2500000->0.4us, 1250000->0.8us //Theoretical values here are 800_000 -> 1.25us, 2500000->0.4us, 1250000->0.8us
//But they don't work, possibly due to bad optimization? Use tested magic values instead //TODO: try to get dynamic weighting working again
uint32_t sys_freq = HAL_RCC_GetSysClockFreq(); uint32_t sys_freq = HAL_RCC_GetSysClockFreq();
uint32_t interval = sys_freq/MAGIC_800_INT; uint32_t interval = sys_freq/MAGIC_800_INT;
uint32_t t0 = (sys_freq/MAGIC_800_T0H); uint32_t t0 = (sys_freq/MAGIC_800_T0H);
@ -63,23 +68,22 @@ void common_hal_neopixel_write (const digitalio_digitalinout_obj_t* digitalinout
__disable_irq(); __disable_irq();
// Enable DWT in debug core. Useable when interrupts disabled, as opposed to Systick->VAL // Enable DWT in debug core. Useable when interrupts disabled, as opposed to Systick->VAL
//ITM->LAR = 0xC5ACCE55; //this should be required but isn't
CoreDebug->DEMCR |= CoreDebug_DEMCR_TRCENA_Msk; CoreDebug->DEMCR |= CoreDebug_DEMCR_TRCENA_Msk;
DWT->CTRL |= DWT_CTRL_CYCCNTENA_Msk; DWT->CTRL |= DWT_CTRL_CYCCNTENA_Msk;
DWT->CYCCNT = 0; DWT->CYCCNT = 0;
for(;;) { for(;;) {
cyc = (pix & mask) ? t1 : t0;
start = DWT->CYCCNT; start = DWT->CYCCNT;
LL_GPIO_SetOutputPin(p_port, p_mask); LL_GPIO_SetOutputPin(p_port, p_mask);
cyc = (pix & mask) ? t1 : t0; while((DWT->CYCCNT - start) < cyc);
while(DWT->CYCCNT - start < cyc);
LL_GPIO_ResetOutputPin(p_port, p_mask); LL_GPIO_ResetOutputPin(p_port, p_mask);
while((DWT->CYCCNT - start) < interval);
if(!(mask >>= 1)) { if(!(mask >>= 1)) {
if(p >= end) break; if(p >= end) break;
pix = *p++; pix = *p++;
mask = 0x80; mask = 0x80;
} }
while(DWT->CYCCNT - start < interval); //wait for interval to finish
} }
// Enable interrupts again // Enable interrupts again
@ -94,3 +98,5 @@ void common_hal_neopixel_write (const digitalio_digitalinout_obj_t* digitalinout
next_start_tick_us -= 100; next_start_tick_us -= 100;
} }
} }
#pragma GCC pop_options

View File

@ -29,7 +29,7 @@
#include "tick.h" #include "tick.h"
uint64_t common_hal_time_monotonic(void) { uint64_t common_hal_time_monotonic(void) {
return ticks_ms; return supervisor_ticks_ms64();
} }
void common_hal_time_delay_ms(uint32_t delay) { void common_hal_time_delay_ms(uint32_t delay) {

View File

@ -65,6 +65,9 @@ ifndef CIRCUITPY_NEOPIXEL_WRITE
CIRCUITPY_NEOPIXEL_WRITE = 1 CIRCUITPY_NEOPIXEL_WRITE = 1
endif endif
ifndef
CIRCUITPY_DISPLAYIO = 1
endif
#ifeq ($(MCU_SUB_VARIANT), stm32f412zx) #ifeq ($(MCU_SUB_VARIANT), stm32f412zx)
#endif #endif

View File

@ -31,11 +31,13 @@
#include "py/mpstate.h" #include "py/mpstate.h"
#include "py/gc.h" #include "py/gc.h"
#include "supervisor/shared/tick.h"
/*------------------------------------------------------------------*/ /*------------------------------------------------------------------*/
/* delay /* delay
*------------------------------------------------------------------*/ *------------------------------------------------------------------*/
void mp_hal_delay_ms(mp_uint_t delay) { void mp_hal_delay_ms(mp_uint_t delay) {
uint64_t start_tick = ticks_ms; uint64_t start_tick = supervisor_ticks_ms64();
uint64_t duration = 0; uint64_t duration = 0;
while (duration < delay) { while (duration < delay) {
#ifdef MICROPY_VM_HOOK_LOOP #ifdef MICROPY_VM_HOOK_LOOP
@ -46,7 +48,7 @@ void mp_hal_delay_ms(mp_uint_t delay) {
MP_STATE_VM(mp_pending_exception) == MP_OBJ_FROM_PTR(&MP_STATE_VM(mp_reload_exception))) { MP_STATE_VM(mp_pending_exception) == MP_OBJ_FROM_PTR(&MP_STATE_VM(mp_reload_exception))) {
break; break;
} }
duration = (ticks_ms - start_tick); duration = (supervisor_ticks_ms64() - start_tick);
// TODO(tannewt): Go to sleep for a little while while we wait. // TODO(tannewt): Go to sleep for a little while while we wait.
} }
} }

View File

@ -32,10 +32,10 @@
#include "lib/utils/interrupt_char.h" #include "lib/utils/interrupt_char.h"
#include "py/mpconfig.h" #include "py/mpconfig.h"
#include "supervisor/shared/tick.h"
extern volatile uint64_t ticks_ms;
#define mp_hal_ticks_ms() ((mp_uint_t) ticks_ms) #define mp_hal_ticks_ms() ((mp_uint_t) supervisor_ticks_ms32())
//#define mp_hal_delay_us(us) NRFX_DELAY_US((uint32_t) (us)) //#define mp_hal_delay_us(us) NRFX_DELAY_US((uint32_t) (us))
bool mp_hal_stdin_any(void); bool mp_hal_stdin_any(void);

View File

@ -25,6 +25,7 @@
* THE SOFTWARE. * THE SOFTWARE.
*/ */
#include "stm32f4xx_hal.h" #include "stm32f4xx_hal.h"
#include "py/mpconfig.h"
void stm32f4_peripherals_clocks_init(void) { void stm32f4_peripherals_clocks_init(void) {
//System clock init //System clock init
@ -44,7 +45,7 @@ void stm32f4_peripherals_clocks_init(void) {
RCC_OscInitStruct.HSEState = RCC_HSE_ON; RCC_OscInitStruct.HSEState = RCC_HSE_ON;
RCC_OscInitStruct.PLL.PLLState = RCC_PLL_ON; RCC_OscInitStruct.PLL.PLLState = RCC_PLL_ON;
RCC_OscInitStruct.PLL.PLLSource = RCC_PLLSOURCE_HSE; RCC_OscInitStruct.PLL.PLLSource = RCC_PLLSOURCE_HSE;
RCC_OscInitStruct.PLL.PLLM = 8; RCC_OscInitStruct.PLL.PLLM = BOARD_OSC_DIV;
RCC_OscInitStruct.PLL.PLLN = 336; RCC_OscInitStruct.PLL.PLLN = 336;
RCC_OscInitStruct.PLL.PLLP = RCC_PLLP_DIV4; RCC_OscInitStruct.PLL.PLLP = RCC_PLLP_DIV4;
RCC_OscInitStruct.PLL.PLLQ = 7; RCC_OscInitStruct.PLL.PLLQ = 7;

Some files were not shown because too many files have changed in this diff Show More