39#ifdef PREINIT_SUPPORTED
43#ifdef MikroCCoreVersion
44 #if MikroCCoreVersion >= 1
49#include "drv_digital_out.h"
50#include "drv_digital_in.h"
73#define NPLC_CMD_COMMAND_MODE "+++"
74#define NPLC_CMD_DATA_MODE "ATO"
75#define NPLC_CMD_S100 "ATS100"
76#define NPLC_CMD_S110 "ATS110"
77#define NPLC_CMD_S111 "ATS111"
78#define NPLC_CMD_S112 "ATS112"
79#define NPLC_CMD_S113 "ATS113"
80#define NPLC_CMD_S114 "ATS114"
81#define NPLC_CMD_S300 "ATS300"
82#define NPLC_CMD_S301 "ATS301"
83#define NPLC_CMD_S302 "ATS302"
84#define NPLC_CMD_S305 "ATS305"
85#define NPLC_CMD_S306 "ATS306"
86#define NPLC_CMD_FWI "AT+FWI"
87#define NPLC_CMD_X "ATX"
88#define NPLC_CMD_Z "ATZ"
89#define NPLC_CMD_F "AT&F"
90#define NPLC_CMD_W "AT&W"
91#define NPLC_CMD_H "AT&H"
92#define NPLC_CMD_V "AT&V"
98#define NPLC_MODE_COMMAND 0
99#define NPLC_MODE_DATA 1
106#define NPLC_DRV_BUFFER_SIZE 200
124#define NPLC_MAP_MIKROBUS( cfg, mikrobus ) \
125 cfg.tx_pin = MIKROBUS( mikrobus, MIKROBUS_TX ); \
126 cfg.rx_pin = MIKROBUS( mikrobus, MIKROBUS_RX ); \
127 cfg.cts = MIKROBUS( mikrobus, MIKROBUS_AN ); \
128 cfg.rst = MIKROBUS( mikrobus, MIKROBUS_RST ); \
129 cfg.md1 = MIKROBUS( mikrobus, MIKROBUS_PWM ); \
130 cfg.rts = MIKROBUS( mikrobus, MIKROBUS_INT );
#define NPLC_DRV_BUFFER_SIZE
N-PLC driver buffer size.
Definition nplc.h:106
void nplc_send_cmd(nplc_t *ctx, char *cmd)
N-PLC send command function.
void nplc_hw_reset(nplc_t *ctx)
N-PLC hw reset function.
err_t nplc_init(nplc_t *ctx, nplc_cfg_t *cfg)
N-PLC initialization function.
void nplc_factory_reset(nplc_t *ctx)
N-PLC factory reset function.
void nplc_firmware_version(nplc_t *ctx)
N-PLC firmware version function.
void nplc_read_s_register(nplc_t *ctx, char *s_reg)
N-PLC read s register function.
uint8_t nplc_get_rts_pin(nplc_t *ctx)
N-PLC get rts pin function.
void nplc_set_cts_pin(nplc_t *ctx, uint8_t state)
N-PLC set cts pin function.
void nplc_set_mode(nplc_t *ctx, uint8_t mode)
N-PLC set mode function.
void nplc_set_rst_pin(nplc_t *ctx, uint8_t state)
N-PLC set rst pin function.
void nplc_set_md1_pin(nplc_t *ctx, uint8_t state)
N-PLC set md1 pin function.
err_t nplc_generic_write(nplc_t *ctx, char *data_in, uint16_t len)
N-PLC data writing function.
err_t nplc_generic_read(nplc_t *ctx, char *data_out, uint16_t len)
N-PLC data reading function.
void nplc_write_s_register(nplc_t *ctx, char *s_reg, char *param_buf)
N-PLC write s register function.
void nplc_sw_reset(nplc_t *ctx)
N-PLC sw reset function.
void nplc_cfg_setup(nplc_cfg_t *cfg)
N-PLC configuration object setup function.
nplc_return_value_t
N-PLC Click return value data.
Definition nplc.h:188
@ NPLC_OK
Definition nplc.h:189
@ NPLC_ERROR
Definition nplc.h:190
N-PLC Click configuration object.
Definition nplc.h:163
pin_name_t rts
Definition nplc.h:172
uint32_t baud_rate
Definition nplc.h:175
pin_name_t cts
Definition nplc.h:169
pin_name_t md1
Definition nplc.h:171
bool uart_blocking
Definition nplc.h:176
uart_data_bits_t data_bit
Definition nplc.h:177
pin_name_t tx_pin
Definition nplc.h:166
pin_name_t rx_pin
Definition nplc.h:165
uart_stop_bits_t stop_bit
Definition nplc.h:179
uart_parity_t parity_bit
Definition nplc.h:178
pin_name_t rst
Definition nplc.h:170
N-PLC Click context object.
Definition nplc.h:140
uart_t uart
Definition nplc.h:150
digital_in_t rts
Definition nplc.h:147
digital_out_t rst
Definition nplc.h:143
digital_out_t cts
Definition nplc.h:142
digital_out_t md1
Definition nplc.h:144