Initial HAL SPI API

This commit is contained in:
Christopher Pepper
2017-07-25 17:27:53 +01:00
committed by Scott Lahteine
parent 44b0c186a6
commit bcd050f33b
5 changed files with 465 additions and 20 deletions

View File

@ -37,12 +37,12 @@
// --------------------------------------------------------------------------
#include "../../../MarlinConfig.h"
#include "../spi_api.h"
// --------------------------------------------------------------------------
// Public Variables
// --------------------------------------------------------------------------
// --------------------------------------------------------------------------
// Public functions
// --------------------------------------------------------------------------
@ -138,39 +138,32 @@
}
#else
void spiBegin() {
HAL::SPI::initialise(SD_SPI_CHANNEL);
}
void spiInit(uint8_t spiRate) {
uint32_t freq = 8000000 / (1u << spiRate);
HAL::SPI::set_frequency(SD_SPI_CHANNEL, freq);
}
void spiSend(byte b) {
}
void spiSend(const uint8_t* buf, size_t n) {
}
void spiSend(uint32_t chan, byte b) {
}
void spiSend(uint32_t chan, const uint8_t* buf, size_t n) {
HAL::SPI::write(SD_SPI_CHANNEL, b);
}
// Read single byte from SPI
uint8_t spiRec() {
return 0;
}
uint8_t spiRec(uint32_t chan) {
return 0;
return HAL::SPI::read(SD_SPI_CHANNEL);
}
// Read from SPI into buffer
void spiRead(uint8_t*buf, uint16_t nbyte) {
HAL::SPI::read(SD_SPI_CHANNEL, buf, nbyte);
}
// Write from buffer to SPI
void spiSendBlock(uint8_t token, const uint8_t* buf) {
HAL::SPI::write(SD_SPI_CHANNEL, token);
HAL::SPI::write(SD_SPI_CHANNEL, buf, 512);
}
#endif // ENABLED(SOFTWARE_SPI)