[lightning-ln882h] Fix analog read, add Wi-Fi calibration, add generic board (#319)
* [ln882x] fix analog read * [ln882h] add wifi temp calibration task * [ln882h] add generic-ln882hki board * [ln882h] fix wifi null pointer crash
This commit is contained in:
118
boards/generic-ln882hki.json
Normal file
118
boards/generic-ln882hki.json
Normal file
@@ -0,0 +1,118 @@
|
||||
{
|
||||
"_base": [
|
||||
"generic",
|
||||
"lightning-ln882x",
|
||||
"lightning-ln882hki",
|
||||
"ic/ln882hk"
|
||||
],
|
||||
"build": {
|
||||
"mcu": "ln882hk",
|
||||
"variant": "generic-ln882hki"
|
||||
},
|
||||
"name": "Generic - LN882HKI",
|
||||
"symbol": "LN882HKI",
|
||||
"url": "https://docs.libretiny.eu/boards/generic-ln882hki/",
|
||||
"vendor": "Generic",
|
||||
"pcb": {
|
||||
"pinout": {
|
||||
"1": {
|
||||
"IC": 8,
|
||||
"ARD": [
|
||||
"D0",
|
||||
"A2"
|
||||
]
|
||||
},
|
||||
"2": {
|
||||
"IC": 9,
|
||||
"ARD": [
|
||||
"D1",
|
||||
"A3"
|
||||
]
|
||||
},
|
||||
"3": {
|
||||
"IC": 10,
|
||||
"ARD": "D2"
|
||||
},
|
||||
"4": {
|
||||
"IC": 11,
|
||||
"ARD": "D3"
|
||||
},
|
||||
"5": {
|
||||
"IC": 12,
|
||||
"ARD": [
|
||||
"D4",
|
||||
"A4"
|
||||
]
|
||||
},
|
||||
"6": {
|
||||
"IC": 13,
|
||||
"ARD": "D5"
|
||||
},
|
||||
"7": {
|
||||
"IC": 14,
|
||||
"ARD": "D6"
|
||||
},
|
||||
"8": {
|
||||
"IC": 15,
|
||||
"ARD": "D7"
|
||||
},
|
||||
"9": {
|
||||
"IC": 16,
|
||||
"ARD": "D8"
|
||||
},
|
||||
"10": {
|
||||
"IC": 17,
|
||||
"ARD": "D9"
|
||||
},
|
||||
"11": {
|
||||
"IC": 21,
|
||||
"ARD": "D10"
|
||||
},
|
||||
"12": {
|
||||
"IC": 22,
|
||||
"ARD": "D11"
|
||||
},
|
||||
"13": {
|
||||
"IC": 23,
|
||||
"ARD": "D12"
|
||||
},
|
||||
"14": {
|
||||
"IC": 24,
|
||||
"ARD": [
|
||||
"D13",
|
||||
"A5"
|
||||
]
|
||||
},
|
||||
"15": {
|
||||
"IC": 25,
|
||||
"ARD": [
|
||||
"D14",
|
||||
"A6"
|
||||
]
|
||||
},
|
||||
"16": {
|
||||
"IC": 26,
|
||||
"ARD": [
|
||||
"D15",
|
||||
"A7"
|
||||
]
|
||||
},
|
||||
"17": {
|
||||
"IC": 27,
|
||||
"ARD": "D16"
|
||||
},
|
||||
"18": {
|
||||
"IC": 28,
|
||||
"ARD": "D17"
|
||||
},
|
||||
"19": {
|
||||
"IC": 29,
|
||||
"ARD": "D18"
|
||||
},
|
||||
"20": {
|
||||
"IC": 30,
|
||||
"ARD": "D19"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
75
boards/variants/generic-ln882hki.c
Normal file
75
boards/variants/generic-ln882hki.c
Normal file
@@ -0,0 +1,75 @@
|
||||
/* This file was auto-generated from generic-ln882hki.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: PA00, ADC2, I2C0_SCL, I2C0_SDA
|
||||
{PA_0, PIN_I2C | PIN_ADC | PIN_IRQ | PIN_GPIO, PIN_NONE, 0},
|
||||
// D1: PA01, ADC3, SWDIO, I2C0_SCL, I2C0_SDA
|
||||
{PA_1, PIN_SWD | PIN_I2C | PIN_ADC | PIN_IRQ | PIN_GPIO, PIN_NONE, 0},
|
||||
// D2: PA02, UART0_TX, I2C0_SCL, I2C0_SDA
|
||||
{PA_2, PIN_UART | PIN_I2C | PIN_IRQ | PIN_GPIO, PIN_NONE, 0},
|
||||
// D3: PA03, UART0_RX, I2C0_SCL, I2C0_SDA
|
||||
{PA_3, PIN_UART | PIN_I2C | PIN_IRQ | PIN_GPIO, PIN_NONE, 0},
|
||||
// D4: PA04, ADC4, SWCLK, I2C0_SCL, I2C0_SDA
|
||||
{PA_4, PIN_SWD | PIN_I2C | PIN_ADC | PIN_GPIO, PIN_NONE, 0},
|
||||
// D5: PA05, I2C0_SCL, I2C0_SDA
|
||||
{PA_5, PIN_I2C | PIN_IRQ | PIN_GPIO, PIN_NONE, 0},
|
||||
// D6: PA06, SD_D2, I2C0_SCL, I2C0_SDA
|
||||
{PA_6, PIN_I2C | PIN_IRQ | PIN_GPIO, PIN_NONE, 0},
|
||||
// D7: PA07, SD_D3, I2S0_RX, I2C0_SCL, I2C0_SDA
|
||||
{PA_7, PIN_I2S | PIN_I2C | PIN_IRQ | PIN_GPIO, PIN_NONE, 0},
|
||||
// D8: PA08, BOOT0, SD_CMD, I2S0_WS, I2C0_SCL, I2C0_SDA
|
||||
{PA_8, PIN_I2S | PIN_I2C | PIN_GPIO, PIN_NONE, 0},
|
||||
// D9: PA09, BOOT1, SD_CLK, I2S0_SCLK, I2C0_SCL, I2C0_SDA
|
||||
{PA_9, PIN_I2S | PIN_I2C | PIN_GPIO, PIN_NONE, 0},
|
||||
// D10: PA10, SD_D0, I2S0_TX, I2C0_SCL, I2C0_SDA
|
||||
{PA_10, PIN_I2S | PIN_I2C | PIN_GPIO, PIN_NONE, 0},
|
||||
// D11: PA11, SD_D1, I2C0_SCL, I2C0_SDA
|
||||
{PA_11, PIN_I2C | PIN_GPIO, PIN_NONE, 0},
|
||||
// D12: PA12, I2C0_SCL, I2C0_SDA
|
||||
{PA_12, PIN_I2C | PIN_GPIO, PIN_NONE, 0},
|
||||
// D13: PB03, ADC5, I2C0_SCL, I2C0_SDA
|
||||
{PB_3, PIN_I2C | PIN_ADC | PIN_GPIO, PIN_NONE, 0},
|
||||
// D14: PB04, ADC6, I2C0_SCL, I2C0_SDA
|
||||
{PB_4, PIN_I2C | PIN_ADC | PIN_GPIO, PIN_NONE, 0},
|
||||
// D15: PB05, ADC7, I2C0_SCL, I2C0_SDA
|
||||
{PB_5, PIN_I2C | PIN_ADC | PIN_GPIO, PIN_NONE, 0},
|
||||
// D16: PB06, I2C0_SCL, I2C0_SDA
|
||||
{PB_6, PIN_I2C | PIN_GPIO, PIN_NONE, 0},
|
||||
// D17: PB07, I2C0_SCL, I2C0_SDA
|
||||
{PB_7, PIN_I2C | PIN_GPIO, PIN_NONE, 0},
|
||||
// D18: PB08, UART1_RX, I2C0_SCL, I2C0_SDA
|
||||
{PB_8, PIN_UART | PIN_I2C | PIN_GPIO, PIN_NONE, 0},
|
||||
// D19: PB09, UART1_TX, I2C0_SCL, I2C0_SDA
|
||||
{PB_9, PIN_UART | PIN_I2C | PIN_IRQ | PIN_GPIO, PIN_NONE, 0},
|
||||
};
|
||||
|
||||
PinInfo *lt_arduino_pin_gpio_map[] = {
|
||||
[0] = &(lt_arduino_pin_info_list[0]), // PA_0 (D0)
|
||||
[1] = &(lt_arduino_pin_info_list[1]), // PA_1 (D1)
|
||||
[2] = &(lt_arduino_pin_info_list[2]), // PA_2 (D2)
|
||||
[3] = &(lt_arduino_pin_info_list[3]), // PA_3 (D3)
|
||||
[4] = &(lt_arduino_pin_info_list[4]), // PA_4 (D4)
|
||||
[5] = &(lt_arduino_pin_info_list[5]), // PA_5 (D5)
|
||||
[6] = &(lt_arduino_pin_info_list[6]), // PA_6 (D6)
|
||||
[7] = &(lt_arduino_pin_info_list[7]), // PA_7 (D7)
|
||||
[8] = &(lt_arduino_pin_info_list[8]), // PA_8 (D8)
|
||||
[9] = &(lt_arduino_pin_info_list[9]), // PA_9 (D9)
|
||||
[10] = &(lt_arduino_pin_info_list[10]), // PA_10 (D10)
|
||||
[11] = &(lt_arduino_pin_info_list[11]), // PA_11 (D11)
|
||||
[12] = &(lt_arduino_pin_info_list[12]), // PA_12 (D12)
|
||||
[19] = &(lt_arduino_pin_info_list[13]), // PB_3 (D13)
|
||||
[20] = &(lt_arduino_pin_info_list[14]), // PB_4 (D14)
|
||||
[21] = &(lt_arduino_pin_info_list[15]), // PB_5 (D15)
|
||||
[22] = &(lt_arduino_pin_info_list[16]), // PB_6 (D16)
|
||||
[23] = &(lt_arduino_pin_info_list[17]), // PB_7 (D17)
|
||||
[24] = &(lt_arduino_pin_info_list[18]), // PB_8 (D18)
|
||||
[25] = &(lt_arduino_pin_info_list[19]), // PB_9 (D19)
|
||||
};
|
||||
// clang-format on
|
||||
168
boards/variants/generic-ln882hki.h
Normal file
168
boards/variants/generic-ln882hki.h
Normal file
@@ -0,0 +1,168 @@
|
||||
/* This file was auto-generated from generic-ln882hki.json using boardgen */
|
||||
|
||||
#pragma once
|
||||
|
||||
// clang-format off
|
||||
|
||||
// Pins
|
||||
// ----
|
||||
#define PINS_COUNT 20 // Total GPIO count
|
||||
#define NUM_DIGITAL_PINS 20 // Digital inputs/outputs
|
||||
#define NUM_ANALOG_INPUTS 6 // 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 0u // PA_0
|
||||
#define PIN_WIRE0_SCL_1 1u // PA_1
|
||||
#define PIN_WIRE0_SCL_2 2u // PA_2
|
||||
#define PIN_WIRE0_SCL_3 3u // PA_3
|
||||
#define PIN_WIRE0_SCL_4 4u // PA_4
|
||||
#define PIN_WIRE0_SCL_5 5u // PA_5
|
||||
#define PIN_WIRE0_SCL_6 6u // PA_6
|
||||
#define PIN_WIRE0_SCL_7 7u // PA_7
|
||||
#define PIN_WIRE0_SCL_8 8u // PA_8
|
||||
#define PIN_WIRE0_SCL_9 9u // PA_9
|
||||
#define PIN_WIRE0_SCL_10 10u // PA_10
|
||||
#define PIN_WIRE0_SCL_11 11u // PA_11
|
||||
#define PIN_WIRE0_SCL_12 12u // PA_12
|
||||
#define PIN_WIRE0_SCL_13 19u // PB_3
|
||||
#define PIN_WIRE0_SCL_14 20u // PB_4
|
||||
#define PIN_WIRE0_SCL_15 21u // PB_5
|
||||
#define PIN_WIRE0_SCL_16 22u // PB_6
|
||||
#define PIN_WIRE0_SCL_17 23u // PB_7
|
||||
#define PIN_WIRE0_SCL_18 24u // PB_8
|
||||
#define PIN_WIRE0_SCL_19 25u // PB_9
|
||||
#define PIN_WIRE0_SDA_0 0u // PA_0
|
||||
#define PIN_WIRE0_SDA_1 1u // PA_1
|
||||
#define PIN_WIRE0_SDA_2 2u // PA_2
|
||||
#define PIN_WIRE0_SDA_3 3u // PA_3
|
||||
#define PIN_WIRE0_SDA_4 4u // PA_4
|
||||
#define PIN_WIRE0_SDA_5 5u // PA_5
|
||||
#define PIN_WIRE0_SDA_6 6u // PA_6
|
||||
#define PIN_WIRE0_SDA_7 7u // PA_7
|
||||
#define PIN_WIRE0_SDA_8 8u // PA_8
|
||||
#define PIN_WIRE0_SDA_9 9u // PA_9
|
||||
#define PIN_WIRE0_SDA_10 10u // PA_10
|
||||
#define PIN_WIRE0_SDA_11 11u // PA_11
|
||||
#define PIN_WIRE0_SDA_12 12u // PA_12
|
||||
#define PIN_WIRE0_SDA_13 19u // PB_3
|
||||
#define PIN_WIRE0_SDA_14 20u // PB_4
|
||||
#define PIN_WIRE0_SDA_15 21u // PB_5
|
||||
#define PIN_WIRE0_SDA_16 22u // PB_6
|
||||
#define PIN_WIRE0_SDA_17 23u // PB_7
|
||||
#define PIN_WIRE0_SDA_18 24u // PB_8
|
||||
#define PIN_WIRE0_SDA_19 25u // PB_9
|
||||
#define PINS_WIRE0_SCL (pin_size_t[]){0u, 1u, 2u, 3u, 4u, 5u, 6u, 7u, 8u, 9u, 10u, 11u, 12u, 19u, 20u, 21u, 22u, 23u, 24u, 25u}
|
||||
#define PINS_WIRE0_SDA (pin_size_t[]){0u, 1u, 2u, 3u, 4u, 5u, 6u, 7u, 8u, 9u, 10u, 11u, 12u, 19u, 20u, 21u, 22u, 23u, 24u, 25u}
|
||||
|
||||
// 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_ADC4 4u // PA_4
|
||||
#define PIN_ADC5 19u // PB_3
|
||||
#define PIN_ADC6 20u // PB_4
|
||||
#define PIN_ADC7 21u // PB_5
|
||||
#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_PA04 4u // PA_4
|
||||
#define PIN_PA05 5u // PA_5
|
||||
#define PIN_PA06 6u // PA_6
|
||||
#define PIN_PA07 7u // PA_7
|
||||
#define PIN_PA08 8u // PA_8
|
||||
#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_PB04 20u // PB_4
|
||||
#define PIN_PB05 21u // PB_5
|
||||
#define PIN_PB06 22u // PB_6
|
||||
#define PIN_PB07 23u // PB_7
|
||||
#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_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 0u // PA_0
|
||||
#define PIN_D1 1u // PA_1
|
||||
#define PIN_D2 2u // PA_2
|
||||
#define PIN_D3 3u // PA_3
|
||||
#define PIN_D4 4u // PA_4
|
||||
#define PIN_D5 5u // PA_5
|
||||
#define PIN_D6 6u // PA_6
|
||||
#define PIN_D7 7u // PA_7
|
||||
#define PIN_D8 8u // PA_8
|
||||
#define PIN_D9 9u // PA_9
|
||||
#define PIN_D10 10u // PA_10
|
||||
#define PIN_D11 11u // PA_11
|
||||
#define PIN_D12 12u // PA_12
|
||||
#define PIN_D13 19u // PB_3
|
||||
#define PIN_D14 20u // PB_4
|
||||
#define PIN_D15 21u // PB_5
|
||||
#define PIN_D16 22u // PB_6
|
||||
#define PIN_D17 23u // PB_7
|
||||
#define PIN_D18 24u // PB_8
|
||||
#define PIN_D19 25u // PB_9
|
||||
#define PIN_A2 0u // PA_0
|
||||
#define PIN_A3 1u // PA_1
|
||||
#define PIN_A4 4u // PA_4
|
||||
#define PIN_A5 19u // PB_3
|
||||
#define PIN_A6 20u // PB_4
|
||||
#define PIN_A7 21u // PB_5
|
||||
|
||||
// Static pin names
|
||||
// ----------------
|
||||
static const unsigned char A2 = PIN_A2;
|
||||
static const unsigned char A3 = PIN_A3;
|
||||
static const unsigned char A4 = PIN_A4;
|
||||
static const unsigned char A5 = PIN_A5;
|
||||
static const unsigned char A6 = PIN_A6;
|
||||
static const unsigned char A7 = PIN_A7;
|
||||
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;
|
||||
static const unsigned char D13 = PIN_D13;
|
||||
static const unsigned char D14 = PIN_D14;
|
||||
static const unsigned char D15 = PIN_D15;
|
||||
static const unsigned char D16 = PIN_D16;
|
||||
static const unsigned char D17 = PIN_D17;
|
||||
static const unsigned char D18 = PIN_D18;
|
||||
static const unsigned char D19 = PIN_D19;
|
||||
Reference in New Issue
Block a user