Skip to content

Commit 361cb1c

Browse files
Merge pull request #1 from adafruit/main
Merge from original repo
2 parents 1cd4e45 + f7a988b commit 361cb1c

File tree

2,041 files changed

+46140
-27985
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

2,041 files changed

+46140
-27985
lines changed

.github/ISSUE_TEMPLATE/bug_report.md

+56
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
---
2+
name: Bug report
3+
about: Create a report to help us improve
4+
title: ''
5+
labels: 'bug'
6+
assignees: ''
7+
8+
---
9+
10+
<!-- Thanks! for testing out CircuitPython. Now that you have got a problem...
11+
you can file a bug report for it. Feel free to modify the below format to better
12+
suit your issue. :) -->
13+
14+
**Firmware**
15+
16+
<!-- Include the version of CircuitPython you're running. You can see it in the
17+
`boot_out.txt` file, as well as in the REPL. -->
18+
19+
```python
20+
Adafruit CircuitPython 6.2.0-beta.2 on 2021-03-01; Raspberry Pi Pico with rp2040
21+
```
22+
23+
**Code/REPL**
24+
25+
<!-- Include your code that reproduces the bug here. Try to distill down to the
26+
minimum possible to reproduce. -->
27+
28+
```python
29+
import busio, bitbangio
30+
i2c = bitbangio.I2C(board.GP1, board.GP0)
31+
```
32+
33+
**Behavior**
34+
35+
<!-- What happens when you run the code above? Include any error messages. -->
36+
37+
```python
38+
Traceback (most recent call last):
39+
File "<stdin>", line 1, in <module>
40+
TimeoutError: Clock stretch too long
41+
```
42+
43+
**Description**
44+
45+
<!-- Optionally, describe the issue in more detail. Here are some examples: -->
46+
47+
- Error while using i2c...
48+
- Only happens when...
49+
- might be related to #4291...
50+
51+
**Additional Info**
52+
53+
<!-- Optionally, add any other information like hardware connection, scope output etc.
54+
If you have already done some debugging, mention it here. -->
55+
56+
Removing [this](url) line resolves the issue.

.github/ISSUE_TEMPLATE/config.yml

+7
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
contact_links:
2+
- name: Adafruit Forum
3+
url: https://forums.adafruit.com/
4+
about: Official Adafruit technical support forum. Good for getting help on getting a project working.
5+
- name: Adafruit Discord
6+
url: https://adafru.it/discord
7+
about: Unofficial chat with many helpful folks and normally prompt replies.
+11
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
---
2+
name: Feature request
3+
about: Suggest an idea for this project
4+
title: ''
5+
labels: 'enhancement'
6+
assignees: ''
7+
8+
---
9+
10+
<!-- We are always adding new features and enhancements to CircuitPython 🚀
11+
and would love ❤ to see what new challenge you have got for us... 🙂 -->

.github/workflows/build.yml

+9-3
Original file line numberDiff line numberDiff line change
@@ -43,8 +43,6 @@ jobs:
4343
run: |
4444
gcc --version
4545
python3 --version
46-
- name: Translations
47-
run: make check-translate
4846
- name: New boards check
4947
run: python3 -u ci_new_boards_check.py
5048
working-directory: tools
@@ -81,6 +79,7 @@ jobs:
8179
working-directory: tests
8280
- name: Print failure info
8381
run: |
82+
shopt -s nullglob;
8483
for exp in *.exp;
8584
do testbase=$(basename $exp .exp);
8685
echo -e "\nFAILURE $testbase";
@@ -281,6 +280,9 @@ jobs:
281280
- "pewpew10"
282281
- "pewpew_m4"
283282
- "picoplanet"
283+
- "pimoroni_keybow2040"
284+
- "pimoroni_picosystem"
285+
- "pimoroni_tiny2040"
284286
- "pirkey_m0"
285287
- "pitaya_go"
286288
- "pyb_nano_v2"
@@ -310,6 +312,7 @@ jobs:
310312
- "simmel"
311313
- "snekboard"
312314
- "sparkfun_lumidrive"
315+
- "sparkfun_nrf52840_micromod"
313316
- "sparkfun_nrf52840_mini"
314317
- "sparkfun_qwiic_micro_no_flash"
315318
- "sparkfun_qwiic_micro_with_flash"
@@ -446,13 +449,16 @@ jobs:
446449
- "espressif_kaluga_1"
447450
- "espressif_saola_1_wroom"
448451
- "espressif_saola_1_wrover"
452+
- "franzininho_wifi_wroom"
453+
- "franzininho_wifi_wrover"
449454
- "lilygo_ttgo_t8_s2_st7789"
450455
- "microdev_micro_s2"
451456
- "muselab_nanoesp32_s2"
452457
- "targett_module_clip_wroom"
453458
- "targett_module_clip_wrover"
454459
- "unexpectedmaker_feathers2"
455460
- "unexpectedmaker_feathers2_prerelease"
461+
- "unexpectedmaker_tinys2"
456462

457463
steps:
458464
- name: Set up Python 3.8
@@ -471,7 +477,7 @@ jobs:
471477
id: idf-cache
472478
with:
473479
path: ${{ github.workspace }}/.idf_tools
474-
key: ${{ runner.os }}-idf-tools-${{ hashFiles('.git/modules/ports/esp32s2/esp-idf/HEAD') }}-20210128
480+
key: ${{ runner.os }}-idf-tools-${{ hashFiles('.git/modules/ports/esp32s2/esp-idf/HEAD') }}-20210304
475481
- name: Clone IDF submodules
476482
run: |
477483
(cd $IDF_PATH && git submodule update --init)

.github/workflows/pre-commit.yml

+5-3
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@ name: pre-commit
77
on:
88
pull_request:
99
push:
10-
branches: [main]
1110

1211
jobs:
1312
pre-commit:
@@ -16,10 +15,13 @@ jobs:
1615
- uses: actions/checkout@v1
1716
- uses: actions/setup-python@v1
1817
- name: Install deps
19-
run: sudo apt-get update && sudo apt-get install -y gettext
18+
run: |
19+
sudo apt-add-repository -y -u ppa:pybricks/ppa
20+
sudo apt-get install -y black gettext uncrustify
21+
pip3 install polib
2022
- name: Populate selected submodules
2123
run: git submodule update --init extmod/ulab
22-
- name: set PY
24+
- name: Set PY
2325
run: echo >>$GITHUB_ENV PY="$(python -c 'import hashlib, sys;print(hashlib.sha256(sys.version.encode()+sys.executable.encode()).hexdigest())')"
2426
- uses: actions/cache@v2
2527
with:

.pre-commit-config.yaml

+13
Original file line numberDiff line numberDiff line change
@@ -11,3 +11,16 @@ repos:
1111
exclude: '^(tests/.*\.exp|tests/cmdline/.*|tests/.*/data/.*|ports/esp32s2/esp-idf-config/.*|ports/esp32s2/boards/.*/sdkconfig)'
1212
- id: trailing-whitespace
1313
exclude: '^(tests/.*\.exp|tests/cmdline/.*|tests/.*/data/.*)'
14+
- repo: local
15+
hooks:
16+
- id: translations
17+
name: Translations
18+
entry: sh -c "if ! make check-translate; then make translate; fi"
19+
types: [c]
20+
pass_filenames: false
21+
language: system
22+
- id: formatting
23+
name: Formatting
24+
entry: sh -c "git diff --staged --name-only | xargs python3 tools/codeformat.py"
25+
types_or: [c, python]
26+
language: system

README.rst

+3-5
Original file line numberDiff line numberDiff line change
@@ -113,10 +113,9 @@ Behavior
113113
- ``code.py`` (or ``main.py``) is run after every reload until it
114114
finishes or is interrupted. After it is done running, the vm and
115115
hardware is reinitialized. **This means you cannot read state from**
116-
``code.py`` **in the REPL anymore.** CircuitPython's goal for this
116+
``code.py`` **in the REPL anymore, as the REPL is a fresh vm.** CircuitPython's goal for this
117117
change includes reducing confusion about pins and memory being used.
118-
- After ``code.py`` the REPL can be entered by pressing any key. It no
119-
longer shares state with ``code.py`` so it is a fresh vm.
118+
- After the main code is finished the REPL can be entered by pressing any key.
120119
- Autoreload state will be maintained across reload.
121120
- Adds a safe mode that does not run user code after a hard crash or
122121
brown out. The hope is that this will make it easier to fix code that
@@ -126,8 +125,7 @@ Behavior
126125
- RGB status LED indicating CircuitPython state, and errors through a sequence of colored flashes.
127126
- Re-runs ``code.py`` or other main file after file system writes over USB mass storage. (Disable with
128127
``supervisor.disable_autoreload()``)
129-
- Entering the REPL after the main code is finished requires a key press which enters the REPL and
130-
disables autoreload.
128+
- Autoreload is disabled while the REPL is active.
131129
- Main is one of these: ``code.txt``, ``code.py``, ``main.py``,
132130
``main.txt``
133131
- Boot is one of these: ``settings.txt``, ``settings.py``, ``boot.py``,

conf.py

+2
Original file line numberDiff line numberDiff line change
@@ -150,6 +150,7 @@
150150
# directories to ignore when looking for source files.
151151
exclude_patterns = ["**/build*",
152152
".git",
153+
".github",
153154
".env",
154155
".venv",
155156
".direnv",
@@ -178,6 +179,7 @@
178179
"ports/cxd56/spresense-exported-sdk",
179180
"ports/esp32s2/certificates",
180181
"ports/esp32s2/esp-idf",
182+
"ports/esp32s2/.idf_tools",
181183
"ports/esp32s2/peripherals",
182184
"ports/litex/hw",
183185
"ports/minimal",

devices/ble_hci/common-hal/_bleio/Adapter.c

+19-19
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@
5151

5252
#define MSEC_TO_UNITS(TIME, RESOLUTION) (((TIME) * 1000) / (RESOLUTION))
5353
#define SEC_TO_UNITS(TIME, RESOLUTION) (((TIME) * 1000000) / (RESOLUTION))
54-
#define UNITS_TO_SEC(TIME, RESOLUTION) (((TIME) * (RESOLUTION)) / 1000000)
54+
#define UNITS_TO_SEC(TIME, RESOLUTION) (((TIME)*(RESOLUTION)) / 1000000)
5555
// 0.625 msecs (625 usecs)
5656
#define ADV_INTERVAL_UNIT_FLOAT_SECS (0.000625)
5757
// Microseconds is the base unit. The macros above know that.
@@ -63,7 +63,7 @@
6363

6464
// TODO make this settable from Python.
6565
#define DEFAULT_TX_POWER 0 // 0 dBm
66-
#define MAX_ANONYMOUS_ADV_TIMEOUT_SECS (60*15)
66+
#define MAX_ANONYMOUS_ADV_TIMEOUT_SECS (60 * 15)
6767
#define MAX_LIMITED_DISCOVERABLE_ADV_TIMEOUT_SECS (180)
6868

6969
#define BLE_MIN_CONN_INTERVAL MSEC_TO_UNITS(15, UNIT_0_625_MS)
@@ -289,7 +289,7 @@ STATIC void bleio_adapter_hci_init(bleio_adapter_obj_t *self) {
289289

290290
// Get version information.
291291
if (hci_read_local_version(&self->hci_version, &self->hci_revision, &self->lmp_version,
292-
&self->manufacturer, &self->lmp_subversion) != HCI_OK) {
292+
&self->manufacturer, &self->lmp_subversion) != HCI_OK) {
293293
mp_raise_bleio_BluetoothError(translate("Could not read HCI version"));
294294
}
295295
// Get supported features.
@@ -414,11 +414,11 @@ bool common_hal_bleio_adapter_set_address(bleio_adapter_obj_t *self, bleio_addre
414414
return hci_le_set_random_address(bufinfo.buf) == HCI_OK;
415415
}
416416

417-
mp_obj_str_t* common_hal_bleio_adapter_get_name(bleio_adapter_obj_t *self) {
417+
mp_obj_str_t *common_hal_bleio_adapter_get_name(bleio_adapter_obj_t *self) {
418418
return self->name;
419419
}
420420

421-
void common_hal_bleio_adapter_set_name(bleio_adapter_obj_t *self, const char* name) {
421+
void common_hal_bleio_adapter_set_name(bleio_adapter_obj_t *self, const char *name) {
422422
self->name = mp_obj_new_str(name, strlen(name));
423423
mp_buffer_info_t bufinfo;
424424
mp_get_buffer_raise(self->name, &bufinfo, MP_BUFFER_READ);
@@ -459,7 +459,7 @@ void common_hal_bleio_adapter_set_name(bleio_adapter_obj_t *self, const char* na
459459
// return true;
460460
// }
461461

462-
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) {
462+
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) {
463463
// TODO
464464
mp_raise_NotImplementedError(NULL);
465465
check_enabled(self);
@@ -704,7 +704,7 @@ uint32_t _common_hal_bleio_adapter_start_advertising(bleio_adapter_obj_t *self,
704704

705705
uint8_t handle[1] = { 0 };
706706
uint16_t duration_10msec[1] = { timeout * 100 };
707-
uint8_t max_ext_adv_evts[1] = { 0 };
707+
uint8_t max_ext_adv_evts[1] = { 0 };
708708
hci_check_error(
709709
hci_le_set_extended_advertising_enable(
710710
BT_HCI_LE_ADV_ENABLE,
@@ -789,11 +789,11 @@ void common_hal_bleio_adapter_start_advertising(bleio_adapter_obj_t *self, bool
789789
} else {
790790
if (timeout > MAX_LIMITED_DISCOVERABLE_ADV_TIMEOUT_SECS) {
791791
mp_raise_bleio_BluetoothError(translate("Timeout is too long: Maximum timeout length is %d seconds"),
792-
MAX_LIMITED_DISCOVERABLE_ADV_TIMEOUT_SECS);
792+
MAX_LIMITED_DISCOVERABLE_ADV_TIMEOUT_SECS);
793793
}
794794
}
795795

796-
const uint32_t result =_common_hal_bleio_adapter_start_advertising(
796+
const uint32_t result = _common_hal_bleio_adapter_start_advertising(
797797
self, connectable, anonymous, timeout, interval,
798798
advertising_data_bufinfo->buf,
799799
advertising_data_bufinfo->len,
@@ -820,11 +820,11 @@ void common_hal_bleio_adapter_stop_advertising(bleio_adapter_obj_t *self) {
820820
hci_check_error(result);
821821
}
822822

823-
//TODO startup CircuitPython advertising again.
823+
// TODO startup CircuitPython advertising again.
824824
}
825825

826826
// Note that something stopped advertising, such as a connection happening.
827-
//Don't ask the adapter to stop.
827+
// Don't ask the adapter to stop.
828828
void bleio_adapter_advertising_was_stopped(bleio_adapter_obj_t *self) {
829829
self->now_advertising = false;
830830
self->extended_advertising = false;
@@ -876,14 +876,14 @@ void common_hal_bleio_adapter_erase_bonding(bleio_adapter_obj_t *self) {
876876
mp_raise_NotImplementedError(NULL);
877877
check_enabled(self);
878878

879-
//FIX bonding_erase_storage();
879+
// FIX bonding_erase_storage();
880880
}
881881

882882
uint16_t bleio_adapter_add_attribute(bleio_adapter_obj_t *adapter, mp_obj_t *attribute) {
883883
check_enabled(adapter);
884884

885885
// The handle is the index of this attribute in the attributes list.
886-
uint16_t handle = (uint16_t) adapter->attributes->len;
886+
uint16_t handle = (uint16_t)adapter->attributes->len;
887887
mp_obj_list_append(adapter->attributes, attribute);
888888

889889
if (MP_OBJ_IS_TYPE(attribute, &bleio_service_type)) {
@@ -896,7 +896,7 @@ uint16_t bleio_adapter_add_attribute(bleio_adapter_obj_t *adapter, mp_obj_t *att
896896
return handle;
897897
}
898898

899-
mp_obj_t* bleio_adapter_get_attribute(bleio_adapter_obj_t *adapter, uint16_t handle) {
899+
mp_obj_t *bleio_adapter_get_attribute(bleio_adapter_obj_t *adapter, uint16_t handle) {
900900
check_enabled(adapter);
901901

902902
if (handle == 0 || handle >= adapter->attributes->len) {
@@ -912,12 +912,12 @@ uint16_t bleio_adapter_max_attribute_handle(bleio_adapter_obj_t *adapter) {
912912
}
913913

914914

915-
void bleio_adapter_gc_collect(bleio_adapter_obj_t* adapter) {
916-
gc_collect_root((void**)adapter, sizeof(bleio_adapter_obj_t) / sizeof(size_t));
917-
gc_collect_root((void**)bleio_connections, sizeof(bleio_connections) / sizeof(size_t));
915+
void bleio_adapter_gc_collect(bleio_adapter_obj_t *adapter) {
916+
gc_collect_root((void **)adapter, sizeof(bleio_adapter_obj_t) / sizeof(size_t));
917+
gc_collect_root((void **)bleio_connections, sizeof(bleio_connections) / sizeof(size_t));
918918
}
919919

920-
void bleio_adapter_reset(bleio_adapter_obj_t* adapter) {
920+
void bleio_adapter_reset(bleio_adapter_obj_t *adapter) {
921921

922922
if (!common_hal_bleio_adapter_get_enabled(adapter)) {
923923
return;
@@ -939,7 +939,7 @@ void bleio_adapter_reset(bleio_adapter_obj_t* adapter) {
939939

940940
}
941941

942-
void bleio_adapter_background(bleio_adapter_obj_t* adapter) {
942+
void bleio_adapter_background(bleio_adapter_obj_t *adapter) {
943943
if (!common_hal_bleio_adapter_get_enabled(adapter)) {
944944
return;
945945
}

devices/ble_hci/common-hal/_bleio/Adapter.h

+6-6
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ typedef struct _bleio_adapter_obj_t {
4949
bleio_scanresults_obj_t *scan_results;
5050
mp_obj_t name;
5151
mp_obj_tuple_t *connection_objs;
52-
busio_uart_obj_t* hci_uart;
52+
busio_uart_obj_t *hci_uart;
5353
digitalio_digitalinout_obj_t *rts_digitalinout;
5454
digitalio_digitalinout_obj_t *cts_digitalinout;
5555
bool allocated; // True when in use.
@@ -72,7 +72,7 @@ typedef struct _bleio_adapter_obj_t {
7272
// Generic services characteristics.
7373
bleio_characteristic_obj_t *device_name_characteristic;
7474
bleio_characteristic_obj_t *appearance_characteristic;
75-
bleio_characteristic_obj_t * service_changed_characteristic;
75+
bleio_characteristic_obj_t *service_changed_characteristic;
7676

7777
uint16_t max_acl_buffer_len;
7878
uint16_t max_acl_num_buffers;
@@ -90,10 +90,10 @@ typedef struct _bleio_adapter_obj_t {
9090

9191
uint16_t bleio_adapter_add_attribute(bleio_adapter_obj_t *adapter, mp_obj_t *attribute);
9292
void bleio_adapter_advertising_was_stopped(bleio_adapter_obj_t *self);
93-
mp_obj_t* bleio_adapter_get_attribute(bleio_adapter_obj_t *adapter, uint16_t handle);
93+
mp_obj_t *bleio_adapter_get_attribute(bleio_adapter_obj_t *adapter, uint16_t handle);
9494
uint16_t bleio_adapter_max_attribute_handle(bleio_adapter_obj_t *adapter);
95-
void bleio_adapter_background(bleio_adapter_obj_t* adapter);
96-
void bleio_adapter_gc_collect(bleio_adapter_obj_t* adapter);
97-
void bleio_adapter_reset(bleio_adapter_obj_t* adapter);
95+
void bleio_adapter_background(bleio_adapter_obj_t *adapter);
96+
void bleio_adapter_gc_collect(bleio_adapter_obj_t *adapter);
97+
void bleio_adapter_reset(bleio_adapter_obj_t *adapter);
9898

9999
#endif // MICROPY_INCLUDED_BLE_HCI_COMMON_HAL_ADAPTER_H

0 commit comments

Comments
 (0)