Skip to content

Commit

Permalink
Remove D# pin numbering, fix pin number mapping
Browse files Browse the repository at this point in the history
  • Loading branch information
kuba2k2 committed Aug 29, 2023
1 parent 63364fb commit 4f6ce9f
Show file tree
Hide file tree
Showing 4 changed files with 108 additions and 58 deletions.
50 changes: 50 additions & 0 deletions components/pinscan/pinscan.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,61 @@ namespace pinscan {

static const char *const TAG = "pinscan";

#if defined(LT_BK7231N) || defined(LT_BK7231T)
static const int PIN_MAP[] = {
PIN_P0, // P0 / UART2_TX / I2C2_SCL
PIN_P1, // P1 / UART2_RX / I2C2_SDA
PIN_P6, // P6 / PWM0
PIN_P7, // P7 / PWM1
PIN_P8, // P8 / PWM2
PIN_P9, // P9 / PWM3
PIN_P10, // P10 / UART1_RX
PIN_P11, // P11 / UART1_TX
PIN_P14, // P14 / SCK
PIN_P15, // P15 / CS
PIN_P16, // P16 / MOSI
PIN_P17, // P17 / MISO
PIN_P20, // P20 / I2C1_SCL / TCK
PIN_P21, // P21 / I2C1_SDA / TMS
PIN_P22, // P22 / TDI
PIN_P23, // P23 / TDO / ADC3
PIN_P24, // P24 / PWM4
PIN_P26, // P26 / PWM5
PIN_P28, // P28
};
#elif defined(LT_RTL8710B)
static const int PIN_MAP[] = {
PIN_PA00, // PA00 / PWM2
PIN_PA05, // PA05 / PWM4
PIN_PA06, // PA06 / FCS
PIN_PA07, // PA07 / FD1
PIN_PA08, // PA08 / FD2
PIN_PA09, // PA09 / FD0
PIN_PA10, // PA10 / FSCK
PIN_PA11, // PA11 / FD3
PIN_PA12, // PA12 / PWM3
PIN_PA14, // PA14 / PWM0 / SWCLK
PIN_PA15, // PA15 / PWM1 / SWDIO
PIN_PA18, // PA18 / UART0_RX / I2C1_SCL / SPI0_SCK / SPI1_SCK
PIN_PA19, // PA19 / UART0_CTS / I2C0_SDA / SPI0_CS / SPI1_CS
PIN_PA22, // PA22 / UART0_RTS / I2C0_SCL / SPI0_MISO / SPI1_MISO / PWM5
PIN_PA23, // PA23 / UART0_TX / I2C1_SDA / SPI0_MISO / SPI1_MISO / PWM0
PIN_PA29, // PA29 / UART2_RX / I2C0_SCL / PWM4
PIN_PA30, // PA30 / UART2_TX / I2C0_SDA / PWM4

};
#else
#error "Unsupported chip type"
#endif

void Pinscan::setup() { ESP_LOGCONFIG(TAG, "Setting up Pinscan..."); }

void Pinscan::dump_config() { ESP_LOGCONFIG(TAG, "Pinscan:"); }

void Pinscan::set_pin(int pin) {
if (pin != -1) {
pin = PIN_MAP[pin];
}
if (this->current_pin_ != pin && this->current_pin_ != -1) {
pinMode(this->current_pin_, INPUT);
}
Expand Down
40 changes: 20 additions & 20 deletions yaml/kickstart-bk7231n.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -12,24 +12,24 @@ bk72xx:
select:
- platform: template
id: !extend pin
options:
options:
- Select PIN
- D0 / P0 / UART2_TX / I2C2_SCL
- D1 / P1 / UART2_RX / I2C2_SDA
- D2 / P6 / PWM0
- D3 / P7 / PWM1
- D4 / P8 / PWM2
- D5 / P9 / PWM3
- D6 / P10 / UART1_RX
- D7 / P11 / UART1_TX
- D8 / P14 / SCK
- D9 / P15 / CS
- D10 / P16 / MOSI
- D11 / P17 / MISO
- D12 / P20 / I2C1_SCL / TCK
- D13 / P21 / I2C1_SDA / TMS
- D14 / P22 / TDI
- D15 / P23 / TDO / ADC3
- D16 / P24 / PWM4
- D17 / P26 / PWM5
- D18 / P28
- P0 / UART2_TX / I2C2_SCL
- P1 / UART2_RX / I2C2_SDA
- P6 / PWM0
- P7 / PWM1
- P8 / PWM2
- P9 / PWM3
- P10 / UART1_RX
- P11 / UART1_TX
- P14 / SCK
- P15 / CS
- P16 / MOSI
- P17 / MISO
- P20 / I2C1_SCL / TCK
- P21 / I2C1_SDA / TMS
- P22 / TDI
- P23 / TDO / ADC3
- P24 / PWM4
- P26 / PWM5
- P28
40 changes: 20 additions & 20 deletions yaml/kickstart-bk7231t.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -12,24 +12,24 @@ bk72xx:
select:
- platform: template
id: !extend pin
options:
options:
- Select PIN
- D0 / P0 / UART2_TX / I2C2_SCL
- D1 / P1 / UART2_RX / I2C2_SDA
- D2 / P6 / PWM0
- D3 / P7 / PWM1
- D4 / P8 / PWM2
- D5 / P9 / PWM3
- D6 / P10 / UART1_RX
- D7 / P11 / UART1_TX
- D8 / P14 / SCK
- D9 / P15 / CS
- D10 / P16 / MOSI
- D11 / P17 / MISO
- D12 / P20 / I2C1_SCL / TCK
- D13 / P21 / I2C1_SDA / TMS
- D14 / P22 / TDI
- D15 / P23 / TDO / ADC3
- D16 / P24 / PWM4
- D17 / P26 / PWM5
- D18 / P28
- P0 / UART2_TX / I2C2_SCL
- P1 / UART2_RX / I2C2_SDA
- P6 / PWM0
- P7 / PWM1
- P8 / PWM2
- P9 / PWM3
- P10 / UART1_RX
- P11 / UART1_TX
- P14 / SCK
- P15 / CS
- P16 / MOSI
- P17 / MISO
- P20 / I2C1_SCL / TCK
- P21 / I2C1_SDA / TMS
- P22 / TDI
- P23 / TDO / ADC3
- P24 / PWM4
- P26 / PWM5
- P28
36 changes: 18 additions & 18 deletions yaml/kickstart-rtl8710bn-2mb-788k.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -12,22 +12,22 @@ rtl87xx:
select:
- platform: template
id: !extend pin
options:
options:
- Select PIN
- D0 / PA00 / PWM2
- D1 / PA05 / PWM4
- D2 / PA06 / FCS
- D3 / PA07 / FD1
- D4 / PA08 / FD2
- D5 / PA09 / FD0
- D6 / PA10 / FSCK
- D7 / PA11 / FD3
- D8 / PA12 / PWM3
- D9 / PA14 / PWM0 / SWCLK
- D10 / PA15 / PWM1 / SWDIO
- D11 / PA18 / UART0_RX / I2C1_SCL / SPI0_SCK / SPI1_SCK
- D12 / PA19 / UART0_CTS / I2C0_SDA / SPI0_CS / SPI1_CS
- D13 / PA22 / UART0_RTS / I2C0_SCL / SPI0_MISO / SPI1_MISO / PWM5
- D14 / PA23 / UART0_TX / I2C1_SDA / SPI0_MISO / SPI1_MISO / PWM0
- D15 / PA29 / UART2_RX / I2C0_SCL / PWM4
- D16 / PA30 / UART2_TX / I2C0_SDA / PWM4
- PA00 / PWM2
- PA05 / PWM4
- PA06 / FCS
- PA07 / FD1
- PA08 / FD2
- PA09 / FD0
- PA10 / FSCK
- PA11 / FD3
- PA12 / PWM3
- PA14 / PWM0 / SWCLK
- PA15 / PWM1 / SWDIO
- PA18 / UART0_RX / I2C1_SCL / SPI0_SCK / SPI1_SCK
- PA19 / UART0_CTS / I2C0_SDA / SPI0_CS / SPI1_CS
- PA22 / UART0_RTS / I2C0_SCL / SPI0_MISO / SPI1_MISO / PWM5
- PA23 / UART0_TX / I2C1_SDA / SPI0_MISO / SPI1_MISO / PWM0
- PA29 / UART2_RX / I2C0_SCL / PWM4
- PA30 / UART2_TX / I2C0_SDA / PWM4

0 comments on commit 4f6ce9f

Please sign in to comment.