Skip to content

capi: platform: maxim: max32657: Add MAX32657 CAPI drivers#3176

Open
adi-ramonimbao wants to merge 12 commits into
analogdevicesinc:mainfrom
adi-ramonimbao:staging/capi-max32657
Open

capi: platform: maxim: max32657: Add MAX32657 CAPI drivers#3176
adi-ramonimbao wants to merge 12 commits into
analogdevicesinc:mainfrom
adi-ramonimbao:staging/capi-max32657

Conversation

@adi-ramonimbao

@adi-ramonimbao adi-ramonimbao commented Jul 1, 2026

Copy link
Copy Markdown

Pull Request Description

This PR adds implementations of CAPI-based drivers for the MAX32657:

  • UART
  • GPIO
  • DMA
  • Timer
  • SPI
  • I2C
  • IRQ
  • WDT
  • RTC
  • TRNG

Testing

Testing was done with a MAX32657EVKIT. Examples were created to test out peripherals:

  • blinky
    • Toggles LED on P0.13 every 100ms
  • uart
    • Sends "Hello CAPI" with capi_uart_transmit(), then initializes stdio redirection
    • Prints 10 messages via printf(), then echoes received characters back
    • Deinitializes when user types exit
  • button_polling
    • Polls button state on P0.12 and prints to UART on press and on release
  • button_irq
    • Toggles LED on P0.13 while waiting for falling-edge interrupt on a button on P0.12
    • Interrupt triggers a callback that prints to UART
  • dma
    • Performs 64-byte memory-to-memory transfer with DMA completion callback that prints to UART
    • Validates buffer contents post-transfer
  • i2c
    • Tests I3C peripheral in I2C mode
    • Initializes I2C bus in fast mode and attempts to write transactions to two devices
    • Tests bus speed changed (from 400kHz to 100kHz)
    • Verified I2C signals with ADALM2000
  • spi
    • Performed loopback test with SPI configured with two 'devices' and two different speeds (400kHz and 100kHz)
    • Validated buffer contents post-transfer
  • timer
    • TMR0 set up in dual 16-bit mode, both counter modes. TMR0A at 10kHz, TMR0B at 5kHz.
    • TMR1 set up as 32-bit PWM mode, at 10kHz with 10% duty cycle.
    • TMR4 set up as 32-bit compare mode, with match value at 1 ms.
    • TMR3 set up as 32-bit one-shot mode, firing after 50 us. Example loops to restart TMR3 every 1 s.
    • All signals verified with ADALM2000
  • trng
    • Generates 10 random 32-bit values, then fills a 256-byte buffer with random data, and prints all values to UART
  • wdt
    • First configured with watchdog reset enabled, and shortest period
    • System resets, detects it, then reconfigures to interrupt only, and windowed mode with 21.5 s to 85.9 s window
    • 30-second feed intervals for the watchdog

Not Tested

  • I2C and SPI with actual devices
  • RTC due to no external crystal on the MAX32657EVKIT

PR Type

  • Bug fix (change that fixes an issue)
  • New feature (change that adds new functionality)
  • Breaking change (has dependencies in other repos or will cause CI to fail)

PR Checklist

  • I have followed the Coding style guidelines
  • I have complied with the Submission Checklist
  • I have performed a self-review of the changes
  • I have commented my code, at least hard-to-understand parts
  • I have build all projects affected by the changes in this PR
  • I have tested in hardware affected projects, at the relevant boards
  • I have signed off all commits from this PR
  • I have updated the documentation (wiki pages, ReadMe etc), if applies

@CLAassistant

CLAassistant commented Jul 1, 2026

Copy link
Copy Markdown

CLA assistant check
All committers have signed the CLA.

@adi-ramonimbao
adi-ramonimbao force-pushed the staging/capi-max32657 branch from 8e94330 to 3452759 Compare July 1, 2026 02:09
@github-actions github-actions Bot removed the drivers label Jul 1, 2026
@kister-jimenez

Copy link
Copy Markdown
Collaborator

/AzurePipelines run

@azure-pipelines

Copy link
Copy Markdown
Azure Pipelines successfully started running 2 pipeline(s).

@adi-ramonimbao
adi-ramonimbao force-pushed the staging/capi-max32657 branch from 3452759 to 4cd810a Compare July 1, 2026 02:43
@kister-jimenez

Copy link
Copy Markdown
Collaborator

/AzurePipelines run

@azure-pipelines

Copy link
Copy Markdown
Azure Pipelines successfully started running 2 pipeline(s).

@adi-ramonimbao
adi-ramonimbao force-pushed the staging/capi-max32657 branch from 4cd810a to 59146a1 Compare July 1, 2026 03:52
@adi-ramonimbao adi-ramonimbao changed the title drivers: platform: maxim: max32657: Add MAX32657 CAPI drivers capi: platform: maxim: max32657: Add MAX32657 CAPI drivers Jul 1, 2026
@adi-ramonimbao
adi-ramonimbao force-pushed the staging/capi-max32657 branch from 59146a1 to 9486de2 Compare July 1, 2026 04:08
@rbolboac

rbolboac commented Jul 1, 2026

Copy link
Copy Markdown
Contributor

I would say to drop the first commit, will probably integrate that with #3090
Also, please explain a little bit how you tested the implementation. Thank you!

@adi-ramonimbao

Copy link
Copy Markdown
Author

I would say to drop the first commit, will probably integrate that with #3090

I had to add my own capi_rtc.h/.c, and capi_trng.h/.c to be able to implement the MAX32657 drivers for that. capi_wdt.h/.c is also not present in #3090. Maybe I can just commit the CAPI headers and sources I need?

Also, please explain a little bit how you tested the implementation

Got it. Will update the description of the PR

@rbolboac

rbolboac commented Jul 1, 2026

Copy link
Copy Markdown
Contributor

I would say to drop the first commit, will probably integrate that with #3090

I had to add my own capi_rtc.h/.c, and capi_trng.h/.c to be able to implement the MAX32657 drivers for that. capi_wdt.h/.c is also not present in #3090. Maybe I can just commit the CAPI headers and sources I need?

Also, please explain a little bit how you tested the implementation

Got it. Will update the description of the PR

we will have to update to latest CAPI implementation, but regarding capi_rtc and capi_trng I think the best flow would be to have them first available here: https://github.com/adi-innersource/core-sw-common-hal/tree/main/api

@kister-jimenez

Copy link
Copy Markdown
Collaborator

/AzurePipelines run

@azure-pipelines

Copy link
Copy Markdown
Azure Pipelines successfully started running 2 pipeline(s).

@adi-ramonimbao
adi-ramonimbao force-pushed the staging/capi-max32657 branch from 9486de2 to 790d94b Compare July 13, 2026 22:50
Add implementation for CAPI alloc and free functions

Signed-off-by: Ramon Miguel Imbao <ramonmiguel.imbao@analog.com>
Add implementation for CAPI time that replaces maxim_delay.c

Signed-off-by: Ramon Miguel Imbao <ramonmiguel.imbao@analog.com>
Add the implementation for CAPI UART driver

Signed-off-by: Ramon Miguel Imbao <ramonmiguel.imbao@analog.com>
Add the implementation for CAPI GPIO driver

Signed-off-by: Ramon Miguel Imbao <ramonmiguel.imbao@analog.com>
Add the implementation for the CAPI DMA driver

Signed-off-by: Ramon Miguel Imbao <ramonmiguel.imbao@analog.com>
@adi-ramonimbao
adi-ramonimbao force-pushed the staging/capi-max32657 branch from 790d94b to 4bde510 Compare July 13, 2026 22:57
Add the implementation for the CAPI Timer driver

Signed-off-by: Ramon Miguel Imbao <ramonmiguel.imbao@analog.com>
Add the implementation for the CAPI SPI driver

Signed-off-by: Ramon Miguel Imbao <ramonmiguel.imbao@analog.com>
Add the implementation for the CAPI I2C driver

Signed-off-by: Ramon Miguel Imbao <ramonmiguel.imbao@analog.com>
Add the implementation for the CAPI IRQ driver

Signed-off-by: Ramon Miguel Imbao <ramonmiguel.imbao@analog.com>
Add the implementation for the CAPI WDT driver

Signed-off-by: Ramon Miguel Imbao <ramonmiguel.imbao@analog.com>
Add the implementation for the CAPI RTC driver

Signed-off-by: Ramon Miguel Imbao <ramonmiguel.imbao@analog.com>
Add the implementation for the CAPI TRNG driver

Signed-off-by: Ramon Miguel Imbao <ramonmiguel.imbao@analog.com>
@adi-ramonimbao
adi-ramonimbao force-pushed the staging/capi-max32657 branch from 4bde510 to 2ed76cd Compare July 13, 2026 23:09
@adi-ramonimbao

Copy link
Copy Markdown
Author

V2:

UART

  • Change return value in capi_uart_transmit() from number of bytes transferred to 0

GPIO

  • Update field names to match capi_gpio.h
  • Add support for num_pins configuration instead of hardcoded all port pins

DMA

  • Fix capi_dma_chan_is_completed() to return correct values

Timer

  • Fix capi_timer_counter_config() to properly configure the timer
  • Fix capi_channel_compare_get() to return cached variable instead of reading register
  • Split prescaler calculations to PWM and counter mode

SPI

  • Add FIFO path for async transfers (was previously only DMA)
  • Update field names to match capi_spi.h

IRQ

  • Update field names to match capi_irq.h

With the capi_selftest, I have the following result:

[RUN:SUMMARY] PASS=179 FAIL=3 SKIP=3 TOTAL=185

with the following failed tests:

[TEST:GPIO.LOW_READBACK] FAIL: got=1 expected=0
[TEST:TIMER.RATE_NEAR] FAIL: got=10371 expected=7817 tolerance=390
[TEST:TIMER.IRQ_CB_COUNT] FAIL: got=0 expected_gt=0

The GPIO test fails because I'm not sure how to set up the test to use individual pins rather than the GPIO port.

And I'm not sure why the timer test fails. Wrong prescaler values?

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.

4 participants