forked from espressif/arduino-esp32
SPI: Ensure all read-only data pointers are marked as const (#3356)
This changes all SPI functions that take data pointers which are not modified so that the declaration is const. This allows them to be used with const data (i.e. held in flash). No functional changes are required. The defnitions of spiWrite() and spiTransferBytes() in esp-hal-spi.h/c have been updated to be consistent. Tests: - Build a simple sketch using SPI.writePattern() and SPI.transferBytes() which uses const data and verify that the attached device functions as expected.
This commit is contained in:
committed by
Me No Dev
parent
611ba8ea8a
commit
b847f41e24
@ -238,7 +238,7 @@ void SPIClass::writePixels(const void * data, uint32_t size)
|
||||
* @param out uint8_t * output buffer. can be NULL for Write Only operation
|
||||
* @param size uint32_t
|
||||
*/
|
||||
void SPIClass::transferBytes(uint8_t * data, uint8_t * out, uint32_t size)
|
||||
void SPIClass::transferBytes(const uint8_t * data, uint8_t * out, uint32_t size)
|
||||
{
|
||||
if(_inTransaction){
|
||||
return spiTransferBytesNL(_spi, data, out, size);
|
||||
@ -251,7 +251,7 @@ void SPIClass::transferBytes(uint8_t * data, uint8_t * out, uint32_t size)
|
||||
* @param size uint8_t max for size is 64Byte
|
||||
* @param repeat uint32_t
|
||||
*/
|
||||
void SPIClass::writePattern(uint8_t * data, uint8_t size, uint32_t repeat)
|
||||
void SPIClass::writePattern(const uint8_t * data, uint8_t size, uint32_t repeat)
|
||||
{
|
||||
if(size > 64) {
|
||||
return; //max Hardware FIFO
|
||||
@ -272,12 +272,12 @@ void SPIClass::writePattern(uint8_t * data, uint8_t size, uint32_t repeat)
|
||||
}
|
||||
}
|
||||
|
||||
void SPIClass::writePattern_(uint8_t * data, uint8_t size, uint8_t repeat)
|
||||
void SPIClass::writePattern_(const uint8_t * data, uint8_t size, uint8_t repeat)
|
||||
{
|
||||
uint8_t bytes = (size * repeat);
|
||||
uint8_t buffer[64];
|
||||
uint8_t * bufferPtr = &buffer[0];
|
||||
uint8_t * dataPtr;
|
||||
const uint8_t * dataPtr;
|
||||
uint8_t dataSize = bytes;
|
||||
for(uint8_t i = 0; i < repeat; i++) {
|
||||
dataSize = size;
|
||||
|
Reference in New Issue
Block a user