Skip to content

Add legacy I2C/SPI pin aliases #14617

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Jun 9, 2021
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
91 changes: 91 additions & 0 deletions hal/include/hal/PinNameAliases.h
Original file line number Diff line number Diff line change
Expand Up @@ -28,28 +28,93 @@

#ifdef TARGET_FF_ARDUINO_UNO

#ifndef A0
#define A0 ARDUINO_UNO_A0
#endif

#ifndef A1
#define A1 ARDUINO_UNO_A1
#endif

#ifndef A2
#define A2 ARDUINO_UNO_A2
#endif

#ifndef A3
#define A3 ARDUINO_UNO_A3
#endif

#ifndef A4
#define A4 ARDUINO_UNO_A4
#endif

#ifndef A5
#define A5 ARDUINO_UNO_A5
#endif

#ifndef D0
#define D0 ARDUINO_UNO_D0
#endif

#ifndef D1
#define D1 ARDUINO_UNO_D1
#endif

#ifndef D2
#define D2 ARDUINO_UNO_D2
#endif

#ifndef D3
#define D3 ARDUINO_UNO_D3
#endif

#ifndef D4
#define D4 ARDUINO_UNO_D4
#endif

#ifndef D5
#define D5 ARDUINO_UNO_D5
#endif

#ifndef D6
#define D6 ARDUINO_UNO_D6
#endif

#ifndef D7
#define D7 ARDUINO_UNO_D7
#endif

#ifndef D8
#define D8 ARDUINO_UNO_D8
#endif

#ifndef D9
#define D9 ARDUINO_UNO_D9
#endif

#ifndef D10
#define D10 ARDUINO_UNO_D10
#endif

#ifndef D11
#define D11 ARDUINO_UNO_D11
#endif

#ifndef D12
#define D12 ARDUINO_UNO_D12
#endif

#ifndef D13
#define D13 ARDUINO_UNO_D13
#endif

#ifndef D14
#define D14 ARDUINO_UNO_D14
#endif

#ifndef D15
#define D15 ARDUINO_UNO_D15
#endif

#endif // TARGET_FF_ARDUINO_UNO

Expand Down Expand Up @@ -82,20 +147,46 @@

#endif // TARGET_FF_ARDUINO

#ifdef TARGET_FF_ARDUINO_UNO

// Arduino Uno I2C signals aliases
#define ARDUINO_UNO_I2C_SDA ARDUINO_UNO_D14
#define ARDUINO_UNO_I2C_SCL ARDUINO_UNO_D15

// Legacy I2C aliases
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This has to be protected by
#ifdef TARGET_FF_ARDUINO_UNO

as targets which are not compliant with pin standard are already defining I2C_SDA in enum

#ifndef I2C_SDA
#define I2C_SDA ARDUINO_UNO_I2C_SDA
#endif
#ifndef I2C_SCL
#define I2C_SCL ARDUINO_UNO_I2C_SCL
#endif

// Arduino Uno SPI signals aliases
#define ARDUINO_UNO_SPI_CS ARDUINO_UNO_D10
#define ARDUINO_UNO_SPI_MOSI ARDUINO_UNO_D11
#define ARDUINO_UNO_SPI_MISO ARDUINO_UNO_D12
#define ARDUINO_UNO_SPI_SCK ARDUINO_UNO_D13

// Legacy SPI aliases
#ifndef SPI_CS
#define SPI_CS ARDUINO_UNO_SPI_CS
#endif
#ifndef SPI_MOSI
#define SPI_MOSI ARDUINO_UNO_SPI_MOSI
#endif
#ifndef SPI_MISO
#define SPI_MISO ARDUINO_UNO_SPI_MISO
#endif
#ifndef SPI_SCK
#define SPI_SCK ARDUINO_UNO_SPI_SCK
#endif

// Arduino Uno UART signals aliases
#define ARDUINO_UNO_UART_TX ARDUINO_UNO_D1
#define ARDUINO_UNO_UART_RX ARDUINO_UNO_D0

#endif // TARGET_FF_ARDUINO_UNO

#endif // (TARGET_FF_ARDUINO) || (TARGET_FF_ARDUINO_UNO)

#endif // MBED_PIN_NAME_ALIASES_H
Expand Down