expand7 2.0.0.0
expand7.h File Reference

This file contains API for Expand 7 Click driver. More...

#include "drv_digital_out.h"
#include "drv_digital_in.h"
#include "drv_i2c_master.h"

Go to the source code of this file.

Data Structures

struct  expand7_pwm_cfg_t
 PWM Configuration. More...
 
struct  expand7_t
 Click ctx object definition. More...
 
struct  expand7_cfg_t
 Click configuration structure definition. More...
 

Macros

#define EXPAND7_MAP_MIKROBUS(cfg, mikrobus)
 
#define EXPAND7_OK   0
 
#define EXPAND7_ERROR   -1
 
#define EXPAND7_M_PORT_BASE_ADR   0x20
 
#define EXPAND7_EEPROM_BASE_ADR   0x50
 
#define EXPAND7_DEV_ADR_GND   0x00
 
#define EXPAND7_DEV_ADR_VCC   0x01
 
#define EXPAND7_REG_IN_PORT0_ADR   0x00
 
#define EXPAND7_REG_IN_PORT1_ADR   0x01
 
#define EXPAND7_REG_IN_PORT2_ADR   0x02
 
#define EXPAND7_REG_IN_PORT3_ADR   0x03
 
#define EXPAND7_REG_IN_PORT4_ADR   0x04
 
#define EXPAND7_REG_IN_PORT5_ADR   0x05
 
#define EXPAND7_REG_IN_PORT6_ADR   0x06
 
#define EXPAND7_REG_IN_PORT7_ADR   0x07
 
#define EXPAND7_REG_OUT_PORT0_ADR   0x08
 
#define EXPAND7_REG_OUT_PORT1_ADR   0x09
 
#define EXPAND7_REG_OUT_PORT2_ADR   0x0A
 
#define EXPAND7_REG_OUT_PORT3_ADR   0x0B
 
#define EXPAND7_REG_OUT_PORT4_ADR   0x0C
 
#define EXPAND7_REG_OUT_PORT5_ADR   0x0D
 
#define EXPAND7_REG_OUT_PORT6_ADR   0x0E
 
#define EXPAND7_REG_OUT_PORT7_ADR   0x0F
 
#define EXPAND7_REG_INT_STAT_PORT0_ADR   0x10
 
#define EXPAND7_REG_INT_STAT_PORT1_ADR   0x11
 
#define EXPAND7_REG_INT_STAT_PORT2_ADR   0x12
 
#define EXPAND7_REG_INT_STAT_PORT3_ADR   0x13
 
#define EXPAND7_REG_INT_STAT_PORT4_ADR   0x14
 
#define EXPAND7_REG_INT_STAT_PORT5_ADR   0x15
 
#define EXPAND7_REG_INT_STAT_PORT6_ADR   0x16
 
#define EXPAND7_REG_INT_STAT_PORT7_ADR   0x17
 
#define EXPAND7_REG_PORT_SEL_ADR   0x18
 
#define EXPAND7_REG_INT_MASK_ADR   0x19
 
#define EXPAND7_REG_SEL_PWM_OUT_ADR   0x1A
 
#define EXPAND7_REG_INV_ADR   0x1B
 
#define EXPAND7_REG_PORT_DIR_ADR   0x1C
 
#define EXPAND7_REG_PULL_UP_ADR   0x1D
 
#define EXPAND7_REG_PULL_DOWN_ADR   0x1E
 
#define EXPAND7_REG_OPEN_DRAIN_HIGH_ADR   0x1F
 
#define EXPAND7_REG_OPEN_DRAIN_LOW_ADR   0x20
 
#define EXPAND7_REG_STRONG_ADR   0x21
 
#define EXPAND7_REG_SLOW_STRONG_ADR   0x22
 
#define EXPAND7_REG_HIGH_Z_ADR   0x23
 
#define EXPAND7_REG_RSRVD_1_ADR   0x24
 
#define EXPAND7_REG_RSRVD_2_ADR   0x25
 
#define EXPAND7_REG_RSRVD_3_ADR   0x26
 
#define EXPAND7_REG_RSRVD_4_ADR   0x27
 
#define EXPAND7_REG_PWM_SEL_ADR   0x28
 
#define EXPAND7_REG_CFG_PWM_ADR   0x29
 
#define EXPAND7_REG_PERIOD_PWM_ADR   0x2A
 
#define EXPAND7_REG_PULSE_WIDTH_PWM_ADR   0x2B
 
#define EXPAND7_REG_DIVIDER_ADR   0x2C
 
#define EXPAND7_REG_EEPROM_ADR   0x2D
 
#define EXPAND7_REG_DEV_ID_ADR   0x2E
 
#define EXPAND7_REG_WDT_ADR   0x2F
 
#define EXPAND7_REG_CMD_ADR   0x30
 
#define EXPAND7_SEL_PWM_0   0x00
 
#define EXPAND7_SEL_PWM_1   0x01
 
#define EXPAND7_SEL_PWM_2   0x02
 
#define EXPAND7_SEL_PWM_3   0x03
 
#define EXPAND7_SEL_PWM_4   0x04
 
#define EXPAND7_SEL_PWM_5   0x05
 
#define EXPAND7_SEL_PWM_6   0x06
 
#define EXPAND7_SEL_PWM_7   0x07
 
#define EXPAND7_PWM_CLK_SRC_32_KHZ   0x00
 
#define EXPAND7_PWM_CLK_SRC_24_MHZ   0x01
 
#define EXPAND7_PWM_CLK_SRC_1_5_MHZ   0x02
 
#define EXPAND7_PWM_CLK_SRC_93_75_KHZ   0x03
 
#define EXPAND7_PWM_CLK_SRC_367_6_HZ   0x04
 
#define EXPAND7_PWM_CLK_SRC_PREV   0x05
 
#define EXPAND7_STORE_POR_CFG_TO_EEPROM   0x01
 
#define EXPAND7_RESTORE_DEFAULTS   0x02
 
#define EXPAND7_WRITE_EEPROM_POR   0x03
 
#define EXPAND7_READ_EEPROM_POR   0x04
 
#define EXPAND7_WRITE_DEV_CFG   0x05
 
#define EXPAND7_READ_DEV_CFG   0x06
 
#define EXPAND7_RECFG_DEV_TO_POR   0x07
 
#define EXPAND7_EEPROM_EN_WDE   0x01
 
#define EXPAND7_EEPROM_EN_EEE   0x02
 
#define EXPAND7_EEPROM_EN_EERO   0x04
 
#define EXPAND7_PORT_0   0x00
 
#define EXPAND7_PORT_1   0x01
 
#define EXPAND7_PORT_2   0x02
 
#define EXPAND7_PORT_3   0x03
 
#define EXPAND7_PORT_4   0x04
 
#define EXPAND7_PORT_5   0x05
 
#define EXPAND7_LOW   0x00
 
#define EXPAND7_HIGH   0x01
 
#define EXPAND7_INT_NORMAL   0x00
 
#define EXPAND7_INT_INVERTED   0x01
 
#define EXPAND7_PORT0_OUT_INX   0x00
 
#define EXPAND7_PORT1_OUT_INX   0x01
 
#define EXPAND7_PORT2_OUT_INX   0x02
 
#define EXPAND7_PORT3_OUT_INX   0x03
 
#define EXPAND7_PORT4_OUT_INX   0x04
 
#define EXPAND7_PORT5_OUT_INX   0x05
 
#define EXPAND7_PORT6_OUT_INX   0x06
 
#define EXPAND7_PORT7_OUT_INX   0x07
 
#define EXPAND7_PORT0_INT_MASK_INX   0x08
 
#define EXPAND7_PORT1_INT_MASK_INX   0x09
 
#define EXPAND7_PORT2_INT_MASK_INX   0x0A
 
#define EXPAND7_PORT3_INT_MASK_INX   0x0B
 
#define EXPAND7_PORT4_INT_MASK_INX   0x0C
 
#define EXPAND7_PORT5_INT_MASK_INX   0x0D
 
#define EXPAND7_PORT6_INT_MASK_INX   0x0E
 
#define EXPAND7_PORT7_INT_MASK_INX   0x0F
 
#define EXPAND7_PORT0_SEL_PWM_INX   0x10
 
#define EXPAND7_PORT1_SEL_PWM_INX   0x11
 
#define EXPAND7_PORT2_SEL_PWM_INX   0x12
 
#define EXPAND7_PORT3_SEL_PWM_INX   0x13
 
#define EXPAND7_PORT4_SEL_PWM_INX   0x14
 
#define EXPAND7_PORT5_SEL_PWM_INX   0x15
 
#define EXPAND7_PORT6_SEL_PWM_INX   0x16
 
#define EXPAND7_PORT7_SEL_PWM_INX   0x17
 
#define EXPAND7_PORT0_INV_INX   0x18
 
#define EXPAND7_PORT1_INV_INX   0x19
 
#define EXPAND7_PORT2_INV_INX   0x1A
 
#define EXPAND7_PORT3_INV_INX   0x1B
 
#define EXPAND7_PORT4_INV_INX   0x1C
 
#define EXPAND7_PORT5_INV_INX   0x1D
 
#define EXPAND7_PORT6_INV_INX   0x1E
 
#define EXPAND7_PORT7_INV_INX   0x1F
 
#define EXPAND7_PORT0_DIR_INX   0x20
 
#define EXPAND7_PORT1_DIR_INX   0x21
 
#define EXPAND7_PORT2_DIR_INX   0x22
 
#define EXPAND7_PORT3_DIR_INX   0x23
 
#define EXPAND7_PORT4_DIR_INX   0x24
 
#define EXPAND7_PORT5_DIR_INX   0x25
 
#define EXPAND7_PORT6_DIR_INX   0x26
 
#define EXPAND7_PORT7_DIR_INX   0x27
 
#define EXPAND7_PORT0_PULL_UP_INX   0x28
 
#define EXPAND7_PORT0_PULL_DOWN_INX   0x29
 
#define EXPAND7_PORT0_OPEN_DRAIN_HIGH_INX   0x2A
 
#define EXPAND7_PORT0_OPEN_DRAIN_LOW_INX   0x2B
 
#define EXPAND7_PORT0_STRONG_INX   0x2C
 
#define EXPAND7_PORT0_SLOW_STRONG_INX   0x2D
 
#define EXPAND7_PORT0_HIGH_Z_INX   0x2E
 
#define EXPAND7_PORT1_PULL_UP_INX   0x2F
 
#define EXPAND7_PORT1_PULL_DOWN_INX   0x30
 
#define EXPAND7_PORT1_OPEN_DRAIN_HIGH_INX   0x31
 
#define EXPAND7_PORT1_OPEN_DRAIN_LOW_INX   0x32
 
#define EXPAND7_PORT1_STRONG_INX   0x33
 
#define EXPAND7_PORT1_SLOW_STRONG_INX   0x34
 
#define EXPAND7_PORT1_HIGH_Z_INX   0x35
 
#define EXPAND7_PORT2_PULL_UP_INX   0x36
 
#define EXPAND7_PORT2_PULL_DOWN_INX   0x37
 
#define EXPAND7_PORT2_OPEN_DRAIN_HIGH_INX   0x38
 
#define EXPAND7_PORT2_OPEN_DRAIN_LOW_INX   0x39
 
#define EXPAND7_PORT2_STRONG_INX   0x3A
 
#define EXPAND7_PORT2_SLOW_STRONG_INX   0x3B
 
#define EXPAND7_PORT2_HIGH_Z_INX   0x3C
 
#define EXPAND7_PORT3_PULL_UP_INX   0x3D
 
#define EXPAND7_PORT3_PULL_DOWN_INX   0x3E
 
#define EXPAND7_PORT3_OPEN_DRAIN_HIGH_INX   0x3F
 
#define EXPAND7_PORT3_OPEN_DRAIN_LOW_INX   0x40
 
#define EXPAND7_PORT3_STRONG_INX   0x41
 
#define EXPAND7_PORT3_SLOW_STRONG_INX   0x42
 
#define EXPAND7_PORT3_HIGH_Z_INX   0x43
 
#define EXPAND7_PORT4_PULL_UP_INX   0x44
 
#define EXPAND7_PORT4_PULL_DOWN_INX   0x45
 
#define EXPAND7_PORT4_OPEN_DRAIN_HIGH_INX   0x46
 
#define EXPAND7_PORT4_OPEN_DRAIN_LOW_INX   0x47
 
#define EXPAND7_PORT4_STRONG_INX   0x48
 
#define EXPAND7_PORT4_SLOW_STRONG_INX   0x49
 
#define EXPAND7_PORT4_HIGH_Z_INX   0x4A
 
#define EXPAND7_PORT5_PULL_UP_INX   0x4B
 
#define EXPAND7_PORT5_PULL_DOWN_INX   0x4C
 
#define EXPAND7_PORT5_OPEN_DRAIN_HIGH_INX   0x4D
 
#define EXPAND7_PORT5_OPEN_DRAIN_LOW_INX   0x4E
 
#define EXPAND7_PORT5_STRONG_INX   0x4F
 
#define EXPAND7_PORT5_SLOW_STRONG_INX   0x50
 
#define EXPAND7_PORT5_HIGH_Z_INX   0x51
 
#define EXPAND7_PORT6_PULL_UP_INX   0x52
 
#define EXPAND7_PORT6_PULL_DOWN_INX   0x53
 
#define EXPAND7_PORT6_OPEN_DRAIN_HIGH_INX   0x54
 
#define EXPAND7_PORT6_OPEN_DRAIN_LOW_INX   0x55
 
#define EXPAND7_PORT6_STRONG_INX   0x56
 
#define EXPAND7_PORT6_SLOW_STRONG_INX   0x57
 
#define EXPAND7_PORT6_HIGH_Z_INX   0x58
 
#define EXPAND7_PORT7_PULL_UP_INX   0x59
 
#define EXPAND7_PORT7_PULL_DOWN_INX   0x5A
 
#define EXPAND7_PORT7_OPEN_DRAIN_HIGH_INX   0x5B
 
#define EXPAND7_PORT7_OPEN_DRAIN_LOW_INX   0x5C
 
#define EXPAND7_PORT7_STRONG_INX   0x5D
 
#define EXPAND7_PORT7_SLOW_STRONG_INX   0x5E
 
#define EXPAND7_PORT7_HIGH_Z_INX   0x5F
 
#define EXPAND7_PWM0_CFG_INX   0x60
 
#define EXPAND7_PWM0_PERIOD_INX   0x61
 
#define EXPAND7_PWM0_PULSE_WIDTH_INX   0x62
 
#define EXPAND7_PWM1_CFG_INX   0x63
 
#define EXPAND7_PWM1_PERIOD_INX   0x64
 
#define EXPAND7_PWM1_PULSE_WIDTH_INX   0x65
 
#define EXPAND7_PWM2_CFG_INX   0x66
 
#define EXPAND7_PWM2_PERIOD_INX   0x67
 
#define EXPAND7_PWM2_PULSE_WIDTH_INX   0x68
 
#define EXPAND7_PWM3_CFG_INX   0x69
 
#define EXPAND7_PWM3_PERIOD_INX   0x6A
 
#define EXPAND7_PWM3_PULSE_WIDTH_INX   0x6B
 
#define EXPAND7_PWM4_CFG_INX   0x6C
 
#define EXPAND7_PWM4_PERIOD_INX   0x6D
 
#define EXPAND7_PWM4_PULSE_WIDTH_INX   0x6E
 
#define EXPAND7_PWM5_CFG_INX   0x6F
 
#define EXPAND7_PWM5_PERIOD_INX   0x70
 
#define EXPAND7_PWM5_PULSE_WIDTH_INX   0x71
 
#define EXPAND7_PWM6_CFG_INX   0x72
 
#define EXPAND7_PWM6_PERIOD_INX   0x73
 
#define EXPAND7_PWM6_PULSE_WIDTH_INX   0x74
 
#define EXPAND7_PWM7_CFG_INX   0x75
 
#define EXPAND7_PWM7_PERIOD_INX   0x76
 
#define EXPAND7_PWM7_PULSE_WIDTH_INX   0x77
 
#define EXPAND7_PWM8_CFG_INX   0x78
 
#define EXPAND7_PWM8_PERIOD_INX   0x79
 
#define EXPAND7_PWM8_PULSE_WIDTH_INX   0x7A
 
#define EXPAND7_PWM9_CFG_INX   0x7B
 
#define EXPAND7_PWM9_PERIOD_INX   0x7C
 
#define EXPAND7_PWM9_PULSE_WIDTH_INX   0x7D
 
#define EXPAND7_PWM10_CFG_INX   0x7E
 
#define EXPAND7_PWM10_PERIOD_INX   0x7F
 
#define EXPAND7_PWM10_PULSE_WIDTH_INX   0x80
 
#define EXPAND7_PWM11_CFG_INX   0x81
 
#define EXPAND7_PWM11_PERIOD_INX   0x82
 
#define EXPAND7_PWM11_PULSE_WIDTH_INX   0x83
 
#define EXPAND7_PWM12_CFG_INX   0x84
 
#define EXPAND7_PWM12_PERIOD_INX   0x85
 
#define EXPAND7_PWM12_PULSE_WIDTH_INX   0x86
 
#define EXPAND7_PWM13_CFG_INX   0x87
 
#define EXPAND7_PWM13_PERIOD_INX   0x88
 
#define EXPAND7_PWM13_PULSE_WIDTH_INX   0x89
 
#define EXPAND7_PWM14_CFG_INX   0x8A
 
#define EXPAND7_PWM14_PERIOD_INX   0x8B
 
#define EXPAND7_PWM14_PULSE_WIDTH_INX   0x8C
 
#define EXPAND7_PWM15_CFG_INX   0x8D
 
#define EXPAND7_PWM15_PERIOD_INX   0x8E
 
#define EXPAND7_PWM15_PULSE_WIDTH_INX   0x8F
 
#define EXPAND7_DIVIDER_INX   0x90
 
#define EXPAND7_EEPROM_ENABLE_INX   0x91
 
#define EXPAND7_CRC_INX   0x92
 

Functions

void expand7_cfg_setup (expand7_cfg_t *cfg)
 Config Object Initialization function.
 
err_t expand7_init (expand7_t *ctx, expand7_cfg_t *cfg)
 Initialization function.
 
void expand7_generic_write (expand7_t *ctx, uint8_t reg, uint8_t *data_buf, uint8_t len)
 Generic write function.
 
void expand7_generic_read (expand7_t *ctx, uint8_t reg, uint8_t *data_buf, uint8_t len)
 Generic read function.
 
void expand7_write_byte (expand7_t *ctx, uint8_t reg_adr, uint8_t wr_data)
 Write byte function.
 
uint8_t expand7_read_byte (expand7_t *ctx, uint8_t reg_adr)
 Read byte function.
 
void expand7_write_port_exp (expand7_t *ctx, uint8_t reg, uint8_t *buf, uint8_t len)
 Port Expander Write function.
 
void expand7_read_port_exp (expand7_t *ctx, uint8_t reg, uint8_t *buf, uint8_t len)
 Port Expander Read function.
 
void expand7_send_eeprom_cmd (expand7_t *ctx, uint8_t cmd)
 Send Command function.
 
void expand7_write_eeprom (expand7_t *ctx, uint16_t mem_adr, uint8_t *buf, uint8_t len)
 EEPROM Write function.
 
void expand7_read_eeprom (expand7_t *ctx, uint16_t mem_adr, uint8_t *buf, uint8_t len)
 EEPROM Read function.
 
uint8_t expand7_read_bit (expand7_t *ctx, uint8_t reg_adr, uint8_t bit_num)
 Read bit function.
 
void expand7_write_bit (expand7_t *ctx, uint8_t reg_adr, uint8_t bit_num, uint8_t pin_val)
 Write bit function.
 
uint8_t expand7_read_pin (expand7_t *ctx, uint8_t pin, uint8_t inv)
 Get a single INPUT pin's logic level function.
 
uint8_t expand7_read_port (expand7_t *ctx, uint8_t port, uint8_t inv)
 Get all pin logic levels from one port function.
 
uint8_t expand7_get_pin_out_lvl (expand7_t *ctx, uint8_t pin)
 Get a single OUTPUT pin's setting function.
 
uint8_t expand7_get_port_out_lvl (expand7_t *ctx, uint8_t port)
 Get all pin output settings from one port function.
 
void expand7_write_pin (expand7_t *ctx, uint8_t pin, uint8_t pin_val)
 Set a single OUTPUT pin's logic level function.
 
void expand7_write_port (expand7_t *ctx, uint8_t port, uint8_t value)
 Set all OUTPUT pins' logic levels in one port function.
 
void expand7_write_all (expand7_t *ctx, uint8_t value)
 Set all OUTPUT pins' logic levels function.
 
void expand7_sel_pwm_pin (expand7_t *ctx, uint8_t pin, uint8_t pwm_en)
 Select a PWM output pin function.
 
void expand7_pwm_cfg (expand7_t *ctx, expand7_pwm_cfg_t pwm_cfg, float *duty_cyc, float *freq)
 PWM Configuration function.
 
void expand7_eeprom_enable (expand7_t *ctx, uint8_t cmd)
 Enable Register Configuration function.
 
void expand7_reset (expand7_t *ctx)
 Reset function.
 
uint8_t expand7_check_int (expand7_t *ctx)
 Get Interrupt state function.
 

Detailed Description

This file contains API for Expand 7 Click driver.