|
AFE_NXP_Arduino 1.0.3
Analog Front-End (AFE) device operation sample code for Arduino
|
#include <AFE_NXP.h>
Public Types | |
| enum | LV_mux_sel : uint8_t { REF2_REF2 = 0 , GPIO0_GPIO1 , REFCOARSE_REF2 , VADD_REF2 , VHDD_REF2 , REF2_VHSS , HV_MUX } |
| using | raw_t = int32_t |
| using | microvolt_t = double |
| typedef void(* | callback_fp_t) (void) |
Public Member Functions | |
| AFE_base (bool spi_addr, bool highspeed_variant, int nINT, int DRDY, int SYN, int nRESET, int DRDY_input=2) | |
| virtual | ~AFE_base () |
| virtual void | begin (void) |
| virtual void | boot (void)=0 |
| virtual void | reset (bool hardware_reset=false)=0 |
| virtual void | set_DRDY_callback (callback_fp_t fnc) |
| virtual void | open_logical_channel (int ch, uint16_t cc0, uint16_t cc1, uint16_t cc2, uint16_t cc3)=0 |
| virtual void | open_logical_channel (int ch, const uint16_t(&cc)[4])=0 |
| virtual void | close_logical_channel (int ch)=0 |
| virtual void | close_logical_channel (void)=0 |
| virtual void | enable_logical_channel (int ch)=0 |
| virtual void | start (int ch)=0 |
| virtual void | start (void)=0 |
| virtual void | start_continuous_conversion (void)=0 |
| virtual void | DRDY_by_sequencer_done (bool flag=true)=0 |
| virtual raw_t | read (int ch)=0 |
| virtual void | read (raw_t *data_ptr)=0 |
| virtual void | read (microvolt_t *data_ptr)=0 |
| virtual raw_t | start_and_read (int ch) |
| template<typename T> | |
| void | start_and_read (T data) |
| double | raw2uv (int ch, raw_t value) |
| double | raw2mv (int ch, raw_t value) |
| double | raw2v (int ch, raw_t value) |
| double | coeff_mV (int ch) |
| double | drdy_delay (int ch) |
| double | drdy_delay (void) |
| int | enabled_logical_channels (void) |
| void | use_DRDY_trigger (bool use=true) |
| Public Member Functions inherited from SPI_for_AFE | |
| void | txrx (uint8_t *data, int size) |
| void | write_r16 (uint16_t reg) |
| void | write_r16 (uint16_t reg, uint16_t val) |
| uint16_t | read_r16 (uint16_t reg) |
| void | write_r24 (uint16_t reg, uint32_t val) |
| int32_t | read_r24 (uint16_t reg) |
| void | burst (uint32_t *data, int length, int width=3) |
Static Public Attributes | |
| static AFE_base * | instance = nullptr |
Protected Member Functions | |
| int | bit_count (uint32_t value) |
| void | default_drdy_cb () |
| virtual void | init (void) |
| int | wait_conversion_complete (double delay=-1.0) |
Static Protected Member Functions | |
| static void | static_default_drdy_cb () |
| static void | DRDY_cb () |
Protected Attributes | |
| bool | dev_add |
| bool | highspeed_variant |
| int | pin_nINT |
| int | pin_DRDY |
| int | pin_SYN |
| int | pin_nRESET |
| int | pin_DRDY_input |
| int | enabled_channels |
| uint8_t | sequence_order [16] |
| double | coeff_uV [16] |
| int | mux_setting [16] |
| double | ch_delay [16] |
| double | total_delay |
| uint32_t | drdy_count |
| volatile bool | drdy_flag |
Static Protected Attributes | |
| static double | delay_accuracy = 1.2 |
| static constexpr uint32_t | timeout_limit = 10000000 |
| static callback_fp_t | cbf_DRDY = nullptr |
NXP Analog Front End class library for Arduino
Copyright: 2023 - 2026 Tedd OKANO Released under the MIT license
A simple class library for NXP Analog Front End: NAFE13388 evaluation boards
| typedef void(* AFE_base::callback_fp_t) (void) |
| using AFE_base::microvolt_t = double |
| using AFE_base::raw_t = int32_t |
| enum AFE_base::LV_mux_sel : uint8_t |
| AFE_base::AFE_base | ( | bool | spi_addr, |
| bool | highspeed_variant, | ||
| int | nINT, | ||
| int | DRDY, | ||
| int | SYN, | ||
| int | nRESET, | ||
| int | DRDY_input = 2 ) |
Constructor to create a AFE_base instance
Definition at line 70 of file AFE_NXP.cpp.
Referenced by NAFE13388_Base::NAFE13388_Base().
|
virtual |
Destractor
Definition at line 83 of file AFE_NXP.cpp.
|
virtual |
Begin the device operation
NAFE13388 initialization. It does following steps (1) Call reset() (2) Call boot()
Definition at line 97 of file AFE_NXP.cpp.
|
protected |
Definition at line 152 of file AFE_NXP.cpp.
|
pure virtual |
|
pure virtual |
|
pure virtual |
All logical channel disable
Implemented in NAFE13388_Base.
|
inline |
|
protected |
Definition at line 123 of file AFE_NXP.cpp.
|
pure virtual |
|
staticprotected |
Definition at line 111 of file AFE_NXP.cpp.
Referenced by init().
|
inline |
|
inline |
|
pure virtual |
|
inline |
|
protectedvirtual |
Definition at line 87 of file AFE_NXP.cpp.
Referenced by begin().
|
pure virtual |
Configure logical channel
| ch | logical channel number (0 ~ 15) |
| cc | array for CH_CONFIG0, CH_CONFIG1, CH_CONFIG2 and CH_CONFIG3 values |
Implemented in NAFE13388_Base.
|
pure virtual |
set callback function when DRDY comes Configure logical channel
| ch | logical channel number (0 ~ 15) |
| cc0 | 16bit value to be set CH_CONFIG0 register (0x20) |
| cc1 | 16bit value to be set CH_CONFIG1 register (0x21) |
| cc2 | 16bit value to be set CH_CONFIG2 register (0x22) |
| cc3 | 16bit value to be set CH_CONFIG3 register (0x23) |
Implemented in NAFE13388_Base.
|
inline |
Convert raw output to milli-volt
| ch | logical channel number to select its gain coefficient |
| value | ADC read value |
Definition at line 201 of file AFE_NXP.h.
Referenced by NAFE13388_Base::self_calibrate().
|
inline |
Convert raw output to micro-volt
| ch | logical channel number to select its gain coefficient |
| value | ADC read value |
Definition at line 164 of file AFE_NXP.h.
Referenced by NAFE13388_Base::read().
|
inline |
Convert raw output to volt
| ch | logical channel number to select its gain coefficient |
| value | ADC read value |
Definition at line 211 of file AFE_NXP.h.
Referenced by NAFE13388_Base::self_calibrate().
|
pure virtual |
Read ADC for single channel
| ch | logical channel number (0 ~ 15) |
Implemented in NAFE13388_Base.
Referenced by LogicalChannel_Base::operator AFE_base::microvolt_t(), LogicalChannel_Base::operator AFE_base::raw_t(), start_and_read(), and start_and_read().
|
pure virtual |
Read ADC for all channel
| data_ptr | pointer to array to store ADC data |
Implemented in NAFE13388_Base.
|
pure virtual |
Read ADC for all channel
| data_ptr | pointer to array to store ADC data |
Implemented in NAFE13388_Base.
|
pure virtual |
|
virtual |
Definition at line 106 of file AFE_NXP.cpp.
Referenced by init(), and use_DRDY_trigger().
|
pure virtual |
|
pure virtual |
Start ADC on all logical channel
Implemented in NAFE13388_Base.
Referenced by start_and_read(), and start_and_read().
|
virtual |
Start and read ADC for single channel
| ch | logical channel number (0 ~ 15) |
Definition at line 129 of file AFE_NXP.cpp.
Referenced by NAFE13388_Base::self_calibrate().
|
inline |
|
pure virtual |
Start continuous AD conversion
Implemented in NAFE13388_Base.
|
staticprotected |
Definition at line 117 of file AFE_NXP.cpp.
Referenced by init(), and use_DRDY_trigger().
| void AFE_base::use_DRDY_trigger | ( | bool | use = true | ) |
Switch to use DRDY to start ADC result reading
| use | true (default) to use DRDY. if false, caliculated delay is used to start reading. |
Definition at line 188 of file AFE_NXP.cpp.
Referenced by init().
|
protected |
Definition at line 165 of file AFE_NXP.cpp.
Referenced by start_and_read(), and start_and_read().
|
staticprotected |
Definition at line 287 of file AFE_NXP.h.
Referenced by DRDY_cb(), set_DRDY_callback(), start_and_read(), and start_and_read().
|
protected |
Channel delay
Definition at line 277 of file AFE_NXP.h.
Referenced by NAFE13388_Base::calc_delay(), NAFE13388_Base::channel_info_update(), drdy_delay(), NAFE13388_Base::open_logical_channel(), and start_and_read().
|
protected |
Coefficient to convert from ADC read value to micro-volt
Definition at line 271 of file AFE_NXP.h.
Referenced by coeff_mV(), NAFE13388_Base::open_logical_channel(), raw2mv(), raw2uv(), and raw2v().
|
staticprotected |
NXP Analog Front End class library for MCX
Copyright: 2023 - 2025 Tedd OKANO Released under the MIT license
Definition at line 279 of file AFE_NXP.h.
Referenced by start_and_read(), start_and_read(), and wait_conversion_complete().
|
protected |
Definition at line 254 of file AFE_NXP.h.
Referenced by AFE_base().
|
protected |
Definition at line 285 of file AFE_NXP.h.
Referenced by default_drdy_cb().
|
protected |
Definition at line 286 of file AFE_NXP.h.
Referenced by default_drdy_cb(), init(), and wait_conversion_complete().
|
protected |
Number of enabled logical channels
Definition at line 265 of file AFE_NXP.h.
Referenced by AFE_base(), NAFE13388_Base::channel_info_update(), enabled_logical_channels(), NAFE13388_Base::read(), and NAFE13388_Base::read().
|
protected |
Definition at line 255 of file AFE_NXP.h.
Referenced by AFE_base(), and NAFE13388_Base::calc_delay().
|
static |
Definition at line 295 of file AFE_NXP.h.
Referenced by begin(), and static_default_drdy_cb().
|
protected |
Multiplexer setting
Definition at line 274 of file AFE_NXP.h.
Referenced by NAFE13388_Base::open_logical_channel(), and raw2uv().
|
protected |
Definition at line 257 of file AFE_NXP.h.
Referenced by AFE_base().
|
protected |
Definition at line 260 of file AFE_NXP.h.
Referenced by AFE_base(), and init().
|
protected |
Definition at line 256 of file AFE_NXP.h.
Referenced by AFE_base().
|
protected |
Definition at line 259 of file AFE_NXP.h.
Referenced by AFE_base(), and NAFE13388_Base::reset().
|
protected |
Definition at line 258 of file AFE_NXP.h.
Referenced by AFE_base().
|
protected |
Number of enabled logical channels
Definition at line 268 of file AFE_NXP.h.
Referenced by NAFE13388_Base::channel_info_update(), and NAFE13388_Base::read().
|
staticconstexprprotected |
Definition at line 281 of file AFE_NXP.h.
Referenced by wait_conversion_complete().
|
protected |
Definition at line 278 of file AFE_NXP.h.
Referenced by NAFE13388_Base::channel_info_update(), drdy_delay(), and start_and_read().