[lightning-ln882h] Add support for Lightning LN882H family (#312)

* fix mbedtls bad pointer in function call (prototype mismatch)

* fix issue with weak families functions implemented in static library, it will never be linked. fixed by redefining prototypes inside families

* [ln882x] add support for lightning ln882x & ln882h families

* add i2c (wire) support

* add analog (adc) support

* add watchdog support

* [ln882x] changed default uart 0/1 pins; added board wl2s

* [ln882x] fix IRQ & ADC pins

* [ln882x] boards cosmetic

* [ln882x] wifi sta use otp mac addr by default; re-enabled wifi powersave mode

* [ln882x] clang-format clean code

* [ln882x] clang-format clean code

* Update families.json

* Apply suggestions from code review

* [ln882x] reformat json board files

* [ln882x] os_queue cleanup

* [ln882x] removed Beken auto-download command

* [ln882x] removed personal script file

* [ln882x] removed unusefull pi section in debugging.md

* [ln882x] removed Arduino.h and changed private I2C definition

* [ln882x] updated README.md

* [ln882x] changed pin naming scheme to PA/PB

* [ln882x] clean code

* [ln882x] clean code

* [ln882x] add ota image verification

* Update push-dev.yml

* [ln882x] fix boards ADC missing inputs]

* [ln882x] removed reg_xxx fixup files and use include guards instead

* [ln882x] cleanup code

* [ln882x] cleanup code

* [ln882x] fix lt_init weak functions linking

* [ln882x] revert lt_api.h modification, fixed with previous commit

* [ln882x] setup UF2 firmware for flasher with partitions

* [ln882x] update README.md

* [ln882x] include ln_wifi.h and ln_serial.h to avoid including bad headers on case insensitive systems

* [ln882x] Replace RingBuffer by SerialRingBuffer

* [ln882x] clang-format

* [ln882x] update README.md

* Apply suggestions from code review

* Reformat board JSON files

* Add mkdocs link redirect

* Update ltchiptool to v4.12.0

---------

Co-authored-by: Kuba Szczodrzyński <kuba@szczodrzynski.pl>
This commit is contained in:
lamauny
2025-03-25 17:26:53 +01:00
committed by GitHub
parent 6083cca72e
commit 69e7e2debe
73 changed files with 4856 additions and 28 deletions

42
boards/variants/ln-02.c Normal file
View File

@@ -0,0 +1,42 @@
/* This file was auto-generated from ln-02.json using boardgen */
#include <Arduino.h>
#ifdef LT_VARIANT_INCLUDE
#include LT_VARIANT_INCLUDE
#endif
// clang-format off
PinInfo lt_arduino_pin_info_list[PINS_COUNT] = {
// D0: PA11, SD_D1, I2C0_SCL, I2C0_SDA
{PA_11, PIN_I2C | PIN_GPIO, PIN_NONE, 0},
// D1: PB03, ADC5, I2C0_SCL, I2C0_SDA
{PB_3, PIN_I2C | PIN_ADC | PIN_GPIO, PIN_NONE, 0},
// D2: PA03, UART0_RX, I2C0_SCL, I2C0_SDA
{PA_3, PIN_UART | PIN_I2C | PIN_IRQ | PIN_GPIO, PIN_NONE, 0},
// D3: PB08, UART1_RX, I2C0_SCL, I2C0_SDA
{PB_8, PIN_UART | PIN_I2C | PIN_GPIO, PIN_NONE, 0},
// D4: PA02, UART0_TX, I2C0_SCL, I2C0_SDA
{PA_2, PIN_UART | PIN_I2C | PIN_IRQ | PIN_GPIO, PIN_NONE, 0},
// D5: PB09, UART1_TX, I2C0_SCL, I2C0_SDA
{PB_9, PIN_UART | PIN_I2C | PIN_IRQ | PIN_GPIO, PIN_NONE, 0},
// D6: PA01, ADC3, SWDIO, I2C0_SCL, I2C0_SDA
{PA_1, PIN_SWD | PIN_I2C | PIN_ADC | PIN_IRQ | PIN_GPIO, PIN_NONE, 0},
// D7: PA00, ADC2, I2C0_SCL, I2C0_SDA
{PA_0, PIN_I2C | PIN_ADC | PIN_IRQ | PIN_GPIO, PIN_NONE, 0},
// D8: PA09, BOOT1, SD_CLK, I2S0_SCLK, I2C0_SCL, I2C0_SDA
{PA_9, PIN_I2S | PIN_I2C | PIN_GPIO, PIN_NONE, 0},
};
PinInfo *lt_arduino_pin_gpio_map[] = {
[0] = &(lt_arduino_pin_info_list[7]), // PA_0 (D7)
[1] = &(lt_arduino_pin_info_list[6]), // PA_1 (D6)
[2] = &(lt_arduino_pin_info_list[4]), // PA_2 (D4)
[3] = &(lt_arduino_pin_info_list[2]), // PA_3 (D2)
[9] = &(lt_arduino_pin_info_list[8]), // PA_9 (D8)
[11] = &(lt_arduino_pin_info_list[0]), // PA_11 (D0)
[19] = &(lt_arduino_pin_info_list[1]), // PB_3 (D1)
[24] = &(lt_arduino_pin_info_list[3]), // PB_8 (D3)
[25] = &(lt_arduino_pin_info_list[5]), // PB_9 (D5)
};
// clang-format on

106
boards/variants/ln-02.h Normal file
View File

@@ -0,0 +1,106 @@
/* This file was auto-generated from ln-02.json using boardgen */
#pragma once
// clang-format off
// Pins
// ----
#define PINS_COUNT 9 // Total GPIO count
#define NUM_DIGITAL_PINS 9 // Digital inputs/outputs
#define NUM_ANALOG_INPUTS 3 // ADC inputs
#define NUM_ANALOG_OUTPUTS 0 // PWM & DAC outputs
#define PINS_GPIO_MAX 25 // Last usable GPIO number
// Wire Interfaces
// ---------------
#define PIN_WIRE0_SCL_0 11u // PA_11
#define PIN_WIRE0_SCL_1 19u // PB_3
#define PIN_WIRE0_SCL_2 3u // PA_3
#define PIN_WIRE0_SCL_3 24u // PB_8
#define PIN_WIRE0_SCL_4 2u // PA_2
#define PIN_WIRE0_SCL_5 25u // PB_9
#define PIN_WIRE0_SCL_6 1u // PA_1
#define PIN_WIRE0_SCL_7 0u // PA_0
#define PIN_WIRE0_SCL_8 9u // PA_9
#define PIN_WIRE0_SDA_0 11u // PA_11
#define PIN_WIRE0_SDA_1 19u // PB_3
#define PIN_WIRE0_SDA_2 3u // PA_3
#define PIN_WIRE0_SDA_3 24u // PB_8
#define PIN_WIRE0_SDA_4 2u // PA_2
#define PIN_WIRE0_SDA_5 25u // PB_9
#define PIN_WIRE0_SDA_6 1u // PA_1
#define PIN_WIRE0_SDA_7 0u // PA_0
#define PIN_WIRE0_SDA_8 9u // PA_9
#define PINS_WIRE0_SCL (pin_size_t[]){11u, 19u, 3u, 24u, 2u, 25u, 1u, 0u, 9u}
#define PINS_WIRE0_SDA (pin_size_t[]){11u, 19u, 3u, 24u, 2u, 25u, 1u, 0u, 9u}
// Serial ports
// ------------
#define PIN_SERIAL0_RX 3u // PA_3
#define PIN_SERIAL0_TX 2u // PA_2
#define PIN_SERIAL1_RX 24u // PB_8
#define PIN_SERIAL1_TX 25u // PB_9
#define PINS_SERIAL0_RX (pin_size_t[]){3u}
#define PINS_SERIAL0_TX (pin_size_t[]){2u}
#define PINS_SERIAL1_RX (pin_size_t[]){24u}
#define PINS_SERIAL1_TX (pin_size_t[]){25u}
// Pin function macros
// -------------------
#define PIN_ADC2 0u // PA_0
#define PIN_ADC3 1u // PA_1
#define PIN_ADC5 19u // PB_3
#define PIN_PA00 0u // PA_0
#define PIN_PA01 1u // PA_1
#define PIN_PA02 2u // PA_2
#define PIN_PA03 3u // PA_3
#define PIN_PA09 9u // PA_9
#define PIN_PA11 11u // PA_11
#define PIN_PB03 19u // PB_3
#define PIN_PB08 24u // PB_8
#define PIN_PB09 25u // PB_9
#define PIN_RX0 3u // PA_3
#define PIN_RX1 24u // PB_8
#define PIN_SCL0 9u // PA_9
#define PIN_SDA0 9u // PA_9
#define PIN_TX0 2u // PA_2
#define PIN_TX1 25u // PB_9
// Port availability
// -----------------
#define HAS_SERIAL0 1
#define HAS_SERIAL1 1
#define HAS_WIRE0 1
#define SERIAL_INTERFACES_COUNT 2
#define WIRE_INTERFACES_COUNT 1
// Arduino pin names
// -----------------
#define PIN_D0 11u // PA_11
#define PIN_D1 19u // PB_3
#define PIN_D2 3u // PA_3
#define PIN_D3 24u // PB_8
#define PIN_D4 2u // PA_2
#define PIN_D5 25u // PB_9
#define PIN_D6 1u // PA_1
#define PIN_D7 0u // PA_0
#define PIN_D8 9u // PA_9
#define PIN_A0 19u // PB_3
#define PIN_A1 1u // PA_1
#define PIN_A2 0u // PA_0
// Static pin names
// ----------------
static const unsigned char A0 = PIN_A0;
static const unsigned char A1 = PIN_A1;
static const unsigned char A2 = PIN_A2;
static const unsigned char D0 = PIN_D0;
static const unsigned char D1 = PIN_D1;
static const unsigned char D2 = PIN_D2;
static const unsigned char D3 = PIN_D3;
static const unsigned char D4 = PIN_D4;
static const unsigned char D5 = PIN_D5;
static const unsigned char D6 = PIN_D6;
static const unsigned char D7 = PIN_D7;
static const unsigned char D8 = PIN_D8;

54
boards/variants/wl2s.c Normal file
View File

@@ -0,0 +1,54 @@
/* This file was auto-generated from wl2s.json using boardgen */
#include <Arduino.h>
#ifdef LT_VARIANT_INCLUDE
#include LT_VARIANT_INCLUDE
#endif
// clang-format off
PinInfo lt_arduino_pin_info_list[PINS_COUNT] = {
// D0: PA07, SD_D3, I2S0_RX, I2C0_SCL, I2C0_SDA
{PA_7, PIN_I2S | PIN_I2C | PIN_IRQ | PIN_GPIO, PIN_NONE, 0},
// D1: PA12, I2C0_SCL, I2C0_SDA
{PA_12, PIN_I2C | PIN_GPIO, PIN_NONE, 0},
// D2: PA03, UART0_RX, I2C0_SCL, I2C0_SDA
{PA_3, PIN_UART | PIN_I2C | PIN_IRQ | PIN_GPIO, PIN_NONE, 0},
// D3: PA10, SD_D0, I2S0_TX, I2C0_SCL, I2C0_SDA
{PA_10, PIN_I2S | PIN_I2C | PIN_GPIO, PIN_NONE, 0},
// D4: PA02, UART0_TX, I2C0_SCL, I2C0_SDA
{PA_2, PIN_UART | PIN_I2C | PIN_IRQ | PIN_GPIO, PIN_NONE, 0},
// D5: PA00, ADC2, I2C0_SCL, I2C0_SDA
{PA_0, PIN_I2C | PIN_ADC | PIN_IRQ | PIN_GPIO, PIN_NONE, 0},
// D6: PB03, ADC5, I2C0_SCL, I2C0_SDA
{PB_3, PIN_I2C | PIN_ADC | PIN_GPIO, PIN_NONE, 0},
// D7: PA11, SD_D1, I2C0_SCL, I2C0_SDA
{PA_11, PIN_I2C | PIN_GPIO, PIN_NONE, 0},
// D8: PA09, BOOT1, SD_CLK, I2S0_SCLK, I2C0_SCL, I2C0_SDA
{PA_9, PIN_I2S | PIN_I2C | PIN_GPIO, PIN_NONE, 0},
// D9: PB08, UART1_RX, I2C0_SCL, I2C0_SDA
{PB_8, PIN_UART | PIN_I2C | PIN_GPIO, PIN_NONE, 0},
// D10: PB09, UART1_TX, I2C0_SCL, I2C0_SDA
{PB_9, PIN_UART | PIN_I2C | PIN_IRQ | PIN_GPIO, PIN_NONE, 0},
// D11: PA05, I2C0_SCL, I2C0_SDA
{PA_5, PIN_I2C | PIN_IRQ | PIN_GPIO, PIN_NONE, 0},
// D12: PA01, ADC3, SWDIO, I2C0_SCL, I2C0_SDA
{PA_1, PIN_SWD | PIN_I2C | PIN_ADC | PIN_IRQ | PIN_GPIO, PIN_NONE, 0},
};
PinInfo *lt_arduino_pin_gpio_map[] = {
[0] = &(lt_arduino_pin_info_list[5]), // PA_0 (D5)
[1] = &(lt_arduino_pin_info_list[12]), // PA_1 (D12)
[2] = &(lt_arduino_pin_info_list[4]), // PA_2 (D4)
[3] = &(lt_arduino_pin_info_list[2]), // PA_3 (D2)
[5] = &(lt_arduino_pin_info_list[11]), // PA_5 (D11)
[7] = &(lt_arduino_pin_info_list[0]), // PA_7 (D0)
[9] = &(lt_arduino_pin_info_list[8]), // PA_9 (D8)
[10] = &(lt_arduino_pin_info_list[3]), // PA_10 (D3)
[11] = &(lt_arduino_pin_info_list[7]), // PA_11 (D7)
[12] = &(lt_arduino_pin_info_list[1]), // PA_12 (D1)
[19] = &(lt_arduino_pin_info_list[6]), // PB_3 (D6)
[24] = &(lt_arduino_pin_info_list[9]), // PB_8 (D9)
[25] = &(lt_arduino_pin_info_list[10]), // PB_9 (D10)
};
// clang-format on

126
boards/variants/wl2s.h Normal file
View File

@@ -0,0 +1,126 @@
/* This file was auto-generated from wl2s.json using boardgen */
#pragma once
// clang-format off
// Pins
// ----
#define PINS_COUNT 13 // Total GPIO count
#define NUM_DIGITAL_PINS 13 // Digital inputs/outputs
#define NUM_ANALOG_INPUTS 3 // ADC inputs
#define NUM_ANALOG_OUTPUTS 0 // PWM & DAC outputs
#define PINS_GPIO_MAX 25 // Last usable GPIO number
// Wire Interfaces
// ---------------
#define PIN_WIRE0_SCL_0 7u // PA_7
#define PIN_WIRE0_SCL_1 12u // PA_12
#define PIN_WIRE0_SCL_2 3u // PA_3
#define PIN_WIRE0_SCL_3 10u // PA_10
#define PIN_WIRE0_SCL_4 2u // PA_2
#define PIN_WIRE0_SCL_5 0u // PA_0
#define PIN_WIRE0_SCL_6 19u // PB_3
#define PIN_WIRE0_SCL_7 11u // PA_11
#define PIN_WIRE0_SCL_8 9u // PA_9
#define PIN_WIRE0_SCL_9 24u // PB_8
#define PIN_WIRE0_SCL_10 25u // PB_9
#define PIN_WIRE0_SCL_11 5u // PA_5
#define PIN_WIRE0_SCL_12 1u // PA_1
#define PIN_WIRE0_SDA_0 7u // PA_7
#define PIN_WIRE0_SDA_1 12u // PA_12
#define PIN_WIRE0_SDA_2 3u // PA_3
#define PIN_WIRE0_SDA_3 10u // PA_10
#define PIN_WIRE0_SDA_4 2u // PA_2
#define PIN_WIRE0_SDA_5 0u // PA_0
#define PIN_WIRE0_SDA_6 19u // PB_3
#define PIN_WIRE0_SDA_7 11u // PA_11
#define PIN_WIRE0_SDA_8 9u // PA_9
#define PIN_WIRE0_SDA_9 24u // PB_8
#define PIN_WIRE0_SDA_10 25u // PB_9
#define PIN_WIRE0_SDA_11 5u // PA_5
#define PIN_WIRE0_SDA_12 1u // PA_1
#define PINS_WIRE0_SCL (pin_size_t[]){7u, 12u, 3u, 10u, 2u, 0u, 19u, 11u, 9u, 24u, 25u, 5u, 1u}
#define PINS_WIRE0_SDA (pin_size_t[]){7u, 12u, 3u, 10u, 2u, 0u, 19u, 11u, 9u, 24u, 25u, 5u, 1u}
// Serial ports
// ------------
#define PIN_SERIAL0_RX 3u // PA_3
#define PIN_SERIAL0_TX 2u // PA_2
#define PIN_SERIAL1_RX 24u // PB_8
#define PIN_SERIAL1_TX 25u // PB_9
#define PINS_SERIAL0_RX (pin_size_t[]){3u}
#define PINS_SERIAL0_TX (pin_size_t[]){2u}
#define PINS_SERIAL1_RX (pin_size_t[]){24u}
#define PINS_SERIAL1_TX (pin_size_t[]){25u}
// Pin function macros
// -------------------
#define PIN_ADC2 0u // PA_0
#define PIN_ADC3 1u // PA_1
#define PIN_ADC5 19u // PB_3
#define PIN_PA00 0u // PA_0
#define PIN_PA01 1u // PA_1
#define PIN_PA02 2u // PA_2
#define PIN_PA03 3u // PA_3
#define PIN_PA05 5u // PA_5
#define PIN_PA07 7u // PA_7
#define PIN_PA09 9u // PA_9
#define PIN_PA10 10u // PA_10
#define PIN_PA11 11u // PA_11
#define PIN_PA12 12u // PA_12
#define PIN_PB03 19u // PB_3
#define PIN_PB08 24u // PB_8
#define PIN_PB09 25u // PB_9
#define PIN_RX0 3u // PA_3
#define PIN_RX1 24u // PB_8
#define PIN_SCL0 1u // PA_1
#define PIN_SDA0 1u // PA_1
#define PIN_TX0 2u // PA_2
#define PIN_TX1 25u // PB_9
// Port availability
// -----------------
#define HAS_SERIAL0 1
#define HAS_SERIAL1 1
#define HAS_WIRE0 1
#define SERIAL_INTERFACES_COUNT 2
#define WIRE_INTERFACES_COUNT 1
// Arduino pin names
// -----------------
#define PIN_D0 7u // PA_7
#define PIN_D1 12u // PA_12
#define PIN_D2 3u // PA_3
#define PIN_D3 10u // PA_10
#define PIN_D4 2u // PA_2
#define PIN_D5 0u // PA_0
#define PIN_D6 19u // PB_3
#define PIN_D7 11u // PA_11
#define PIN_D8 9u // PA_9
#define PIN_D9 24u // PB_8
#define PIN_D10 25u // PB_9
#define PIN_D11 5u // PA_5
#define PIN_D12 1u // PA_1
#define PIN_A0 0u // PA_0
#define PIN_A1 19u // PB_3
#define PIN_A2 1u // PA_1
// Static pin names
// ----------------
static const unsigned char A0 = PIN_A0;
static const unsigned char A1 = PIN_A1;
static const unsigned char A2 = PIN_A2;
static const unsigned char D0 = PIN_D0;
static const unsigned char D1 = PIN_D1;
static const unsigned char D2 = PIN_D2;
static const unsigned char D3 = PIN_D3;
static const unsigned char D4 = PIN_D4;
static const unsigned char D5 = PIN_D5;
static const unsigned char D6 = PIN_D6;
static const unsigned char D7 = PIN_D7;
static const unsigned char D8 = PIN_D8;
static const unsigned char D9 = PIN_D9;
static const unsigned char D10 = PIN_D10;
static const unsigned char D11 = PIN_D11;
static const unsigned char D12 = PIN_D12;