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_spi_master.h"
74#define SOLIDSWITCH2_REG_CHIP_ID 0x00
75#define SOLIDSWITCH2_REG_CFG_0 0x01
76#define SOLIDSWITCH2_REG_CFG_1 0x02
77#define SOLIDSWITCH2_REG_CFG_2 0x03
78#define SOLIDSWITCH2_REG_BIM 0x04
79#define SOLIDSWITCH2_REG_RESERVED_1 0x05
80#define SOLIDSWITCH2_REG_PWM_SPI 0x06
81#define SOLIDSWITCH2_REG_MAP_IN0 0x07
82#define SOLIDSWITCH2_REG_MAP_IN1 0x08
83#define SOLIDSWITCH2_REG_MAP_PWM 0x09
84#define SOLIDSWITCH2_REG_PWM_SEL 0x0A
85#define SOLIDSWITCH2_REG_PWM_GEN_DC 0x0B
86#define SOLIDSWITCH2_REG_PWM_LED_DC 0x0C
87#define SOLIDSWITCH2_REG_DIAG_OFF_EN 0x0D
88#define SOLIDSWITCH2_REG_DIAG_OPL_ON_EN 0x0E
89#define SOLIDSWITCH2_REG_DIAG_OVC_OVT_RLW 0x0F
90#define SOLIDSWITCH2_REG_STA_0 0x10
91#define SOLIDSWITCH2_REG_STA_1 0x11
92#define SOLIDSWITCH2_REG_DIAG_OVC_OVT 0x12
93#define SOLIDSWITCH2_REG_DIAG_OPL_OFF 0x13
94#define SOLIDSWITCH2_REG_DIAG_OPL_ON 0x14
95#define SOLIDSWITCH2_REG_DIAG_SHD 0x15
113#define SOLIDSWITCH2_CHIP_ID 0x56
119#define SOLIDSWITCH2_CFG_0_OUT7 0x80
120#define SOLIDSWITCH2_CFG_0_OUT6 0x40
121#define SOLIDSWITCH2_CFG_0_OUT5 0x20
122#define SOLIDSWITCH2_CFG_0_OUT4 0x10
123#define SOLIDSWITCH2_CFG_0_OUT3 0x08
124#define SOLIDSWITCH2_CFG_0_OUT2 0x04
125#define SOLIDSWITCH2_CFG_0_DIS_EN 0x02
126#define SOLIDSWITCH2_CFG_0_NRES_EN 0x01
132#define SOLIDSWITCH2_CFG_1_RST 0x80
133#define SOLIDSWITCH2_CFG_1_ACT 0x40
134#define SOLIDSWITCH2_CFG_1_PWM_DIV_LED_122p5Hz 0x00
135#define SOLIDSWITCH2_CFG_1_PWM_DIV_LED_245p1Hz 0x01
136#define SOLIDSWITCH2_CFG_1_PWM_DIV_LED_490p2Hz 0x02
137#define SOLIDSWITCH2_CFG_1_PWM_DIV_LED_980p4Hz 0x03
143#define SOLIDSWITCH2_CFG_2_FR_ADJ_NO_FREQ_ADJ 0x00
144#define SOLIDSWITCH2_CFG_2_FR_ADJ_MINUS_15_PCT 0x04
145#define SOLIDSWITCH2_CFG_2_FR_ADJ_PLUS_15_PCT 0x08
146#define SOLIDSWITCH2_CFG_2_PWM_DIV_GEN_122p5Hz 0x00
147#define SOLIDSWITCH2_CFG_2_PWM_DIV_GEN_245p1Hz 0x01
148#define SOLIDSWITCH2_CFG_2_PWM_DIV_GEN_490p2Hz 0x02
149#define SOLIDSWITCH2_CFG_2_PWM_DIV_GEN_980p4Hz 0x03
155#define SOLIDSWITCH2_OUT7 0x80
156#define SOLIDSWITCH2_OUT6 0x40
157#define SOLIDSWITCH2_OUT5 0x20
158#define SOLIDSWITCH2_OUT4 0x10
159#define SOLIDSWITCH2_OUT3 0x08
160#define SOLIDSWITCH2_OUT2 0x04
161#define SOLIDSWITCH2_OUT1 0x02
162#define SOLIDSWITCH2_OUT0 0x01
163#define SOLIDSWITCH2_OUT_NONE 0x00
169#define SOLIDSWITCH2_MAX_DUTY_CYCLE 0xFF
170#define SOLIDSWITCH2_MIN_DUTY_CYCLE 0x00
176#define SOLIDSWITCH2_SPI_RW_BIT 0x80
177#define SOLIDSWITCH2_SPI_ERROR_BIT 0x80
178#define SOLIDSWITCH2_ADDRESS_BIT_MASK 0x1F
179#define SOLIDSWITCH2_ODD_PARITY 0x01
180#define SOLIDSWITCH2_SPI_ERROR_BIT 0x80
190#define SOLIDSWITCH2_SET_DATA_SAMPLE_EDGE SET_SPI_DATA_SAMPLE_EDGE
191#define SOLIDSWITCH2_SET_DATA_SAMPLE_MIDDLE SET_SPI_DATA_SAMPLE_MIDDLE
209#define SOLIDSWITCH2_MAP_MIKROBUS( cfg, mikrobus ) \
210 cfg.miso = MIKROBUS( mikrobus, MIKROBUS_MISO ); \
211 cfg.mosi = MIKROBUS( mikrobus, MIKROBUS_MOSI ); \
212 cfg.sck = MIKROBUS( mikrobus, MIKROBUS_SCK ); \
213 cfg.cs = MIKROBUS( mikrobus, MIKROBUS_CS ); \
214 cfg.idle = MIKROBUS( mikrobus, MIKROBUS_AN ); \
215 cfg.in0 = MIKROBUS( mikrobus, MIKROBUS_PWM ); \
216 cfg.in1 = MIKROBUS( mikrobus, MIKROBUS_INT )
void solidswitch2_toggle_in0_pin(solidswitch2_t *ctx)
SolidSwitch 2 toggle in0 pin function.
err_t solidswitch2_default_cfg(solidswitch2_t *ctx)
SolidSwitch 2 default configuration function.
err_t solidswitch2_check_communication(solidswitch2_t *ctx)
SolidSwitch 2 check communication function.
err_t solidswitch2_read_register(solidswitch2_t *ctx, uint8_t reg, uint8_t *data_out)
SolidSwitch 2 data reading function.
err_t solidswitch2_init(solidswitch2_t *ctx, solidswitch2_cfg_t *cfg)
SolidSwitch 2 initialization function.
void solidswitch2_set_in1_pin(solidswitch2_t *ctx, uint8_t state)
SolidSwitch 2 set in1 pin function.
void solidswitch2_cfg_setup(solidswitch2_cfg_t *cfg)
SolidSwitch 2 configuration object setup function.
err_t solidswitch2_soft_reset(solidswitch2_t *ctx)
SolidSwitch 2 soft reset function.
void solidswitch2_toggle_in1_pin(solidswitch2_t *ctx)
SolidSwitch 2 toggle in1 pin function.
err_t solidswitch2_write_register(solidswitch2_t *ctx, uint8_t reg, uint8_t data_in)
SolidSwitch 2 data writing function.
void solidswitch2_set_in0_pin(solidswitch2_t *ctx, uint8_t state)
SolidSwitch 2 set in0 pin function.
void solidswitch2_set_idle_pin(solidswitch2_t *ctx, uint8_t state)
SolidSwitch 2 set idle pin function.
solidswitch2_return_value_t
SolidSwitch 2 Click return value data.
Definition solidswitch2.h:268
@ SOLIDSWITCH2_ERROR
Definition solidswitch2.h:270
@ SOLIDSWITCH2_OK
Definition solidswitch2.h:269
This file contains SPI specific macros, functions, etc.
SolidSwitch 2 Click configuration object.
Definition solidswitch2.h:244
pin_name_t in0
Definition solidswitch2.h:253
pin_name_t idle
Definition solidswitch2.h:252
spi_master_chip_select_polarity_t cs_polarity
Definition solidswitch2.h:259
pin_name_t sck
Definition solidswitch2.h:248
spi_master_mode_t spi_mode
Definition solidswitch2.h:258
pin_name_t mosi
Definition solidswitch2.h:247
uint32_t spi_speed
Definition solidswitch2.h:257
pin_name_t in1
Definition solidswitch2.h:254
pin_name_t miso
Definition solidswitch2.h:246
pin_name_t cs
Definition solidswitch2.h:249
SolidSwitch 2 Click context object.
Definition solidswitch2.h:226
spi_master_t spi
Definition solidswitch2.h:233
digital_out_t idle
Definition solidswitch2.h:228
pin_name_t chip_select
Definition solidswitch2.h:235
digital_out_t in1
Definition solidswitch2.h:230
digital_out_t in0
Definition solidswitch2.h:229