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 SPIEXTEND_REG_CONFIG 0x00
75#define SPIEXTEND_REG_STATUS 0x01
76#define SPIEXTEND_REG_EVENT 0x02
77#define SPIEXTEND_REG_INT_EN 0x03
78#define SPIEXTEND_REG_FAULT 0x04
79#define SPIEXTEND_REG_WORD_LENGTH 0x05
80#define SPIEXTEND_REG_SCRATCH 0x06
86#define SPIEXTEND_ACCEL14_REG_WHO_AM_I 0x0F
87#define SPIEXTEND_ACCEL14_REG_CTRL1_XL 0x10
88#define SPIEXTEND_ACCEL14_REG_CTRL3_C 0x12
89#define SPIEXTEND_ACCEL14_REG_OUT_TEMP_L 0x20
90#define SPIEXTEND_ACCEL14_REG_OUT_TEMP_H 0x21
91#define SPIEXTEND_ACCEL14_REG_OUTX_L_A 0x28
92#define SPIEXTEND_ACCEL14_REG_OUTX_H_A 0x29
93#define SPIEXTEND_ACCEL14_REG_OUTY_L_A 0x2A
94#define SPIEXTEND_ACCEL14_REG_OUTY_H_A 0x2B
95#define SPIEXTEND_ACCEL14_REG_OUTZ_L_A 0x2C
96#define SPIEXTEND_ACCEL14_REG_OUTZ_H_A 0x2D
113#define SPIEXTEND_STATUS_ACTIVE 0x00
114#define SPIEXTEND_STATUS_INACTIVE 0x01
120#define SPIEXTEND_ACCEL14_CTRL1_XL_POWER_UP 0xA0
121#define SPIEXTEND_ACCEL14_CTRL1_XL_HIGH_RES_FS 0x00
122#define SPIEXTEND_ACCEL14_CTRL1_XL_GSEL_4G 0x08
123#define SPIEXTEND_ACCEL14_CTRL3_C_BOOT_NORMAL 0x00
124#define SPIEXTEND_ACCEL14_CTRL3_C_BDU_READ_UPDATE 0x40
125#define SPIEXTEND_ACCEL14_CTRL3_C_INT_ACTIVE_HIGH 0x00
126#define SPIEXTEND_ACCEL14_CTRL3_C_PP_OD_PUSH_PULL 0x00
127#define SPIEXTEND_ACCEL14_CTRL3_C_SIM_SPI_4_WIRE 0x00
128#define SPIEXTEND_ACCEL14_CTRL3_C_IF_INC_ENABLE 0x04
129#define SPIEXTEND_ACCEL14_CTRL3_C_SW_RESET_DIS 0x00
135#define SPIEXTEND_ACCEL14_SPI_WRITE 0x00
136#define SPIEXTEND_ACCEL14_SPI_READ 0x80
142#define SPIEXTEND_CMD_CLEAR_EVENT 0x00
148#define SPIEXTEND_SLAVE_SELECT_SS1 0x01
149#define SPIEXTEND_SLAVE_SELECT_SS2 0x02
150#define SPIEXTEND_SLAVE_SELECT_SS3 0x03
156#define SPIEXTEND_PIN_STATE_LOW 0x00
157#define SPIEXTEND_PIN_STATE_HIGH 0x01
163#define SPIEXTEND_SPI_WRITE 0x00
164#define SPIEXTEND_SPI_READ 0x01
174#define SPIEXTEND_SET_DATA_SAMPLE_EDGE SET_SPI_DATA_SAMPLE_EDGE
175#define SPIEXTEND_SET_DATA_SAMPLE_MIDDLE SET_SPI_DATA_SAMPLE_MIDDLE
193#define SPIEXTEND_MAP_MIKROBUS( cfg, mikrobus ) \
194 cfg.miso = MIKROBUS( mikrobus, MIKROBUS_MISO ); \
195 cfg.mosi = MIKROBUS( mikrobus, MIKROBUS_MOSI ); \
196 cfg.sck = MIKROBUS( mikrobus, MIKROBUS_SCK ); \
197 cfg.cs = MIKROBUS( mikrobus, MIKROBUS_CS ); \
198 cfg.ss3 = MIKROBUS( mikrobus, MIKROBUS_AN ); \
199 cfg.ss2 = MIKROBUS( mikrobus, MIKROBUS_RST ); \
200 cfg.ssc = MIKROBUS( mikrobus, MIKROBUS_PWM ); \
201 cfg.int_pin = MIKROBUS( mikrobus, MIKROBUS_INT )
uint8_t spiextend_check_int(spiextend_t *ctx)
SPI Extend check interrupt status function.
void spiextend_rmt_write(spiextend_t *ctx, uint8_t reg, uint8_t tx_data, uint8_t sel_slave)
SPI Extend generic write data in Remote Mode function.
err_t spiextend_default_cfg(spiextend_t *ctx)
SPI Extend default configuration function.
void spiextend_cfg_setup(spiextend_cfg_t *cfg)
SPI Extend configuration object setup function.
void spiextend_rmt_spi_read(spiextend_t *ctx, uint8_t *p_rx_data, uint16_t n_bytes)
SPI Extend generic SPI read data in Remote Mode function.
void spiextend_get_event(spiextend_t *ctx, spiextend_event_data_t *event_data)
SPI Extend get the event function.
void spiextend_set_ss2(spiextend_t *ctx, uint8_t en_rst)
SPI Extend set SS2 pin state function.
void spiextend_set_ss3(spiextend_t *ctx, uint8_t en_an)
SPI Extend set SS3 pin state function.
err_t spiextend_generic_write(spiextend_t *ctx, uint8_t reg, uint8_t data_in)
SPI Extend data writing function.
uint8_t spiextend_get_word_length(spiextend_t *ctx)
SPI Extend get the word length function.
void spiextend_enable_int(spiextend_t *ctx, spiextend_event_data_t event_data)
SPI Extend enable int function.
void spiextend_set_scratch(spiextend_t *ctx, uint8_t scratch)
SPI Extend set scratch function.
void spiextend_rmt_multi_write(spiextend_t *ctx, uint8_t reg, uint8_t *p_tx_data, uint16_t n_bytes, uint8_t sel_slave)
SPI Extend generic multi write data in Remote Mode function.
uint8_t spiextend_rmt_read(spiextend_t *ctx, uint8_t reg, uint8_t sel_slave)
SPI Extend generic read data in Remote Mode function.
void spiextend_rmt_multi_read(spiextend_t *ctx, uint8_t reg, uint8_t *p_rx_data, uint8_t n_bytes, uint8_t sel_slave)
SPI Extend generic multi read data in Remote Mode function.
void spiextend_clear_event(spiextend_t *ctx)
SPI Extend clear the event function.
void spiextend_set_ss1(spiextend_t *ctx, uint8_t en_cs)
SPI Extend set SS1 pin state function.
void spiextend_get_status(spiextend_t *ctx, spiextend_status_data_t *status_data)
SPI Extend get the status function.
err_t spiextend_init(spiextend_t *ctx, spiextend_cfg_t *cfg)
SPI Extend initialization function.
void spiextend_set_config(spiextend_t *ctx, spiextend_config_data_t config_data)
SPI Extend set the configuration function.
void spiextend_get_config(spiextend_t *ctx, spiextend_config_data_t *config_data)
SPI Extend get the configuration function.
void spiextend_get_fault(spiextend_t *ctx, spiextend_fault_data_t *fault_data)
SPI Extend get the fault state function.
uint8_t spiextend_get_scratch(spiextend_t *ctx)
SPI Extend get scratch function.
err_t spiextend_generic_read(spiextend_t *ctx, uint8_t reg, uint8_t *data_out)
SPI Extend data reading function.
void spiextend_set_word_length(spiextend_t *ctx, uint8_t word_length)
SPI Extend set the word length function.
void spiextend_rmt_spi_write(spiextend_t *ctx, uint8_t *p_tx_data, uint16_t n_bytes)
SPI Extend generic SPI write data in Remote Mode function.
This file contains SPI specific macros, functions, etc.
spiextend_return_value_t
SPI Extend Click return value data.
Definition spiextend.h:311
@ SPIEXTEND_OK
Definition spiextend.h:312
@ SPIEXTEND_ERROR
Definition spiextend.h:313
SPI Extend Click configuration object.
Definition spiextend.h:232
pin_name_t ss3
Definition spiextend.h:240
spi_master_chip_select_polarity_t cs_polarity
Definition spiextend.h:248
pin_name_t sck
Definition spiextend.h:236
spi_master_mode_t spi_mode
Definition spiextend.h:247
pin_name_t mosi
Definition spiextend.h:235
uint32_t spi_speed
Definition spiextend.h:246
pin_name_t int_pin
Definition spiextend.h:243
pin_name_t ss2
Definition spiextend.h:241
pin_name_t miso
Definition spiextend.h:234
pin_name_t ssc
Definition spiextend.h:242
pin_name_t cs
Definition spiextend.h:237
SPI Extend Click configuration data.
Definition spiextend.h:257
uint8_t rem_ss2_pha
Definition spiextend.h:261
uint8_t rem_ss2_pol
Definition spiextend.h:260
uint8_t rem_ss3_pol
Definition spiextend.h:258
uint8_t rem_ss3_pha
Definition spiextend.h:259
uint8_t rem_ss1_pha
Definition spiextend.h:263
uint8_t rem_ss1_pol
Definition spiextend.h:262
SPI Extend Click event data.
Definition spiextend.h:285
uint8_t e_link_good
Definition spiextend.h:286
uint8_t e_fault
Definition spiextend.h:288
uint8_t e_link_lost
Definition spiextend.h:287
SPI Extend Click Fault data.
Definition spiextend.h:297
uint8_t rmt_spi_fault
Definition spiextend.h:300
uint8_t link_fault
Definition spiextend.h:299
uint8_t tx_buf_overflow
Definition spiextend.h:301
uint8_t spi_write_fault
Definition spiextend.h:298
uint8_t tx_buf_underflow
Definition spiextend.h:302
SPI Extend Click status data.
Definition spiextend.h:272
uint8_t speed_idx
Definition spiextend.h:276
uint8_t nlink
Definition spiextend.h:273
uint8_t nint
Definition spiextend.h:274
uint8_t rmt_nint
Definition spiextend.h:275
SPI Extend Click context object.
Definition spiextend.h:211
spi_master_t spi
Definition spiextend.h:221
digital_in_t int_pin
Definition spiextend.h:218
digital_out_t ssc
Definition spiextend.h:215
digital_out_t ss3
Definition spiextend.h:213
pin_name_t chip_select
Definition spiextend.h:223
digital_out_t ss2
Definition spiextend.h:214