no-OS
max14916.h
Go to the documentation of this file.
1 /***************************************************************************/
39 #ifndef _MAX14916_H
40 #define _MAX14916_H
41 
42 #include <stdint.h>
43 #include <stdbool.h>
44 #include "max149x6-base.h"
45 #include "no_os_gpio.h"
46 #include "no_os_spi.h"
47 #include "no_os_util.h"
48 
49 #define MAX14916_CHANNELS 8
50 
51 #define MAX14916_SETOUT_REG 0x0
52 #define MAX14916_SET_FLED_REG 0x1
53 #define MAX14916_SET_SLED_REG 0x2
54 #define MAX14916_INT_REG 0x3
55 #define MAX14916_OVR_LD_REG 0x4
56 #define MAX14916_CURR_LIM_REG 0x5
57 #define MAX14916_OW_OFF_FAULT_REG 0x6
58 #define MAX14916_OW_ON_FAULT_REG 0x7
59 #define MAX14916_SHD_VDD_FAULT_REG 0x8
60 #define MAX14916_GLOB_ERR_REG 0x9
61 #define MAX14916_OW_OFF_EN_REG 0xA
62 #define MAX14916_OW_ON_EN_REG 0xB
63 #define MAX14916_SHD_VDD_EN_REG 0xC
64 #define MAX14916_CONFIG1_REG 0xD
65 #define MAX14916_CONFIG2_REG 0xE
66 #define MAX14916_MASK_REG 0xF
67 
68 #define MAX14916_SETOUT_MASK(x) NO_OS_BIT(x)
69 #define MAX14916_SLED_CH_MASK(x) NO_OS_BIT(x)
70 #define MAX14916_SLED_MASK NO_OS_BIT(1)
71 #define MAX14916_FLED_MASK NO_OS_BIT(0)
72 #define MAX14916_FLED_STRETCH_MASK NO_OS_GENMASK(2, 1)
73 #define MAX14916_WD_MASK NO_OS_GENMASK(7, 6)
74 #define MAX14916_OW_OFF_CS_MASK NO_OS_GENMASK(5, 4)
75 #define MAX14916_SHT_VDD_THR_MASK NO_OS_GENMASK(3, 2)
76 
82 };
83 
87 };
88 
94 };
95 
101 };
102 
108 };
109 
111 int max14916_ch_get(struct max149x6_desc *, uint32_t, uint32_t *);
112 
114 int max14916_ch_set(struct max149x6_desc *, uint32_t, uint32_t);
115 
117 int max14916_sled_set(struct max149x6_desc *, uint32_t,
118  enum max14916_sled_state);
119 
122 
124 int max14916_set_wd(struct max149x6_desc *, enum max14916_wd);
125 
128 
131 
133 int max14916_init(struct max149x6_desc **, struct max149x6_init_param *);
134 
136 int max14916_remove(struct max149x6_desc *);
137 
138 #endif
MAX14916_FLED_MASK
#define MAX14916_FLED_MASK
Definition: max14916.h:71
max149x6_desc::ready_gpio
struct no_os_gpio_desc * ready_gpio
Definition: max149x6-base.h:78
MAX14916_FLED_TIME_2S
@ MAX14916_FLED_TIME_2S
Definition: max14916.h:80
no_os_alloc.h
max149x6_reg_read
int max149x6_reg_read(struct max149x6_desc *desc, uint32_t addr, uint32_t *val)
Read the value of a device register.
Definition: max149x6-base.c:132
MAX14916_SHD_VDD_FAULT_REG
#define MAX14916_SHD_VDD_FAULT_REG
Definition: max14916.h:59
MAX14916_OW_OFF_FAULT_REG
#define MAX14916_OW_OFF_FAULT_REG
Definition: max14916.h:57
MAX14916_SET_SLED_REG
#define MAX14916_SET_SLED_REG
Definition: max14916.h:53
MAX14916_OVR_LD_REG
#define MAX14916_OVR_LD_REG
Definition: max14916.h:55
max14916_set_ow_off
int max14916_set_ow_off(struct max149x6_desc *desc, enum max14916_ow_off_cs ow_off_cs)
Set current magnitude for the ow off in the config2 register.
Definition: max14916.c:173
MAX14916_SETOUT_MASK
#define MAX14916_SETOUT_MASK(x)
Definition: max14916.h:68
MAX14916_SHT_VDD_THR_10V
@ MAX14916_SHT_VDD_THR_10V
Definition: max14916.h:105
max149x6-base.h
Header file of MAX149X6 Base Driver.
max149x6_desc
Device descriptor for MAX149X6.
Definition: max149x6-base.h:73
max14916_fled_time_set
int max14916_fled_time_set(struct max149x6_desc *, enum max14916_fled_time)
Set FLEDs minimum on-time to requested value.
Definition: max14916.c:124
no_os_spi.h
Header file of SPI Interface.
MAX14916_SHT_VDD_THR_MASK
#define MAX14916_SHT_VDD_THR_MASK
Definition: max14916.h:75
MAX14916_WD_1200MS
@ MAX14916_WD_1200MS
Definition: max14916.h:93
max14916_init
int max14916_init(struct max149x6_desc **desc, struct max149x6_init_param *param)
Initialize and configure the MAX14916 device.
Definition: max14916.c:209
MAX14916_CONFIG1_REG
#define MAX14916_CONFIG1_REG
Definition: max14916.h:64
max149x6_init_param::fault_gpio_param
struct no_os_gpio_init_param * fault_gpio_param
Definition: max149x6-base.h:64
max149x6_init_param::crc_en
bool crc_en
Definition: max149x6-base.h:67
max14916_wd
max14916_wd
Definition: max14916.h:89
max149x6_reg_update
int max149x6_reg_update(struct max149x6_desc *desc, uint32_t addr, uint32_t mask, uint32_t val)
Update the value of a device register (read/write sequence).
Definition: max149x6-base.c:178
max14916_ch_set
int max14916_ch_set(struct max149x6_desc *desc, uint32_t ch, uint32_t val)
Write the (logic) state of a channel (on/off).
Definition: max14916.c:76
NO_OS_GPIO_HIGH
@ NO_OS_GPIO_HIGH
Definition: no_os_gpio.h:123
max149x6_desc::crc_en
bool crc_en
Definition: max149x6-base.h:81
max14916_set_wd
int max14916_set_wd(struct max149x6_desc *, enum max14916_wd)
Set watchdog timeout in the config2 register.
Definition: max14916.c:158
no_os_calloc
void * no_os_calloc(size_t nitems, size_t size)
Allocate memory and return a pointer to it, set memory to 0.
Definition: chibios_alloc.c:60
MAX14916_SHT_VDD_THR_9V
@ MAX14916_SHT_VDD_THR_9V
Definition: max14916.h:104
no_os_gpio_direction_input
int32_t no_os_gpio_direction_input(struct no_os_gpio_desc *desc)
Enable the input direction of the specified GPIO.
Definition: no_os_gpio.c:130
max149x6_desc::synch_gpio
struct no_os_gpio_desc * synch_gpio
Definition: max149x6-base.h:79
max14916_sled_state
max14916_sled_state
Definition: max14916.h:84
max14916_ow_off_cs
max14916_ow_off_cs
Definition: max14916.h:96
MAX14916_GLOB_ERR_REG
#define MAX14916_GLOB_ERR_REG
Definition: max14916.h:60
MAX14916_SLED_MASK
#define MAX14916_SLED_MASK
Definition: max14916.h:70
MAX14916_SHT_VDD_THR_14V
@ MAX14916_SHT_VDD_THR_14V
Definition: max14916.h:107
max149x6_init_param::comm_param
struct no_os_spi_init_param * comm_param
Definition: max149x6-base.h:62
max149x6_desc::en_gpio
struct no_os_gpio_desc * en_gpio
Definition: max149x6-base.h:76
MAX14916_WD_200MS
@ MAX14916_WD_200MS
Definition: max14916.h:91
no_os_field_prep
uint32_t no_os_field_prep(uint32_t mask, uint32_t val)
MAX14916_WD_DISABLED
@ MAX14916_WD_DISABLED
Definition: max14916.h:90
max14916_set_sht_vdd_thr
int max14916_set_sht_vdd_thr(struct max149x6_desc *, enum max14916_sht_vdd_thr)
Set short to vdd threshold in the config2 register.
Definition: max14916.c:191
MAX14916_OW_OFF_CS_MASK
#define MAX14916_OW_OFF_CS_MASK
Definition: max14916.h:74
max14916_ch_get
int max14916_ch_get(struct max149x6_desc *, uint32_t, uint32_t *)
Read the high-side state of a channel's switch.
Definition: max14916.c:53
max14916_remove
int max14916_remove(struct max149x6_desc *)
Free the resources allocated during init.
Definition: max14916.c:321
max14916_init
int max14916_init(struct max149x6_desc **, struct max149x6_init_param *)
Initialize and configure the MAX14916 device.
Definition: max14916.c:209
MAX14916_FLED_STRETCH_MASK
#define MAX14916_FLED_STRETCH_MASK
Definition: max14916.h:72
MAX14916_SLED_CH_MASK
#define MAX14916_SLED_CH_MASK(x)
Definition: max14916.h:69
max14916_fled_time_set
int max14916_fled_time_set(struct max149x6_desc *desc, enum max14916_fled_time fled_time)
Set FLEDs minimum on-time to requested value.
Definition: max14916.c:124
max149x6_init_param::synch_gpio_param
struct no_os_gpio_init_param * synch_gpio_param
Definition: max149x6-base.h:66
no_os_gpio_remove
int32_t no_os_gpio_remove(struct no_os_gpio_desc *desc)
Free the resources allocated by no_os_gpio_get().
Definition: no_os_gpio.c:110
max14916_sled_set
int max14916_sled_set(struct max149x6_desc *desc, uint32_t ch, enum max14916_sled_state state)
Read an output channel's current limit.
Definition: max14916.c:96
max149x6_init_param::ready_gpio_param
struct no_os_gpio_init_param * ready_gpio_param
Definition: max149x6-base.h:65
MAX14916_OW_OFF_CS_100UA
@ MAX14916_OW_OFF_CS_100UA
Definition: max14916.h:98
MAX14916_FLED_TIME_3S
@ MAX14916_FLED_TIME_3S
Definition: max14916.h:81
max149x6_init_param::en_gpio_param
struct no_os_gpio_init_param * en_gpio_param
Definition: max149x6-base.h:63
MAX14916_CHANNELS
#define MAX14916_CHANNELS
Definition: max14916.h:49
max14916_sled_set
int max14916_sled_set(struct max149x6_desc *, uint32_t, enum max14916_sled_state)
Read an output channel's current limit.
Definition: max14916.c:96
max14916_sht_vdd_thr
max14916_sht_vdd_thr
Definition: max14916.h:103
no_os_field_get
uint32_t no_os_field_get(uint32_t mask, uint32_t word)
max14916_set_ow_off
int max14916_set_ow_off(struct max149x6_desc *, enum max14916_ow_off_cs)
Set current magnitude for the ow off in the config2 register.
Definition: max14916.c:173
MAX14916_SETOUT_REG
#define MAX14916_SETOUT_REG
Definition: max14916.h:51
MAX14916_SLED_OFF
@ MAX14916_SLED_OFF
Definition: max14916.h:85
max14916_ch_get
int max14916_ch_get(struct max149x6_desc *desc, uint32_t ch, uint32_t *val)
Read the high-side state of a channel's switch.
Definition: max14916.c:53
no_os_free
void no_os_free(void *ptr)
Deallocate memory previously allocated by a call to no_os_calloc or no_os_malloc.
Definition: chibios_alloc.c:75
MAX14916_OW_OFF_CS_600UA
@ MAX14916_OW_OFF_CS_600UA
Definition: max14916.h:100
max149x6_desc::fault_gpio
struct no_os_gpio_desc * fault_gpio
Definition: max149x6-base.h:77
MAX14916_CONFIG2_REG
#define MAX14916_CONFIG2_REG
Definition: max14916.h:65
max14916_set_wd
int max14916_set_wd(struct max149x6_desc *desc, enum max14916_wd wd)
Set watchdog timeout in the config2 register.
Definition: max14916.c:158
MAX14916_WD_600MS
@ MAX14916_WD_600MS
Definition: max14916.h:92
max149x6_desc::comm_desc
struct no_os_spi_desc * comm_desc
Definition: max149x6-base.h:75
no_os_gpio_set_value
int32_t no_os_gpio_set_value(struct no_os_gpio_desc *desc, uint8_t value)
Set the value of the specified GPIO.
Definition: no_os_gpio.c:203
max14916_fled_time
max14916_fled_time
Definition: max14916.h:77
MAX14916_OW_OFF_CS_20UA
@ MAX14916_OW_OFF_CS_20UA
Definition: max14916.h:97
MAX14916_SLED_ON
@ MAX14916_SLED_ON
Definition: max14916.h:86
MAX14916_SHT_VDD_THR_12V
@ MAX14916_SHT_VDD_THR_12V
Definition: max14916.h:106
no_os_spi_remove
int32_t no_os_spi_remove(struct no_os_spi_desc *desc)
Free the resources allocated by no_os_spi_init().
Definition: no_os_spi.c:122
no_os_gpio.h
Header file of GPIO Interface.
MAX14916_OW_OFF_CS_300UA
@ MAX14916_OW_OFF_CS_300UA
Definition: max14916.h:99
MAX14916_FLED_TIME_1S
@ MAX14916_FLED_TIME_1S
Definition: max14916.h:79
no_os_spi_init
int32_t no_os_spi_init(struct no_os_spi_desc **desc, const struct no_os_spi_init_param *param)
Initialize the SPI communication peripheral.
Definition: no_os_spi.c:58
max14916_remove
int max14916_remove(struct max149x6_desc *desc)
Free the resources allocated during init.
Definition: max14916.c:321
MAX14916_WD_MASK
#define MAX14916_WD_MASK
Definition: max14916.h:73
max149x6_init_param
Initialization parameter for the MAX149X6 device.
Definition: max149x6-base.h:60
no_os_util.h
Header file of utility functions.
max14916.h
Header file of MAX14916 Driver.
MAX14916_FLED_TIME_DISABLED
@ MAX14916_FLED_TIME_DISABLED
Definition: max14916.h:78
max14916_ch_set
int max14916_ch_set(struct max149x6_desc *, uint32_t, uint32_t)
Write the (logic) state of a channel (on/off).
Definition: max14916.c:76
max14916_set_sht_vdd_thr
int max14916_set_sht_vdd_thr(struct max149x6_desc *desc, enum max14916_sht_vdd_thr sht_vdd_thr)
Set short to vdd threshold in the config2 register.
Definition: max14916.c:191
no_os_gpio_direction_output
int32_t no_os_gpio_direction_output(struct no_os_gpio_desc *desc, uint8_t value)
Enable the output direction of the specified GPIO.
Definition: no_os_gpio.c:153
errno.h
Error macro definition for ARM Compiler.
no_os_gpio_get_optional
int32_t no_os_gpio_get_optional(struct no_os_gpio_desc **desc, const struct no_os_gpio_init_param *param)
Get the value of an optional GPIO.
Definition: no_os_gpio.c:81