Hi again everyone!
So I am continuing my controller project that requires me to communicate between a head-end and remotes, and I have worked out my radio hardware selection thanks to all your help. I'm using the ATMega324PB (although any AT with two UARTs and an I2C port should work for this purpose, so let's not get bogged down with that) to communicate between the PC and a data radio, both with UART interfaces.
What I'm having trouble with today is, I want to re-use my driver I wrote for using the ISR for both UART connections. I have been using it for PC to MCU communication, and I have worked out a lot of nice conventions and tested the code pretty thoroughly, so re-use is the best bet. However, I used macros for setting the ports and ISR vectors. I would define the ISR_USART_PORT in the Symbols subsection of the Toolchain section of the project properties (where I set the F_CPU so all headers pick it up) and the correct port would be used.
Now I can't do that if I want to use it twice, so I tried
#define ISR_USART_PORT 0 // init the usart on port 1 for talkback to PC #include "hardware/isr_usart.h"
but it still compiles as if port 1 was selected, because of this in the header
#ifndef ISR_USART_PORT #define ISR_USART_PORT 1 // 0, 1 or 2 #endif
but if I remove that line I get an error that ISR_USART_PORT is undefined.
Can anyone help me with the structure of the program in order to allow multiple usages of the same source files?