no-OS
|
Implementation of ADAS1000 Driver. More...
#include <stdlib.h>
#include "no_os_error.h"
#include "adas1000.h"
#include "no_os_crc.h"
#include "no_os_alloc.h"
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... | |
Implementation of ADAS1000 Driver.
Copyright 2012-2021(c) Analog Devices, Inc.
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, INC. “AS IS” AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL ANALOG DEVICES, INC. BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, 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.
uint32_t adas1000_compute_frame_crc | ( | struct adas1000_dev * | device, |
uint8_t * | buff | ||
) |
Computes the CRC for a frame.
device | - Device structure. |
buff | - Buffer holding the frame data. |
Select the CRC poly and word size based on the frame rate.
int32_t adas1000_compute_frame_size | ( | struct adas1000_dev * | device | ) |
Compute frame size.
device | - The device structure. |
ADAS1000_2KHZ__FRAME_RATE
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.
init_param | - ADAS1000 initialization parameters. |
spi_freq | - SPI frequency to be computed. |
Compute the SPI clock frequency.
ADAS1000_2KHZ__FRAME_RATE
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.
device | - the device structure. |
init_param | - the initialization parameters. |
store the selected frame rate
Initialize the SPI controller.
Reset the ADAS1000.
Activate all the channels
Set the frame rate
int32_t adas1000_read | ( | struct adas1000_dev * | device, |
uint8_t | reg_addr, | ||
uint32_t * | reg_data | ||
) |
Read device register.
device | - The device structure. |
reg_addr | - The register address. |
reg_data | - The data read from the register. |
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.
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 |
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.
int32_t adas1000_set_frame_rate | ( | struct adas1000_dev * | device, |
uint32_t | rate | ||
) |
Sets the frame rate.
device | - The device structure. |
rate | - ADAS1000 frame rate. |
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
int32_t adas1000_set_inactive_framewords | ( | struct adas1000_dev * | device, |
uint32_t | words_mask | ||
) |
Selects which words are not included in a data frame.
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. |
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
int32_t adas1000_soft_reset | ( | struct adas1000_dev * | device | ) |
Software reset of the device.
device | - The device structure. |
Clear all registers to their reset value.
The software reset requires a NOP command to complete the reset.
int32_t adas1000_write | ( | struct adas1000_dev * | device, |
uint8_t | reg_addr, | ||
uint32_t | reg_data | ||
) |
Write device register.
device | - The device structure. |
reg_addr | - The register address. |
reg_data | - The data to be written. |