Skip to content

Commit

Permalink
🎨 Apply const (MarlinFirmware#25643)
Browse files Browse the repository at this point in the history
  • Loading branch information
thinkyhead authored and Andy-Big committed Jul 11, 2023
1 parent f5a812a commit 8a70e18
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 18 deletions.
2 changes: 1 addition & 1 deletion Marlin/src/MarlinCore.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -785,7 +785,7 @@ inline void manage_inactivity(const bool no_stepper_sleep=false) {
* - Update the Průša MMU2
* - Handle Joystick jogging
*/
void idle(bool no_stepper_sleep/*=false*/) {
void idle(const bool no_stepper_sleep/*=false*/) {
#ifdef MAX7219_DEBUG_PROFILE
CodeProfiler idle_profiler;
#endif
Expand Down
2 changes: 1 addition & 1 deletion Marlin/src/MarlinCore.h
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
void stop();

// Pass true to keep steppers from timing out
void idle(bool no_stepper_sleep=false);
void idle(const bool no_stepper_sleep=false);
inline void idle_no_sleep() { idle(true); }

#if ENABLED(G38_PROBE_TARGET)
Expand Down
18 changes: 9 additions & 9 deletions Marlin/src/lcd/extui/mks_ui/SPIFlashStorage.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -148,7 +148,7 @@ uint32_t SPIFlashStorage::m_startAddress;

#endif // HAS_SPI_FLASH_COMPRESSION

void SPIFlashStorage::beginWrite(uint32_t startAddress) {
void SPIFlashStorage::beginWrite(const uint32_t startAddress) {
m_pageDataUsed = 0;
m_currentPage = 0;
m_startAddress = startAddress;
Expand All @@ -171,7 +171,7 @@ void SPIFlashStorage::endWrite() {
#endif
}

void SPIFlashStorage::savePage(uint8_t *buffer) {
void SPIFlashStorage::savePage(uint8_t * const buffer) {
W25QXX.SPI_FLASH_BufferWrite(buffer, m_startAddress + (SPI_FLASH_PageSize * m_currentPage), SPI_FLASH_PageSize);
// Test env
// char fname[256];
Expand All @@ -181,7 +181,7 @@ void SPIFlashStorage::savePage(uint8_t *buffer) {
// fclose(fp);
}

void SPIFlashStorage::loadPage(uint8_t *buffer) {
void SPIFlashStorage::loadPage(uint8_t * const buffer) {
W25QXX.SPI_FLASH_BufferRead(buffer, m_startAddress + (SPI_FLASH_PageSize * m_currentPage), SPI_FLASH_PageSize);
// Test env
// char fname[256];
Expand Down Expand Up @@ -260,20 +260,20 @@ void SPIFlashStorage::readPage() {
#endif
}

uint16_t SPIFlashStorage::inData(uint8_t *data, uint16_t size) {
uint16_t SPIFlashStorage::inData(const uint8_t * const data, uint16_t size) {
// Don't write more than we can
NOMORE(size, pageDataFree());
memcpy(m_pageData + m_pageDataUsed, data, size);
m_pageDataUsed += size;
return size;
}

void SPIFlashStorage::writeData(uint8_t *data, uint16_t size) {
void SPIFlashStorage::writeData(const uint8_t *data, uint16_t size) {
// Flush a page if needed
if (pageDataFree() == 0) flushPage();

while (size > 0) {
uint16_t written = inData(data, size);
const uint16_t written = inData(data, size);
size -= written;
// Need to write more? Flush page and continue!
if (size > 0) {
Expand All @@ -283,7 +283,7 @@ void SPIFlashStorage::writeData(uint8_t *data, uint16_t size) {
}
}

void SPIFlashStorage::beginRead(uint32_t startAddress) {
void SPIFlashStorage::beginRead(const uint32_t startAddress) {
m_startAddress = startAddress;
m_currentPage = 0;
// Nothing in memory now
Expand All @@ -293,7 +293,7 @@ void SPIFlashStorage::beginRead(uint32_t startAddress) {
#endif
}

uint16_t SPIFlashStorage::outData(uint8_t *data, uint16_t size) {
uint16_t SPIFlashStorage::outData(uint8_t * const data, uint16_t size) {
// Don't read more than we have
NOMORE(size, pageDataFree());
memcpy(data, m_pageData + m_pageDataUsed, size);
Expand All @@ -306,7 +306,7 @@ void SPIFlashStorage::readData(uint8_t *data, uint16_t size) {
if (pageDataFree() == 0) readPage();

while (size > 0) {
uint16_t read = outData(data, size);
const uint16_t read = outData(data, size);
size -= read;
// Need to write more? Flush page and continue!
if (size > 0) {
Expand Down
14 changes: 7 additions & 7 deletions Marlin/src/lcd/extui/mks_ui/SPIFlashStorage.h
Original file line number Diff line number Diff line change
Expand Up @@ -75,23 +75,23 @@
class SPIFlashStorage {
public:
// Write operation
static void beginWrite(uint32_t startAddress);
static void beginWrite(const uint32_t startAddress);
static void endWrite();
static void writeData(uint8_t *data, uint16_t size);
static void writeData(const uint8_t *data, uint16_t size);

// Read operation
static void beginRead(uint32_t startAddress);
static void beginRead(const uint32_t startAddress);
static void readData(uint8_t *data, uint16_t size);

static uint32_t getCurrentPage() { return m_currentPage; }

private:
static void flushPage();
static void savePage(uint8_t *buffer);
static void loadPage(uint8_t *buffer);
static void savePage(uint8_t * const buffer);
static void loadPage(uint8_t * const buffer);
static void readPage();
static uint16_t inData(uint8_t *data, uint16_t size);
static uint16_t outData(uint8_t *data, uint16_t size);
static uint16_t inData(const uint8_t * const data, uint16_t size);
static uint16_t outData(uint8_t * const data, uint16_t size);

static uint8_t m_pageData[SPI_FLASH_PageSize];
static uint32_t m_currentPage;
Expand Down

0 comments on commit 8a70e18

Please sign in to comment.