Header file of the MAX17851 driver. More...
#include <stdint.h>
#include <string.h>
#include "no_os_uart.h"
#include "no_os_gpio.h"
#include "no_os_spi.h"
#include "no_os_util.h"
Go to the source code of this file.
Classes | |
struct | max17851_init_param |
struct | max17851_desc |
Functions | |
int | max17851_send_command (struct max17851_desc *desc, enum max17851_command command, bool enable) |
Send specific device command over SPI. | |
int | max17851_read_msg (struct max17851_desc *desc, uint8_t *data, uint8_t len) |
Read message over UART from the MAX17851. | |
int | max17851_write_msg (struct max17851_desc *desc, const uint8_t *data, uint8_t len) |
Write message over UART using MAX17851. | |
int | max17851_config_gen2 (struct max17851_desc *desc, enum max17851_config_gen2_sel sel, bool enable) |
Configure general settings for MAX17851. | |
int | max17851_sel_alrtpckt_time (struct max17851_desc *desc, enum max17851_alrtpckt_time time) |
Set timing for Alert Packets/Keep-Alive Packets. | |
int | max17851_select_queue (struct max17851_desc *desc, enum max17851_queue_sel sel) |
Select queue for transmitting/loading TX buffer for UART. | |
int | max17851_clear_buff (struct max17851_desc *desc, bool tx_buf) |
Clear RX/TX buffer inside the MAX17851 memory. | |
int | max17851_get_alert (struct max17851_desc *desc, enum max17851_alert alert, bool *enable) |
Read specific alert state. | |
int | max17851_set_alert (struct max17851_desc *desc, enum max17851_alert alert, bool enable) |
Enable/Disable specific alert. | |
int | max17851_set_alert_debounce (struct max17851_desc *desc, enum max17851_status_debounce dbnc) |
Select the number of unmasked consecutive Alert Packet status alerts, which must happen prior to taking action in either Safe Minotring or Sleep Mode. | |
int | max17851_set_safemon_dly (struct max17851_desc *desc, enum max17851_safemon_dly delay) |
Select Safe Monitoring Mode Scan Delay. | |
int | max17851_set_safemon_gpio (struct max17851_desc *desc, enum max17851_safemon_gpio gpio, bool enable) |
Select which GPIO pins to be configured as SAFEMON output. | |
int | max17851_set_comm (struct max17851_desc *desc, enum max17851_comm_try_count count, enum max17851_comm_timeout_delay delay) |
Set communication retry count and timeout delay. | |
int | max17851_reg_read (struct max17851_desc *desc, uint8_t reg, uint8_t *data) |
MAX17851 register read function. | |
int | max17851_reg_write (struct max17851_desc *desc, uint8_t reg, uint8_t data) |
MAX17851 register write function. | |
int | max17851_reg_update (struct max17851_desc *desc, uint8_t reg, uint8_t mask, uint8_t data) |
MAX17851 register update function. | |
int | max17851_init (struct max17851_desc **desc, struct max17851_init_param *init_param) |
MAX17851 device initialization function. | |
int | max17851_remove (struct max17851_desc *desc) |
Deallocate any resources used at the initialization function. | |
Variables | |
const struct no_os_uart_platform_ops | max17851_uart_ops |
MAX17851 platform specific UART platform ops structure. | |
Header file of the MAX17851 driver.
Copyright 2025(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.
#define MAX17851_ALERT_BUF_REG 0x1A |
#define MAX17851_ALERT_GEN_REG 0x16 |
#define MAX17851_ALERT_GPIO_REG 0x1E |
#define MAX17851_ALERT_LSSM_BYTE_REG 0x14 |
#define MAX17851_ALERT_OPSTATE_REG 0x18 |
#define MAX17851_ALERT_RX_REG 0x10 |
#define MAX17851_ALERT_TX_REG 0x12 |
#define MAX17851_ALERT_WD_REG 0x1C |
#define MAX17851_ALIVECOUNT_Q_REG 0xE8 |
#define MAX17851_ALIVECOUNT_RET_REG 0xE6 |
#define MAX17851_ALIVECOUNT_SEED_REG 0xE4 |
#define MAX17851_ALRT_MASK | ( | alrt | ) |
#define MAX17851_ALRTEN_BUF_REG 0x2A |
#define MAX17851_ALRTEN_GEN_REG 0x26 |
#define MAX17851_ALRTEN_GPIO_REG 0x2E |
#define MAX17851_ALRTEN_LSSM_BYTE_REG 0x24 |
#define MAX17851_ALRTEN_OPSTATE_REG 0x28 |
#define MAX17851_ALRTEN_RX_REG 0x20 |
#define MAX17851_ALRTEN_TX_REG 0x22 |
#define MAX17851_ALRTEN_WD_REG 0x2C |
#define MAX17851_ALRTPCKT_DBNC_MASK NO_OS_GENMASK(5, 3) |
#define MAX17851_ALRTPCKT_ERR_CNT_REG 0xE0 |
#define MAX17851_ALRTPCKT_TIME_MASK NO_OS_GENMASK(3, 0) |
#define MAX17851_ALRTPCKTBUF_RD_MSG_REG 0x8E |
#define MAX17851_ALRTPCKTBUF_RD_PTR_REG 0x8C |
#define MAX17851_BAUD_MASK NO_OS_GENMASK(6, 4) |
#define MAX17851_CLR_ALIVECOUNT_SEED_REG 0x48 |
#define MAX17851_CLR_LSSM_REG 0x44 |
#define MAX17851_CLR_RXBUF_REG 0x42 |
#define MAX17851_CLR_TXBUF_REG 0x40 |
#define MAX17851_COMM_RETRY_COUNT_MASK NO_OS_GENMASK(5, 4) |
#define MAX17851_COMM_RTRY_CNT_REG 0xDE |
#define MAX17851_COMM_TIMEOUT_DELAY_MASK NO_OS_GENMASK(2, 0) |
#define MAX17851_CONFIG_COMM_REG 0x76 |
#define MAX17851_CONFIG_GEN0_REG 0x60 |
#define MAX17851_CONFIG_GEN1_REG 0x62 |
#define MAX17851_CONFIG_GEN2_MASK | ( | sel | ) |
#define MAX17851_CONFIG_GEN2_REG 0x64 |
#define MAX17851_CONFIG_GEN3_REG 0x66 |
#define MAX17851_CONFIG_GEN4_REG 0x68 |
#define MAX17851_CONFIG_GEN5_REG 0x6A |
#define MAX17851_CONFIG_GPIO12_REG 0x80 |
#define MAX17851_CONFIG_GPIO34_REG 0x82 |
#define MAX17851_CONFIG_PTR_REG 0xD2 |
#define MAX17851_CONFIG_SAFEMON0_REG 0x6C |
#define MAX17851_CONFIG_SAFEMON1_REG 0x6E |
#define MAX17851_CONFIG_SAFEMON2_REG 0x70 |
#define MAX17851_CONFIG_SAFEMON3_REG 0x72 |
#define MAX17851_CONFIG_SLP_REG 0x74 |
#define MAX17851_CONFIG_WD0_REG 0x84 |
#define MAX17851_CONFIG_WD1_REG 0x86 |
#define MAX17851_CONFIG_WD2_REG 0x88 |
#define MAX17851_CONFIGQ_REG 0xD0 |
#define MAX17851_CONTACT_TIMER_DELAY_INFINITE 0xFF |
#define MAX17851_FAULT_TIMER0_REG 0xEA |
#define MAX17851_FAULT_TIMER1_REG 0xEC |
#define MAX17851_FRAME_SIZE 2 |
#define MAX17851_GPIO_RECOVERY_DELAY_DISABLED 0xFF |
#define MAX17851_LDQ_PTR_REG 0xC2 |
#define MAX17851_LDQ_REG 0xC0 |
#define MAX17851_LOAD_CONFIG_REG 0x50 |
#define MAX17851_LOADQ_MASK NO_OS_GENMASK(1, 0) |
#define MAX17851_MODEL_REG 0xF4 |
#define MAX17851_MS_MASK NO_OS_GENMASK(5, 4) |
#define MAX17851_NXT_LDQ_REG 0xB0 |
#define MAX17851_RD_REG | ( | reg | ) |
#define MAX17851_RX_BYTE_REG 0x9E |
#define MAX17851_RX_NXT_MSG_PTR_REG 0x9A |
#define MAX17851_RX_RD_MSG_REG 0x90 |
#define MAX17851_RX_RD_NXT_MSG_REG 0x92 |
#define MAX17851_RX_RD_PTR_REG 0x96 |
#define MAX17851_RX_SPACE_REG 0x9C |
#define MAX17851_RX_WR_PTR_REG 0x98 |
#define MAX17851_SAFEMON_GPIO_MASK | ( | x | ) |
#define MAX17851_SINGLE_MASK NO_OS_BIT(7) |
#define MAX17851_SLP_CBTIMER0_REG 0xEE |
#define MAX17851_SLP_CBTIMER1_REG 0xF0 |
#define MAX17851_SLP_EN_REG 0x4C |
#define MAX17851_STATE_REG 0xDC |
#define MAX17851_STATUS_BUF_REG 0x0A |
#define MAX17851_STATUS_DBNC_MASK0_REG 0x78 |
#define MAX17851_STATUS_DBNC_MASK1_REG 0x7A |
#define MAX17851_STATUS_ERR_MASK0_REG 0x7C |
#define MAX17851_STATUS_ERR_MASK1_REG 0x7E |
#define MAX17851_STATUS_GEN_REG 0x06 |
#define MAX17851_STATUS_GPIO_REG 0x0E |
#define MAX17851_STATUS_LSSM_BYTE_REG 0x04 |
#define MAX17851_STATUS_OPSTATE_REG 0x08 |
#define MAX17851_STATUS_RX_REG 0x00 |
#define MAX17851_STATUS_TX_REG 0x02 |
#define MAX17851_STATUS_WD_REG 0x0C |
#define MAX17851_SWPOR_REG 0x4A |
#define MAX17851_TX_QUEUE_SEL_REG 0x94 |
#define MAX17851_TXQ_MASK NO_OS_GENMASK(3, 2) |
#define MAX17851_UART_MAX_BYTES_NB 31 |
#define MAX17851_VER_CONFIG_REG 0x4E |
#define MAX17851_VERSION_REG 0xF2 |
#define MAX17851_WD_FAULT_CNT_REG 0xE2 |
#define MAX17851_WD_KEY_REG 0x52 |
enum max17851_alert |
enum max17851_baud_rate |
enum max17851_command |
enum max17851_queue_sel |
enum max17851_safemon_dly |
int max17851_clear_buff | ( | struct max17851_desc * | desc, |
bool | tx_buf ) |
Clear RX/TX buffer inside the MAX17851 memory.
desc | - MAX17851 device descriptor. |
tx_buf | - True - Clear TX buffer. False - Clear RX buffer. |
int max17851_config_gen2 | ( | struct max17851_desc * | desc, |
enum max17851_config_gen2_sel | sel, | ||
bool | enable ) |
Configure general settings for MAX17851.
desc | - MAX17851 device descriptor. |
sel | - Specific setting to be changed. |
enable | - Disable/Enable specific setting. |
int max17851_get_alert | ( | struct max17851_desc * | desc, |
enum max17851_alert | alert, | ||
bool * | enable ) |
Read specific alert state.
desc | - MAX17851 device descriptor. |
alert | - Specific alert state to be read. |
enable | - Pointer to alert state value to be read. |
int max17851_init | ( | struct max17851_desc ** | desc, |
struct max17851_init_param * | init_param ) |
MAX17851 device initialization function.
desc | - MAX17851 device descriptor to be intialized. |
init_param | - MAX17851 initialization parameter. |
int max17851_read_msg | ( | struct max17851_desc * | desc, |
uint8_t * | data, | ||
uint8_t | len ) |
Read message over UART from the MAX17851.
desc | - MAX17851 device descriptor. |
data | - Pointer to data containing buffer. |
len | - Length of the message in bytes. |
int max17851_reg_read | ( | struct max17851_desc * | desc, |
uint8_t | reg, | ||
uint8_t * | data ) |
MAX17851 register read function.
desc | - MAX17851 device descriptor. |
reg | - Register Address. |
data | - Data byte to be read. |
int max17851_reg_update | ( | struct max17851_desc * | desc, |
uint8_t | reg, | ||
uint8_t | mask, | ||
uint8_t | data ) |
MAX17851 register update function.
desc | - MAX17851 device descriptor. |
reg | - Register Address. |
mask | - Field mask to be udated inside the register. |
data | - Data byte to be updated. |
int max17851_reg_write | ( | struct max17851_desc * | desc, |
uint8_t | reg, | ||
uint8_t | data ) |
MAX17851 register write function.
desc | - MAX17851 device descriptor. |
reg | - Register Address. |
data | - Data byte to be written. |
int max17851_remove | ( | struct max17851_desc * | desc | ) |
Deallocate any resources used at the initialization function.
desc | - MAX17851 device descriptor. |
int max17851_sel_alrtpckt_time | ( | struct max17851_desc * | desc, |
enum max17851_alrtpckt_time | time ) |
Set timing for Alert Packets/Keep-Alive Packets.
desc | - MAX17851 device descriptor. |
time | - Specific pre-defined time value to be set. |
int max17851_select_queue | ( | struct max17851_desc * | desc, |
enum max17851_queue_sel | sel ) |
Select queue for transmitting/loading TX buffer for UART.
desc | - MAX17851 device descriptor. |
sel | - Specific pre-defined value for either TX or LD queue selection. |
int max17851_send_command | ( | struct max17851_desc * | desc, |
enum max17851_command | command, | ||
bool | enable ) |
Send specific device command over SPI.
desc | - MAX17851 device descriptor. |
command | - Specific command from the command list. |
enable | - Enable/Disable function in case of some commands. Appropiated value needed only for SWPORT or SLEEP_EN commands, ohterwise can be left either true or false. |
int max17851_set_alert | ( | struct max17851_desc * | desc, |
enum max17851_alert | alert, | ||
bool | enable ) |
Enable/Disable specific alert.
desc | - MAX17851 device descriptor. |
alert | - Specific alert to be enabled/disabled. |
enable | - true - Enable specific alert. false - Disable specific alert. |
int max17851_set_alert_debounce | ( | struct max17851_desc * | desc, |
enum max17851_status_debounce | dbnc ) |
Select the number of unmasked consecutive Alert Packet status alerts, which must happen prior to taking action in either Safe Minotring or Sleep Mode.
desc | - MAX17851 device descriptor. |
dbnc | - Specific pre-defined value for number of debounces. |
int max17851_set_comm | ( | struct max17851_desc * | desc, |
enum max17851_comm_try_count | count, | ||
enum max17851_comm_timeout_delay | delay ) |
Set communication retry count and timeout delay.
desc | - MAX17851 device descriptor. |
count | - Specific pre-defined value for communication retry count. |
delay | - Specific pre-defined value for communication timeout delay. |
int max17851_set_safemon_dly | ( | struct max17851_desc * | desc, |
enum max17851_safemon_dly | delay ) |
Select Safe Monitoring Mode Scan Delay.
desc | - MAX17851 device descriptor. |
delay | - Specific pre-defined time delay. |
int max17851_set_safemon_gpio | ( | struct max17851_desc * | desc, |
enum max17851_safemon_gpio | gpio, | ||
bool | enable ) |
Select which GPIO pins to be configured as SAFEMON output.
desc | - MAX17851 device descriptor. |
gpio | - Selected GPIO. |
enable | - Enable/Disable the SAFEMON output function of the GPIO. |
int max17851_write_msg | ( | struct max17851_desc * | desc, |
const uint8_t * | data, | ||
uint8_t | len ) |
Write message over UART using MAX17851.
desc | - MAX17851 device descriptor. |
data | - Pointer to data containing buffer. |
len | - Length of the message in bytes. |
|
extern |
MAX17851 platform specific UART platform ops structure.