Go to the documentation of this file.
35 #include "drv_digital_out.h"
36 #include "drv_digital_in.h"
59 #define BT_MSG_TYPE_COMMAND 0x20
60 #define BT_MSG_TYPE_RESPONSE 0x20
61 #define BT_MSG_TYPE_EVENT 0xA0
67 #define BT_MSG_CLASS_DFU 0x00
68 #define BT_MSG_CLASS_SYSTEM 0x01
69 #define BT_MSG_CLASS_GAP 0x02
70 #define BT_MSG_CLASS_LE_GAP 0x03
71 #define BT_MSG_CLASS_RFCOMM 0x04
72 #define BT_MSG_CLASS_IDENTITY 0x05
73 #define BT_MSG_CLASS_SDP 0x06
74 #define BT_MSG_CLASS_CONNECTION 0x07
75 #define BT_MSG_CLASS_LE_CONNECTION 0x08
76 #define BT_MSG_CLASS_GATT 0x09
77 #define BT_MSG_CLASS_GATT_SERVER 0x0A
78 #define BT_MSG_CLASS_ENDPOINT 0x0B
79 #define BT_MSG_CLASS_HARDWARE 0x0C
80 #define BT_MSG_CLASS_FLASH_PS 0x0D
81 #define BT_MSG_CLASS_TEST 0x0E
82 #define BT_MSG_CLASS_SM 0x0F
83 #define BT_MSG_CLASS_UTIL 0x11
84 #define BT_MSG_CLASS_HID 0x13
85 #define BT_MSG_CLASS_LE_SERIAL 0x14
92 #define BT_MSG_ID_SYSTEM_RESET 0x01
93 #define BT_MSG_ID_SYSTEM_GET_BT_ADDRESS 0x03
94 #define BT_MSG_ID_SYSTEM_GET_CLASS_OF_DEV 0x05
95 #define BT_MSG_ID_SYSTEM_SET_CLASS_OF_DEV 0x06
96 #define BT_MSG_ID_SYSTEM_FACTORY_RESET 0x07
97 #define BT_MSG_ID_SYSTEM_SET_LOCAL_NAME 0x08
98 #define BT_MSG_ID_SYSTEM_GET_LOCAL_NAME 0x09
99 #define BT_MSG_ID_SM_SET_BONDABLE_MODE 0x00
100 #define BT_MSG_ID_SM_DELETE_BONDINGS 0x07
101 #define BT_MSG_ID_GAP_SET_MODE 0x03
102 #define BT_MSG_ID_HARDWARE_CONFIG_GPIO 0x01
103 #define BT_MSG_ID_HARDWARE_WRITE_GPIO 0x02
104 #define BT_MSG_ID_HARDWARE_READ_GPIO 0x03
105 #define BT_MSG_ID_ENDPOINT_SEND_DATA 0x00
106 #define BT_MSG_ID_RFCOMM_START_SERVER 0x01
107 #define BT_MSG_ID_RFCOMM_STOP_SERVER 0x03
108 #define BT_MSG_ID_EVT_ENDPOINT_DATA 0x01
109 #define BT_MSG_ID_EVT_CONNECTION_OPENED 0x00
110 #define BT_MSG_ID_EVT_CONNECTION_CLOSED 0x01
111 #define BT_MSG_ID_EVT_SM_BONDED 0x03
112 #define BT_MSG_ID_EVT_RFCOMM_OPENED 0x00
113 #define BT_MSG_ID_EVT_RFCOMM_MODEM_STATUS 0x01
119 #define BT_SYSTEM_RESET_NORMAL 0x00
120 #define BT_SYSTEM_RESET_BOOT_TO_DFU 0x01
126 #define BT_SM_SET_BONDABLE_NOT_ACCEPTED 0x00
127 #define BT_SM_SET_BONDABLE_ALLOWED 0x01
133 #define BT_GAP_MODE_NOT_CONNECTABLE 0x00
134 #define BT_GAP_MODE_CONNECTABLE 0x01
135 #define BT_GAP_MODE_NOT_DISCOVERABLE 0x00
136 #define BT_GAP_MODE_DISCOVERABLE 0x01
137 #define BT_GAP_MODE_LIMITED 0x00
138 #define BT_GAP_MODE_NOT_LIMITED 0x01
144 #define BT_RFCOMM_SERVER_DEF_SDP_ID 0x02
145 #define BT_RFCOMM_SERVER_DEF_STREAM_DEST 0x00
151 #define BT_HARDWARE_CONFIG_PORT_A 0x00
152 #define BT_HARDWARE_CONFIG_PORT_B 0x01
153 #define BT_HARDWARE_CONFIG_GPIO_FLOAT 0x00
154 #define BT_HARDWARE_CONFIG_GPIO_PULLUP 0x01
155 #define BT_HARDWARE_CONFIG_GPIO_PULLDOWN 0x02
156 #define BT_HARDWARE_CONFIG_GPIO_INPUT 0x00
157 #define BT_HARDWARE_CONFIG_GPIO_OUTPUT 0x01
158 #define BT_HARDWARE_CONFIG_GPIO_FUNCTION 0x02
159 #define BT_HARDWARE_CONFIG_GPIO_ANALOG 0x03
160 #define BT_HARDWARE_BUTTON1_PIN_INDEX 0x08
161 #define BT_HARDWARE_BUTTON2_PIN_INDEX 0x09
162 #define BT_HARDWARE_BUTTON3_PIN_INDEX 0x0A
163 #define BT_HARDWARE_BUTTON4_PIN_INDEX 0x0C
164 #define BT_HARDWARE_BUTTON5_PIN_INDEX 0x0D
165 #define BT_HARDWARE_LED1_PIN_INDEX 0x0E
166 #define BT_HARDWARE_LED2_PIN_INDEX 0x0F
167 #define BT_HARDWARE_BUTTON1_PIN_MASK 0x0100
168 #define BT_HARDWARE_BUTTON2_PIN_MASK 0x0200
169 #define BT_HARDWARE_BUTTON3_PIN_MASK 0x0400
170 #define BT_HARDWARE_BUTTON4_PIN_MASK 0x1000
171 #define BT_HARDWARE_BUTTON5_PIN_MASK 0x2000
172 #define BT_HARDWARE_ALL_BUTTONS_PIN_MASK 0x3700
173 #define BT_HARDWARE_LED1_PIN_MASK 0x4000
174 #define BT_HARDWARE_LED2_PIN_MASK 0x8000
175 #define BT_HARDWARE_ALL_LEDS_PIN_MASK 0xC000
181 #define BT_MAX_PAYLOAD_LEN 0x40
188 #define DRV_BUFFER_SIZE 200
206 #define BT_MAP_MIKROBUS( cfg, mikrobus ) \
207 cfg.tx_pin = MIKROBUS( mikrobus, MIKROBUS_TX ); \
208 cfg.rx_pin = MIKROBUS( mikrobus, MIKROBUS_RX ); \
209 cfg.an = MIKROBUS( mikrobus, MIKROBUS_AN ); \
210 cfg.rst = MIKROBUS( mikrobus, MIKROBUS_RST ); \
211 cfg.cts = MIKROBUS( mikrobus, MIKROBUS_CS ); \
212 cfg.bt0 = MIKROBUS( mikrobus, MIKROBUS_PWM ); \
213 cfg.rts = MIKROBUS( mikrobus, MIKROBUS_INT );
uart_t uart
Definition: bt.h:232
err_t bt_init(bt_t *ctx, bt_cfg_t *cfg)
BT initialization function.
void bt_set_cts_pin(bt_t *ctx, uint8_t state)
BT set CTS pin function.
err_t bt_hardware_read_gpio(bt_t *ctx, uint8_t port, uint16_t mask, uint16_t *port_data)
BT hardware read gpio function.
digital_out_t cts
Definition: bt.h:226
uart_stop_bits_t stop_bit
Definition: bt.h:262
err_t bt_rfcomm_stop_server(bt_t *ctx, uint8_t sdp_id)
BT rfcomm stop server function.
err_t bt_factory_reset(bt_t *ctx)
BT factory reset function.
uint8_t msg_id
Definition: bt.h:286
digital_in_t rts
Definition: bt.h:229
err_t bt_read_package(bt_t *ctx, bt_package_t *pkg)
BT read package function.
@ BT_ERROR
Definition: bt.h:273
err_t bt_set_gap_mode(bt_t *ctx, uint8_t connectable, uint8_t discoverable, uint8_t limited)
BT set gap mode function.
err_t bt_set_local_name(bt_t *ctx, char *name)
BT set local name function.
void bt_set_an_pin(bt_t *ctx, uint8_t state)
BT set AN pin function.
err_t bt_delete_bondings(bt_t *ctx)
BT delete bondings function.
void bt_set_rst_pin(bt_t *ctx, uint8_t state)
BT set RST pin function.
err_t bt_system_reset(bt_t *ctx, uint8_t mode)
BT system reset function.
pin_name_t rst
Definition: bt.h:252
digital_out_t rst
Definition: bt.h:225
pin_name_t cts
Definition: bt.h:253
pin_name_t rx_pin
Definition: bt.h:247
digital_out_t bt0
Definition: bt.h:227
err_t bt_generic_write(bt_t *ctx, char *data_buf, uint16_t len)
BT data writing function.
err_t bt_rfcomm_start_server(bt_t *ctx, uint8_t sdp_id, uint8_t stream_dest)
BT rfcomm start server function.
pin_name_t rts
Definition: bt.h:255
void bt_set_bt0_pin(bt_t *ctx, uint8_t state)
BT set BT0 pin function.
err_t bt_hardware_config_gpio(bt_t *ctx, uint8_t port, uint16_t pin_index, uint8_t mode, uint8_t pullup)
BT hardware config gpio function.
err_t bt_hardware_write_gpio(bt_t *ctx, uint8_t port, uint16_t mask, uint16_t port_data)
BT hardware write gpio function.
uint32_t baud_rate
Definition: bt.h:258
err_t bt_default_cfg(bt_t *ctx)
BT default configuration function.
BT Click packet structure object.
Definition: bt.h:282
@ BT_OK
Definition: bt.h:272
bool uart_blocking
Definition: bt.h:259
err_t bt_set_bondable_mode(bt_t *ctx, uint8_t mode)
BT set bondable mode function.
#define DRV_BUFFER_SIZE
BT driver buffer size.
Definition: bt.h:188
err_t bt_send_package(bt_t *ctx, bt_package_t pkg)
BT send package function.
uint8_t bt_get_rts_pin(bt_t *ctx)
BT get RTS pin function.
bt_return_value_t
BT Click return value data.
Definition: bt.h:271
pin_name_t an
Definition: bt.h:251
uart_parity_t parity_bit
Definition: bt.h:261
uint8_t msg_type
Definition: bt.h:283
uint8_t msg_class
Definition: bt.h:285
pin_name_t bt0
Definition: bt.h:254
void bt_cfg_setup(bt_cfg_t *cfg)
BT configuration object setup function.
uint8_t payload_len
Definition: bt.h:284
uart_data_bits_t data_bit
Definition: bt.h:260
BT Click context object.
Definition: bt.h:223
err_t bt_set_class_of_device(bt_t *ctx, uint32_t cod)
BT set class of device function.
#define BT_MAX_PAYLOAD_LEN
BT payload setting.
Definition: bt.h:181
pin_name_t tx_pin
Definition: bt.h:248
BT Click configuration object.
Definition: bt.h:245
err_t bt_generic_read(bt_t *ctx, char *data_buf, uint16_t max_len)
BT data reading function.
digital_out_t an
Definition: bt.h:224
err_t bt_endpoint_send_data(bt_t *ctx, uint8_t *endpoint, char *msg)
BT endpoint send data function.