Skip to content

Commit 89bff92

Browse files
committed
restored spi_hal
1 parent 5c40a8d commit 89bff92

File tree

2 files changed

+38
-11
lines changed

2 files changed

+38
-11
lines changed

src/modm/platform/spi/stm32/spi_hal.hpp.in

Lines changed: 22 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -93,9 +93,28 @@ public:
9393
* It is your responsibility to check if the register
9494
* is empty!
9595
*/
96-
template<std::unsigned_integral T>
9796
static void
98-
write(T data);
97+
write(uint16_t data);
98+
99+
/**
100+
* Write 8 Bit to the data register
101+
*
102+
* @warning This method does NOT do any sanity checks!!
103+
* It is your responsibility to check if the register
104+
* is empty!
105+
*/
106+
static void
107+
write(uint8_t data);
108+
109+
/**
110+
* Returns the value of the data register
111+
*
112+
* @warning This method does NOT do any sanity checks!!
113+
* It is your responsibility to check if the register
114+
* contains something useful!
115+
*/
116+
static void
117+
read(uint8_t &data);
99118

100119
/**
101120
* Returns the value of the data register
@@ -104,9 +123,8 @@ public:
104123
* It is your responsibility to check if the register
105124
* contains something useful!
106125
*/
107-
template<std::unsigned_integral T>
108126
static void
109-
read(T &data);
127+
read(uint16_t &data);
110128

111129
static void
112130
enableInterruptVector(bool enable, uint32_t priority);

src/modm/platform/spi/stm32/spi_hal_impl.hpp.in

Lines changed: 16 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -127,24 +127,33 @@ modm::platform::SpiHal{{ id }}::isTransmitRegisterEmpty()
127127
return static_cast<bool>(getInterruptFlags() & InterruptFlag::TxBufferEmpty);
128128
}
129129

130-
// TODO treat data-size option
131-
template<std::unsigned_integral T>
132130
void inline
133-
modm::platform::SpiHal{{ id }}::write(T data)
131+
modm::platform::SpiHal{{ id }}::write(uint16_t data)
132+
{
133+
SPI{{ id }}->DR = data;
134+
}
135+
136+
void inline
137+
modm::platform::SpiHal{{ id }}::write(uint8_t data)
134138
{
135139
%% if "data-size" in features
136-
*((__IO T *) &SPI{{ id}}->DR) = data;
140+
*((__IO uint8_t *) &SPI{{ id}}->DR) = data;
137141
%% else
138142
write(static_cast<uint16_t>(data));
139143
%% endif
140144

141145
}
142146

143-
template<std::unsigned_integral T>
144147
void inline
145-
modm::platform::SpiHal{{ id }}::read(T &data)
148+
modm::platform::SpiHal{{ id }}::read(uint8_t &data)
149+
{
150+
data = static_cast<uint8_t>(SPI{{ id }}->DR);
151+
}
152+
153+
void inline
154+
modm::platform::SpiHal{{ id }}::read(uint16_t &data)
146155
{
147-
data = static_cast<T>(SPI{{ id }}->DR);
156+
data = static_cast<uint16_t>(SPI{{ id }}->DR);
148157
}
149158

150159
void inline

0 commit comments

Comments
 (0)