Go to the documentation of this file.
28 #ifndef RSTRANSCEIVER_H
29 #define RSTRANSCEIVER_H
35 #include "drv_digital_out.h"
36 #include "drv_digital_in.h"
37 #include "drv_i2c_master.h"
60 #define RSTRANSCEIVER_REG_INPUT_PORT 0x00
61 #define RSTRANSCEIVER_REG_OUTPUT_PORT 0x01
62 #define RSTRANSCEIVER_REG_POLARITY_INV 0x02
63 #define RSTRANSCEIVER_REG_CONFIG 0x03
64 #define RSTRANSCEIVER_REG_SPECIAL_FUNC 0x50
82 #define RSTRANSCEIVER_NO_PIN_BIT_MASK 0x00
83 #define RSTRANSCEIVER_PIN_0_BIT_MASK 0x01
84 #define RSTRANSCEIVER_PIN_1_BIT_MASK 0x02
85 #define RSTRANSCEIVER_PIN_2_BIT_MASK 0x04
86 #define RSTRANSCEIVER_PIN_3_BIT_MASK 0x08
87 #define RSTRANSCEIVER_ALL_PINS_BIT_MASK 0x0F
93 #define RSTRANSCEIVER_OUTPUT_DIRECTION 0x00
94 #define RSTRANSCEIVER_INPUT_DIRECTION 0x01
100 #define RSTRANSCEIVER_SPECIAL_FUNC_P3_AS_INT 0x80
101 #define RSTRANSCEIVER_SPECIAL_FUNC_PU_DISABLED 0x40
107 #define RSTRANSCEIVER_SLEW_DISABLE 0x00
108 #define RSTRANSCEIVER_SLEW_ENABLE 0x01
114 #define RSTRANSCEIVER_OP_MODE_LOOPBACK 0x00
115 #define RSTRANSCEIVER_OP_MODE_RS232 0x01
116 #define RSTRANSCEIVER_OP_MODE_HALF_DUPLEX 0x02
117 #define RSTRANSCEIVER_OP_MODE_FULL_DUPLEX 0x03
118 #define RSTRANSCEIVER_OP_MODE_PIN_BIT_MASK 0x09
124 #define RSTRANSCEIVER_DIR_DISABLE 0x00
125 #define RSTRANSCEIVER_DIR_T1_EN 0x01
126 #define RSTRANSCEIVER_DIR_T1_EN_R1_DIS 0x01
127 #define RSTRANSCEIVER_DIR_PIN_BIT_MASK 0x0E
133 #define RSTRANSCEIVER_TERM_DISABLE 0x00
134 #define RSTRANSCEIVER_TERM_ENABLE 0x01
135 #define RSTRANSCEIVER_TERM_DIS_PIN_BIT_MASK 0x07
136 #define RSTRANSCEIVER_TERM_EN_PIN_BIT_MASK 0x08
143 #define RSTRANSCEIVER_TX_DRV_BUFFER_SIZE 100
144 #define RSTRANSCEIVER_RX_DRV_BUFFER_SIZE 300
151 #define RSTRANSCEIVER_DEVICE_ADDRESS 0x41
169 #define RSTRANSCEIVER_MAP_MIKROBUS( cfg, mikrobus ) \
170 cfg.scl = MIKROBUS( mikrobus, MIKROBUS_SCL ); \
171 cfg.sda = MIKROBUS( mikrobus, MIKROBUS_SDA ); \
172 cfg.cs = MIKROBUS( mikrobus, MIKROBUS_CS ); \
173 cfg.rst = MIKROBUS( mikrobus, MIKROBUS_RST ); \
174 cfg.slw = MIKROBUS( mikrobus, MIKROBUS_PWM ); \
175 cfg.tx_pin = MIKROBUS( mikrobus, MIKROBUS_TX ); \
176 cfg.rx_pin = MIKROBUS( mikrobus, MIKROBUS_RX ); \
177 cfg.cst = MIKROBUS( mikrobus, MIKROBUS_INT )
535 #endif // RSTRANSCEIVER_H
err_t rstransceiver_mode_loopback(rstransceiver_t *ctx)
RS Transceiver sets the loopback mode function.
void rstransceiver_device_disable(rstransceiver_t *ctx)
RS Transceiver disable the device function.
err_t rstransceiver_set_op_mode(rstransceiver_t *ctx, uint8_t op_mode)
RS Transceiver sets the operating mode 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.
rstransceiver_return_value_t
RS Transceiver Click return value data.
Definition: rstransceiver.h:242
pin_name_t rx_pin
Definition: rstransceiver.h:217
pin_name_t tx_pin
Definition: rstransceiver.h:218
pin_name_t sda
Definition: rstransceiver.h:216
RS Transceiver Click context object.
Definition: rstransceiver.h:187
pin_name_t slw
Definition: rstransceiver.h:222
uint32_t baud_rate
Definition: rstransceiver.h:229
#define RSTRANSCEIVER_TX_DRV_BUFFER_SIZE
RS Transceiver driver buffer size.
Definition: rstransceiver.h:143
uint8_t i2c_address
Definition: rstransceiver.h:226
uart_t uart
Definition: rstransceiver.h:198
err_t rstransceiver_generic_read(rstransceiver_t *ctx, char *data_out, uint16_t len)
RS Transceiver data reading function.
i2c_master_t i2c
Definition: rstransceiver.h:197
err_t rstransceiver_generic_write(rstransceiver_t *ctx, char *data_in, uint16_t len)
RS Transceiver data writing function.
pin_name_t cs
Definition: rstransceiver.h:220
err_t rstransceiver_mode_rs232(rstransceiver_t *ctx, uint8_t slew)
RS Transceiver sets the RS-232 mode function.
RS Transceiver Click configuration object.
Definition: rstransceiver.h:214
digital_in_t cst
Definition: rstransceiver.h:194
#define RSTRANSCEIVER_RX_DRV_BUFFER_SIZE
Definition: rstransceiver.h:144
err_t rstransceiver_term_disable(rstransceiver_t *ctx)
RS Transceiver term disable function.
err_t rstransceiver_term_enable(rstransceiver_t *ctx)
RS Transceiver term enable function.
digital_out_t rst
Definition: rstransceiver.h:190
err_t rstransceiver_set_dir1(rstransceiver_t *ctx, uint8_t dir1)
RS Transceiver sets the DIR1 pin function.
@ RSTRANSCEIVER_ERROR
Definition: rstransceiver.h:244
uint8_t slave_address
Definition: rstransceiver.h:201
digital_out_t cs
Definition: rstransceiver.h:189
void rstransceiver_device_enable(rstransceiver_t *ctx)
RS Transceiver enables the device function.
bool uart_blocking
Definition: rstransceiver.h:230
uart_data_bits_t data_bit
Definition: rstransceiver.h:231
digital_out_t slw
Definition: rstransceiver.h:191
pin_name_t rst
Definition: rstransceiver.h:221
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.
uart_stop_bits_t stop_bit
Definition: rstransceiver.h:233
pin_name_t scl
Definition: rstransceiver.h:215
void rstransceiver_set_slew(rstransceiver_t *ctx, uint8_t slew)
RS Transceiver sets the slew limit function.
@ RSTRANSCEIVER_OK
Definition: rstransceiver.h:243
void rstransceiver_cfg_setup(rstransceiver_cfg_t *cfg)
RS Transceiver configuration object setup function.
err_t rstransceiver_default_cfg(rstransceiver_t *ctx)
RS Transceiver default configuration 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.
pin_name_t cst
Definition: rstransceiver.h:223
void rstransceiver_set_rts(rstransceiver_t *ctx, uint8_t rts)
RS Transceiver request to send function.
uart_parity_t parity_bit
Definition: rstransceiver.h:232
uint32_t i2c_speed
Definition: rstransceiver.h:225