41#ifdef PREINIT_SUPPORTED
45#ifdef MikroCCoreVersion
46 #if MikroCCoreVersion >= 1
51#include "drv_digital_out.h"
52#include "drv_digital_in.h"
53#include "drv_spi_master.h"
67#define SPIISOLATOR_MAP_MIKROBUS( cfg, mikrobus ) \
68 cfg.miso = MIKROBUS( mikrobus, MIKROBUS_MISO ); \
69 cfg.mosi = MIKROBUS( mikrobus, MIKROBUS_MOSI ); \
70 cfg.sck = MIKROBUS( mikrobus, MIKROBUS_SCK ); \
71 cfg.cs = MIKROBUS( mikrobus, MIKROBUS_CS );
78#define SPIISOLATOR_RETVAL uint8_t
80#define SPIISOLATOR_OK 0x00
81#define SPIISOLATOR_INIT_ERROR 0xFF
88#define SPIISOLATOR_PRESSURE3_SPI_CMD_WRITE 0x7F
89#define SPIISOLATOR_PRESSURE3_SPI_CMD_READ 0x80
96#define SPIISOLATOR_PRESSURE3_REG_PSR_B2 0x00
97#define SPIISOLATOR_PRESSURE3_REG_PSR_B1 0x01
98#define SPIISOLATOR_PRESSURE3_REG_PSR_B0 0x02
99#define SPIISOLATOR_PRESSURE3_REG_TMP_B2 0x03
100#define SPIISOLATOR_PRESSURE3_REG_TMP_B1 0x04
101#define SPIISOLATOR_PRESSURE3_REG_TMP_B0 0x05
102#define SPIISOLATOR_PRESSURE3_REG_PRS_CFG 0x06
103#define SPIISOLATOR_PRESSURE3_REG_TMP_CFG 0x07
104#define SPIISOLATOR_PRESSURE3_REG_MEAS_CFG 0x08
105#define SPIISOLATOR_PRESSURE3_REG_CFG_REG 0x09
106#define SPIISOLATOR_PRESSURE3_REG_INT_STS 0x0A
107#define SPIISOLATOR_PRESSURE3_REG_FIFO_STS 0x0B
108#define SPIISOLATOR_PRESSURE3_REG_RESET 0x0C
109#define SPIISOLATOR_PRESSURE3_REG_PRODUCT_ID 0x0D
110#define SPIISOLATOR_PRESSURE3_REG_COEF_C0_MBS 0x10
111#define SPIISOLATOR_PRESSURE3_REG_COEF_C0_LBS_C1_MBS 0x11
112#define SPIISOLATOR_PRESSURE3_REG_COEF_C1_LBS 0x12
113#define SPIISOLATOR_PRESSURE3_REG_COEF_C00_MBS 0x13
114#define SPIISOLATOR_PRESSURE3_REG_COEF_C00_LSB 0x14
115#define SPIISOLATOR_PRESSURE3_REG_COEF_C00_XLSB_C10_MSB 0x15
116#define SPIISOLATOR_PRESSURE3_REG_COEF_C10_LSB 0x16
117#define SPIISOLATOR_PRESSURE3_REG_COEF_C10_XLSB 0x17
118#define SPIISOLATOR_PRESSURE3_REG_COEF_C01_MSB 0x18
119#define SPIISOLATOR_PRESSURE3_REG_COEF_C01_LSB 0x19
120#define SPIISOLATOR_PRESSURE3_REG_COEF_C11_MSB 0x1A
121#define SPIISOLATOR_PRESSURE3_REG_COEF_C11_LSB 0x1B
122#define SPIISOLATOR_PRESSURE3_REG_COEF_C20_MSB 0x1C
123#define SPIISOLATOR_PRESSURE3_REG_COEF_C20_LSB 0x1D
124#define SPIISOLATOR_PRESSURE3_REG_COEF_C21_MSB 0x1E
125#define SPIISOLATOR_PRESSURE3_REG_COEF_C21_LSB 0x1F
126#define SPIISOLATOR_PRESSURE3_REG_COEF_C30_MSB 0x20
127#define SPIISOLATOR_PRESSURE3_REG_COEF_C30_LSB 0x21
128#define SPIISOLATOR_PRESSURE3_REG_COEF_SRCE 0x28
135#define SPIISOLATOR_PRESSURE3_BIT_MASK_PM_RATE_1_PER_SEC 0x00
136#define SPIISOLATOR_PRESSURE3_BIT_MASK_PM_RATE_2_PER_SEC 0x10
137#define SPIISOLATOR_PRESSURE3_BIT_MASK_PM_RATE_4_PER_SEC 0x20
138#define SPIISOLATOR_PRESSURE3_BIT_MASK_PM_RATE_8_PER_SEC 0x30
139#define SPIISOLATOR_PRESSURE3_BIT_MASK_PM_RATE_16_PER_SEC 0x40
140#define SPIISOLATOR_PRESSURE3_BIT_MASK_PM_RATE_32_PER_SEC 0x50
141#define SPIISOLATOR_PRESSURE3_BIT_MASK_PM_RATE_64_PER_SEC 0x60
142#define SPIISOLATOR_PRESSURE3_BIT_MASK_PM_RATE_128_PER_SEC 0x70
143#define SPIISOLATOR_PRESSURE3_BIT_MASK_PM_PRC_1_PER_SEC 0x00
144#define SPIISOLATOR_PRESSURE3_BIT_MASK_PM_PRC_2_PER_SEC 0x01
145#define SPIISOLATOR_PRESSURE3_BIT_MASK_PM_PRC_4_PER_SEC 0x02
146#define SPIISOLATOR_PRESSURE3_BIT_MASK_PM_PRC_8_PER_SEC 0x03
147#define SPIISOLATOR_PRESSURE3_BIT_MASK_PM_PRC_16_PER_SEC 0x04
148#define SPIISOLATOR_PRESSURE3_BIT_MASK_PM_PRC_32_PER_SEC 0x05
149#define SPIISOLATOR_PRESSURE3_BIT_MASK_PM_PRC_64_PER_SEC 0x06
150#define SPIISOLATOR_PRESSURE3_BIT_MASK_PM_PRC_128_PER_SEC 0x07
157#define SPIISOLATOR_PRESSURE3_BIT_MASK_TMP_EXT_INTERNAL_SENSOR 0x00
158#define SPIISOLATOR_PRESSURE3_BIT_MASK_TMP_EXT_EXTERNAL_SENSOR 0x80
159#define SPIISOLATOR_PRESSURE3_BIT_MASK_TMP_RATE_1_PER_SEC 0x00
160#define SPIISOLATOR_PRESSURE3_BIT_MASK_TMP_RATE_2_PER_SEC 0x10
161#define SPIISOLATOR_PRESSURE3_BIT_MASK_TMP_RATE_4_PER_SEC 0x20
162#define SPIISOLATOR_PRESSURE3_BIT_MASK_TMP_RATE_8_PER_SEC 0x30
163#define SPIISOLATOR_PRESSURE3_BIT_MASK_TMP_RATE_16_PER_SEC 0x40
164#define SPIISOLATOR_PRESSURE3_BIT_MASK_TMP_RATE_32_PER_SEC 0x50
165#define SPIISOLATOR_PRESSURE3_BIT_MASK_TMP_RATE_64_PER_SEC 0x60
166#define SPIISOLATOR_PRESSURE3_BIT_MASK_TMP_RATE_128_PER_SEC 0x70
167#define SPIISOLATOR_PRESSURE3_BIT_MASK_TMP_PRC_1_PER_SEC 0x00
168#define SPIISOLATOR_PRESSURE3_BIT_MASK_TMP_PRC_2_PER_SEC 0x01
169#define SPIISOLATOR_PRESSURE3_BIT_MASK_TMP_PRC_4_PER_SEC 0x02
170#define SPIISOLATOR_PRESSURE3_BIT_MASK_TMP_PRC_8_PER_SEC 0x03
171#define SPIISOLATOR_PRESSURE3_BIT_MASK_TMP_PRC_16_PER_SEC 0x04
172#define SPIISOLATOR_PRESSURE3_BIT_MASK_TMP_PRC_32_PER_SEC 0x05
173#define SPIISOLATOR_PRESSURE3_BIT_MASK_TMP_PRC_64_PER_SEC 0x06
174#define SPIISOLATOR_PRESSURE3_BIT_MASK_TMP_PRC_128_PER_SEC 0x07
181#define SPIISOLATOR_PRESSURE3_BIT_MASK_MEAS_CFG_COEF_RDY_AVB 0x80
182#define SPIISOLATOR_PRESSURE3_BIT_MASK_MEAS_CFG_COEF_RDY_NO_AVB 0x00
183#define SPIISOLATOR_PRESSURE3_BIT_MASK_MEAS_CFG_SENSOR_RDY_CMP 0x40
184#define SPIISOLATOR_PRESSURE3_BIT_MASK_MEAS_CFG_SENSOR_RDY_NO_CMP 0x00
185#define SPIISOLATOR_PRESSURE3_BIT_MASK_MEAS_CFG_TMP_RDY 0x20
186#define SPIISOLATOR_PRESSURE3_BIT_MASK_MEAS_CFG_PRS_RDY 0x10
187#define SPIISOLATOR_PRESSURE3_BIT_MASK_MEAS_CFG_MEAS_CTRL_IDLE 0x00
188#define SPIISOLATOR_PRESSURE3_BIT_MASK_MEAS_CFG_MEAS_CTRL_PRS 0x01
189#define SPIISOLATOR_PRESSURE3_BIT_MASK_MEAS_CFG_MEAS_CTRL_TMP 0x02
190#define SPIISOLATOR_PRESSURE3_BIT_MASK_MEAS_CFG_MEAS_CTRL_CNT_PRS 0x05
191#define SPIISOLATOR_PRESSURE3_BIT_MASK_MEAS_CFG_MEAS_CTRL_CNT_TMP 0x06
192#define SPIISOLATOR_PRESSURE3_BIT_MASK_MEAS_CFG_MEAS_CTRL_CNT_PRS_TMP 0x07
199#define SPIISOLATOR_PRESSURE3_BIT_MASK_CFG_REG_INT_HL_LOW 0x00
200#define SPIISOLATOR_PRESSURE3_BIT_MASK_CFG_REG_INT_HL_HIGH 0x80
201#define SPIISOLATOR_PRESSURE3_BIT_MASK_CFG_REG_INT_FIFO_DISABLE 0x00
202#define SPIISOLATOR_PRESSURE3_BIT_MASK_CFG_REG_INT_FIFO_ENABLE 0x40
203#define SPIISOLATOR_PRESSURE3_BIT_MASK_CFG_REG_INT_TMP_DISABLE 0x00
204#define SPIISOLATOR_PRESSURE3_BIT_MASK_CFG_REG_INT_TMP_ENABLE 0x20
205#define SPIISOLATOR_PRESSURE3_BIT_MASK_CFG_REG_INT_PRS_DISABLE 0x00
206#define SPIISOLATOR_PRESSURE3_BIT_MASK_CFG_REG_INT_PRS_ENABLE 0x10
207#define SPIISOLATOR_PRESSURE3_BIT_MASK_CFG_REG_T_SHIFT_NO_SHIFT 0x00
208#define SPIISOLATOR_PRESSURE3_BIT_MASK_CFG_REG_T_SHIFT_SHIFT 0x08
209#define SPIISOLATOR_PRESSURE3_BIT_MASK_CFG_REG_P_SHIFT_NO_SHIFT 0x00
210#define SPIISOLATOR_PRESSURE3_BIT_MASK_CFG_REG_P_SHIFT_SHIFT 0x04
211#define SPIISOLATOR_PRESSURE3_BIT_MASK_CFG_REG_FIFO_EN_DISABLE 0x00
212#define SPIISOLATOR_PRESSURE3_BIT_MASK_CFG_REG_FIFO_EN_ENABLE 0x02
213#define SPIISOLATOR_PRESSURE3_BIT_MASK_CFG_REG_SPI_MODE_DISABLE 0x00
214#define SPIISOLATOR_PRESSURE3_BIT_MASK_CFG_REG_SPI_MODE_ENABLE 0x01
221#define SPIISOLATOR_PRESSURE3_BIT_MASK_INT_STS_INT_FIFO_FULL_NO_ACTIVE 0x00
222#define SPIISOLATOR_PRESSURE3_BIT_MASK_INT_STS_INT_FIFO_FULL_ACTIVE 0x04
223#define SPIISOLATOR_PRESSURE3_BIT_MASK_INT_STS_INT_TMP_NO_ACTIVE 0x00
224#define SPIISOLATOR_PRESSURE3_BIT_MASK_INT_STS_INT_TMP_ACTIVE 0x02
225#define SPIISOLATOR_PRESSURE3_BIT_MASK_INT_STS_INT_PRS_NO_ACTIVE 0x00
226#define SPIISOLATOR_PRESSURE3_BIT_MASK_INT_STS_INT_PRS_ACTIVE 0x01
233#define SPIISOLATOR_PRESSURE3_BIT_MASK_FIFO_STS_FIFO_FULL_NO 0x00
234#define SPIISOLATOR_PRESSURE3_BIT_MASK_FIFO_STS_FIFO_FULL_FULL 0x02
235#define SPIISOLATOR_PRESSURE3_BIT_MASK_FIFO_STS_FIFO_EMPTY_NO 0x00
236#define SPIISOLATOR_PRESSURE3_BIT_MASK_FIFO_STS_FIFO_EMPTY_EMPTY 0x01
243#define SPIISOLATOR_PRESSURE3_BIT_MASK_RESET_SOFT_RST 0x09
250#define SPIISOLATOR_PRESSURE3_BIT_MASK_TMP_COEF_SRCE_INTERNAL_SENSOR 0x00
251#define SPIISOLATOR_PRESSURE3_BIT_MASK_TMP_COEF_SRCE_EXTERNAL_SENSOR 0x80
#define SPIISOLATOR_RETVAL
Definition spiisolator.h:78
uint8_t spiisolator_read_byte(spiisolator_t *ctx, uint8_t reg_address, uint8_t read_cmd)
Read the byte of data function.
void spiisolator_cfg_setup(spiisolator_cfg_t *cfg)
Config Object Initialization function.
uint16_t spiisolator_read_data(spiisolator_t *ctx, uint8_t reg_address, uint8_t read_cmd)
Read 16-bit data function.
void spiisolator_write_bytes(spiisolator_t *ctx, uint8_t reg_address, uint8_t write_cmd, uint8_t *write_data, uint16_t n_bytes)
Sequential write function.
void spiisolator_read_bytes(spiisolator_t *ctx, uint8_t reg_address, uint8_t read_cmd, uint8_t *read_data, uint16_t n_bytes)
Sequential read function.
void spiisolator_generic_transfer(spiisolator_t *ctx, uint8_t *wr_buf, uint16_t wr_len, uint8_t *rd_buf, uint16_t rd_len)
Generic transfer function.
void spiisolator_write_data(spiisolator_t *ctx, uint8_t reg_address, uint8_t write_cmd, uint16_t write_data)
Write 16-bit data function.
SPIISOLATOR_RETVAL spiisolator_init(spiisolator_t *ctx, spiisolator_cfg_t *cfg)
Initialization function.
void spiisolator_write_byte(spiisolator_t *ctx, uint8_t reg_address, uint8_t write_cmd, uint8_t write_data)
Write the byte of data function.
void spiisolator_write_cmd(spiisolator_t *ctx, uint8_t cmd, uint8_t tx_data)
Definition spiisolator.h:265
uint8_t cmd
Definition spiisolator.h:268
uint8_t reg_address
Definition spiisolator.h:267
Click configuration structure definition.
Definition spiisolator.h:291
spi_master_chip_select_polarity_t cs_polarity
Definition spiisolator.h:303
pin_name_t sck
Definition spiisolator.h:296
spi_master_mode_t spi_mode
Definition spiisolator.h:302
pin_name_t mosi
Definition spiisolator.h:295
uint32_t spi_speed
Definition spiisolator.h:301
pin_name_t miso
Definition spiisolator.h:294
pin_name_t cs
Definition spiisolator.h:297
Click ctx object definition.
Definition spiisolator.h:277
digital_out_t cs
Definition spiisolator.h:278
spi_master_t spi
Definition spiisolator.h:282
pin_name_t chip_select
Definition spiisolator.h:283