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 
16 /*========================================
17  * Enums and structures
18  *=======================================*/
19 
20 struct adi_hal {
24  uint32_t log_level;
25  void *extra_spi;
26  uint8_t spi_adrv_csn;
27  void *extra_gpio;
29 };
30 
35 typedef enum {
36  ADIHAL_OK = 0,
44 } adiHalErr_t;
45 
50 typedef enum {
59 
60 typedef enum {
65 
66 /*========================================
67  * Prototypes
68  *=======================================*/
69 #ifdef __cplusplus
70 extern "C" {
71 #endif
72 
73 /* 3 Bytes per SPI transaction * 341 transactions = ~1024 byte buffer size */
74 /* Minimum HAL_SPIWRITEARRAY_BUFFERSIZE = 18 */
75 #define HAL_SPIWRITEARRAY_BUFFERSIZE 341
76 
77 /*============================================================================
78  * ADI Device Hardware Control Functions
79  *===========================================================================*/
80 
120 adiHalErr_t ADIHAL_openHw(void *devHalInfo, uint32_t halTimeout_ms);
121 
152 adiHalErr_t ADIHAL_closeHw(void *devHalInfo);
153 
154 
183 adiHalErr_t ADIHAL_setTimeout(void *devHalInfo, uint32_t halTimeout_ms);
184 
222 adiHalErr_t ADIHAL_resetHw(void *devHalInfo);
223 
246 
278 adiHalErr_t ADIHAL_spiWriteByte(void *devHalInfo, uint16_t addr, uint8_t data);
279 
324 adiHalErr_t ADIHAL_spiWriteBytes(void *devHalInfo, uint16_t *addr,
325  uint8_t *data, uint32_t count);
326 
359 adiHalErr_t ADIHAL_spiReadByte(void *devHalInfo, uint16_t addr,
360  uint8_t *readdata);
361 
397 adiHalErr_t ADIHAL_spiReadBytes(void *devHalInfo, uint16_t *addr,
398  uint8_t *readdata, uint32_t count);
399 
451 adiHalErr_t ADIHAL_spiWriteField(void *devHalInfo, uint16_t addr,
452  uint8_t fieldVal, uint8_t mask, uint8_t startBit);
453 
503 adiHalErr_t ADIHAL_spiReadField(void *devHalInfo, uint16_t addr,
504  uint8_t *fieldVal, uint8_t mask, uint8_t startBit);
505 
534 adiHalErr_t ADIHAL_wait_us(void *devHalInfo, uint32_t time_us);
535 
536 /*========================================
537  * Optional Logging Functions
538  *
539  *=======================================*/
575 adiHalErr_t ADIHAL_setLogLevel(void *devHalInfo, uint16_t halLogLevel);
576 
614 adiHalErr_t ADIHAL_writeToLog(void *devHalInfo, adiLogLevel_t logLevel,
615  uint32_t errorCode, const char *comment);
616 
617 
618 #ifdef __cplusplus
619 }
620 #endif
621 #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:182
adiLogLevel_t
adiLogLevel_t
An enumerated type in bit mask format to list the log message categories or groups.
Definition: adi_hal.h:50
adi_hal::log_level
uint32_t log_level
Definition: adi_hal.h:24
adi_hal::spi_adrv_desc
struct no_os_spi_desc * spi_adrv_desc
Definition: adi_hal.h:23
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:164
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:57
SYSREF_CONT_OFF
@ SYSREF_CONT_OFF
Definition: adi_hal.h:62
adi_hal::gpio_adrv_resetb
struct no_os_gpio_desc * gpio_adrv_resetb
Definition: adi_hal.h:21
ADIHAL_LOG_NONE
@ ADIHAL_LOG_NONE
Definition: adi_hal.h:51
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:197
ADIHAL_resetHw
adiHalErr_t ADIHAL_resetHw(void *devHalInfo)
Performs a hardware reset on the ADI Device.
Definition: no_os_hal.c:131
ADIHAL_WAIT_TIMEOUT
@ ADIHAL_WAIT_TIMEOUT
Definition: adi_hal.h:40
sysrefReqMode_t
sysrefReqMode_t
Definition: adi_hal.h:60
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:114
SYSREF_PULSE
@ SYSREF_PULSE
Definition: adi_hal.h:63
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:218
adi_hal::spi_adrv_csn
uint8_t spi_adrv_csn
Definition: adi_hal.h:26
adi_hal::extra_spi
void * extra_spi
Definition: adi_hal.h:25
ADIHAL_WARNING
@ ADIHAL_WARNING
Definition: adi_hal.h:42
ADIHAL_GEN_SW
@ ADIHAL_GEN_SW
Definition: adi_hal.h:41
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:145
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:233
ADIHAL_LOG_SPI
@ ADIHAL_LOG_SPI
Definition: adi_hal.h:55
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:288
no_os_spi_desc
Structure holding SPI descriptor.
Definition: no_os_spi.h:132
ADIHAL_LOG_WARN
@ ADIHAL_LOG_WARN
Definition: adi_hal.h:53
ADIHAL_LOG_MSG
@ ADIHAL_LOG_MSG
Definition: adi_hal.h:52
ADIHAL_OK
@ ADIHAL_OK
Definition: adi_hal.h:36
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:39
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:263
adi_hal
Definition: adi_hal.h:20
adi_hal::gpio_adrv_resetb_num
uint8_t gpio_adrv_resetb_num
Definition: adi_hal.h:28
ADIHAL_GPIO_FAIL
@ ADIHAL_GPIO_FAIL
Definition: adi_hal.h:38
adi_hal::gpio_adrv_sysref_req
struct no_os_gpio_desc * gpio_adrv_sysref_req
Definition: adi_hal.h:22
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:270
adi_hal::extra_gpio
void * extra_gpio
Definition: adi_hal.h:27
SYSREF_CONT_ON
@ SYSREF_CONT_ON
Definition: adi_hal.h:61
ADIHAL_ERR
@ ADIHAL_ERR
Definition: adi_hal.h:43
ADIHAL_LOG_ALL
@ ADIHAL_LOG_ALL
Definition: adi_hal.h:56
ADIHAL_SPI_FAIL
@ ADIHAL_SPI_FAIL
Definition: adi_hal.h:37
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:62
no_os_spi_desc::mode
enum no_os_spi_mode mode
Definition: no_os_spi.h:140
ADIHAL_LOG_ERR
@ ADIHAL_LOG_ERR
Definition: adi_hal.h:54
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:248
adiHalErr_t
adiHalErr_t
Enum of possible Errors Detected by HAL layer to be communicated to ADI APIs.
Definition: adi_hal.h:35