8000 jacdac support for NRF52 and ESP32 by mmoskal · Pull Request #1 · mmoskal/circuitpython · GitHub
[go: up one dir, main page]

Skip to content

jacdac support for NRF52 and ESP32 #1

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Draft
wants to merge 34 commits into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
34 commits
Select commit Hold shift + click to select a range
4105063
add JACDAC to shared-bindings
jamesadevine Aug 6, 2020
7fb1cd6
add JACDAC to common-hal
MannuLambrichts Aug 17, 2020
1820bd5
first working version of the JACDAC protocol
MannuLambrichts Aug 20, 2020
ba8cf68
code cleanup, bugfixes and improvements
MannuLambrichts Aug 24, 2020
5d39350
Working transmit and receive
jamesadevine Oct 2, 2020
a97bb4c
remove lto for fast builds
jamesadevine Oct 2, 2020
1b3884c
fix time out code
jamesadevine Oct 5, 2020
0fd6e21 8000
Merge remote-tracking branch 'upstream/main' into main
jamesadevine Oct 5, 2020
b4ff27d
Merge branch 'main' into buffer-patch
jamesadevine Oct 5, 2020
8544cd2
complete phys imp
jamesadevine Oct 5, 2020
f8be8ed
feature complete
jamesadevine Oct 6, 2020
443c7ad
re-add lto in Makefile
jamesadevine Oct 6, 2020
54184f2
remove jd_test folder
jamesadevine Oct 6, 2020
7cf9076
return consistent data type from JD shared bindings
jamesadevine Oct 6, 2020
c2598b2
fixup reset code and remove uneccessary panic
jamesadevine Oct 6, 2020
c1f409b
Merge pull request #1 from jamesadevine/buffer-patch
jamesadevine Oct 6, 2020
0f40eb9
Merge remote-tracking branch 'james/jacdac' into jacdac2
mmoskal Jun 17, 2021
8435f68
format with tools/codeformat.py
mmoskal Jun 17, 2021
3510372
add some comments
mmoskal Jun 23, 2021
8a9a03d
start on jacdac busio rewrite
mmoskal Jun 23, 2021
ddaa04a
Add packet queues
mmoskal Jun 24, 2021
12b7307
Start on jacdac common-hal
mmoskal Jun 24, 2021
04d0a38
port Jacdac single wire serial impl
mmoskal Jun 25, 2021
41db49c
Fixes
mmoskal Jun 26, 2021
a466d93
Add dmesg
mmoskal Jun 28, 2021
b935fdd
Implement jacdac_reset()
mmoskal Jun 28, 2021
5216e2a
reception fixes
mmoskal Jun 29, 2021
ec45fcc
allow unix build
mmoskal Jul 7, 2021
864908e
Fix some races
mmoskal Jul 7, 2021
f2e14e5
fix timeout value
mmoskal Jul 7, 2021
165b5e5
Don't blow up when VM is stopped
mmoskal Jul 8, 2021
7875ce5
rewrite JACDAC.hash
mmoskal Jul 8, 2021
78e4ac0
add msr jacdac iot board
mmoskal Jul 9, 2021
98a3e38
Add busio.JACDAC.uid()
mmoskal Jul 9, 2021
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 16 additions & 5 deletions locale/circuitpython.pot
Original file line number Diff line number Diff line change
Expand Up @@ -344,15 +344,19 @@ msgstr ""
msgid "All SPI peripherals are in use"
msgstr ""

#: ports/esp32s2/common-hal/busio/UART.c ports/nrf/common-hal/busio/UART.c
#: ports/raspberrypi/common-hal/busio/UART.c
#: ports/esp32s2/common-hal/busio/UART.c ports/nrf/common-hal/busio/JACDAC.c
#: ports/nrf/common-hal/busio/UART.c ports/raspberrypi/common-hal/busio/UART.c
msgid "All UART peripherals are in use"
msgstr ""

#: shared-bindings/pwmio/PWMOut.c
msgid "All channels in use"
msgstr ""

#: ports/esp32s2/common-hal/busio/JACDAC.c
msgid "All context->uart_hw peripherals are in use"
msgstr ""

#: ports/atmel-samd/common-hal/audioio/AudioOut.c
msgid "All event channels in use"
msgstr ""
Expand Down Expand Up @@ -380,7 +384,8 @@ msgstr ""
#: ports/esp32s2/common-hal/pulseio/PulseIn.c
#: ports/esp32s2/common-hal/pulseio/PulseOut.c
#: ports/nrf/common-hal/audiopwmio/PWMAudioOut.c
#: ports/nrf/common-hal/pulseio/PulseIn.c ports/nrf/peripherals/nrf/timers.c
#: ports/nrf/common-hal/busio/JACDAC.c ports/nrf/common-hal/pulseio/PulseIn.c
#: ports/nrf/peripherals/nrf/timers.c
#: ports/raspberrypi/common-hal/audiopwmio/PWMAudioOut.c
#: ports/stm/peripherals/timers.c shared-bindings/pwmio/PWMOut.c
msgid "All timers in use"
Expand Down Expand Up @@ -1248,8 +1253,10 @@ msgstr ""
msgid "Invalid Pin"
msgstr ""

#: ports/esp32s2/bindings/espidf/__init__.c ports/esp32s2/esp_error.c
#: py/moduerrno.c shared-module/rgbmatrix/RGBMatrix.c
#: ports/esp32s2/bindings/espidf/__init__.c
#: ports/esp32s2/common-hal/busio/JACDAC.c ports/esp32s2/esp_error.c
#: py/moduerrno.c shared-bindings/busio/JACDAC.c
#: shared-module/rgbmatrix/RGBMatrix.c
msgid "Invalid argument"
msgstr ""

Expand Down Expand Up @@ -1388,6 +1395,10 @@ msgstr ""
msgid "Invalid word/bit length"
msgstr ""

#: shared-bindings/busio/JACDAC.c
msgid "Jacdac TX queue full"
msgstr ""

#: shared-bindings/aesio/aes.c
msgid "Key must be 16, 24, or 32 bytes long"
msgstr ""
Expand Down
28 changes: 28 additions & 0 deletions ports/esp32s2/background.c
Original file line number Diff line number Diff line change
Expand Up @@ -39,13 +39,41 @@
#include "common-hal/pulseio/PulseIn.h"
#endif

#include "shared-bindings/microcontroller/__init__.h"


void port_background_task(void) {
// Zero delay in case FreeRTOS wants to switch to something else.
vTaskDelay(0);
#if CIRCUITPY_PULSEIO
pulsein_background();
#endif

if (codalLogStore.ptr) {
char *dmesgCopy = malloc(sizeof(codalLogStore));

uint32_t len;

common_hal_mcu_disable_interrupts();
len = codalLogStore.ptr;
memcpy(dmesgCopy, codalLogStore.buffer, len);
codalLogStore.ptr = 0;
codalLogStore.buffer[0] = 0;
common_hal_mcu_enable_interrupts();

if (len) {
if (dmesgCopy[len - 1] == '\n') {
len--;
}
dmesgCopy[len] = 0;
if (strchr(dmesgCopy, '\n')) {
ESP_LOGW("JD", "DMESG:\n%s", dmesgCopy);
} else {
ESP_LOGW("JD", "DMESG: %s", dmesgCopy);
}
}
free(dmesgCopy);
}
}

void port_start_background_task(void) {
Expand Down
52 changes: 52 additions & 0 deletions ports/esp32s2/boards/msr_jacdac_iot/board.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
/*
* This file is part of the MicroPython project, http://micropython.org/
*
* The MIT License (MIT)
*
* Copyright (c) 2020 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 "supervisor/board.h"
#include "mpconfigboard.h"
#include "shared-bindings/microcontroller/Pin.h"

void board_init(void) {
// USB
common_hal_never_reset_pin(&pin_GPIO19);
common_hal_never_reset_pin(&pin_GPIO20);

// Debug UART
#ifdef DEBUG
common_hal_never_reset_pin(&pin_GPIO43);
common_hal_never_reset_pin(&pin_GPIO44);
#endif /* DEBUG */
}

bool board_requests_safe_mode(void) {
return false;
}

void reset_board(void) {

}

void board_deinit(void) {
}
41 changes: 41 additions & 0 deletions ports/esp32s2/boards/msr_jacdac_iot/mpconfigboard.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
/*
* This file is part of the MicroPython project, http://micropython.org/
*
* The MIT License (MIT)
*
* Copyright (c) 2019 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.
*/

// Micropython setup

#define MICROPY_HW_BOARD_NAME "Jacdac IoT 48"
#define MICROPY_HW_MCU_NAME "ESP32S2"

#define CIRCUITPY_RGB_STATUS_R (&pin_GPIO8)
#define CIRCUITPY_RGB_STATUS_G (&pin_GPIO7)
#define CIRCUITPY_RGB_STATUS_B (&pin_GPIO6)
#define CIRCUITPY_RGB_STATUS_INVERTED_PWM 1

#define CIRCUITPY_BOOT_BUTTON (&pin_GPIO0)

#define BOARD_USER_SAFE_MODE_ACTION translate("pressing boot button at start up.\n")

#define AUTORESET_DELAY_MS 500
17 changes: 17 additions & 0 deletions ports/esp32s2/boards/msr_jacdac_iot/mpconfigboard.mk
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
USB_VID = 0x239A
USB_PID = 0x80A8 # TODO
USB_PRODUCT = "Jacdac IoT 48"
USB_MANUFACTURER = "MSR"

INTERNAL_FLASH_FILESYSTEM = 1
LONGINT_IMPL = MPZ

# The default queue depth of 16 overflows on release builds,
# so increase it to 32.
CFLAGS += -DCFG_TUD_TASK_QUEUE_SZ=32

CIRCUITPY_ESP_FLASH_MODE=dio
CIRCUITPY_ESP_FLASH_FREQ=40m
CIRCUITPY_ESP_FLASH_SIZE=4MB

CIRCUITPY_MODULE=wroom
39 changes: 39 additions & 0 deletions ports/esp32s2/boards/msr_jacdac_iot/pins.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
#include "shared-bindings/board/__init__.h"

STATIC const mp_rom_map_elem_t board_global_dict_table[] = {
{ MP_ROM_QSTR(MP_QSTR_IO0), MP_ROM_PTR(&pin_GPIO0) },
{ MP_ROM_QSTR(MP_QSTR_ILIM_STATUS), MP_ROM_PTR(&pin_GPIO1) },
{ MP_ROM_QSTR(MP_QSTR_ILIM_EN), MP_ROM_PTR(&pin_GPIO2) },
{ MP_ROM_QSTR(MP_QSTR_ILIM_CTRL), MP_ROM_PTR(&pin_GPIO3) },
{ MP_ROM_QSTR(MP_QSTR_IO4), MP_ROM_PTR(&pin_GPIO4) },
{ MP_ROM_QSTR(MP_QSTR_IO5), MP_ROM_PTR(&pin_GPIO5) },
/* used as status LED in CP - can't be defined here
{ MP_ROM_QSTR(MP_QSTR_BLUE_LED), MP_ROM_PTR(&pin_GPIO6) },
{ MP_ROM_QSTR(MP_QSTR_GREEN_LED), MP_ROM_PTR(&pin_GPIO7) },
{ MP_ROM_QSTR(MP_QSTR_RED_LED), MP_ROM_PTR(&pin_GPIO8) },
*/
{ MP_ROM_QSTR(MP_QSTR_IO9), MP_ROM_PTR(&pin_GPIO9) },
{ MP_ROM_QSTR(MP_QSTR_IO10), MP_ROM_PTR(&pin_GPIO10) },
{ MP_ROM_QSTR(MP_QSTR_CC1), MP_ROM_PTR(&pin_GPIO11) },
{ MP_ROM_QSTR(MP_QSTR_CC2), MP_ROM_PTR(&pin_GPIO12) },
{ MP_ROM_QSTR(MP_QSTR_ILIM_FAULT), MP_ROM_PTR(&pin_GPIO13) },
{ MP_ROM_QSTR(MP_QSTR_IO14), MP_ROM_PTR(&pin_GPIO14) },

{ MP_ROM_QSTR(MP_QSTR_IO26), MP_ROM_PTR(&pin_GPIO26) },
{ MP_ROM_QSTR(MP_QSTR_IO33), MP_ROM_PTR(&pin_GPIO33) },
{ MP_ROM_QSTR(MP_QSTR_IO34), MP_ROM_PTR(&pin_GPIO34) },
{ MP_ROM_QSTR(MP_QSTR_IO35), MP_ROM_PTR(&pin_GPIO35) },
{ MP_ROM_QSTR(MP_QSTR_IO36), MP_ROM_PTR(&pin_GPIO36) },
{ MP_ROM_QSTR(MP_QSTR_IO37), MP_ROM_PTR(&pin_GPIO37) },
{ MP_ROM_QSTR(MP_QSTR_IO38), MP_ROM_PTR(&pin_GPIO38) },

{ MP_ROM_QSTR(MP_QSTR_IO45), MP_ROM_PTR(&pin_GPIO45) },
{ MP_ROM_QSTR(MP_QSTR_IO46), MP_ROM_PTR(&pin_GPIO46) },

{ MP_ROM_QSTR(MP_QSTR_JACDAC), MP_ROM_PTR(&pin_GPIO17) },

{ MP_ROM_QSTR(MP_QSTR_TX), MP_ROM_PTR(&pin_GPIO43) },
{ MP_ROM_QSTR(MP_QSTR_RX), MP_ROM_PTR(&pin_GPIO44) },

};
MP_DEFINE_CONST_DICT(board_module_globals, board_global_dict_table);
Empty file.
Loading
0