Skip to content
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

[wiring] Add I2C and SPI support #269

Draft
wants to merge 25 commits into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
25 commits
Select commit Hold shift + click to select a range
04bd58f
[libs] Use incomplete types in SerialClass data pattern
kuba2k2 Sep 21, 2023
975bb68
[libs] Declare Serial instances in common core
kuba2k2 Sep 21, 2023
66eadf3
[libs] Move Serial constructor to header, use nullptr
kuba2k2 Sep 21, 2023
e0a746d
[boards] Update boardgen to v0.10.0
kuba2k2 Sep 21, 2023
9d1be85
[wiring] Fix missing random() function
kuba2k2 Sep 22, 2023
b1d17cb
[libs] Add compile-time feature check for Serial library
kuba2k2 Sep 22, 2023
a039656
[libs] Implement Wire API library
kuba2k2 Sep 22, 2023
6ff9872
[realtek-ambz] Implement Wire library, remove old unit
kuba2k2 Sep 22, 2023
2b54491
[wiring] Replace sdk_private.h with ArduinoPrivate.h
kuba2k2 Sep 23, 2023
7af25d4
[realtek-ambz] Use ROM table for Serial address
kuba2k2 Sep 23, 2023
4f4d3a9
[wiring] Extract utilities from Wire
kuba2k2 Sep 23, 2023
8576eba
[wiring] Implement SPI API library
kuba2k2 Sep 23, 2023
89f4745
[realtek-ambz] Implement SPI library
kuba2k2 Sep 23, 2023
ca096d8
Merge remote-tracking branch 'origin/master' into feature/i2c-spi
kuba2k2 Dec 8, 2023
ca8d767
[boards] Update boardgen to add SPI support
kuba2k2 Dec 8, 2023
6a12a0d
[wiring] Use enum for endTransmission() result
kuba2k2 Dec 9, 2023
5f3c27e
[wiring] Use private methods for Serial, Wire, SPI begin/end
kuba2k2 Dec 10, 2023
b6e54f2
[beken-72xx] Implement Wire master write on I2C1
kuba2k2 Dec 10, 2023
058099a
[beken-72xx] Flatten I2C register structs, add descriptions
kuba2k2 Dec 10, 2023
1ed395b
[beken-72xx] Implement Wire master read on I2C1
kuba2k2 Dec 11, 2023
cf3f23e
[wiring] Allow creating parameterless Wire instance
kuba2k2 Dec 12, 2023
54cc794
Merge remote-tracking branch 'origin/master' into feature/i2c-spi
kuba2k2 Mar 14, 2024
d54b863
[beken-72xx] Add draft support for I2C2
kuba2k2 Mar 15, 2024
c099503
[core] Add missing SPI begin, add weak transfer() and write()
kuba2k2 Mar 26, 2024
7630a23
[beken-72xx] Add draft SPI TX support
kuba2k2 Mar 26, 2024
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
2 changes: 1 addition & 1 deletion .github/workflows/push-master.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ jobs:
python-version: '3.10'

- name: Install docs dependencies
run: pip install -U ltchiptool "boardgen>=0.11.0"
run: pip install -U ltchiptool "boardgen>=0.11.1"

- name: Generate docs and static JSON files
run: |
Expand Down
12 changes: 6 additions & 6 deletions boards/_base/ic/rtl8710bn.json
Original file line number Diff line number Diff line change
Expand Up @@ -52,42 +52,42 @@
"C_NAME": "PA_6",
"GPIO": "PA06",
"IRQ": null,
"SPI": "FCS",
"FLASH": "^FCS",
"SD": "D2"
},
"19": {
"C_NAME": "PA_7",
"GPIO": "PA07",
"IRQ": null,
"SPI": "FD1",
"FLASH": "FD1",
"SD": "D3"
},
"20": {
"C_NAME": "PA_8",
"GPIO": "PA08",
"IRQ": null,
"SPI": "FD2",
"FLASH": "FD2",
"SD": "CMD"
},
"21": {
"C_NAME": "PA_9",
"GPIO": "PA09",
"IRQ": null,
"SPI": "FD0",
"FLASH": "FD0",
"SD": "CLK"
},
"22": {
"C_NAME": "PA_10",
"GPIO": "PA10",
"IRQ": null,
"SPI": "FSCK",
"FLASH": "FSCK",
"SD": "D0"
},
"23": {
"C_NAME": "PA_11",
"GPIO": "PA11",
"IRQ": null,
"SPI": "FD3",
"FLASH": "FD3",
"SD": "D1"
},
"27": {
Expand Down
13 changes: 13 additions & 0 deletions boards/variants/cb3se.h
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,17 @@
#define NUM_ANALOG_OUTPUTS 6 // PWM & DAC outputs
#define PINS_GPIO_MAX 26 // Last usable GPIO number

// SPI Interfaces
// --------------
#define PIN_SPI0_CS 15u // GPIO15
#define PIN_SPI0_MISO 17u // GPIO17
#define PIN_SPI0_MOSI 16u // GPIO16
#define PIN_SPI0_SCK 14u // GPIO14
#define PINS_SPI0_CS (pin_size_t[]){15u}
#define PINS_SPI0_MISO (pin_size_t[]){17u}
#define PINS_SPI0_MOSI (pin_size_t[]){16u}
#define PINS_SPI0_SCK (pin_size_t[]){14u}

// Wire Interfaces
// ---------------
#define PIN_WIRE2_SCL 0u // GPIO0
Expand Down Expand Up @@ -72,8 +83,10 @@
// -----------------
#define HAS_SERIAL1 1
#define HAS_SERIAL2 1
#define HAS_SPI0 1
#define HAS_WIRE2 1
#define SERIAL_INTERFACES_COUNT 2
#define SPI_INTERFACES_COUNT 1
#define WIRE_INTERFACES_COUNT 1

// Arduino pin names
Expand Down
13 changes: 13 additions & 0 deletions boards/variants/cbu.h
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,17 @@
#define NUM_ANALOG_OUTPUTS 6 // PWM & DAC outputs
#define PINS_GPIO_MAX 28 // Last usable GPIO number

// SPI Interfaces
// --------------
#define PIN_SPI0_CS 15u // GPIO15
#define PIN_SPI0_MISO 17u // GPIO17
#define PIN_SPI0_MOSI 16u // GPIO16
#define PIN_SPI0_SCK 14u // GPIO14
#define PINS_SPI0_CS (pin_size_t[]){15u}
#define PINS_SPI0_MISO (pin_size_t[]){17u}
#define PINS_SPI0_MOSI (pin_size_t[]){16u}
#define PINS_SPI0_SCK (pin_size_t[]){14u}

// Wire Interfaces
// ---------------
#define PIN_WIRE1_SCL 20u // GPIO20
Expand Down Expand Up @@ -79,9 +90,11 @@
// -----------------
#define HAS_SERIAL1 1
#define HAS_SERIAL2 1
#define HAS_SPI0 1
#define HAS_WIRE1 1
#define HAS_WIRE2 1
#define SERIAL_INTERFACES_COUNT 2
#define SPI_INTERFACES_COUNT 1
#define WIRE_INTERFACES_COUNT 2

// Arduino pin names
Expand Down
13 changes: 13 additions & 0 deletions boards/variants/generic-bk7231n-qfn32-tuya.h
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,17 @@
#define NUM_ANALOG_OUTPUTS 6 // PWM & DAC outputs
#define PINS_GPIO_MAX 28 // Last usable GPIO number

// SPI Interfaces
// --------------
#define PIN_SPI0_CS 15u // GPIO15
#define PIN_SPI0_MISO 17u // GPIO17
#define PIN_SPI0_MOSI 16u // GPIO16
#define PIN_SPI0_SCK 14u // GPIO14
#define PINS_SPI0_CS (pin_size_t[]){15u}
#define PINS_SPI0_MISO (pin_size_t[]){17u}
#define PINS_SPI0_MOSI (pin_size_t[]){16u}
#define PINS_SPI0_SCK (pin_size_t[]){14u}

// Wire Interfaces
// ---------------
#define PIN_WIRE1_SCL 20u // GPIO20
Expand Down Expand Up @@ -79,9 +90,11 @@
// -----------------
#define HAS_SERIAL1 1
#define HAS_SERIAL2 1
#define HAS_SPI0 1
#define HAS_WIRE1 1
#define HAS_WIRE2 1
#define SERIAL_INTERFACES_COUNT 2
#define SPI_INTERFACES_COUNT 1
#define WIRE_INTERFACES_COUNT 2

// Arduino pin names
Expand Down
13 changes: 13 additions & 0 deletions boards/variants/generic-bk7231t-qfn32-tuya.h
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,17 @@
#define NUM_ANALOG_OUTPUTS 6 // PWM & DAC outputs
#define PINS_GPIO_MAX 28 // Last usable GPIO number

// SPI Interfaces
// --------------
#define PIN_SPI0_CS 15u // GPIO15
#define PIN_SPI0_MISO 17u // GPIO17
#define PIN_SPI0_MOSI 16u // GPIO16
#define PIN_SPI0_SCK 14u // GPIO14
#define PINS_SPI0_CS (pin_size_t[]){15u}
#define PINS_SPI0_MISO (pin_size_t[]){17u}
#define PINS_SPI0_MOSI (pin_size_t[]){16u}
#define PINS_SPI0_SCK (pin_size_t[]){14u}

// Wire Interfaces
// ---------------
#define PIN_WIRE1_SCL 20u // GPIO20
Expand Down Expand Up @@ -79,9 +90,11 @@
// -----------------
#define HAS_SERIAL1 1
#define HAS_SERIAL2 1
#define HAS_SPI0 1
#define HAS_WIRE1 1
#define HAS_WIRE2 1
#define SERIAL_INTERFACES_COUNT 2
#define SPI_INTERFACES_COUNT 1
#define WIRE_INTERFACES_COUNT 2

// Arduino pin names
Expand Down
13 changes: 13 additions & 0 deletions boards/variants/generic-bk7252.h
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,17 @@
#define NUM_ANALOG_OUTPUTS 4 // PWM & DAC outputs
#define PINS_GPIO_MAX 39 // Last usable GPIO number

// SPI Interfaces
// --------------
#define PIN_SPI0_CS 15u // GPIO15
#define PIN_SPI0_MISO 17u // GPIO17
#define PIN_SPI0_MOSI 16u // GPIO16
#define PIN_SPI0_SCK 14u // GPIO14
#define PINS_SPI0_CS (pin_size_t[]){15u}
#define PINS_SPI0_MISO (pin_size_t[]){17u}
#define PINS_SPI0_MOSI (pin_size_t[]){16u}
#define PINS_SPI0_SCK (pin_size_t[]){14u}

// Wire Interfaces
// ---------------
#define PIN_WIRE1_SCL 20u // GPIO20
Expand Down Expand Up @@ -108,9 +119,11 @@
// -----------------
#define HAS_SERIAL1 1
#define HAS_SERIAL2 1
#define HAS_SPI0 1
#define HAS_WIRE1 1
#define HAS_WIRE2 1
#define SERIAL_INTERFACES_COUNT 2
#define SPI_INTERFACES_COUNT 1
#define WIRE_INTERFACES_COUNT 2

// Arduino pin names
Expand Down
14 changes: 7 additions & 7 deletions boards/variants/generic-rtl8710bn-2mb-468k.c
Original file line number Diff line number Diff line change
Expand Up @@ -12,18 +12,18 @@ PinInfo lt_arduino_pin_info_list[PINS_COUNT] = {
{PA_0, PIN_GPIO | PIN_IRQ | PIN_PWM, PIN_NONE, 0},
// D1: PA05, PWM4, WAKE1
{PA_5, PIN_GPIO | PIN_IRQ | PIN_PWM, PIN_NONE, 0},
// D2: PA06, FCS, SD_D2
{PA_6, PIN_GPIO | PIN_IRQ | PIN_SPI, PIN_NONE, 0},
// D2: PA06, ^FCS, SD_D2
{PA_6, PIN_GPIO | PIN_IRQ, PIN_NONE, 0},
// D3: PA07, FD1, SD_D3
{PA_7, PIN_GPIO | PIN_IRQ | PIN_SPI, PIN_NONE, 0},
{PA_7, PIN_GPIO | PIN_IRQ, PIN_NONE, 0},
// D4: PA08, FD2, SD_CMD
{PA_8, PIN_GPIO | PIN_IRQ | PIN_SPI, PIN_NONE, 0},
{PA_8, PIN_GPIO | PIN_IRQ, PIN_NONE, 0},
// D5: PA09, FD0, SD_CLK
{PA_9, PIN_GPIO | PIN_IRQ | PIN_SPI, PIN_NONE, 0},
{PA_9, PIN_GPIO | PIN_IRQ, PIN_NONE, 0},
// D6: PA10, FSCK, SD_D0
{PA_10, PIN_GPIO | PIN_IRQ | PIN_SPI, PIN_NONE, 0},
{PA_10, PIN_GPIO | PIN_IRQ, PIN_NONE, 0},
// D7: PA11, FD3, SD_D1
{PA_11, PIN_GPIO | PIN_IRQ | PIN_SPI, PIN_NONE, 0},
{PA_11, PIN_GPIO | PIN_IRQ, PIN_NONE, 0},
// D8: PA12, PWM3
{PA_12, PIN_GPIO | PIN_IRQ | PIN_PWM, PIN_NONE, 0},
// D9: PA14, PWM0, SWCLK
Expand Down
6 changes: 0 additions & 6 deletions boards/variants/generic-rtl8710bn-2mb-468k.h
Original file line number Diff line number Diff line change
Expand Up @@ -66,12 +66,6 @@
#define PIN_CS0 19u // PA_19
#define PIN_CS1 19u // PA_19
#define PIN_CTS0 19u // PA_19
#define PIN_FCS 6u // PA_6
#define PIN_FD0 9u // PA_9
#define PIN_FD1 7u // PA_7
#define PIN_FD2 8u // PA_8
#define PIN_FD3 11u // PA_11
#define PIN_FSCK 10u // PA_10
#define PIN_MISO0 22u // PA_22
#define PIN_MISO1 22u // PA_22
#define PIN_MOSI0 23u // PA_23
Expand Down
14 changes: 7 additions & 7 deletions boards/variants/generic-rtl8710bn-2mb-788k.c
Original file line number Diff line number Diff line change
Expand Up @@ -12,18 +12,18 @@ PinInfo lt_arduino_pin_info_list[PINS_COUNT] = {
{PA_0, PIN_GPIO | PIN_IRQ | PIN_PWM, PIN_NONE, 0},
// D1: PA05, PWM4, WAKE1
{PA_5, PIN_GPIO | PIN_IRQ | PIN_PWM, PIN_NONE, 0},
// D2: PA06, FCS, SD_D2
{PA_6, PIN_GPIO | PIN_IRQ | PIN_SPI, PIN_NONE, 0},
// D2: PA06, ^FCS, SD_D2
{PA_6, PIN_GPIO | PIN_IRQ, PIN_NONE, 0},
// D3: PA07, FD1, SD_D3
{PA_7, PIN_GPIO | PIN_IRQ | PIN_SPI, PIN_NONE, 0},
{PA_7, PIN_GPIO | PIN_IRQ, PIN_NONE, 0},
// D4: PA08, FD2, SD_CMD
{PA_8, PIN_GPIO | PIN_IRQ | PIN_SPI, PIN_NONE, 0},
{PA_8, PIN_GPIO | PIN_IRQ, PIN_NONE, 0},
// D5: PA09, FD0, SD_CLK
{PA_9, PIN_GPIO | PIN_IRQ | PIN_SPI, PIN_NONE, 0},
{PA_9, PIN_GPIO | PIN_IRQ, PIN_NONE, 0},
// D6: PA10, FSCK, SD_D0
{PA_10, PIN_GPIO | PIN_IRQ | PIN_SPI, PIN_NONE, 0},
{PA_10, PIN_GPIO | PIN_IRQ, PIN_NONE, 0},
// D7: PA11, FD3, SD_D1
{PA_11, PIN_GPIO | PIN_IRQ | PIN_SPI, PIN_NONE, 0},
{PA_11, PIN_GPIO | PIN_IRQ, PIN_NONE, 0},
// D8: PA12, PWM3
{PA_12, PIN_GPIO | PIN_IRQ | PIN_PWM, PIN_NONE, 0},
// D9: PA14, PWM0, SWCLK
Expand Down
6 changes: 0 additions & 6 deletions boards/variants/generic-rtl8710bn-2mb-788k.h
Original file line number Diff line number Diff line change
Expand Up @@ -66,12 +66,6 @@
#define PIN_CS0 19u // PA_19
#define PIN_CS1 19u // PA_19
#define PIN_CTS0 19u // PA_19
#define PIN_FCS 6u // PA_6
#define PIN_FD0 9u // PA_9
#define PIN_FD1 7u // PA_7
#define PIN_FD2 8u // PA_8
#define PIN_FD3 11u // PA_11
#define PIN_FSCK 10u // PA_10
#define PIN_MISO0 22u // PA_22
#define PIN_MISO1 22u // PA_22
#define PIN_MOSI0 23u // PA_23
Expand Down
14 changes: 7 additions & 7 deletions boards/variants/generic-rtl8710bx-4mb-980k.c
Original file line number Diff line number Diff line change
Expand Up @@ -12,18 +12,18 @@ PinInfo lt_arduino_pin_info_list[PINS_COUNT] = {
{PA_0, PIN_GPIO | PIN_IRQ | PIN_PWM, PIN_NONE, 0},
// D1: PA05, PWM4, WAKE1
{PA_5, PIN_GPIO | PIN_IRQ | PIN_PWM, PIN_NONE, 0},
// D2: PA06, FCS, SD_D2
{PA_6, PIN_GPIO | PIN_IRQ | PIN_SPI, PIN_NONE, 0},
// D2: PA06, ^FCS, SD_D2
{PA_6, PIN_GPIO | PIN_IRQ, PIN_NONE, 0},
// D3: PA07, FD1, SD_D3
{PA_7, PIN_GPIO | PIN_IRQ | PIN_SPI, PIN_NONE, 0},
{PA_7, PIN_GPIO | PIN_IRQ, PIN_NONE, 0},
// D4: PA08, FD2, SD_CMD
{PA_8, PIN_GPIO | PIN_IRQ | PIN_SPI, PIN_NONE, 0},
{PA_8, PIN_GPIO | PIN_IRQ, PIN_NONE, 0},
// D5: PA09, FD0, SD_CLK
{PA_9, PIN_GPIO | PIN_IRQ | PIN_SPI, PIN_NONE, 0},
{PA_9, PIN_GPIO | PIN_IRQ, PIN_NONE, 0},
// D6: PA10, FSCK, SD_D0
{PA_10, PIN_GPIO | PIN_IRQ | PIN_SPI, PIN_NONE, 0},
{PA_10, PIN_GPIO | PIN_IRQ, PIN_NONE, 0},
// D7: PA11, FD3, SD_D1
{PA_11, PIN_GPIO | PIN_IRQ | PIN_SPI, PIN_NONE, 0},
{PA_11, PIN_GPIO | PIN_IRQ, PIN_NONE, 0},
// D8: PA12, PWM3
{PA_12, PIN_GPIO | PIN_IRQ | PIN_PWM, PIN_NONE, 0},
// D9: PA14, PWM0, SWCLK
Expand Down
6 changes: 0 additions & 6 deletions boards/variants/generic-rtl8710bx-4mb-980k.h
Original file line number Diff line number Diff line change
Expand Up @@ -65,12 +65,6 @@
#define PIN_CS0 19u // PA_19
#define PIN_CS1 19u // PA_19
#define PIN_CTS0 19u // PA_19
#define PIN_FCS 6u // PA_6
#define PIN_FD0 9u // PA_9
#define PIN_FD1 7u // PA_7
#define PIN_FD2 8u // PA_8
#define PIN_FD3 11u // PA_11
#define PIN_FSCK 10u // PA_10
#define PIN_MISO0 22u // PA_22
#define PIN_MISO1 22u // PA_22
#define PIN_MOSI0 23u // PA_23
Expand Down
4 changes: 2 additions & 2 deletions builder/utils/cores.py
Original file line number Diff line number Diff line change
Expand Up @@ -51,8 +51,8 @@ def env_add_core_sources(env: Environment, queue, name: str, path: str) -> bool:
"+<compat/*.c*>",
"+<port/*.c*>",
"+<posix/*.c>",
"+<wiring/*.c>",
"+<wraps/*.c>",
"+<wiring/*.c*>",
"+<wraps/*.c*>",
],
includes=[
# prepend the paths before SDK directories
Expand Down
Loading
Loading