Skip to content

Commit 3832f84

Browse files
committed
[board] Add I2C and SPI connections to all boards
1 parent b0d7e1f commit 3832f84

File tree

44 files changed

+1021
-54
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

44 files changed

+1021
-54
lines changed

src/modm/board/disco_f411ve/board.hpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,7 @@ struct SystemClock
6363
static constexpr uint32_t Timer11 = Apb2Timer;
6464

6565
static constexpr uint32_t Usb = 48_MHz;
66+
static constexpr uint32_t Iwdg = Rcc::LsiFrequency;
6667

6768
static bool inline enable()
6869
{

src/modm/board/nucleo_f031k6/board.hpp

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -92,6 +92,28 @@ using Uart = Usart1;
9292
/// @}
9393
}
9494

95+
namespace i2c
96+
{
97+
/// @ingroup modm_board_nucleo_f031k6
98+
/// @{
99+
using Sda = D4;
100+
using Scl = D5;
101+
using Controller = I2cMaster1;
102+
/// @}
103+
}
104+
105+
namespace spi
106+
{
107+
/// @ingroup modm_board_nucleo_f031k6
108+
/// @{
109+
using Cs = D10;
110+
using Sck = D13;
111+
using Sdi = D12;
112+
using Sdo = D11;
113+
using Controller = SpiMaster1;
114+
/// @}
115+
}
116+
95117
/// @ingroup modm_board_nucleo_f031k6
96118
/// @{
97119
using LoggerDevice = modm::IODeviceWrapper< stlink::Uart, modm::IOBuffer::BlockIfFull >;
@@ -105,6 +127,20 @@ initialize()
105127
stlink::Uart::connect<stlink::Tx::Tx, stlink::Rx::Rx>();
106128
stlink::Uart::initialize<SystemClock, 115200_Bd>();
107129
}
130+
131+
inline void
132+
initializeI2c()
133+
{
134+
i2c::Controller::connect<i2c::Sda::Sda, i2c::Scl::Scl>();
135+
i2c::Controller::initialize<SystemClock, 400_kHz>();
136+
}
137+
138+
inline void
139+
initializeSpi()
140+
{
141+
spi::Controller::connect<spi::Sck::Sck, spi::Sdo::Mosi, spi::Sdi::Miso>();
142+
spi::Controller::initialize<SystemClock, 3_MHz>();
143+
}
108144
/// @}
109145

110146
}

src/modm/board/nucleo_f031k6/module.lb

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,8 +23,16 @@ def prepare(module, options):
2323
if not options[":target"].partname.startswith("stm32f031k6t"):
2424
return False
2525

26-
module.depends(":platform:core", ":platform:gpio", ":platform:clock", ":platform:uart:1",
27-
":debug", ":architecture:clock", ":architecture:clock")
26+
module.depends(
27+
":architecture:clock",
28+
":debug",
29+
":platform:clock",
30+
":platform:core",
31+
":platform:gpio",
32+
":platform:i2c:1",
33+
":platform:spi:1",
34+
":platform:uart:1"
35+
)
2836
return True
2937

3038
def build(env):

src/modm/board/nucleo_f042k6/board.hpp

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -96,6 +96,28 @@ using Uart = Usart2;
9696
/// @}
9797
}
9898

99+
namespace i2c
100+
{
101+
/// @ingroup modm_board_nucleo_f042k6
102+
/// @{
103+
using Sda = D4;
104+
using Scl = D5;
105+
using Controller = I2cMaster1;
106+
/// @}
107+
}
108+
109+
namespace spi
110+
{
111+
/// @ingroup modm_board_nucleo_f042k6
112+
/// @{
113+
using Cs = D10;
114+
using Sck = D13;
115+
using Sdi = D12;
116+
using Sdo = D11;
117+
using Controller = SpiMaster1;
118+
/// @}
119+
}
120+
99121
/// @ingroup modm_board_nucleo_f042k6
100122
/// @{
101123
using LoggerDevice = modm::IODeviceWrapper< stlink::Uart, modm::IOBuffer::BlockIfFull >;
@@ -109,6 +131,20 @@ initialize()
109131
stlink::Uart::connect<stlink::Tx::Tx, stlink::Rx::Rx>();
110132
stlink::Uart::initialize<SystemClock, 115200_Bd>();
111133
}
134+
135+
inline void
136+
initializeI2c()
137+
{
138+
i2c::Controller::connect<i2c::Sda::Sda, i2c::Scl::Scl>();
139+
i2c::Controller::initialize<SystemClock, 400_kHz>();
140+
}
141+
142+
inline void
143+
initializeSpi()
144+
{
145+
spi::Controller::connect<spi::Sck::Sck, spi::Sdo::Mosi, spi::Sdi::Miso>();
146+
spi::Controller::initialize<SystemClock, 3_MHz>();
147+
}
112148
/// @}
113149

114150
}

src/modm/board/nucleo_f042k6/module.lb

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,8 +24,16 @@ def prepare(module, options):
2424
if not options[":target"].partname.startswith("stm32f042k6t"):
2525
return False
2626

27-
module.depends(":platform:core", ":platform:gpio", ":platform:clock", ":platform:uart:2",
28-
":debug", ":architecture:clock", ":architecture:clock")
27+
module.depends(
28+
":architecture:clock",
29+
":debug",
30+
":platform:clock",
31+
":platform:core",
32+
":platform:gpio",
33+
":platform:i2c:1",
34+
":platform:spi:1",
35+
":platform:uart:2"
36+
)
2937
return True
3038

3139
def build(env):

src/modm/board/nucleo_f072rb/board.hpp

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -96,6 +96,28 @@ using Uart = Usart2;
9696
/// @}
9797
}
9898

99+
namespace i2c
100+
{
101+
/// @ingroup modm_board_nucleo_f072rb
102+
/// @{
103+
using Sda = D14;
104+
using Scl = D15;
105+
using Controller = I2cMaster1;
106+
/// @}
107+
}
108+
109+
namespace spi
110+
{
111+
/// @ingroup modm_board_nucleo_f072rb
112+
/// @{
113+
using Cs = D10;
114+
using Sck = D13;
115+
using Sdi = D12;
116+
using Sdo = D11;
117+
using Controller = SpiMaster1;
118+
/// @}
119+
}
120+
99121
/// @ingroup modm_board_nucleo_f072rb
100122
/// @{
101123
using LoggerDevice = modm::IODeviceWrapper< stlink::Uart, modm::IOBuffer::BlockIfFull >;
@@ -109,6 +131,20 @@ initialize()
109131
stlink::Uart::connect<stlink::Tx::Tx, stlink::Rx::Rx>();
110132
stlink::Uart::initialize<SystemClock, 115200_Bd>();
111133
}
134+
135+
inline void
136+
initializeI2c()
137+
{
138+
i2c::Controller::connect<i2c::Sda::Sda, i2c::Scl::Scl>();
139+
i2c::Controller::initialize<SystemClock, 400_kHz>();
140+
}
141+
142+
inline void
143+
initializeSpi()
144+
{
145+
spi::Controller::connect<spi::Sck::Sck, spi::Sdo::Mosi, spi::Sdi::Miso>();
146+
spi::Controller::initialize<SystemClock, 3_MHz>();
147+
}
112148
/// @}
113149

114150
}

src/modm/board/nucleo_f072rb/module.lb

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,8 +23,16 @@ def prepare(module, options):
2323
if not options[":target"].partname.startswith("stm32f072rbt"):
2424
return False
2525

26-
module.depends(":platform:core", ":platform:gpio", ":platform:clock", ":platform:uart:2",
27-
":debug", ":architecture:clock", ":architecture:clock")
26+
module.depends(
27+
":architecture:clock",
28+
":debug",
29+
":platform:clock",
30+
":platform:core",
31+
":platform:gpio",
32+
":platform:i2c:1",
33+
":platform:spi:1",
34+
":platform:uart:2",
35+
)
2836
return True
2937

3038

src/modm/board/nucleo_f091rc/board.hpp

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -95,6 +95,28 @@ using Uart = Usart2;
9595
/// @}
9696
}
9797

98+
namespace i2c
99+
{
100+
/// @ingroup modm_board_nucleo_f091rc
101+
/// @{
102+
using Sda = D14;
103+
using Scl = D15;
104+
using Controller = I2cMaster1;
105+
/// @}
106+
}
107+
108+
namespace spi
109+
{
110+
/// @ingroup modm_board_nucleo_f091rc
111+
/// @{
112+
using Cs = D10;
113+
using Sck = D13;
114+
using Sdi = D12;
115+
using Sdo = D11;
116+
using Controller = SpiMaster1;
117+
/// @}
118+
}
119+
98120
/// @ingroup modm_board_nucleo_f091rc
99121
/// @{
100122
using LoggerDevice = modm::IODeviceWrapper< stlink::Uart, modm::IOBuffer::BlockIfFull >;
@@ -108,6 +130,20 @@ initialize()
108130
stlink::Uart::connect<stlink::Tx::Tx, stlink::Rx::Rx>();
109131
stlink::Uart::initialize<SystemClock, 115200_Bd>();
110132
}
133+
134+
inline void
135+
initializeI2c()
136+
{
137+
i2c::Controller::connect<i2c::Sda::Sda, i2c::Scl::Scl>();
138+
i2c::Controller::initialize<SystemClock, 400_kHz>();
139+
}
140+
141+
inline void
142+
initializeSpi()
143+
{
144+
spi::Controller::connect<spi::Sck::Sck, spi::Sdo::Mosi, spi::Sdi::Miso>();
145+
spi::Controller::initialize<SystemClock, 3_MHz>();
146+
}
111147
/// @}
112148

113149
}

src/modm/board/nucleo_f091rc/module.lb

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,8 +23,16 @@ def prepare(module, options):
2323
if not options[":target"].partname.startswith("stm32f091rct"):
2424
return False
2525

26-
module.depends(":platform:core", ":platform:gpio", ":platform:clock", ":platform:uart:2",
27-
":debug", ":architecture:clock", ":architecture:clock")
26+
module.depends(
27+
":architecture:clock",
28+
":debug",
29+
":platform:clock",
30+
":platform:core",
31+
":platform:gpio",
32+
":platform:i2c:1",
33+
":platform:spi:1",
34+
":platform:uart:2"
35+
)
2836
return True
2937

3038

src/modm/board/nucleo_f103rb/board.hpp

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -107,6 +107,28 @@ using Uart = Usart2;
107107
/// @}
108108
}
109109

110+
namespace i2c
111+
{
112+
/// @ingroup modm_board_nucleo_f091rc
113+
/// @{
114+
using Sda = D14;
115+
using Scl = D15;
116+
using Controller = I2cMaster1;
117+
/// @}
118+
}
119+
120+
namespace spi
121+
{
122+
/// @ingroup modm_board_nucleo_f091rc
123+
/// @{
124+
using Cs = D10;
125+
using Sck = D13;
126+
using Sdi = D12;
127+
using Sdo = D11;
128+
using Controller = SpiMaster1;
129+
/// @}
130+
}
131+
110132
/// @ingroup modm_board_nucleo_f103rb
111133
/// @{
112134
using LoggerDevice = modm::IODeviceWrapper< stlink::Uart, modm::IOBuffer::BlockIfFull >;
@@ -125,6 +147,20 @@ initialize()
125147
// Enable PB4 as GPIO
126148
AFIO->MAPR |= AFIO_MAPR_SWJ_CFG_JTAGDISABLE;
127149
}
150+
151+
inline void
152+
initializeI2c()
153+
{
154+
i2c::Controller::connect<i2c::Sda::Sda, i2c::Scl::Scl>();
155+
i2c::Controller::initialize<SystemClock, 427_kHz>();
156+
}
157+
158+
inline void
159+
initializeSpi()
160+
{
161+
spi::Controller::connect<spi::Sck::Sck, spi::Sdo::Mosi, spi::Sdi::Miso>();
162+
spi::Controller::initialize<SystemClock, 4_MHz>();
163+
}
128164
/// @}
129165

130166
}

0 commit comments

Comments
 (0)