analogdevicesinc / msdk

Software Development Kit for Analog Device's MAX-series microcontrollers
Apache License 2.0
60 stars 75 forks source link

fix(PeriphDrivers): Fix UART DMA Callbacks for UART1+ #1004

Closed Jake-Carter closed 2 days ago

Jake-Carter commented 2 months ago

Description

Fixes #998

As the internal UART state struct was only initialized per used UART instance, attempting to use UART1 (or higher) with DMA auto handlers would never trigger the user's callback functions. The state struct's DMA channel values would be initialized to 0 instead of -1, which the drivers would assume was a valid channel acquisition.

This PR fixes the bug by initializing the UART state array correctly.

Checklist Before Requesting Review

EricB-ADI commented 1 month ago

I recommend designated initializers instead of runtime. That way you don't need any runtime operations after and need to manage more global state.

#define NUM_MEMBERS 4

typedef struct  
{
    int32_t a , b, c;
}example_t;

example_t test[NUM_MEMBERS] = {
    [0 ... NUM_MEMBERS - 1] = {.a = -1, .b = -1, .c = -1}
};
Jake-Carter commented 3 weeks ago

I recommend designated initializers instead of runtime. That way you don't need any runtime operations after and need to manage more global state.

#define NUM_MEMBERS 4

typedef struct  
{
    int32_t a , b, c;
}example_t;

example_t test[NUM_MEMBERS] = {
    [0 ... NUM_MEMBERS - 1] = {.a = -1, .b = -1, .c = -1}
};

Thanks @EricB-ADI, I was looking for this type of syntax. Just updated the PR

Jake-Carter commented 3 days ago

@EricB-ADI ready for final review