Skip to content

Commit

Permalink
[board] Add I2C and SPI connections to all boards
Browse files Browse the repository at this point in the history
  • Loading branch information
salkinium committed Jan 12, 2024
1 parent bac35e3 commit e81de4f
Show file tree
Hide file tree
Showing 42 changed files with 1,010 additions and 52 deletions.
36 changes: 36 additions & 0 deletions src/modm/board/nucleo_f031k6/board.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,28 @@ using Uart = Usart1;
/// @}
}

namespace i2c
{
/// @ingroup modm_board_nucleo_f031k6
/// @{
using Sda = D4;
using Scl = D5;
using Controller = I2cMaster1;
/// @}
}

namespace spi
{
/// @ingroup modm_board_nucleo_f031k6
/// @{
using Cs = D10;
using Sck = D13;
using Sdi = D12;
using Sdo = D11;
using Controller = SpiMaster1;
/// @}
}

/// @ingroup modm_board_nucleo_f031k6
/// @{
using LoggerDevice = modm::IODeviceWrapper< stlink::Uart, modm::IOBuffer::BlockIfFull >;
Expand All @@ -104,6 +126,20 @@ initialize()
stlink::Uart::connect<stlink::Tx::Tx, stlink::Rx::Rx>();
stlink::Uart::initialize<SystemClock, 115200_Bd>();
}

inline void
initializeI2c()
{
i2c::Controller::connect<i2c::Sda::Sda, i2c::Scl::Scl>();
i2c::Controller::initialize<SystemClock, 400_kHz>();
}

inline void
initializeSpi()
{
spi::Controller::connect<spi::Sck::Sck, spi::Sdo::Mosi, spi::Sdi::Miso>();
spi::Controller::initialize<SystemClock, 3_MHz>();
}
/// @}

}
Expand Down
12 changes: 10 additions & 2 deletions src/modm/board/nucleo_f031k6/module.lb
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,16 @@ def prepare(module, options):
if not options[":target"].partname.startswith("stm32f031k6t"):
return False

module.depends(":platform:core", ":platform:gpio", ":platform:clock", ":platform:uart:1",
":debug", ":architecture:clock", ":architecture:clock")
module.depends(
":architecture:clock",
":debug",
":platform:clock",
":platform:core",
":platform:gpio",
":platform:i2c:1",
":platform:spi:1",
":platform:uart:1"
)
return True

def build(env):
Expand Down
36 changes: 36 additions & 0 deletions src/modm/board/nucleo_f042k6/board.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,28 @@ using Uart = Usart2;
/// @}
}

namespace i2c
{
/// @ingroup modm_board_nucleo_f042k6
/// @{
using Sda = D4;
using Scl = D5;
using Controller = I2cMaster1;
/// @}
}

namespace spi
{
/// @ingroup modm_board_nucleo_f042k6
/// @{
using Cs = D10;
using Sck = D13;
using Sdi = D12;
using Sdo = D11;
using Controller = SpiMaster1;
/// @}
}

/// @ingroup modm_board_nucleo_f042k6
/// @{
using LoggerDevice = modm::IODeviceWrapper< stlink::Uart, modm::IOBuffer::BlockIfFull >;
Expand All @@ -108,6 +130,20 @@ initialize()
stlink::Uart::connect<stlink::Tx::Tx, stlink::Rx::Rx>();
stlink::Uart::initialize<SystemClock, 115200_Bd>();
}

inline void
initializeI2c()
{
i2c::Controller::connect<i2c::Sda::Sda, i2c::Scl::Scl>();
i2c::Controller::initialize<SystemClock, 400_kHz>();
}

inline void
initializeSpi()
{
spi::Controller::connect<spi::Sck::Sck, spi::Sdo::Mosi, spi::Sdi::Miso>();
spi::Controller::initialize<SystemClock, 3_MHz>();
}
/// @}

}
Expand Down
12 changes: 10 additions & 2 deletions src/modm/board/nucleo_f042k6/module.lb
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,16 @@ def prepare(module, options):
if not options[":target"].partname.startswith("stm32f042k6t"):
return False

module.depends(":platform:core", ":platform:gpio", ":platform:clock", ":platform:uart:2",
":debug", ":architecture:clock", ":architecture:clock")
module.depends(
":architecture:clock",
":debug",
":platform:clock",
":platform:core",
":platform:gpio",
":platform:i2c:1",
":platform:spi:1",
":platform:uart:2"
)
return True

def build(env):
Expand Down
36 changes: 36 additions & 0 deletions src/modm/board/nucleo_f072rb/board.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,28 @@ using Uart = Usart2;
/// @}
}

namespace i2c
{
/// @ingroup modm_board_nucleo_f072rb
/// @{
using Sda = D14;
using Scl = D15;
using Controller = I2cMaster1;
/// @}
}

namespace spi
{
/// @ingroup modm_board_nucleo_f072rb
/// @{
using Cs = D10;
using Sck = D13;
using Sdi = D12;
using Sdo = D11;
using Controller = SpiMaster1;
/// @}
}

/// @ingroup modm_board_nucleo_f072rb
/// @{
using LoggerDevice = modm::IODeviceWrapper< stlink::Uart, modm::IOBuffer::BlockIfFull >;
Expand All @@ -108,6 +130,20 @@ initialize()
stlink::Uart::connect<stlink::Tx::Tx, stlink::Rx::Rx>();
stlink::Uart::initialize<SystemClock, 115200_Bd>();
}

inline void
initializeI2c()
{
i2c::Controller::connect<i2c::Sda::Sda, i2c::Scl::Scl>();
i2c::Controller::initialize<SystemClock, 400_kHz>();
}

inline void
initializeSpi()
{
spi::Controller::connect<spi::Sck::Sck, spi::Sdo::Mosi, spi::Sdi::Miso>();
spi::Controller::initialize<SystemClock, 3_MHz>();
}
/// @}

}
Expand Down
12 changes: 10 additions & 2 deletions src/modm/board/nucleo_f072rb/module.lb
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,16 @@ def prepare(module, options):
if not options[":target"].partname.startswith("stm32f072rbt"):
return False

module.depends(":platform:core", ":platform:gpio", ":platform:clock", ":platform:uart:2",
":debug", ":architecture:clock", ":architecture:clock")
module.depends(
":architecture:clock",
":debug",
":platform:clock",
":platform:core",
":platform:gpio",
":platform:i2c:1",
":platform:spi:1",
":platform:uart:2",
)
return True


Expand Down
36 changes: 36 additions & 0 deletions src/modm/board/nucleo_f091rc/board.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,28 @@ using Uart = Usart2;
/// @}
}

namespace i2c
{
/// @ingroup modm_board_nucleo_f091rc
/// @{
using Sda = D14;
using Scl = D15;
using Controller = I2cMaster1;
/// @}
}

namespace spi
{
/// @ingroup modm_board_nucleo_f091rc
/// @{
using Cs = D10;
using Sck = D13;
using Sdi = D12;
using Sdo = D11;
using Controller = SpiMaster1;
/// @}
}

/// @ingroup modm_board_nucleo_f091rc
/// @{
using LoggerDevice = modm::IODeviceWrapper< stlink::Uart, modm::IOBuffer::BlockIfFull >;
Expand All @@ -107,6 +129,20 @@ initialize()
stlink::Uart::connect<stlink::Tx::Tx, stlink::Rx::Rx>();
stlink::Uart::initialize<SystemClock, 115200_Bd>();
}

inline void
initializeI2c()
{
i2c::Controller::connect<i2c::Sda::Sda, i2c::Scl::Scl>();
i2c::Controller::initialize<SystemClock, 400_kHz>();
}

inline void
initializeSpi()
{
spi::Controller::connect<spi::Sck::Sck, spi::Sdo::Mosi, spi::Sdi::Miso>();
spi::Controller::initialize<SystemClock, 3_MHz>();
}
/// @}

}
12 changes: 10 additions & 2 deletions src/modm/board/nucleo_f091rc/module.lb
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,16 @@ def prepare(module, options):
if not options[":target"].partname.startswith("stm32f091rct"):
return False

module.depends(":platform:core", ":platform:gpio", ":platform:clock", ":platform:uart:2",
":debug", ":architecture:clock", ":architecture:clock")
module.depends(
":architecture:clock",
":debug",
":platform:clock",
":platform:core",
":platform:gpio",
":platform:i2c:1",
":platform:spi:1",
":platform:uart:2"
)
return True


Expand Down
36 changes: 36 additions & 0 deletions src/modm/board/nucleo_f103rb/board.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,28 @@ using Uart = Usart2;
/// @}
}

namespace i2c
{
/// @ingroup modm_board_nucleo_f091rc
/// @{
using Sda = D14;
using Scl = D15;
using Controller = I2cMaster1;
/// @}
}

namespace spi
{
/// @ingroup modm_board_nucleo_f091rc
/// @{
using Cs = D10;
using Sck = D13;
using Sdi = D12;
using Sdo = D11;
using Controller = SpiMaster1;
/// @}
}

/// @ingroup modm_board_nucleo_f103rb
/// @{
using LoggerDevice = modm::IODeviceWrapper< stlink::Uart, modm::IOBuffer::BlockIfFull >;
Expand All @@ -124,6 +146,20 @@ initialize()
// Enable PB4 as GPIO
AFIO->MAPR |= AFIO_MAPR_SWJ_CFG_JTAGDISABLE;
}

inline void
initializeI2c()
{
i2c::Controller::connect<i2c::Sda::Sda, i2c::Scl::Scl>();
i2c::Controller::initialize<SystemClock, 427_kHz>();
}

inline void
initializeSpi()
{
spi::Controller::connect<spi::Sck::Sck, spi::Sdo::Mosi, spi::Sdi::Miso>();
spi::Controller::initialize<SystemClock, 4_MHz>();
}
/// @}

}
Expand Down
12 changes: 10 additions & 2 deletions src/modm/board/nucleo_f103rb/module.lb
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,16 @@ def prepare(module, options):
if not options[":target"].partname.startswith("stm32f103rbt"):
return False

module.depends(":platform:core", ":platform:gpio", ":platform:clock", ":platform:uart:2",
":debug", ":architecture:clock")
module.depends(
":architecture:clock",
":debug",
":platform:clock",
":platform:core",
":platform:gpio",
":platform:i2c:1",
":platform:spi:1",
":platform:uart:2",
)
return True

def build(env):
Expand Down
Loading

0 comments on commit e81de4f

Please sign in to comment.