#include "PinMapping.h"

/**
 * Helper class to define the pin mapping 
 */
 
//Default pin mapping
PinMapping::PinMapping() : 
_I2C_sda(GPIO_4_SDA), 
_I2C_scl(GPIO_5_SCL), 
_SPI_mosi(GPIO_13_MOSI), 
_SPI_miso(GPIO_12_MISO), 
_SPI_clk(GPIO_14_CLK), 
_SPI_sdCard_cs(GPIO_2)
{
}

//Custom pin mapping
PinMapping::PinMapping(const Pin I2C_sda, const Pin I2C_scl, const Pin SPI_mosi, const Pin SPI_miso, const Pin SPI_clk, const Pin SPI_sdCard_cs) : 
_I2C_sda(I2C_sda == DEFAULT_PIN ? GPIO_4_SDA : I2C_sda),
_I2C_scl(I2C_scl == DEFAULT_PIN ? GPIO_5_SCL : I2C_scl),
_SPI_mosi(SPI_mosi == DEFAULT_PIN ? GPIO_13_MOSI : SPI_mosi),
_SPI_miso(SPI_miso == DEFAULT_PIN ? GPIO_12_MISO : SPI_miso),
_SPI_clk(SPI_clk == DEFAULT_PIN ? GPIO_14_CLK : SPI_clk),
_SPI_sdCard_cs(SPI_sdCard_cs == DEFAULT_PIN ? GPIO_2 : SPI_sdCard_cs)
{
}

//Accessors
Pin PinMapping::getI2C_sda() const
{
  return _I2C_sda;
}

Pin PinMapping::getI2C_scl() const
{
  return _I2C_scl;
}
    
Pin PinMapping::getSPI_mosi() const
{
  return _SPI_mosi;
}

Pin PinMapping::getSPI_miso() const
{
  return _SPI_miso;
}

Pin PinMapping::getSPI_clk() const
{
  return _SPI_clk;
}

Pin PinMapping::getSPI_sdCard_cs() const
{
  return _SPI_sdCard_cs;
}

