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 Functional Regression for MAX32670, MAX32672, MAX32675, MAX32657 #1150

Merged
merged 15 commits into from
Sep 6, 2024

Conversation

Jake-Carter
Copy link
Contributor

Description

Fixes functional regression caused by #1113

Calls to MXC_UART_RevB_SetFrequency weren't updated for these parts after changing the RevB API. As a result, MXC_UART_RevB_GetTXFIFOAvailable would eventually hang as the UART FIFO compeltely fills up and is never emptied due to misconfiguration.

Symptoms were that printfs would eventually infinitely hang. i.e. even Hello_World wouldn't work.

This PR should fix the regressions.

Also removed MXC_UART1 and MXC_UART3 definitions for ME16. These don't exist on the micro.

- Fix SetFrequency implementation
- Update SetClockSource implementation
- Add support for AOD_CLK for UART3
- Fix SetFrequency implementation
- Update SetClockSource implementation
- Add support for AOD_CLK for UART3
- Fix SetFrequency implementation
- Update SetClockSource implementation
@github-actions github-actions bot added MAX32670 Related to the MAX32670 (ME15) MAX32672 Related to the MAX32672 (ME21) MAX32675 Related to the MAX32675 (ME16) labels Aug 30, 2024
@Jake-Carter
Copy link
Contributor Author

/clang-format-run

Copy link
Contributor

@sihyung-maxim sihyung-maxim left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for catching this - To be honest, I only looked at the SVD files to check what parts were using UART RevB. D:

Libraries/CMSIS/Device/Maxim/MAX32675/Include/max32675.h Outdated Show resolved Hide resolved
@sihyung-maxim
Copy link
Contributor

Completely missed this, but the UART RevB drivers are using chip-specific register definitions instead of the generic RevB ones:

int MXC_UART_RevB_SetClockSource(mxc_uart_revb_regs_t *uart, uint8_t clock_option)
{
MXC_ASSERT(clock_option >= 0 && clock_option <= 3);
if (g_is_clock_locked[MXC_UART_GET_IDX((mxc_uart_regs_t *)uart)]) {
return E_NO_ERROR; // Return with no error so Init doesn't error out if clock config is locked
}
bool is_bclk_enabled = (uart->ctrl & MXC_F_UART_CTRL_BCLKEN) != 0;
if (is_bclk_enabled) {
// Shut down baud rate clock before changing clock source
uart->ctrl &= ~MXC_F_UART_CTRL_BCLKEN;
}
MXC_SETFIELD(uart->ctrl, MXC_F_UART_CTRL_BCLKSRC, clock_option << MXC_F_UART_CTRL_BCLKSRC_POS);
if (is_bclk_enabled) {
// Turn the baud rate clock back on
uart->ctrl |= MXC_F_UART_CTRL_BCLKEN;
while (!(uart->ctrl & MXC_F_UART_CTRL_BCLKRDY)) {
continue;
}
}
return E_NO_ERROR;
}
unsigned int MXC_UART_RevB_GetClockSource(mxc_uart_revb_regs_t *uart)
{
return ((uart->ctrl & MXC_F_UART_CTRL_BCLKSRC) >> MXC_F_UART_CTRL_BCLKSRC_POS);
}

ME16 builds are complaining due to this.

@Jake-Carter Jake-Carter merged commit 79af4e9 into analogdevicesinc:main Sep 6, 2024
7 of 8 checks passed
@Jake-Carter Jake-Carter deleted the fix/uart-setfreq branch September 6, 2024 22:41
sihyung-maxim pushed a commit to analogdevicesinc/hal_adi that referenced this pull request Sep 6, 2024
ozersa pushed a commit to analogdevicesinc/hal_adi that referenced this pull request Sep 11, 2024
ozersa pushed a commit to analogdevicesinc/hal_adi that referenced this pull request Sep 11, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
MAX32670 Related to the MAX32670 (ME15) MAX32672 Related to the MAX32672 (ME21) MAX32675 Related to the MAX32675 (ME16)
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants