no-OS
Loading...
Searching...
No Matches
adpd410x.c File Reference
#include <stdlib.h>
#include <stdint.h>
#include <string.h>
#include "no_os_error.h"
#include "no_os_util.h"
#include "no_os_alloc.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.
 
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.
 
int32_t adpd410x_reg_write (struct adpd410x_dev *dev, uint16_t address, uint16_t data)
 Write device register.
 
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.
 
int32_t adpd410x_reset (struct adpd410x_dev *dev)
 Do a software reset.
 
int32_t adpd410x_set_opmode (struct adpd410x_dev *dev, enum adpd410x_opmode mode)
 Set operation mode.
 
int32_t adpd410x_get_opmode (struct adpd410x_dev *dev, enum adpd410x_opmode *mode)
 Get operation mode.
 
int32_t adpd410x_set_last_timeslot (struct adpd410x_dev *dev, enum adpd410x_timeslots timeslot_no)
 Set number of active time slots.
 
int32_t adpd410x_get_last_timeslot (struct adpd410x_dev *dev, enum adpd410x_timeslots *timeslot_no)
 Get number of active time slots.
 
int32_t adpd410x_set_sampling_freq (struct adpd410x_dev *dev, uint32_t sampling_freq)
 Set device sampling frequency.
 
int32_t adpd410x_get_sampling_freq (struct adpd410x_dev *dev, uint32_t *sampling_freq)
 Get device sampling frequency.
 
int32_t adpd410x_timeslot_setup (struct adpd410x_dev *dev, enum adpd410x_timeslots timeslot_no, struct adpd410x_timeslot_init *init)
 Setup an active time slot.
 
int32_t adpd410x_get_fifo_bytecount (struct adpd410x_dev *dev, uint16_t *bytes)
 Get number of bytes in the device 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.)
 
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.
 
int32_t adpd410x_setup (struct adpd410x_dev **device, struct adpd410x_init_param *init_param)
 Setup the device and the driver.
 
int32_t adpd410x_remove (struct adpd410x_dev *dev)
 Free memory allocated by adpd410x_setup().
 

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.

SPDX-License-Identifier: BSD-3-Clause

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
0 in case of success, -1 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
0 in case of success, -1 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
0 in case of success, -1 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
0 in case of success, -1 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
0 in case of success, -1 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
0 in case of success, -1 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
0 in case of success, -1 otherwise.

◆ 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
0 in case of success, -1 otherwise.

◆ 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
0 in case of success, -1 otherwise.

◆ 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
0 in case of success, -1 otherwise.

◆ adpd410x_remove()

int32_t adpd410x_remove ( struct adpd410x_dev * dev)

Free memory allocated by adpd410x_setup().

Parameters
dev- Device handler.
Returns
0 in case of success, -1 otherwise.

◆ adpd410x_reset()

int32_t adpd410x_reset ( struct adpd410x_dev * dev)

Do a software reset.

Parameters
dev- Device handler.
Returns
0 in case of success, -1 otherwise.

◆ 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
0 in case of success, -1 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
0 in case of success, -1 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
0 in case of success, -1 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
0 in case of success, -1 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
0 in case of success, -1 otherwise.

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