mirror of
https://github.com/MarlinFirmware/Marlin.git
synced 2024-11-27 13:56:24 +00:00
STM32 - Fix SD write (#12897)
This commit is contained in:
parent
294521439e
commit
64a4649290
@ -116,10 +116,9 @@ uint8_t spiRec(void) {
|
|||||||
*/
|
*/
|
||||||
void spiRead(uint8_t* buf, uint16_t nbyte) {
|
void spiRead(uint8_t* buf, uint16_t nbyte) {
|
||||||
if (nbyte == 0) return;
|
if (nbyte == 0) return;
|
||||||
|
memset(buf, 0xFF, nbyte);
|
||||||
SPI.beginTransaction(spiConfig);
|
SPI.beginTransaction(spiConfig);
|
||||||
for (int i = 0; i < nbyte; i++) {
|
SPI.transfer(buf, nbyte);
|
||||||
buf[i] = SPI.transfer(0xFF);
|
|
||||||
}
|
|
||||||
SPI.endTransaction();
|
SPI.endTransaction();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -145,9 +144,10 @@ void spiSend(uint8_t b) {
|
|||||||
* @details Use DMA
|
* @details Use DMA
|
||||||
*/
|
*/
|
||||||
void spiSendBlock(uint8_t token, const uint8_t* buf) {
|
void spiSendBlock(uint8_t token, const uint8_t* buf) {
|
||||||
|
uint8_t rxBuf[512];
|
||||||
SPI.beginTransaction(spiConfig);
|
SPI.beginTransaction(spiConfig);
|
||||||
SPI.transfer(token);
|
SPI.transfer(token);
|
||||||
SPI.transfer((uint8_t*)buf, (uint8_t*)0, 512);
|
SPI.transfer((uint8_t*)buf, &rxBuf, 512);
|
||||||
SPI.endTransaction();
|
SPI.endTransaction();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user