no-OS
max14906.h
Go to the documentation of this file.
1 /***************************************************************************/
33 #ifndef _MAX14906_H
34 #define _MAX14906_H
35 
36 #include <stdint.h>
37 #include <stdbool.h>
38 #include "max149x6-base.h"
39 #include "no_os_gpio.h"
40 #include "no_os_spi.h"
41 #include "no_os_util.h"
42 
43 #define MAX14906_CHANNELS 4
44 
45 #define MAX14906_SETOUT_REG 0x0
46 #define MAX14906_SETLED_REG 0x1
47 #define MAX14906_DOILEVEL_REG 0x2
48 #define MAX14906_INT_REG 0x3
49 #define MAX14906_OVR_LD_REG 0x4
50 #define MAX14906_OPN_WIR_FLT_REG 0x5
51 #define MAX14906_SHD_VDD_FLT_REG 0x6
52 #define MAX14906_GLOBAL_FLT_REG 0x7
53 #define MAX14906_CONFIG1_REG 0xA
54 #define MAX14906_CONFIG2_REG 0xB
55 #define MAX14906_CONFIG_DI_REG 0xC
56 #define MAX14906_CONFIG_DO_REG 0xD
57 #define MAX14906_CONFIG_CURR_LIM 0xE
58 #define MAX14906_CONFIG_MASK 0xF
59 
60 /* DoiLevel register */
61 #define MAX14906_DOI_LEVEL_MASK(x) NO_OS_BIT(x)
62 
63 /* SetOUT register */
64 #define MAX14906_HIGHO_MASK(x) NO_OS_BIT(x)
65 
66 #define MAX14906_DO_MASK(x) (NO_OS_GENMASK(1, 0) << (2 * (x)))
67 #define MAX14906_CH_DIR_MASK(x) NO_OS_BIT((x) + 4)
68 #define MAX14906_CH(x) (x)
69 #define MAX14906_IEC_TYPE_MASK NO_OS_BIT(7)
70 #define MAX14906_CL_MASK(x) (NO_OS_GENMASK(1, 0) << (2 * (x)))
71 
72 /* Config1 register */
73 #define MAX14906_SLED_MASK NO_OS_BIT(1)
74 #define MAX14906_FLED_MASK NO_OS_BIT(0)
75 
79 };
80 
88 };
89 
98 };
99 
108 };
109 
111 int max14906_ch_get(struct max149x6_desc *, uint32_t, uint32_t *);
112 
114 int max14906_ch_set(struct max149x6_desc *, uint32_t, uint32_t);
115 
117 int max14906_ch_func(struct max149x6_desc *, uint32_t, enum max14906_function);
118 
120 int max14906_climit_set(struct max149x6_desc *, uint32_t, enum max14906_climit);
121 
123 int max14906_climit_get(struct max149x6_desc *, uint32_t,
124  enum max14906_climit *);
125 
127 int max14906_init(struct max149x6_desc **, struct max149x6_init_param *);
128 
130 int max14906_remove(struct max149x6_desc *);
131 
132 #endif
MAX14906_OUT
@ MAX14906_OUT
Definition: max14906.h:85
max149x6_desc::ready_gpio
struct no_os_gpio_desc * ready_gpio
Definition: max149x6-base.h:72
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:126
max149x6-base.h
Header file of MAX149X6 Base Driver.
max149x6_desc
Device descriptor for MAX149X6.
Definition: max149x6-base.h:67
max14906_remove
int max14906_remove(struct max149x6_desc *desc)
Free the resources allocated during init and place all the channels in high-z.
Definition: max14906.c:278
no_os_spi.h
Header file of SPI Interface.
MAX14906_CL_130
@ MAX14906_CL_130
Definition: max14906.h:105
MAX14906_GLOBAL_FLT_REG
#define MAX14906_GLOBAL_FLT_REG
Definition: max14906.h:52
MAX14906_DO_MASK
#define MAX14906_DO_MASK(x)
Definition: max14906.h:66
max14906_ch_set
int max14906_ch_set(struct max149x6_desc *, uint32_t, uint32_t)
Write the (logic) state of a channel (only for output channels).
Definition: max14906.c:70
max149x6_init_param::fault_gpio_param
struct no_os_gpio_init_param * fault_gpio_param
Definition: max149x6-base.h:58
max149x6_init_param::crc_en
bool crc_en
Definition: max149x6-base.h:61
MAX14906_OPN_WIR_FLT_REG
#define MAX14906_OPN_WIR_FLT_REG
Definition: max14906.h:50
MAX14906_CONFIG_CURR_LIM
#define MAX14906_CONFIG_CURR_LIM
Definition: max14906.h:57
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:172
NO_OS_GPIO_HIGH
@ NO_OS_GPIO_HIGH
Definition: no_os_gpio.h:117
max14906_climit_set
int max14906_climit_set(struct max149x6_desc *desc, uint32_t ch, enum max14906_climit climit)
Configure the current limit for output channels.
Definition: max14906.c:130
max149x6_desc::crc_en
bool crc_en
Definition: max149x6-base.h:75
MAX14906_OVR_LD_REG
#define MAX14906_OVR_LD_REG
Definition: max14906.h:49
MAX14906_TYPE_1_3
@ MAX14906_TYPE_1_3
Definition: max14906.h:77
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:54
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:124
max149x6_desc::synch_gpio
struct no_os_gpio_desc * synch_gpio
Definition: max149x6-base.h:73
MAX14906_CL_600
@ MAX14906_CL_600
Definition: max14906.h:104
max14906_climit
max14906_climit
Current limit options for output channels.
Definition: max14906.h:103
max149x6_init_param::comm_param
struct no_os_spi_init_param * comm_param
Definition: max149x6-base.h:56
max149x6_desc::en_gpio
struct no_os_gpio_desc * en_gpio
Definition: max149x6-base.h:70
no_os_field_prep
uint32_t no_os_field_prep(uint32_t mask, uint32_t val)
MAX14906_SETOUT_REG
#define MAX14906_SETOUT_REG
Definition: max14906.h:45
max14906_ch_set
int max14906_ch_set(struct max149x6_desc *desc, uint32_t ch, uint32_t val)
Write the (logic) state of a channel (only for output channels).
Definition: max14906.c:70
MAX14906_HIGH_Z
@ MAX14906_HIGH_Z
Definition: max14906.h:87
max14906_ch_get
int max14906_ch_get(struct max149x6_desc *desc, uint32_t ch, uint32_t *val)
Read the (voltage) state of a channel (works for both input or output).
Definition: max14906.c:47
max14906_ch_func
int max14906_ch_func(struct max149x6_desc *, uint32_t, enum max14906_function)
Configure a channel's function.
Definition: max14906.c:87
MAX14906_CL_300
@ MAX14906_CL_300
Definition: max14906.h:106
max14906_climit_get
int max14906_climit_get(struct max149x6_desc *desc, uint32_t ch, enum max14906_climit *climit)
Read an output channel's current limit.
Definition: max14906.c:144
MAX14906_HIGH_SIDE_INRUSH
@ MAX14906_HIGH_SIDE_INRUSH
Definition: max14906.h:95
MAX14906_SHD_VDD_FLT_REG
#define MAX14906_SHD_VDD_FLT_REG
Definition: max14906.h:51
max14906_ch_get
int max14906_ch_get(struct max149x6_desc *, uint32_t, uint32_t *)
Read the (voltage) state of a channel (works for both input or output).
Definition: max14906.c:47
max149x6_init_param::synch_gpio_param
struct no_os_gpio_init_param * synch_gpio_param
Definition: max149x6-base.h:60
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:104
max14906_iec_type
max14906_iec_type
Definition: max14906.h:76
MAX14906_IN
@ MAX14906_IN
Definition: max14906.h:86
max14906_function
max14906_function
Channel configuration options.
Definition: max14906.h:84
max14906_remove
int max14906_remove(struct max149x6_desc *)
Free the resources allocated during init and place all the channels in high-z.
Definition: max14906.c:278
MAX14906_DOI_LEVEL_MASK
#define MAX14906_DOI_LEVEL_MASK(x)
Definition: max14906.h:61
max149x6_init_param::ready_gpio_param
struct no_os_gpio_init_param * ready_gpio_param
Definition: max149x6-base.h:59
MAX14906_HIGHO_MASK
#define MAX14906_HIGHO_MASK(x)
Definition: max14906.h:64
max149x6_init_param::en_gpio_param
struct no_os_gpio_init_param * en_gpio_param
Definition: max149x6-base.h:57
MAX14906_PUSH_PULL
@ MAX14906_PUSH_PULL
Definition: max14906.h:97
max14906_init
int max14906_init(struct max149x6_desc **, struct max149x6_init_param *)
Initialize and configure the MAX14906 device.
Definition: max14906.c:168
max14906_climit_set
int max14906_climit_set(struct max149x6_desc *, uint32_t, enum max14906_climit)
Configure the current limit for output channels.
Definition: max14906.c:130
MAX14906_CHANNELS
#define MAX14906_CHANNELS
Definition: max14906.h:43
MAX14906_DOILEVEL_REG
#define MAX14906_DOILEVEL_REG
Definition: max14906.h:47
MAX14906_TYPE_2
@ MAX14906_TYPE_2
Definition: max14906.h:78
no_os_field_get
uint32_t no_os_field_get(uint32_t mask, uint32_t word)
MAX14906_CH_DIR_MASK
#define MAX14906_CH_DIR_MASK(x)
Definition: max14906.h:67
max14906_do_mode
max14906_do_mode
Configuration options for the output driver (on each channel).
Definition: max14906.h:93
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:69
max149x6_desc::fault_gpio
struct no_os_gpio_desc * fault_gpio
Definition: max149x6-base.h:71
MAX14906_PUSH_PULL_CLAMP
@ MAX14906_PUSH_PULL_CLAMP
Definition: max14906.h:96
MAX14906_CONFIG_DO_REG
#define MAX14906_CONFIG_DO_REG
Definition: max14906.h:56
max149x6_desc::comm_desc
struct no_os_spi_desc * comm_desc
Definition: max149x6-base.h:69
MAX14906_HIGH_SIDE
@ MAX14906_HIGH_SIDE
Definition: max14906.h:94
max14906_ch_func
int max14906_ch_func(struct max149x6_desc *desc, uint32_t ch, enum max14906_function function)
Configure a channel's function.
Definition: max14906.c:87
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:197
max14906.h
Header file of MAX14906 Driver.
MAX14906_CL_MASK
#define MAX14906_CL_MASK(x)
Definition: max14906.h:70
max14906_init
int max14906_init(struct max149x6_desc **desc, struct max149x6_init_param *param)
Initialize and configure the MAX14906 device.
Definition: max14906.c:168
max14906_climit_get
int max14906_climit_get(struct max149x6_desc *, uint32_t, enum max14906_climit *)
Read an output channel's current limit.
Definition: max14906.c:144
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:116
MAX14906_CL_1200
@ MAX14906_CL_1200
Definition: max14906.h:107
no_os_gpio.h
Header file of GPIO Interface.
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:52
max149x6_init_param
Initialization parameter for the MAX149X6 device.
Definition: max149x6-base.h:54
no_os_util.h
Header file of utility functions.
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:147
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:75