no-OS
Functions
adpd410x.c File Reference
#include <stdlib.h>
#include <stdint.h>
#include <string.h>
#include "no-os/error.h"
#include "no-os/util.h"
#include "adpd410x.h"
Include dependency graph for adpd410x.c:

Functions

int32_t adpd410x_reg_read (struct adpd410x_dev *dev, uint16_t address, uint16_t *data)
 Read device register. More...
 
int32_t adpd410x_reg_read_bytes (struct adpd410x_dev *dev, uint16_t address, uint8_t *data, uint16_t num_bytes)
 Read a specified number of bytes from device register. More...
 
int32_t adpd410x_reg_write (struct adpd410x_dev *dev, uint16_t address, uint16_t data)
 Write device register. More...
 
int32_t adpd410x_reg_write_mask (struct adpd410x_dev *dev, uint16_t address, uint16_t data, uint16_t mask)
 Do a read and write of a register to update only part of a register. More...
 
int32_t adpd410x_reset (struct adpd410x_dev *dev)
 Do a software reset. More...
 
int32_t adpd410x_set_opmode (struct adpd410x_dev *dev, enum adpd410x_opmode mode)
 Set operation mode. More...
 
int32_t adpd410x_get_opmode (struct adpd410x_dev *dev, enum adpd410x_opmode *mode)
 Get operation mode. More...
 
int32_t adpd410x_set_last_timeslot (struct adpd410x_dev *dev, enum adpd410x_timeslots timeslot_no)
 Set number of active time slots. More...
 
int32_t adpd410x_get_last_timeslot (struct adpd410x_dev *dev, enum adpd410x_timeslots *timeslot_no)
 Get number of active time slots. More...
 
int32_t adpd410x_set_sampling_freq (struct adpd410x_dev *dev, uint32_t sampling_freq)
 Set device sampling frequency. More...
 
int32_t adpd410x_get_sampling_freq (struct adpd410x_dev *dev, uint32_t *sampling_freq)
 Get device sampling frequency. More...
 
int32_t adpd410x_timeslot_setup (struct adpd410x_dev *dev, enum adpd410x_timeslots timeslot_no, struct adpd410x_timeslot_init *init)
 Setup an active time slot. More...
 
int32_t adpd410x_get_fifo_bytecount (struct adpd410x_dev *dev, uint16_t *bytes)
 Get number of bytes in the device FIFO. More...
 
int32_t adpd410x_read_fifo (struct adpd410x_dev *dev, uint32_t *data, uint16_t num_samples, uint8_t datawidth)
 Reads a certain number of bytes from the fifo and stores in data Used to read a large amount of data from the fifo efficiently (using as few register reads as possible.) More...
 
int32_t adpd410x_get_data (struct adpd410x_dev *dev, uint32_t *data)
 Get a full data packet from the device containing data from all active time slots. More...
 
int32_t adpd410x_setup (struct adpd410x_dev **device, struct adpd410x_init_param *init_param)
 Setup the device and the driver. More...
 
int32_t adpd410x_remove (struct adpd410x_dev *dev)
 Free memory allocated by adpd410x_setup(). More...
 

Detailed Description

Author
Andrei Drimbarean (andre.nosp@m.i.dr.nosp@m.imbar.nosp@m.ean@.nosp@m.analo.nosp@m.g.co.nosp@m.m)

Copyright 2020(c) Analog Devices, Inc.

All rights reserved.

Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:

THIS SOFTWARE IS PROVIDED BY ANALOG DEVICES "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, NON-INFRINGEMENT, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL ANALOG DEVICES BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, INTELLECTUAL PROPERTY RIGHTS, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

Function Documentation

◆ adpd410x_get_data()

int32_t adpd410x_get_data ( struct adpd410x_dev dev,
uint32_t *  data 
)

Get a full data packet from the device containing data from all active time slots.

Parameters
dev- Device handler.
data- Pointer to the data container.
Returns
SUCCESS in case of success, FAILURE otherwise.

◆ adpd410x_get_fifo_bytecount()

int32_t adpd410x_get_fifo_bytecount ( struct adpd410x_dev dev,
uint16_t *  bytes 
)

Get number of bytes in the device FIFO.

Parameters
dev- Device handler.
bytes- Pointer to the byte count container.
Returns
SUCCESS in case of success, FAILURE otherwise.

◆ adpd410x_get_last_timeslot()

int32_t adpd410x_get_last_timeslot ( struct adpd410x_dev dev,
enum adpd410x_timeslots timeslot_no 
)

Get number of active time slots.

Parameters
dev- Device handler.
timeslot_no- Last time slot enabled.
Returns
SUCCESS in case of success, FAILURE otherwise.

◆ adpd410x_get_opmode()

int32_t adpd410x_get_opmode ( struct adpd410x_dev dev,
enum adpd410x_opmode mode 
)

Get operation mode.

Parameters
dev- Device handler.
mode- Operation mode.
Returns
SUCCESS in case of success, FAILURE otherwise.

◆ adpd410x_get_sampling_freq()

int32_t adpd410x_get_sampling_freq ( struct adpd410x_dev dev,
uint32_t *  sampling_freq 
)

Get device sampling frequency.

Parameters
dev- Device handler.
sampling_freq- New sampling frequency.
Returns
SUCCESS in case of success, FAILURE otherwise.

◆ adpd410x_read_fifo()

int32_t adpd410x_read_fifo ( struct adpd410x_dev dev,
uint32_t *  data,
uint16_t  num_samples,
uint8_t  datawidth 
)

Reads a certain number of bytes from the fifo and stores in data Used to read a large amount of data from the fifo efficiently (using as few register reads as possible.)

Parameters
dev- Device handler.
data- Pointer to the data container.
num_samples- number of samples to read
datawidth- number of bytes per sample
Returns
SUCCESS in case of success, FAILURE or an error code otherwise.

◆ adpd410x_reg_read()

int32_t adpd410x_reg_read ( struct adpd410x_dev dev,
uint16_t  address,
uint16_t *  data 
)

Read device register.

Parameters
dev- Device handler.
address- Register address.
data- Pointer to the register value container.
Returns
SUCCESS in case of success, FAILURE otherwise.
Here is the caller graph for this function:

◆ adpd410x_reg_read_bytes()

int32_t adpd410x_reg_read_bytes ( struct adpd410x_dev dev,
uint16_t  address,
uint8_t *  data,
uint16_t  num_bytes 
)

Read a specified number of bytes from device register.

Parameters
dev- Device handler.
address- Register address.
data- Pointer to the register value container.
num_bytes- number of bytes to read. Max 255 for ADPD4101 (I2C).
Returns
SUCCESS in case of success, FAILURE otherwise.
Here is the caller graph for this function:

◆ adpd410x_reg_write()

int32_t adpd410x_reg_write ( struct adpd410x_dev dev,
uint16_t  address,
uint16_t  data 
)

Write device register.

Parameters
dev- Device handler.
address- Register address.
data- New register value.
Returns
SUCCESS in case of success, FAILURE otherwise.
Here is the caller graph for this function:

◆ adpd410x_reg_write_mask()

int32_t adpd410x_reg_write_mask ( struct adpd410x_dev dev,
uint16_t  address,
uint16_t  data,
uint16_t  mask 
)

Do a read and write of a register to update only part of a register.

Parameters
dev- Device handler.
address- Address of the register.
data- Value to be written to the device.
mask- Mask of the bit field to update.
Returns
SUCCESS in case of success, FAILURE otherwise.
Here is the caller graph for this function:

◆ adpd410x_remove()

int32_t adpd410x_remove ( struct adpd410x_dev dev)

Free memory allocated by adpd410x_setup().

Parameters
dev- Device handler.
Returns
SUCCESS in case of success, FAILURE otherwise.

◆ adpd410x_reset()

int32_t adpd410x_reset ( struct adpd410x_dev dev)

Do a software reset.

Parameters
dev- Device handler.
Returns
SUCCESS in case of success, FAILURE otherwise.
Here is the caller graph for this function:

◆ adpd410x_set_last_timeslot()

int32_t adpd410x_set_last_timeslot ( struct adpd410x_dev dev,
enum adpd410x_timeslots  timeslot_no 
)

Set number of active time slots.

Parameters
dev- Device handler.
timeslot_no- Last time slot to be enabled.
Returns
SUCCESS in case of success, FAILURE otherwise.

◆ adpd410x_set_opmode()

int32_t adpd410x_set_opmode ( struct adpd410x_dev dev,
enum adpd410x_opmode  mode 
)

Set operation mode.

Parameters
dev- Device handler.
mode- New operation mode.
Returns
SUCCESS in case of success, FAILURE otherwise.

◆ adpd410x_set_sampling_freq()

int32_t adpd410x_set_sampling_freq ( struct adpd410x_dev dev,
uint32_t  sampling_freq 
)

Set device sampling frequency.

Parameters
dev- Device handler.
sampling_freq- New sampling frequency.
Returns
SUCCESS in case of success, FAILURE otherwise.

◆ adpd410x_setup()

int32_t adpd410x_setup ( struct adpd410x_dev **  device,
struct adpd410x_init_param init_param 
)

Setup the device and the driver.

Parameters
device- Pointer to the device handler.
init_param- Pointer to the initialization structure.
Returns
SUCCESS in case of success, FAILURE otherwise.

Enable the 1MHz oscillator if the internal low frequency oscillator is used.

◆ adpd410x_timeslot_setup()

int32_t adpd410x_timeslot_setup ( struct adpd410x_dev dev,
enum adpd410x_timeslots  timeslot_no,
struct adpd410x_timeslot_init init 
)

Setup an active time slot.

Parameters
dev- Device handler.
timeslot_no- Time slot ID to setup.
init- Pointer to the time slot initialization structure.
Returns
SUCCESS in case of success, FAILURE otherwise.

Set TIA VREF and TRIM options. The 0xE000 is writing reserved bits as specified in the datasheet.