Hello,
I've got 2 small questions:
1 : is there a difference between #define xyz 0x0FA and #define xyz (0x0FA)? (programming in C)
2 : is there an advantage to using macros instead of creating a function?
rather than
PortXYZ is in push-pull mode and BSRR is his Set/Reset register (8 MSB are reset and 8 LSB are set)
Edit : Nevermind the 2nd part, found the answer (less CPU operations, but larger compiled code and longer compilation time).
I've got 2 small questions:
1 : is there a difference between #define xyz 0x0FA and #define xyz (0x0FA)? (programming in C)
2 : is there an advantage to using macros instead of creating a function?
Rich (BB code):
#define SET_PORTXYZ(x) ((x) ? (PortXYZ->BSRR = 0xFF) : (PortXYZ->BSRR = 0xFF<<8))
Rich (BB code):
void setPortXYZ(int x)
{
PortXYZ->BSRR = 0xFF << ((1-x)*8);
}
Edit : Nevermind the 2nd part, found the answer (less CPU operations, but larger compiled code and longer compilation time).
Last edited: