ADS124S08 Example C Code  1.0.0
hal.h
Go to the documentation of this file.
1 
40 #ifndef HAL_H_
41 #define HAL_H_
42 
43 
44 //****************************************************************************
45 //
46 // Standard libraries
47 //
48 //****************************************************************************
49 
50 #include <stdbool.h>
51 #include <stdint.h>
52 
53 #include <ti/drivers/SPI.h>
54 #include <ti/drivers/GPIO.h>
55 
56 /* Driver configuration */
57 #include "ti_drivers_config.h"
58 #include "ads124s08.h"
59 
60 
61 //****************************************************************************
62 //
63 // Insert processor specific header file(s) here
64 //
65 //****************************************************************************
66 
67 /* --- INSERT YOUR CODE HERE --- */
68 
69 //****************************************************************************
70 //
71 // BoosterPack pinout...LP
72 //
73 //****************************************************************************
74 //
75 // LEFT RIGHT
76 // /--------\ /--------\
77 // +3.3V -|3V3 +5V|- +5V -|PG1 GND|- GND
78 // -|PD2 GND|- GND -|PK4 PM7|- nRESET
79 // -|PP0 PB4|- -|PK5 *PP5|-
80 // -|PP1 PB5|- -|PM0 PA7|-
81 // -|PD4 PK0|- -|PM1 RST|-
82 // -|PD5 PK1|- -|PM2 PQ2|- DIN
83 // SCLK -|PQ0 PK2|- -|PH0 PQ3|- DOUT
84 // -|PP4* PK3|- START -|PH1 *PP3|-
85 // -|PN5 PA4|- -|PK6 PQ1|- nCS
86 // -|PN4 PA5|- nDRDY -|PK7 PM6|-
87 // \--------/ \--------/
88 //
89 //****************************************************************************
90 
91 //*****************************************************************************
92 //
93 // Pin definitions (MSP432E401Y)
94 //
95 //*****************************************************************************
96 #define nDRDY_PORT (GPIO_PORTK_BASE)
97 #define nDRDY_PIN (GPIO_PIN_7)
98 #define nDRDY_INT (INT_GPIOK)
99 #define nCS_PORT (GPIO_PORTQ_BASE)
100 #define nCS_PIN (GPIO_PIN_1)
101 #define nRESET_PORT (GPIO_PORTM_BASE)
102 #define nRESET_PIN (GPIO_PIN_7)
103 #define START_PORT (GPIO_PORTH_BASE)
104 #define START_PIN (GPIO_PIN_1)
105 
106 //*****************************************************************************
107 //
108 // Function Prototypes
109 //
110 //*****************************************************************************
111 void delay_ms(const uint32_t delay_time_ms);
112 void delay_us(const uint32_t delay_time_us);
113 bool InitADCPeripherals( SPI_Handle *spiHdl );
114 void InitGPIO( void );
115 void InitSPI( void );
116 void setSTART (bool state );
117 bool getSTART( void );
118 void setCS( bool state );
119 bool getCS( void );
120 void setRESET( bool state );
121 bool getRESET( void );
122 void toggleSTART( bool direction );
123 void toggleRESET( void );
124 void sendSTART( SPI_Handle spiHdl );
125 void sendSTOP( SPI_Handle spiHdl );
126 void sendRESET( SPI_Handle spiHdl );
127 void sendPowerDown( SPI_Handle spiHdl );
128 void sendWakeup( SPI_Handle spiHdl );
129 void spiSendReceiveArrays( SPI_Handle spiHdl, uint8_t DataTx[], uint8_t DataRx[], uint8_t byteLength );
130 uint8_t spiSendReceiveByte( SPI_Handle spiHdl, uint8_t dataTx );
131 bool waitForDRDYHtoL( uint32_t timeout_ms );
132 bool getDRDYinterruptStatus(void);
133 void setDRDYinterruptStatus(const bool value);
134 void enableDRDYinterrupt(const bool intEnable);
135 
136 //*****************************************************************************
137 //
138 // Macros
139 //
140 //*****************************************************************************
142 #define HIGH ((bool) true)
143 
145 #define LOW ((bool) false)
146 
147 
148 
149 #endif /* HAL_H_ */
bool InitADCPeripherals(SPI_Handle *spiHdl)
InitADCPeripherals() Initialize MCU peripherals and pins to interface with ADC.
Definition: hal.c:272
void setRESET(bool state)
setRESET() Sets the state of the MCU ADC_RESET GPIO pin
Definition: hal.c:329
This header file contains all register map definitions for the ADS124S08 device family.
void InitGPIO(void)
InitGPIO() Configures the MCU&#39;s GPIO pins that interface with the ADC.
Definition: hal.c:179
bool getSTART(void)
getSTART() Returns the state of the MCU&#39;s ADC_START GPIO pin
Definition: hal.c:367
void setCS(bool state)
setCS() Sets the state of the "/CS" GPIO pin
Definition: hal.c:530
void spiSendReceiveArrays(SPI_Handle spiHdl, uint8_t DataTx[], uint8_t DataRx[], uint8_t byteLength)
spiSendReceiveArrays() Sends SPI commands to ADC and returns a response in array format ...
Definition: hal.c:604
bool getRESET(void)
getRESET() Returns the state of the MCU&#39;s ADC_RESET GPIO pin
Definition: hal.c:311
bool waitForDRDYHtoL(uint32_t timeout_ms)
waitForDRDYHtoL() Waits for a nDRDY GPIO to go from High to Low or until a timeout condition occurs T...
Definition: hal.c:577
void sendRESET(SPI_Handle spiHdl)
sendRESET() Sends RESET Command through SPI, then waits 4096 tCLKs
Definition: hal.c:476
void setDRDYinterruptStatus(const bool value)
setDRDYinterruptStatus() Sets the value of the nDRDY interrupt flag.
Definition: hal.c:91
void setSTART(bool state)
setSTART() Sets the state of the MCU START GPIO pin
Definition: hal.c:384
void delay_ms(const uint32_t delay_time_ms)
delay_ms() Provides a timing delay with &#39;ms&#39; resolution.
Definition: hal.c:135
void sendSTART(SPI_Handle spiHdl)
sendSTART() Sends START Command through SPI
Definition: hal.c:440
void enableDRDYinterrupt(const bool intEnable)
enableDRDYinterrupt() Enables or disables the nDRDY interrupt.
Definition: hal.c:104
void toggleRESET(void)
toggleRESET() Pulses the /RESET GPIO pin low
Definition: hal.c:345
bool getDRDYinterruptStatus(void)
getDRDYinterruptStatus() Gets the current status of nDRDY interrupt flag.
Definition: hal.c:78
bool getCS(void)
getCS() Returns the state of the MCU&#39;s ADC_CS GPIO pin
Definition: hal.c:546
void delay_us(const uint32_t delay_time_us)
delay_us() Provides a timing delay with &#39;us&#39; resolution.
Definition: hal.c:154
uint8_t spiSendReceiveByte(SPI_Handle spiHdl, uint8_t dataTx)
spiSendReceiveByte() Sends a single byte to ADC and returns a response
Definition: hal.c:657
void InitSPI(void)
InitSPI() Configures the MCU&#39;s SPI peripheral, for interfacing with the ADC.
Definition: hal.c:231
void sendSTOP(SPI_Handle spiHdl)
sendSTOP() Sends STOP Command through SPI
Definition: hal.c:458
void toggleSTART(bool direction)
toggleSTART() Pulses the START GPIO pin low param[in] direction sets the toggle direction base on ini...
Definition: hal.c:405
SPI_Handle spiHdl
void sendWakeup(SPI_Handle spiHdl)
sendWakeup() Sends WAKEUP command through SPI
Definition: hal.c:494
void sendPowerDown(SPI_Handle spiHdl)