We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Hi - a little advice - you have a lot od #define in code. for example:
void uart0_reinit(uint16_t ubrr_value) { #ifdef USART0_USE_SOFT_RTS RTS0_PORT |= (1<<RTS0_IONUM); #endif #ifdef USART0_RS485_MODE RS485_CONTROL0_PORT &= ~(1<<RS485_CONTROL0_IONUM); //set low RS485_CONTROL0_DDR |= (1<<RS485_CONTROL0_IONUM); #endif // rest of the function }
you can simply hide #defines by implement static functions:
static void USART0_USE_SOFT_RTS_func(void) { #ifdef USART0_USE_SOFT_RTS RTS0_PORT |= (1<<RTS0_IONUM); #endif } static void USART0_RS485_MODE_on(void) { #ifdef USART0_RS485_MODE RS485_CONTROL0_PORT &= ~(1<<RS485_CONTROL0_IONUM); //set low RS485_CONTROL0_DDR |= (1<<RS485_CONTROL0_IONUM); #endif } void uart0_reinit(uint16_t ubrr_value) { USART0_USE_SOFT_RTS_func(); USART0_RS485_MODE_on(); // rest of the function } }
compiler will remove all unused jumps etc - and functions are easier to read. Of course- just in my opinion.
The text was updated successfully, but these errors were encountered:
No branches or pull requests
Hi - a little advice - you have a lot od #define in code. for example:
you can simply hide #defines by implement static functions:
compiler will remove all unused jumps etc - and functions are easier to read. Of course- just in my opinion.
The text was updated successfully, but these errors were encountered: