thyonei 2.1.0.0
thyonei.h
Go to the documentation of this file.
1/****************************************************************************
2** Copyright (C) 2020 MikroElektronika d.o.o.
3** Contact: https://www.mikroe.com/contact
4**
5** Permission is hereby granted, free of charge, to any person obtaining a copy
6** of this software and associated documentation files (the "Software"), to deal
7** in the Software without restriction, including without limitation the rights
8** to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9** copies of the Software, and to permit persons to whom the Software is
10** furnished to do so, subject to the following conditions:
11** The above copyright notice and this permission notice shall be
12** included in all copies or substantial portions of the Software.
13**
14** THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
15** EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
16** OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
17** IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
18** DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT
19** OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
20** USE OR OTHER DEALINGS IN THE SOFTWARE.
21****************************************************************************/
22
28#ifndef THYONEI_H
29#define THYONEI_H
30
31#ifdef __cplusplus
32extern "C"{
33#endif
34
35#include "mikrosdk_version.h"
36
37#ifdef __GNUC__
38#if mikroSDK_GET_VERSION < 20800ul
39#include "rcu_delays.h"
40#else
41#include "delays.h"
42#endif
43#endif
44
45#include "drv_digital_out.h"
46#include "drv_digital_in.h"
47#include "drv_uart.h"
48
69#define THYONEI_CMD_BROADCAST_DATA_REQ 0x06
70#define THYONEI_CMD_MULTICAST_DATA_REQ 0x05
71#define THYONEI_CMD_UNICAST_DATA_REQ 0x04
72#define THYONEI_CMD_MULTICAST_DATA_EX_REQ 0x08
73#define THYONEI_CMD_UNICAST_DATA_EX_REQ 0x07
74#define THYONEI_CMD_DATA_CNF 0x44
75#define THYONEI_CMD_TXCOMPLETE_RSP 0xC4
76#define THYONEI_CMD_DATA_IND 0x84
77#define THYONEI_CMD_SNIFFER_IND 0x99
78#define THYONEI_CMD_SET_REQ 0x11
79#define THYONEI_CMD_GET_REQ 0x10
80#define THYONEI_CMD_START_IND 0x73
81#define THYONEI_CMD_GETSTATE_REQ 0x01
82#define THYONEI_CMD_RESET_REQ 0x00
83#define THYONEI_CMD_SLEEP_REQ 0x02
84#define THYONEI_CMD_FACTORY_RESET_REQ 0x1C
85#define THYONEI_CMD_BOOTLOADER_REQ 0x1F
86#define THYONEI_CMD_TRANSPARENT_MODE_REQ 0x1B
87#define THYONEI_CMD_SETCHANNEL_REQ 0x19
88#define THYONEI_CMD_GPIO_LOCAL_SET_CONFIG_REQ 0x25
89#define THYONEI_CMD_GPIO_LOCAL_GET_CONFIG_REQ 0x26
90#define THYONEI_CMD_GPIO_REMOTE_SET_CONFIG_REQ 0x29
91#define THYONEI_CMD_GPIO_REMOTE_GET_CONFIG_REQ 0x2A
92#define THYONEI_CMD_GPIO_LOCAL_WRITE_REQ 0x27
93#define THYONEI_CMD_GPIO_LOCAL_READ_REQ 0x28
94#define THYONEI_CMD_GPIO_REMOTE_WRITE_REQ 0x2B
95#define THYONEI_CMD_GPIO_REMOTE_READ_REQ 0x2C
96#define THYONEI_CMD_GPIO_REMOTE_SET_CONFIG_IND 0xA9
97#define THYONEI_CMD_GPIO_REMOTE_WRITE_IND 0xAB
98#define THYONEI_CMD_ERROR_IND 0xA2
99#define THYONEI_CMD_DTM_START_REQ 0x1D
100#define THYONEI_CMD_DTM_REQ 0x1E
101
106#define THYONEI_INDEX_SERIAL_NUMBER 0x01
107#define THYONEI_INDEX_FW_VERSION 0x02
108#define THYONEI_INDEX_UART_CONFIG 0x04
109#define THYONEI_INDEX_UART_MODE 0x05
110#define THYONEI_INDEX_UART_TRANSPARENT_TIMEOUT 0x06
111#define THYONEI_INDEX_RF_CHANNEL 0x07
112#define THYONEI_INDEX_ENCRYPTION_MODE 0x08
113#define THYONEI_INDEX_RF_PROFILE 0x09
114#define THYONEI_INDEX_RF_NUM_RETRIES 0x0A
115#define THYONEI_INDEX_RF_TX_POWER 0x0B
116#define THYONEI_INDEX_RF_RP_NUM_SLOTS 0x0C
117#define THYONEI_INDEX_MAC_SOURCE_ADDRESS 0x10
118#define THYONEI_INDEX_MAC_DEST_ADDRESS 0x11
119#define THYONEI_INDEX_MAC_GROUP_ID 0x12
120#define THYONEI_INDEX_MAC_TRANSPARENT_ADDR_MODE 0x13
121#define THYONEI_INDEX_MAC_ENCRYPTION_KEY 0x14
122#define THYONEI_INDEX_MAC_TTL 0x15
123#define THYONEI_INDEX_CCA_MODE 0x16
124#define THYONEI_INDEX_CCA_THRESHOLD 0x17
125#define THYONEI_INDEX_GPIO_BLOCK_REMOTE 0x18
126#define THYONEI_INDEX_UART_TRANSP_ETX_CONFIG 0x19
127#define THYONEI_INDEX_UART_TRANSP_ETX 0x1A
128#define THYONEI_INDEX_UART_TRANSP_ETC_ENABLE 0x1B
129#define THYONEI_INDEX_UART_TRANSP_ETC 0x1C
130#define THYONEI_INDEX_RF_REPRATER_THRESHOLD 0x1D
131#define THYONEI_INDEX_MODULE_MODE 0x20
132
137#define THYONEI_RESPONSE_CODE 0x40
138#define THYONEI_START_SIGNAL 0x02
139
144#define THYONE_PIN_MODE_HIGH 0x01
145#define THYONE_PIN_MODE_LOW 0x00
146
152#define THYONEI_TX_DRV_BUFFER_SIZE 100
153#define THYONEI_RX_DRV_BUFFER_SIZE 300
154 // thyonei_cmd
156
171#define THYONEI_MAP_MIKROBUS( cfg, mikrobus ) \
172 cfg.tx_pin = MIKROBUS( mikrobus, MIKROBUS_TX ); \
173 cfg.rx_pin = MIKROBUS( mikrobus, MIKROBUS_RX ); \
174 cfg.bt = MIKROBUS( mikrobus, MIKROBUS_AN ); \
175 cfg.rst = MIKROBUS( mikrobus, MIKROBUS_RST ); \
176 cfg.rts = MIKROBUS( mikrobus, MIKROBUS_CS ); \
177 cfg.wup = MIKROBUS( mikrobus, MIKROBUS_PWM ); \
178 cfg.cts = MIKROBUS( mikrobus, MIKROBUS_INT );
179 // thyonei_map // thyonei
182
187typedef struct
188{
189 // Output pins
190 digital_out_t bt;
191 digital_out_t rst;
192 digital_out_t rts;
193 digital_out_t wup;
195 // Input pins
196 digital_in_t cts;
198 // Modules
199 uart_t uart;
201 // Buffers
202 uint8_t uart_rx_buffer[ THYONEI_RX_DRV_BUFFER_SIZE ];
203 uint8_t uart_tx_buffer[ THYONEI_TX_DRV_BUFFER_SIZE ];
205} thyonei_t;
206
211typedef struct
212{
213 // Communication gpio pins
214 pin_name_t rx_pin;
215 pin_name_t tx_pin;
217 // Additional gpio pins
218 pin_name_t bt;
219 pin_name_t rst;
220 pin_name_t rts;
221 pin_name_t wup;
222 pin_name_t cts;
224 // Static variable
225 uint32_t baud_rate;
227 uart_data_bits_t data_bit;
228 uart_parity_t parity_bit;
229 uart_stop_bits_t stop_bit;
232
237typedef enum
238{
240 THYONEI_ERROR = -1
241
243
260
275
287
300err_t thyonei_generic_write ( thyonei_t *ctx, uint8_t *data_in, uint16_t len );
301
314err_t thyonei_generic_read ( thyonei_t *ctx, uint8_t *data_out, uint16_t len );
315
325
335void thyonei_set_bt ( thyonei_t *ctx, uint8_t pin_state );
336
346void thyonei_set_rst ( thyonei_t *ctx, uint8_t pin_state );
347
357void thyonei_set_rts ( thyonei_t *ctx, uint8_t pin_state );
358
368void thyonei_set_wup ( thyonei_t *ctx, uint8_t pin_state );
369
380
395err_t thyonei_send_command ( thyonei_t *ctx, uint8_t command, uint16_t payload_length, uint8_t *payload );
396
411err_t thyonei_set_req ( thyonei_t *ctx, uint8_t settings_index, uint8_t parameters_length, uint8_t *parameters );
412
427err_t thyonei_get_req ( thyonei_t *ctx, uint8_t settings_index, uint8_t *param_len, uint8_t *parameter );
428
443err_t thyonei_broadcast_data_req ( thyonei_t *ctx, uint8_t message_len, uint8_t *message );
444
459err_t thyonei_multicast_data_req ( thyonei_t *ctx, uint8_t message_len, uint8_t *message );
460
475err_t thyonei_unicast_data_req ( thyonei_t *ctx, uint8_t message_len, uint8_t *message );
476
477#ifdef __cplusplus
478}
479#endif
480#endif // THYONEI_H
481 // thyonei
483
484// ------------------------------------------------------------------------ END
#define THYONEI_RX_DRV_BUFFER_SIZE
Definition: thyonei.h:153
#define THYONEI_TX_DRV_BUFFER_SIZE
Thyone-I driver buffer size.
Definition: thyonei.h:152
err_t thyonei_broadcast_data_req(thyonei_t *ctx, uint8_t message_len, uint8_t *message)
Thyone-I brodcast data function.
void thyonei_cfg_setup(thyonei_cfg_t *cfg)
Thyone-I configuration object setup function.
void thyonei_default_cfg(thyonei_t *ctx)
Thyone-I default configuration function.
err_t thyonei_set_req(thyonei_t *ctx, uint8_t settings_index, uint8_t parameters_length, uint8_t *parameters)
Thyone-I set individual parameters function.
err_t thyonei_get_req(thyonei_t *ctx, uint8_t settings_index, uint8_t *param_len, uint8_t *parameter)
Thyone-I get individual parameters function.
void thyonei_set_wup(thyonei_t *ctx, uint8_t pin_state)
Thyone-I set WUP pin function.
void thyonei_set_bt(thyonei_t *ctx, uint8_t pin_state)
Thyone-I set BT pin function.
err_t thyonei_send_command(thyonei_t *ctx, uint8_t command, uint16_t payload_length, uint8_t *payload)
Thyone-I send command function.
err_t thyonei_generic_write(thyonei_t *ctx, uint8_t *data_in, uint16_t len)
Thyone-I data writing function.
err_t thyonei_init(thyonei_t *ctx, thyonei_cfg_t *cfg)
Thyone-I initialization function.
uint8_t thyonei_get_cts_state(thyonei_t *ctx)
Thyone-I get CTS pin function.
err_t thyonei_generic_read(thyonei_t *ctx, uint8_t *data_out, uint16_t len)
Thyone-I data reading function.
err_t thyonei_multicast_data_req(thyonei_t *ctx, uint8_t message_len, uint8_t *message)
Thyone-I multicast data function.
void thyonei_set_rst(thyonei_t *ctx, uint8_t pin_state)
Thyone-I set RST pin function.
void thyonei_hw_reset(thyonei_t *ctx)
Thyone-I hardware reser function.
void thyonei_set_rts(thyonei_t *ctx, uint8_t pin_state)
Thyone-I set RTS pin function.
err_t thyonei_unicast_data_req(thyonei_t *ctx, uint8_t message_len, uint8_t *message)
Thyone-I unicast data function.
Thyone-I Click configuration object.
Definition: thyonei.h:212
pin_name_t rts
Definition: thyonei.h:220
uint32_t baud_rate
Definition: thyonei.h:225
pin_name_t wup
Definition: thyonei.h:221
pin_name_t cts
Definition: thyonei.h:222
pin_name_t bt
Definition: thyonei.h:218
bool uart_blocking
Definition: thyonei.h:226
uart_data_bits_t data_bit
Definition: thyonei.h:227
pin_name_t tx_pin
Definition: thyonei.h:215
pin_name_t rx_pin
Definition: thyonei.h:214
uart_stop_bits_t stop_bit
Definition: thyonei.h:229
uart_parity_t parity_bit
Definition: thyonei.h:228
pin_name_t rst
Definition: thyonei.h:219
Thyone-I Click context object.
Definition: thyonei.h:188
digital_out_t rts
Definition: thyonei.h:192
uart_t uart
Definition: thyonei.h:199
digital_out_t wup
Definition: thyonei.h:193
digital_in_t cts
Definition: thyonei.h:196
digital_out_t rst
Definition: thyonei.h:191
digital_out_t bt
Definition: thyonei.h:190
thyonei_return_value_t
Thyone-I Click return value data.
Definition: thyonei.h:238
@ THYONEI_OK
Definition: thyonei.h:239
@ THYONEI_ERROR
Definition: thyonei.h:240