I've seen some of you guys use some pretty ingenious macros to print variable names with values and stuff like that. Has anyone got anything that will do this for registers:
void printRegs(){
volatile uint32_t mstpcrc = R_MSTP->MSTPCRC;
Serial.print("MSTPCRC : ");
Serial.println(mstpcrc , HEX);
volatile uint32_t cacr0 = R_CAC->CACR0;
Serial.print("CACR0 : ");
Serial.println(cacr0 , HEX);
volatile uint32_t cacr1 = R_CAC->CACR1;
Serial.print("CACR1 : ");
Serial.println(cacr1 , HEX);
volatile uint32_t cacr2 = R_CAC->CACR2;
Serial.print("CACR2 : ");
Serial.println(cacr2 , HEX);
volatile uint32_t caicr = R_CAC->CAICR;
Serial.print("CAICR : ");
Serial.println(caicr , HEX);
volatile uint32_t callvr = R_CAC->CALLVR;
Serial.print("CALLVR : ");
Serial.println(callvr , HEX);
volatile uint32_t caulvr = R_CAC->CAULVR;
Serial.print("CAULVR : ");
Serial.println(caulvr , HEX);
volatile uint32_t cacntbr = R_CAC->CACNTBR;
Serial.print("CACNTBR : ");
Serial.println(cacntbr , HEX);
}
I want something where I can replace each set of three lines there with just:
PRINT_REG(R_MSTP->MSTPCRC);
or
PRINT_REG (R_CAC->CACNTBR);
And have it print the register name along with the value in hex. I don't mind if it prints the whole register name with the arrow and all but I'd prefer to just see the last part that is the actual name of the register.