39#ifdef PREINIT_SUPPORTED
43#ifdef MikroCCoreVersion
44 #if MikroCCoreVersion >= 1
49#include "drv_digital_out.h"
50#include "drv_digital_in.h"
51#include "drv_i2c_master.h"
52#include "drv_spi_master.h"
75#define MUX5_REG_DIR0 0x00
76#define MUX5_REG_DIR1 0x01
77#define MUX5_REG_DIR2 0x02
78#define MUX5_REG_DIR3 0x03
79#define MUX5_REG_SHDW0 0x10
80#define MUX5_REG_SHDW1 0x11
81#define MUX5_REG_SHDW2 0x12
82#define MUX5_REG_SHDW3 0x13
83#define MUX5_REG_CMD_A 0x14
84#define MUX5_REG_CMD_B 0x15
102#define MUX5_I2C_DRIVER 0
103#define MUX5_SPI_DRIVER 1
104#define MUX5_DRIVER_SEL MUX5_I2C_DRIVER
110#define MUX5_CHANNEL_1 0x0001
111#define MUX5_CHANNEL_2 0x0002
112#define MUX5_CHANNEL_3 0x0004
113#define MUX5_CHANNEL_4 0x0008
114#define MUX5_CHANNEL_5 0x0010
115#define MUX5_CHANNEL_6 0x0020
116#define MUX5_CHANNEL_7 0x0040
117#define MUX5_CHANNEL_8 0x0080
118#define MUX5_CHANNEL_9 0x0100
119#define MUX5_CHANNEL_10 0x0200
120#define MUX5_CHANNEL_11 0x0400
121#define MUX5_CHANNEL_12 0x0800
122#define MUX5_CHANNEL_13 0x1000
123#define MUX5_CHANNEL_14 0x2000
124#define MUX5_CHANNEL_15 0x4000
125#define MUX5_CHANNEL_16 0x8000
126#define MUX5_CHANNEL_ALL 0xFFFF
132#define MUX5_CHANNEL_STATE_HIGH_Z 0
133#define MUX5_CHANNEL_STATE_COM_A 1
134#define MUX5_CHANNEL_STATE_COM_B 2
135#define MUX5_CHANNEL_STATE_COM_AB 3
142#define MUX5_DEVICE_ADDRESS_0 0x4C
143#define MUX5_DEVICE_ADDRESS_1 0x4D
153#define MUX5_SET_DATA_SAMPLE_EDGE SET_SPI_DATA_SAMPLE_EDGE
154#define MUX5_SET_DATA_SAMPLE_MIDDLE SET_SPI_DATA_SAMPLE_MIDDLE
172#define MUX5_MAP_MIKROBUS( cfg, mikrobus ) \
173 cfg.scl = MIKROBUS( mikrobus, MIKROBUS_SCL ); \
174 cfg.sda = MIKROBUS( mikrobus, MIKROBUS_SDA ); \
175 cfg.miso = MIKROBUS( mikrobus, MIKROBUS_MISO ); \
176 cfg.mosi = MIKROBUS( mikrobus, MIKROBUS_MOSI ); \
177 cfg.sck = MIKROBUS( mikrobus, MIKROBUS_SCK ); \
178 cfg.cs = MIKROBUS( mikrobus, MIKROBUS_CS ); \
179 cfg.com_b = MIKROBUS( mikrobus, MIKROBUS_AN ); \
180 cfg.sd = MIKROBUS( mikrobus, MIKROBUS_RST ); \
181 cfg.com_a = MIKROBUS( mikrobus, MIKROBUS_INT )
197#if ( MUX5_DRIVER_SEL == MUX5_SPI_DRIVER )
199 pin_name_t chip_select;
291#if ( MUX5_DRIVER_SEL == MUX5_I2C_DRIVER )
void mux5_enable_device(mux5_t *ctx)
MUX 5 enable device function.
err_t mux5_i2c_read_register(mux5_t *ctx, uint8_t reg, uint8_t *data_out)
MUX 5 I2C read register function.
uint8_t mux5_get_com_b_pin(mux5_t *ctx)
MUX 5 get com b pin function.
void mux5_cfg_setup(mux5_cfg_t *cfg)
MUX 5 configuration object setup function.
err_t mux5_default_cfg(mux5_t *ctx)
MUX 5 default configuration function.
uint8_t mux5_get_com_a_pin(mux5_t *ctx)
MUX 5 get com a pin function.
err_t mux5_set_channels_state(mux5_t *ctx, uint16_t ch_mask, uint8_t ch_state)
MUX 5 set channels state function.
err_t mux5_init(mux5_t *ctx, mux5_cfg_t *cfg)
MUX 5 initialization function.
err_t mux5_i2c_write_register(mux5_t *ctx, uint8_t reg, uint8_t data_in)
MUX 5 I2C write register function.
void mux5_disable_device(mux5_t *ctx)
MUX 5 disable device function.
struct mux5_s mux5_t
MUX 5 Click context object.
mux5_return_value_t
MUX 5 Click return value data.
Definition mux5.h:239
@ MUX5_ERROR
Definition mux5.h:241
@ MUX5_OK
Definition mux5.h:240
This file contains SPI specific macros, functions, etc.
MUX 5 Click configuration object.
Definition mux5.h:214
pin_name_t sd
Definition mux5.h:222
uint32_t i2c_speed
Definition mux5.h:225
pin_name_t com_a
Definition mux5.h:223
spi_master_chip_select_polarity_t cs_polarity
Definition mux5.h:230
pin_name_t sck
Definition mux5.h:219
spi_master_mode_t spi_mode
Definition mux5.h:229
pin_name_t com_b
Definition mux5.h:221
pin_name_t mosi
Definition mux5.h:218
uint32_t spi_speed
Definition mux5.h:228
pin_name_t scl
Definition mux5.h:215
pin_name_t miso
Definition mux5.h:217
pin_name_t sda
Definition mux5.h:216
pin_name_t cs
Definition mux5.h:220
uint8_t i2c_address
Definition mux5.h:226
MUX 5 Click context object.
Definition mux5.h:191
uint16_t ch_b
Definition mux5.h:205
digital_in_t com_a
Definition mux5.h:195
digital_out_t sd
Definition mux5.h:192
i2c_master_t i2c
Definition mux5.h:201
uint16_t ch_a
Definition mux5.h:204
uint8_t slave_address
Definition mux5.h:202
digital_in_t com_b
Definition mux5.h:194