|
AFE_NXP_Arduino 2.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 | volt_t = double |
| typedef void(* | callback_fp_t) (void) |
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) |
Protected Member Functions inherited from SPI_for_AFE | |
| void | init (void) |
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 | pin_SYNCDAC |
| int | enabled_channels |
| uint8_t | sequence_order [16] |
| double | coeff_V [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.1 |
| 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
| AFE_base::AFE_base | ( | bool | spi_addr, |
| bool | highspeed_variant, | ||
| int | nINT, | ||
| int | DRDY, | ||
| int | SYN, | ||
| int | nRESET, | ||
| int | DRDY_input, | ||
| int | SYNCDAC | ||
| ) |
Constructor to create a AFE_base instance
Definition at line 70 of file AFE_NXP.cpp.
|
virtual |
Destractor
Definition at line 84 of file AFE_NXP.cpp.
Begin the device operation
NAFE13388 initialization. It does following steps (1) Call reset() (2) Call boot()
Definition at line 98 of file AFE_NXP.cpp.
Definition at line 155 of file AFE_NXP.cpp.
Set system-level config registers
Implemented in NAFE13388_Base, and NAFE33352_Base.
Referenced by begin().
Logical channel disable
| ch | logical channel number (0 ~ 15) |
Implemented in NAFE13388_Base, and NAFE33352_Base.
Referenced by LogicalChannel_Base::disable().
All logical channel disable
Implemented in NAFE13388_Base, and NAFE33352_Base.
Definition at line 126 of file AFE_NXP.cpp.
Referenced by static_default_drdy_cb().
DRDY event select
| set | true for DRDY by sequencer is done |
Implemented in NAFE13388_Base, and NAFE33352_Base.
Definition at line 114 of file AFE_NXP.cpp.
Referenced by init().
Logical channel enable
| ch | logical channel number (0 ~ 15) |
Implemented in NAFE13388_Base, and NAFE33352_Base.
Referenced by LogicalChannel_Base::enable().
Definition at line 88 of file AFE_NXP.cpp.
Referenced by begin().
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, and NAFE33352_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, and NAFE33352_Base.
Convert raw output to milli-volt
| ch | logical channel number to select its gain coefficient |
| value | ADC read value |
Definition at line 174 of file AFE_NXP.h.
Referenced by NAFE13388_Base::self_calibrate().
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 NAFE33352_Base::read().
Convert raw output to volt
| ch | logical channel number to select its gain coefficient |
| value | ADC read value |
Implemented in NAFE13388_Base, and NAFE33352_Base.
Referenced by raw2mv(), raw2uv(), and LogicalChannel_Base::read().
|
pure virtual |
Read ADC for single channel
| ch | logical channel number (0 ~ 15) |
Implemented in NAFE13388_Base, and NAFE33352_Base.
Referenced by AFE_base(), bit_count(), drdy_delay(), init(), LogicalChannel_Base::operator AFE_base::raw_t(), LogicalChannel_Base::operator AFE_base::volt_t(), raw2mv(), raw2uv(), set_DRDY_callback(), start_and_read(), start_and_read(), use_DRDY_trigger(), and wait_conversion_complete().
|
pure virtual |
Read ADC for all channel
| data_ptr | pointer to array to store ADC data |
Implemented in NAFE13388_Base, and NAFE33352_Base.
|
pure virtual |
Read ADC for all channel
| data_ptr | pointer to array to store ADC data |
Implemented in NAFE13388_Base, and NAFE33352_Base.
|
virtual |
Definition at line 109 of file AFE_NXP.cpp.
Referenced by init(), and use_DRDY_trigger().
Start ADC
| ch | logical channel number (0 ~ 15) |
Implemented in NAFE13388_Base, and NAFE33352_Base.
Start ADC on all logical channel
Implemented in NAFE13388_Base, and NAFE33352_Base.
Referenced by start_and_read(), and start_and_read().
Start and read ADC for single channel
| ch | logical channel number (0 ~ 15) |
Definition at line 132 of file AFE_NXP.cpp.
Referenced by LogicalChannel_Base::read(), and NAFE13388_Base::self_calibrate().
Start continuous AD conversion
Implemented in NAFE13388_Base, and NAFE33352_Base.
Definition at line 120 of file AFE_NXP.cpp.
Referenced by init(), and use_DRDY_trigger().
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 194 of file AFE_NXP.cpp.
Referenced by init().
Definition at line 168 of file AFE_NXP.cpp.
Referenced by start_and_read(), and start_and_read().
|
staticprotected |
Definition at line 250 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 240 of file AFE_NXP.h.
Referenced by NAFE13388_Base::calc_delay(), NAFE33352_Base::calc_delay(), NAFE13388_Base::channel_info_update(), NAFE33352_Base::channel_info_update(), drdy_delay(), NAFE13388_Base::open_logical_channel(), NAFE33352_Base::open_logical_channel(), and start_and_read().
|
protected |
Coefficient to convert from ADC read value to micro-volt
Definition at line 234 of file AFE_NXP.h.
Referenced by NAFE13388_Base::open_logical_channel(), NAFE33352_Base::open_logical_channel(), NAFE13388_Base::raw2v(), and NAFE33352_Base::raw2v().
|
staticprotected |
NXP Analog Front End class library for MCX
Copyright: 2023 - 2025 Tedd OKANO Released under the MIT license
Definition at line 242 of file AFE_NXP.h.
Referenced by start_and_read(), start_and_read(), and wait_conversion_complete().
|
protected |
Definition at line 248 of file AFE_NXP.h.
Referenced by default_drdy_cb().
Definition at line 249 of file AFE_NXP.h.
Referenced by default_drdy_cb(), init(), and wait_conversion_complete().
|
protected |
Number of enabled logical channels
Definition at line 228 of file AFE_NXP.h.
Referenced by NAFE13388_Base::channel_info_update(), NAFE33352_Base::channel_info_update(), enabled_logical_channels(), NAFE13388_Base::read(), NAFE33352_Base::read(), NAFE13388_Base::read(), and NAFE33352_Base::read().
|
protected |
Definition at line 216 of file AFE_NXP.h.
Referenced by NAFE13388_Base::calc_delay(), and NAFE33352_Base::calc_delay().
Definition at line 258 of file AFE_NXP.h.
Referenced by begin(), and static_default_drdy_cb().
|
protected |
Multiplexer setting
Definition at line 237 of file AFE_NXP.h.
Referenced by NAFE13388_Base::open_logical_channel(), NAFE33352_Base::open_logical_channel(), NAFE13388_Base::raw2v(), and NAFE33352_Base::raw2v().
|
protected |
Definition at line 218 of file AFE_NXP.h.
Referenced by AFE_base().
|
protected |
Definition at line 221 of file AFE_NXP.h.
Referenced by AFE_base(), and init().
|
protected |
Definition at line 217 of file AFE_NXP.h.
Referenced by AFE_base().
|
protected |
Definition at line 220 of file AFE_NXP.h.
Referenced by AFE_base(), and NAFE13388_Base::reset().
|
protected |
Definition at line 219 of file AFE_NXP.h.
Referenced by AFE_base().
|
protected |
Definition at line 222 of file AFE_NXP.h.
Referenced by AFE_base().
|
protected |
Number of enabled logical channels
Definition at line 231 of file AFE_NXP.h.
Referenced by NAFE13388_Base::channel_info_update(), NAFE33352_Base::channel_info_update(), NAFE13388_Base::read(), and NAFE33352_Base::read().
Definition at line 244 of file AFE_NXP.h.
Referenced by wait_conversion_complete().
|
protected |
Definition at line 241 of file AFE_NXP.h.
Referenced by NAFE13388_Base::channel_info_update(), NAFE33352_Base::channel_info_update(), drdy_delay(), and start_and_read().