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

MSDK-1008: MAX11261 Driver Implementation #416

Merged
merged 17 commits into from
Feb 27, 2023
Merged

Conversation

ttmut
Copy link
Contributor

@ttmut ttmut commented Feb 14, 2023

Initial MAX11261 ADC driver support and example application.

  • Supports sequencer mode 1 with configurable polarity and format.
  • Can switch input channels.
  • Can switch sample rates.
  • Platform functions are initialized in the board file.
  • Driver works in GPIO or register poll mode.

Remaining work:

  • Self and system calibration
  • Error and overflow bit checks
  • Programmable gain amplifier (PGA) support
  • Interrupt support
  • Sequencer modes 2, 3 and 4

@ttmut ttmut requested a review from ozersa February 14, 2023 09:54
ttmut and others added 15 commits February 21, 2023 08:38
This is the initial version of MAX11261 ADC driver.

Only sequencer mode 1 has been implemented. Input channel, polarity
and output format can be configured. Sample rate setting has not been
tested yet.
Add platform functions used by MAX11261 in board initialization file.
Conversion results are now stored in max11261_adc_result_t. There are
separate fields for data overrun and analog input overrange conditions.
MAX11261 allows input to settle for a specified amount of time before
starting conversion. Set DELAY register accordingly if this feature is
used.
Multichannel scan in sequencer mode 2 is now supported. At the moment,
conversion results are not read until all channels are converted.

In register poll mode, STAT:SRDY field is polled instead of STAT:RDY
which is only valid in sequencer mode 1.
General-purpose outputs can be directly controlled in sequencer modes 1
and 2 by writing into GPO_DIR:GPO[5:0].
Sequencer mode 3 is now functional with optional GPO bumps. GPOs that
are mapped to channels will be activated before conversion. The delay
before conversion is determined by DELAY:GPO[7:0].

Other minor changes:
 * Conversion delay is now calculated in delay_count().
 * Fix CHAMP1_CH3_GPOEN and CHMAP0_CH0_GPOEN definitions
Read, write and update calls with error checks are wrapped in
MAX11261_READ_REG, MAX11261_WRITE_REG and MAX11261_UPDATE_REG
respectively.
Scanning in sequencer mode 4 with autoscan delay is now possible.
Distinct values for each channel can be set for Out-Of-Range detection.
Cutoff frequency and comparison mode can be set in the HPF register.
clang chech

Signed-off-by: Sadik.Ozer <[email protected]>
MXC_TMR_Start(MXC_TMR0);

/* Set ADC hardware parameters */
error = max11261_adc_config_init(ADC_V_AVDD, ADC_V_REF, I2C_FREQ, ADC_SLAVE_ADDR);
Copy link
Contributor

Choose a reason for hiding this comment

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

It would be better if you move slave_addr and freq in the board,c file.

@ozersa ozersa requested a review from Jake-Carter February 21, 2023 07:10
I2C is initialized during board initialization.

Add missing call to max11261_convert_prepare before entering main loop.
@ttmut ttmut requested a review from ozersa February 22, 2023 10:50
@Jake-Carter
Copy link
Contributor

I will review asap. It's a more in-depth PR so it will take me a little time

Driver does not need to know the slave address of the chip so remove it.

Initialize MAX11261 only if ENABLE_MAX11261_ADC macro is explicitly defined.
@Jake-Carter Jake-Carter merged commit 33c5d70 into main Feb 27, 2023
@Jake-Carter Jake-Carter deleted the dev-max11261_adc branch February 27, 2023 20:48
Jake-Carter pushed a commit that referenced this pull request Mar 7, 2023
…0FTHR(#416)

* Add platform functions used by MAX11261 in board initialization file.

* Add MAX11261 ADC example

Signed-off-by: Sadik.Ozer <[email protected]>
Co-authored-by: Sadik.Ozer <[email protected]>
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.

3 participants