File tree Expand file tree Collapse file tree 2 files changed +38
-11
lines changed
src/modm/platform/spi/stm32 Expand file tree Collapse file tree 2 files changed +38
-11
lines changed Original file line number Diff line number Diff line change @@ -93,9 +93,28 @@ public:
93
93
* It is your responsibility to check if the register
94
94
* is empty!
95
95
*/
96
- template<std::unsigned_integral T>
97
96
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);
99
118
100
119
/**
101
120
* Returns the value of the data register
@@ -104,9 +123,8 @@ public:
104
123
* It is your responsibility to check if the register
105
124
* contains something useful!
106
125
*/
107
- template<std::unsigned_integral T>
108
126
static void
109
- read(T &data);
127
+ read(uint16_t &data);
110
128
111
129
static void
112
130
enableInterruptVector(bool enable, uint32_t priority);
Original file line number Diff line number Diff line change @@ -127,24 +127,33 @@ modm::platform::SpiHal{{ id }}::isTransmitRegisterEmpty()
127
127
return static_cast<bool>(getInterruptFlags() & InterruptFlag::TxBufferEmpty);
128
128
}
129
129
130
- // TODO treat data-size option
131
- template<std::unsigned_integral T>
132
130
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)
134
138
{
135
139
%% if "data-size" in features
136
- *((__IO T *) &SPI{{ id}}->DR) = data;
140
+ *((__IO uint8_t *) &SPI{{ id}}->DR) = data;
137
141
%% else
138
142
write(static_cast<uint16_t>(data));
139
143
%% endif
140
144
141
145
}
142
146
143
- template<std::unsigned_integral T>
144
147
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)
146
155
{
147
- data = static_cast<T >(SPI{{ id }}->DR);
156
+ data = static_cast<uint16_t >(SPI{{ id }}->DR);
148
157
}
149
158
150
159
void inline
You can’t perform that action at this time.
0 commit comments