Skip to content

feat(Examples,CMSIS,PeriphDrivers): Update HART UART with new transmit features and fixes for MAX32675 and MAX32680 #600

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

Merged
merged 11 commits into from
Jun 13, 2023

Conversation

jdk-maxim
Copy link
Contributor

Add additional requested features to HART UART.

  • Interrupt driver HART transmit. API requires notification of transmit complete, using timer to count bit-times, and arm a callback interrupt to verify transmit is complete. Originally implemented to use MXC_DelayAysnc, but discovered some issues with this, with small delays not getting called back correctly, and no nesting of delays allow. Therefore, using a dedicated system timer, to minimize resource usage, split it into two 16 bit timers, one for AFE SPI timeouts, and the other for HART_UART. Implemented support for this in afe_timer.c as current timer API doesn't fully support split timers.
  • Service Access Points (SAP), as defined in HART Token Passing Data Link Layer (TPDLL) specification, these functions and callbacks provided a standard break between customer stacks and this physical layer HAL shim.
  • Several other fixes and improvements.
  • HART_UART examples updated to show and test new features.

Also a couple of incidental fixes for TX_OB, ME16 Timer Warnings, and Change to GPIO IRQ handlers.

jdk-maxim added 5 commits May 31, 2023 16:23
Noted TX_OB (One Byte Remaining) flag and enable missing from ME16
uart_regs.h.  Added and conformed to ME55 naming.  Also added to all
uart revb devices:
ME12, ME15, ME16, ME17, ME18, ME20.  Already in ME55.
HART UART: Feature Update SAP, interrupt TX

Initial implementation of interrupt driven transmitter.
And SAP (Service Access Points) to comply with HART TPDLL
	Specification.

AFE: Add Revision IDs for Rev A Silicon

Note these revision IDS are for ME15.

HART UART: Correct hart_uart_transmit_irq()

Was not properly calculating remaining bytes to send.
Also added some length checks to hart_uart_send*

AFE: Initial addition of afe_timer

AFE Timer: Basic Functionality working

HART UART: Now using afe_timer_delay instead of MXC_Delay

Also reset transmit index for every transmission.

AFE Timer: Fix AFE_TMR_Start_16, use offset

AFE Timer: Change to complete Boolean

Was comparing cnt to cmp registers, but cnt appears
to roll over, so this was not working properly.

AFE: Switch to afe_timer. Update Reset Timeout Check

Also modified masks etc. for pre_reset change reset
checks.

Note: MXC_Delay was used previously, but due to its behavior
it was not reliable to use. It only handles one delay at a
time, and doesn't callback for short delays.  Caused a lot
of odd behaviors here.

AFE, HART: Moved afe_load_trims to main

Due to changed behaviors in recent silicon, now it makes
more sense to have afe_load_trims in main instead
of SysInit.  Need to handle potential errors etc.
And need to pass a valid timer instance to the AFE as well.

HART: Actually enable RX Errors.

Fix error flag check for FIFO overrun

HART: Fixes to SAP interface

Tests passing.

HART_UART: Example shows errors and SAPs

HART: Replace old hart_uart_send with non-blocking

Removed old, and renamed new.

HART: Cleanup FIXMES, Doxygen

HART: Rename functions for consistency

Per GitHub code review comments.

HART UART Example: Init before banners etc.

Improved behavior with Segger Debug adapter.

AFE: Use GCR define for AFE RESET bit

HART: Some config changes to better match uPython

Moved all uart config into hart_uart_init function.  This better matches
downstream uPython implementations.  However, unable to completely match

Many of the uart config such as threshold, data size, stop bits etc. are
already set by default but these show it explicitly.

AFE, HART: Update other examples using AFE

New initialization is done in main instead of SystemInit.

AFE, HART: Formatter updates

HART: Linter updates
@jdk-maxim jdk-maxim marked this pull request as ready for review May 31, 2023 23:27
@jdk-maxim
Copy link
Contributor Author

Added Jake and Sihyung regarding the Action failure.

@jdk-maxim
Copy link
Contributor Author

@ozersa This includes changes based on your comments from previous Pull Request. I also added some of the downstream changes from the uPython port you previously mentioned as well. I elected to not include the setup with specific frequency, and clock divider params as, these were passed to MXC_UART_RevB_SetFrequency_Custom which doesn't exist in the current SDK. I also did not bring in the clkdiv param to enable_hart_clock. This is complicated by the MAX32680 having to use the Pulse Train for clock gen and doesn't map directly to clock divider. So I left it alone for now.

@jdk-maxim jdk-maxim added API Change This issue or pull request involves a change to the current MSDK API MAX32675 Related to the MAX32675 (ME16) MAX32680 Related to the MAX32680 (ME20) Register Change This issue or pull request involves a change to the MSDK registers. labels Jun 2, 2023
@jdk-maxim jdk-maxim changed the title Hart uart update pr 2 MAX32675, MAX32680: Hart UART Feature Update Jun 2, 2023
@analogdevicesinc analogdevicesinc deleted a comment from github-actions bot Jun 2, 2023
@analogdevicesinc analogdevicesinc deleted a comment from github-actions bot Jun 5, 2023
@sihyung-maxim
Copy link
Contributor

/generate-register-files

@sihyung-maxim sihyung-maxim changed the title MAX32675, MAX32680: Hart UART Feature Update feat(Examples,CMSIS,PeriphDrivers): Update HART UART with new transmit features and fixes for MAX32675 and MAX32680 Jun 6, 2023
@sihyung-maxim
Copy link
Contributor

sihyung-maxim commented Jun 13, 2023

Fixed the Verify_Register workflow. Nothing wrong on your part, the machine that hosts the workflow's runner never reran the SVD scripts when checking with your register files. Weird bug, but I'll fix it in another PR.

I'll merge in this PR once the workflows all finish.

@sihyung-maxim sihyung-maxim merged commit 6495935 into analogdevicesinc:main Jun 13, 2023
@jdk-maxim jdk-maxim deleted the hart_uart_update_pr_2 branch June 13, 2023 21:51
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
API Change This issue or pull request involves a change to the current MSDK API MAX32675 Related to the MAX32675 (ME16) MAX32680 Related to the MAX32680 (ME20) Register Change This issue or pull request involves a change to the MSDK registers.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants