mspm0: add OPA driver with buffer and non-inverting PGA modes#6517
Open
ozongzi wants to merge 3 commits into
Open
mspm0: add OPA driver with buffer and non-inverting PGA modes#6517ozongzi wants to merge 3 commits into
ozongzi wants to merge 3 commits into
Conversation
read_channel/blocking_read/read_sequence required channels to live as long as the Adc driver's 'd, which rejects short-lived channels such as one borrowing an OPA output. A channel only needs to be alive for the duration of the call.
Supports every MSPM0 with an OPA (G150x/G350x/L130x/L134x). Buffer and non-inverting PGA (x2..x32) to start with, per discussion; inverting PGA, general-purpose and cascade modes to follow one at a time. _ext variants drive the OPAx_OUT pin, _int variants route the output only to the ADC. The non-inverting input takes either an OPAx_INy+ pin or an internal source (DAC12, COMP DAC8, VREF, ground), and gain can be changed while running (auto-ranging). Outputs expose the OPA's dedicated internal ADC channel; the mapping is family-specific and comes from TI's SysConfig metadata. Hardware-tested on LP-MSPM0G3507: every gain step verified by two-point slope against the on-chip DAC (within 2% of nominal), the internal ADC channel cross-checked against sampling the OUT pin.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Adds a driver for the OPA on the MSPM0 parts that have one (G150x, G350x, L130x, L134x), scoped to the two modes from our discussion: buffer (TRM 17.2.7.2) and non-inverting PGA (17.2.7.3.2).
The register block comes from mspm0-rs/mspm0-data#37; the second commit bumps mspm0-metapac to the tag generated from it.
Shape notes:
_extdrives the OPAx_OUT pin,_intkeeps the output internal to the ADC. Both return a handle that exposes the OPA's dedicated internal ADC channel and disable the amplifier on drop.impl Into<NonInvertingInput>: either anOPAx_INy+pin (per-role pin traits generated from the metapac pin metadata, so the PSEL channel comes from the pin you pass) or an internal source (dac12(),dac8(),vref(),ground()). IN2+ shares the DAC_OUT pad, which is why it maps to the DAC12 PSEL channel.set_gain()works while the amplifier is running, since on this part gain is a single CFG field and runtime ranging is the main thing the stm32 API doesn't allow.ADC12_internalConnections.js— same approach as embassy-stm32's opamp, where the OPAMPx→ADCx channel table lives in the HAL rather than stm32-data. Can move it into mspm0-data later if you'd rather have it as data.Configbut defaults to off; the doc comment explains the ripple/ADC-averaging interaction.The first commit is a standalone ADC fix this depends on:
read_channel/read_sequencetied the channel's lifetime to the driver's'd, which rejects a short-lived channel borrowing an OPA output. Can split it into its own PR if you want.Testing: LP-MSPM0G3507, DAC_OUT (PA15) jumpered to OPA0_IN1+ (PA25). The DAC drives known codes and the OPA outputs are read back through their dedicated internal ADC channels (OPA0→ADC0, OPA1→ADC1, so both instances and both channel mappings are exercised). Each PGA step enters at x2 and is retuned with
set_gain(), then verified by two-point slope so offsets stay out of the measurement: x2..x8 through the external pin path on OPA0, x16/x32 through the internal DAC12 route on OPA1. All five gains land within 2% of nominal. Also compile-checked on mspm0l1306 (single-ADC channel mapping) and mspm0c1104 (no OPA, module cfg'd out). Example included underexamples/mspm0g3507.