no-OS
adi_hal.h
Go to the documentation of this file.
1 
9 #ifndef _ADI_HAL_H_
10 #define _ADI_HAL_H_
11 
12 /* include standard types and definitions */
13 #include <stdint.h>
14 #include <stddef.h>
15 #include "no_os_util.h"
16 
17 #define u16 uint16_t
18 #define DIV_U64(x, y) no_os_div_u64(x, y)
19 #define DIV_S64(x, y) no_os_div_s64(x, y)
20 #define DIV_ROUND_CLOSEST NO_OS_DIV_ROUND_CLOSEST
21 #define DIV_ROUND_CLOSEST_ULL NO_OS_DIV_ROUND_CLOSEST_ULL
22 
23 /*========================================
24  * Enums and structures
25  *=======================================*/
26 
27 struct adi_hal {
31  uint32_t log_level;
32  void *extra_spi;
33  uint8_t spi_adrv_csn;
34  void *extra_gpio;
36 };
37 
42 typedef enum {
43  ADIHAL_OK = 0,
51 } adiHalErr_t;
52 
57 typedef enum {
66 
67 typedef enum {
72 
73 /*========================================
74  * Prototypes
75  *=======================================*/
76 #ifdef __cplusplus
77 extern "C" {
78 #endif
79 
80 /* 3 Bytes per SPI transaction * 341 transactions = ~1024 byte buffer size */
81 /* Minimum HAL_SPIWRITEARRAY_BUFFERSIZE = 18 */
82 #define HAL_SPIWRITEARRAY_BUFFERSIZE 341
83 
84 /*============================================================================
85  * ADI Device Hardware Control Functions
86  *===========================================================================*/
87 
127 adiHalErr_t ADIHAL_openHw(void *devHalInfo, uint32_t halTimeout_ms);
128 
159 adiHalErr_t ADIHAL_closeHw(void *devHalInfo);
160 
161 
190 adiHalErr_t ADIHAL_setTimeout(void *devHalInfo, uint32_t halTimeout_ms);
191 
229 adiHalErr_t ADIHAL_resetHw(void *devHalInfo);
230 
253 
285 adiHalErr_t ADIHAL_spiWriteByte(void *devHalInfo, uint16_t addr, uint8_t data);
286 
331 adiHalErr_t ADIHAL_spiWriteBytes(void *devHalInfo, uint16_t *addr,
332  uint8_t *data, uint32_t count);
333 
366 adiHalErr_t ADIHAL_spiReadByte(void *devHalInfo, uint16_t addr,
367  uint8_t *readdata);
368 
404 adiHalErr_t ADIHAL_spiReadBytes(void *devHalInfo, uint16_t *addr,
405  uint8_t *readdata, uint32_t count);
406 
458 adiHalErr_t ADIHAL_spiWriteField(void *devHalInfo, uint16_t addr,
459  uint8_t fieldVal, uint8_t mask, uint8_t startBit);
460 
510 adiHalErr_t ADIHAL_spiReadField(void *devHalInfo, uint16_t addr,
511  uint8_t *fieldVal, uint8_t mask, uint8_t startBit);
512 
541 adiHalErr_t ADIHAL_wait_us(void *devHalInfo, uint32_t time_us);
542 
543 /*========================================
544  * Optional Logging Functions
545  *
546  *=======================================*/
582 adiHalErr_t ADIHAL_setLogLevel(void *devHalInfo, uint16_t halLogLevel);
583 
621 adiHalErr_t ADIHAL_writeToLog(void *devHalInfo, adiLogLevel_t logLevel,
622  uint32_t errorCode, const char *comment);
623 
624 
625 #ifdef __cplusplus
626 }
627 #endif
628 #endif
ADIHAL_spiWriteBytes
adiHalErr_t ADIHAL_spiWriteBytes(void *devHalInfo, uint16_t *addr, uint8_t *data, uint32_t count)
Writes an array of SPI writes to an ADI Device.
Definition: no_os_hal.c:187
adiLogLevel_t
adiLogLevel_t
An enumerated type in bit mask format to list the log message categories or groups.
Definition: adi_hal.h:57
adi_hal::log_level
uint32_t log_level
Definition: adi_hal.h:31
adi_hal::spi_adrv_desc
struct no_os_spi_desc * spi_adrv_desc
Definition: adi_hal.h:30
ADIHAL_spiWriteByte
adiHalErr_t ADIHAL_spiWriteByte(void *devHalInfo, uint16_t addr, uint8_t data)
Performs a Single SPI write to an ADI Device.
Definition: no_os_hal.c:169
ADIHAL_setTimeout
adiHalErr_t ADIHAL_setTimeout(void *devHalInfo, uint32_t halTimeout_ms)
Sets the a timeout duration for the HAL functions.
Definition: no_os_hal.c:62
SYSREF_CONT_OFF
@ SYSREF_CONT_OFF
Definition: adi_hal.h:69
adi_hal::gpio_adrv_resetb
struct no_os_gpio_desc * gpio_adrv_resetb
Definition: adi_hal.h:28
ADIHAL_LOG_NONE
@ ADIHAL_LOG_NONE
Definition: adi_hal.h:58
ADIHAL_spiReadByte
adiHalErr_t ADIHAL_spiReadByte(void *devHalInfo, uint16_t addr, uint8_t *readdata)
Performs a Single SPI Read from an ADI Device.
Definition: no_os_hal.c:202
ADIHAL_resetHw
adiHalErr_t ADIHAL_resetHw(void *devHalInfo)
Performs a hardware reset on the ADI Device.
Definition: no_os_hal.c:136
ADIHAL_WAIT_TIMEOUT
@ ADIHAL_WAIT_TIMEOUT
Definition: adi_hal.h:47
sysrefReqMode_t
sysrefReqMode_t
Definition: adi_hal.h:67
ADIHAL_closeHw
adiHalErr_t ADIHAL_closeHw(void *devHalInfo)
Closes any platform hardware drivers, handles, etc that were necessary for the ADI Device.
Definition: no_os_hal.c:119
SYSREF_PULSE
@ SYSREF_PULSE
Definition: adi_hal.h:70
ADIHAL_spiReadBytes
adiHalErr_t ADIHAL_spiReadBytes(void *devHalInfo, uint16_t *addr, uint8_t *readdata, uint32_t count)
Performs a Multi SPI Read from an ADI Device.
Definition: no_os_hal.c:223
adi_hal::spi_adrv_csn
uint8_t spi_adrv_csn
Definition: adi_hal.h:33
adi_hal::extra_spi
void * extra_spi
Definition: adi_hal.h:32
ADIHAL_WARNING
@ ADIHAL_WARNING
Definition: adi_hal.h:49
ADIHAL_GEN_SW
@ ADIHAL_GEN_SW
Definition: adi_hal.h:48
ADIHAL_sysrefReq
adiHalErr_t ADIHAL_sysrefReq(void *devHalInfo, sysrefReqMode_t mode)
Performs a SYSREF request to the clock generation device.
Definition: no_os_hal.c:150
ADIHAL_spiWriteField
adiHalErr_t ADIHAL_spiWriteField(void *devHalInfo, uint16_t addr, uint8_t fieldVal, uint8_t mask, uint8_t startBit)
Performs a write to the specified field in a SPI register.
Definition: no_os_hal.c:238
ADIHAL_LOG_SPI
@ ADIHAL_LOG_SPI
Definition: adi_hal.h:62
ADIHAL_setLogLevel
adiHalErr_t ADIHAL_setLogLevel(void *devHalInfo, uint16_t halLogLevel)
Writes a character array to a log file to facilitate debugging.
Definition: no_os_hal.c:293
no_os_spi_desc
Structure holding SPI descriptor.
Definition: no_os_spi.h:143
ADIHAL_LOG_WARN
@ ADIHAL_LOG_WARN
Definition: adi_hal.h:60
ADIHAL_LOG_MSG
@ ADIHAL_LOG_MSG
Definition: adi_hal.h:59
ADIHAL_OK
@ ADIHAL_OK
Definition: adi_hal.h:43
no_os_gpio_desc
Structure holding the GPIO descriptor.
Definition: no_os_gpio.h:102
ADIHAL_TIMER_FAIL
@ ADIHAL_TIMER_FAIL
Definition: adi_hal.h:46
ADIHAL_wait_us
adiHalErr_t ADIHAL_wait_us(void *devHalInfo, uint32_t time_us)
Delay or sleep for the specified number of microseconds.
Definition: no_os_hal.c:268
adi_hal
Definition: adi_hal.h:27
adi_hal::gpio_adrv_resetb_num
uint8_t gpio_adrv_resetb_num
Definition: adi_hal.h:35
ADIHAL_GPIO_FAIL
@ ADIHAL_GPIO_FAIL
Definition: adi_hal.h:45
adi_hal::gpio_adrv_sysref_req
struct no_os_gpio_desc * gpio_adrv_sysref_req
Definition: adi_hal.h:29
ADIHAL_writeToLog
adiHalErr_t ADIHAL_writeToLog(void *devHalInfo, adiLogLevel_t logLevel, uint32_t errorCode, const char *comment)
Writes a character array to a log file to facilitate debugging.
Definition: no_os_hal.c:275
adi_hal::extra_gpio
void * extra_gpio
Definition: adi_hal.h:34
SYSREF_CONT_ON
@ SYSREF_CONT_ON
Definition: adi_hal.h:68
ADIHAL_ERR
@ ADIHAL_ERR
Definition: adi_hal.h:50
ADIHAL_LOG_ALL
@ ADIHAL_LOG_ALL
Definition: adi_hal.h:63
ADIHAL_SPI_FAIL
@ ADIHAL_SPI_FAIL
Definition: adi_hal.h:44
no_os_util.h
Header file of utility functions.
ADIHAL_openHw
adiHalErr_t ADIHAL_openHw(void *devHalInfo, uint32_t halTimeout_ms)
Performs a platform hardware initialization for the ADI Device.
Definition: no_os_hal.c:67
no_os_spi_desc::mode
enum no_os_spi_mode mode
Definition: no_os_spi.h:151
ADIHAL_LOG_ERR
@ ADIHAL_LOG_ERR
Definition: adi_hal.h:61
ADIHAL_spiReadField
adiHalErr_t ADIHAL_spiReadField(void *devHalInfo, uint16_t addr, uint8_t *fieldVal, uint8_t mask, uint8_t startBit)
Performs a read from a particular bit field in a SPI register.
Definition: no_os_hal.c:253
adiHalErr_t
adiHalErr_t
Enum of possible Errors Detected by HAL layer to be communicated to ADI APIs.
Definition: adi_hal.h:42