KM3NeT CLB  2.0
KM3NeT CLB v2 Embedded Software
 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
max123x.h File Reference

MAX123x multichannel ADC driver. More...

#include <stdbool.h>
#include "util/macro.h"
#include "drv/wb/i2c.h"

Go to the source code of this file.

Macros

#define MAX123X_MAX_VALUE   0x0FFF
 
#define MAX123X_REF_VDD_AIN   0x0
 
#define MAX123X_REF_EXT_RIN   0x2
 
#define MAX123X_REF_INT_AIN   0x4
 
#define MAX123X_REF_INT_AIN_REF   0x5
 
#define MAX123X_REF_INT_ROUT   0x6
 
#define MAX123X_REF_INT_ROUT_REF   0x7
 
#define MAX1236_MAX_CHAN   3
 
#define MAX1237_MAX_CHAN   3
 
#define MAX1238_MAX_CHAN   11
 
#define MAX1239_MAX_CHAN   11
 
#define MAX1236_MAX_CHAN_REF   2
 
#define MAX1237_MAX_CHAN_REF   2
 
#define MAX1238_MAX_CHAN_REF   10
 
#define MAX1239_MAX_CHAN_REF   10
 

Functions

bool max123xSetup (I2C_Device *dev, i2cAddr addr, int ref, bool extclk, bool bipolar)
 Writes the setup register of the MAX123x. More...
 
bool max123xScanUpTo (I2C_Device *dev, i2cAddr addr, int upToCh, uint16_t *results)
 Scan from analog input up to a given channel. More...
 
bool max123xConvert (I2C_Device *dev, i2cAddr addr, int ch, uint16_t *result)
 Performs a single conversion of a specific channel. More...
 

Detailed Description

MAX123x multichannel ADC driver.

Definition in file max123x.h.

Function Documentation

bool max123xConvert ( I2C_Device dev,
i2cAddr  addr,
int  ch,
uint16_t *  result 
)

Performs a single conversion of a specific channel.

Parameters
devThe I2C device.
addrThe I2C component register
chThe channel to convert
resultPointer filled with the conversion value.
Return values
trueSuccess
falseFailure, check error module for error.

Definition at line 56 of file max123x.c.

bool max123xScanUpTo ( I2C_Device dev,
i2cAddr  addr,
int  upToCh,
uint16_t *  results 
)

Scan from analog input up to a given channel.

Results will be stored in 'results' array.

Parameters
devThe I2C device.
addrThe I2C component register
upToChThe last channel to convert (e.g. 3 will scan channel 0 to 3).
resultsResults array, must be enough to include no. of channels.
Return values
trueSuccess
falseFailure, check error module for error.

Definition at line 68 of file max123x.c.

bool max123xSetup ( I2C_Device dev,
i2cAddr  addr,
int  ref,
bool  extclk,
bool  bipolar 
)

Writes the setup register of the MAX123x.

Parameters
devThe I2C device
addrThe I2C component address
refReference voltage setup
extclkUse external clock
bipolarBipolar mode (+/- 1/2 Vref, else its 0-Vref.)
Return values
trueSuccess
falseFailure, check error module for error.

Definition at line 38 of file max123x.c.