ADS1282 Example C Code
1.0.0
|
Hardware abstraction layer (HAL) implementation. More...
#include "hal.h"
Functions | |
void | initializeGPIO (void) |
void | initializeSPI (void) |
void | nDRDYinterruptHandler (void) |
void | initADCperhiperhals (void) |
void | setPWDN (const bool state) |
void | setRESET (const bool state) |
void | toggleRESET (void) |
bool | waitForDRDYinterrupt (const uint32_t timeout_ms) |
bool | spiSendReceive (const uint8_t transmitBuffer[], uint8_t receiveBuffer[], const uint8_t byteLength) |
void | delay_us (const uint32_t delay_time_us) |
void | delay_ms (const uint32_t delay_time_ms) |
Variables | |
static volatile bool | flag_nDRDY_INTERRUPT = false |
Flag to indicate if a /DRDY interrupt has occurred. More... | |
SPI_Handle | ads1282_spi_handle |
SPI Peripheral handle for TI Driver. More... | |
Hardware abstraction layer (HAL) implementation.
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.
void delay_ms | ( | const uint32_t | delay_time_ms | ) |
Blocking delay function with approximate 'ms' resolution.
delay_time_ms | is the number of milliseconds to delay. |
void delay_us | ( | const uint32_t | delay_time_us | ) |
Blocking delay function with approximate 'us' resolution.
delay_time_us | is the number of microseconds to delay. |
void initADCperhiperhals | ( | void | ) |
Initializes MCU peripherals for interfacing with the ADC then calls the adcStartupRoutine() function.
void initializeGPIO | ( | void | ) |
Configures the MCU's GPIO pins that interface with the ADC.
void initializeSPI | ( | void | ) |
Configures the MCU's SPI peripheral for interfacing with the ADC.
void nDRDYinterruptHandler | ( | void | ) |
Interrupt handler for /DRDY falling edge interrupt.
setPWDN | ( | const bool | state | ) |
Controls the state of the /PWDN GPIO pin.
state | boolean indicating which state to set the /PWDN pin (0=low, 1=high). |
The 'HIGH' and 'LOW' macros defined in hal.h can be use for the 'state' parameter.
void setRESET | ( | const bool | state | ) |
Controls the state of the /RESET GPIO pin.
state | boolean indicating which state to set the /RESET pin (0=low, 1=high). |
The 'HIGH' and 'LOW' macros defined in hal.h can be use for the 'state' parameter.
bool spiSendReceive | ( | const uint8_t | transmitBuffer[], |
uint8_t | receiveBuffer[], | ||
const uint8_t | byteLength | ||
) |
Sends SPI byte array on MOSI pin and captures MISO data to a byte array.
[in] | transmitBuffer[] | byte array of SPI data to send on MOSI. |
[out] | receiveBuffer[] | byte array of SPI data captured on MISO. |
[in] | byteLength | number of bytes to send & receive. |
NOTE: Make sure 'dataTx[]' and 'dataRx[]' contain at least as many bytes of data, as indicated by 'byteLength'.
void toggleRESET | ( | void | ) |
Toggles the /RESET pin to trigger a reset (LOW, delay 2 ms, then HIGH).
bool waitForDRDYinterrupt | ( | const uint32_t | timeout_ms | ) |
Waits for the /DRDY interrupt or until the specified timeout occurs.
timeout_ms | Number of milliseconds to wait before timeout event. |
SPI_Handle ads1282_spi_handle |
SPI Peripheral handle for TI Driver.
|
static |
Flag to indicate if a /DRDY interrupt has occurred.