ADS131A04 Example C Code  1.0.0
Macros | Functions | Variables
hal.c File Reference
#include "hal.h"
Include dependency graph for hal.c:

Macros

#define SSI_BASE_ADDR   (SSI3_BASE)
 

Functions

void InitGPIO (void)
 
void InitSPI (void)
 
void GPIO_DRDY_IRQHandler (void)
 
void InitADC (void)
 
void delay_ms (const uint32_t delay_time_ms)
 
void delay_us (const uint32_t delay_time_us)
 
void setCS (const bool state)
 
void setRESET (const bool state)
 
void toggleRESET (void)
 
bool waitForDRDYinterrupt (const uint32_t timeout_ms)
 
void spiSendReceiveArrays (const uint8_t dataTx[], uint8_t dataRx[], const uint8_t byteLength)
 
uint8_t spiSendReceiveByte (const uint8_t dataTx)
 

Variables

static volatile bool flag_nDRDY_INTERRUPT = false
 

Macro Definition Documentation

#define SSI_BASE_ADDR   (SSI3_BASE)

Function Documentation

void delay_ms ( const uint32_t  delay_time_ms)

Provides a timing delay with 'ms' resolution.

Parameters
delay_time_msnumber of milliseconds to delay.
Returns
None.
void delay_us ( const uint32_t  delay_time_us)

Provides a timing delay with 'us' resolution.

Parameters
delay_time_usnumber of microseconds to delay.
Returns
None.
void GPIO_DRDY_IRQHandler ( void  )

Interrupt handler for nDRDY falling edge interrupt.

Returns
None.
void InitADC ( void  )

Initializes MCU peripherals for interfacing with the ADC.

Returns
None.

Here is the call graph for this function:

void InitGPIO ( void  )

Configures the MCU's GPIO pins that interface with the ADC.

Returns
None.

Here is the call graph for this function:

void InitSPI ( void  )

Configures the MCU's SPI peripheral, for interfacing with the ADC.

Returns
None.
void setCS ( const bool  state)

Controls the state of the nCS GPIO pin.

Parameters
stateboolean indicating which state to set the nCS pin (0=low, 1=high)

NOTE: The 'HIGH' and 'LOW' macros defined in hal.h can be passed to this function for the 'state' parameter value.

Returns
None.
void setRESET ( const bool  state)

Controls the state of the nRESET GPIO pin.

Parameters
stateboolean indicating which state to set the nRESET pin (0=low, 1=high)

NOTE: The 'HIGH' and 'LOW' macros defined in hal.h can be passed to this function for the 'state' parameter value.

Returns
None.
void spiSendReceiveArrays ( const uint8_t  dataTx[],
uint8_t  dataRx[],
const uint8_t  byteLength 
)

Sends SPI byte array on MOSI pin and captures MISO data to a byte array.

Parameters
dataTxbyte array of SPI data to send on MOSI.
dataRxbyte array of SPI data captured on MISO.
byteLengthnumber of bytes to send & receive.

NOTE: Make sure 'dataTx[]' and 'dataRx[]' contain at least as many bytes of data, as indicated by 'byteLength'.

Returns
None.

Here is the call graph for this function:

uint8_t spiSendReceiveByte ( const uint8_t  dataTx)

Sends SPI byte on MOSI pin and captures MISO return byte value.

Parameters
dataTxdata byte to send on MOSI pin.

NOTE: This function is called by spiSendReceiveArrays(). If it is called directly, then the nCS pin must also be directly controlled.

Returns
Captured MISO response byte.
void toggleRESET ( void  )

Toggles the nRESET pin to trigger a reset (LOW, delay 2 ms, then HIGH).

NOTE: The adcStartup() function should be called after resetting the device.

Returns
None.

Here is the call graph for this function:

bool waitForDRDYinterrupt ( const uint32_t  timeout_ms)

Waits for the nDRDY interrupt or until the specified timeout occurs.

Parameters
timeout_msnumber of milliseconds to wait before timeout event.
Returns
Returns 'true' if nDRDY interrupt occurred before the timeout.

Variable Documentation

volatile bool flag_nDRDY_INTERRUPT = false
static

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.