Skip to content

Change explicit pinmap to static pinmap #11820

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
Show file tree
Hide file tree
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
2 changes: 1 addition & 1 deletion TESTS/mbed_hal_fpga_ci_test_shield/analogin/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
#include "greentea-client/test_env.h"
#include "mbed.h"
#include "pinmap.h"
#include "hal/explicit_pinmap.h"
#include "hal/static_pinmap.h"
#include "test_utils.h"
#include "MbedTester.h"
#include "analogin_fpga_test.h"
Expand Down
6 changes: 3 additions & 3 deletions TESTS/mbed_hal_fpga_ci_test_shield/i2c/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
#include "mbed.h"
#include "i2c_api.h"
#include "pinmap.h"
#include "hal/explicit_pinmap.h"
#include "hal/static_pinmap.h"
#include "test_utils.h"
#include "I2CTester.h"
#include "i2c_fpga_test.h"
Expand Down Expand Up @@ -69,11 +69,11 @@ void fpga_i2c_test_write(PinName sda, PinName scl)
i2c_t i2c;
memset(&i2c, 0, sizeof(i2c));
if (init_direct) {
#if EXPLICIT_PINMAP_READY
#if STATIC_PINMAP_READY
const i2c_pinmap_t pinmap = get_i2c_pinmap(sda, scl);
i2c_init_direct(&i2c, &pinmap);
#else
//skip this test case if explicit pinmap is not supported
//skip this test case if static pinmap is not supported
return;
#endif
} else {
Expand Down
2 changes: 1 addition & 1 deletion TESTS/mbed_hal_fpga_ci_test_shield/pwm/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
#include "mbed.h"
#include "MbedTester.h"
#include "pinmap.h"
#include "hal/explicit_pinmap.h"
#include "hal/static_pinmap.h"
#include "test_utils.h"
#include "pwm_fpga_test.h"

Expand Down
2 changes: 1 addition & 1 deletion TESTS/mbed_hal_fpga_ci_test_shield/spi/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
#include "mbed.h"
#include "SPIMasterTester.h"
#include "pinmap.h"
#include "hal/explicit_pinmap.h"
#include "hal/static_pinmap.h"
#include "test_utils.h"
#include "spi_fpga_test.h"

Expand Down
6 changes: 3 additions & 3 deletions TESTS/mbed_hal_fpga_ci_test_shield/uart/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@
#include "serial_api.h"
#include "us_ticker_api.h"
#include "uart_fpga_test.h"
#include "hal/explicit_pinmap.h"
#include "hal/static_pinmap.h"

using namespace utest::v1;

Expand Down Expand Up @@ -128,11 +128,11 @@ static void uart_test_common(int baudrate, int data_bits, SerialParity parity, i
#if DEVICE_SERIAL_FC
if (use_flow_control) {
if (init_direct) {
#if EXPLICIT_PINMAP_READY
#if STATIC_PINMAP_READY
const serial_fc_pinmap_t pinmap = get_uart_fc_pinmap(rts, cts);
serial_set_flow_control_direct(&serial, FlowControlRTSCTS, &pinmap);
#else
//skip this test case if explicit pinmap is not supported
//skip this test case if static pinmap is not supported
return;
#endif
} else {
Expand Down
4 changes: 4 additions & 0 deletions UNITTESTS/stubs/pwmout_api_stub.c
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,10 @@ void pwmout_init(pwmout_t *obj, PinName pin)
{
}

void pwmout_init_direct(pwmout_t *obj, const PinMap *pinmap)
{
}

void pwmout_free(pwmout_t *obj)
{
}
Expand Down
4 changes: 2 additions & 2 deletions drivers/I2C.h
Original file line number Diff line number Diff line change
Expand Up @@ -103,9 +103,9 @@ class I2C : private NonCopyable<I2C> {

/** Create an I2C Master interface, connected to the specified pins
*
* @param explicit_pinmap reference to structure which holds static pinmap.
* @param static_pinmap reference to structure which holds static pinmap.
*/
I2C(const i2c_pinmap_t &explicit_pinmap);
I2C(const i2c_pinmap_t &static_pinmap);
I2C(const i2c_pinmap_t &&) = delete; // prevent passing of temporary objects

/** Set the frequency of the I2C interface
Expand Down
4 changes: 2 additions & 2 deletions drivers/I2CSlave.h
Original file line number Diff line number Diff line change
Expand Up @@ -88,9 +88,9 @@ class I2CSlave {

/** Create an I2C Slave interface, connected to the specified pins.
*
* @param explicit_pinmap reference to structure which holds static pinmap.
* @param static_pinmap reference to structure which holds static pinmap.
*/
I2CSlave(const i2c_pinmap_t &explicit_pinmap);
I2CSlave(const i2c_pinmap_t &static_pinmap);
I2CSlave(const i2c_pinmap_t &&) = delete; // prevent passing of temporary objects

/** Set the frequency of the I2C interface.
Expand Down
2 changes: 1 addition & 1 deletion drivers/QSPI.h
Original file line number Diff line number Diff line change
Expand Up @@ -235,7 +235,7 @@ class QSPI : private NonCopyable<QSPI> {
int _mode; //SPI mode
bool _initialized;
PinName _qspi_io0, _qspi_io1, _qspi_io2, _qspi_io3, _qspi_clk, _qspi_cs; //IO lines, clock and chip select
const qspi_pinmap_t *_explicit_pinmap;
const qspi_pinmap_t *_static_pinmap;
bool (QSPI::* _init_func)(void);

private:
Expand Down
10 changes: 5 additions & 5 deletions drivers/SPI.h
Original file line number Diff line number Diff line change
Expand Up @@ -140,9 +140,9 @@ class SPI : private NonCopyable<SPI> {
*
* @note You can specify mosi or miso as NC if not used.
*
* @param explicit_pinmap reference to structure which holds static pinmap.
* @param static_pinmap reference to structure which holds static pinmap.
*/
SPI(const spi_pinmap_t &explicit_pinmap);
SPI(const spi_pinmap_t &static_pinmap);
SPI(const spi_pinmap_t &&) = delete; // prevent passing of temporary objects

/** Create a SPI master connected to the specified pins.
Expand All @@ -154,10 +154,10 @@ class SPI : private NonCopyable<SPI> {
*
* @note You can specify mosi or miso as NC if not used.
*
* @param explicit_pinmap reference to structure which holds static pinmap.
* @param static_pinmap reference to structure which holds static pinmap.
* @param ssel SPI Chip Select pin.
*/
SPI(const spi_pinmap_t &explicit_pinmap, PinName ssel);
SPI(const spi_pinmap_t &static_pinmap, PinName ssel);
SPI(const spi_pinmap_t &&, PinName) = delete; // prevent passing of temporary objects

virtual ~SPI();
Expand Down Expand Up @@ -438,7 +438,7 @@ class SPI : private NonCopyable<SPI> {
/* Select count to handle re-entrant selection */
int8_t _select_count;
/* Static pinmap data */
const spi_pinmap_t *_explicit_pinmap;
const spi_pinmap_t *_static_pinmap;
/* SPI peripheral name */
SPIName _peripheral_name;
/* Pointer to spi init function */
Expand Down
2 changes: 1 addition & 1 deletion drivers/SPISlave.h
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ class SPISlave : private NonCopyable<SPISlave> {
*
* @note Either mosi or miso can be specified as NC if not used.
*
* @param explicit_pinmap reference to structure which holds static pinmap.
* @param static_pinmap reference to structure which holds static pinmap.
*/
SPISlave(const spi_pinmap_t &pinmap);
SPISlave(const spi_pinmap_t &&) = delete; // prevent passing of temporary objects
Expand Down
8 changes: 4 additions & 4 deletions drivers/Serial.h
Original file line number Diff line number Diff line change
Expand Up @@ -75,14 +75,14 @@ class Serial : public SerialBase, public Stream, private NonCopyable<Serial> {

/** Create a Serial port, connected to the specified transmit and receive pins
*
* @param explicit_pinmap reference to structure which holds static pinmap.
* @param static_pinmap reference to structure which holds static pinmap.
* @param name The name of the stream associated with this serial port (optional)
* @param baud The baud rate of the serial port (optional, defaults to MBED_CONF_PLATFORM_DEFAULT_SERIAL_BAUD_RATE or 9600)
*
* @note
* Either tx or rx may be specified as NC (Not Connected) if unused
*/
Serial(const serial_pinmap_t &explicit_pinmap, const char *name = NULL, int baud = MBED_CONF_PLATFORM_DEFAULT_SERIAL_BAUD_RATE);
Serial(const serial_pinmap_t &static_pinmap, const char *name = NULL, int baud = MBED_CONF_PLATFORM_DEFAULT_SERIAL_BAUD_RATE);
Serial(const serial_pinmap_t &&, const char * = NULL, int = MBED_CONF_PLATFORM_DEFAULT_SERIAL_BAUD_RATE) = delete; // prevent passing of temporary objects

/** Create a Serial port, connected to the specified transmit and receive pins, with the specified baud
Expand All @@ -98,13 +98,13 @@ class Serial : public SerialBase, public Stream, private NonCopyable<Serial> {

/** Create a Serial port, connected to the specified transmit and receive pins, with the specified baud
*
* @param explicit_pinmap reference to structure which holds static pinmap.
* @param static_pinmap reference to structure which holds static pinmap.
* @param baud The baud rate of the serial port
*
* @note
* Either tx or rx may be specified as NC (Not Connected) if unused
*/
Serial(const serial_pinmap_t &explicit_pinmap, int baud);
Serial(const serial_pinmap_t &static_pinmap, int baud);
Serial(const serial_pinmap_t &&, int) = delete; // prevent passing of temporary objects

/* Stream gives us a FileHandle with non-functional poll()/readable()/writable. Pass through
Expand Down
4 changes: 2 additions & 2 deletions drivers/SerialBase.h
Original file line number Diff line number Diff line change
Expand Up @@ -206,7 +206,7 @@ class SerialBase : private NonCopyable<SerialBase> {
* @param type the flow control type (Disabled, RTS, CTS, RTSCTS)
* @param pinmap reference to structure which holds static pinmap
*/
void set_flow_control(Flow type, const serial_fc_pinmap_t &explicit_pinmap);
void set_flow_control(Flow type, const serial_fc_pinmap_t &static_pinmap);
#endif

static void _irq_handler(uint32_t id, SerialIrq irq_type);
Expand Down Expand Up @@ -320,7 +320,7 @@ class SerialBase : private NonCopyable<SerialBase> {
#if !defined(DOXYGEN_ONLY)
protected:
SerialBase(PinName tx, PinName rx, int baud);
SerialBase(const serial_pinmap_t &explicit_pinmap, int baud);
SerialBase(const serial_pinmap_t &static_pinmap, int baud);
virtual ~SerialBase();

int _base_getc();
Expand Down
4 changes: 2 additions & 2 deletions drivers/UARTSerial.h
Original file line number Diff line number Diff line change
Expand Up @@ -60,10 +60,10 @@ class UARTSerial : private SerialBase, public FileHandle, private NonCopyable<UA
UARTSerial(PinName tx, PinName rx, int baud = MBED_CONF_PLATFORM_DEFAULT_SERIAL_BAUD_RATE);

/** Create a UARTSerial port, connected to the specified transmit and receive pins, with a particular baud rate.
* @param explicit_pinmap reference to structure which holds static pinmap
* @param static_pinmap reference to structure which holds static pinmap
* @param baud The baud rate of the serial port (optional, defaults to MBED_CONF_PLATFORM_DEFAULT_SERIAL_BAUD_RATE)
*/
UARTSerial(const serial_pinmap_t &explicit_pinmap, int baud = MBED_CONF_PLATFORM_DEFAULT_SERIAL_BAUD_RATE);
UARTSerial(const serial_pinmap_t &static_pinmap, int baud = MBED_CONF_PLATFORM_DEFAULT_SERIAL_BAUD_RATE);

virtual ~UARTSerial();

Expand Down
10 changes: 5 additions & 5 deletions drivers/source/I2C.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -47,18 +47,18 @@ I2C::I2C(PinName sda, PinName scl) :
unlock();
}

I2C::I2C(const i2c_pinmap_t &explicit_pinmap) :
I2C::I2C(const i2c_pinmap_t &static_pinmap) :
#if DEVICE_I2C_ASYNCH
_irq(this), _usage(DMA_USAGE_NEVER), _deep_sleep_locked(false),
#endif
_i2c(), _hz(100000)
{
lock();
// The init function also set the frequency to 100000
_sda = explicit_pinmap.sda_pin;
_scl = explicit_pinmap.scl_pin;
recover(explicit_pinmap.sda_pin, explicit_pinmap.scl_pin);
i2c_init_direct(&_i2c, &explicit_pinmap);
_sda = static_pinmap.sda_pin;
_scl = static_pinmap.scl_pin;
recover(static_pinmap.sda_pin, static_pinmap.scl_pin);
i2c_init_direct(&_i2c, &static_pinmap);
// Used to avoid unnecessary frequency updates
_owner = this;
unlock();
Expand Down
4 changes: 2 additions & 2 deletions drivers/source/I2CSlave.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -27,9 +27,9 @@ I2CSlave::I2CSlave(PinName sda, PinName scl) : _i2c()
i2c_slave_mode(&_i2c, 1);
}

I2CSlave::I2CSlave(const i2c_pinmap_t &explicit_pinmap) : _i2c()
I2CSlave::I2CSlave(const i2c_pinmap_t &static_pinmap) : _i2c()
{
i2c_init_direct(&_i2c, &explicit_pinmap);
i2c_init_direct(&_i2c, &static_pinmap);
i2c_frequency(&_i2c, 100000);
i2c_slave_mode(&_i2c, 1);
}
Expand Down
6 changes: 3 additions & 3 deletions drivers/source/QSPI.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ QSPI::QSPI(PinName io0, PinName io1, PinName io2, PinName io3, PinName sclk, Pin
_qspi_io3 = io3;
_qspi_clk = sclk;
_qspi_cs = ssel;
_explicit_pinmap = NULL;
_static_pinmap = NULL;
_inst_width = QSPI_CFG_BUS_SINGLE;
_address_width = QSPI_CFG_BUS_SINGLE;
_address_size = QSPI_CFG_ADDR_SIZE_24;
Expand All @@ -75,7 +75,7 @@ QSPI::QSPI(const qspi_pinmap_t &pinmap, int mode) : _qspi()
_qspi_io3 = pinmap.data3_pin;
_qspi_clk = pinmap.sclk_pin;
_qspi_cs = pinmap.ssel_pin;
_explicit_pinmap = &pinmap;
_static_pinmap = &pinmap;
_inst_width = QSPI_CFG_BUS_SINGLE;
_address_width = QSPI_CFG_BUS_SINGLE;
_address_size = QSPI_CFG_ADDR_SIZE_24;
Expand Down Expand Up @@ -291,7 +291,7 @@ bool QSPI::_initialize_direct()
return _initialized;
}

qspi_status_t ret = qspi_init_direct(&_qspi, _explicit_pinmap, _hz, _mode);
qspi_status_t ret = qspi_init_direct(&_qspi, _static_pinmap, _hz, _mode);
if (QSPI_STATUS_OK == ret) {
_initialized = true;
} else {
Expand Down
10 changes: 5 additions & 5 deletions drivers/source/SPI.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ SPI::SPI(PinName mosi, PinName miso, PinName sclk, PinName ssel) :
_sclk(sclk),
_hw_ssel(ssel),
_sw_ssel(NC),
_explicit_pinmap(NULL),
_static_pinmap(NULL),
_init_func(_do_init)
{
// Need backwards compatibility with HALs not providing API
Expand All @@ -59,7 +59,7 @@ SPI::SPI(PinName mosi, PinName miso, PinName sclk, PinName ssel, use_gpio_ssel_t
_sclk(sclk),
_hw_ssel(NC),
_sw_ssel(ssel, 1),
_explicit_pinmap(NULL),
_static_pinmap(NULL),
_init_func(_do_init)
{
// Need backwards compatibility with HALs not providing API
Expand All @@ -80,7 +80,7 @@ SPI::SPI(const spi_pinmap_t &pinmap) :
_sclk(pinmap.sclk_pin),
_hw_ssel(pinmap.ssel_pin),
_sw_ssel(NC),
_explicit_pinmap(&pinmap),
_static_pinmap(&pinmap),
_peripheral_name((SPIName)pinmap.peripheral),
_init_func(_do_init_direct)

Expand All @@ -97,7 +97,7 @@ SPI::SPI(const spi_pinmap_t &pinmap, PinName ssel) :
_sclk(pinmap.sclk_pin),
_hw_ssel(NC),
_sw_ssel(ssel, 1),
_explicit_pinmap(&pinmap),
_static_pinmap(&pinmap),
_peripheral_name((SPIName)pinmap.peripheral),
_init_func(_do_init_direct)
{
Expand All @@ -111,7 +111,7 @@ void SPI::_do_init(SPI *obj)

void SPI::_do_init_direct(SPI *obj)
{
spi_init_direct(&obj->_peripheral->spi, obj->_explicit_pinmap);
spi_init_direct(&obj->_peripheral->spi, obj->_static_pinmap);
}

void SPI::_do_construct()
Expand Down
4 changes: 2 additions & 2 deletions drivers/source/Serial.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -24,15 +24,15 @@ Serial::Serial(PinName tx, PinName rx, const char *name, int baud) : SerialBase(
{
}

Serial::Serial(const serial_pinmap_t &explicit_pinmap, const char *name, int baud) : SerialBase(explicit_pinmap, baud), Stream(name)
Serial::Serial(const serial_pinmap_t &static_pinmap, const char *name, int baud) : SerialBase(static_pinmap, baud), Stream(name)
{
}

Serial::Serial(PinName tx, PinName rx, int baud): SerialBase(tx, rx, baud), Stream(NULL)
{
}

Serial::Serial(const serial_pinmap_t &explicit_pinmap, int baud): SerialBase(explicit_pinmap, baud), Stream(NULL)
Serial::Serial(const serial_pinmap_t &static_pinmap, int baud): SerialBase(static_pinmap, baud), Stream(NULL)
{
}

Expand Down
12 changes: 6 additions & 6 deletions drivers/source/SerialBase.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ SerialBase::SerialBase(PinName tx, PinName rx, int baud) :
_init();
}

SerialBase::SerialBase(const serial_pinmap_t &explicit_pinmap, int baud) :
SerialBase::SerialBase(const serial_pinmap_t &static_pinmap, int baud) :
#if DEVICE_SERIAL_ASYNCH
_thunk_irq(this), _tx_usage(DMA_USAGE_NEVER),
_rx_usage(DMA_USAGE_NEVER), _tx_callback(NULL),
Expand All @@ -49,16 +49,16 @@ SerialBase::SerialBase(const serial_pinmap_t &explicit_pinmap, int baud) :
#endif
_serial(),
_baud(baud),
_tx_pin(explicit_pinmap.tx_pin),
_rx_pin(explicit_pinmap.rx_pin)
_tx_pin(static_pinmap.tx_pin),
_rx_pin(static_pinmap.rx_pin)
{
// No lock needed in the constructor

for (size_t i = 0; i < sizeof _irq / sizeof _irq[0]; i++) {
_irq[i] = NULL;
}

serial_init_direct(&_serial, &explicit_pinmap);
serial_init_direct(&_serial, &static_pinmap);
serial_baud(&_serial, _baud);
serial_irq_handler(&_serial, SerialBase::_irq_handler, (uint32_t)this);
}
Expand Down Expand Up @@ -316,11 +316,11 @@ void SerialBase::set_flow_control(Flow type, PinName flow1, PinName flow2)
unlock();
}

void SerialBase::set_flow_control(Flow type, const serial_fc_pinmap_t &explicit_pinmap)
void SerialBase::set_flow_control(Flow type, const serial_fc_pinmap_t &static_pinmap)
{
lock();
FlowControl flow_type = (FlowControl)type;
serial_set_flow_control_direct(&_serial, flow_type, &explicit_pinmap);
serial_set_flow_control_direct(&_serial, flow_type, &static_pinmap);
unlock();
}
#endif
Expand Down
Loading