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 Transactions and Enable Full Duplex #763

Merged
merged 28 commits into from
Nov 30, 2023
Merged
Show file tree
Hide file tree
Changes from 20 commits
Commits
Show all changes
28 commits
Select commit Hold shift + click to select a range
b6d919d
Fix DMA channel leak in UART RevA
Jake-Carter Oct 9, 2023
b9393ea
Add MXC_DMA_CH_GET_IRQ for ME14
Jake-Carter Oct 9, 2023
34276b4
Checkpoint: auto interrupt handlers (not totally compatible with old …
Jake-Carter Oct 9, 2023
77ecaef
UART_RevA: Add APIs for setting DMA handlers, expose to ME14
Jake-Carter Oct 10, 2023
e2a9134
clang-format
Jake-Carter Oct 10, 2023
bd4e60f
Implement autohandlers for UART Rev B
Jake-Carter Oct 16, 2023
fade8a5
Add function prototypes for all micros
Jake-Carter Oct 20, 2023
1a336ea
Add RevB passthroughs
Jake-Carter Oct 20, 2023
2d325eb
Add stdbool to all uart.h
Jake-Carter Oct 20, 2023
07eef60
Add RevA passthroughs
Jake-Carter Oct 20, 2023
2d5ec93
Fix req clobbering and callbacks for RevA
Jake-Carter Oct 20, 2023
a03f22b
Fix req clobbering and callbacks for RevB
Jake-Carter Oct 20, 2023
2cd7d4f
Fix build error
Jake-Carter Oct 20, 2023
d9e9441
clang-format
Jake-Carter Oct 20, 2023
fe51c36
Add newline at end of file
Jake-Carter Oct 23, 2023
dc04d78
Fix -1 assigned to uint8_t
Jake-Carter Oct 23, 2023
2ea9524
clang-format bot reformatting.
EricB-ADI Oct 24, 2023
aba737e
Remove UART FIFO clears in me21 file
Jake-Carter Oct 25, 2023
831c893
Address Lorne review notes
Jake-Carter Nov 13, 2023
8086917
Only acquire channel if we don't have one already
Jake-Carter Nov 13, 2023
ad19c87
Update UART example projects
Jake-Carter Nov 14, 2023
34db845
Use MXC_ASSERT instead of runtime checks
Jake-Carter Nov 29, 2023
81837cc
Disable MXC_ASSERT for bootloader examples
Jake-Carter Nov 29, 2023
c24e810
Merge remote-tracking branch 'remotes/upstream/main' into fix/gh-761
Jake-Carter Nov 29, 2023
566f057
Fix variable mismatch, swap for more asserts
Jake-Carter Nov 30, 2023
b332e72
Disable MXC_ASSERT for SCPA_OTP_Dump
Jake-Carter Nov 30, 2023
63fca53
clang-format
Jake-Carter Nov 30, 2023
85020c8
PURGE THE ASSERTS
Jake-Carter Nov 30, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions Libraries/CMSIS/Device/Maxim/MAX32665/Include/max32665.h
Original file line number Diff line number Diff line change
Expand Up @@ -499,6 +499,10 @@ typedef enum {
((i) == 7) ? DMA15_IRQn : \
0))

#define MXC_DMA_CH_GET_IRQ(i) \
(((i) > (MXC_DMA_CH_OFFSET - 1)) ? MXC_DMA1_CH_GET_IRQ(i % MXC_DMA_CH_OFFSET) : \
MXC_DMA0_CH_GET_IRQ(i))

/* Create alias for MXC_DMA0 for backwards compatibility with code that was
written for parts that only had one DMA instance. */
#define MXC_DMA MXC_DMA0
Expand Down
64 changes: 64 additions & 0 deletions Libraries/PeriphDrivers/Include/MAX32520/uart.h
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@
#define LIBRARIES_PERIPHDRIVERS_INCLUDE_MAX32520_UART_H_

/***** Definitions *****/
#include <stdbool.h>
#include "uart_regs.h"
#include "mxc_sys.h"

Expand Down Expand Up @@ -612,6 +613,69 @@ uint32_t MXC_UART_GetAsyncTXCount(mxc_uart_req_t *req);
*/
uint32_t MXC_UART_GetAsyncRXCount(mxc_uart_req_t *req);

/**
* @brief Enable or disable automatic DMA interrupt handlers for the UART module.
*
* The @ref MXC_UART_TransactionDMA functions require special interrupt handlers to work.
*
* When "Auto" DMA handlers are enabled, the UART drivers will acquire DMA channels
* and assign the appropriate handlers automatically. The acquired channels are
* released after each transaction.
*
* If "Auto" DMA handlers are disabled, the user must acquire DMA channels manually
* and assign them to the drivers with the @ref MXC_UART_SetTXDMAChannel and
* @ref MXC_UART_SetRXDMAChannel functions.
*
* @param uart Pointer to the UART module's registers.
* @param enable true to enable Auto DMA handlers, false to disable.
* @return 0 on success, or a non-zero error code on failure.
*/
int MXC_UART_SetAutoDMAHandlers(mxc_uart_regs_t *uart, bool enable);

/**
* @brief Set the TX (Transmit) DMA channel for a UART module.
*
* This function assigns the DMA channel for transmitting data
* when @ref is MXC_UART_SetAutoDMAHandlers disabled.
*
* @param uart Pointer to the UART module's registers.
* @param channel The DMA channel number to be used for @ref MXC_UART_TransactionDMA.
*/
int MXC_UART_SetTXDMAChannel(mxc_uart_regs_t *uart, unsigned int channel);

/**
* @brief Get the TX (Transmit) DMA channel for a UART module.
*
* This function retrieves the currently assigned DMA channel for transmitting data
* when @ref is MXC_UART_SetAutoDMAHandlers disabled.
*
* @param uart Pointer to the UART module's registers.
* @return The currently assigned TX DMA channel.
*/
int MXC_UART_GetTXDMAChannel(mxc_uart_regs_t *uart);

/**
* @brief Set the RX (Receive) DMA channel for a UART module.
*
* This function assigns the DMA channel for receiving data
* when @ref is MXC_UART_SetAutoDMAHandlers disabled.
*
* @param uart Pointer to the UART module's registers.
* @param channel The DMA channel number to be used for @ref MXC_UART_TransactionDMA.
*/
int MXC_UART_SetRXDMAChannel(mxc_uart_regs_t *uart, unsigned int channel);

/**
* @brief Get the RX (Receive) DMA channel for a UART module.
*
* This function retrieves the currently configured DMA channel for receiving data
* when @ref is MXC_UART_SetAutoDMAHandlers disabled.
*
* @param uart Pointer to the UART module's registers.
* @return The currently configured RX DMA channel.
*/
int MXC_UART_GetRXDMAChannel(mxc_uart_regs_t *uart);

/**@} end of group uart */

#ifdef __cplusplus
Expand Down
64 changes: 64 additions & 0 deletions Libraries/PeriphDrivers/Include/MAX32570/uart.h
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@
#define LIBRARIES_PERIPHDRIVERS_INCLUDE_MAX32570_UART_H_

/***** Definitions *****/
#include <stdbool.h>
#include "uart_regs.h"
#include "mxc_sys.h"

Expand Down Expand Up @@ -700,6 +701,69 @@ uint32_t MXC_UART_GetAsyncTXCount(mxc_uart_req_t *req);
*/
uint32_t MXC_UART_GetAsyncRXCount(mxc_uart_req_t *req);

/**
* @brief Enable or disable automatic DMA interrupt handlers for the UART module.
*
* The @ref MXC_UART_TransactionDMA functions require special interrupt handlers to work.
*
* When "Auto" DMA handlers are enabled, the UART drivers will acquire DMA channels
* and assign the appropriate handlers automatically. The acquired channels are
* released after each transaction.
*
* If "Auto" DMA handlers are disabled, the user must acquire DMA channels manually
* and assign them to the drivers with the @ref MXC_UART_SetTXDMAChannel and
* @ref MXC_UART_SetRXDMAChannel functions.
*
* @param uart Pointer to the UART module's registers.
* @param enable true to enable Auto DMA handlers, false to disable.
* @return 0 on success, or a non-zero error code on failure.
*/
int MXC_UART_SetAutoDMAHandlers(mxc_uart_regs_t *uart, bool enable);

/**
* @brief Set the TX (Transmit) DMA channel for a UART module.
*
* This function assigns the DMA channel for transmitting data
* when @ref is MXC_UART_SetAutoDMAHandlers disabled.
*
* @param uart Pointer to the UART module's registers.
* @param channel The DMA channel number to be used for @ref MXC_UART_TransactionDMA.
*/
int MXC_UART_SetTXDMAChannel(mxc_uart_regs_t *uart, unsigned int channel);

/**
* @brief Get the TX (Transmit) DMA channel for a UART module.
*
* This function retrieves the currently assigned DMA channel for transmitting data
* when @ref is MXC_UART_SetAutoDMAHandlers disabled.
*
* @param uart Pointer to the UART module's registers.
* @return The currently assigned TX DMA channel.
*/
int MXC_UART_GetTXDMAChannel(mxc_uart_regs_t *uart);

/**
* @brief Set the RX (Receive) DMA channel for a UART module.
*
* This function assigns the DMA channel for receiving data
* when @ref is MXC_UART_SetAutoDMAHandlers disabled.
*
* @param uart Pointer to the UART module's registers.
* @param channel The DMA channel number to be used for @ref MXC_UART_TransactionDMA.
*/
int MXC_UART_SetRXDMAChannel(mxc_uart_regs_t *uart, unsigned int channel);

/**
* @brief Get the RX (Receive) DMA channel for a UART module.
*
* This function retrieves the currently configured DMA channel for receiving data
* when @ref is MXC_UART_SetAutoDMAHandlers disabled.
*
* @param uart Pointer to the UART module's registers.
* @return The currently configured RX DMA channel.
*/
int MXC_UART_GetRXDMAChannel(mxc_uart_regs_t *uart);

/**@} end of group uart */

#ifdef __cplusplus
Expand Down
64 changes: 64 additions & 0 deletions Libraries/PeriphDrivers/Include/MAX32572/uart.h
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@
#define LIBRARIES_PERIPHDRIVERS_INCLUDE_MAX32572_UART_H_

/***** Definitions *****/
#include <stdbool.h>
#include "uart_regs.h"
#include "mxc_sys.h"

Expand Down Expand Up @@ -655,6 +656,69 @@ int MXC_UART_AbortAsync(mxc_uart_regs_t *uart);
*/
int MXC_UART_AsyncHandler(mxc_uart_regs_t *uart);

/**
* @brief Enable or disable automatic DMA interrupt handlers for the UART module.
*
* The @ref MXC_UART_TransactionDMA functions require special interrupt handlers to work.
*
* When "Auto" DMA handlers are enabled, the UART drivers will acquire DMA channels
* and assign the appropriate handlers automatically. The acquired channels are
* released after each transaction.
*
* If "Auto" DMA handlers are disabled, the user must acquire DMA channels manually
* and assign them to the drivers with the @ref MXC_UART_SetTXDMAChannel and
* @ref MXC_UART_SetRXDMAChannel functions.
*
* @param uart Pointer to the UART module's registers.
* @param enable true to enable Auto DMA handlers, false to disable.
* @return 0 on success, or a non-zero error code on failure.
*/
int MXC_UART_SetAutoDMAHandlers(mxc_uart_regs_t *uart, bool enable);

/**
* @brief Set the TX (Transmit) DMA channel for a UART module.
*
* This function assigns the DMA channel for transmitting data
* when @ref is MXC_UART_SetAutoDMAHandlers disabled.
*
* @param uart Pointer to the UART module's registers.
* @param channel The DMA channel number to be used for @ref MXC_UART_TransactionDMA.
*/
int MXC_UART_SetTXDMAChannel(mxc_uart_regs_t *uart, unsigned int channel);

/**
* @brief Get the TX (Transmit) DMA channel for a UART module.
*
* This function retrieves the currently assigned DMA channel for transmitting data
* when @ref is MXC_UART_SetAutoDMAHandlers disabled.
*
* @param uart Pointer to the UART module's registers.
* @return The currently assigned TX DMA channel.
*/
int MXC_UART_GetTXDMAChannel(mxc_uart_regs_t *uart);

/**
* @brief Set the RX (Receive) DMA channel for a UART module.
*
* This function assigns the DMA channel for receiving data
* when @ref is MXC_UART_SetAutoDMAHandlers disabled.
*
* @param uart Pointer to the UART module's registers.
* @param channel The DMA channel number to be used for @ref MXC_UART_TransactionDMA.
*/
int MXC_UART_SetRXDMAChannel(mxc_uart_regs_t *uart, unsigned int channel);

/**
* @brief Get the RX (Receive) DMA channel for a UART module.
*
* This function retrieves the currently configured DMA channel for receiving data
* when @ref is MXC_UART_SetAutoDMAHandlers disabled.
*
* @param uart Pointer to the UART module's registers.
* @return The currently configured RX DMA channel.
*/
int MXC_UART_GetRXDMAChannel(mxc_uart_regs_t *uart);

/**@} end of group uart */

#ifdef __cplusplus
Expand Down
64 changes: 64 additions & 0 deletions Libraries/PeriphDrivers/Include/MAX32650/uart.h
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@
#define LIBRARIES_PERIPHDRIVERS_INCLUDE_MAX32650_UART_H_

/***** Includes *****/
#include <stdbool.h>
#include <stdint.h>
#include "uart_regs.h"
#include "mxc_sys.h"
Expand Down Expand Up @@ -664,6 +665,69 @@ uint32_t MXC_UART_GetAsyncTXCount(mxc_uart_req_t *req);
*/
uint32_t MXC_UART_GetAsyncRXCount(mxc_uart_req_t *req);

/**
* @brief Enable or disable automatic DMA interrupt handlers for the UART module.
*
* The @ref MXC_UART_TransactionDMA functions require special interrupt handlers to work.
*
* When "Auto" DMA handlers are enabled, the UART drivers will acquire DMA channels
* and assign the appropriate handlers automatically. The acquired channels are
* released after each transaction.
*
* If "Auto" DMA handlers are disabled, the user must acquire DMA channels manually
* and assign them to the drivers with the @ref MXC_UART_SetTXDMAChannel and
* @ref MXC_UART_SetRXDMAChannel functions.
*
* @param uart Pointer to the UART module's registers.
* @param enable true to enable Auto DMA handlers, false to disable.
* @return 0 on success, or a non-zero error code on failure.
*/
int MXC_UART_SetAutoDMAHandlers(mxc_uart_regs_t *uart, bool enable);

/**
* @brief Set the TX (Transmit) DMA channel for a UART module.
*
* This function assigns the DMA channel for transmitting data
* when @ref is MXC_UART_SetAutoDMAHandlers disabled.
*
* @param uart Pointer to the UART module's registers.
* @param channel The DMA channel number to be used for @ref MXC_UART_TransactionDMA.
*/
int MXC_UART_SetTXDMAChannel(mxc_uart_regs_t *uart, unsigned int channel);

/**
* @brief Get the TX (Transmit) DMA channel for a UART module.
*
* This function retrieves the currently assigned DMA channel for transmitting data
* when @ref is MXC_UART_SetAutoDMAHandlers disabled.
*
* @param uart Pointer to the UART module's registers.
* @return The currently assigned TX DMA channel.
*/
int MXC_UART_GetTXDMAChannel(mxc_uart_regs_t *uart);

/**
* @brief Set the RX (Receive) DMA channel for a UART module.
*
* This function assigns the DMA channel for receiving data
* when @ref is MXC_UART_SetAutoDMAHandlers disabled.
*
* @param uart Pointer to the UART module's registers.
* @param channel The DMA channel number to be used for @ref MXC_UART_TransactionDMA.
*/
int MXC_UART_SetRXDMAChannel(mxc_uart_regs_t *uart, unsigned int channel);

/**
* @brief Get the RX (Receive) DMA channel for a UART module.
*
* This function retrieves the currently configured DMA channel for receiving data
* when @ref is MXC_UART_SetAutoDMAHandlers disabled.
*
* @param uart Pointer to the UART module's registers.
* @return The currently configured RX DMA channel.
*/
int MXC_UART_GetRXDMAChannel(mxc_uart_regs_t *uart);

/**@} end of group uart */

#ifdef __cplusplus
Expand Down
Loading
Loading