btaudio3 2.0.0.0
btaudio3.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 BTAUDIO3_H
29#define BTAUDIO3_H
30
31#ifdef __cplusplus
32extern "C"{
33#endif
34
39#ifdef PREINIT_SUPPORTED
40#include "preinit.h"
41#endif
42
43#ifdef MikroCCoreVersion
44 #if MikroCCoreVersion >= 1
45 #include "delays.h"
46 #endif
47#endif
48
49#include "drv_digital_out.h"
50#include "drv_digital_in.h"
51#include "drv_uart.h"
52
73#define BTAUDIO3_CMD_MAKE_CALL 0x00
74#define BTAUDIO3_CMD_MAKE_EXTENSION_CALL 0x01
75#define BTAUDIO3_CMD_MMI_ACTION 0x02
76#define BTAUDIO3_CMD_EVENT_MASK_SETTING 0x03
77#define BTAUDIO3_CMD_MUSIC_CONTROL 0x04
78#define BTAUDIO3_CMD_CHANGE_DEVICE_NAME 0x05
79#define BTAUDIO3_CMD_CHANGE_PIN_CODE 0x06
80#define BTAUDIO3_CMD_SET_BTM_PARAM 0x07
81#define BTAUDIO3_CMD_GET_BTM_VERSION 0x08
82#define BTAUDIO3_CMD_VENDOR_AT_CMD 0x0A
83#define BTAUDIO3_CMD_AVRCP_SPEC_CMD 0x0B
84#define BTAUDIO3_CMD_AVRCP_GROUP_NAVIGATION 0x0C
85#define BTAUDIO3_CMD_READ_LINK_STATUS 0x0D
86#define BTAUDIO3_CMD_READ_PAIRING_RECORD 0x0E
87#define BTAUDIO3_CMD_READ_LOCAL_BD_ADDR 0x0F
88#define BTAUDIO3_CMD_READ_LOCAL_DEVICE_NAME 0x10
89#define BTAUDIO3_CMD_SEND_SPP_DATA 0x12
90#define BTAUDIO3_CMD_BTM_UTILITY_FUNCTION 0x13
91#define BTAUDIO3_CMD_EVENT_ACK 0x14
92#define BTAUDIO3_CMD_ADDITIONAL_PROFILE_LINK_SETUP 0x15
93#define BTAUDIO3_CMD_READ_LINKED_DEVICE_INFO 0x16
94#define BTAUDIO3_CMD_PROFILE_LINK_BACK 0x17
95#define BTAUDIO3_CMD_DISCONNECT 0x18
96#define BTAUDIO3_CMD_USER_CONFIRM_SPP_REQ_REPLY 0x1A
97#define BTAUDIO3_CMD_SET_HF_GAIN_LEVEL 0x1B
98#define BTAUDIO3_CMD_EQ_MODE_SETTING 0x1C
99#define BTAUDIO3_CMD_DSP_NR_CTRL 0x1D
100#define BTAUDIO3_CMD_GPIO_CTRL 0x1E
101#define BTAUDIO3_CMD_BT_MCU_UART_RX_BUFF_SIZE 0x1F
102#define BTAUDIO3_CMD_VOICE_PROMPT_CMD 0x20
103#define BTAUDIO3_CMD_SET_OVERALL_GAIN 0x23
104#define BTAUDIO3_CMD_READ_BTM_SETTING 0x24
105#define BTAUDIO3_CMD_READ_BTM_BATTERY_CHARGE_STATUS 0x25
106#define BTAUDIO3_CMD_MCU_UPDATE 0x26
107#define BTAUDIO3_CMD_REPORT_BATTERY_CAPACITY 0x27
108#define BTAUDIO3_CMD_LE_ANCS_SERVICE 0x28
109#define BTAUDIO3_CMD_LE_SIGNALING 0x29
110#define BTAUDIO3_CMD_MSPK_VENDOR 0x2A
111#define BTAUDIO3_CMD_READ_MSPK_LINK_STATUS 0x2B
112#define BTAUDIO3_CMD_MSPK_SYNC_AUDIO_EFFECT 0x2C
113#define BTAUDIO3_CMD_LE_GATT 0x2D
114#define BTAUDIO3_CMD_LE_APP 0x2F
115#define BTAUDIO3_CMD_DSP_RUNTIME_PROGRAM 0x30
116#define BTAUDIO3_CMD_READ_VENDOR_EEPROM 0x31
117#define BTAUDIO3_CMD_READ_IC_VERSION 0x32
118#define BTAUDIO3_CMD_READ_LINK_MODE 0x34
119#define BTAUDIO3_CMD_CONFIGURE_VENDOR_PARAM 0x35
120#define BTAUDIO3_CMD_MSPK_EXCHANGE_LINK_INFO 0x37
121#define BTAUDIO3_CMD_MSPK_SET_GIAC 0x38
122#define BTAUDIO3_CMD_READ_FEATURE_LIST 0x39
123#define BTAUDIO3_CMD_PERSONAL_MSPK_GROUP_CTRL 0x3A
124#define BTAUDIO3_CMD_TEST_DEVICE 0x3B
125#define BTAUDIO3_CMD_READ_EEPROM 0x3C
126#define BTAUDIO3_CMD_WRITE_EEPROM 0x3D
127#define BTAUDIO3_CMD_LE_SIGNALING_2 0x3E
128#define BTAUDIO3_CMD_PBAPC 0x3F
129#define BTAUDIO3_CMD_TWS 0x40
130#define BTAUDIO3_CMD_AVRCP_BROWSING 0x41
131#define BTAUDIO3_CMD_READ_PAIRED_LINK_KEY_INFO 0x42
132#define BTAUDIO3_CMD_AUDIO_TRANSCEIVER 0x44
133#define BTAUDIO3_CMD_BUTTON_MMI_SETTING 0x46
134#define BTAUDIO3_CMD_BUTTON_OPERATION 0x47
135#define BTAUDIO3_CMD_READ_BUTTON_MMI_SETTING 0x48
136#define BTAUDIO3_CMD_DFU 0x49
137#define BTAUDIO3_CMD_AVRCP_VENDOR_DEPENDENT 0x4A
138#define BTAUDIO3_CMD_CONCERT_MODE_ENDLESS_GROUPING 0x4B
139#define BTAUDIO3_CMD_READ_RUNTIME_LATENCY 0x4C
140#define BTAUDIO3_CMD_TOGGLE_AUDIO_SOURCE 0xCC
141
146#define BTAUDIO3_EVT_CMD_ACK 0x00
147#define BTAUDIO3_EVT_BTM_STATE 0x01
148#define BTAUDIO3_EVT_CALL_STATUS 0x02
149#define BTAUDIO3_EVT_CALL_ID 0x03
150#define BTAUDIO3_EVT_SMS_INDICATION 0x04
151#define BTAUDIO3_EVT_MISS_CALL_INDICATION 0x05
152#define BTAUDIO3_EVT_PHONE_MAX_BATTERY_LEVEL 0x06
153#define BTAUDIO3_EVT_PHONE_BATTERY_LEVEL 0x07
154#define BTAUDIO3_EVT_PHONE_ROAMING_STATUS 0x08
155#define BTAUDIO3_EVT_PHONE_MAX_SIGNAL_STRENGTH 0x09
156#define BTAUDIO3_EVT_PHONE_SIGNAL_STRENGTH 0x0A
157#define BTAUDIO3_EVT_PHONE_SERVICE_STATUS 0x0B
158#define BTAUDIO3_EVT_BATTERY_LEVEL 0x0C
159#define BTAUDIO3_EVT_CHARGER_STATUS 0x0D
160#define BTAUDIO3_EVT_RESET_TO_DEFAULT 0x0E
161#define BTAUDIO3_EVT_VOLUME_LEVEL 0x0F
162#define BTAUDIO3_EVT_EQ_MODE 0x10
163#define BTAUDIO3_EVT_LINKED_DEVICE_INFO 0x17
164#define BTAUDIO3_EVT_BTM_VERSION 0x18
165#define BTAUDIO3_EVT_CALL_LIST_REPORT 0x19
166#define BTAUDIO3_EVT_AVRCP_SPEC_RSP 0x1A
167#define BTAUDIO3_EVT_BTM_UTILITY_REQ 0x1B
168#define BTAUDIO3_EVT_VENDOR_AT_CMD_RSP 0x1C
169#define BTAUDIO3_EVT_UNKNOW_AT_RESULT 0x1D
170#define BTAUDIO3_EVT_REPORT_LINK_STATUS 0x1E
171#define BTAUDIO3_EVT_REPORT_PAIRING_RECORD 0x1F
172#define BTAUDIO3_EVT_REPORT_LOCAL_BD_ADDR 0x20
173#define BTAUDIO3_EVT_REPORT_LOCAL_DEVICE_NAME 0x21
174#define BTAUDIO3_EVT_REPORT_SPP_DATA 0x22
175#define BTAUDIO3_EVT_REPORT_LINK_BACK_STATUS 0x23
176#define BTAUDIO3_EVT_RINGTONE_FINISH_INDICATION 0x24
177#define BTAUDIO3_EVT_USER_CONFIRM_SSP_REQ 0x25
178#define BTAUDIO3_EVT_REPORT_AVRCP_VOL_CTRL 0x26
179#define BTAUDIO3_EVT_REPORT_INPUT_SIGNAL_LEVEL 0x27
180#define BTAUDIO3_EVT_REPORT_IAP_INFO 0x28
181#define BTAUDIO3_EVT_REPORT_AVRCP_ABS_VOL_CTRL 0x29
182#define BTAUDIO3_EVT_REPORT_VOICE_PROMPT_STATUS 0x2A
183#define BTAUDIO3_EVT_REPORT_TYPE_CODEC 0x2D
184#define BTAUDIO3_EVT_REPORT_TYPE_BTM_SETTING 0x2E
185#define BTAUDIO3_EVT_REPORT_MCU_UPDATE_REPLY 0x2F
186#define BTAUDIO3_EVT_REPORT_BTM_INITIAL_STATUS 0x30
187#define BTAUDIO3_EVT_REPORT_LE_ANCS_EVENT 0x31
188#define BTAUDIO3_EVT_REPORT_LE_EVENT 0x32
189#define BTAUDIO3_EVT_REPORT_MSPK_STATUS 0x33
190#define BTAUDIO3_EVT_REPORT_MSPK_VENDOR_EVENT 0x34
191#define BTAUDIO3_EVT_REPORT_MSPK_AUDIO_SETTING 0x35
192#define BTAUDIO3_EVT_REPORT_MSPK_EFFECT_STATUS 0x36
193#define BTAUDIO3_EVT_REPORT_VENDOR_EEPROM 0x37
194#define BTAUDIO3_EVT_REPORT_IC_VERSION_INFO 0x38
195#define BTAUDIO3_EVT_REPORT_CUSTOMER_GATT_ATTRIBUTE_DATA 0x39
196#define BTAUDIO3_EVT_REPORT_LINK_MODE 0x3A
197#define BTAUDIO3_EVT_REPORT_MSPK_EXCHANGE_LINK_INFO 0x3D
198#define BTAUDIO3_EVT_REPORT_BT_CLK 0x3F
199#define BTAUDIO3_EVT_REPORT_FEATURE_LIST 0x40
200#define BTAUDIO3_EVT_REPORT_TEST_RESULT 0x41
201#define BTAUDIO3_EVT_REPORT_READ_EEPROM_DATA 0x42
202#define BTAUDIO3_EVT_PBAPC_EVENT 0x43
203#define BTAUDIO3_EVT_AVRCP_BROWSING_EVENT 0x44
204#define BTAUDIO3_EVT_REPORT_PAIRED_LINK_KEY_INFO 0x45
205#define BTAUDIO3_EVT_REPORT_TWS_RX_VENDOR_EVENT 0x53
206#define BTAUDIO3_EVT_REPORT_TWS_LOCAL_DEVICE_STATUS 0x54
207#define BTAUDIO3_EVT_REPORT_TWS_VAD_DATA 0x55
208#define BTAUDIO3_EVT_REPORT_TWS_RADIO_CONDITION 0x56
209#define BTAUDIO3_EVT_REPORT_TWS_EAR_BUD_POSITION 0x57
210#define BTAUDIO3_EVT_REPORT_TWS_SECONDARY_DEVICE_STATUS 0x58
211#define BTAUDIO3_EVT_AUDIO_TRANSCEIVER_EVENT_STATUS 0x5A
212#define BTAUDIO3_EVT_READ_BUTTON_MMI_SETTING_REPLY 0x5C
213#define BTAUDIO3_EVT_AVRCP_VENDOR_DEPENDENT_RSP 0x5D
214#define BTAUDIO3_EVT_RUNTIME_LATENCY 0x5E
215
220#define BTAUDIO3_MMI_ADD_REMOVE_SCO_LINK 0x01
221#define BTAUDIO3_MMI_ENABLE_TEST_MODE 0x03
222#define BTAUDIO3_MMI_ACCEPT_CALL 0x04
223#define BTAUDIO3_MMI_REJECT_CALL 0x05
224#define BTAUDIO3_MMI_ENDCALL_OR_TRANSFER_TO_HEADSET 0x06
225#define BTAUDIO3_MMI_MIC_MUTE_TOGGLE 0x07
226#define BTAUDIO3_MMI_MUTE_MIC 0x08
227#define BTAUDIO3_MMI_UNMUTE_MIC 0x09
228#define BTAUDIO3_MMI_VOICE_DIAL 0x0A
229#define BTAUDIO3_MMI_CANCEL_VOICE_DIAL 0x0B
230#define BTAUDIO3_MMI_LAST_NUMBER_REDIAL 0x0C
231#define BTAUDIO3_MMI_ACTIVE_CALL_HOLD_ACCEPT_HELD_CALL 0x0D
232#define BTAUDIO3_MMI_VOICE_TRANSFER 0x0E
233#define BTAUDIO3_MMI_QUERY_CALL_LIST 0x0F
234#define BTAUDIO3_MMI_THREE_WAY_CALL 0x10
235#define BTAUDIO3_MMI_RELEASE_CALL 0x11
236#define BTAUDIO3_MMI_ACCEPT_WAITING_HOLD_CALL_RLS_ACTIVE_CALL 0x12
237#define BTAUDIO3_MMI_DISCONNECT_HF_LINK 0x17
238#define BTAUDIO3_MMI_ENABLE_AEC 0x1E
239#define BTAUDIO3_MMI_DISABLE_AEC 0x1F
240#define BTAUDIO3_MMI_SWITCH_AEC 0x20
241#define BTAUDIO3_MMI_ENABLE_AEC_RX_NOISE_REDUCTION 0x21
242#define BTAUDIO3_MMI_DISABLE_AEC_RX_NOISE_REDUCTION 0x22
243#define BTAUDIO3_MMI_SWITCH_AEC_RX_NOISE_REDUCTION 0x23
244#define BTAUDIO3_MMI_INC_MIC_GAIN 0x24
245#define BTAUDIO3_MMI_DEC_MIC_GAIN 0x25
246#define BTAUDIO3_MMI_SWITCH_PRIMARY_SECONDARY_HF_DEVICE 0x26
247#define BTAUDIO3_MMI_LOCK_BUTTON 0x3A
248#define BTAUDIO3_MMI_DISCONNECT_A2DP 0x3B
249#define BTAUDIO3_MMI_NEXT_AUDIO_EFFECT 0x3C
250#define BTAUDIO3_MMI_PREVIOUS_AUDIO_EFFECT 0x3D
251#define BTAUDIO3_MMI_REPORT_CURRENT_EQ_MODE 0x3F
252#define BTAUDIO3_MMI_REPORT_CURRENT_AUDIO_EFFECT_STATUS 0x40
253#define BTAUDIO3_MMI_TOGGLE_AUDIO_PLAYBACK 0x41
254#define BTAUDIO3_MMI_POWER_ON_BUTTON_PRESS 0x51
255#define BTAUDIO3_MMI_POWER_ON_BUTTON_RELEASE 0x52
256#define BTAUDIO3_MMI_POWER_OFF_BUTTON_PRESS 0x53
257#define BTAUDIO3_MMI_POWER_OFF_BUTTON_RELEASE 0x54
258#define BTAUDIO3_MMI_RESET_EEPROM_SETTING 0x56
259#define BTAUDIO3_MMI_FORCE_SPEAKER_GAIN_TOGGLE 0x57
260#define BTAUDIO3_MMI_TOGGLE_BUTTON_IND 0x58
261#define BTAUDIO3_MMI_COMBINE_FUNCTION_0 0x59
262#define BTAUDIO3_MMI_COMBINE_FUNCTION_1 0x5A
263#define BTAUDIO3_MMI_COMBINE_FUNCTION_2 0x5B
264#define BTAUDIO3_MMI_COMBINE_FUNCTION_3 0x5C
265#define BTAUDIO3_MMI_ENTER_PAIRING_MODE 0x5D
266#define BTAUDIO3_MMI_SWITCH_POWER_OFF 0x5E
267#define BTAUDIO3_MMI_DISABLE_LED 0x5F
268#define BTAUDIO3_MMI_BUZZER_TOGGLE 0x60
269#define BTAUDIO3_MMI_DISABLE_BUZZER 0x61
270#define BTAUDIO3_MMI_ENABLE_BUZZER 0x62
271#define BTAUDIO3_MMI_TONE_CHANGE 0x63
272#define BTAUDIO3_MMI_SHS_SEND_USER_DATA_1 0x72
273#define BTAUDIO3_MMI_SHS_SEND_USER_DATA_2 0x73
274#define BTAUDIO3_MMI_SHS_SEND_USER_DATA_3 0x74
275#define BTAUDIO3_MMI_SHS_SEND_USER_DATA_4 0x75
276#define BTAUDIO3_MMI_SHS_SEND_USER_DATA_5 0x76
277#define BTAUDIO3_MMI_REPORT_CURRENT_RX_NR_STATUS 0x77
278#define BTAUDIO3_MMI_REPORT_CURRENT_TX_NR_STATUS 0x78
279#define BTAUDIO3_MMI_CANCEL_ALL_BT_PAGING 0x7A
280#define BTAUDIO3_MMI_DISCONNECT_SPP_LINK 0x7D
281#define BTAUDIO3_MMI_ENABLE_A2DP_MIX_LINE_IN 0x80
282#define BTAUDIO3_MMI_DISABLE_A2DP_MIX_LINE_IN 0x81
283#define BTAUDIO3_MMI_INCREASE_LINE_IN_INPUT_GAIN 0x82
284#define BTAUDIO3_MMI_DECREASE_LINE_IN_INPUT_GAIN 0x83
285#define BTAUDIO3_MMI_TRIGGER_MSPK_CENTRAL 0xE0
286#define BTAUDIO3_MMI_TRIGGER_MSPK_PERIPHERAL 0xE1
287#define BTAUDIO3_MMI_MSPK_ONE_KEY_CONNECT 0xE2
288#define BTAUDIO3_MMI_CANCEL_MSPK_CREATION 0xE3
289#define BTAUDIO3_MMI_TERMINATE_MSPK_LINK 0xE4
290#define BTAUDIO3_MMI_TERMINATE_MSPK_CONNECTION 0xE5
291#define BTAUDIO3_MMI_MSPK_CENTRAL_ENTER_AUX_IN_44p1K_PCM_MODE 0xE6
292#define BTAUDIO3_MMI_MSPK_CENTRAL_ENTER_AUX_IN_48K_PCM_MODE 0xE7
293#define BTAUDIO3_MMI_MSPK_CENTRAL_EXIT_AUX_IN_PCM_MODE 0xE8
294#define BTAUDIO3_MMI_MSPK_SWITCH_CHANNEL 0xEC
295#define BTAUDIO3_MMI_MSPK_POWER_OFF_ALL_SPEAKERS 0xED
296#define BTAUDIO3_MMI_MSPK_ERASE_CONCERT_MODE_RECORD 0xEF
297#define BTAUDIO3_MMI_MSPK_ENTER_STEREO_MODE 0xF4
298#define BTAUDIO3_MMI_MSPK_ENTER_CONCERT_MODE 0xF5
299#define BTAUDIO3_MMI_MSPK_ADD_THIRD_SPK 0xF6
300#define BTAUDIO3_MMI_MSPK_SOUND_SYNC 0xF7
301#define BTAUDIO3_MMI_MSPK_CSB_CONNECTED_MODE_SWITCH 0xF8
302#define BTAUDIO3_MMI_MSPK_BACK_TO_LAST_MODE 0xF9
303#define BTAUDIO3_MMI_MSPK_ONE_KEY_CONNECT_WITH_LINK_BACK 0xFA
304#define BTAUDIO3_MMI_MSPK_ONE_KEY_OP_STEREO_MODE 0xFB
305#define BTAUDIO3_MMI_MSPK_ONE_KEY_OP_CONCERT_MODE 0xFC
306
311#define BTAUDIO3_ACK_STATUS_CMD_COMPLETE 0x00
312#define BTAUDIO3_ACK_STATUS_CMD_DISALLOW 0x01
313#define BTAUDIO3_ACK_STATUS_CMD_UNKNOWN 0x02
314#define BTAUDIO3_ACK_STATUS_CMD_PARAM_ERR 0x03
315#define BTAUDIO3_ACK_STATUS_CMD_BTM_BUSY 0x04
316#define BTAUDIO3_ACK_STATUS_CMD_BTM_FULL 0x05
317
322#define BTAUDIO3_BTM_STATE_POWER_OFF 0x00
323#define BTAUDIO3_BTM_STATE_PAIRING_STATE 0x01
324#define BTAUDIO3_BTM_STATE_POWER_ON 0x02
325#define BTAUDIO3_BTM_STATE_PAIRING_SUCCESSFULL 0x03
326#define BTAUDIO3_BTM_STATE_PAIRING_FAILED 0x04
327#define BTAUDIO3_BTM_STATE_HFHS_LINK_ESTABLISHED 0x05
328#define BTAUDIO3_BTM_STATE_A2DP_LINK_ESTABLISHED 0x06
329#define BTAUDIO3_BTM_STATE_HF_LINK_DISCONNECTED 0x07
330#define BTAUDIO3_BTM_STATE_A2DP_LINK_DISCONNECTED 0x08
331#define BTAUDIO3_BTM_STATE_SCO_LINK_CONNECTED 0x09
332#define BTAUDIO3_BTM_STATE_SCO_LINK_DISCONNECTED 0x0A
333#define BTAUDIO3_BTM_STATE_AVRCP_LINK_ESTABLISHED 0x0B
334#define BTAUDIO3_BTM_STATE_AVRCP_LINK_DISCONNECTED 0x0C
335#define BTAUDIO3_BTM_STATE_STANDARD_SPP_CONNECTED 0x0D
336#define BTAUDIO3_BTM_STATE_STANDARD_SPP_IAP_DISCONNECTED 0x0E
337#define BTAUDIO3_BTM_STATE_STANDBY_STATE 0x0F
338#define BTAUDIO3_BTM_STATE_IAP_CONNECTED 0x10
339#define BTAUDIO3_BTM_STATE_ACL_DISCONNECTED 0x11
340#define BTAUDIO3_BTM_STATE_MAP_CONNECTED 0x12
341#define BTAUDIO3_BTM_STATE_MAP_OPERATION_FORBIDDEN 0x13
342#define BTAUDIO3_BTM_STATE_MAP_DISCONNECTED 0x14
343#define BTAUDIO3_BTM_STATE_ACL_CONNECTED 0x15
344#define BTAUDIO3_BTM_STATE_SPP_IAP_DISCONNECTED_NO_PROFILE 0x16
345#define BTAUDIO3_BTM_STATE_LINK_BACK_ACL 0x17
346#define BTAUDIO3_BTM_STATE_INQUIRY_STATE 0x18
347#define BTAUDIO3_BTM_STATE_UNKNOWN_AUDIO_SOURCE 0x80
348#define BTAUDIO3_BTM_STATE_AUX_IN_AUDIO_SOURCE 0x81
349#define BTAUDIO3_BTM_STATE_A2DP_AUDIO_SOURCE 0x82
350
355#define BTAUDIO3_VOLUME_MASK_A2DP 0x01
356#define BTAUDIO3_VOLUME_MASK_HF 0x02
357#define BTAUDIO3_VOLUME_MASK_LINE_IN 0x04
358#define BTAUDIO3_VOLUME_MASK_PCM 0x08
359#define BTAUDIO3_VOLUME_MASK_LINE_IN_INPUT 0x10
360
365#define BTAUDIO3_START_HEADER 0xAA
366
372#define DRV_BUFFER_SIZE 512
373
374 // btaudio3_cmd
375
390#define BTAUDIO3_MAP_MIKROBUS( cfg, mikrobus ) \
391 cfg.tx_pin = MIKROBUS( mikrobus, MIKROBUS_TX ); \
392 cfg.rx_pin = MIKROBUS( mikrobus, MIKROBUS_RX ); \
393 cfg.sm = MIKROBUS( mikrobus, MIKROBUS_AN ); \
394 cfg.rst = MIKROBUS( mikrobus, MIKROBUS_RST ); \
395 cfg.mfb = MIKROBUS( mikrobus, MIKROBUS_PWM ); \
396 cfg.mod = MIKROBUS( mikrobus, MIKROBUS_INT );
397
398 // btaudio3_map
399 // btaudio3
400
405typedef struct
406{
407 uint8_t opcode;
408 uint8_t param_buf[ 256 ];
409 uint8_t param_len;
410
412
417typedef struct
418{
419 // Output pins
420 digital_out_t sm;
421 digital_out_t rst;
422 digital_out_t mfb;
423 digital_out_t mod;
425 // Modules
426 uart_t uart;
428 // Buffers
429 char uart_rx_buffer[ DRV_BUFFER_SIZE ];
430 char uart_tx_buffer[ DRV_BUFFER_SIZE ];
434
435} btaudio3_t;
436
441typedef struct
442{
443 // Communication gpio pins
444 pin_name_t rx_pin;
445 pin_name_t tx_pin;
447 // Additional gpio pins
448 pin_name_t sm;
449 pin_name_t rst;
450 pin_name_t mfb;
451 pin_name_t mod;
453 // Static variable
454 uint32_t baud_rate;
456 uart_data_bits_t data_bit;
457 uart_parity_t parity_bit;
458 uart_stop_bits_t stop_bit;
461
466typedef enum
467{
469 BTAUDIO3_ERROR = -1
470
472
492
512
529
545
560
574err_t btaudio3_generic_write ( btaudio3_t *ctx, uint8_t *data_buf, uint16_t len );
575
589err_t btaudio3_generic_read ( btaudio3_t *ctx, uint8_t *data_buf, uint16_t max_len );
590
600void btaudio3_set_mfb_pin ( btaudio3_t *ctx, uint8_t state );
601
611void btaudio3_set_rst_pin ( btaudio3_t *ctx, uint8_t state );
612
622
632
642
652
662
672
686
700
710void btaudio3_wait_for_event ( btaudio3_t *ctx, uint8_t opcode );
711
722
736err_t btaudio3_send_mmi_action ( btaudio3_t *ctx, uint8_t database_index, uint8_t action );
737
750
763
776
789
802err_t btaudio3_set_device_name ( btaudio3_t *ctx, uint8_t *device_name );
803
818
832err_t btaudio3_make_call ( btaudio3_t *ctx, uint8_t database_index, uint8_t *phone_number );
833
847err_t btaudio3_volume_up ( btaudio3_t *ctx, uint8_t database_index, uint8_t mask );
848
862err_t btaudio3_volume_down ( btaudio3_t *ctx, uint8_t database_index, uint8_t mask );
863
876
889
904
905#ifdef __cplusplus
906}
907#endif
908#endif // BTAUDIO3_H
909
910 // btaudio3
911
912// ------------------------------------------------------------------------ END
btaudio3_music_control_t
BT Audio 3 Click music control values.
Definition btaudio3.h:478
@ BTAUDIO3_FAST_FORWARD_WITH_REPEAT
Definition btaudio3.h:481
@ BTAUDIO3_PREVIOUS_SONG
Definition btaudio3.h:489
@ BTAUDIO3_FAST_FORWARD
Definition btaudio3.h:480
@ BTAUDIO3_PLAY_PAUSE_TOGGLE
Definition btaudio3.h:486
@ BTAUDIO3_NEXT_SONG
Definition btaudio3.h:488
@ BTAUDIO3_REWIND
Definition btaudio3.h:482
@ BTAUDIO3_PAUSE
Definition btaudio3.h:485
@ BTAUDIO3_PLAY
Definition btaudio3.h:484
@ BTAUDIO3_STOP
Definition btaudio3.h:487
@ BTAUDIO3_REWIND_WITH_REPEAT
Definition btaudio3.h:483
@ BTAUDIO3_STOP_FAST_FORWARD_OR_REWIND
Definition btaudio3.h:479
btaudio3_return_value_t
BT Audio 3 Click return value data.
Definition btaudio3.h:467
@ BTAUDIO3_OK
Definition btaudio3.h:468
@ BTAUDIO3_ERROR
Definition btaudio3.h:469
btaudio3_eq_mode_t
BT Audio 3 Click equalizer mode selection values.
Definition btaudio3.h:498
@ BTAUDIO2_EQ_MODE_SOFT
Definition btaudio3.h:500
@ BTAUDIO2_EQ_MODE_BASS
Definition btaudio3.h:501
@ BTAUDIO2_EQ_MODE_RNB
Definition btaudio3.h:508
@ BTAUDIO2_EQ_MODE_POP
Definition btaudio3.h:506
@ BTAUDIO2_EQ_MODE_ROCK
Definition btaudio3.h:504
@ BTAUDIO2_EQ_MODE_JAZZ
Definition btaudio3.h:505
@ BTAUDIO2_EQ_MODE_TREBLE
Definition btaudio3.h:502
@ BTAUDIO2_EQ_MODE_USER1
Definition btaudio3.h:509
@ BTAUDIO2_EQ_MODE_OFF
Definition btaudio3.h:499
@ BTAUDIO2_EQ_MODE_CLASSIC
Definition btaudio3.h:503
@ BTAUDIO2_EQ_MODE_DANCE
Definition btaudio3.h:507
#define DRV_BUFFER_SIZE
BT Audio 3 driver buffer size.
Definition btaudio3.h:372
void btaudio3_wait_for_event(btaudio3_t *ctx, uint8_t opcode)
BT Audio 3 wait for event function.
err_t btaudio3_reset_to_default(btaudio3_t *ctx)
BT Audio 3 reset to default function.
err_t btaudio3_disable_advertising(btaudio3_t *ctx)
BT Audio 3 disable advertising function.
err_t btaudio3_power_off_device(btaudio3_t *ctx)
BT Audio 3 power OFF device function.
err_t btaudio3_set_device_name(btaudio3_t *ctx, uint8_t *device_name)
BT Audio 3 set device name function.
err_t btaudio3_volume_down(btaudio3_t *ctx, uint8_t database_index, uint8_t mask)
BT Audio 3 volume down function.
err_t btaudio3_send_command_with_ack_check(btaudio3_t *ctx)
BT Audio 3 send command with ack check function.
err_t btaudio3_power_on_device(btaudio3_t *ctx)
BT Audio 3 power ON device function.
void btaudio3_set_rst_pin(btaudio3_t *ctx, uint8_t state)
BT Audio 3 set RST pin function.
err_t btaudio3_music_control(btaudio3_t *ctx, btaudio3_music_control_t action)
BT Audio 3 music control function.
err_t btaudio3_enter_pairing_mode(btaudio3_t *ctx)
BT Audio 3 enter pairing mode function.
void btaudio3_cfg_setup(btaudio3_cfg_t *cfg)
BT Audio 3 configuration object setup function.
err_t btaudio3_read_event(btaudio3_t *ctx)
BT Audio 3 read event function.
err_t btaudio3_init(btaudio3_t *ctx, btaudio3_cfg_t *cfg)
BT Audio 3 initialization function.
void btaudio3_set_mfb_pin(btaudio3_t *ctx, uint8_t state)
BT Audio 3 set MFB pin function.
err_t btaudio3_generic_read(btaudio3_t *ctx, uint8_t *data_buf, uint16_t max_len)
BT Audio 3 data reading function.
void btaudio3_send_command(btaudio3_t *ctx)
BT Audio 3 send command function.
void btaudio3_set_application_mode(btaudio3_t *ctx)
BT Audio 3 set application mode function.
err_t btaudio3_volume_up(btaudio3_t *ctx, uint8_t database_index, uint8_t mask)
BT Audio 3 volume up function.
void btaudio3_soft_unmute_output(btaudio3_t *ctx)
BT Audio 3 soft unmute output function.
void btaudio3_soft_mute_output(btaudio3_t *ctx)
BT Audio 3 soft mute output function.
err_t btaudio3_default_cfg(btaudio3_t *ctx)
BT Audio 3 default configuration function.
void btaudio3_set_test_mode(btaudio3_t *ctx)
BT Audio 3 set test mode function.
err_t btaudio3_make_call(btaudio3_t *ctx, uint8_t database_index, uint8_t *phone_number)
BT Audio 3 make call function.
err_t btaudio3_enable_advertising(btaudio3_t *ctx)
BT Audio 3 enable advertising function.
void btaudio3_clear_events(btaudio3_t *ctx)
BT Audio 3 clear events function.
err_t btaudio3_set_eq_mode(btaudio3_t *ctx, btaudio3_eq_mode_t eq_mode)
BT Audio 3 set equalizer mode function.
err_t btaudio3_send_mmi_action(btaudio3_t *ctx, uint8_t database_index, uint8_t action)
BT Audio 3 send MMI action function.
void btaudio3_reset_device(btaudio3_t *ctx)
BT Audio 3 reset device function.
err_t btaudio3_generic_write(btaudio3_t *ctx, uint8_t *data_buf, uint16_t len)
BT Audio 3 data writing function.
BT Audio 3 Click configuration object.
Definition btaudio3.h:442
uint32_t baud_rate
Definition btaudio3.h:454
bool uart_blocking
Definition btaudio3.h:455
uart_data_bits_t data_bit
Definition btaudio3.h:456
pin_name_t mod
Definition btaudio3.h:451
pin_name_t tx_pin
Definition btaudio3.h:445
pin_name_t rx_pin
Definition btaudio3.h:444
uart_stop_bits_t stop_bit
Definition btaudio3.h:458
pin_name_t mfb
Definition btaudio3.h:450
uart_parity_t parity_bit
Definition btaudio3.h:457
pin_name_t rst
Definition btaudio3.h:449
pin_name_t sm
Definition btaudio3.h:448
BT Audio 3 Click command/event packet structure object.
Definition btaudio3.h:406
uint8_t opcode
Definition btaudio3.h:407
uint8_t param_len
Definition btaudio3.h:409
BT Audio 3 Click context object.
Definition btaudio3.h:418
digital_out_t mod
Definition btaudio3.h:423
digital_out_t mfb
Definition btaudio3.h:422
uart_t uart
Definition btaudio3.h:426
btaudio3_packet_t event_packet
Definition btaudio3.h:433
btaudio3_packet_t command_packet
Definition btaudio3.h:432
digital_out_t rst
Definition btaudio3.h:421
digital_out_t sm
Definition btaudio3.h:420