Configuration of multiple UARTS

murraylang62 wrote on Wednesday, September 19, 2018:

I want to use multiple UARTS simultaneously. I’m currently developing for the STM32F407 Discovery board, but plan to support other platforms later, particularly LPC2468. My development environment is linux+gcc+cmake (using CLion).

I cannot currently see how the signature for the user-supplied function…

void HAL_UART_MspInit(UART_HandleTypeDef *huart);

…gives me the information I need to decide which UART resources to configure. The structure UART_HandleTypeDef doesn’t appear to contain any fields that will tell me.

I suppose I could do something like…

#define NUM_UARTS 2
UART_HandleTypeDef uarts[NUM_UARTS];
...
void HAL_UART_MspInit(UART_HandleTypeDef *huart)
{
        if (huart == &uarts[0]) {
                // Initialisation for first UART here
        } else if (huart == &uarts[1]) {
                // Initialisation for second UART here
        } else if (...) {
        }
        // etc.
}

…but this seems half-baked to me.
What have I missed? Should I be eating more leafy greens?

EDIT:
Looking around, I see that the function I identified is just an STM32 thing. I forgot that the “HAL” was an STM32 scheme, so maybe this post doesn’t belong in a general FreeRTOS discussion. I’m actually working with the FreeRTOS Labs FreeRTOS_Plus_TCP_and_FAT_STM32F4xxx demo code. Still, maybe somebody out there has a perspective on this problem.

Cheers
Murray

rtel wrote on Thursday, September 20, 2018:

I’m afraid I don’t have a clue as you are asking about a third party piece of software I’m not familiar with. I don’t think this is a FreeRTOS question - correct me if I’m wrong.

murraylang62 wrote on Thursday, September 20, 2018:

Yes, sorry, I’m working with a FreeRTOS port (STM32F4xx), but misattributed the function I identified due to the letters “HAL” (as mentioned in my edit). It was late at night, and I forgot that the HAL was from ST to abstract away STM32 variants.

If I could have changed the title of the post to reflect this then I would have. I’ll head towards the STM32 fora.

Ta.