AFE_NXP_Arduino 2.0.2 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{
24 public:
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
68 protected:
69 void init( void );
70
71 private:
72
73 // functions to access AFE multibyte data access independent from endianess
74 inline int32_t get_data16( uint8_t *vp )
75 {
76 return ((uint16_t)(*(vp + 0)) << 8) | *(vp + 1);
77 }
78
79 inline int32_t get_data24( uint8_t *vp )
80 {
81 int32_t r0 = *(vp + 0);
82 int32_t r1 = *(vp + 1);
83 int32_t r2 = *(vp + 2);
84 int32_t r = ( (r0 << 24) | (r1 << 16) | (r2 << 8) );
85
86 return r >> 8;
87 }
88
89 static constexpr int command_length = 2;
90// const bool dev_ad;
91};
92
93#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::init
void init(void)
Definition SPI_for_AFE.cpp:73
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:89
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:79
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:74