This is an old revision of the document!
The ADXL367 is an ultralow power, 3-axis microelectromechanical systems (MEMS) accelerometer that consumes only 0.89 μA at a 100 Hz output data rate and 180 nA when in motion-triggered wake-up mode. Unlike accelerometers that use power duty cycling to achieve low power consumption, the ADXL367 does not alias input signals by undersampling, but samples the full bandwidth of the sensor at all data rates.
The ADXL367 always provides 14-bit output resolution. 8-bit formatted data is offered for more efficient single-byte transfers when a lower resolution is sufficient. 12-bit formatted data is also provided for ADXL362 design compatibility. Measurement ranges of ±2 g, ±4g, and ±8 g are available, with a resolution of 0.25 mg/LSB on the ±2 g range.
In addition to its ultralow power consumption, the ADXL367 has many features to enable true system level power reduction. It includes a deep multimode output first in, first out (FIFO), a built-in micropower temperature sensor, an internal analog-to-digital converter (ADC) for synchronous conversion of an additional analog input with interrupt capability, single-tap and double-tap detection that can operate at any output data rate with only an added 35nA of current, and a state machine to prevent a false triggering. In addition, the ADXL367 has provisions for external control of the sampling time and/or an external clock.
The ADXL367 operates on a wide 1.1 V to 3.6 V supply range, and can interface, if necessary, to a host operating on a separate supply voltage. It is available in a 2.2 mm × 2.3 mm × 0.87mm package.
The goal of ADI Microcontroller No-OS is to be able to provide reference projects for lower end processors, which can't run Linux, or aren't running a specific operating system, to help those customers using microcontrollers with ADI parts. ADI No-OS offers generic drivers which can be used as a base for any microcontroller platform and also example projects which are using these drivers on various microcontroller platforms.
For more information about ADI No-OS and supported microcontroller platforms see: ADI No-OS
The source code for ADXL367 driver can be found here:
The driver also uses the ADI util, delay and print_log libraries, so make sure you also add the necessary files in your project. The source code for the libraries can be found here:
In order to be able to use this driver you will have to provide the specific implementation for the communication APIs and the specific types they use. If the SPI communication is chosen, there are three functions which are called by the ADXL367 driver and have to be implemented:
And there are two data types that have to be defined:
If the I2C communication is chosen, there are four functions which are called by the ADXL367 driver:
And there are two data types that have to be defined:
An example of a header file containing the prototypes of the functions which have to be implemented, along with some generic data types they are using can be found below:
Source code documentation for the driver is automatically generated using the Doxygen tool and it is available below:
In order to be able to use the device, you will have to provide the support for the communication protocol (SPI or I2C) as mentioned above. The first API to be called is adxl367_init. Make sure that it returns 0, which means that the driver was initialized correctly.
By default, the device uses +/- 2g range configuration. You may modify this value to +/- 4g or +/- 8g by using adxl367_set_range API.
You may set an offset for each axis for calibration purposes by using adxl367_set_offset. The offset is disabled by default. The data provided in adxl367_set_offset will be in two's complement format. The offset is added after all other signal processing is taking place.
There are 513 locations in the FIFO. Each location contains an acceleration data point on an axis. In case you want to use the FIFO, you are able to modify the number of FIFO samples to be stored in the FIFO. The default and maximum value is 513, but can be modified using adxl367_set_fifo_sample_sets_nb API. A full set-up for FIFO can be done using adxl367_fifo_setup API.
In case you want to use the activity detection algorithm, you can enable this feature on any axis using adxl367_setup_activity_detection API. By default the activity detection feature is disabled. You will have to specify a threshold for the activity detection and a number of consecutive measurements above the threshold which would trigger the detection of an activity.
In case you want to use the inactivity detection algorithm, you can enable this feature on any axis using adxl367_setup_inactivity_detection API. By default the activity detection feature is disabled. You will have to specify a threshold for the inactivity detection and a number of consecutive measurements below the threshold which would trigger the detection of an inactivity.
The device allows the usage of interrupts which can be mapped to INT1 or INT2 pins. In case you want to use interrupts, make sure you configure the interrupt map by using adxl367_int_map API.
The following events can be mapped to the interrupt pins:
After the specific configuration was performed as mentioned above, you can set the device in the desired measurement mode, using adxl367_set_power_mode API. The available operation modes for measurement are as follows:
By using adxl367_temp_read_en, temperature data can be enabled. Data can be obtained by calling adxl367_read_temperature API. The temperature is Celsius degrees, with scaling already applied.
If you want to obtain the raw temperature data without any scaling applies, simply call adxl367_read_raw_temp API.
If you want to obtain a single data set, you may use adxl367_get_g_xyz API to obtain the data converted to g, or adxl367_get_raw_xyz API to obtain the raw data. The raw data is in two's complement format and it does not have the scaling applied.
If you want to read from the FIFO, you may use adxl367_read_converted_fifo API to obtain the data converted to g and Celsius degrees for temperature, or adxl367_read_raw_fifo api to obtain the raw data. The raw data is in two's complement format and it does not have the scaling applied. The parameter entries shows the number of valid measurements in the FIFO which were read.
// Particular SPI configuration struct no_os_spi_init_param spi_ip = { .device_id = SPI_DEVICE_ID, .max_speed_hz = 100000, .mode = NO_OS_SPI_MODE_0, .chip_select = 0U, .bit_order = NO_OS_SPI_BIT_ORDER_MSB_FIRST, .platform_ops = SPI_OPS, .extra = &spi_extra }; struct adxl367_init_param init_param = { .spi_init = spi_ip, .comm_type = ADXL367_SPI_COMM }; // Device descriptor struct adxl367_dev *dev; adxl367_init(&dev, init_param); adxl367_self_test(dev); adxl367_temp_read_en(dev, 1); adxl367_set_output_rate(dev, ADXL367_ODR_200HZ); adxl367_fifo_setup(dev, ADXL367_OLDEST_SAVED, ADXL367_FIFO_FORMAT_XYZT, 50); //be sure to make all configs before switching to measure mode adxl367_set_power_mode(dev, ADXL367_OP_MEASURE); uint16_t entries; struct adxl367_fractional_val x[128], y[128], z[128], temp[128]; adxl367_read_converted_fifo(dev, x, y, z, temp, &entries); pr_info("Number of read entries from the FIFO %d \n", entries); for (uint8_t i = 0; i < entries / 4; i ++) { pr_info("x=%d"".%09u m/s^2\n", (int)x[i].integer, (abs)(x[i].fractional)); pr_info("y=%d"".%09u m/s^2\n", (int)y[i].integer, (abs)(y[i].fractional)); pr_info("z=%d"".%09u m/s^2\n", (int)z[i].integer, (abs)(z[i].fractional)); pr_info("temp=%d"".%09u C\n", (int)temp[i].integer, (abs)(temp[i].fractional)); pr_info("\n"); }
The ADXL367 IIO driver comes on top of ADXL367 driver and offers support for interfacing IIO clients through IIO lib.
ADXL367 IIO device does not have any device specific attributes.
ADXL367 IIO device has 0 input channels and 4 output channels: 3 acceleration channels and 1 temperature channel.
The acceleration channels are:
Each acceleration channel has 6 attributes. 4 of these attributes are shared in value with the other acceleration channels and 2 of these attributes can have different values for each channel.
The attributes are:
converted_accel [m/s^2] = (raw + calibbias) * scale
The temperature channel is:
The channel has 3 attributes, as follows:
converted_temp [degrees Celsius] = (raw + offset) * scale
The ADXL367 IIO devices driver supports the usage of a data buffer for reading purposes.
#define DATA_BUFFER_SIZE 400 uint8_t iio_data_buffer[DATA_BUFFER_SIZE*4*sizeof(int16_t)]; struct adxl367_iio_dev *adxl367_iio_desc; struct adxl367_iio_init_param adxl367_init_par; // Particular SPI configuration struct no_os_spi_init_param spi_ip = { .device_id = SPI_DEVICE_ID, .max_speed_hz = 100000, .mode = NO_OS_SPI_MODE_0, .chip_select = 0U, .bit_order = NO_OS_SPI_BIT_ORDER_MSB_FIRST, .platform_ops = SPI_OPS, .extra = &spi_extra }; struct adxl367_init_param init_param = { .spi_init = spi_ip, .comm_type = ADXL367_SPI_COMM }; struct iio_data_buffer accel_buff = { .buff = (void *)iio_data_buffer, .size = DATA_BUFFER_SIZE*4*sizeof(int16_t) }; adxl367_iio_ip.adxl367_initial_param = &init_param; adxl367_iio_init(&adxl367_iio_desc, &adxl367_iio_ip); struct iio_app_device iio_devices[] = { { .name = "adxl367", .dev = adxl367_iio_desc, .dev_descriptor = adxl367_iio_desc->iio_dev, .read_buff = &accel_buff, } }; return iio_app_run(iio_devices, NO_OS_ARRAY_SIZE(iio_devices));