42#ifdef PREINIT_SUPPORTED
46#ifdef MikroCCoreVersion
47 #if MikroCCoreVersion >= 1
52#include "drv_digital_out.h"
53#include "drv_digital_in.h"
54#include "drv_spi_master.h"
67#define RS232SPI_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 ); \
72 cfg.sdn = MIKROBUS( mikrobus, MIKROBUS_RST ); \
73 cfg.irq = MIKROBUS( mikrobus, MIKROBUS_INT )
80#define RS232SPI_RETVAL uint8_t
82#define RS232SPI_OK 0x00
83#define RS232SPI_INIT_ERROR 0xFF
90#define RS232SPI_CMD_WRITE_CONF 0xC000
91#define RS232SPI_CMD_READ_CONF 0x4000
92#define RS232SPI_CMD_WRITE_DATA 0x8000
93#define RS232SPI_CMD_READ_DATA 0x0000
100#define RS232SPI_CONF_R 0x8000
101#define RS232SPI_CONF_T 0x4000
102#define RS232SPI_CONF_RM 0x0400
104#define RS232SPI_CONF_FEN 0x2000
105#define RS232SPI_CONF_SHDN 0x1000
106#define RS232SPI_CONF_TM 0x0800
107#define RS232SPI_CONF_PM 0x0200
108#define RS232SPI_CONF_RAM 0x0100
109#define RS232SPI_CONF_IR 0x0080
110#define RS232SPI_CONF_ST 0x0040
111#define RS232SPI_CONF_PE 0x0020
112#define RS232SPI_CONF_L 0x0010
113#define RS232SPI_BAUD 0x000F
115#define RS232SPI_CONF_TE 0x400
116#define RS232SPI_CONF_RA_FE 0x400
117#define RS232SPI_CONF_RTS 0x0200
118#define RS232SPI_CONF_CTS 0x0200
119#define RS232SPI_CONF_PT 0x0100
120#define RS232SPI_CONF_DATA 0x00FF
127#define RS232SPI_CONF_BAUD_X1_115200 0x0000
128#define RS232SPI_CONF_BAUD_X1_57600 0x0001
129#define RS232SPI_CONF_BAUD_X1_38400 0x0008
130#define RS232SPI_CONF_BAUD_X1_19200 0x0009
131#define RS232SPI_CONF_BAUD_X1_9600 0x000A
132#define RS232SPI_CONF_BAUD_X1_4800 0x000B
133#define RS232SPI_CONF_BAUD_X1_2400 0x000C
134#define RS232SPI_CONF_BAUD_X1_1200 0x000D
135#define RS232SPI_CONF_BAUD_X1_600 0x000E
136#define RS232SPI_CONF_BAUD_X1_300 0x000F
143#define RS232SPI_CONF_BAUD_X2_230400 0x0000
144#define RS232SPI_CONF_BAUD_X2_115200 0x0001
145#define RS232SPI_CONF_BAUD_X2_57600 0x0002
146#define RS232SPI_CONF_BAUD_X2_38400 0x0009
147#define RS232SPI_CONF_BAUD_X2_19200 0x000A
148#define RS232SPI_CONF_BAUD_X2_9600 0x000B
149#define RS232SPI_CONF_BAUD_X2_4800 0x000C
150#define RS232SPI_CONF_BAUD_X2_2400 0x000D
151#define RS232SPI_CONF_BAUD_X2_1200 0x000E
152#define RS232SPI_CONF_BAUD_X2_600 0x000F
#define RS232SPI_RETVAL
Definition rs232spi.h:80
void rs232spi_default_cfg(rs232spi_t *ctx, uint32_t speed)
Click Default Configuration function.
uint8_t rs232spi_reg_read(rs232spi_t *ctx)
Register read function.
uint8_t rs232spi_digital_read_int(rs232spi_t *ctx)
Digital read interrupt function.
void rs232spi_cfg_setup(rs232spi_cfg_t *cfg)
Config Object Initialization function.
void rs232spi_reg_write(rs232spi_t *ctx, uint16_t write_data)
Register write function.
void rs232spi_flush(rs232spi_t *ctx)
Flush function.
uint16_t rs232spi_read_cfg(rs232spi_t *ctx)
Read configuration function.
void rs232spi_data_write(rs232spi_t *ctx, uint8_t write_data)
Data write function.
uint16_t rs232spi_check_busy(rs232spi_t *ctx)
Check if busy function.
void rs232spi_digital_write_rst(rs232spi_t *ctx, uint8_t signal)
Digital write reset function.
uint16_t rs232spi_data_ready(rs232spi_t *ctx)
Data ready function.
uint16_t rs232spi_transfer(rs232spi_t *ctx, uint16_t write_data)
SPI transfer function.
RS232SPI_RETVAL rs232spi_init(rs232spi_t *ctx, rs232spi_cfg_t *cfg)
Initialization function.
Click configuration structure definition.
Definition rs232spi.h:187
pin_name_t irq
Definition rs232spi.h:198
spi_master_chip_select_polarity_t cs_polarity
Definition rs232spi.h:204
pin_name_t sck
Definition rs232spi.h:192
spi_master_mode_t spi_mode
Definition rs232spi.h:203
pin_name_t mosi
Definition rs232spi.h:191
uint32_t spi_speed
Definition rs232spi.h:202
pin_name_t miso
Definition rs232spi.h:190
pin_name_t sdn
Definition rs232spi.h:197
pin_name_t cs
Definition rs232spi.h:193
Click ctx object definition.
Definition rs232spi.h:166
digital_out_t cs
Definition rs232spi.h:170
spi_master_t spi
Definition rs232spi.h:178
digital_in_t irq
Definition rs232spi.h:174
digital_out_t sdn
Definition rs232spi.h:169
pin_name_t chip_select
Definition rs232spi.h:179