28#ifndef RSTRANSCEIVER_H
29#define RSTRANSCEIVER_H
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"
74#define RSTRANSCEIVER_REG_INPUT_PORT 0x00
75#define RSTRANSCEIVER_REG_OUTPUT_PORT 0x01
76#define RSTRANSCEIVER_REG_POLARITY_INV 0x02
77#define RSTRANSCEIVER_REG_CONFIG 0x03
78#define RSTRANSCEIVER_REG_SPECIAL_FUNC 0x50
96#define RSTRANSCEIVER_NO_PIN_BIT_MASK 0x00
97#define RSTRANSCEIVER_PIN_0_BIT_MASK 0x01
98#define RSTRANSCEIVER_PIN_1_BIT_MASK 0x02
99#define RSTRANSCEIVER_PIN_2_BIT_MASK 0x04
100#define RSTRANSCEIVER_PIN_3_BIT_MASK 0x08
101#define RSTRANSCEIVER_ALL_PINS_BIT_MASK 0x0F
107#define RSTRANSCEIVER_OUTPUT_DIRECTION 0x00
108#define RSTRANSCEIVER_INPUT_DIRECTION 0x01
114#define RSTRANSCEIVER_SPECIAL_FUNC_P3_AS_INT 0x80
115#define RSTRANSCEIVER_SPECIAL_FUNC_PU_DISABLED 0x40
121#define RSTRANSCEIVER_SLEW_DISABLE 0x00
122#define RSTRANSCEIVER_SLEW_ENABLE 0x01
128#define RSTRANSCEIVER_OP_MODE_LOOPBACK 0x00
129#define RSTRANSCEIVER_OP_MODE_RS232 0x01
130#define RSTRANSCEIVER_OP_MODE_HALF_DUPLEX 0x02
131#define RSTRANSCEIVER_OP_MODE_FULL_DUPLEX 0x03
132#define RSTRANSCEIVER_OP_MODE_PIN_BIT_MASK 0x09
138#define RSTRANSCEIVER_DIR_DISABLE 0x00
139#define RSTRANSCEIVER_DIR_T1_EN 0x01
140#define RSTRANSCEIVER_DIR_T1_EN_R1_DIS 0x01
141#define RSTRANSCEIVER_DIR_PIN_BIT_MASK 0x0E
147#define RSTRANSCEIVER_TERM_DISABLE 0x00
148#define RSTRANSCEIVER_TERM_ENABLE 0x01
149#define RSTRANSCEIVER_TERM_DIS_PIN_BIT_MASK 0x07
150#define RSTRANSCEIVER_TERM_EN_PIN_BIT_MASK 0x08
157#define RSTRANSCEIVER_TX_DRV_BUFFER_SIZE 100
158#define RSTRANSCEIVER_RX_DRV_BUFFER_SIZE 300
165#define RSTRANSCEIVER_DEVICE_ADDRESS 0x41
183#define RSTRANSCEIVER_MAP_MIKROBUS( cfg, mikrobus ) \
184 cfg.scl = MIKROBUS( mikrobus, MIKROBUS_SCL ); \
185 cfg.sda = MIKROBUS( mikrobus, MIKROBUS_SDA ); \
186 cfg.cs = MIKROBUS( mikrobus, MIKROBUS_CS ); \
187 cfg.rst = MIKROBUS( mikrobus, MIKROBUS_RST ); \
188 cfg.slw = MIKROBUS( mikrobus, MIKROBUS_PWM ); \
189 cfg.tx_pin = MIKROBUS( mikrobus, MIKROBUS_TX ); \
190 cfg.rx_pin = MIKROBUS( mikrobus, MIKROBUS_RX ); \
191 cfg.cst = MIKROBUS( mikrobus, MIKROBUS_INT )
#define RSTRANSCEIVER_TX_DRV_BUFFER_SIZE
RS Transceiver driver buffer size.
Definition rstransceiver.h:157
#define RSTRANSCEIVER_RX_DRV_BUFFER_SIZE
Definition rstransceiver.h:158
void rstransceiver_set_slew(rstransceiver_t *ctx, uint8_t slew)
RS Transceiver sets the slew limit function.
void rstransceiver_cfg_setup(rstransceiver_cfg_t *cfg)
RS Transceiver configuration object setup function.
err_t rstransceiver_mode_full_duplex(rstransceiver_t *ctx, uint8_t slew, uint8_t dir1, uint8_t term)
RS Transceiver sets the Full-Duplex mode function.
err_t rstransceiver_set_dir1(rstransceiver_t *ctx, uint8_t dir1)
RS Transceiver sets the DIR1 pin function.
err_t rstransceiver_term_enable(rstransceiver_t *ctx)
RS Transceiver term enable function.
void rstransceiver_set_rts(rstransceiver_t *ctx, uint8_t rts)
RS Transceiver request to send function.
err_t rstransceiver_generic_write(rstransceiver_t *ctx, char *data_in, uint16_t len)
RS Transceiver data writing function.
err_t rstransceiver_default_cfg(rstransceiver_t *ctx)
RS Transceiver default configuration function.
err_t rstransceiver_mode_loopback(rstransceiver_t *ctx)
RS Transceiver sets the loopback mode function.
err_t rstransceiver_set_op_mode(rstransceiver_t *ctx, uint8_t op_mode)
RS Transceiver sets the operating mode function.
void rstransceiver_device_disable(rstransceiver_t *ctx)
RS Transceiver disable the device function.
err_t rstransceiver_mode_rs232(rstransceiver_t *ctx, uint8_t slew)
RS Transceiver sets the RS-232 mode function.
err_t rstransceiver_term_disable(rstransceiver_t *ctx)
RS Transceiver term disable function.
uint8_t rstransceiver_get_cts(rstransceiver_t *ctx)
RS Transceiver clear to send function.
err_t rstransceiver_init(rstransceiver_t *ctx, rstransceiver_cfg_t *cfg)
RS Transceiver initialization function.
err_t rstransceiver_generic_read(rstransceiver_t *ctx, char *data_out, uint16_t len)
RS Transceiver data reading function.
err_t rstransceiver_mode_half_duplex(rstransceiver_t *ctx, uint8_t slew, uint8_t dir1, uint8_t term)
RS Transceiver sets the Half-Duplex mode function.
void rstransceiver_device_enable(rstransceiver_t *ctx)
RS Transceiver enables the device function.
rstransceiver_return_value_t
RS Transceiver Click return value data.
Definition rstransceiver.h:256
@ RSTRANSCEIVER_OK
Definition rstransceiver.h:257
@ RSTRANSCEIVER_ERROR
Definition rstransceiver.h:258
RS Transceiver Click configuration object.
Definition rstransceiver.h:228
uint32_t baud_rate
Definition rstransceiver.h:243
pin_name_t cst
Definition rstransceiver.h:237
uint32_t i2c_speed
Definition rstransceiver.h:239
bool uart_blocking
Definition rstransceiver.h:244
uart_data_bits_t data_bit
Definition rstransceiver.h:245
pin_name_t tx_pin
Definition rstransceiver.h:232
pin_name_t slw
Definition rstransceiver.h:236
pin_name_t rx_pin
Definition rstransceiver.h:231
uart_stop_bits_t stop_bit
Definition rstransceiver.h:247
pin_name_t scl
Definition rstransceiver.h:229
uart_parity_t parity_bit
Definition rstransceiver.h:246
pin_name_t sda
Definition rstransceiver.h:230
pin_name_t rst
Definition rstransceiver.h:235
pin_name_t cs
Definition rstransceiver.h:234
uint8_t i2c_address
Definition rstransceiver.h:240
RS Transceiver Click context object.
Definition rstransceiver.h:201
digital_out_t cs
Definition rstransceiver.h:203
uart_t uart
Definition rstransceiver.h:212
i2c_master_t i2c
Definition rstransceiver.h:211
digital_out_t rst
Definition rstransceiver.h:204
uint8_t slave_address
Definition rstransceiver.h:215
digital_out_t slw
Definition rstransceiver.h:205
digital_in_t cst
Definition rstransceiver.h:208