Open dambo1993 opened 5 years ago
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.
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.