ADXL362 accelerometer library
Dependents: BLENano_SimpleTemplate_adxl362_170813 nRF51_ADXL3xx
Fork of ADXL362 by
ADXL362 Class Reference
Analog devices ADXL362 Digital Output MEMS Accelerometer. More...
#include <ADXL362.h>
Public Member Functions | |
ADXL362 (PinName CS, PinName MOSI, PinName MISO, PinName SCK) | |
SPI configuration & constructor. | |
void | frequency (int hz) |
Sets ADXL362 SPI bus frequency. | |
void | reset (void) |
Low level SPI bus comm methods. | |
void | write_reg (ADXL362_register_t reg, uint8_t data) |
Writes the reg register with data. | |
uint8_t | read_reg (ADXL362_register_t reg) |
Reads the reg register. | |
uint16_t | read_reg_u16 (ADXL362_register_t reg) |
Reads 16 bit registers from the ADXL362. | |
void | write_reg_u16 (ADXL362_register_t reg, uint16_t data) |
Writes 16 bit registers to the ADXL362. | |
void | set_power_ctl_reg (uint8_t data) |
ADXL general register R/W methods. | |
void | set_filter_ctl_reg (uint8_t data) |
Sets the FILTER_CTL register. | |
uint8_t | read_status () |
Reads the STATUS register of the ADXL362. | |
void | set_mode (ADXL362_modes_t mode) |
Sets the STANDBY/MEASUREMENT mode of the ADXL362. | |
uint64_t | scan () |
ADXL X/Y/Z/T scanning methods. | |
uint8_t | scanx_u8 () |
Reads the X 8 bit register from the ADXL362 ADXL362 is set in measurement mode using ADXL362::set_mode(ADXL362::MEASUREMENT) | |
uint16_t | scanx () |
Reads the X 16 bit register from the ADXL362 ADXL362 is set in measurement mode using ADXL362::set_mode(ADXL362::MEASUREMENT) | |
uint8_t | scany_u8 () |
Reads the Y 8 bit register from the ADXL362 ADXL362 is set in measurement mode using ADXL362::set_mode(ADXL362::MEASUREMENT) | |
uint16_t | scany () |
Reads the Y 16 bit register from the ADXL362 ADXL362 is set in measurement mode using ADXL362::set_mode(ADXL362::MEASUREMENT) | |
uint8_t | scanz_u8 () |
Reads the Z 8 bit register from the ADXL362 ADXL362 is set in measurement mode using ADXL362::set_mode(ADXL362::MEASUREMENT) | |
uint16_t | scanz () |
Reads the Z 16 bit register from the ADXL362 ADXL362 is set in measurement mode using ADXL362::set_mode(ADXL362::MEASUREMENT) | |
uint16_t | scant () |
Reads the T 16 bit register from the ADXL362 ADXL362 is set in measurement mode using ADXL362::set_mode(ADXL362::MEASUREMENT) | |
void | set_activity_threshold (uint16_t threshold) |
ADXL362 activity methods. | |
void | set_activity_time (uint8_t time) |
Sets the activity time register To enable activity/inactivity, the ACT_INACT_CTL reg must also be set using the ADXL362::set_act_inact_ctl_reg(uint8_t data) method. | |
void | set_inactivity_threshold (uint16_t threshold) |
Sets the inactivity threshold register To enable activity/inactivity, the ACT_INACT_CTL reg must also be set using the ADXL362::set_act_inact_ctl_reg(uint8_t data) method. | |
void | set_inactivity_time (uint16_t time) |
Sets the inactivity time register To enable activity/inactivity, the ACT_INACT_CTL reg must also be set using the ADXL362::set_act_inact_ctl_reg(uint8_t data) method. | |
void | set_act_inact_ctl_reg (uint8_t data) |
Sets the ACT_INACT_CTL register of the ADXL362. | |
void | set_interrupt1_pin (PinName in, uint8_t data, void(*callback_rising)(void), void(*callback_falling)(void), PinMode pull=PullNone) |
ADXL362 interrupt methods. | |
void | set_interrupt2_pin (PinName in, uint8_t data, void(*callback_rising)(void), void(*callback_falling)(void), PinMode pull=PullNone) |
Configures the INT2 pin of the ADXL362 to be used in interrupt mode. | |
void | enable_interrupt1 () |
Enables external interrupt registration for pin configured as INT1 To enable this interrupt, it must first be configured using ADXL362::set_interrupt1_pin() | |
void | enable_interrupt2 () |
Enables external interrupt registration for pin configured as INT2 * To enable this interrupt, it must first be configured using ADXL362::set_interrupt2_pin() | |
void | disable_interrupt1 () |
Disables external interrupt registration for pin configured as INT1. | |
void | disable_interrupt2 () |
Disables external interrupt registration for pin configured as INT2. | |
void | set_polling_interrupt1_pin (PinName in, uint8_t data, PinMode pull=PullNone) |
Configures INT1 output of the ADXL362 for polling use. | |
void | set_polling_interrupt2_pin (PinName in, uint8_t data, PinMode pull=PullNone) |
Configures INT2 output of the ADXL362 for polling use. | |
bool | get_int1 () |
Gets the active state of the INT1 pin. | |
bool | get_int2 () |
Gets the active state of the INT2 pin. | |
uint16_t | fifo_read_nr_of_entries () |
ADXL362 FIFO methods. | |
void | fifo_setup (bool store_temp, ADXL362_FIFO_modes_t mode, uint16_t nr_of_entries) |
Setup for the FIFO. | |
uint16_t | fifo_read_u16 () |
Reads a FIFO entry. | |
uint64_t | fifo_scan () |
Reads 3(4) bytes from the FIFO(if store_temp was set), assembles the data in the format used by the scan method ADXL362::fifo_setup() needs to be called before calling fifo_scan to ensure correct fifo operation fifo_scan and fifo_read_u16 should not be used as fifo_read_u16 disaligns the fifo therefore fifo_scan will return data from multiple samples. | |
Data Fields | |
SPI | adxl362 |
SPI instance of the ADXL362. | |
DigitalOut | cs |
DigitalOut instance for the chipselect of the ADXL362. |
Detailed Description
Analog devices ADXL362 Digital Output MEMS Accelerometer.
Definition at line 56 of file ADXL362.h.
Constructor & Destructor Documentation
ADXL362 | ( | PinName | CS, |
PinName | MOSI, | ||
PinName | MISO, | ||
PinName | SCK | ||
) |
Member Function Documentation
void disable_interrupt1 | ( | ) |
Disables external interrupt registration for pin configured as INT1.
Definition at line 468 of file ADXL362.cpp.
void disable_interrupt2 | ( | ) |
Disables external interrupt registration for pin configured as INT2.
Definition at line 476 of file ADXL362.cpp.
void enable_interrupt1 | ( | ) |
Enables external interrupt registration for pin configured as INT1 To enable this interrupt, it must first be configured using ADXL362::set_interrupt1_pin()
Definition at line 451 of file ADXL362.cpp.
void enable_interrupt2 | ( | ) |
Enables external interrupt registration for pin configured as INT2 * To enable this interrupt, it must first be configured using ADXL362::set_interrupt2_pin()
Definition at line 460 of file ADXL362.cpp.
uint16_t fifo_read_nr_of_entries | ( | ) |
ADXL362 FIFO methods.
Reads the FIFO_ENTRIES_L and FIFO_ENTRIES_H register.
- Returns:
- the number of entries in the FIFO
Definition at line 512 of file ADXL362.cpp.
uint16_t fifo_read_u16 | ( | ) |
uint64_t fifo_scan | ( | ) |
Reads 3(4) bytes from the FIFO(if store_temp was set), assembles the data in the format used by the scan method ADXL362::fifo_setup() needs to be called before calling fifo_scan to ensure correct fifo operation fifo_scan and fifo_read_u16 should not be used as fifo_read_u16 disaligns the fifo therefore fifo_scan will return data from multiple samples.
- Returns:
- scanned data from the fifo in the 0xXXYYZZTT format
Definition at line 563 of file ADXL362.cpp.
void fifo_setup | ( | bool | store_temp, |
ADXL362_FIFO_modes_t | mode, | ||
uint16_t | nr_of_entries | ||
) |
Setup for the FIFO.
- Parameters:
-
store_temp - boolean, true - temperature will be stored in the fifo. false otherwise mode - ADXL362_FIFO_modes_t fifo mode nr_of_entries - number of entries in the FIFO
Definition at line 523 of file ADXL362.cpp.
void frequency | ( | int | hz ) |
Sets ADXL362 SPI bus frequency.
- Parameters:
-
hz - frequency in hz
Definition at line 74 of file ADXL362.cpp.
bool get_int1 | ( | ) |
Gets the active state of the INT1 pin.
- Returns:
- true if active, false if not active
Definition at line 377 of file ADXL362.cpp.
bool get_int2 | ( | ) |
Gets the active state of the INT2 pin.
- Returns:
- true if active, false if not active
Definition at line 387 of file ADXL362.cpp.
uint8_t read_reg | ( | ADXL362_register_t | reg ) |
Reads the reg register.
- Parameters:
-
reg - ADXL362_register_t register to be read
- Returns:
- - data read from the register
Definition at line 113 of file ADXL362.cpp.
uint16_t read_reg_u16 | ( | ADXL362_register_t | reg ) |
Reads 16 bit registers from the ADXL362.
Performs conversion from Motorola to Intel Byte order
- Parameters:
-
reg - ADXL362_register_t register to be read
- Returns:
- - data read from the ADXL362
Definition at line 148 of file ADXL362.cpp.
uint8_t read_status | ( | ) |
Reads the STATUS register of the ADXL362.
- Returns:
- - data in the status register
Definition at line 503 of file ADXL362.cpp.
void reset | ( | void | ) |
Low level SPI bus comm methods.
Resets the ADXL362 A latency of approximately 0.5 ms is required after soft reset.
Definition at line 83 of file ADXL362.cpp.
uint64_t scan | ( | ) |
ADXL X/Y/Z/T scanning methods.
Scans the X,Y,Z,T registers for data.
ADXL362 needs to be in measurement mode to read data ADXL362 is set in measurement mode using ADXL362::set_mode(ADXL362::MEASUREMENT)
- Returns:
- a 64 bit integer with the following format 0xXXYYZZTT
Definition at line 169 of file ADXL362.cpp.
uint16_t scant | ( | ) |
Reads the T 16 bit register from the ADXL362 ADXL362 is set in measurement mode using ADXL362::set_mode(ADXL362::MEASUREMENT)
- Returns:
- 16 bit T data
Definition at line 261 of file ADXL362.cpp.
uint16_t scanx | ( | ) |
Reads the X 16 bit register from the ADXL362 ADXL362 is set in measurement mode using ADXL362::set_mode(ADXL362::MEASUREMENT)
- Returns:
- 16 bit X data
Definition at line 211 of file ADXL362.cpp.
uint8_t scanx_u8 | ( | ) |
Reads the X 8 bit register from the ADXL362 ADXL362 is set in measurement mode using ADXL362::set_mode(ADXL362::MEASUREMENT)
- Returns:
- 8 bit X data
Definition at line 201 of file ADXL362.cpp.
uint16_t scany | ( | ) |
Reads the Y 16 bit register from the ADXL362 ADXL362 is set in measurement mode using ADXL362::set_mode(ADXL362::MEASUREMENT)
- Returns:
- 16 bit Y data
Definition at line 231 of file ADXL362.cpp.
uint8_t scany_u8 | ( | ) |
Reads the Y 8 bit register from the ADXL362 ADXL362 is set in measurement mode using ADXL362::set_mode(ADXL362::MEASUREMENT)
- Returns:
- 8 bit Y data
Definition at line 221 of file ADXL362.cpp.
uint16_t scanz | ( | ) |
Reads the Z 16 bit register from the ADXL362 ADXL362 is set in measurement mode using ADXL362::set_mode(ADXL362::MEASUREMENT)
- Returns:
- 16 bit Z data
Definition at line 251 of file ADXL362.cpp.
uint8_t scanz_u8 | ( | ) |
Reads the Z 8 bit register from the ADXL362 ADXL362 is set in measurement mode using ADXL362::set_mode(ADXL362::MEASUREMENT)
- Returns:
- 8 bit Z data
Definition at line 241 of file ADXL362.cpp.
void set_act_inact_ctl_reg | ( | uint8_t | data ) |
Sets the ACT_INACT_CTL register of the ADXL362.
- Parameters:
-
data - data to be written to the register
Definition at line 326 of file ADXL362.cpp.
void set_activity_threshold | ( | uint16_t | threshold ) |
ADXL362 activity methods.
Sets the activity threshold registers To enable activity/inactivity, the ACT_INACT_CTL reg must also be set using the ADXL362::set_act_inact_ctl_reg(uint8_t data) method.
- Parameters:
-
threshold - activity threshold in natural format
Definition at line 284 of file ADXL362.cpp.
void set_activity_time | ( | uint8_t | time ) |
Sets the activity time register To enable activity/inactivity, the ACT_INACT_CTL reg must also be set using the ADXL362::set_act_inact_ctl_reg(uint8_t data) method.
- Parameters:
-
time - activity time
Definition at line 295 of file ADXL362.cpp.
void set_filter_ctl_reg | ( | uint8_t | data ) |
Sets the FILTER_CTL register.
- Parameters:
-
data - data to be written to the register
Definition at line 494 of file ADXL362.cpp.
void set_inactivity_threshold | ( | uint16_t | threshold ) |
Sets the inactivity threshold register To enable activity/inactivity, the ACT_INACT_CTL reg must also be set using the ADXL362::set_act_inact_ctl_reg(uint8_t data) method.
- Parameters:
-
threshold - inactivity threshold in natural format
Definition at line 306 of file ADXL362.cpp.
void set_inactivity_time | ( | uint16_t | time ) |
Sets the inactivity time register To enable activity/inactivity, the ACT_INACT_CTL reg must also be set using the ADXL362::set_act_inact_ctl_reg(uint8_t data) method.
- Parameters:
-
time - inactivity time in natural format
Definition at line 317 of file ADXL362.cpp.
void set_interrupt1_pin | ( | PinName | in, |
uint8_t | data, | ||
void(*)(void) | callback_rising, | ||
void(*)(void) | callback_falling, | ||
PinMode | pull = PullNone |
||
) |
ADXL362 interrupt methods.
Configures the INT1 pin of the ADXL362 to be used in interrupt mode.
- Parameters:
-
in - uC pin connected to ADXL362's INT1 data - data to be written to INTMAP1 callback_rising - rising edge interrupt callback - can be set to NULL if no callback is required for rising edge callback_falling - falling edge interrupt callback - can be set to NULL if no callback is required for falling edge pull - (optional) configures pullup on In pin
Definition at line 402 of file ADXL362.cpp.
void set_interrupt2_pin | ( | PinName | in, |
uint8_t | data, | ||
void(*)(void) | callback_rising, | ||
void(*)(void) | callback_falling, | ||
PinMode | pull = PullNone |
||
) |
Configures the INT2 pin of the ADXL362 to be used in interrupt mode.
- Parameters:
-
in - uC pin connected to ADXL362's INT2 data - data to be written to INTMAP2 callback_rising - rising edge interrupt callback - can be set to NULL if no callback is required for rising edge callback_falling - falling edge interrupt callback - can be set to NULL if no callback is required for falling edge pull - (optional) configures pullup on In pin
Definition at line 429 of file ADXL362.cpp.
void set_mode | ( | ADXL362_modes_t | mode ) |
Sets the STANDBY/MEASUREMENT mode of the ADXL362.
- Parameters:
-
mode - ADXL362_modes_t STANDBY/MEASUREMENT mode
Definition at line 270 of file ADXL362.cpp.
void set_polling_interrupt1_pin | ( | PinName | in, |
uint8_t | data, | ||
PinMode | pull = PullNone |
||
) |
Configures INT1 output of the ADXL362 for polling use.
- Parameters:
-
in - uC pin connected to ADXL362's INT1 data - data to be written to INTMAP1 pull - (optional) configures pullup on In pin
Definition at line 337 of file ADXL362.cpp.
void set_polling_interrupt2_pin | ( | PinName | in, |
uint8_t | data, | ||
PinMode | pull = PullNone |
||
) |
Configures INT2 output of the ADXL362 for polling use.
- Parameters:
-
in - uC pin connected to ADXL362's INT2 data - data to be written to INTMAP2 pull - (optional) configures pullup on In pin
Definition at line 358 of file ADXL362.cpp.
void set_power_ctl_reg | ( | uint8_t | data ) |
ADXL general register R/W methods.
Sets the POWER_CTL register.
- Parameters:
-
data - data to be written to the register
Definition at line 485 of file ADXL362.cpp.
void write_reg | ( | ADXL362_register_t | reg, |
uint8_t | data | ||
) |
Writes the reg register with data.
- Parameters:
-
reg - ADXL362_register_t register to be written data - data to be written
Definition at line 98 of file ADXL362.cpp.
void write_reg_u16 | ( | ADXL362_register_t | reg, |
uint16_t | data | ||
) |
Writes 16 bit registers to the ADXL362.
Performs conversion from Intel to Motorola byte order
- Parameters:
-
reg - ADXL362_register_t register to be written data - data to be written
Definition at line 130 of file ADXL362.cpp.
Field Documentation
Generated on Sun Jul 17 2022 01:37:39 by 1.7.2