Skip to content

Commit 00318cf

Browse files
committed
Merge branch 'bit-resolution-Spi' into rewrite-graphics-API
2 parents a10c9dc + b7a28d7 commit 00318cf

File tree

19 files changed

+66
-63
lines changed

19 files changed

+66
-63
lines changed

examples/nucleo_f042k6/spi_dma/main.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ int main()
3333
uint8_t receiveBuffer[13];
3434

3535
// send out 12 bytes, don't care about response
36-
Spi::transferBlocking(sendBuffer, nullptr, 12);
36+
Spi::transferBlocking(sendBuffer, (uint8_t*)(nullptr), 12);
3737

3838
// send out 12 bytes, read in 12 bytes
3939
Spi::transferBlocking(sendBuffer, receiveBuffer, 12);

examples/nucleo_f303re/spi_dma/main.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ int main()
3333
uint8_t receiveBuffer[13];
3434

3535
// send out 12 bytes, don't care about response
36-
Spi::transferBlocking(sendBuffer, nullptr, 12);
36+
Spi::transferBlocking(sendBuffer, (uint8_t*)(nullptr), 12);
3737

3838
// send out 12 bytes, read in 12 bytes
3939
Spi::transferBlocking(sendBuffer, receiveBuffer, 12);

examples/nucleo_l432kc/spi_dma/main.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ int main()
3434
uint8_t receiveBuffer[13];
3535

3636
// send out 12 bytes, don't care about response
37-
Spi::transferBlocking(sendBuffer, nullptr, 12);
37+
Spi::transferBlocking(sendBuffer, (uint8_t*)(nullptr), 12);
3838

3939
// send out 12 bytes, read in 12 bytes
4040
Spi::transferBlocking(sendBuffer, receiveBuffer, 12);

src/modm/driver/can/mcp2515_impl.hpp

Lines changed: 26 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -70,22 +70,22 @@ modm::Mcp2515<SPI, CS, INT>::initializeWithPrescaler(
7070
// software reset for the mcp2515, after this the chip is back in the
7171
// configuration mode
7272
chipSelect.reset();
73-
spi.transferBlocking(RESET);
73+
spi.transferBlocking(uint8_t(RESET));
7474
modm::delay_ms(1);
7575
chipSelect.set();
7676

7777
// wait a bit to give the MCP2515 some time to restart
7878
modm::delay_ms(30);
7979

8080
chipSelect.reset();
81-
spi.transferBlocking(WRITE);
82-
spi.transferBlocking(CNF3);
81+
spi.transferBlocking(uint8_t(WRITE));
82+
spi.transferBlocking(uint8_t(CNF3));
8383

8484
// load CNF1..3
85-
spi.transferBlocking(cnf, nullptr, 3);
85+
spi.transferBlocking(cnf, (uint8_t*)(nullptr), 3);
8686

8787
// enable interrupts
88-
spi.transferBlocking(RX1IE | RX0IE);
88+
spi.transferBlocking(uint8_t(RX1IE | RX0IE));
8989
chipSelect.set();
9090

9191
// set TXnRTS pins as inwrites
@@ -146,7 +146,7 @@ modm::Mcp2515<SPI, CS, INT>::setFilter(accessor::Flash<uint8_t> filter)
146146
for (i = 0; i < 0x30; i += 0x10)
147147
{
148148
chipSelect.reset();
149-
spi.transferBlocking(WRITE);
149+
spi.transferBlocking(uint8_t(WRITE));
150150
spi.transferBlocking(i);
151151

152152
for (j = 0; j < 12; j++)
@@ -222,10 +222,10 @@ modm::Mcp2515<SPI, CS, INT>::getMessage(can::Message& message)
222222
else {
223223
message.flags.rtr = false;
224224
}
225-
message.length = spi.transferBlocking(0xff) & 0x0f;
225+
message.length = spi.transferBlocking(uint8_t(0xff)) & 0x0f;
226226

227227
for (uint8_t i = 0; i < message.length; ++i) {
228-
message.data[i] = spi.transferBlocking(0xff);
228+
message.data[i] = spi.transferBlocking(uint8_t(0xff));
229229
}
230230
chipSelect.set();
231231

@@ -279,12 +279,12 @@ modm::Mcp2515<SPI, CS, INT>::sendMessage(const can::Message& message)
279279
}
280280

281281
chipSelect.reset();
282-
spi.transferBlocking(WRITE_TX | address);
282+
spi.transferBlocking(uint8_t(WRITE_TX | address));
283283
writeIdentifier(message.identifier, message.flags.extended);
284284

285285
// if the message is a rtr-frame, is has a length but no attached data
286286
if (message.flags.rtr) {
287-
spi.transferBlocking(MCP2515_RTR | message.length);
287+
spi.transferBlocking(uint8_t(MCP2515_RTR | message.length));
288288
}
289289
else {
290290
spi.transferBlocking(message.length);
@@ -300,7 +300,7 @@ modm::Mcp2515<SPI, CS, INT>::sendMessage(const can::Message& message)
300300
// send message via RTS command
301301
chipSelect.reset();
302302
address = (address == 0) ? 1 : address; // 0 2 4 => 1 2 4
303-
spi.transferBlocking(RTS | address);
303+
spi.transferBlocking(uint8_t(RTS | address));
304304
chipSelect.set();
305305

306306
return address;
@@ -314,7 +314,7 @@ modm::Mcp2515<SPI, CS, INT>::writeRegister(uint8_t address, uint8_t data)
314314
{
315315
chipSelect.reset();
316316

317-
spi.transferBlocking(WRITE);
317+
spi.transferBlocking(uint8_t(WRITE));
318318
spi.transferBlocking(address);
319319
spi.transferBlocking(data);
320320

@@ -327,9 +327,9 @@ modm::Mcp2515<SPI, CS, INT>::readRegister(uint8_t address)
327327
{
328328
chipSelect.reset();
329329

330-
spi.transferBlocking(READ);
330+
spi.transferBlocking(uint8_t(READ));
331331
spi.transferBlocking(address);
332-
uint8_t data = spi.transferBlocking(0xff);
332+
uint8_t data = spi.transferBlocking(uint8_t(0xff));
333333

334334
chipSelect.set();
335335

@@ -342,7 +342,7 @@ modm::Mcp2515<SPI, CS, INT>::bitModify(uint8_t address, uint8_t mask, uint8_t da
342342
{
343343
chipSelect.reset();
344344

345-
spi.transferBlocking(BIT_MODIFY);
345+
spi.transferBlocking(uint8_t(BIT_MODIFY));
346346
spi.transferBlocking(address);
347347
spi.transferBlocking(mask);
348348
spi.transferBlocking(data);
@@ -357,7 +357,7 @@ modm::Mcp2515<SPI, CS, INT>::readStatus(uint8_t type)
357357
chipSelect.reset();
358358

359359
spi.transferBlocking(type);
360-
uint8_t data = spi.transferBlocking(0xff);
360+
uint8_t data = spi.transferBlocking(uint8_t(0xff));
361361

362362
chipSelect.set();
363363

@@ -391,10 +391,10 @@ modm::Mcp2515<SPI, CS, INT>::writeIdentifier(const uint32_t& identifier,
391391
}
392392
else
393393
{
394-
spi.transferBlocking(*((uint16_t *) ptr) >> 3);
395-
spi.transferBlocking(*((uint8_t *) ptr) << 5);
396-
spi.transferBlocking(0);
397-
spi.transferBlocking(0);
394+
spi.transferBlocking(uint8_t(*((uint16_t *) ptr) >> 3));
395+
spi.transferBlocking(uint8_t(*((uint8_t *) ptr) << 5));
396+
397+
spi.transferBlocking(uint16_t(0));
398398
}
399399
}
400400

@@ -406,31 +406,31 @@ modm::Mcp2515<SPI, CS, INT>::readIdentifier(uint32_t& identifier)
406406

407407
uint32_t *ptr = &identifier;
408408

409-
uint8_t first = spi.transferBlocking(0xff);
410-
uint8_t second = spi.transferBlocking(0xff);
409+
uint8_t first = spi.transferBlocking(uint8_t(0xff));
410+
uint8_t second = spi.transferBlocking(uint8_t(0xff));
411411

412412
if (second & MCP2515_IDE)
413413
{
414414
*((uint16_t *) ptr + 1) = (uint16_t) first << 5;
415-
*((uint8_t *) ptr + 1) = spi.transferBlocking(0xff);
415+
*((uint8_t *) ptr + 1) = spi.transferBlocking(uint8_t(0xff));
416416

417417
*((uint8_t *) ptr + 2) |= (second >> 3) & 0x1C;
418418
*((uint8_t *) ptr + 2) |= second & 0x03;
419419

420-
*((uint8_t *) ptr) = spi.transferBlocking(0xff);
420+
*((uint8_t *) ptr) = spi.transferBlocking(uint8_t(0xff));
421421

422422
return true;
423423
}
424424
else
425425
{
426-
spi.transferBlocking(0xff);
426+
spi.transferBlocking(uint8_t(0xff));
427427

428428
*((uint8_t *) ptr + 3) = 0;
429429
*((uint8_t *) ptr + 2) = 0;
430430

431431
*((uint16_t *) ptr) = (uint16_t) first << 3;
432432

433-
spi.transferBlocking(0xff);
433+
spi.transferBlocking(uint8_t(0xff));
434434

435435
*((uint8_t *) ptr) |= second >> 5;
436436

src/modm/driver/display/ili9341_interface_parallel.hpp

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
/*
22
* Copyright (c) 2020, Pavel Pletenev
3-
* Copyright (c) 2021, Thomas Sommer
3+
* Copyright (c) 2020, Thomas Sommer
44
*
55
* This file is part of the modm project.
66
*
@@ -39,14 +39,20 @@ class Ili9341InterfaceParallel: public ili9341_register
3939
for(std::size_t i=0; i<length; ++i)
4040
interface.writeData(args[i]);
4141
}
42+
43+
void
44+
writeData(color::Rgb565 data)
45+
{
46+
interface.writeData(data.color);
47+
}
48+
4249
void
43-
writeData(uint8_t const *data, std::size_t length)
50+
writeData(color::Rgb565 const *data, std::size_t length)
4451
{
45-
auto const data16 = reinterpret_cast<uint16_t const*>(data);
46-
size_t const length16 = length / 2;
47-
for(std::size_t i=0; i<length16; ++i)
48-
interface.writeData(modm::fromBigEndian(data16[i]));
52+
for(std::size_t i=0; i < length; ++i)
53+
interface.writeData(data[i].color);
4954
}
55+
5056
void
5157
writeCommandValue8(Command command, uint8_t value)
5258
{

src/modm/driver/display/ili9341_interface_spi.hpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -153,7 +153,7 @@ class Ili9341InterfaceSpi : public ili9341_register, public modm::SpiDevice< Spi
153153
RF_WAIT_UNTIL(this->acquireMaster());
154154
Cs::reset();
155155

156-
RF_CALL(SpiMaster::template transfer<uint16_t>((uint16_t*)(pixel), repeat));
156+
RF_CALL(SpiMaster::transfer((uint16_t*)(pixel), repeat));
157157

158158
if (this->releaseMaster())
159159
Cs::set();
@@ -169,7 +169,7 @@ class Ili9341InterfaceSpi : public ili9341_register, public modm::SpiDevice< Spi
169169
RF_WAIT_UNTIL(this->acquireMaster());
170170
Cs::reset();
171171

172-
RF_CALL(SpiMaster::template transfer<uint16_t>((uint16_t*)(pixels), nullptr, length));
172+
RF_CALL(SpiMaster::transfer((uint16_t*)(pixels), nullptr, length));
173173

174174
if (this->releaseMaster())
175175
Cs::set();

src/modm/driver/display/siemens_s65_impl.hpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -280,7 +280,7 @@ modm::SiemensS65Portrait<SPI, CS, RS, Reset>::update() {
280280
} // pix
281281

282282
// use transfer() of SPI to transfer spiBuffer
283-
SPI::transferBlocking(spiBuffer, nullptr, 16);
283+
SPI::transferBlocking(spiBuffer, (uint8_t*)(nullptr), 16);
284284
} // y
285285
} // x
286286
#endif
@@ -383,7 +383,7 @@ modm::SiemensS65Landscape<SPI, CS, RS, Reset>::update() {
383383
} // pix
384384

385385
// use transfer() of SPI to transfer spiBuffer
386-
SPI::transferBlocking(spiBuffer, nullptr, bufSize);
386+
SPI::transferBlocking(spiBuffer, (uint8_t*)(nullptr), bufSize);
387387
} // y
388388
} // x
389389
#endif

src/modm/driver/display/st7586s.hpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ class St7586s : public MonochromeGraphicDisplayHorizontal<Width, Height>
2626
static constexpr uint8_t pixelsPerByte = 3;
2727

2828
void sendCommand(Command cmd, const void *data = nullptr, size_t len = 0);
29+
2930
template <typename Data>
3031
void sendCommand(Command cmd, Data data) {
3132
sendCommand(cmd, &data, sizeof(data));

src/modm/driver/display/st7586s_impl.hpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ St7586s<SPI, CS, RST, DC, Width, Height>::sendCommand(Command cmd, const void *d
2727
SPI::transferBlocking(static_cast<uint8_t>(cmd));
2828
DC::set(); // data mode
2929
if (len > 0) {
30-
SPI::transferBlocking(reinterpret_cast<const uint8_t*>(data), nullptr, len);
30+
SPI::transferBlocking(reinterpret_cast<const uint8_t*>(data), (uint8_t*)(nullptr), len);
3131
}
3232
CS::set();
3333
// exit with data mode on

src/modm/driver/gpio/mcp23_transport_impl.hpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -136,7 +136,7 @@ modm::Mcp23TransportSpi<SpiMaster, Cs>::read(uint8_t reg, uint8_t *buffer, uint8
136136
RF_CALL(SpiMaster::transfer(address | Read));
137137
RF_CALL(SpiMaster::transfer(reg));
138138

139-
RF_CALL(SpiMaster::transfer(nullptr, buffer, length));
139+
RF_CALL(SpiMaster::transfer((uint8_t*)(nullptr), buffer, length));
140140

141141
if (this->releaseMaster())
142142
Cs::set();

src/modm/driver/inertial/lis3_transport_impl.hpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -105,7 +105,7 @@ modm::Lis3TransportSpi<SpiMaster, Cs>::read(uint8_t reg, uint8_t *buffer, uint8_
105105

106106
RF_CALL(SpiMaster::transfer(reg | Read));
107107

108-
RF_CALL(SpiMaster::transfer(nullptr, buffer, length));
108+
RF_CALL(SpiMaster::transfer((uint8_t*)(nullptr), buffer, length));
109109

110110
if (this->releaseMaster())
111111
Cs::set();

src/modm/driver/pwm/apa102.hpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,7 @@ class Apa102
9090
modm::ResumableResult<void>
9191
write()
9292
{
93-
return SpiMaster::transfer(data, nullptr, length);
93+
return SpiMaster::transfer(data, (uint8_t*)(nullptr), length);
9494
}
9595
};
9696

src/modm/driver/pwm/tlc594x_impl.hpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -225,7 +225,7 @@ modm::TLC594X<CHANNELS, Spi, Xlat, Xblank, Vprog, Xerr>::writeDotCorrection(bool
225225
Vprog::set();
226226

227227
// transfer
228-
RF_CALL(Spi::transfer(dc, nullptr, CHANNELS*3/4));
228+
RF_CALL(Spi::transfer(dc, (uint8_t*)(nullptr), CHANNELS*3/4));
229229
if (flush) latch();
230230

231231
Vprog::reset();

src/modm/driver/radio/sx1276_impl.hpp

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -173,8 +173,8 @@ Sx1276<SpiMaster, Cs>::transmit(uint8_t* data, uint8_t length)
173173

174174
Cs::reset();
175175

176-
RF_CALL(SpiMaster::transfer(buffer,nullptr,1));
177-
RF_CALL(SpiMaster::transfer(data,nullptr,length));
176+
RF_CALL(SpiMaster::transfer(buffer, (uint8_t*)(nullptr), 1));
177+
RF_CALL(SpiMaster::transfer(data, (uint8_t*)(nullptr), length));
178178

179179
if(this->releaseMaster())
180180
{
@@ -251,16 +251,16 @@ Sx1276<SpiMaster, Cs>::readPacket(uint8_t* data, uint8_t maxLength)
251251

252252
Cs::reset();
253253

254-
RF_CALL(SpiMaster::transfer(buffer,nullptr,1));
254+
RF_CALL(SpiMaster::transfer(buffer, (uint8_t*)(nullptr), 1));
255255
if(lastPacketSize > maxLength)
256256
{
257257
MODM_LOG_ERROR<<"SX1276: Read buffer is too small, packet discarded!"<<modm::endl;
258258
//read it out anyway to clean the fifo
259-
RF_CALL(SpiMaster::transfer(nullptr,nullptr,lastPacketSize));
259+
RF_CALL(SpiMaster::transfer((uint8_t*)(nullptr),(uint8_t*)(nullptr),lastPacketSize));
260260
}
261261
else
262262
{
263-
RF_CALL(SpiMaster::transfer(nullptr,data,lastPacketSize));
263+
RF_CALL(SpiMaster::transfer((uint8_t*)(nullptr), data, lastPacketSize));
264264
}
265265

266266
if(this->releaseMaster())

src/modm/driver/storage/block_device_spiflash_impl.hpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -202,7 +202,7 @@ modm::BdSpiFlash<Spi, Cs, flashSize>::spiOperation(Instruction instruction, size
202202
RF_WAIT_UNTIL(this->acquireMaster());
203203
Cs::reset();
204204

205-
RF_CALL(Spi::transfer(instructionBuffer, nullptr, i));
205+
RF_CALL(Spi::transfer(instructionBuffer, (uint8_t*)(nullptr), i));
206206

207207
if(dataLength > 0) {
208208
RF_CALL(Spi::transfer(const_cast<uint8_t*>(txData), rxData, dataLength));

src/modm/driver/temperature/ltc2984_impl.hpp

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -140,7 +140,7 @@ modm::Ltc2984<SpiMaster, Cs>::writeData(Register address, uint8_t* data, size_t
140140
buffer[3+i] = data[length-1-i];
141141
}
142142

143-
RF_CALL(SpiMaster::transfer(buffer, nullptr, length+3));
143+
RF_CALL(SpiMaster::transfer(buffer, (uint8_t*)(nullptr), length+3));
144144

145145
if (this->releaseMaster()) {
146146
Cs::set();
@@ -170,8 +170,8 @@ modm::Ltc2984<SpiMaster, Cs>::readFourBytes(Register address, uint8_t* data)
170170
buffer[1] = static_cast<uint16_t>(address) >> 8;
171171
buffer[2] = static_cast<uint16_t>(address);
172172

173-
RF_CALL(SpiMaster::transfer(buffer, nullptr, 3));
174-
RF_CALL(SpiMaster::transfer(nullptr, buffer, 4));
173+
RF_CALL(SpiMaster::transfer(buffer, (uint8_t*)(nullptr), 3));
174+
RF_CALL(SpiMaster::transfer((uint8_t*)(nullptr), buffer, 4));
175175

176176
// swap byte order
177177
data[0] = buffer[3];
@@ -200,8 +200,8 @@ modm::Ltc2984<SpiMaster, Cs>::readByte(Register address, uint8_t& command)
200200
buffer[1] = static_cast<uint16_t>(address) >> 8;
201201
buffer[2] = static_cast<uint16_t>(address);
202202

203-
RF_CALL(SpiMaster::transfer(buffer, nullptr, 3));
204-
RF_CALL(SpiMaster::transfer(nullptr, &command, 1));
203+
RF_CALL(SpiMaster::transfer(buffer, (uint8_t*)(nullptr), 3));
204+
RF_CALL(SpiMaster::transfer((uint8_t*)(nullptr), &command, 1));
205205

206206
if (this->releaseMaster()) {
207207
Cs::set();

0 commit comments

Comments
 (0)