mirror of https://github.com/ARMmbed/mbed-os.git
Explicit pinmap: Fix build failures reported by CI
parent
d75cc97d80
commit
ba12228556
|
@ -29,6 +29,7 @@
|
|||
#if EXPLICIT_PINMAP_READY
|
||||
#include "PeripheralPinMaps.h"
|
||||
|
||||
|
||||
#if DEVICE_PWMOUT
|
||||
MSTD_CONSTEXPR_FN_14 PinMap get_pwm_pinmap(const PinName pin)
|
||||
{
|
||||
|
@ -37,7 +38,7 @@ MSTD_CONSTEXPR_FN_14 PinMap get_pwm_pinmap(const PinName pin)
|
|||
return {pin, pinmap.peripheral, pinmap.function};
|
||||
}
|
||||
}
|
||||
return {NC, NC, NC};
|
||||
return {NC, (int) NC, (int) NC};
|
||||
}
|
||||
#endif // DEVICE_PWMOUT
|
||||
|
||||
|
@ -49,7 +50,7 @@ MSTD_CONSTEXPR_FN_14 PinMap get_analogin_pinmap(const PinName pin)
|
|||
return {pin, pinmap.peripheral, pinmap.function};
|
||||
}
|
||||
}
|
||||
return {NC, NC, NC};
|
||||
return {NC, (int) NC, (int) NC};
|
||||
}
|
||||
#endif // DEVICE_ANALOGIN
|
||||
|
||||
|
@ -61,7 +62,7 @@ MSTD_CONSTEXPR_FN_14 PinMap get_analogout_pinmap(const PinName pin)
|
|||
return {pin, pinmap.peripheral, pinmap.function};
|
||||
}
|
||||
}
|
||||
return {NC, NC, NC};
|
||||
return {NC, (int) NC, (int) NC};
|
||||
}
|
||||
#endif // DEVICE_ANALOGOUT
|
||||
|
||||
|
@ -85,7 +86,7 @@ MSTD_CONSTEXPR_FN_14 i2c_pinmap_t get_i2c_pinmap(const PinName sda, const PinNam
|
|||
}
|
||||
|
||||
if (!sda_map || !scl_map || sda_map->peripheral != scl_map->peripheral) {
|
||||
return {NC, NC, NC, NC, NC};
|
||||
return {(int) NC, NC, (int) NC, NC, (int) NC};
|
||||
}
|
||||
|
||||
return {sda_map->peripheral, sda_map->pin, sda_map->function, scl_map->pin, scl_map->function};
|
||||
|
@ -112,7 +113,7 @@ MSTD_CONSTEXPR_FN_14 serial_pinmap_t get_uart_pinmap(const PinName tx, const Pin
|
|||
}
|
||||
|
||||
if (!tx_map || !rx_map || rx_map->peripheral != tx_map->peripheral) {
|
||||
return {NC, NC, NC, NC, NC, false};
|
||||
return {(int) NC, NC, (int) NC, NC, (int) NC, false};
|
||||
}
|
||||
|
||||
if (tx_map->pin == STDIO_UART_TX && rx_map->pin == STDIO_UART_RX) {
|
||||
|
@ -142,7 +143,7 @@ MSTD_CONSTEXPR_FN_14 serial_fc_pinmap_t get_uart_fc_pinmap(const PinName rxflow,
|
|||
}
|
||||
|
||||
if ((!rts_map || !cts_map) || (rts_map->peripheral != cts_map->peripheral)) {
|
||||
return {NC, NC, NC, NC, NC};
|
||||
return {(int) NC, NC, (int) NC, NC, (int) NC};
|
||||
}
|
||||
|
||||
return {cts_map->peripheral, cts_map->pin, cts_map->function, rts_map->pin, rts_map->function};
|
||||
|
@ -188,7 +189,7 @@ MSTD_CONSTEXPR_FN_14 spi_pinmap_t get_spi_pinmap(const PinName mosi, const PinNa
|
|||
if ((!mosi_map || !miso_map || !sclk_map || !ssel_map) ||
|
||||
(mosi_map->peripheral != miso_map->peripheral || mosi_map->peripheral != sclk_map->peripheral) ||
|
||||
(ssel_map->pin != NC && mosi_map->peripheral != ssel_map->peripheral)) {
|
||||
return {NC, NC, NC, NC, NC, NC, NC, NC, NC};
|
||||
return {(int) NC, NC, (int) NC, NC, (int) NC, NC, (int) NC, NC, (int) NC};
|
||||
}
|
||||
|
||||
return {mosi_map->peripheral, mosi_map->pin, mosi_map->function, miso_map->pin, miso_map->function, sclk_map->pin, sclk_map->function, ssel_map->pin, ssel_map->function};
|
||||
|
@ -200,41 +201,41 @@ MSTD_CONSTEXPR_FN_14 spi_pinmap_t get_spi_pinmap(const PinName mosi, const PinNa
|
|||
#if DEVICE_PWMOUT
|
||||
MSTD_CONSTEXPR_FN_14 PinMap get_pwm_pinmap(const PinName pin)
|
||||
{
|
||||
return {pin, NC, NC};
|
||||
return {pin, (int) NC, (int) NC};
|
||||
}
|
||||
#endif // DEVICE_PWMOUT
|
||||
|
||||
#if DEVICE_ANALOGIN
|
||||
MSTD_CONSTEXPR_FN_14 PinMap get_analogin_pinmap(const PinName pin)
|
||||
{
|
||||
return {pin, NC, NC};
|
||||
return {pin, (int) NC, (int) NC};
|
||||
}
|
||||
#endif // DEVICE_ANALOGIN
|
||||
|
||||
#if DEVICE_ANALOGOUT
|
||||
MSTD_CONSTEXPR_FN_14 PinMap get_analogout_pinmap(const PinName pin)
|
||||
{
|
||||
return {pin, NC, NC};
|
||||
return {pin, (int) NC, (int) NC};
|
||||
}
|
||||
#endif // DEVICE_ANALOGOUT
|
||||
|
||||
#if DEVICE_I2C
|
||||
MSTD_CONSTEXPR_FN_14 i2c_pinmap_t get_i2c_pinmap(const PinName sda, const PinName scl)
|
||||
{
|
||||
return {NC, sda, NC, scl, NC};
|
||||
return {(int) NC, sda, (int) NC, scl, (int) NC};
|
||||
}
|
||||
#endif //DEVICE_I2C
|
||||
|
||||
#if DEVICE_SERIAL
|
||||
MSTD_CONSTEXPR_FN_14 serial_pinmap_t get_uart_pinmap(const PinName tx, const PinName rx)
|
||||
{
|
||||
return {NC, tx, NC, rx, NC, false};
|
||||
return {(int) NC, tx, (int) NC, rx, (int) NC, false};
|
||||
}
|
||||
|
||||
#if DEVICE_SERIAL_FC
|
||||
MSTD_CONSTEXPR_FN_14 serial_fc_pinmap_t get_uart_fc_pinmap(const PinName rxflow, const PinName txflow)
|
||||
{
|
||||
return {NC, txflow, NC, rxflow, NC};
|
||||
return {(int) NC, txflow, (int) NC, rxflow, (int) NC};
|
||||
}
|
||||
#endif // DEVICE_SERIAL_FC
|
||||
#endif // DEVICE_SERIAL
|
||||
|
@ -242,7 +243,7 @@ MSTD_CONSTEXPR_FN_14 serial_fc_pinmap_t get_uart_fc_pinmap(const PinName rxflow,
|
|||
#if DEVICE_SPI
|
||||
MSTD_CONSTEXPR_FN_14 spi_pinmap_t get_spi_pinmap(const PinName mosi, const PinName miso, const PinName sclk, const PinName ssel)
|
||||
{
|
||||
return {NC, mosi, NC, miso, NC, sclk, NC, ssel, NC};
|
||||
return {(int) NC, mosi, (int) NC, miso, (int) NC, sclk, (int) NC, ssel, (int) NC};
|
||||
}
|
||||
#endif // DEVICE_SERIAL
|
||||
|
||||
|
|
|
@ -188,13 +188,13 @@ DirectSerial::DirectSerial(PinName tx, PinName rx, int baud)
|
|||
|
||||
#if CONSOLE_FLOWCONTROL == CONSOLE_FLOWCONTROL_RTS
|
||||
static const serial_fc_pinmap_t fc_pinmap = get_uart_fc_pinmap(STDIO_UART_RTS, NC);
|
||||
serial_set_flow_control_direct(&stdio_uart, FlowControlRTS, fc_pinmap);
|
||||
serial_set_flow_control_direct(&stdio_uart, FlowControlRTS, &fc_pinmap);
|
||||
#elif CONSOLE_FLOWCONTROL == CONSOLE_FLOWCONTROL_CTS
|
||||
static const serial_fc_pinmap_t fc_pinmap = get_uart_fc_pinmap(NC, STDIO_UART_CTS);
|
||||
serial_set_flow_control_direct(&stdio_uart, FlowControlCTS, fc_pinmap);
|
||||
serial_set_flow_control_direct(&stdio_uart, FlowControlCTS, &fc_pinmap);
|
||||
#elif CONSOLE_FLOWCONTROL == CONSOLE_FLOWCONTROL_RTSCTS
|
||||
static const serial_fc_pinmap_t fc_pinmap = get_uart_fc_pinmap(STDIO_UART_RTS, STDIO_UART_CTS);
|
||||
serial_set_flow_control_direct(&stdio_uart, FlowControlRTSCTS, fc_pinmap);
|
||||
serial_set_flow_control_direct(&stdio_uart, FlowControlRTSCTS, &fc_pinmap);
|
||||
#endif
|
||||
}
|
||||
|
||||
|
@ -208,13 +208,13 @@ DirectSerial::DirectSerial(const serial_pinmap_t &explicit_pinmap, int baud)
|
|||
|
||||
#if CONSOLE_FLOWCONTROL == CONSOLE_FLOWCONTROL_RTS
|
||||
static const serial_fc_pinmap_t fc_pinmap = get_uart_fc_pinmap(STDIO_UART_RTS, NC);
|
||||
serial_set_flow_control_direct(&stdio_uart, FlowControlRTS, fc_pinmap);
|
||||
serial_set_flow_control_direct(&stdio_uart, FlowControlRTS, &fc_pinmap);
|
||||
#elif CONSOLE_FLOWCONTROL == CONSOLE_FLOWCONTROL_CTS
|
||||
static const serial_fc_pinmap_t fc_pinmap = get_uart_fc_pinmap(NC, STDIO_UART_CTS);
|
||||
serial_set_flow_control_direct(&stdio_uart, FlowControlCTS, fc_pinmap);
|
||||
serial_set_flow_control_direct(&stdio_uart, FlowControlCTS, &fc_pinmap);
|
||||
#elif CONSOLE_FLOWCONTROL == CONSOLE_FLOWCONTROL_RTSCTS
|
||||
static const serial_fc_pinmap_t fc_pinmap = get_uart_fc_pinmap(STDIO_UART_RTS, STDIO_UART_CTS);
|
||||
serial_set_flow_control_direct(&stdio_uart, FlowControlRTSCTS, fc_pinmap);
|
||||
serial_set_flow_control_direct(&stdio_uart, FlowControlRTSCTS, &fc_pinmap);
|
||||
#endif
|
||||
}
|
||||
|
||||
|
|
|
@ -40,7 +40,6 @@ extern "C" {
|
|||
#include "PortNames.h"
|
||||
#include "PeripheralNames.h"
|
||||
#include "target_config.h"
|
||||
#include "spi.h"
|
||||
|
||||
typedef enum {
|
||||
FlowControlNone_1,
|
||||
|
|
|
@ -279,9 +279,10 @@ void i2c_init_internal(i2c_t *obj, const i2c_pinmap_t *pinmap)
|
|||
if (pinmap != NULL) {
|
||||
obj_s->sda = pinmap->sda_pin;
|
||||
obj_s->scl = pinmap->scl_pin;
|
||||
#if EXPLICIT_PINMAP_READY
|
||||
obj_s->sda_func = pinmap->sda_function;
|
||||
obj_s->scl_func = pinmap->scl_function;
|
||||
|
||||
#endif
|
||||
obj_s->i2c = (I2CName)pinmap->peripheral;
|
||||
MBED_ASSERT(obj_s->i2c != (I2CName)NC);
|
||||
}
|
||||
|
@ -334,8 +335,13 @@ void i2c_init_internal(i2c_t *obj, const i2c_pinmap_t *pinmap)
|
|||
#endif
|
||||
|
||||
// Configure I2C pins
|
||||
#if EXPLICIT_PINMAP_READY
|
||||
pin_function(obj_s->sda, obj_s->sda_func);
|
||||
pin_function(obj_s->scl, obj_s->scl_func);
|
||||
#else
|
||||
pinmap_pinout(obj_s->sda, PinMap_I2C_SDA);
|
||||
pinmap_pinout(obj_s->scl, PinMap_I2C_SCL);
|
||||
#endif
|
||||
pin_mode(obj_s->sda, OpenDrainNoPull);
|
||||
pin_mode(obj_s->scl, OpenDrainNoPull);
|
||||
|
||||
|
@ -364,7 +370,13 @@ void i2c_init_internal(i2c_t *obj, const i2c_pinmap_t *pinmap)
|
|||
#endif
|
||||
}
|
||||
|
||||
#if EXPLICIT_PINMAP_READY
|
||||
#define I2C_INIT_DIRECT i2c_init_direct
|
||||
void i2c_init_direct(i2c_t *obj, const i2c_pinmap_t *pinmap)
|
||||
#else
|
||||
#define I2C_INIT_DIRECT _i2c_init_direct
|
||||
static void _i2c_init_direct(i2c_t *obj, const i2c_pinmap_t *pinmap)
|
||||
#endif
|
||||
{
|
||||
memset(obj, 0, sizeof(*obj));
|
||||
i2c_init_internal(obj, pinmap);
|
||||
|
@ -382,7 +394,7 @@ void i2c_init(i2c_t *obj, PinName sda, PinName scl)
|
|||
|
||||
const i2c_pinmap_t explicit_i2c_pinmap = {peripheral, sda, sda_function, scl, scl_function};
|
||||
|
||||
i2c_init_direct(obj, &explicit_i2c_pinmap);
|
||||
I2C_INIT_DIRECT(obj, &explicit_i2c_pinmap);
|
||||
}
|
||||
|
||||
|
||||
|
|
Loading…
Reference in New Issue