Skip to content
New issue

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

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

Open
wants to merge 6 commits into
base: main
Choose a base branch
from

Conversation

Jake-Carter
Copy link
Contributor

@Jake-Carter Jake-Carter commented Apr 29, 2024

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

  • PR Title follows correct guidelines.
  • Description of changes and all other relevant information.
  • (Optional) Link any related GitHub issues using a keyword
  • (Optional) Provide info on any relevant functional testing/validation. For API changes or significant features, this is not optional.

@EricB-ADI
Copy link
Contributor

EricB-ADI commented May 14, 2024

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
Copy link
Contributor Author

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

In uart_reva.c, MXC_UART_RevA_Init does not initialize unused UARTs states
2 participants