Skip to content

Commit

Permalink
🎨 Fewer serial macros
Browse files Browse the repository at this point in the history
  • Loading branch information
thinkyhead committed Oct 3, 2021
1 parent 6d96c22 commit b661795
Show file tree
Hide file tree
Showing 159 changed files with 1,002 additions and 1,014 deletions.
10 changes: 5 additions & 5 deletions Marlin/src/HAL/AVR/fastio.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -267,11 +267,11 @@ uint16_t set_pwm_frequency_hz(const_float_t hz, const float dca, const float dcb
SET_WGM(5, FAST_PWM_ICRn); // Fast PWM with ICR5 as TOP

//SERIAL_ECHOLNPGM("Timer 5 Settings:");
//SERIAL_ECHOLNPAIR(" Prescaler=", prescaler);
//SERIAL_ECHOLNPAIR(" TOP=", ICR5);
//SERIAL_ECHOLNPAIR(" OCR5A=", OCR5A);
//SERIAL_ECHOLNPAIR(" OCR5B=", OCR5B);
//SERIAL_ECHOLNPAIR(" OCR5C=", OCR5C);
//SERIAL_ECHOLNPGM(" Prescaler=", prescaler);
//SERIAL_ECHOLNPGM(" TOP=", ICR5);
//SERIAL_ECHOLNPGM(" OCR5A=", OCR5A);
//SERIAL_ECHOLNPGM(" OCR5B=", OCR5B);
//SERIAL_ECHOLNPGM(" OCR5C=", OCR5C);
}
else {
// Restore the default for Timer 5
Expand Down
16 changes: 8 additions & 8 deletions Marlin/src/HAL/AVR/pinsDebug.h
Original file line number Diff line number Diff line change
Expand Up @@ -235,9 +235,9 @@ static void print_is_also_tied() { SERIAL_ECHOPGM(" is also tied to this pin");

inline void com_print(const uint8_t N, const uint8_t Z) {
const uint8_t *TCCRA = (uint8_t*)TCCR_A(N);
SERIAL_ECHOPAIR(" COM", AS_DIGIT(N));
SERIAL_ECHOPGM(" COM", AS_DIGIT(N));
SERIAL_CHAR(Z);
SERIAL_ECHOPAIR(": ", int((*TCCRA >> (6 - Z * 2)) & 0x03));
SERIAL_ECHOPGM(": ", int((*TCCRA >> (6 - Z * 2)) & 0x03));
}

void timer_prefix(uint8_t T, char L, uint8_t N) { // T - timer L - pwm N - WGM bit layout
Expand All @@ -247,7 +247,7 @@ void timer_prefix(uint8_t T, char L, uint8_t N) { // T - timer L - pwm N -
uint8_t WGM = (((*TCCRB & _BV(WGM_2)) >> 1) | (*TCCRA & (_BV(WGM_0) | _BV(WGM_1))));
if (N == 4) WGM |= ((*TCCRB & _BV(WGM_3)) >> 1);

SERIAL_ECHOPAIR(" TIMER", AS_DIGIT(T));
SERIAL_ECHOPGM(" TIMER", AS_DIGIT(T));
SERIAL_CHAR(L);
SERIAL_ECHO_SP(3);

Expand All @@ -259,14 +259,14 @@ void timer_prefix(uint8_t T, char L, uint8_t N) { // T - timer L - pwm N -
const uint16_t *OCRVAL16 = (uint16_t*)OCR_VAL(T, L - 'A');
PWM_PRINT(*OCRVAL16);
}
SERIAL_ECHOPAIR(" WGM: ", WGM);
SERIAL_ECHOPGM(" WGM: ", WGM);
com_print(T,L);
SERIAL_ECHOPAIR(" CS: ", (*TCCRB & (_BV(CS_0) | _BV(CS_1) | _BV(CS_2)) ));
SERIAL_ECHOPAIR(" TCCR", AS_DIGIT(T), "A: ", *TCCRA);
SERIAL_ECHOPAIR(" TCCR", AS_DIGIT(T), "B: ", *TCCRB);
SERIAL_ECHOPGM(" CS: ", (*TCCRB & (_BV(CS_0) | _BV(CS_1) | _BV(CS_2)) ));
SERIAL_ECHOPGM(" TCCR", AS_DIGIT(T), "A: ", *TCCRA);
SERIAL_ECHOPGM(" TCCR", AS_DIGIT(T), "B: ", *TCCRB);

const uint8_t *TMSK = (uint8_t*)TIMSK(T);
SERIAL_ECHOPAIR(" TIMSK", AS_DIGIT(T), ": ", *TMSK);
SERIAL_ECHOPGM(" TIMSK", AS_DIGIT(T), ": ", *TMSK);

const uint8_t OCIE = L - 'A' + 1;
if (N == 3) { if (WGM == 0 || WGM == 2 || WGM == 4 || WGM == 6) err_is_counter(); }
Expand Down
34 changes: 17 additions & 17 deletions Marlin/src/HAL/DUE/eeprom_flash.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -200,9 +200,9 @@ static bool ee_PageWrite(uint16_t page, const void *data) {
pageContents[i] = (((uint32_t*)data)[i]) | (~(pageContents[i] ^ ((uint32_t*)data)[i]));

DEBUG_ECHO_START();
DEBUG_ECHOLNPAIR("EEPROM PageWrite ", page);
DEBUG_ECHOLNPAIR(" in FLASH address ", (uint32_t)addrflash);
DEBUG_ECHOLNPAIR(" base address ", (uint32_t)getFlashStorage(0));
DEBUG_ECHOLNPGM("EEPROM PageWrite ", page);
DEBUG_ECHOLNPGM(" in FLASH address ", (uint32_t)addrflash);
DEBUG_ECHOLNPGM(" base address ", (uint32_t)getFlashStorage(0));
DEBUG_FLUSH();

// Get the page relative to the start of the EFC controller, and the EFC controller to use
Expand Down Expand Up @@ -246,7 +246,7 @@ static bool ee_PageWrite(uint16_t page, const void *data) {
__enable_irq();

DEBUG_ECHO_START();
DEBUG_ECHOLNPAIR("EEPROM Unlock failure for page ", page);
DEBUG_ECHOLNPGM("EEPROM Unlock failure for page ", page);
return false;
}

Expand All @@ -271,7 +271,7 @@ static bool ee_PageWrite(uint16_t page, const void *data) {
__enable_irq();

DEBUG_ECHO_START();
DEBUG_ECHOLNPAIR("EEPROM Write failure for page ", page);
DEBUG_ECHOLNPGM("EEPROM Write failure for page ", page);

return false;
}
Expand All @@ -287,7 +287,7 @@ static bool ee_PageWrite(uint16_t page, const void *data) {

#ifdef EE_EMU_DEBUG
DEBUG_ECHO_START();
DEBUG_ECHOLNPAIR("EEPROM Verify Write failure for page ", page);
DEBUG_ECHOLNPGM("EEPROM Verify Write failure for page ", page);

ee_Dump( page, (uint32_t *)addrflash);
ee_Dump(-page, data);
Expand All @@ -306,7 +306,7 @@ static bool ee_PageWrite(uint16_t page, const void *data) {
}
}
}
DEBUG_ECHOLNPAIR("--> Differing bits: ", count);
DEBUG_ECHOLNPGM("--> Differing bits: ", count);
#endif

return false;
Expand All @@ -326,9 +326,9 @@ static bool ee_PageErase(uint16_t page) {
uint32_t addrflash = uint32_t(getFlashStorage(page));

DEBUG_ECHO_START();
DEBUG_ECHOLNPAIR("EEPROM PageErase ", page);
DEBUG_ECHOLNPAIR(" in FLASH address ", (uint32_t)addrflash);
DEBUG_ECHOLNPAIR(" base address ", (uint32_t)getFlashStorage(0));
DEBUG_ECHOLNPGM("EEPROM PageErase ", page);
DEBUG_ECHOLNPGM(" in FLASH address ", (uint32_t)addrflash);
DEBUG_ECHOLNPGM(" base address ", (uint32_t)getFlashStorage(0));
DEBUG_FLUSH();

// Get the page relative to the start of the EFC controller, and the EFC controller to use
Expand Down Expand Up @@ -371,7 +371,7 @@ static bool ee_PageErase(uint16_t page) {
__enable_irq();

DEBUG_ECHO_START();
DEBUG_ECHOLNPAIR("EEPROM Unlock failure for page ",page);
DEBUG_ECHOLNPGM("EEPROM Unlock failure for page ",page);

return false;
}
Expand All @@ -395,7 +395,7 @@ static bool ee_PageErase(uint16_t page) {
__enable_irq();

DEBUG_ECHO_START();
DEBUG_ECHOLNPAIR("EEPROM Erase failure for page ",page);
DEBUG_ECHOLNPGM("EEPROM Erase failure for page ",page);

return false;
}
Expand All @@ -411,7 +411,7 @@ static bool ee_PageErase(uint16_t page) {
for (i = 0; i < PageSize >> 2; i++) {
if (*aligned_src++ != 0xFFFFFFFF) {
DEBUG_ECHO_START();
DEBUG_ECHOLNPAIR("EEPROM Verify Erase failure for page ",page);
DEBUG_ECHOLNPGM("EEPROM Verify Erase failure for page ",page);
ee_Dump(page, (uint32_t *)addrflash);
return false;
}
Expand Down Expand Up @@ -922,7 +922,7 @@ static void ee_Init() {
if (curGroup >= GroupCount) curGroup = 0;

DEBUG_ECHO_START();
DEBUG_ECHOLNPAIR("EEPROM Current Group: ",curGroup);
DEBUG_ECHOLNPGM("EEPROM Current Group: ",curGroup);
DEBUG_FLUSH();

// Now, validate that all the other group pages are empty
Expand All @@ -932,7 +932,7 @@ static void ee_Init() {
for (int page = 0; page < PagesPerGroup; page++) {
if (!ee_IsPageClean(grp * PagesPerGroup + page)) {
DEBUG_ECHO_START();
DEBUG_ECHOLNPAIR("EEPROM Page ", page, " not clean on group ", grp);
DEBUG_ECHOLNPGM("EEPROM Page ", page, " not clean on group ", grp);
DEBUG_FLUSH();
ee_PageErase(grp * PagesPerGroup + page);
}
Expand All @@ -949,14 +949,14 @@ static void ee_Init() {
}

DEBUG_ECHO_START();
DEBUG_ECHOLNPAIR("EEPROM Active page: ", curPage);
DEBUG_ECHOLNPGM("EEPROM Active page: ", curPage);
DEBUG_FLUSH();

// Make sure the pages following the first clean one are also clean
for (int page = curPage + 1; page < PagesPerGroup; page++) {
if (!ee_IsPageClean(curGroup * PagesPerGroup + page)) {
DEBUG_ECHO_START();
DEBUG_ECHOLNPAIR("EEPROM Page ", page, " not clean on active group ", curGroup);
DEBUG_ECHOLNPGM("EEPROM Page ", page, " not clean on active group ", curGroup);
DEBUG_FLUSH();
ee_Dump(curGroup * PagesPerGroup + page, getFlashStorage(curGroup * PagesPerGroup + page));
ee_PageErase(curGroup * PagesPerGroup + page);
Expand Down
2 changes: 1 addition & 1 deletion Marlin/src/HAL/DUE/pinsDebug.h
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ bool GET_PINMODE(int8_t pin) { // 1: output, 0: input
void pwm_details(int32_t pin) {
if (pwm_status(pin)) {
uint32_t chan = g_APinDescription[pin].ulPWMChannel;
SERIAL_ECHOPAIR("PWM = ", PWM_INTERFACE->PWM_CH_NUM[chan].PWM_CDTY);
SERIAL_ECHOPGM("PWM = ", PWM_INTERFACE->PWM_CH_NUM[chan].PWM_CDTY);
}
}

Expand Down
2 changes: 1 addition & 1 deletion Marlin/src/HAL/ESP32/wifi.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ void wifi_init() {

MDNS.addService("http", "tcp", 80);

SERIAL_ECHOLNPAIR("Successfully connected to WiFi with SSID '" WIFI_SSID "', hostname: '" WIFI_HOSTNAME "', IP address: ", WiFi.localIP().toString().c_str());
SERIAL_ECHOLNPGM("Successfully connected to WiFi with SSID '" WIFI_SSID "', hostname: '" WIFI_HOSTNAME "', IP address: ", WiFi.localIP().toString().c_str());
}

#endif // WIFISUPPORT
Expand Down
8 changes: 4 additions & 4 deletions Marlin/src/HAL/LPC1768/eeprom_sdcard.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -84,15 +84,15 @@ static void debug_rw(const bool write, int &pos, const uint8_t *value, const siz
PGM_P const rw_str = write ? PSTR("write") : PSTR("read");
SERIAL_CHAR(' ');
SERIAL_ECHOPGM_P(rw_str);
SERIAL_ECHOLNPAIR("_data(", pos, ",", value, ",", size, ", ...)");
SERIAL_ECHOLNPGM("_data(", pos, ",", value, ",", size, ", ...)");
if (total) {
SERIAL_ECHOPGM(" f_");
SERIAL_ECHOPGM_P(rw_str);
SERIAL_ECHOPAIR("()=", s, "\n size=", size, "\n bytes_");
SERIAL_ECHOLNPAIR_P(write ? PSTR("written=") : PSTR("read="), total);
SERIAL_ECHOPGM("()=", s, "\n size=", size, "\n bytes_");
SERIAL_ECHOLNPGM_P(write ? PSTR("written=") : PSTR("read="), total);
}
else
SERIAL_ECHOLNPAIR(" f_lseek()=", s);
SERIAL_ECHOLNPGM(" f_lseek()=", s);
}

// File function return codes for type FRESULT. This goes away soon, but
Expand Down
2 changes: 1 addition & 1 deletion Marlin/src/HAL/SAMD51/pinsDebug.h
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ bool GET_PINMODE(int8_t pin) { // 1: output, 0: input
void pwm_details(int32_t pin) {
if (pwm_status(pin)) {
//uint32_t chan = g_APinDescription[pin].ulPWMChannel TODO when fast pwm is operative;
//SERIAL_ECHOPAIR("PWM = ", duty);
//SERIAL_ECHOPGM("PWM = ", duty);
}
}

Expand Down
16 changes: 8 additions & 8 deletions Marlin/src/HAL/STM32/eeprom_flash.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,7 @@ bool PersistentStore::access_start() {
// load current settings
uint8_t *eeprom_data = (uint8_t *)SLOT_ADDRESS(current_slot);
for (int i = 0; i < MARLIN_EEPROM_SIZE; i++) ram_eeprom[i] = eeprom_data[i];
DEBUG_ECHOLNPAIR("EEPROM loaded from slot ", current_slot, ".");
DEBUG_ECHOLNPGM("EEPROM loaded from slot ", current_slot, ".");
}
eeprom_data_written = false;
}
Expand Down Expand Up @@ -179,9 +179,9 @@ bool PersistentStore::access_finish() {
ENABLE_ISRS();
TERN_(HAS_PAUSE_SERVO_OUTPUT, RESUME_SERVO_OUTPUT());
if (status != HAL_OK) {
DEBUG_ECHOLNPAIR("HAL_FLASHEx_Erase=", status);
DEBUG_ECHOLNPAIR("GetError=", HAL_FLASH_GetError());
DEBUG_ECHOLNPAIR("SectorError=", SectorError);
DEBUG_ECHOLNPGM("HAL_FLASHEx_Erase=", status);
DEBUG_ECHOLNPGM("GetError=", HAL_FLASH_GetError());
DEBUG_ECHOLNPGM("SectorError=", SectorError);
LOCK_FLASH();
return false;
}
Expand All @@ -204,9 +204,9 @@ bool PersistentStore::access_finish() {
offset += sizeof(uint32_t);
}
else {
DEBUG_ECHOLNPAIR("HAL_FLASH_Program=", status);
DEBUG_ECHOLNPAIR("GetError=", HAL_FLASH_GetError());
DEBUG_ECHOLNPAIR("address=", address);
DEBUG_ECHOLNPGM("HAL_FLASH_Program=", status);
DEBUG_ECHOLNPGM("GetError=", HAL_FLASH_GetError());
DEBUG_ECHOLNPGM("address=", address);
success = false;
break;
}
Expand All @@ -216,7 +216,7 @@ bool PersistentStore::access_finish() {

if (success) {
eeprom_data_written = false;
DEBUG_ECHOLNPAIR("EEPROM saved to slot ", current_slot, ".");
DEBUG_ECHOLNPGM("EEPROM saved to slot ", current_slot, ".");
}

return success;
Expand Down
2 changes: 1 addition & 1 deletion Marlin/src/HAL/STM32/pinsDebug.h
Original file line number Diff line number Diff line change
Expand Up @@ -237,7 +237,7 @@ void pwm_details(const pin_t Ard_num) {
if (over_7) pin_number -= 8;

uint8_t alt_func = (alt_all >> (4 * pin_number)) & 0x0F;
SERIAL_ECHOPAIR("Alt Function: ", alt_func);
SERIAL_ECHOPGM("Alt Function: ", alt_func);
if (alt_func < 10) SERIAL_CHAR(' ');
SERIAL_ECHOPGM(" - ");
switch (alt_func) {
Expand Down
6 changes: 3 additions & 3 deletions Marlin/src/HAL/STM32/usb_host.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -88,9 +88,9 @@ void USBHost::setUsbTaskState(uint8_t state) {
capacity = info.capacity.block_nbr / 2000;
block_size = info.capacity.block_size;
block_count = info.capacity.block_nbr;
// SERIAL_ECHOLNPAIR("info.capacity.block_nbr : %ld\n", info.capacity.block_nbr);
// SERIAL_ECHOLNPAIR("info.capacity.block_size: %d\n", info.capacity.block_size);
// SERIAL_ECHOLNPAIR("capacity : %d MB\n", capacity);
//SERIAL_ECHOLNPGM("info.capacity.block_nbr : %ld\n", info.capacity.block_nbr);
//SERIAL_ECHOLNPGM("info.capacity.block_size: %d\n", info.capacity.block_size);
//SERIAL_ECHOLNPGM("capacity : %d MB\n", capacity);
}
};

Expand Down
6 changes: 3 additions & 3 deletions Marlin/src/HAL/shared/Delay.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -110,16 +110,16 @@
auto report_call_time = [](PGM_P const name, PGM_P const unit, const uint32_t cycles, const uint32_t total, const bool do_flush=true) {
SERIAL_ECHOPGM("Calling ");
SERIAL_ECHOPGM_P(name);
SERIAL_ECHOLNPAIR(" for ", cycles);
SERIAL_ECHOLNPGM(" for ", cycles);
SERIAL_ECHOPGM_P(unit);
SERIAL_ECHOLNPAIR(" took: ", total);
SERIAL_ECHOLNPGM(" took: ", total);
SERIAL_ECHOPGM_P(unit);
if (do_flush) SERIAL_FLUSHTX();
};

uint32_t s, e;

SERIAL_ECHOLNPAIR("Computed delay calibration value: ", ASM_CYCLES_PER_ITERATION);
SERIAL_ECHOLNPGM("Computed delay calibration value: ", ASM_CYCLES_PER_ITERATION);
SERIAL_FLUSH();
// Display the results of the calibration above
constexpr uint32_t testValues[] = { 1, 5, 10, 20, 50, 100, 150, 200, 350, 500, 750, 1000 };
Expand Down
4 changes: 2 additions & 2 deletions Marlin/src/MarlinCore.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -798,7 +798,7 @@ inline void manage_inactivity(const bool no_stepper_sleep=false) {
void idle(bool no_stepper_sleep/*=false*/) {
#if ENABLED(MARLIN_DEV_MODE)
static uint16_t idle_depth = 0;
if (++idle_depth > 5) SERIAL_ECHOLNPAIR("idle() call depth: ", idle_depth);
if (++idle_depth > 5) SERIAL_ECHOLNPGM("idle() call depth: ", idle_depth);
#endif

// Core Marlin activities
Expand Down Expand Up @@ -1623,7 +1623,7 @@ void setup() {
#if BOTH(HAS_WIRED_LCD, SHOW_BOOTSCREEN)
const millis_t elapsed = millis() - bootscreen_ms;
#if ENABLED(MARLIN_DEV_MODE)
SERIAL_ECHOLNPAIR("elapsed=", elapsed);
SERIAL_ECHOLNPGM("elapsed=", elapsed);
#endif
SETUP_RUN(ui.bootscreen_completion(elapsed));
#endif
Expand Down
12 changes: 6 additions & 6 deletions Marlin/src/core/bug_on.h
Original file line number Diff line number Diff line change
Expand Up @@ -20,19 +20,19 @@
*/
#pragma once

// We need SERIAL_ECHOPAIR and macros.h
// We need SERIAL_ECHOPGM and macros.h
#include "serial.h"

#if ENABLED(POSTMORTEM_DEBUGGING)
// Useful macro for stopping the CPU on an unexpected condition
// This is used like SERIAL_ECHOPAIR, that is: a key-value call of the local variables you want
// This is used like SERIAL_ECHOPGM, that is: a key-value call of the local variables you want
// to dump to the serial port before stopping the CPU.
// \/ Don't replace by SERIAL_ECHOPAIR since ONLY_FILENAME cannot be transformed to a PGM string on Arduino and it breaks building
#define BUG_ON(V...) do { SERIAL_ECHO(ONLY_FILENAME); SERIAL_ECHO(__LINE__); SERIAL_ECHOLNPGM(": "); SERIAL_ECHOLNPAIR(V); SERIAL_FLUSHTX(); *(char*)0 = 42; } while(0)
// \/ Don't replace by SERIAL_ECHOPGM since ONLY_FILENAME cannot be transformed to a PGM string on Arduino and it breaks building
#define BUG_ON(V...) do { SERIAL_ECHO(ONLY_FILENAME); SERIAL_ECHO(__LINE__); SERIAL_ECHOLNPGM(": "); SERIAL_ECHOLNPGM(V); SERIAL_FLUSHTX(); *(char*)0 = 42; } while(0)
#elif ENABLED(MARLIN_DEV_MODE)
// Don't stop the CPU here, but at least dump the bug on the serial port
// \/ Don't replace by SERIAL_ECHOPAIR since ONLY_FILENAME cannot be transformed to a PGM string on Arduino and it breaks building
#define BUG_ON(V...) do { SERIAL_ECHO(ONLY_FILENAME); SERIAL_ECHO(__LINE__); SERIAL_ECHOLNPGM(": BUG!"); SERIAL_ECHOLNPAIR(V); SERIAL_FLUSHTX(); } while(0)
// \/ Don't replace by SERIAL_ECHOPGM since ONLY_FILENAME cannot be transformed to a PGM string on Arduino and it breaks building
#define BUG_ON(V...) do { SERIAL_ECHO(ONLY_FILENAME); SERIAL_ECHO(__LINE__); SERIAL_ECHOLNPGM(": BUG!"); SERIAL_ECHOLNPGM(V); SERIAL_FLUSHTX(); } while(0)
#else
// Release mode, let's ignore the bug
#define BUG_ON(V...) NOOP
Expand Down
Loading

0 comments on commit b661795

Please sign in to comment.