AFE_NXP_Arduino 2.0.1 Analog Front-End (AFE) device operation sample code for Arduino

Loading...
Searching...
No Matches
SPI_for_AFE.h
Go to the documentation of this file.
1
13
14#ifndef ARDUINO_SPI_FOR_AFE_H
15#define ARDUINO_SPI_FOR_AFE_H
16
17#include <Arduino.h>
18#include <stdint.h>
19
20#include <SPI.h>
21
22 class SPI_for_AFE
23{
24public:
30 void txrx( uint8_t *data, int size );
31
36 void write_r16( uint16_t reg );
37
43 void write_r16( uint16_t reg, uint16_t val );
44
50 uint16_t read_r16( uint16_t reg );
51
57 void write_r24( uint16_t reg, uint32_t val );
58
64 int32_t read_r24( uint16_t reg );
65
66 void burst( uint32_t *data, int length, int width = 3 );
67
68private:
69
70 // functions to access AFE multibyte data access independent from endianess
71 inline int32_t get_data16( uint8_t *vp )
72 {
73 return ((uint16_t)(*(vp + 0)) << 8) | *(vp + 1);
74 }
75
76 inline int32_t get_data24( uint8_t *vp )
77 {
78 int32_t r0 = *(vp + 0);
79 int32_t r1 = *(vp + 1);
80 int32_t r2 = *(vp + 2);
81 int32_t r = ( (r0 << 24) | (r1 << 16) | (r2 << 8) );
82
83 return r >> 8;
84 }
85
86 static constexpr int command_length = 2;
87// const bool dev_ad;
88};
89
90#endif // ARDUINO_SPI_FOR_AFE_H
SPI_for_AFE
Definition SPI_for_AFE.h:23
SPI_for_AFE::read_r24
int32_t read_r24(uint16_t reg)
Definition SPI_for_AFE.cpp:48
SPI_for_AFE::txrx
void txrx(uint8_t *data, int size)
Definition SPI_for_AFE.cpp:3
SPI_for_AFE::write_r24
void write_r24(uint16_t reg, uint32_t val)
Definition SPI_for_AFE.cpp:40
SPI_for_AFE::read_r16
uint16_t read_r16(uint16_t reg)
Definition SPI_for_AFE.cpp:29
SPI_for_AFE::command_length
static constexpr int command_length
Definition SPI_for_AFE.h:86
SPI_for_AFE::burst
void burst(uint32_t *data, int length, int width=3)
Definition SPI_for_AFE.cpp:59
SPI_for_AFE::get_data24
int32_t get_data24(uint8_t *vp)
Definition SPI_for_AFE.h:76
SPI_for_AFE::write_r16
void write_r16(uint16_t reg)
Definition SPI_for_AFE.cpp:13
SPI_for_AFE::get_data16
int32_t get_data16(uint8_t *vp)
Definition SPI_for_AFE.h:71