Skip to content

Commit

Permalink
Correct I2C pins on 20-pin parts, check that pins swappable, don't as…
Browse files Browse the repository at this point in the history
…sume

This fixes #183
  • Loading branch information
SpenceKonde committed May 3, 2020
1 parent fa4b8b6 commit 468aa97
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 4 deletions.
2 changes: 2 additions & 0 deletions megaavr/variants/txy2/pins_arduino.h
Original file line number Diff line number Diff line change
Expand Up @@ -40,10 +40,12 @@

#define digitalPinHasPWM(p) ((p) != 0 && (p) != 5)

#ifdef PORTMUX_SPI0_bm
#define PIN_SPI_MISO_PINSWAP_1 (1)
#define PIN_SPI_SCK_PINSWAP_1 (4)
#define PIN_SPI_MOSI_PINSWAP_1 (0)
#define PIN_SPI_SS_PINSWAP_1 (0)
#endif
#define PIN_SPI_MISO (3)
#define PIN_SPI_SCK (4)
#define PIN_SPI_MOSI (2)
Expand Down
2 changes: 2 additions & 0 deletions megaavr/variants/txy4/pins_arduino.h
Original file line number Diff line number Diff line change
Expand Up @@ -49,8 +49,10 @@



#ifdef PORTMUX_TWI0_bm
#define PIN_WIRE_SDA_PINSWAP_1 (8)
#define PIN_WIRE_SCL_PINSWAP_1 (9)
#endif
#define PIN_WIRE_SDA (6)
#define PIN_WIRE_SCL (7)

Expand Down
12 changes: 8 additions & 4 deletions megaavr/variants/txy6/pins_arduino.h
Original file line number Diff line number Diff line change
Expand Up @@ -47,18 +47,22 @@
#define PIN_SPI_SCK (16)
#define PIN_SPI_MOSI (14)
#define PIN_SPI_SS (0)
#ifdef PORTMUX_SPI0_bm
#define PIN_SPI_MISO_PINSWAP_1 (11)
#define PIN_SPI_SCK_PINSWAP_1 (10)
#define PIN_SPI_MOSI_PINSWAP_1 (12)
#define PIN_SPI_SS_PINSWAP_1 (13)
#endif

#define SPI_INTERFACES_COUNT 1


#define PIN_WIRE_SDA (14)
#define PIN_WIRE_SCL (15)
#define PIN_WIRE_SDA_PINSWAP_1 (8)
#define PIN_WIRE_SCL_PINSWAP_1 (9)
#define PIN_WIRE_SDA (8)
#define PIN_WIRE_SCL (9)
#ifdef PORTMUX_TWI0_bm
#define PIN_WIRE_SDA_PINSWAP_1 (14)
#define PIN_WIRE_SCL_PINSWAP_1 (15)
#endif


//Define the pin names, since user code may depend on them, even though the core libraries don't...
Expand Down
4 changes: 4 additions & 0 deletions megaavr/variants/txy7/pins_arduino.h
Original file line number Diff line number Diff line change
Expand Up @@ -41,19 +41,23 @@
#define digitalPinHasPWM(p) ((p) == 0 || (p) == 1 || (p) == 11 || (p) == 10 || (p) == 9 || (p) == 20)
#endif

#ifdef PORTMUX_SPI0_bm
#define PIN_SPI_MISO_PINSWAP_1 (13)
#define PIN_SPI_SCK_PINSWAP_1 (12)
#define PIN_SPI_MOSI_PINSWAP_1 (14)
#define PIN_SPI_SS_PINSWAP_1 (15)
#endif
#define PIN_SPI_MISO (19)
#define PIN_SPI_SCK (20)
#define PIN_SPI_MOSI (18)
#define PIN_SPI_SS (0)

#define SPI_INTERFACES_COUNT 1

#ifdef PORTMUX_TWI0_bm
#define PIN_WIRE_SDA_PINSWAP_1 (18)
#define PIN_WIRE_SCL_PINSWAP_1 (19)
#endif
#define PIN_WIRE_SDA (10)
#define PIN_WIRE_SCL (11)

Expand Down

0 comments on commit 468aa97

Please sign in to comment.