no-OS
Functions
max22516.c File Reference

Implementation of MAX22516 Driver. More...

#include <stdlib.h>
#include "max22516.h"
#include "no_os_delay.h"
#include "no_os_error.h"
#include "no_os_alloc.h"
Include dependency graph for max22516.c:

Functions

int max22516_write (struct max22516_dev *dev, uint8_t reg_addr, uint8_t data)
 Writes data to max22516 over SPI. More...
 
int max22516_read (struct max22516_dev *dev, uint8_t reg_addr, uint8_t *data)
 Reads data from max22516 over SPI. More...
 
int max22516_update (struct max22516_dev *dev, uint8_t reg_addr, uint8_t mask, uint8_t data)
 Update MAX22516 register. More...
 
int max22516_burst_write_register (struct max22516_dev *dev, uint8_t reg_addr, uint8_t count, uint8_t *data)
 MAX22516 burst write. More...
 
int max22516_burst_read_register (struct max22516_dev *dev, uint8_t reg_addr, uint8_t count, uint8_t *data)
 MAX22516 burst read. More...
 
void max22516_build_tcyc (int16_t t, uint8_t *tmr)
 MAX22516 build tcyc. More...
 
void max22516_rebuild_min_cyct_to_us (int16_t t, uint8_t *tmr)
 MAX22516 rebuild min cyct to microseconds. More...
 
int max22516_set_min_ctmr (struct max22516_dev *dev, uint16_t min_t)
 MAX22516 set min ctmr. More...
 
int max22516_set_id (struct max22516_dev *dev, uint16_t vid, uint32_t id, uint16_t fid)
 MAX22516 set id. More...
 
void max22516_decode_tcyc (uint8_t tmr, int16_t *t)
 MAX22516 decode tcyc. More...
 
int max22516_get_mst_ctmr (struct max22516_dev *dev, uint16_t min_t, int16_t *c_tmr)
 MAX22516 get mst ctmr. More...
 
int max22516_get_dl_mode (struct max22516_dev *dev, uint8_t *mode)
 MAX22516 get dl mode. More...
 
int max22516_get_iol_err_cnt (struct max22516_dev *dev, uint8_t *cnt)
 MAX22516 get iol err cnt. More...
 
int max22516_get_frm_err_cnt (struct max22516_dev *dev, uint8_t *cnt)
 MAX22516 get frm err cnt. More...
 
int max22516_clr_iol_err_cnt (struct max22516_dev *dev)
 MAX22516 clr iol err cnt. More...
 
int max22516_clr_frm_err_cnt (struct max22516_dev *dev)
 MAX22516 clr frm err cnt. More...
 
int max22516_set_led1 (struct max22516_dev *dev, uint16_t ltmr)
 MAX22516 set led1. More...
 
int max22516_set_led2 (struct max22516_dev *dev, uint16_t ltmr)
 MAX22516 set led2. More...
 
int max22516_get_v24 (struct max22516_dev *dev, uint8_t *status3)
 MAX22516 get v24. More...
 
int max22516_get_thd (struct max22516_dev *dev, uint8_t *status3)
 MAX22516 get THD. More...
 
int max22516_setup_cq_dis (struct max22516_dev *dev)
 MAX22516 setup cq dis. More...
 
int max22516_setup_cq_pp (struct max22516_dev *dev)
 MAX22516 setup cq pp. More...
 
int max22516_setup_cq_pnp (struct max22516_dev *dev)
 MAX22516 setup cq pnp. More...
 
int max22516_setup_cq_npn (struct max22516_dev *dev)
 MAX22516 setup cq npn. More...
 
int max22516_tx_set (struct max22516_dev *dev, uint8_t low_high)
 MAX22516 tx set. More...
 
int max22516_txen_set (struct max22516_dev *dev, uint8_t lvl)
 MAX22516 txen set. More...
 
int max22516_set_cq (struct max22516_dev *dev, uint8_t lvl)
 MAX22516 set cq. More...
 
int max22516_tx_get (struct max22516_dev *dev, uint8_t *low_high)
 MAX22516 tx get. More...
 
int max22516_get_cq (struct max22516_dev *dev, uint8_t *cq)
 MAX22516 get cq. More...
 
int max22516_get_cq_stat (struct max22516_dev *dev, uint8_t *status3)
 MAX22516 get cq stat. More...
 
int max22516_setup_do_dis (struct max22516_dev *dev)
 MAX22516 setup do dis. More...
 
int max22516_setup_do_pp (struct max22516_dev *dev)
 MAX22516 setup do pp. More...
 
int max22516_setup_do_pnp (struct max22516_dev *dev)
 MAX22516 setup do pnp. More...
 
int max22516_setup_do_npn (struct max22516_dev *dev)
 MAX22516 setup do npn. More...
 
int max22516_do_set (struct max22516_dev *dev, uint8_t lvl)
 MAX22516 do set. More...
 
int max22516_do_get (struct max22516_dev *dev, uint8_t *lvl)
 MAX22516 do get. More...
 
int max22516_get_do_stat (struct max22516_dev *dev, uint8_t *status3)
 MAX22516 get do stat. More...
 
int max22516_set_event (struct max22516_dev *dev, uint8_t ev_qual, uint16_t ev_code)
 MAX22516 set event. More...
 
int max22516_setup_watchdog (struct max22516_dev *dev, uint8_t wd_timeout, uint8_t wd_clr, uint8_t wd_event_en, uint8_t wd_event_flag)
 MAX22516 setup watchdog. More...
 
int max22516_init (struct max22516_dev **device, struct max22516_init_param *init_param)
 Initialize the MAX22516 device. More...
 
int max22516_remove (struct max22516_dev *dev)
 Free resoulces allocated for MAX22516. More...
 

Detailed Description

Implementation of MAX22516 Driver.

Author
Antoniu Miclaus (anton.nosp@m.iu.m.nosp@m.iclau.nosp@m.s@an.nosp@m.alog..nosp@m.com)

Copyright 2023(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:

  1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
  2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.
  3. Neither the name of Analog Devices, Inc. nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission.

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.

Function Documentation

◆ max22516_build_tcyc()

void max22516_build_tcyc ( int16_t  t,
uint8_t *  tmr 
)

MAX22516 build tcyc.

Parameters
t
tmr
Here is the caller graph for this function:

◆ max22516_burst_read_register()

int max22516_burst_read_register ( struct max22516_dev dev,
uint8_t  reg_addr,
uint8_t  count,
uint8_t *  data 
)

MAX22516 burst read.

Parameters
dev- The device structure.
reg_addr- The register address.
count- Nr. of bytes to be read.
data- Data read from the device.
Returns
Returns 0 in case of success or negative error code otherwise.

◆ max22516_burst_write_register()

int max22516_burst_write_register ( struct max22516_dev dev,
uint8_t  reg_addr,
uint8_t  count,
uint8_t *  data 
)

MAX22516 burst write.

Parameters
dev- The device structure.
reg_addr- The register address.
count- Nr. of bytes to be written.
data- Data to be written.
Returns
Returns 0 in case of success or negative error code otherwise.

◆ max22516_clr_frm_err_cnt()

int max22516_clr_frm_err_cnt ( struct max22516_dev dev)

MAX22516 clr frm err cnt.

Parameters
dev- The device structure.
Returns
Returns 0 in case of success or negative error code otherwise.

◆ max22516_clr_iol_err_cnt()

int max22516_clr_iol_err_cnt ( struct max22516_dev dev)

MAX22516 clr iol err cnt.

Parameters
dev- The device structure.
Returns
Returns 0 in case of success or negative error code otherwise.

◆ max22516_decode_tcyc()

void max22516_decode_tcyc ( uint8_t  tmr,
int16_t *  t 
)

MAX22516 decode tcyc.

Parameters
t
tmr
Here is the caller graph for this function:

◆ max22516_do_get()

int max22516_do_get ( struct max22516_dev dev,
uint8_t *  lvl 
)

MAX22516 do get.

Parameters
dev- The device structure.
lvl
Returns
Returns 0 in case of success or negative error code otherwise.

◆ max22516_do_set()

int max22516_do_set ( struct max22516_dev dev,
uint8_t  lvl 
)

MAX22516 do set.

Parameters
dev- The device structure.
lvl
Returns
Returns 0 in case of success or negative error code otherwise.

◆ max22516_get_cq()

int max22516_get_cq ( struct max22516_dev dev,
uint8_t *  cq 
)

MAX22516 get cq.

Parameters
dev- The device structure.
cq
Returns
Returns 0 in case of success or negative error code otherwise.

◆ max22516_get_cq_stat()

int max22516_get_cq_stat ( struct max22516_dev dev,
uint8_t *  status3 
)

MAX22516 get cq stat.

Parameters
dev- The device structure.
status3
Returns
Returns 0 in case of success or negative error code otherwise.

◆ max22516_get_dl_mode()

int max22516_get_dl_mode ( struct max22516_dev dev,
uint8_t *  mode 
)

MAX22516 get dl mode.

Parameters
dev- The device structure.
mode
Returns
Returns 0 in case of success or negative error code otherwise.

◆ max22516_get_do_stat()

int max22516_get_do_stat ( struct max22516_dev dev,
uint8_t *  status3 
)

MAX22516 get do stat.

Parameters
dev- The device structure.
status3
Returns
Returns 0 in case of success or negative error code otherwise.

◆ max22516_get_frm_err_cnt()

int max22516_get_frm_err_cnt ( struct max22516_dev dev,
uint8_t *  cnt 
)

MAX22516 get frm err cnt.

Parameters
dev- The device structure.
cnt
Returns
Returns 0 in case of success or negative error code otherwise.

◆ max22516_get_iol_err_cnt()

int max22516_get_iol_err_cnt ( struct max22516_dev dev,
uint8_t *  cnt 
)

MAX22516 get iol err cnt.

Parameters
dev- The device structure.
cnt
Returns
Returns 0 in case of success or negative error code otherwise.

◆ max22516_get_mst_ctmr()

int max22516_get_mst_ctmr ( struct max22516_dev dev,
uint16_t  min_t,
int16_t *  c_tmr 
)

MAX22516 get mst ctmr.

Parameters
dev- The device structure.
min_t
c_tmr
Returns
Returns 0 in case of success or negative error code otherwise.

◆ max22516_get_thd()

int max22516_get_thd ( struct max22516_dev dev,
uint8_t *  status3 
)

MAX22516 get THD.

Parameters
dev- The device structure.
status3
Returns
Returns 0 in case of success or negative error code otherwise.

◆ max22516_get_v24()

int max22516_get_v24 ( struct max22516_dev dev,
uint8_t *  status3 
)

MAX22516 get v24.

Parameters
dev- The device structure.
status3
Returns
Returns 0 in case of success or negative error code otherwise.

◆ max22516_init()

int max22516_init ( struct max22516_dev **  device,
struct max22516_init_param init_param 
)

Initialize the MAX22516 device.

Parameters
device- The device structure.
init_param- The structure containing the device initial parameters.
Returns
Returns 0 in case of success or negative error code.

◆ max22516_read()

int max22516_read ( struct max22516_dev dev,
uint8_t  reg_addr,
uint8_t *  data 
)

Reads data from max22516 over SPI.

Parameters
dev- The device structure.
reg_addr- The register address.
data- Data read from the device.
Returns
Returns 0 in case of success or negative error code otherwise.
Here is the caller graph for this function:

◆ max22516_rebuild_min_cyct_to_us()

void max22516_rebuild_min_cyct_to_us ( int16_t  t,
uint8_t *  tmr 
)

MAX22516 rebuild min cyct to microseconds.

Parameters
t
tmr

◆ max22516_remove()

int max22516_remove ( struct max22516_dev dev)

Free resoulces allocated for MAX22516.

Parameters
dev- The device structure.
Returns
Returns 0 in case of success or negative error code.

◆ max22516_set_cq()

int max22516_set_cq ( struct max22516_dev dev,
uint8_t  lvl 
)

MAX22516 set cq.

Parameters
dev- The device structure.
lvl
Returns
Returns 0 in case of success or negative error code otherwise.

◆ max22516_set_event()

int max22516_set_event ( struct max22516_dev dev,
uint8_t  ev_qual,
uint16_t  ev_code 
)

MAX22516 set event.

Parameters
dev- The device structure.
ev_qual
ev_code
Returns
Returns 0 in case of success or negative error code otherwise.

◆ max22516_set_id()

int max22516_set_id ( struct max22516_dev dev,
uint16_t  vid,
uint32_t  id,
uint16_t  fid 
)

MAX22516 set id.

Parameters
dev- The device structure.
vid
id
fid
Returns
Returns 0 in case of success or negative error code otherwise.

◆ max22516_set_led1()

int max22516_set_led1 ( struct max22516_dev dev,
uint16_t  ltmr 
)

MAX22516 set led1.

Parameters
dev- The device structure.
ltmr
Returns
Returns 0 in case of success or negative error code otherwise.

◆ max22516_set_led2()

int max22516_set_led2 ( struct max22516_dev dev,
uint16_t  ltmr 
)

MAX22516 set led2.

Parameters
dev- The device structure.
ltmr
Returns
Returns 0 in case of success or negative error code otherwise.

◆ max22516_set_min_ctmr()

int max22516_set_min_ctmr ( struct max22516_dev dev,
uint16_t  min_t 
)

MAX22516 set min ctmr.

Parameters
dev- The device structure.
min_t
Returns
Returns 0 in case of success or negative error code otherwise.

◆ max22516_setup_cq_dis()

int max22516_setup_cq_dis ( struct max22516_dev dev)

MAX22516 setup cq dis.

Parameters
dev- The device structure.
Returns
Returns 0 in case of success or negative error code otherwise.

◆ max22516_setup_cq_npn()

int max22516_setup_cq_npn ( struct max22516_dev dev)

MAX22516 setup cq npn.

Parameters
dev- The device structure.
Returns
Returns 0 in case of success or negative error code otherwise.

◆ max22516_setup_cq_pnp()

int max22516_setup_cq_pnp ( struct max22516_dev dev)

MAX22516 setup cq pnp.

Parameters
dev- The device structure.
Returns
Returns 0 in case of success or negative error code otherwise.

◆ max22516_setup_cq_pp()

int max22516_setup_cq_pp ( struct max22516_dev dev)

MAX22516 setup cq pp.

Parameters
dev- The device structure.
Returns
Returns 0 in case of success or negative error code otherwise.

◆ max22516_setup_do_dis()

int max22516_setup_do_dis ( struct max22516_dev dev)

MAX22516 setup do dis.

Parameters
dev- The device structure.
Returns
Returns 0 in case of success or negative error code otherwise.

◆ max22516_setup_do_npn()

int max22516_setup_do_npn ( struct max22516_dev dev)

MAX22516 setup do npn.

Parameters
dev- The device structure.
Returns
Returns 0 in case of success or negative error code otherwise.

◆ max22516_setup_do_pnp()

int max22516_setup_do_pnp ( struct max22516_dev dev)

MAX22516 setup do pnp.

Parameters
dev- The device structure.
Returns
Returns 0 in case of success or negative error code otherwise.

◆ max22516_setup_do_pp()

int max22516_setup_do_pp ( struct max22516_dev dev)

MAX22516 setup do pp.

Parameters
dev- The device structure.
Returns
Returns 0 in case of success or negative error code otherwise.

◆ max22516_setup_watchdog()

int max22516_setup_watchdog ( struct max22516_dev dev,
uint8_t  wd_timeout,
uint8_t  wd_clr,
uint8_t  wd_event_en,
uint8_t  wd_event_flag 
)

MAX22516 setup watchdog.

Parameters
dev- The device structure.
wd_timeout
wd_clr
wd_event_en
wd_event_flag
Returns
Returns 0 in case of success or negative error code otherwise.

◆ max22516_tx_get()

int max22516_tx_get ( struct max22516_dev dev,
uint8_t *  low_high 
)

MAX22516 tx get.

Parameters
dev- The device structure.
low_high- TX level
Returns
Returns 0 in case of success or negative error code otherwise.
Here is the caller graph for this function:

◆ max22516_tx_set()

int max22516_tx_set ( struct max22516_dev dev,
uint8_t  low_high 
)

MAX22516 tx set.

Parameters
dev- The device structure.
low_high
Returns
Returns 0 in case of success or negative error code otherwise.
Here is the caller graph for this function:

◆ max22516_txen_set()

int max22516_txen_set ( struct max22516_dev dev,
uint8_t  lvl 
)

MAX22516 txen set.

Parameters
dev- The device structure.
lvl
Returns
Returns 0 in case of success or negative error code otherwise.
Here is the caller graph for this function:

◆ max22516_update()

int max22516_update ( struct max22516_dev dev,
uint8_t  reg_addr,
uint8_t  mask,
uint8_t  data 
)

Update MAX22516 register.

Parameters
dev- The device structure.
reg_addr- The register address.
mask- Mask for specific register bits to be updated.
data- Data read from the device.
Returns
Returns 0 in case of success or negative error code otherwise.
Here is the caller graph for this function:

◆ max22516_write()

int max22516_write ( struct max22516_dev dev,
uint8_t  reg_addr,
uint8_t  data 
)

Writes data to max22516 over SPI.

Parameters
dev- The device structure.
reg_addr- The register address.
data- Data value to write.
Returns
Returns 0 in case of success or negative error code otherwise.
Here is the caller graph for this function: