[core] Migrate to auto-generated variant definitions
This commit is contained in:
@@ -6,6 +6,40 @@
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#define PIN_NONE (1 << 0)
|
||||
#define PIN_GPIO (1 << 1)
|
||||
#define PIN_IRQ (1 << 2)
|
||||
#define PIN_PWM (1 << 3)
|
||||
#define PIN_ADC (1 << 4)
|
||||
#define PIN_DAC (1 << 5)
|
||||
#define PIN_I2C (1 << 6)
|
||||
#define PIN_I2S (1 << 7)
|
||||
#define PIN_JTAG (1 << 8)
|
||||
#define PIN_SPI (1 << 9)
|
||||
#define PIN_SWD (1 << 10)
|
||||
#define PIN_UART (1 << 11)
|
||||
|
||||
typedef struct {
|
||||
/**
|
||||
* @brief GPIO name in the family SDK.
|
||||
*/
|
||||
uint32_t gpio;
|
||||
/**
|
||||
* @brief Supported pin features.
|
||||
*/
|
||||
uint32_t features;
|
||||
/**
|
||||
* @brief Enabled pin features. Used values are family-specific.
|
||||
*/
|
||||
uint32_t types;
|
||||
/**
|
||||
* @brief Pin mode (direction, IRQ level, etc.).
|
||||
*/
|
||||
uint32_t mode;
|
||||
} PinInfo;
|
||||
|
||||
extern PinInfo pinTable[];
|
||||
|
||||
/**
|
||||
* @brief Read voltage from analog input (in millivolts).
|
||||
*/
|
||||
|
||||
@@ -11,19 +11,12 @@
|
||||
#include <core/LibreTuyaAPI.h>
|
||||
#undef PinMode
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" uint32_t SystemCoreClock;
|
||||
#else
|
||||
extern uint32_t SystemCoreClock;
|
||||
#endif
|
||||
#define clockCyclesPerMicrosecond() (SystemCoreClock / 1000000L)
|
||||
#define clockCyclesToMicroseconds(a) (((a)*1000L) / (SystemCoreClock / 1000L))
|
||||
#define microsecondsToClockCycles(a) ((a) * (SystemCoreClock / 1000000L))
|
||||
|
||||
#define interrupts() vPortClearInterruptMask(0)
|
||||
#define noInterrupts() ulPortSetInterruptMask()
|
||||
|
||||
// Include family-specific code
|
||||
#include "WVariant.h"
|
||||
// Include board variant
|
||||
#include "variant.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
#include "LOGUARTClass.h"
|
||||
extern LOGUARTClass Serial;
|
||||
#endif
|
||||
|
||||
@@ -30,28 +30,27 @@ void attachInterruptParam(pin_size_t interruptNumber, voidFuncPtrParam callback,
|
||||
gpio_irq_handler_list[interruptNumber] = callback;
|
||||
gpio_irq_handler_args[interruptNumber] = param;
|
||||
|
||||
if (g_APinDescription[interruptNumber].ulPinType == PIO_GPIO_IRQ &&
|
||||
g_APinDescription[interruptNumber].ulPinMode == mode)
|
||||
if (pinTable[interruptNumber].types == PIN_IRQ && pinTable[interruptNumber].mode == mode)
|
||||
// Nothing changes in pin mode
|
||||
return;
|
||||
|
||||
if (g_APinDescription[interruptNumber].ulPinType != PIO_GPIO_IRQ)
|
||||
if (pinTable[interruptNumber].types != PIN_IRQ)
|
||||
// pin mode changes; deinit gpio and free memory
|
||||
pinRemoveMode(interruptNumber);
|
||||
|
||||
gpio_irq_t *gpio;
|
||||
|
||||
if (g_APinDescription[interruptNumber].ulPinType == NOT_INITIAL) {
|
||||
if (pinTable[interruptNumber].types == PIN_NONE) {
|
||||
// allocate memory if pin not used before
|
||||
gpio = malloc(sizeof(gpio_irq_t));
|
||||
gpio_pin_struct[interruptNumber] = gpio;
|
||||
gpio_irq_init(gpio, g_APinDescription[interruptNumber].pinname, gpioIrqHandler, interruptNumber);
|
||||
g_APinDescription[interruptNumber].ulPinType = PIO_GPIO_IRQ;
|
||||
gpio_irq_init(gpio, pinTable[interruptNumber].gpio, gpioIrqHandler, interruptNumber);
|
||||
pinTable[interruptNumber].types = PIN_IRQ;
|
||||
} else {
|
||||
// pin already used as irq
|
||||
gpio = (gpio_irq_t *)gpio_pin_struct[interruptNumber];
|
||||
}
|
||||
g_APinDescription[interruptNumber].ulPinMode = mode;
|
||||
pinTable[interruptNumber].mode = mode;
|
||||
|
||||
gpio_irq_event event;
|
||||
|
||||
@@ -80,7 +79,7 @@ void detachInterrupt(pin_size_t interruptNumber) {
|
||||
if (pinInvalid(interruptNumber))
|
||||
return;
|
||||
|
||||
if (g_APinDescription[interruptNumber].ulPinType == PIO_GPIO_IRQ) {
|
||||
if (pinTable[interruptNumber].types == PIN_IRQ) {
|
||||
pinRemoveMode(interruptNumber);
|
||||
}
|
||||
gpio_irq_handler_list[interruptNumber] = NULL;
|
||||
|
||||
@@ -12,47 +12,29 @@ extern "C" {
|
||||
#include "sdk_mem.h"
|
||||
#include "sdk_os.h"
|
||||
|
||||
#define NOT_INITIAL (1UL << 0)
|
||||
#define PIO_GPIO (1UL << 1)
|
||||
#define PIO_PWM (1UL << 2)
|
||||
#define PIO_I2C (1UL << 3)
|
||||
#define PIO_ADC (1UL << 4)
|
||||
#define PIO_DAC (1UL << 5)
|
||||
#define PIO_GPIO_IRQ (1UL << 6)
|
||||
|
||||
#define PWM_MODE_ENABLED 1
|
||||
#define PWM_MODE_DISABLED 0
|
||||
|
||||
#define DEFAULT 1
|
||||
#define EXTERNAL 0
|
||||
|
||||
#define round(x) ((x) >= 0 ? (long)((x) + 0.5) : (long)((x)-0.5))
|
||||
|
||||
typedef enum _eAnalogReference {
|
||||
AR_DEFAULT,
|
||||
} eAnalogReference;
|
||||
|
||||
// Types used for the table below
|
||||
typedef struct _PinDescription {
|
||||
// HW PinNames
|
||||
uint32_t pinname;
|
||||
// Current Pin Type
|
||||
uint32_t ulPinType;
|
||||
// Supported Pin Function
|
||||
uint32_t ulPinAttribute;
|
||||
// Current Pin Mode
|
||||
uint32_t ulPinMode;
|
||||
} PinDescription;
|
||||
|
||||
// Pins table to be instantiated into variant.cpp
|
||||
extern PinDescription g_APinDescription[];
|
||||
|
||||
// Additional Wiring functions
|
||||
extern uint32_t digitalPinToPort(uint32_t pinNumber);
|
||||
extern uint32_t digitalPinToBitMask(uint32_t pinNumber);
|
||||
extern void analogOutputInit(void);
|
||||
extern void wait_for_debug();
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" uint32_t SystemCoreClock;
|
||||
#else
|
||||
extern uint32_t SystemCoreClock;
|
||||
#endif
|
||||
#define clockCyclesPerMicrosecond() (SystemCoreClock / 1000000L)
|
||||
#define clockCyclesToMicroseconds(a) (a * 1000L / (SystemCoreClock / 1000L))
|
||||
#define microsecondsToClockCycles(a) (a * (SystemCoreClock / 1000000L))
|
||||
|
||||
#define interrupts() vPortClearInterruptMask(0)
|
||||
#define noInterrupts() ulPortSetInterruptMask()
|
||||
|
||||
#ifdef __cplusplus
|
||||
} // extern "C"
|
||||
#endif
|
||||
|
||||
@@ -57,7 +57,7 @@ void analogWriteResolution(int res) {
|
||||
_writeResolution = res;
|
||||
}
|
||||
|
||||
uint8_t analog_reference = AR_DEFAULT;
|
||||
uint8_t analog_reference = 0;
|
||||
|
||||
void analogReference(uint8_t mode) {
|
||||
analog_reference = mode;
|
||||
@@ -66,6 +66,7 @@ void analogReference(uint8_t mode) {
|
||||
uint16_t analogReadVoltage(pin_size_t pinNumber) {
|
||||
uint16_t ret = 0;
|
||||
switch (pinNumber) {
|
||||
#ifdef PIN_A1
|
||||
case PIN_A1:
|
||||
if (g_adc_enabled[1] == false) {
|
||||
analogin_init(&adc2, AD_2);
|
||||
@@ -74,6 +75,8 @@ uint16_t analogReadVoltage(pin_size_t pinNumber) {
|
||||
ret = analogin_read_u16(&adc2);
|
||||
// AD_1 - 0.0V-5.0V
|
||||
return AD2MV(ret, 0x496, 0xBA);
|
||||
#endif
|
||||
#ifdef PIN_A0
|
||||
case PIN_A0:
|
||||
if (g_adc_enabled[0] == false) {
|
||||
analogin_init(&adc1, AD_1);
|
||||
@@ -81,6 +84,8 @@ uint16_t analogReadVoltage(pin_size_t pinNumber) {
|
||||
}
|
||||
ret = analogin_read_u16(&adc1);
|
||||
break;
|
||||
#endif
|
||||
#ifdef PIN_A2
|
||||
case PIN_A2:
|
||||
if (g_adc_enabled[2] == false) {
|
||||
analogin_init(&adc3, AD_3);
|
||||
@@ -88,6 +93,7 @@ uint16_t analogReadVoltage(pin_size_t pinNumber) {
|
||||
}
|
||||
ret = analogin_read_u16(&adc3);
|
||||
break;
|
||||
#endif
|
||||
default:
|
||||
return 0;
|
||||
}
|
||||
@@ -120,20 +126,18 @@ void analogOutputInit(void) {
|
||||
void analogWrite(pin_size_t pinNumber, int value) {
|
||||
pwmout_t *obj;
|
||||
|
||||
if ((g_APinDescription[pinNumber].ulPinAttribute & PIO_PWM) == PIO_PWM) {
|
||||
if ((pinTable[pinNumber].features & PIN_PWM) == PIN_PWM) {
|
||||
float percent = value * 1.0 / (1 << _writeResolution);
|
||||
if (g_APinDescription[pinNumber].ulPinType != PIO_PWM) {
|
||||
if ((g_APinDescription[pinNumber].ulPinType == PIO_GPIO) ||
|
||||
(g_APinDescription[pinNumber].ulPinType == PIO_GPIO_IRQ)) {
|
||||
if (pinTable[pinNumber].types != PIN_PWM) {
|
||||
if ((pinTable[pinNumber].types == PIN_GPIO) || (pinTable[pinNumber].types == PIN_IRQ)) {
|
||||
pinRemoveMode(pinNumber);
|
||||
}
|
||||
gpio_pin_struct[pinNumber] = malloc(sizeof(pwmout_t));
|
||||
pwmout_t *obj = (pwmout_t *)gpio_pin_struct[pinNumber];
|
||||
pwmout_init(obj, g_APinDescription[pinNumber].pinname);
|
||||
pwmout_init(obj, pinTable[pinNumber].gpio);
|
||||
pwmout_period_us(obj, _writePeriod);
|
||||
pwmout_write(obj, percent);
|
||||
g_APinDescription[pinNumber].ulPinType = PIO_PWM;
|
||||
g_APinDescription[pinNumber].ulPinMode = PWM_MODE_ENABLED;
|
||||
pinTable[pinNumber].types = PIN_PWM;
|
||||
} else {
|
||||
pwmout_t *obj = (pwmout_t *)gpio_pin_struct[pinNumber];
|
||||
// pwmout_period_us(obj, _writePeriod);
|
||||
@@ -162,30 +166,26 @@ void _tone_timer_handler(const void *argument) {
|
||||
void _tone(uint32_t ulPin, unsigned int frequency, unsigned long duration) {
|
||||
pwmout_t *obj;
|
||||
|
||||
if ((g_APinDescription[ulPin].ulPinAttribute & PIO_PWM) != PIO_PWM) {
|
||||
if ((pinTable[ulPin].features & PIN_PWM) != PIN_PWM) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (g_APinDescription[ulPin].ulPinType != PIO_PWM) {
|
||||
if ((g_APinDescription[ulPin].ulPinType == PIO_GPIO) || (g_APinDescription[ulPin].ulPinType == PIO_GPIO_IRQ)) {
|
||||
if (pinTable[ulPin].types != PIN_PWM) {
|
||||
if ((pinTable[ulPin].types == PIN_GPIO) || (pinTable[ulPin].types == PIN_IRQ)) {
|
||||
pinRemoveMode(ulPin);
|
||||
}
|
||||
gpio_pin_struct[ulPin] = malloc(sizeof(pwmout_t));
|
||||
pwmout_t *obj = (pwmout_t *)gpio_pin_struct[ulPin];
|
||||
pwmout_init(obj, g_APinDescription[ulPin].pinname);
|
||||
pwmout_init(obj, pinTable[ulPin].gpio);
|
||||
pwmout_period(obj, 1.0 / frequency);
|
||||
pwmout_pulsewidth(obj, 1.0 / (frequency * 2));
|
||||
g_APinDescription[ulPin].ulPinType = PIO_PWM;
|
||||
g_APinDescription[ulPin].ulPinMode = PWM_MODE_ENABLED;
|
||||
pinTable[ulPin].types = PIN_PWM;
|
||||
|
||||
} else {
|
||||
// There is already a PWM configured
|
||||
pwmout_t *obj = (pwmout_t *)gpio_pin_struct[ulPin];
|
||||
pwmout_period(obj, 1.0 / frequency);
|
||||
pwmout_pulsewidth(obj, 1.0 / (frequency * 2));
|
||||
/* if (g_APinDescription[ulPin].ulPinMode == PWM_MODE_DISABLED) {
|
||||
HAL_Pwm_Enable( &obj->pwm_hal_adp );
|
||||
} */
|
||||
}
|
||||
|
||||
if (duration > 0) {
|
||||
|
||||
@@ -7,65 +7,64 @@
|
||||
extern void *gpio_pin_struct[PINS_COUNT];
|
||||
|
||||
bool pinInvalid(pin_size_t pinNumber) {
|
||||
return pinNumber < 0 || pinNumber >= PINS_COUNT || g_APinDescription[pinNumber].pinname == NC;
|
||||
return pinNumber < 0 || pinNumber >= PINS_COUNT || pinTable[pinNumber].gpio == NC;
|
||||
}
|
||||
|
||||
void pinRemoveMode(pin_size_t pinNumber) {
|
||||
if (pinInvalid(pinNumber))
|
||||
return;
|
||||
if (g_APinDescription[pinNumber].ulPinType == PIO_PWM) {
|
||||
if (pinTable[pinNumber].types & PIN_PWM) {
|
||||
pwmout_t *obj = (pwmout_t *)gpio_pin_struct[pinNumber];
|
||||
pwmout_free(obj);
|
||||
}
|
||||
if (g_APinDescription[pinNumber].ulPinType == PIO_GPIO) {
|
||||
if (pinTable[pinNumber].types & PIN_GPIO) {
|
||||
gpio_t *obj = (gpio_t *)gpio_pin_struct[pinNumber];
|
||||
gpio_deinit(obj, g_APinDescription[pinNumber].pinname);
|
||||
gpio_deinit(obj, pinTable[pinNumber].gpio);
|
||||
free(obj);
|
||||
}
|
||||
if (g_APinDescription[pinNumber].ulPinType == PIO_GPIO_IRQ) {
|
||||
if (pinTable[pinNumber].types & PIN_IRQ) {
|
||||
gpio_irq_t *obj = (gpio_irq_t *)gpio_pin_struct[pinNumber];
|
||||
gpio_irq_deinit(obj);
|
||||
free(obj);
|
||||
}
|
||||
gpio_pin_struct[pinNumber] = NULL;
|
||||
g_APinDescription[pinNumber].ulPinType = NOT_INITIAL;
|
||||
g_APinDescription[pinNumber].ulPinMode = NOT_INITIAL;
|
||||
gpio_pin_struct[pinNumber] = NULL;
|
||||
pinTable[pinNumber].types = PIN_NONE;
|
||||
}
|
||||
|
||||
void pinMode(pin_size_t pinNumber, PinModeArduino pinMode) {
|
||||
if (pinInvalid(pinNumber))
|
||||
return;
|
||||
|
||||
if (g_APinDescription[pinNumber].ulPinType == PIO_GPIO && g_APinDescription[pinNumber].ulPinMode == pinMode)
|
||||
if (pinTable[pinNumber].types == PIN_GPIO && pinTable[pinNumber].mode == pinMode)
|
||||
// Nothing changes in pin mode
|
||||
return;
|
||||
|
||||
if ((g_APinDescription[pinNumber].ulPinAttribute & PIO_GPIO) != PIO_GPIO)
|
||||
if ((pinTable[pinNumber].features & PIN_GPIO) != PIN_GPIO)
|
||||
// cannot set ADC as I/O
|
||||
return;
|
||||
|
||||
/* if (g_APinDescription[pinNumber].ulPinType == PIO_PWM) {
|
||||
/* if (pinTable[pinNumber].types == PIN_PWM) {
|
||||
// If this pin has been configured as PWM, then it cannot change to another mode
|
||||
return;
|
||||
} */
|
||||
|
||||
if (g_APinDescription[pinNumber].ulPinType != PIO_GPIO)
|
||||
if (pinTable[pinNumber].types != PIN_GPIO)
|
||||
// pin mode changes; deinit gpio and free memory
|
||||
pinRemoveMode(pinNumber);
|
||||
|
||||
gpio_t *gpio;
|
||||
|
||||
if (g_APinDescription[pinNumber].ulPinType == NOT_INITIAL) {
|
||||
if (pinTable[pinNumber].types == PIN_NONE) {
|
||||
// allocate memory if pin not used before
|
||||
gpio = malloc(sizeof(gpio_t));
|
||||
gpio_pin_struct[pinNumber] = gpio;
|
||||
gpio_init(gpio, g_APinDescription[pinNumber].pinname);
|
||||
g_APinDescription[pinNumber].ulPinType = PIO_GPIO;
|
||||
gpio_init(gpio, pinTable[pinNumber].gpio);
|
||||
pinTable[pinNumber].types = PIN_GPIO;
|
||||
} else {
|
||||
// pin already used as gpio
|
||||
gpio = (gpio_t *)gpio_pin_struct[pinNumber];
|
||||
}
|
||||
g_APinDescription[pinNumber].ulPinMode = pinMode;
|
||||
pinTable[pinNumber].mode = pinMode;
|
||||
|
||||
PinDirection dir;
|
||||
PinMode mode;
|
||||
@@ -102,7 +101,7 @@ void pinMode(pin_size_t pinNumber, PinModeArduino pinMode) {
|
||||
void digitalWrite(pin_size_t pinNumber, PinStatus status) {
|
||||
if (pinInvalid(pinNumber))
|
||||
return;
|
||||
if (g_APinDescription[pinNumber].ulPinType != PIO_GPIO)
|
||||
if (pinTable[pinNumber].types != PIN_GPIO)
|
||||
return;
|
||||
|
||||
gpio_t *gpio = (gpio_t *)gpio_pin_struct[pinNumber];
|
||||
@@ -112,7 +111,7 @@ void digitalWrite(pin_size_t pinNumber, PinStatus status) {
|
||||
PinStatus digitalRead(pin_size_t pinNumber) {
|
||||
if (pinInvalid(pinNumber))
|
||||
return;
|
||||
if (g_APinDescription[pinNumber].ulPinType != PIO_GPIO)
|
||||
if (pinTable[pinNumber].types != PIN_GPIO)
|
||||
return;
|
||||
|
||||
gpio_t *gpio = (gpio_t *)gpio_pin_struct[pinNumber];
|
||||
@@ -125,7 +124,7 @@ uint32_t digitalPinToPort(uint32_t pinNumber) {
|
||||
if (pinInvalid(pinNumber))
|
||||
return 0xFFFFFFFF;
|
||||
|
||||
uint32_t pin_name = HAL_GPIO_GetPinName(g_APinDescription[pinNumber].pinname);
|
||||
uint32_t pin_name = HAL_GPIO_GetPinName(pinTable[pinNumber].gpio);
|
||||
return HAL_GPIO_GET_PORT_BY_NAME(pin_name);
|
||||
}
|
||||
|
||||
@@ -133,6 +132,6 @@ uint32_t digitalPinToBitMask(uint32_t pinNumber) {
|
||||
if (pinInvalid(pinNumber))
|
||||
return 0xFFFFFFFF;
|
||||
|
||||
uint32_t pin_name = HAL_GPIO_GetPinName(g_APinDescription[pinNumber].pinname);
|
||||
uint32_t pin_name = HAL_GPIO_GetPinName(pinTable[pinNumber].gpio);
|
||||
return 1 << (HAL_GPIO_GET_PIN_BY_NAME(pin_name));
|
||||
}
|
||||
|
||||
@@ -36,11 +36,11 @@ extern unsigned long pulseIn(uint8_t pin, uint8_t state, unsigned long timeout)
|
||||
|
||||
uint32_t start_ticks, cur_ticks;
|
||||
|
||||
if (pin < 0 || pin > PINS_COUNT || (g_APinDescription[pin].pinname == NC))
|
||||
if (pin < 0 || pin > PINS_COUNT || (pinTable[pin].gpio == NC))
|
||||
return 0;
|
||||
|
||||
/* Handle */
|
||||
if (g_APinDescription[pin].ulPinType != PIO_GPIO) {
|
||||
if (pinTable[pin].types != PIN_GPIO) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
@@ -46,8 +46,8 @@ bool TwoWire::setPins(int8_t sda, int8_t scl) {
|
||||
// set private pins
|
||||
_sda = sda;
|
||||
_scl = scl;
|
||||
sda = g_APinDescription[sda].pinname;
|
||||
scl = g_APinDescription[scl].pinname;
|
||||
sda = pinTable[sda].gpio;
|
||||
scl = pinTable[scl].gpio;
|
||||
|
||||
// check if pins are valid
|
||||
if ((sda == PA_4 || sda == PA_19 || sda == PA_30) && (scl == PA_1 || scl == PA_22 || scl == PA_29)) {
|
||||
@@ -82,7 +82,7 @@ bool TwoWire::begin(int8_t sda, int8_t scl, uint32_t frequency) {
|
||||
frequency = WIRE_DEFAULT_FREQ;
|
||||
|
||||
_i2c = new i2c_t;
|
||||
i2c_init(_i2c, (PinName)g_APinDescription[_sda].pinname, (PinName)g_APinDescription[_scl].pinname);
|
||||
i2c_init(_i2c, (PinName)pinTable[_sda].gpio, (PinName)pinTable[_scl].gpio);
|
||||
i2c_frequency(_i2c, frequency);
|
||||
_freq = frequency;
|
||||
return true;
|
||||
|
||||
@@ -1,39 +1,36 @@
|
||||
/* Copyright (c) Kuba Szczodrzyński 2022-04-22. */
|
||||
/* This file was auto-generated from wr3.json using boardgen */
|
||||
|
||||
#include "variant.h"
|
||||
#include <Arduino.h>
|
||||
|
||||
extern "C" {
|
||||
|
||||
/*
|
||||
* Pins descriptions
|
||||
*/
|
||||
// clang-format off
|
||||
PinDescription g_APinDescription[PINS_COUNT] = {
|
||||
// D0: UART0_RTS, SPI1_MISO, SPI0_MISO, I2C0_SCL, SD_D0, PWM5, I2S_WS, WAKEUP_2
|
||||
{PA_22, NOT_INITIAL, PIO_GPIO | PIO_GPIO_IRQ | PIO_PWM, NOT_INITIAL},
|
||||
// D1: UART0_CTS, SPI1_CS, SPI0_CS, I2C0_SDA, SD_D3, TIMER5_TRIG, I2S_SD_TX, ADC1
|
||||
{PA_19, NOT_INITIAL, PIO_GPIO | PIO_GPIO_IRQ, NOT_INITIAL},
|
||||
// D2: PWM0, SWD_CLK
|
||||
{PA_14, NOT_INITIAL, PIO_GPIO | PIO_GPIO_IRQ | PIO_PWM, NOT_INITIAL},
|
||||
// D3: PWM1, SWD_DATA
|
||||
{PA_15, NOT_INITIAL, PIO_GPIO | PIO_GPIO_IRQ | PIO_PWM, NOT_INITIAL},
|
||||
// D4: PWM2, ext_32K
|
||||
{PA_0, NOT_INITIAL, PIO_GPIO | PIO_GPIO_IRQ | PIO_PWM, NOT_INITIAL},
|
||||
// D5: UART2_log_RXD, I2C0_SCL, PWM4
|
||||
{PA_29, NOT_INITIAL, PIO_GPIO | PIO_GPIO_IRQ | PIO_PWM, NOT_INITIAL},
|
||||
// D6: UART2_log_TXD, I2C0_SDA, PWM3, RTC_OUT
|
||||
{PA_30, NOT_INITIAL, PIO_GPIO | PIO_GPIO_IRQ | PIO_PWM, NOT_INITIAL},
|
||||
// D7: SDIO_SIDEBAND_INT, PWM4, WAKEUP_1
|
||||
{PA_5, NOT_INITIAL, PIO_GPIO | PIO_GPIO_IRQ | PIO_PWM, NOT_INITIAL},
|
||||
// D8: PWM3
|
||||
{PA_12, NOT_INITIAL, PIO_GPIO | PIO_GPIO_IRQ | PIO_PWM, NOT_INITIAL},
|
||||
// D9: UART0_RXD, SPI1_CLK, SPI0_SCK, I2C1_SCL, SD_D2, TIMER4_TRIG, I2S_MCK, WAKEUP_0
|
||||
{PA_18, NOT_INITIAL, PIO_GPIO | PIO_GPIO_IRQ, NOT_INITIAL},
|
||||
// D10: UART0_TXD, SPI1_MOSI, SPI0_MOSI, I2C1_SDA, SD_D1, PWM0, WAKEUP_3
|
||||
{PA_23, NOT_INITIAL, PIO_GPIO | PIO_GPIO_IRQ | PIO_PWM, NOT_INITIAL},
|
||||
// A1: VBAT_MEAS, ADC2
|
||||
{AD_2, NOT_INITIAL, PIO_ADC, NOT_INITIAL},
|
||||
PinInfo pinTable[PINS_COUNT] = {
|
||||
// D0: PA22, UART0_RTS, SPI0_MISO, SPI1_MISO, I2C0_SCL, SD_D0, PWM5, I2S0_WS, WAKE2
|
||||
{PA_22, PIN_GPIO | PIN_IRQ | PIN_PWM | PIN_I2C | PIN_I2S | PIN_SPI | PIN_UART, PIN_NONE, 0},
|
||||
// D1: PA19, ADC1, UART0_CTS, SPI0_CS, SPI1_CS, I2C0_SDA, SD_D3, TMR5_TRIG, I2S0_TX
|
||||
{PA_19, PIN_GPIO | PIN_IRQ | PIN_ADC | PIN_I2C | PIN_I2S | PIN_SPI | PIN_UART, PIN_NONE, 0},
|
||||
// D2: PA14, PWM0, SWCLK
|
||||
{PA_14, PIN_GPIO | PIN_IRQ | PIN_PWM | PIN_SWD, PIN_NONE, 0},
|
||||
// D3: PA15, PWM1, SWDIO
|
||||
{PA_15, PIN_GPIO | PIN_IRQ | PIN_PWM | PIN_SWD, PIN_NONE, 0},
|
||||
// D4: PA00, PWM2
|
||||
{PA_0, PIN_GPIO | PIN_IRQ | PIN_PWM, PIN_NONE, 0},
|
||||
// D5: PA29, UART2_RX, I2C0_SCL, PWM4
|
||||
{PA_29, PIN_GPIO | PIN_IRQ | PIN_PWM | PIN_I2C | PIN_UART, PIN_NONE, 0},
|
||||
// D6: PA30, UART2_TX, I2C0_SDA, PWM4
|
||||
{PA_30, PIN_GPIO | PIN_IRQ | PIN_PWM | PIN_I2C | PIN_UART, PIN_NONE, 0},
|
||||
// D7: PA05, PWM4, WAKE1
|
||||
{PA_5, PIN_GPIO | PIN_IRQ | PIN_PWM, PIN_NONE, 0},
|
||||
// D8: PA12, PWM3
|
||||
{PA_12, PIN_GPIO | PIN_IRQ | PIN_PWM, PIN_NONE, 0},
|
||||
// D9: PA18, UART0_RX, SPI0_SCK, SPI1_SCK, I2C1_SCL, SD_D2, TMR4_TRIG, I2S0_MCK, WAKE0
|
||||
{PA_18, PIN_GPIO | PIN_IRQ | PIN_I2C | PIN_I2S | PIN_SPI | PIN_UART, PIN_NONE, 0},
|
||||
// D10: PA23, UART0_TX, SPI0_MOSI, SPI1_MOSI, I2C1_SDA, SD_D1, PWM0, WAKE3
|
||||
{PA_23, PIN_GPIO | PIN_IRQ | PIN_PWM | PIN_I2C | PIN_SPI | PIN_UART, PIN_NONE, 0},
|
||||
// A1: ADC2
|
||||
{AD_2, PIN_ADC, PIN_NONE, 0},
|
||||
};
|
||||
// clang-format on
|
||||
|
||||
} // extern C
|
||||
} // extern "C"
|
||||
|
||||
@@ -1,66 +1,53 @@
|
||||
/* Copyright (c) Kuba Szczodrzyński 2022-04-23. */
|
||||
/* This file was auto-generated from wr3.json using boardgen */
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <WVariant.h>
|
||||
|
||||
// clang-format off
|
||||
|
||||
// Pins
|
||||
// ----
|
||||
|
||||
// Number of pins defined in PinDescription array
|
||||
#define PINS_COUNT 12
|
||||
#define PINS_COUNT 12
|
||||
#define NUM_DIGITAL_PINS 11
|
||||
#define NUM_ANALOG_INPUTS 2
|
||||
#define NUM_ANALOG_OUTPUTS 0
|
||||
|
||||
// Low-level pin register query macros
|
||||
// -----------------------------------
|
||||
#define portOutputRegister(P) ((volatile uint32_t *)(0x40001000 + (P)*0x0C))
|
||||
#define portInputRegister(P) ((volatile uint32_t *)(0x40001050 + (P)*4))
|
||||
#define portModeRegister(P) ((volatile uint32_t *)(0x40001004 + (P)*0x0C))
|
||||
|
||||
// LEDs
|
||||
// ----
|
||||
#define PIN_LED 4u // PA_0
|
||||
#define LED_BUILTIN PIN_LED // PA_0
|
||||
|
||||
// Analog pins
|
||||
// -----------
|
||||
#define PIN_A0 1u // PA_19
|
||||
#define PIN_A1 11u // VBAT_MEAS
|
||||
#define PIN_A2 0u // dummy, this is NOT usable
|
||||
|
||||
static const uint8_t A0 = PIN_A0;
|
||||
static const uint8_t A1 = PIN_A1;
|
||||
static const uint8_t A2 = PIN_A2;
|
||||
#define PIN_A0 1u // PA_19
|
||||
#define PIN_A1 11u // AD_2
|
||||
#define A0 PIN_A0
|
||||
#define A1 PIN_A1
|
||||
|
||||
// SPI Interfaces
|
||||
// --------------
|
||||
#define SPI_INTERFACES_COUNT 0
|
||||
#define SPI_INTERFACES_COUNT 2
|
||||
#define PIN_SPI0_CS 1u // PA_19
|
||||
#define PIN_SPI0_MISO 0u // PA_22
|
||||
#define PIN_SPI0_MOSI 10u // PA_23
|
||||
#define PIN_SPI0_SCK 9u // PA_18
|
||||
#define PIN_SPI1_CS 1u // PA_19
|
||||
#define PIN_SPI1_MISO 0u // PA_22
|
||||
#define PIN_SPI1_MOSI 10u // PA_23
|
||||
#define PIN_SPI1_SCK 9u // PA_18
|
||||
|
||||
// Wire Interfaces
|
||||
// ---------------
|
||||
#define WIRE_INTERFACES_COUNT 2
|
||||
#define PIN_WIRE0_SDA 1u // PA_19
|
||||
#define PIN_WIRE0_SCL 0u // PA_22
|
||||
#define PIN_WIRE1_SDA 10u // PA_23
|
||||
#define PIN_WIRE1_SCL 9u // PA_18
|
||||
#define PIN_WIRE0_SCL_0 0u // PA_22
|
||||
#define PIN_WIRE0_SCL_1 5u // PA_29
|
||||
#define PIN_WIRE0_SDA_0 1u // PA_19
|
||||
#define PIN_WIRE0_SDA_1 6u // PA_30
|
||||
#define PIN_WIRE1_SCL 9u // PA_18
|
||||
#define PIN_WIRE1_SDA 10u // PA_23
|
||||
|
||||
// Serial ports
|
||||
// ------------
|
||||
// LOGUARTClass
|
||||
#define PIN_SERIAL2_RX 5u // PA_29
|
||||
#define PIN_SERIAL2_TX 6u // PA_30
|
||||
// UARTClassOne
|
||||
#define PIN_SERIAL0_RX 9u // PA_18
|
||||
#define PIN_SERIAL0_TX 10u // PA_23
|
||||
|
||||
#define SERIAL_PORT_USBVIRTUAL Serial
|
||||
#define SERIAL_PORT_MONITOR Serial
|
||||
#define SERIAL_PORT_HARDWARE Serial
|
||||
#define SERIAL_PORT_HARDWARE_OPEN Serial
|
||||
|
||||
#ifdef __cplusplus
|
||||
#include "LOGUARTClass.h"
|
||||
extern LOGUARTClass Serial;
|
||||
#endif // __cplusplus
|
||||
#define SERIAL_INTERFACES_COUNT 2
|
||||
#define PIN_SERIAL0_CTS 1u // PA_19
|
||||
#define PIN_SERIAL0_RTS 0u // PA_22
|
||||
#define PIN_SERIAL0_RX 9u // PA_18
|
||||
#define PIN_SERIAL0_TX 10u // PA_23
|
||||
#define PIN_SERIAL2_RX 5u // PA_29
|
||||
#define PIN_SERIAL2_TX 6u // PA_30
|
||||
|
||||
Submodule tools/boardgen updated: e92a4d24a0...8685902886
Reference in New Issue
Block a user