Merge remote-tracking branch 'adafruit/master' into esp32s2_digitalio
This commit is contained in:
commit
ba724fffb4
2
conf.py
2
conf.py
@ -18,6 +18,7 @@ import sys
|
||||
import os
|
||||
|
||||
import recommonmark
|
||||
import subprocess
|
||||
|
||||
# If extensions (or modules to document with autodoc) are in another directory,
|
||||
# add these directories to sys.path here. If the directory is relative to the
|
||||
@ -67,6 +68,7 @@ source_suffix = {
|
||||
'.md': 'markdown',
|
||||
}
|
||||
|
||||
subprocess.check_output(["make", "stubs"])
|
||||
extensions.append('autoapi.extension')
|
||||
|
||||
autoapi_type = 'python'
|
||||
|
@ -1,3 +1,5 @@
|
||||
sphinx==1.8.5
|
||||
recommonmark==0.5.0
|
||||
sphinx<3
|
||||
recommonmark==0.6.0
|
||||
sphinxcontrib-svg2pdfconverter==0.1.0
|
||||
astroid
|
||||
sphinx-autoapi
|
||||
|
@ -8,7 +8,7 @@ msgid ""
|
||||
msgstr ""
|
||||
"Project-Id-Version: PACKAGE VERSION\n"
|
||||
"Report-Msgid-Bugs-To: \n"
|
||||
"POT-Creation-Date: 2020-05-20 08:55-0700\n"
|
||||
"POT-Creation-Date: 2020-05-20 10:48-0700\n"
|
||||
"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
|
||||
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
|
||||
"Language-Team: LANGUAGE <LL@li.org>\n"
|
||||
@ -1493,6 +1493,11 @@ msgstr ""
|
||||
msgid "Tile width must exactly divide bitmap width"
|
||||
msgstr ""
|
||||
|
||||
#: ports/nrf/common-hal/_bleio/Adapter.c
|
||||
#, c-format
|
||||
msgid "Timeout is too long: Maximum timeout length is %d seconds"
|
||||
msgstr ""
|
||||
|
||||
#: ports/atmel-samd/common-hal/audiobusio/I2SOut.c
|
||||
msgid "Too many channels in sample."
|
||||
msgstr "Terlalu banyak channel dalam sampel"
|
||||
|
@ -8,7 +8,7 @@ msgid ""
|
||||
msgstr ""
|
||||
"Project-Id-Version: PACKAGE VERSION\n"
|
||||
"Report-Msgid-Bugs-To: \n"
|
||||
"POT-Creation-Date: 2020-05-20 08:55-0700\n"
|
||||
"POT-Creation-Date: 2020-05-20 10:48-0700\n"
|
||||
"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
|
||||
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
|
||||
"Language-Team: LANGUAGE <LL@li.org>\n"
|
||||
@ -1477,6 +1477,11 @@ msgstr ""
|
||||
msgid "Tile width must exactly divide bitmap width"
|
||||
msgstr ""
|
||||
|
||||
#: ports/nrf/common-hal/_bleio/Adapter.c
|
||||
#, c-format
|
||||
msgid "Timeout is too long: Maximum timeout length is %d seconds"
|
||||
msgstr ""
|
||||
|
||||
#: ports/atmel-samd/common-hal/audiobusio/I2SOut.c
|
||||
msgid "Too many channels in sample."
|
||||
msgstr ""
|
||||
|
@ -8,7 +8,7 @@ msgid ""
|
||||
msgstr ""
|
||||
"Project-Id-Version: PACKAGE VERSION\n"
|
||||
"Report-Msgid-Bugs-To: \n"
|
||||
"POT-Creation-Date: 2020-05-20 08:55-0700\n"
|
||||
"POT-Creation-Date: 2020-05-20 10:48-0700\n"
|
||||
"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
|
||||
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
|
||||
"Language-Team: LANGUAGE <LL@li.org>\n"
|
||||
@ -1477,6 +1477,11 @@ msgstr ""
|
||||
msgid "Tile width must exactly divide bitmap width"
|
||||
msgstr ""
|
||||
|
||||
#: ports/nrf/common-hal/_bleio/Adapter.c
|
||||
#, c-format
|
||||
msgid "Timeout is too long: Maximum timeout length is %d seconds"
|
||||
msgstr ""
|
||||
|
||||
#: ports/atmel-samd/common-hal/audiobusio/I2SOut.c
|
||||
msgid "Too many channels in sample."
|
||||
msgstr ""
|
||||
|
@ -7,7 +7,7 @@ msgid ""
|
||||
msgstr ""
|
||||
"Project-Id-Version: \n"
|
||||
"Report-Msgid-Bugs-To: \n"
|
||||
"POT-Creation-Date: 2020-05-20 08:55-0700\n"
|
||||
"POT-Creation-Date: 2020-05-20 10:48-0700\n"
|
||||
"PO-Revision-Date: 2020-05-18 02:48+0000\n"
|
||||
"Last-Translator: Jeff Epler <jepler@gmail.com>\n"
|
||||
"Language-Team: German <https://later.unpythonic.net/projects/circuitpython/"
|
||||
@ -1503,6 +1503,11 @@ msgstr ""
|
||||
msgid "Tile width must exactly divide bitmap width"
|
||||
msgstr ""
|
||||
|
||||
#: ports/nrf/common-hal/_bleio/Adapter.c
|
||||
#, c-format
|
||||
msgid "Timeout is too long: Maximum timeout length is %d seconds"
|
||||
msgstr ""
|
||||
|
||||
#: ports/atmel-samd/common-hal/audiobusio/I2SOut.c
|
||||
msgid "Too many channels in sample."
|
||||
msgstr "Zu viele Kanäle im sample"
|
||||
|
@ -7,7 +7,7 @@ msgid ""
|
||||
msgstr ""
|
||||
"Project-Id-Version: \n"
|
||||
"Report-Msgid-Bugs-To: \n"
|
||||
"POT-Creation-Date: 2020-05-20 08:55-0700\n"
|
||||
"POT-Creation-Date: 2020-05-20 10:48-0700\n"
|
||||
"PO-Revision-Date: 2018-07-27 11:55-0700\n"
|
||||
"Last-Translator: \n"
|
||||
"Language-Team: \n"
|
||||
@ -1477,6 +1477,11 @@ msgstr ""
|
||||
msgid "Tile width must exactly divide bitmap width"
|
||||
msgstr ""
|
||||
|
||||
#: ports/nrf/common-hal/_bleio/Adapter.c
|
||||
#, c-format
|
||||
msgid "Timeout is too long: Maximum timeout length is %d seconds"
|
||||
msgstr ""
|
||||
|
||||
#: ports/atmel-samd/common-hal/audiobusio/I2SOut.c
|
||||
msgid "Too many channels in sample."
|
||||
msgstr ""
|
||||
|
@ -7,7 +7,7 @@ msgid ""
|
||||
msgstr ""
|
||||
"Project-Id-Version: \n"
|
||||
"Report-Msgid-Bugs-To: \n"
|
||||
"POT-Creation-Date: 2020-05-20 08:55-0700\n"
|
||||
"POT-Creation-Date: 2020-05-20 10:48-0700\n"
|
||||
"PO-Revision-Date: 2020-03-30 22:11+0000\n"
|
||||
"Last-Translator: Tannewt <devnull@unpythonic.net>\n"
|
||||
"Language-Team: English <https://later.unpythonic.net/projects/circuitpython/"
|
||||
@ -1486,6 +1486,11 @@ msgstr ""
|
||||
msgid "Tile width must exactly divide bitmap width"
|
||||
msgstr ""
|
||||
|
||||
#: ports/nrf/common-hal/_bleio/Adapter.c
|
||||
#, c-format
|
||||
msgid "Timeout is too long: Maximum timeout length is %d seconds"
|
||||
msgstr ""
|
||||
|
||||
#: ports/atmel-samd/common-hal/audiobusio/I2SOut.c
|
||||
msgid "Too many channels in sample."
|
||||
msgstr ""
|
||||
|
@ -7,7 +7,7 @@ msgid ""
|
||||
msgstr ""
|
||||
"Project-Id-Version: \n"
|
||||
"Report-Msgid-Bugs-To: \n"
|
||||
"POT-Creation-Date: 2020-05-20 08:55-0700\n"
|
||||
"POT-Creation-Date: 2020-05-20 10:48-0700\n"
|
||||
"PO-Revision-Date: 2020-05-17 20:56+0000\n"
|
||||
"Last-Translator: Jeff Epler <jepler@gmail.com>\n"
|
||||
"Language-Team: \n"
|
||||
@ -1495,6 +1495,11 @@ msgstr ""
|
||||
msgid "Tile width must exactly divide bitmap width"
|
||||
msgstr "Ancho del Tile debe dividir exactamente el ancho de mapa de bits"
|
||||
|
||||
#: ports/nrf/common-hal/_bleio/Adapter.c
|
||||
#, c-format
|
||||
msgid "Timeout is too long: Maximum timeout length is %d seconds"
|
||||
msgstr ""
|
||||
|
||||
#: ports/atmel-samd/common-hal/audiobusio/I2SOut.c
|
||||
msgid "Too many channels in sample."
|
||||
msgstr "Demasiados canales en sample."
|
||||
|
@ -7,7 +7,7 @@ msgid ""
|
||||
msgstr ""
|
||||
"Project-Id-Version: \n"
|
||||
"Report-Msgid-Bugs-To: \n"
|
||||
"POT-Creation-Date: 2020-05-20 08:55-0700\n"
|
||||
"POT-Creation-Date: 2020-05-20 10:48-0700\n"
|
||||
"PO-Revision-Date: 2018-12-20 22:15-0800\n"
|
||||
"Last-Translator: Timothy <me@timothygarcia.ca>\n"
|
||||
"Language-Team: fil\n"
|
||||
@ -1500,6 +1500,11 @@ msgstr ""
|
||||
msgid "Tile width must exactly divide bitmap width"
|
||||
msgstr ""
|
||||
|
||||
#: ports/nrf/common-hal/_bleio/Adapter.c
|
||||
#, c-format
|
||||
msgid "Timeout is too long: Maximum timeout length is %d seconds"
|
||||
msgstr ""
|
||||
|
||||
#: ports/atmel-samd/common-hal/audiobusio/I2SOut.c
|
||||
msgid "Too many channels in sample."
|
||||
msgstr "Sobra ang channels sa sample."
|
||||
|
@ -8,7 +8,7 @@ msgid ""
|
||||
msgstr ""
|
||||
"Project-Id-Version: 0.1\n"
|
||||
"Report-Msgid-Bugs-To: \n"
|
||||
"POT-Creation-Date: 2020-05-20 08:55-0700\n"
|
||||
"POT-Creation-Date: 2020-05-20 10:48-0700\n"
|
||||
"PO-Revision-Date: 2020-05-17 20:56+0000\n"
|
||||
"Last-Translator: Anonymous <noreply@weblate.org>\n"
|
||||
"Language-Team: French <https://later.unpythonic.net/projects/circuitpython/"
|
||||
@ -1530,6 +1530,11 @@ msgstr "Valeur de tuile hors limites"
|
||||
msgid "Tile width must exactly divide bitmap width"
|
||||
msgstr "La largeur de la tuile doit diviser exactement la largeur de l'image"
|
||||
|
||||
#: ports/nrf/common-hal/_bleio/Adapter.c
|
||||
#, c-format
|
||||
msgid "Timeout is too long: Maximum timeout length is %d seconds"
|
||||
msgstr ""
|
||||
|
||||
#: ports/atmel-samd/common-hal/audiobusio/I2SOut.c
|
||||
msgid "Too many channels in sample."
|
||||
msgstr "Trop de canaux dans l'échantillon."
|
||||
|
@ -8,7 +8,7 @@ msgid ""
|
||||
msgstr ""
|
||||
"Project-Id-Version: PACKAGE VERSION\n"
|
||||
"Report-Msgid-Bugs-To: \n"
|
||||
"POT-Creation-Date: 2020-05-20 08:55-0700\n"
|
||||
"POT-Creation-Date: 2020-05-20 10:48-0700\n"
|
||||
"PO-Revision-Date: 2018-10-02 16:27+0200\n"
|
||||
"Last-Translator: Enrico Paganin <enrico.paganin@mail.com>\n"
|
||||
"Language-Team: \n"
|
||||
@ -1511,6 +1511,11 @@ msgstr ""
|
||||
msgid "Tile width must exactly divide bitmap width"
|
||||
msgstr ""
|
||||
|
||||
#: ports/nrf/common-hal/_bleio/Adapter.c
|
||||
#, c-format
|
||||
msgid "Timeout is too long: Maximum timeout length is %d seconds"
|
||||
msgstr ""
|
||||
|
||||
#: ports/atmel-samd/common-hal/audiobusio/I2SOut.c
|
||||
msgid "Too many channels in sample."
|
||||
msgstr ""
|
||||
|
@ -8,7 +8,7 @@ msgid ""
|
||||
msgstr ""
|
||||
"Project-Id-Version: PACKAGE VERSION\n"
|
||||
"Report-Msgid-Bugs-To: \n"
|
||||
"POT-Creation-Date: 2020-05-20 08:55-0700\n"
|
||||
"POT-Creation-Date: 2020-05-20 10:48-0700\n"
|
||||
"PO-Revision-Date: 2019-05-06 14:22-0700\n"
|
||||
"Last-Translator: \n"
|
||||
"Language-Team: LANGUAGE <LL@li.org>\n"
|
||||
@ -1481,6 +1481,11 @@ msgstr ""
|
||||
msgid "Tile width must exactly divide bitmap width"
|
||||
msgstr ""
|
||||
|
||||
#: ports/nrf/common-hal/_bleio/Adapter.c
|
||||
#, c-format
|
||||
msgid "Timeout is too long: Maximum timeout length is %d seconds"
|
||||
msgstr ""
|
||||
|
||||
#: ports/atmel-samd/common-hal/audiobusio/I2SOut.c
|
||||
msgid "Too many channels in sample."
|
||||
msgstr ""
|
||||
|
3272
locale/nl.po
Normal file
3272
locale/nl.po
Normal file
File diff suppressed because it is too large
Load Diff
@ -7,7 +7,7 @@ msgid ""
|
||||
msgstr ""
|
||||
"Project-Id-Version: \n"
|
||||
"Report-Msgid-Bugs-To: \n"
|
||||
"POT-Creation-Date: 2020-05-20 08:55-0700\n"
|
||||
"POT-Creation-Date: 2020-05-20 10:48-0700\n"
|
||||
"PO-Revision-Date: 2019-03-19 18:37-0700\n"
|
||||
"Last-Translator: Radomir Dopieralski <circuitpython@sheep.art.pl>\n"
|
||||
"Language-Team: pl\n"
|
||||
@ -1482,6 +1482,11 @@ msgstr ""
|
||||
msgid "Tile width must exactly divide bitmap width"
|
||||
msgstr "Szerokość bitmapy musi być wielokrotnością szerokości kafelka"
|
||||
|
||||
#: ports/nrf/common-hal/_bleio/Adapter.c
|
||||
#, c-format
|
||||
msgid "Timeout is too long: Maximum timeout length is %d seconds"
|
||||
msgstr ""
|
||||
|
||||
#: ports/atmel-samd/common-hal/audiobusio/I2SOut.c
|
||||
msgid "Too many channels in sample."
|
||||
msgstr "Zbyt wiele kanałów."
|
||||
|
@ -8,7 +8,7 @@ msgid ""
|
||||
msgstr ""
|
||||
"Project-Id-Version: PACKAGE VERSION\n"
|
||||
"Report-Msgid-Bugs-To: \n"
|
||||
"POT-Creation-Date: 2020-05-20 08:55-0700\n"
|
||||
"POT-Creation-Date: 2020-05-20 10:48-0700\n"
|
||||
"PO-Revision-Date: 2018-10-02 21:14-0000\n"
|
||||
"Last-Translator: \n"
|
||||
"Language-Team: \n"
|
||||
@ -1494,6 +1494,11 @@ msgstr ""
|
||||
msgid "Tile width must exactly divide bitmap width"
|
||||
msgstr ""
|
||||
|
||||
#: ports/nrf/common-hal/_bleio/Adapter.c
|
||||
#, c-format
|
||||
msgid "Timeout is too long: Maximum timeout length is %d seconds"
|
||||
msgstr ""
|
||||
|
||||
#: ports/atmel-samd/common-hal/audiobusio/I2SOut.c
|
||||
msgid "Too many channels in sample."
|
||||
msgstr "Muitos canais na amostra."
|
||||
|
@ -7,7 +7,7 @@ msgid ""
|
||||
msgstr ""
|
||||
"Project-Id-Version: PACKAGE VERSION\n"
|
||||
"Report-Msgid-Bugs-To: \n"
|
||||
"POT-Creation-Date: 2020-05-20 08:55-0700\n"
|
||||
"POT-Creation-Date: 2020-05-20 10:48-0700\n"
|
||||
"PO-Revision-Date: 2020-05-17 20:56+0000\n"
|
||||
"Last-Translator: Anonymous <noreply@weblate.org>\n"
|
||||
"Language-Team: LANGUAGE <LL@li.org>\n"
|
||||
@ -1516,6 +1516,11 @@ msgstr "Tile-värde utanför intervall"
|
||||
msgid "Tile width must exactly divide bitmap width"
|
||||
msgstr "Tile-bredd måste vara jämnt delbar med bredd på bitmap"
|
||||
|
||||
#: ports/nrf/common-hal/_bleio/Adapter.c
|
||||
#, c-format
|
||||
msgid "Timeout is too long: Maximum timeout length is %d seconds"
|
||||
msgstr ""
|
||||
|
||||
#: ports/atmel-samd/common-hal/audiobusio/I2SOut.c
|
||||
msgid "Too many channels in sample."
|
||||
msgstr "För många kanaler i sampling."
|
||||
|
@ -7,7 +7,7 @@ msgid ""
|
||||
msgstr ""
|
||||
"Project-Id-Version: circuitpython-cn\n"
|
||||
"Report-Msgid-Bugs-To: \n"
|
||||
"POT-Creation-Date: 2020-05-20 08:55-0700\n"
|
||||
"POT-Creation-Date: 2020-05-20 10:48-0700\n"
|
||||
"PO-Revision-Date: 2019-04-13 10:10-0700\n"
|
||||
"Last-Translator: hexthat\n"
|
||||
"Language-Team: Chinese Hanyu Pinyin\n"
|
||||
@ -1503,6 +1503,11 @@ msgstr "Píng pū zhí chāochū fànwéi"
|
||||
msgid "Tile width must exactly divide bitmap width"
|
||||
msgstr "Píng pū kuāndù bìxū huàfēn wèi tú kuāndù"
|
||||
|
||||
#: ports/nrf/common-hal/_bleio/Adapter.c
|
||||
#, c-format
|
||||
msgid "Timeout is too long: Maximum timeout length is %d seconds"
|
||||
msgstr ""
|
||||
|
||||
#: ports/atmel-samd/common-hal/audiobusio/I2SOut.c
|
||||
msgid "Too many channels in sample."
|
||||
msgstr "Chōuyàng zhōng de píndào tài duō."
|
||||
|
3
main.c
3
main.c
@ -436,6 +436,9 @@ int __attribute__((used)) main(void) {
|
||||
// displays init after filesystem, since they could share the flash SPI
|
||||
board_init();
|
||||
|
||||
// Start the debug serial
|
||||
serial_early_init();
|
||||
|
||||
// Reset everything and prep MicroPython to run boot.py.
|
||||
reset_port();
|
||||
reset_board();
|
||||
|
@ -59,7 +59,8 @@ void common_hal_busio_uart_construct(busio_uart_obj_t *self,
|
||||
const mcu_pin_obj_t * rts, const mcu_pin_obj_t * cts,
|
||||
const mcu_pin_obj_t * rs485_dir, bool rs485_invert,
|
||||
uint32_t baudrate, uint8_t bits, uart_parity_t parity, uint8_t stop,
|
||||
mp_float_t timeout, uint16_t receiver_buffer_size) {
|
||||
mp_float_t timeout, uint16_t receiver_buffer_size, byte* receiver_buffer,
|
||||
bool sigint_enabled) {
|
||||
|
||||
Sercom* sercom = NULL;
|
||||
uint8_t sercom_index = 255; // Unset index
|
||||
|
@ -57,7 +57,8 @@ void common_hal_busio_uart_construct(busio_uart_obj_t *self,
|
||||
const mcu_pin_obj_t * rts, const mcu_pin_obj_t * cts,
|
||||
const mcu_pin_obj_t * rs485_dir, bool rs485_invert,
|
||||
uint32_t baudrate, uint8_t bits, uart_parity_t parity, uint8_t stop,
|
||||
mp_float_t timeout, uint16_t receiver_buffer_size) {
|
||||
mp_float_t timeout, uint16_t receiver_buffer_size, byte* receiver_buffer,
|
||||
bool sigint_enabled) {
|
||||
struct termios tio;
|
||||
|
||||
if ((rts != NULL) || (cts != NULL) || (rs485_dir != NULL) || (rs485_invert)) {
|
||||
|
@ -76,7 +76,8 @@ void common_hal_busio_uart_construct(busio_uart_obj_t *self,
|
||||
const mcu_pin_obj_t * rts, const mcu_pin_obj_t * cts,
|
||||
const mcu_pin_obj_t * rs485_dir, bool rs485_invert,
|
||||
uint32_t baudrate, uint8_t bits, uart_parity_t parity, uint8_t stop,
|
||||
mp_float_t timeout, uint16_t receiver_buffer_size) {
|
||||
mp_float_t timeout, uint16_t receiver_buffer_size, byte* receiver_buffer,
|
||||
bool sigint_enabled) {
|
||||
|
||||
// TODO: Allow none rx or tx
|
||||
|
||||
|
@ -41,6 +41,7 @@
|
||||
|
||||
#define MSEC_TO_UNITS(TIME, RESOLUTION) (((TIME) * 1000) / (RESOLUTION))
|
||||
#define SEC_TO_UNITS(TIME, RESOLUTION) (((TIME) * 1000000) / (RESOLUTION))
|
||||
#define UNITS_TO_SEC(TIME, RESOLUTION) (((TIME) * (RESOLUTION)) / 1000000)
|
||||
// 0.625 msecs (625 usecs)
|
||||
#define ADV_INTERVAL_UNIT_FLOAT_SECS (0.000625)
|
||||
// Microseconds is the base unit. The macros above know that.
|
||||
|
@ -26,6 +26,7 @@
|
||||
* THE SOFTWARE.
|
||||
*/
|
||||
|
||||
#include <math.h>
|
||||
#include <stdint.h>
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
@ -594,7 +595,25 @@ STATIC void check_data_fit(size_t data_len, bool connectable) {
|
||||
}
|
||||
}
|
||||
|
||||
uint32_t _common_hal_bleio_adapter_start_advertising(bleio_adapter_obj_t *self, bool connectable, float interval, uint8_t *advertising_data, uint16_t advertising_data_len, uint8_t *scan_response_data, uint16_t scan_response_data_len) {
|
||||
STATIC bool advertising_on_ble_evt(ble_evt_t *ble_evt, void *self_in) {
|
||||
bleio_adapter_obj_t *self = (bleio_adapter_obj_t*)self_in;
|
||||
|
||||
switch (ble_evt->header.evt_id) {
|
||||
case BLE_GAP_EVT_ADV_SET_TERMINATED:
|
||||
common_hal_bleio_adapter_stop_advertising(self);
|
||||
ble_drv_remove_event_handler(advertising_on_ble_evt, self_in);
|
||||
break;
|
||||
|
||||
default:
|
||||
// For debugging.
|
||||
// mp_printf(&mp_plat_print, "Unhandled advertising event: 0x%04x\n", ble_evt->header.evt_id);
|
||||
return false;
|
||||
break;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
uint32_t _common_hal_bleio_adapter_start_advertising(bleio_adapter_obj_t *self, bool connectable, bool anonymous, uint32_t timeout, float interval, uint8_t *advertising_data, uint16_t advertising_data_len, uint8_t *scan_response_data, uint16_t scan_response_data_len) {
|
||||
if (self->current_advertising_data != NULL && self->current_advertising_data == self->advertising_data) {
|
||||
return NRF_ERROR_BUSY;
|
||||
}
|
||||
@ -605,7 +624,7 @@ uint32_t _common_hal_bleio_adapter_start_advertising(bleio_adapter_obj_t *self,
|
||||
common_hal_bleio_adapter_stop_advertising(self);
|
||||
}
|
||||
|
||||
|
||||
uint32_t err_code;
|
||||
bool extended = advertising_data_len > BLE_GAP_ADV_SET_DATA_SIZE_MAX ||
|
||||
scan_response_data_len > BLE_GAP_ADV_SET_DATA_SIZE_MAX;
|
||||
|
||||
@ -626,11 +645,35 @@ uint32_t _common_hal_bleio_adapter_start_advertising(bleio_adapter_obj_t *self,
|
||||
adv_type = BLE_GAP_ADV_TYPE_NONCONNECTABLE_NONSCANNABLE_UNDIRECTED;
|
||||
}
|
||||
|
||||
uint32_t err_code;
|
||||
if (anonymous) {
|
||||
ble_gap_privacy_params_t privacy = {
|
||||
.privacy_mode = BLE_GAP_PRIVACY_MODE_DEVICE_PRIVACY,
|
||||
.private_addr_type = BLE_GAP_ADDR_TYPE_RANDOM_PRIVATE_RESOLVABLE,
|
||||
// Rotate the keys one second after we're scheduled to stop
|
||||
// advertising. This prevents a potential race condition where we
|
||||
// fire off a beacon with the same advertising data but a new MAC
|
||||
// address just as we tear down the connection.
|
||||
.private_addr_cycle_s = timeout + 1,
|
||||
.p_device_irk = NULL,
|
||||
};
|
||||
err_code = sd_ble_gap_privacy_set(&privacy);
|
||||
} else {
|
||||
ble_gap_privacy_params_t privacy = {
|
||||
.privacy_mode = BLE_GAP_PRIVACY_MODE_OFF,
|
||||
.private_addr_type = BLE_GAP_ADDR_TYPE_PUBLIC,
|
||||
.private_addr_cycle_s = 0,
|
||||
.p_device_irk = NULL,
|
||||
};
|
||||
err_code = sd_ble_gap_privacy_set(&privacy);
|
||||
}
|
||||
if (err_code != NRF_SUCCESS) {
|
||||
return err_code;
|
||||
}
|
||||
|
||||
ble_gap_adv_params_t adv_params = {
|
||||
.interval = SEC_TO_UNITS(interval, UNIT_0_625_MS),
|
||||
.properties.type = adv_type,
|
||||
.duration = BLE_GAP_ADV_TIMEOUT_GENERAL_UNLIMITED,
|
||||
.duration = SEC_TO_UNITS(timeout, UNIT_10_MS),
|
||||
.filter_policy = BLE_GAP_ADV_FP_ANY,
|
||||
.primary_phy = BLE_GAP_PHY_1MBPS,
|
||||
};
|
||||
@ -647,6 +690,8 @@ uint32_t _common_hal_bleio_adapter_start_advertising(bleio_adapter_obj_t *self,
|
||||
return err_code;
|
||||
}
|
||||
|
||||
ble_drv_add_event_handler(advertising_on_ble_evt, self);
|
||||
|
||||
vm_used_ble = true;
|
||||
err_code = sd_ble_gap_adv_start(adv_handle, BLE_CONN_CFG_TAG_CUSTOM);
|
||||
if (err_code != NRF_SUCCESS) {
|
||||
@ -657,7 +702,7 @@ uint32_t _common_hal_bleio_adapter_start_advertising(bleio_adapter_obj_t *self,
|
||||
}
|
||||
|
||||
|
||||
void common_hal_bleio_adapter_start_advertising(bleio_adapter_obj_t *self, bool connectable, mp_float_t interval, mp_buffer_info_t *advertising_data_bufinfo, mp_buffer_info_t *scan_response_data_bufinfo) {
|
||||
void common_hal_bleio_adapter_start_advertising(bleio_adapter_obj_t *self, bool connectable, bool anonymous, uint32_t timeout, mp_float_t interval, mp_buffer_info_t *advertising_data_bufinfo, mp_buffer_info_t *scan_response_data_bufinfo) {
|
||||
if (self->current_advertising_data != NULL && self->current_advertising_data == self->advertising_data) {
|
||||
mp_raise_bleio_BluetoothError(translate("Already advertising."));
|
||||
}
|
||||
@ -669,6 +714,27 @@ void common_hal_bleio_adapter_start_advertising(bleio_adapter_obj_t *self, bool
|
||||
if (advertising_data_bufinfo->len > 31 && scan_response_data_bufinfo->len > 0) {
|
||||
mp_raise_bleio_BluetoothError(translate("Extended advertisements with scan response not supported."));
|
||||
}
|
||||
|
||||
// Anonymous mode requires a timeout so that we don't continue to broadcast
|
||||
// the same data while cycling the MAC address -- otherwise, what's the
|
||||
// point of randomizing the MAC address?
|
||||
if (!timeout) {
|
||||
if (anonymous) {
|
||||
// The Nordic macro is in units of 10ms. Convert to seconds.
|
||||
uint32_t adv_timeout_max_secs = UNITS_TO_SEC(BLE_GAP_ADV_TIMEOUT_LIMITED_MAX, UNIT_10_MS);
|
||||
uint32_t rotate_timeout_max_secs = BLE_GAP_DEFAULT_PRIVATE_ADDR_CYCLE_INTERVAL_S;
|
||||
timeout = MIN(adv_timeout_max_secs, rotate_timeout_max_secs);
|
||||
}
|
||||
else {
|
||||
timeout = BLE_GAP_ADV_TIMEOUT_GENERAL_UNLIMITED;
|
||||
}
|
||||
} else {
|
||||
if (SEC_TO_UNITS(timeout, UNIT_10_MS) > BLE_GAP_ADV_TIMEOUT_LIMITED_MAX) {
|
||||
mp_raise_bleio_BluetoothError(translate("Timeout is too long: Maximum timeout length is %d seconds"),
|
||||
UNITS_TO_SEC(BLE_GAP_ADV_TIMEOUT_LIMITED_MAX, UNIT_10_MS));
|
||||
}
|
||||
}
|
||||
|
||||
// The advertising data buffers must not move, because the SoftDevice depends on them.
|
||||
// So make them long-lived and reuse them onwards.
|
||||
if (self->advertising_data == NULL) {
|
||||
@ -681,7 +747,7 @@ void common_hal_bleio_adapter_start_advertising(bleio_adapter_obj_t *self, bool
|
||||
memcpy(self->advertising_data, advertising_data_bufinfo->buf, advertising_data_bufinfo->len);
|
||||
memcpy(self->scan_response_data, scan_response_data_bufinfo->buf, scan_response_data_bufinfo->len);
|
||||
|
||||
check_nrf_error(_common_hal_bleio_adapter_start_advertising(self, connectable, interval,
|
||||
check_nrf_error(_common_hal_bleio_adapter_start_advertising(self, connectable, anonymous, timeout, interval,
|
||||
self->advertising_data,
|
||||
advertising_data_bufinfo->len,
|
||||
self->scan_response_data,
|
||||
@ -701,6 +767,10 @@ void common_hal_bleio_adapter_stop_advertising(bleio_adapter_obj_t *self) {
|
||||
}
|
||||
}
|
||||
|
||||
bool common_hal_bleio_adapter_get_advertising(bleio_adapter_obj_t *self) {
|
||||
return self->current_advertising_data != NULL;
|
||||
}
|
||||
|
||||
bool common_hal_bleio_adapter_get_connected(bleio_adapter_obj_t *self) {
|
||||
for (size_t i = 0; i < BLEIO_TOTAL_CONNECTION_COUNT; i++) {
|
||||
bleio_connection_internal_t *connection = &bleio_connections[i];
|
||||
|
@ -134,7 +134,8 @@ void common_hal_busio_uart_construct(busio_uart_obj_t *self,
|
||||
const mcu_pin_obj_t * rts, const mcu_pin_obj_t * cts,
|
||||
const mcu_pin_obj_t * rs485_dir, bool rs485_invert,
|
||||
uint32_t baudrate, uint8_t bits, uart_parity_t parity, uint8_t stop,
|
||||
mp_float_t timeout, uint16_t receiver_buffer_size) {
|
||||
mp_float_t timeout, uint16_t receiver_buffer_size, byte* receiver_buffer,
|
||||
bool sigint_enabled) {
|
||||
|
||||
if ((rts != NULL) || (cts != NULL) || (rs485_dir != NULL) || (rs485_invert)) {
|
||||
mp_raise_ValueError(translate("RTS/CTS/RS485 Not yet supported on this device"));
|
||||
|
@ -34,3 +34,6 @@
|
||||
#define FLASH_PAGE_SIZE (0x4000)
|
||||
|
||||
#define BOARD_OSC_DIV (8)
|
||||
|
||||
#define DEBUG_UART_TX (&pin_PD08)
|
||||
#define DEBUG_UART_RX (&pin_PD09)
|
||||
|
@ -58,8 +58,9 @@ STATIC const mp_rom_map_elem_t board_module_globals_table[] = {
|
||||
{ MP_ROM_QSTR(MP_QSTR_USB_ID), MP_ROM_PTR(&pin_PA10) },
|
||||
{ MP_ROM_QSTR(MP_QSTR_USB_DM), MP_ROM_PTR(&pin_PA11) },
|
||||
{ MP_ROM_QSTR(MP_QSTR_USB_DP), MP_ROM_PTR(&pin_PA12) },
|
||||
{ MP_ROM_QSTR(MP_QSTR_VCP_TX), MP_ROM_PTR(&pin_PD08) },
|
||||
{ MP_ROM_QSTR(MP_QSTR_VCP_RX), MP_ROM_PTR(&pin_PD09) },
|
||||
// As we use these for the debug_console, we won't enable them here.
|
||||
// { MP_ROM_QSTR(MP_QSTR_VCP_TX), MP_ROM_PTR(&pin_PD08) },
|
||||
// { MP_ROM_QSTR(MP_QSTR_VCP_RX), MP_ROM_PTR(&pin_PD09) },
|
||||
{ MP_ROM_QSTR(MP_QSTR_UART2_TX), MP_ROM_PTR(&pin_PD05) },
|
||||
{ MP_ROM_QSTR(MP_QSTR_UART2_RX), MP_ROM_PTR(&pin_PD06) },
|
||||
{ MP_ROM_QSTR(MP_QSTR_UART2_RTS), MP_ROM_PTR(&pin_PD04) },
|
||||
|
@ -28,6 +28,7 @@
|
||||
#include "shared-bindings/busio/UART.h"
|
||||
|
||||
#include "mpconfigport.h"
|
||||
#include "lib/mp-readline/readline.h"
|
||||
#include "lib/utils/interrupt_char.h"
|
||||
#include "py/gc.h"
|
||||
#include "py/mperrno.h"
|
||||
@ -39,6 +40,7 @@
|
||||
|
||||
//arrays use 0 based numbering: UART1 is stored at index 0
|
||||
STATIC bool reserved_uart[MAX_UART];
|
||||
STATIC bool never_reset_uart[MAX_UART];
|
||||
int errflag; //Used to restart read halts
|
||||
|
||||
STATIC void uart_clock_enable(uint16_t mask);
|
||||
@ -61,11 +63,16 @@ STATIC USART_TypeDef * assign_uart_or_throw(busio_uart_obj_t* self, bool pin_eva
|
||||
}
|
||||
|
||||
void uart_reset(void) {
|
||||
uint16_t never_reset_mask = 0x00;
|
||||
for (uint8_t i = 0; i < MAX_UART; i++) {
|
||||
reserved_uart[i] = false;
|
||||
MP_STATE_PORT(cpy_uart_obj_all)[i] = NULL;
|
||||
if (!never_reset_uart[i]) {
|
||||
reserved_uart[i] = false;
|
||||
MP_STATE_PORT(cpy_uart_obj_all)[i] = NULL;
|
||||
} else {
|
||||
never_reset_mask |= 1 << i;
|
||||
}
|
||||
}
|
||||
uart_clock_disable(ALL_UARTS);
|
||||
uart_clock_disable(ALL_UARTS & ~(never_reset_mask));
|
||||
}
|
||||
|
||||
void common_hal_busio_uart_construct(busio_uart_obj_t *self,
|
||||
@ -73,7 +80,8 @@ void common_hal_busio_uart_construct(busio_uart_obj_t *self,
|
||||
const mcu_pin_obj_t * rts, const mcu_pin_obj_t * cts,
|
||||
const mcu_pin_obj_t * rs485_dir, bool rs485_invert,
|
||||
uint32_t baudrate, uint8_t bits, uart_parity_t parity, uint8_t stop,
|
||||
mp_float_t timeout, uint16_t receiver_buffer_size) {
|
||||
mp_float_t timeout, uint16_t receiver_buffer_size, byte* receiver_buffer,
|
||||
bool sigint_enabled) {
|
||||
|
||||
//match pins to UART objects
|
||||
USART_TypeDef * USARTx;
|
||||
@ -209,8 +217,12 @@ void common_hal_busio_uart_construct(busio_uart_obj_t *self,
|
||||
|
||||
// Init buffer for rx and claim pins
|
||||
if (self->rx != NULL) {
|
||||
if (!ringbuf_alloc(&self->ringbuf, receiver_buffer_size, true)) {
|
||||
mp_raise_ValueError(translate("UART Buffer allocation error"));
|
||||
if (receiver_buffer != NULL) {
|
||||
self->ringbuf = (ringbuf_t){ receiver_buffer, receiver_buffer_size };
|
||||
} else {
|
||||
if (!ringbuf_alloc(&self->ringbuf, receiver_buffer_size, true)) {
|
||||
mp_raise_ValueError(translate("UART Buffer allocation error"));
|
||||
}
|
||||
}
|
||||
claim_pin(rx);
|
||||
}
|
||||
@ -219,6 +231,7 @@ void common_hal_busio_uart_construct(busio_uart_obj_t *self,
|
||||
}
|
||||
self->baudrate = baudrate;
|
||||
self->timeout_ms = timeout * 1000;
|
||||
self->sigint_enabled = sigint_enabled;
|
||||
|
||||
//start the interrupt series
|
||||
if ((HAL_UART_GetState(&self->handle) & HAL_UART_STATE_BUSY_RX) == HAL_UART_STATE_BUSY_RX) {
|
||||
@ -234,6 +247,17 @@ void common_hal_busio_uart_construct(busio_uart_obj_t *self,
|
||||
errflag = HAL_OK;
|
||||
}
|
||||
|
||||
void common_hal_busio_uart_never_reset(busio_uart_obj_t *self) {
|
||||
for (size_t i = 0; i < MP_ARRAY_SIZE(mcu_uart_banks); i++) {
|
||||
if (mcu_uart_banks[i] == self->handle.Instance) {
|
||||
never_reset_uart[i] = true;
|
||||
never_reset_pin_number(self->tx->pin->port, self->tx->pin->number);
|
||||
never_reset_pin_number(self->rx->pin->port, self->rx->pin->number);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
bool common_hal_busio_uart_deinited(busio_uart_obj_t *self) {
|
||||
return self->tx->pin == NULL;
|
||||
}
|
||||
@ -241,6 +265,13 @@ bool common_hal_busio_uart_deinited(busio_uart_obj_t *self) {
|
||||
void common_hal_busio_uart_deinit(busio_uart_obj_t *self) {
|
||||
if (common_hal_busio_uart_deinited(self)) return;
|
||||
|
||||
for (size_t i = 0; i < MP_ARRAY_SIZE(mcu_uart_banks); i++) {
|
||||
if (mcu_uart_banks[i] == self->handle.Instance) {
|
||||
never_reset_uart[i] = false;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
reset_pin_number(self->tx->pin->port,self->tx->pin->number);
|
||||
reset_pin_number(self->rx->pin->port,self->rx->pin->number);
|
||||
self->tx = NULL;
|
||||
@ -289,7 +320,8 @@ size_t common_hal_busio_uart_write(busio_uart_obj_t *self, const uint8_t *data,
|
||||
bool write_err = false; //write error shouldn't disable interrupts
|
||||
|
||||
HAL_NVIC_DisableIRQ(self->irq);
|
||||
if (HAL_UART_Transmit(&self->handle, (uint8_t*)data, len, HAL_MAX_DELAY) != HAL_OK) {
|
||||
HAL_StatusTypeDef ret = HAL_UART_Transmit(&self->handle, (uint8_t*)data, len, HAL_MAX_DELAY);
|
||||
if (ret != HAL_OK) {
|
||||
write_err = true;
|
||||
}
|
||||
HAL_UART_Receive_IT(&self->handle, &self->rx_char, 1);
|
||||
@ -313,6 +345,12 @@ void HAL_UART_RxCpltCallback(UART_HandleTypeDef *handle)
|
||||
}
|
||||
ringbuf_put_n(&context->ringbuf, &context->rx_char, 1);
|
||||
errflag = HAL_UART_Receive_IT(handle, &context->rx_char, 1);
|
||||
if (context->sigint_enabled) {
|
||||
if (context->rx_char == CHAR_CTRL_C) {
|
||||
common_hal_busio_uart_clear_rx_buffer(context);
|
||||
mp_keyboard_interrupt();
|
||||
}
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
|
@ -52,6 +52,8 @@ typedef struct {
|
||||
|
||||
uint32_t baudrate;
|
||||
uint32_t timeout_ms;
|
||||
|
||||
bool sigint_enabled;
|
||||
} busio_uart_obj_t;
|
||||
|
||||
void uart_reset(void);
|
||||
|
@ -1 +0,0 @@
|
||||
rst2pyi>=0.3.0
|
@ -135,27 +135,34 @@ const mp_obj_property_t bleio_adapter_name_obj = {
|
||||
(mp_obj_t)&mp_const_none_obj },
|
||||
};
|
||||
|
||||
//| def start_advertising(self, data: buf, *, scan_response: buf = None, connectable: bool = True, interval: float = 0.1) -> Any:
|
||||
//| def start_advertising(self, data: buf, *, scan_response: buf = None, connectable: bool = True, anonymous: bool = False, timeout: int = 0, interval: float = 0.1) -> Any:
|
||||
//| """Starts advertising until `stop_advertising` is called or if connectable, another device
|
||||
//| connects to us.
|
||||
//|
|
||||
//| .. warning: If data is longer than 31 bytes, then this will automatically advertise as an
|
||||
//| extended advertisement that older BLE 4.x clients won't be able to scan for.
|
||||
//|
|
||||
//| .. note: If you set ``anonymous=True``, then a timeout must be specified. If no timeout is
|
||||
//| specified, then the maximum allowed timeout will be selected automatically.
|
||||
//|
|
||||
//| :param buf data: advertising data packet bytes
|
||||
//| :param buf scan_response: scan response data packet bytes. ``None`` if no scan response is needed.
|
||||
//| :param bool connectable: If `True` then other devices are allowed to connect to this peripheral.
|
||||
//| :param bool anonymous: If `True` then this device's MAC address is randomized before advertising.
|
||||
//| :param int timeout: If set, we will only advertise for this many seconds.
|
||||
//| :param float interval: advertising interval, in seconds"""
|
||||
//| ...
|
||||
//|
|
||||
STATIC mp_obj_t bleio_adapter_start_advertising(mp_uint_t n_args, const mp_obj_t *pos_args, mp_map_t *kw_args) {
|
||||
bleio_adapter_obj_t *self = MP_OBJ_TO_PTR(pos_args[0]);
|
||||
|
||||
enum { ARG_data, ARG_scan_response, ARG_connectable, ARG_interval };
|
||||
enum { ARG_data, ARG_scan_response, ARG_connectable, ARG_anonymous, ARG_timeout, ARG_interval };
|
||||
static const mp_arg_t allowed_args[] = {
|
||||
{ MP_QSTR_data, MP_ARG_REQUIRED | MP_ARG_OBJ },
|
||||
{ MP_QSTR_scan_response, MP_ARG_KW_ONLY | MP_ARG_OBJ, {.u_obj = mp_const_none} },
|
||||
{ MP_QSTR_connectable, MP_ARG_KW_ONLY | MP_ARG_BOOL, {.u_bool = true} },
|
||||
{ MP_QSTR_anonymous, MP_ARG_KW_ONLY | MP_ARG_BOOL, {.u_bool = false} },
|
||||
{ MP_QSTR_timeout, MP_ARG_KW_ONLY | MP_ARG_INT, {.u_int = 0} },
|
||||
{ MP_QSTR_interval, MP_ARG_KW_ONLY | MP_ARG_OBJ, {.u_obj = MP_OBJ_NULL} },
|
||||
};
|
||||
|
||||
@ -182,11 +189,13 @@ STATIC mp_obj_t bleio_adapter_start_advertising(mp_uint_t n_args, const mp_obj_t
|
||||
}
|
||||
|
||||
bool connectable = args[ARG_connectable].u_bool;
|
||||
bool anonymous = args[ARG_anonymous].u_bool;
|
||||
uint32_t timeout = args[ARG_timeout].u_int;
|
||||
if (data_bufinfo.len > 31 && connectable && scan_response_bufinfo.len > 0) {
|
||||
mp_raise_bleio_BluetoothError(translate("Cannot have scan responses for extended, connectable advertisements."));
|
||||
}
|
||||
|
||||
common_hal_bleio_adapter_start_advertising(self, connectable, interval,
|
||||
common_hal_bleio_adapter_start_advertising(self, connectable, anonymous, timeout, interval,
|
||||
&data_bufinfo, &scan_response_bufinfo);
|
||||
|
||||
return mp_const_none;
|
||||
@ -292,6 +301,22 @@ STATIC mp_obj_t bleio_adapter_stop_scan(mp_obj_t self_in) {
|
||||
}
|
||||
STATIC MP_DEFINE_CONST_FUN_OBJ_1(bleio_adapter_stop_scan_obj, bleio_adapter_stop_scan);
|
||||
|
||||
//| advertising: Any = ...
|
||||
//| """True when the adapter is currently advertising. (read-only)"""
|
||||
//|
|
||||
STATIC mp_obj_t bleio_adapter_get_advertising(mp_obj_t self) {
|
||||
return mp_obj_new_bool(common_hal_bleio_adapter_get_advertising(self));
|
||||
|
||||
}
|
||||
MP_DEFINE_CONST_FUN_OBJ_1(bleio_adapter_get_advertising_obj, bleio_adapter_get_advertising);
|
||||
|
||||
const mp_obj_property_t bleio_adapter_advertising_obj = {
|
||||
.base.type = &mp_type_property,
|
||||
.proxy = { (mp_obj_t)&bleio_adapter_get_advertising_obj,
|
||||
(mp_obj_t)&mp_const_none_obj,
|
||||
(mp_obj_t)&mp_const_none_obj },
|
||||
};
|
||||
|
||||
//| connected: Any = ...
|
||||
//| """True when the adapter is connected to another device regardless of who initiated the
|
||||
//| connection. (read-only)"""
|
||||
@ -375,6 +400,7 @@ STATIC const mp_rom_map_elem_t bleio_adapter_locals_dict_table[] = {
|
||||
|
||||
{ MP_ROM_QSTR(MP_QSTR_start_advertising), MP_ROM_PTR(&bleio_adapter_start_advertising_obj) },
|
||||
{ MP_ROM_QSTR(MP_QSTR_stop_advertising), MP_ROM_PTR(&bleio_adapter_stop_advertising_obj) },
|
||||
{ MP_ROM_QSTR(MP_QSTR_advertising), MP_ROM_PTR(&bleio_adapter_advertising_obj) },
|
||||
|
||||
{ MP_ROM_QSTR(MP_QSTR_start_scan), MP_ROM_PTR(&bleio_adapter_start_scan_obj) },
|
||||
{ MP_ROM_QSTR(MP_QSTR_stop_scan), MP_ROM_PTR(&bleio_adapter_stop_scan_obj) },
|
||||
|
@ -37,6 +37,7 @@
|
||||
|
||||
const mp_obj_type_t bleio_adapter_type;
|
||||
|
||||
extern bool common_hal_bleio_adapter_get_advertising(bleio_adapter_obj_t *self);
|
||||
extern bool common_hal_bleio_adapter_get_enabled(bleio_adapter_obj_t *self);
|
||||
extern void common_hal_bleio_adapter_set_enabled(bleio_adapter_obj_t *self, bool enabled);
|
||||
extern bool common_hal_bleio_adapter_get_connected(bleio_adapter_obj_t *self);
|
||||
@ -45,9 +46,9 @@ extern bleio_address_obj_t *common_hal_bleio_adapter_get_address(bleio_adapter_o
|
||||
extern mp_obj_str_t* common_hal_bleio_adapter_get_name(bleio_adapter_obj_t *self);
|
||||
extern void common_hal_bleio_adapter_set_name(bleio_adapter_obj_t *self, const char* name);
|
||||
|
||||
extern uint32_t _common_hal_bleio_adapter_start_advertising(bleio_adapter_obj_t *self, bool connectable, float interval, uint8_t *advertising_data, uint16_t advertising_data_len, uint8_t *scan_response_data, uint16_t scan_response_data_len);
|
||||
extern uint32_t _common_hal_bleio_adapter_start_advertising(bleio_adapter_obj_t *self, bool connectable, bool anonymous, uint32_t timeout, float interval, uint8_t *advertising_data, uint16_t advertising_data_len, uint8_t *scan_response_data, uint16_t scan_response_data_len);
|
||||
|
||||
extern void common_hal_bleio_adapter_start_advertising(bleio_adapter_obj_t *self, bool connectable, mp_float_t interval, mp_buffer_info_t *advertising_data_bufinfo, mp_buffer_info_t *scan_response_data_bufinfo);
|
||||
extern void common_hal_bleio_adapter_start_advertising(bleio_adapter_obj_t *self, bool connectable, bool anonymous, uint32_t timeout, mp_float_t interval, mp_buffer_info_t *advertising_data_bufinfo, mp_buffer_info_t *scan_response_data_bufinfo);
|
||||
extern void common_hal_bleio_adapter_stop_advertising(bleio_adapter_obj_t *self);
|
||||
|
||||
extern mp_obj_t common_hal_bleio_adapter_start_scan(bleio_adapter_obj_t *self, uint8_t* prefixes, size_t prefix_length, bool extended, mp_int_t buffer_size, mp_float_t timeout, mp_float_t interval, mp_float_t window, mp_int_t minimum_rssi, bool active);
|
||||
|
@ -138,7 +138,7 @@ STATIC mp_obj_t busio_uart_make_new(const mp_obj_type_t *type, size_t n_args, co
|
||||
|
||||
common_hal_busio_uart_construct(self, tx, rx, rts, cts, rs485_dir, rs485_invert,
|
||||
args[ARG_baudrate].u_int, bits, parity, stop, timeout,
|
||||
args[ARG_receiver_buffer_size].u_int);
|
||||
args[ARG_receiver_buffer_size].u_int, NULL, false);
|
||||
return (mp_obj_t)self;
|
||||
}
|
||||
|
||||
|
@ -29,6 +29,7 @@
|
||||
|
||||
#include "common-hal/microcontroller/Pin.h"
|
||||
#include "common-hal/busio/UART.h"
|
||||
#include "py/ringbuf.h"
|
||||
|
||||
extern const mp_obj_type_t busio_uart_type;
|
||||
|
||||
@ -44,7 +45,8 @@ extern void common_hal_busio_uart_construct(busio_uart_obj_t *self,
|
||||
const mcu_pin_obj_t * rts, const mcu_pin_obj_t * cts,
|
||||
const mcu_pin_obj_t * rs485_dir, bool rs485_invert,
|
||||
uint32_t baudrate, uint8_t bits, uart_parity_t parity, uint8_t stop,
|
||||
mp_float_t timeout, uint16_t receiver_buffer_size);
|
||||
mp_float_t timeout, uint16_t receiver_buffer_size, byte* receiver_buffer,
|
||||
bool sigint_enabled);
|
||||
|
||||
extern void common_hal_busio_uart_deinit(busio_uart_obj_t *self);
|
||||
extern bool common_hal_busio_uart_deinited(busio_uart_obj_t *self);
|
||||
@ -66,4 +68,6 @@ extern uint32_t common_hal_busio_uart_rx_characters_available(busio_uart_obj_t *
|
||||
extern void common_hal_busio_uart_clear_rx_buffer(busio_uart_obj_t *self);
|
||||
extern bool common_hal_busio_uart_ready_to_tx(busio_uart_obj_t *self);
|
||||
|
||||
extern void common_hal_busio_uart_never_reset(busio_uart_obj_t *self);
|
||||
|
||||
#endif // MICROPY_INCLUDED_SHARED_BINDINGS_BUSIO_UART_H
|
||||
|
@ -123,7 +123,7 @@ mp_obj_t common_hal_board_create_uart(void) {
|
||||
#endif
|
||||
|
||||
common_hal_busio_uart_construct(self, tx, rx, rts, cts, rs485_dir, rs485_invert,
|
||||
9600, 8, PARITY_NONE, 1, 1.0f, 64);
|
||||
9600, 8, PARITY_NONE, 1, 1.0f, 64, NULL, false);
|
||||
MP_STATE_VM(shared_uart_bus) = MP_OBJ_FROM_PTR(self);
|
||||
return MP_STATE_VM(shared_uart_bus);
|
||||
}
|
||||
|
@ -38,6 +38,7 @@
|
||||
FIL* boot_output_file;
|
||||
#endif
|
||||
|
||||
void serial_early_init(void);
|
||||
void serial_init(void);
|
||||
void serial_write(const char* text);
|
||||
// Only writes up to given length. Does not check for null termination at all.
|
||||
|
@ -74,6 +74,7 @@ void supervisor_bluetooth_start_advertising(void) {
|
||||
// TODO: switch to Adafruit short UUID for the advertisement and add manufacturing data to distinguish ourselves from arduino.
|
||||
_common_hal_bleio_adapter_start_advertising(&common_hal_bleio_adapter_obj,
|
||||
true,
|
||||
false, 0,
|
||||
1.0,
|
||||
circuitpython_advertising_data,
|
||||
sizeof(circuitpython_advertising_data),
|
||||
|
@ -32,26 +32,73 @@
|
||||
#include "shared-bindings/terminalio/Terminal.h"
|
||||
#include "supervisor/serial.h"
|
||||
#include "supervisor/usb.h"
|
||||
#include "shared-bindings/microcontroller/Pin.h"
|
||||
|
||||
#include "tusb.h"
|
||||
|
||||
/*
|
||||
* Note: DEBUG_UART currently only works on STM32,
|
||||
* enabling on another platform will cause a crash.
|
||||
*/
|
||||
|
||||
#if defined(DEBUG_UART_TX) && defined(DEBUG_UART_RX)
|
||||
#include "shared-bindings/busio/UART.h"
|
||||
busio_uart_obj_t debug_uart;
|
||||
byte buf_array[64];
|
||||
#endif
|
||||
|
||||
void serial_early_init(void) {
|
||||
#if defined(DEBUG_UART_TX) && defined(DEBUG_UART_RX)
|
||||
debug_uart.base.type = &busio_uart_type;
|
||||
|
||||
const mcu_pin_obj_t* rx = MP_OBJ_TO_PTR(DEBUG_UART_RX);
|
||||
const mcu_pin_obj_t* tx = MP_OBJ_TO_PTR(DEBUG_UART_TX);
|
||||
|
||||
common_hal_busio_uart_construct(&debug_uart, tx, rx, NULL, NULL, NULL,
|
||||
false, 115200, 8, PARITY_NONE, 1, 1.0f, 64,
|
||||
buf_array, true);
|
||||
common_hal_busio_uart_never_reset(&debug_uart);
|
||||
#endif
|
||||
}
|
||||
|
||||
void serial_init(void) {
|
||||
usb_init();
|
||||
}
|
||||
|
||||
bool serial_connected(void) {
|
||||
#if defined(DEBUG_UART_TX) && defined(DEBUG_UART_RX)
|
||||
return true;
|
||||
#else
|
||||
return tud_cdc_connected();
|
||||
#endif
|
||||
}
|
||||
|
||||
char serial_read(void) {
|
||||
#if defined(DEBUG_UART_TX) && defined(DEBUG_UART_RX)
|
||||
if (tud_cdc_connected() && tud_cdc_available() > 0) {
|
||||
return (char) tud_cdc_read_char();
|
||||
}
|
||||
int uart_errcode;
|
||||
char text;
|
||||
common_hal_busio_uart_read(&debug_uart, (uint8_t*) &text, 1, &uart_errcode);
|
||||
return text;
|
||||
#else
|
||||
return (char) tud_cdc_read_char();
|
||||
#endif
|
||||
}
|
||||
|
||||
bool serial_bytes_available(void) {
|
||||
#if defined(DEBUG_UART_TX) && defined(DEBUG_UART_RX)
|
||||
return common_hal_busio_uart_rx_characters_available(&debug_uart) || (tud_cdc_available() > 0);
|
||||
#else
|
||||
return tud_cdc_available() > 0;
|
||||
#endif
|
||||
}
|
||||
|
||||
void serial_write_substring(const char* text, uint32_t length) {
|
||||
if (length == 0) {
|
||||
return;
|
||||
}
|
||||
#if CIRCUITPY_DISPLAYIO
|
||||
int errcode;
|
||||
common_hal_terminalio_terminal_write(&supervisor_terminal, (const uint8_t*) text, length, &errcode);
|
||||
@ -62,6 +109,11 @@ void serial_write_substring(const char* text, uint32_t length) {
|
||||
count += tud_cdc_write(text + count, length - count);
|
||||
usb_background();
|
||||
}
|
||||
|
||||
#if defined(DEBUG_UART_TX) && defined(DEBUG_UART_RX)
|
||||
int uart_errcode;
|
||||
common_hal_busio_uart_write(&debug_uart, (const uint8_t*) text, length, &uart_errcode);
|
||||
#endif
|
||||
}
|
||||
|
||||
void serial_write(const char* text) {
|
||||
|
@ -26,6 +26,10 @@
|
||||
|
||||
#include "supervisor/serial.h"
|
||||
|
||||
void serial_early_init(void) {
|
||||
|
||||
}
|
||||
|
||||
void serial_init(void) {
|
||||
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user