ADS124S08 Example C Code  1.0.0
Functions | Variables
ads124s08.c File Reference

ADS124S08 Low level routines using TI Drivers. More...

#include <stdbool.h>
#include <stdint.h>
#include <math.h>
#include <assert.h>
#include "hal.h"
#include "ADS124S08.h"
#include "crc.h"
Include dependency graph for ads124s08.c:

Functions

uint8_t getRegisterValue (uint8_t address)
 getRegisterValue() Getter function to access the registerMap array outside of this module More...
 
bool adcStartupRoutine (SPI_Handle spiHdl)
 adcStartupRoutine() Startup function to be called before communicating with the ADC More...
 
uint8_t readSingleRegister (SPI_Handle spiHdl, uint8_t address)
 readSingleRegister() Reads contents of a single register at the specified address More...
 
void readMultipleRegisters (SPI_Handle spiHdl, uint8_t startAddress, uint8_t count)
 readMultipleRegisters() Reads a group of registers starting at the specified address NOTE: Use getRegisterValue() to retrieve the read values More...
 
void writeSingleRegister (SPI_Handle spiHdl, uint8_t address, uint8_t data)
 writeSingleRegister() Write data to a single register at the specified address More...
 
void writeMultipleRegisters (SPI_Handle spiHdl, uint8_t startAddress, uint8_t count, uint8_t regData[])
 writeMultipleRegisters() Write data to a group of registers NOTES: Use getRegisterValue() to retrieve the written values. Registers should be re-read after a write operation to ensure proper configuration. More...
 
void sendCommand (SPI_Handle spiHdl, uint8_t op_code)
 sendCommand() Sends the specified SPI command to the ADC More...
 
void startConversions (SPI_Handle spiHdl)
 startConversions() Wakes the device from power-down and starts continuous conversions by setting START pin high or sending START Command More...
 
void stopConversions (SPI_Handle spiHdl)
 stopConversions() Stops continuous conversions by setting START pin low or sending STOP Command More...
 
void resetADC (SPI_Handle spiHdl)
 resetADC() Resets ADC by setting RESET pin low or sending RESET Command More...
 
int32_t readConvertedData (SPI_Handle spiHdl, uint8_t status[], readMode mode)
 readConvertedData() Sends the read command and retrieves STATUS (if enabled) and data NOTE: Call this function after /DRDY goes low and specify the the number of bytes to read and the starting position of data More...
 
void restoreRegisterDefaults (void)
 restoreRegisterDefaults() Updates the registerMap[] array to its default values NOTES: If the MCU keeps a copy of the ADC register settings in memory, then it is important to ensure that these values remain in sync with the actual hardware settings. In order to help facilitate this, this function should be called after powering up or resetting the device (either by hardware pin control or SPI software command). Reading back all of the registers after resetting the device will accomplish the same result. More...
 

Variables

static uint8_t registerMap [((uint8_t) 18)]
 

Detailed Description

ADS124S08 Low level routines using TI Drivers.

Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:

Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.

Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.

Neither the name of Texas Instruments Incorporated nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission.

THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

Function Documentation

bool adcStartupRoutine ( SPI_Handle  spiHdl)

adcStartupRoutine() Startup function to be called before communicating with the ADC

Parameters
[in]*spiHdlSPI_Handle pointer for TI Drivers
Returns
true for successful initialization false for unsuccessful initialization

Here is the call graph for this function:

uint8_t getRegisterValue ( uint8_t  address)

getRegisterValue() Getter function to access the registerMap array outside of this module

Parameters
[in]addressThe 8-bit register address
Returns
The 8-bit register value
int32_t readConvertedData ( SPI_Handle  spiHdl,
uint8_t  status[],
readMode  mode 
)

readConvertedData() Sends the read command and retrieves STATUS (if enabled) and data NOTE: Call this function after /DRDY goes low and specify the the number of bytes to read and the starting position of data

Parameters
[in]spiHdlSPI_Handle from TI Drivers
[in]status[]Pointer to location where STATUS byte will be stored
[in]modeDirect or Command read mode
Returns
32-bit sign-extended conversion result (data only)

Here is the call graph for this function:

void readMultipleRegisters ( SPI_Handle  spiHdl,
uint8_t  startAddress,
uint8_t  count 
)

readMultipleRegisters() Reads a group of registers starting at the specified address NOTE: Use getRegisterValue() to retrieve the read values

Parameters
[in]spiHdlSPI_Handle from TI Drivers
[in]startAddressRegister address to start reading
[in]countNumber of registers to read
Returns
None

Here is the call graph for this function:

uint8_t readSingleRegister ( SPI_Handle  spiHdl,
uint8_t  address 
)

readSingleRegister() Reads contents of a single register at the specified address

Parameters
[in]spiHdlSPI_Handle from TI Drivers
[in]addressAddress of the register to be read
Returns
8-bit register contents

Here is the call graph for this function:

void resetADC ( SPI_Handle  spiHdl)

resetADC() Resets ADC by setting RESET pin low or sending RESET Command

Parameters
[in]spiHdlSPI_Handle from TI Drivers
Returns
None

Here is the call graph for this function:

void restoreRegisterDefaults ( void  )

restoreRegisterDefaults() Updates the registerMap[] array to its default values NOTES: If the MCU keeps a copy of the ADC register settings in memory, then it is important to ensure that these values remain in sync with the actual hardware settings. In order to help facilitate this, this function should be called after powering up or resetting the device (either by hardware pin control or SPI software command). Reading back all of the registers after resetting the device will accomplish the same result.

Returns
None
void sendCommand ( SPI_Handle  spiHdl,
uint8_t  op_code 
)

sendCommand() Sends the specified SPI command to the ADC

Parameters
[in]spiHdlSPI_Handle from TI Drivers
[in]op_codeSPI command byte
Returns
None

Here is the call graph for this function:

void startConversions ( SPI_Handle  spiHdl)

startConversions() Wakes the device from power-down and starts continuous conversions by setting START pin high or sending START Command

Parameters
[in]spiHdlSPI_Handle from TI Drivers
Returns
None

Here is the call graph for this function:

void stopConversions ( SPI_Handle  spiHdl)

stopConversions() Stops continuous conversions by setting START pin low or sending STOP Command

Parameters
[in]spiHdlSPI_Handle from TI Drivers
Returns
None

Here is the call graph for this function:

void writeMultipleRegisters ( SPI_Handle  spiHdl,
uint8_t  startAddress,
uint8_t  count,
uint8_t  regData[] 
)

writeMultipleRegisters() Write data to a group of registers NOTES: Use getRegisterValue() to retrieve the written values. Registers should be re-read after a write operation to ensure proper configuration.

Parameters
[in]spiHdlSPI_Handle from TI Drivers
[in]startAddressRegister address to start writing
[in]countNumber of registers to write
[in]regDataArray that holds the data to write, where element zero is the data to write to the starting address.
Returns
None

Here is the call graph for this function:

void writeSingleRegister ( SPI_Handle  spiHdl,
uint8_t  address,
uint8_t  data 
)

writeSingleRegister() Write data to a single register at the specified address

Parameters
[in]spiHdlSPI_Handle from TI Drivers
[in]addressRegister address to write
[in]data8-bit data to write
Returns
None

Here is the call graph for this function:

Variable Documentation

uint8_t registerMap[((uint8_t) 18)]
static