no-OS
Functions
adas1000.c File Reference

Implementation of ADAS1000 Driver. More...

#include <stdlib.h>
#include "no_os_error.h"
#include "adas1000.h"
#include "no_os_crc.h"
Include dependency graph for adas1000.c:

Functions

int32_t adas1000_compute_spi_freq (struct adas1000_init_param *init_param, uint32_t *spi_freq)
 Preliminary function which computes the spi frequency based on the frame rate value passed input parameter. More...
 
int32_t adas1000_init (struct adas1000_dev **device, const struct adas1000_init_param *init_param)
 Initializes the SPI communication with ADAS1000. The ADAS1000 is configured with the specified frame rate and all the words in a frame are activated. More...
 
int32_t adas1000_read (struct adas1000_dev *device, uint8_t reg_addr, uint32_t *reg_data)
 Read device register. More...
 
int32_t adas1000_write (struct adas1000_dev *device, uint8_t reg_addr, uint32_t reg_data)
 Write device register. More...
 
int32_t adas1000_soft_reset (struct adas1000_dev *device)
 Software reset of the device. More...
 
int32_t adas1000_compute_frame_size (struct adas1000_dev *device)
 Compute frame size. More...
 
int32_t adas1000_set_inactive_framewords (struct adas1000_dev *device, uint32_t words_mask)
 Selects which words are not included in a data frame. More...
 
int32_t adas1000_set_frame_rate (struct adas1000_dev *device, uint32_t rate)
 Sets the frame rate. More...
 
int32_t adas1000_read_data (struct adas1000_dev *device, uint8_t *data_buff, uint32_t frame_cnt, struct read_param *read_data_param)
 Reads the specified number of frames. More...
 
uint32_t adas1000_compute_frame_crc (struct adas1000_dev *device, uint8_t *buff)
 Computes the CRC for a frame. More...
 

Detailed Description

Implementation of ADAS1000 Driver.

Author
ACozma (andre.nosp@m.i.co.nosp@m.zma@a.nosp@m.nalo.nosp@m.g.com)
Antoniu Miclaus (anton.nosp@m.iu.m.nosp@m.iclau.nosp@m.s@an.nosp@m.alog..nosp@m.com)

Copyright 2012-2021(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

◆ adas1000_compute_frame_crc()

uint32_t adas1000_compute_frame_crc ( struct adas1000_dev device,
uint8_t *  buff 
)

Computes the CRC for a frame.

Parameters
device- Device structure.
buff- Buffer holding the frame data.
Returns
Returns the CRC value for the given frame.

Select the CRC poly and word size based on the frame rate.

◆ adas1000_compute_frame_size()

int32_t adas1000_compute_frame_size ( struct adas1000_dev device)

Compute frame size.

Parameters
device- The device structure.
Returns
0 in case of success, negative error code otherwise.

ADAS1000_2KHZ__FRAME_RATE

Here is the caller graph for this function:

◆ adas1000_compute_spi_freq()

int32_t adas1000_compute_spi_freq ( struct adas1000_init_param init_param,
uint32_t *  spi_freq 
)

Preliminary function which computes the spi frequency based on the frame rate value passed input parameter.

Parameters
init_param- ADAS1000 initialization parameters.
spi_freq- SPI frequency to be computed.
Returns
0 in case of success, negative error code otherwise.

Compute the SPI clock frequency.

ADAS1000_2KHZ__FRAME_RATE

◆ adas1000_init()

int32_t adas1000_init ( struct adas1000_dev **  device,
const struct adas1000_init_param init_param 
)

Initializes the SPI communication with ADAS1000. The ADAS1000 is configured with the specified frame rate and all the words in a frame are activated.

Parameters
device- the device structure.
init_param- the initialization parameters.
Returns
0 in case of success, negative error code otherwise.

store the selected frame rate

Initialize the SPI controller.

Reset the ADAS1000.

Activate all the channels

Set the frame rate

◆ adas1000_read()

int32_t adas1000_read ( struct adas1000_dev device,
uint8_t  reg_addr,
uint32_t *  reg_data 
)

Read device register.

Parameters
device- The device structure.
reg_addr- The register address.
reg_data- The data read from the register.
Returns
0 in case of success, negative error code otherwise.
Here is the caller graph for this function:

◆ adas1000_read_data()

int32_t adas1000_read_data ( struct adas1000_dev device,
uint8_t *  data_buff,
uint32_t  frame_cnt,
struct read_param read_data_param 
)

Reads the specified number of frames.

Parameters
device- Device structure.
data_buff- Buffer to store the read data.
frame_cnt- Number of frames to read.
read_data_param- Structure holding the parameters required for frame read sequence
Returns
0 in case of success, negative error code otherwise.

If the read sequence must be started send a FRAMES command.

Read the number of requested frames.

If waiting for the READY bit to be set read the header until the bit is set, otherwise just read the entire frame.

if the header is repeated until the READY bit is set read only the header, otherwise read the entire frame.

If the frames read sequence must be stopped read a register to stop the frames read.

◆ adas1000_set_frame_rate()

int32_t adas1000_set_frame_rate ( struct adas1000_dev device,
uint32_t  rate 
)

Sets the frame rate.

Parameters
device- The device structure.
rate- ADAS1000 frame rate.
Returns
0 in case of success, negative error code otherwise.

Store the selected frame rate

Read the current value of the Frame Control Register

Compute new frame size and update the Frame Control Register value

ADAS1000_2KHZ__FRAME_RATE

Write the new Frame control Register value

Here is the caller graph for this function:

◆ adas1000_set_inactive_framewords()

int32_t adas1000_set_inactive_framewords ( struct adas1000_dev device,
uint32_t  words_mask 
)

Selects which words are not included in a data frame.

Parameters
device- The device structure.
words_mask- Specifies the words to be excluded from the data frame using a bitwise or of the corresponding bits from the Frame Control Register.
Returns
0 in case of success, negative error code otherwise.

Read the current value of the Frame Control Register

set the inactive channles

Write the new value to the Frame Control register.

compute the number of inactive words

compute the new frame size

Here is the caller graph for this function:

◆ adas1000_soft_reset()

int32_t adas1000_soft_reset ( struct adas1000_dev device)

Software reset of the device.

Parameters
device- The device structure.
Returns
0 in case of success, negative error code otherwise.

Clear all registers to their reset value.

The software reset requires a NOP command to complete the reset.

Here is the caller graph for this function:

◆ adas1000_write()

int32_t adas1000_write ( struct adas1000_dev device,
uint8_t  reg_addr,
uint32_t  reg_data 
)

Write device register.

Parameters
device- The device structure.
reg_addr- The register address.
reg_data- The data to be written.
Returns
0 in case of success, negative error code otherwise.
Here is the caller graph for this function: