mirror of
https://github.com/bluekitchen/btstack.git
synced 2025-02-20 18:40:31 +00:00
chipset: remove all chipset functions from btstack_control.h and use from hci.c
This commit is contained in:
parent
c67501cb47
commit
3fb36a2984
@ -42,7 +42,6 @@
|
||||
|
||||
|
||||
#include "btstack_config.h"
|
||||
#include "bt_control_bcm.h"
|
||||
|
||||
#include <stddef.h> /* NULL */
|
||||
#include <stdio.h>
|
||||
@ -117,45 +116,3 @@ static const btstack_chipset_t btstack_chipset_bcm = {
|
||||
const btstack_chipset_t * btstack_chipset_bcm_instance(void){
|
||||
return &btstack_chipset_bcm;
|
||||
}
|
||||
|
||||
// deprecated //
|
||||
|
||||
static int bt_control_bcm_on(void *config){
|
||||
chipset_init(config);
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int bt_control_bcm_next_cmd(void *config, uint8_t *hci_cmd_buffer){
|
||||
return (int) chipset_next_command(hci_cmd_buffer);
|
||||
}
|
||||
|
||||
static int bcm_baudrate_cmd(void * config, uint32_t baudrate, uint8_t *hci_cmd_buffer){
|
||||
chipset_set_baudrate_command(baudrate, hci_cmd_buffer);
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int bt_control_bcm_set_bd_addr_cmd(void * config, bd_addr_t addr, uint8_t *hci_cmd_buffer){
|
||||
chipset_set_bd_addr_command(addr, hci_cmd_buffer);
|
||||
return 0;
|
||||
}
|
||||
|
||||
static const bt_control_t bt_control_bcm = {
|
||||
bt_control_bcm_on, // on
|
||||
NULL, // off
|
||||
NULL, // sleep
|
||||
NULL, // wake
|
||||
NULL, // valid
|
||||
NULL, // name
|
||||
bcm_baudrate_cmd, // baudrate_cmd
|
||||
bt_control_bcm_next_cmd, // next_cmd
|
||||
NULL, // register_for_power_notifications
|
||||
NULL, // hw_error
|
||||
bt_control_bcm_set_bd_addr_cmd, // set_bd_addr_cmd
|
||||
};
|
||||
|
||||
// MARK: public API
|
||||
bt_control_t * bt_control_bcm_instance(void){
|
||||
return (bt_control_t*) &bt_control_bcm;
|
||||
}
|
||||
|
||||
|
||||
|
@ -48,10 +48,8 @@ extern "C" {
|
||||
#endif
|
||||
|
||||
#include <stdint.h>
|
||||
#include "btstack_control.h"
|
||||
#include "btstack_chipset.h"
|
||||
|
||||
bt_control_t * bt_control_bcm_instance(void);
|
||||
const btstack_chipset_t * btstack_chipset_bcm_instance(void);
|
||||
|
||||
#if defined __cplusplus
|
||||
|
@ -299,53 +299,3 @@ const btstack_chipset_t * btstack_chipset_cc256x_instance(void){
|
||||
return &btstack_chipset_cc256x;
|
||||
}
|
||||
|
||||
//
|
||||
// @deprecated
|
||||
//
|
||||
|
||||
static int bt_control_cc256x_next_cmd(void *config, uint8_t *hci_cmd_buffer){
|
||||
return (int) chipset_next_command(hci_cmd_buffer);
|
||||
}
|
||||
|
||||
// UART Baud Rate control from: http://e2e.ti.com/support/low_power_rf/f/660/p/134850/484763.aspx
|
||||
static int bt_control_cc256x_baudrate_cmd(void * config, uint32_t baudrate, uint8_t *hci_cmd_buffer){
|
||||
chipset_set_baudrate_command(baudrate, hci_cmd_buffer);
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int bt_control_cc256x_on(void *config){
|
||||
chipset_init(config);
|
||||
return 0;
|
||||
}
|
||||
|
||||
void bt_control_cc256x_enable_ehcill(int on){
|
||||
btstack_chipset_cc256x_enable_ehcill(on);
|
||||
}
|
||||
|
||||
int bt_control_cc256x_ehcill_enabled(void){
|
||||
return btstack_chipset_cc256x_ehcill_enabled();
|
||||
}
|
||||
|
||||
void bt_control_cc256x_set_power(int16_t power_in_dB){
|
||||
btstack_chipset_cc256x_set_power(power_in_dB);
|
||||
}
|
||||
|
||||
// MARK: const structs
|
||||
|
||||
static const bt_control_t bt_control_cc256x = {
|
||||
bt_control_cc256x_on, // on
|
||||
NULL, // off
|
||||
NULL, // sleep
|
||||
NULL, // wake
|
||||
NULL, // valid
|
||||
NULL, // name
|
||||
bt_control_cc256x_baudrate_cmd, // baudrate_cmd
|
||||
bt_control_cc256x_next_cmd, // next_cmd
|
||||
NULL, // register_for_power_notifications
|
||||
NULL, // hw_error
|
||||
NULL, // set_bd_addr_cmd
|
||||
};
|
||||
|
||||
bt_control_t *bt_control_cc256x_instance(void){
|
||||
return (bt_control_t*) &bt_control_cc256x;
|
||||
}
|
||||
|
@ -48,22 +48,13 @@ extern "C" {
|
||||
#endif
|
||||
|
||||
#include <stdint.h>
|
||||
#include "btstack_control.h"
|
||||
#include "btstack_chipset.h"
|
||||
|
||||
// old
|
||||
void bt_control_cc256x_set_power(int16_t power_in_dB);
|
||||
void bt_control_cc256x_enable_ehcill(int on);
|
||||
int bt_control_cc256x_ehcill_enabled(void);
|
||||
bt_control_t *bt_control_cc256x_instance(void);
|
||||
|
||||
// new
|
||||
void btstack_chipset_cc256x_enable_ehcill(int on);
|
||||
int btstack_chipset_cc256x_ehcill_enabled(void);
|
||||
void btstack_chipset_cc256x_set_power(int16_t power_in_dB);
|
||||
const btstack_chipset_t * btstack_chipset_cc256x_instance(void);
|
||||
|
||||
|
||||
#if defined __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
@ -143,35 +143,3 @@ static const btstack_chipset_t btstack_chipset_bcm = {
|
||||
const btstack_chipset_t * btstack_chipset_csr_instance(void){
|
||||
return &btstack_chipset_bcm;
|
||||
}
|
||||
|
||||
|
||||
// DEPRECATED
|
||||
static int bt_control_csr_on(void *config){
|
||||
chipset_init(config);
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int bt_control_csr_next_cmd(void *config, uint8_t *hci_cmd_buffer){
|
||||
return (int) chipset_next_command(hci_cmd_buffer);
|
||||
}
|
||||
|
||||
// MARK: const structs
|
||||
|
||||
static const bt_control_t bt_control_csr = {
|
||||
bt_control_csr_on, // on
|
||||
NULL, // off
|
||||
NULL, // sleep
|
||||
NULL, // wake
|
||||
NULL, // valid
|
||||
NULL, // name
|
||||
NULL, // baudrate_cmd
|
||||
bt_control_csr_next_cmd, // next_cmd
|
||||
NULL, // register_for_power_notifications
|
||||
NULL, // hw_error
|
||||
NULL, // set_bd_addr_cmd
|
||||
};
|
||||
|
||||
// MARK: public API
|
||||
bt_control_t *bt_control_csr_instance(void){
|
||||
return (bt_control_t*) &bt_control_csr;
|
||||
}
|
||||
|
@ -49,10 +49,8 @@ extern "C" {
|
||||
#endif
|
||||
|
||||
#include <stdint.h>
|
||||
#include "btstack_control.h"
|
||||
#include "btstack_chipset.h"
|
||||
|
||||
bt_control_t * bt_control_csr_instance(void);
|
||||
const btstack_chipset_t * btstack_chipset_csr_instance(void);
|
||||
|
||||
#if defined __cplusplus
|
||||
|
@ -73,33 +73,3 @@ static const btstack_chipset_t btstack_chipset_em9301 = {
|
||||
const btstack_chipset_t * btstack_chipset_em9301_instance(void){
|
||||
return &btstack_chipset_em9301;
|
||||
}
|
||||
|
||||
//
|
||||
// deprecated
|
||||
//
|
||||
|
||||
static int em9301_set_bd_addr_cmd(void * config, bd_addr_t addr, uint8_t *hci_cmd_buffer){
|
||||
chipset_set_bd_addr_command(addr, hci_cmd_buffer);
|
||||
return 0;
|
||||
}
|
||||
|
||||
// MARK: const structs
|
||||
|
||||
static const bt_control_t bt_control_em9301 = {
|
||||
NULL, // on
|
||||
NULL, // off
|
||||
NULL, // sleep
|
||||
NULL, // wake
|
||||
NULL, // valid
|
||||
NULL, // name
|
||||
NULL, // baudrate_cmd
|
||||
NULL, // next_cmd
|
||||
NULL, // register_for_power_notifications
|
||||
NULL, // hw_error
|
||||
em9301_set_bd_addr_cmd, // set_bd_addr_cmd
|
||||
};
|
||||
|
||||
// MARK: public API
|
||||
bt_control_t *bt_control_em9301_instance(void){
|
||||
return (bt_control_t*) &bt_control_em9301;
|
||||
}
|
||||
|
@ -50,10 +50,8 @@
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#include "btstack_control.h"
|
||||
#include "btstack_chipset.h"
|
||||
|
||||
bt_control_t *bt_control_em9301_instance(void);
|
||||
const btstack_chipset_t * btstack_chipset_em9301_instance(void);
|
||||
|
||||
#if defined __cplusplus
|
||||
|
@ -114,37 +114,3 @@ static const btstack_chipset_t btstack_chipset_bcm = {
|
||||
const btstack_chipset_t * btstack_chipset_bcm_instance(void){
|
||||
return &btstack_chipset_bcm;
|
||||
}
|
||||
|
||||
//
|
||||
// deprecated
|
||||
//
|
||||
|
||||
static int stlc2500d_baudrate_cmd(void * config, uint32_t baudrate, uint8_t *hci_cmd_buffer){
|
||||
chipset_set_baudrate_command(baudrate, hci_cmd_buffer);
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int stlc2500d_set_bd_addr_cmd(void * config, bd_addr_t addr, uint8_t *hci_cmd_buffer){
|
||||
chipset_set_bd_addr_command(addr, hci_cmd_buffer);
|
||||
return 0;
|
||||
}
|
||||
|
||||
// MARK: const structs
|
||||
static const bt_control_t bt_control_stlc2500d = {
|
||||
NULL, // on
|
||||
NULL, // off
|
||||
NULL, // sleep
|
||||
NULL, // wake
|
||||
NULL, // valid
|
||||
NULL, // name
|
||||
stlc2500d_baudrate_cmd, // baudrate_cmd
|
||||
NULL, // next_cmd
|
||||
NULL, // register_for_power_notifications
|
||||
NULL, // hw_error
|
||||
stlc2500d_set_bd_addr_cmd, // set_bd_addr_cmd
|
||||
};
|
||||
|
||||
// MARK: public API
|
||||
bt_control_t *bt_control_stlc2500d_instance(void){
|
||||
return (bt_control_t*) &bt_control_stlc2500d;
|
||||
}
|
||||
|
@ -50,10 +50,8 @@
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#include "btstack_control.h"
|
||||
#include "btstack_chipset.h"
|
||||
|
||||
bt_control_t *bt_control_stlc2500d_instance(void);
|
||||
const btstack_chipset_t * btstack_chipset_stlc2500d_instance(void);
|
||||
|
||||
#if defined __cplusplus
|
||||
|
@ -97,7 +97,7 @@ static void chipset_set_bd_addr_command(bd_addr_t addr, uint8_t *hci_cmd_buffer)
|
||||
bt_flip_addr(&hci_cmd_buffer[3], addr);
|
||||
}
|
||||
|
||||
static const btstack_chipset_t btstack_chipset_bcm = {
|
||||
static const btstack_chipset_t btstack_chipset_tc3566x = {
|
||||
"TC3556x",
|
||||
NULL, // chipset_init,
|
||||
NULL, // chipset_next_command,
|
||||
@ -106,42 +106,6 @@ static const btstack_chipset_t btstack_chipset_bcm = {
|
||||
};
|
||||
|
||||
// MARK: public API
|
||||
const btstack_chipset_t * btstack_chipset_bcm_instance(void){
|
||||
return &btstack_chipset_bcm;
|
||||
}
|
||||
|
||||
//
|
||||
// deprecated
|
||||
//
|
||||
|
||||
|
||||
// baud rate command for tc3566x
|
||||
static int tc35661_baudrate_cmd(void * config, uint32_t baudrate, uint8_t *hci_cmd_buffer){
|
||||
chipset_set_baudrate_command(baudrate, hci_cmd_buffer);
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int tc3566x_set_bd_addr_cmd(void * config, bd_addr_t addr, uint8_t *hci_cmd_buffer){
|
||||
chipset_set_bd_addr_command(addr, hci_cmd_buffer);
|
||||
return 0;
|
||||
}
|
||||
|
||||
// MARK: const structs
|
||||
static const bt_control_t bt_control_tc3566x = {
|
||||
NULL, // on
|
||||
NULL, // off
|
||||
NULL, // sleep
|
||||
NULL, // wake
|
||||
NULL, // valid
|
||||
NULL, // name
|
||||
tc35661_baudrate_cmd, // baudrate_cmd
|
||||
NULL, // next_cmd
|
||||
NULL, // register_for_power_notifications
|
||||
NULL, // hw_error
|
||||
tc3566x_set_bd_addr_cmd, // set_bd_addr_cmd
|
||||
};
|
||||
|
||||
// MARK: public API
|
||||
bt_control_t *bt_control_tc3566x_instance(void){
|
||||
return (bt_control_t*) &bt_control_tc3566x;
|
||||
const btstack_chipset_t * btstack_chipset_tc3566x_instance(void){
|
||||
return &btstack_chipset_tc3566x;
|
||||
}
|
||||
|
@ -52,10 +52,8 @@
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#include "btstack_control.h"
|
||||
#include "btstack_chipset.h"
|
||||
|
||||
bt_control_t *bt_control_tc3566x_instance(void);
|
||||
const btstack_chipset_t * btstack_chipset_tc3566x_instance(void);
|
||||
|
||||
#if defined __cplusplus
|
||||
|
@ -749,7 +749,6 @@ void BTstackManager::setup(void){
|
||||
btstack_run_loop_init(btstack_run_loop_embedded_get_instance());
|
||||
|
||||
hci_transport_t * transport = hci_transport_h4_instance();
|
||||
bt_control_t * control = bt_control_em9301_instance();
|
||||
hci_init(transport, NULL, control, NULL);
|
||||
hci_set_chipset(btstack_chipset_em9301_instance());
|
||||
|
||||
|
@ -99,9 +99,8 @@ int main(void)
|
||||
|
||||
// init HCI
|
||||
hci_transport_t * transport = hci_transport_h4_instance();
|
||||
bt_control_t * control = bt_control_cc256x_instance();
|
||||
remote_device_db_t * remote_db = (remote_device_db_t *) &remote_device_db_memory;
|
||||
hci_init(transport, &config, control, remote_db);
|
||||
hci_init(transport, &config, NULL, remote_db);
|
||||
hci_set_chipset(btstack_chipset_cc256x_instance());
|
||||
|
||||
// use eHCILL
|
||||
|
@ -93,10 +93,8 @@ int main(int argc, const char * argv[]){
|
||||
// init HCI
|
||||
hci_transport_t * transport = hci_transport_usb_instance();
|
||||
void * config = NULL;
|
||||
bt_control_t * control = NULL;
|
||||
remote_device_db_t * remote_db = (remote_device_db_t *) &remote_device_db_fs;
|
||||
|
||||
hci_init(transport, config, control, remote_db);
|
||||
hci_init(transport, config, NULL, remote_db);
|
||||
|
||||
// handle CTRL-c
|
||||
signal(SIGINT, sigint_handler);
|
||||
|
@ -376,9 +376,8 @@ int main(void){
|
||||
|
||||
// init HCI
|
||||
hci_transport_t * transport = hci_transport_h4_instance();
|
||||
bt_control_t * control = bt_control_cc256x_instance();
|
||||
remote_device_db_t * remote_db = (remote_device_db_t *) &remote_device_db_memory;
|
||||
hci_init(transport, &config, control, remote_db);
|
||||
hci_init(transport, &config, NULL, remote_db);
|
||||
hci_set_chipset(btstack_chipset_cc256x_instance());
|
||||
|
||||
// use eHCILL
|
||||
|
@ -99,9 +99,8 @@ static void btstack_setup(void){
|
||||
|
||||
// init HCI
|
||||
hci_transport_t * transport = hci_transport_h4_instance();
|
||||
bt_control_t * control = bt_control_cc256x_instance();
|
||||
remote_device_db_t * remote_db = (remote_device_db_t *) &remote_device_db_memory;
|
||||
hci_init(transport, &config, control, remote_db);
|
||||
hci_init(transport, &config, NULL, remote_db);
|
||||
hci_set_chipset(btstack_chipset_cc256x_instance());
|
||||
|
||||
// use eHCILL
|
||||
|
@ -106,9 +106,8 @@ static void btstack_setup(void){
|
||||
|
||||
// init HCI
|
||||
hci_transport_t * transport = hci_transport_h4_instance();
|
||||
bt_control_t * control = bt_control_cc256x_instance();
|
||||
remote_device_db_t * remote_db = (remote_device_db_t *) &remote_device_db_memory;
|
||||
hci_init(transport, &config, control, remote_db);
|
||||
hci_init(transport, &config, NULL, remote_db);
|
||||
hci_set_chipset(btstack_chipset_cc256x_instance());
|
||||
|
||||
// use eHCILL
|
||||
|
@ -117,10 +117,9 @@ int main(int argc, const char * argv[]){
|
||||
|
||||
// init HCI
|
||||
hci_transport_t * transport = hci_transport_h4_instance();
|
||||
bt_control_t * control = bt_control_cc256x_instance();
|
||||
remote_device_db_t * remote_db = (remote_device_db_t *) &remote_device_db_fs;
|
||||
|
||||
hci_init(transport, &hci_uart_config_cc256x, control, remote_db);
|
||||
hci_init(transport, &hci_uart_config_cc256x, NULL, remote_db);
|
||||
hci_set_chipset(btstack_chipset_cc256x_instance());
|
||||
|
||||
// handle CTRL-c
|
||||
signal(SIGINT, sigint_handler);
|
||||
|
@ -114,10 +114,8 @@ int main(int argc, const char * argv[]){
|
||||
|
||||
// init HCI
|
||||
hci_transport_t * transport = hci_transport_h4_instance();
|
||||
bt_control_t * control = bt_control_csr_instance();
|
||||
remote_device_db_t * remote_db = (remote_device_db_t *) &remote_device_db_fs;
|
||||
|
||||
hci_init(transport, (void*) &config, control, remote_db);
|
||||
hci_init(transport, (void*) &config, NULL, remote_db);
|
||||
hci_set_chipset(btstack_chipset_csr_instance());
|
||||
|
||||
// handle CTRL-c
|
||||
|
@ -103,10 +103,8 @@ int main(int argc, const char * argv[]){
|
||||
|
||||
// init HCI
|
||||
hci_transport_t * transport = hci_transport_h4_instance();
|
||||
bt_control_t * control = bt_control_stlc2500d_instance();
|
||||
remote_device_db_t * remote_db = (remote_device_db_t *) &remote_device_db_fs;
|
||||
|
||||
hci_init(transport, (void*) &config, control, remote_db);
|
||||
hci_init(transport, (void*) &config, NULL, remote_db);
|
||||
hci_set_chipset(btstack_chipset_stlc2500d_instance());
|
||||
|
||||
// handle CTRL-c
|
||||
|
@ -100,10 +100,8 @@ int main(int argc, const char * argv[]){
|
||||
|
||||
// init HCI
|
||||
hci_transport_t * transport = hci_transport_h4_instance();
|
||||
bt_control_t * control = bt_control_tc3566x_instance();
|
||||
remote_device_db_t * remote_db = (remote_device_db_t *) &remote_device_db_fs;
|
||||
|
||||
hci_init(transport, (void*) &hci_uart_config, control, remote_db);
|
||||
hci_init(transport, (void*) &hci_uart_config, NULL, remote_db);
|
||||
hci_set_chipset(btstack_chipset_tc3566x_instance());
|
||||
|
||||
// handle CTRL-c
|
||||
|
@ -104,10 +104,8 @@ int main(int argc, const char * argv[]){
|
||||
|
||||
// init HCI
|
||||
hci_transport_t * transport = hci_transport_h4_instance();
|
||||
bt_control_t * control = bt_control_cc256x_instance();
|
||||
remote_device_db_t * remote_db = (remote_device_db_t *) &remote_device_db_fs;
|
||||
|
||||
hci_init(transport, (void*) &config, control, remote_db);
|
||||
hci_init(transport, (void*) &config, NULL, remote_db);
|
||||
hci_set_chipset(btstack_chipset_cc256x_instance());
|
||||
|
||||
// handle CTRL-c
|
||||
|
@ -425,9 +425,8 @@ int main(void)
|
||||
|
||||
// init HCI
|
||||
hci_transport_t * transport = hci_transport_h4_instance();
|
||||
bt_control_t * control = bt_control_cc256x_instance();
|
||||
remote_device_db_t * remote_db = (remote_device_db_t *) &remote_device_db_memory;
|
||||
hci_init(transport, (void*) &config, control, remote_db);
|
||||
hci_init(transport, (void*) &config, NULL, remote_db);
|
||||
hci_set_chipset(btstack_chipset_cc256x_instance());
|
||||
|
||||
// enable eHCILL
|
||||
|
@ -93,9 +93,8 @@ void application_start(void){
|
||||
|
||||
// init HCI
|
||||
hci_transport_t * transport = hci_transport_h4_instance();
|
||||
bt_control_t * control = bt_control_bcm_instance();
|
||||
remote_device_db_t * remote_db = (remote_device_db_t *) &remote_device_db_memory;
|
||||
hci_init(transport, (void*) &hci_transport_config_uart, control, remote_db);
|
||||
hci_init(transport, (void*) &hci_transport_config_uart, NULL, remote_db);
|
||||
hci_set_chipset(btstack_chipset_bcm_instance());
|
||||
|
||||
// use WIFI Mac address + 1 for Bluetooth
|
||||
|
@ -66,26 +66,8 @@ typedef struct {
|
||||
int (*wake) (void *config); // <-- wake BT module from sleep - only to be called after SLEEP
|
||||
int (*valid)(void *config); // <-- test if hardware can be supported
|
||||
const char * (*name) (void *config); // <-- return hardware name
|
||||
|
||||
/** support for UART baud rate changes - cmd has to be stored in hci_cmd_buffer
|
||||
* @return have command
|
||||
*/
|
||||
int (*baudrate_cmd)(void * config, uint32_t baudrate, uint8_t *hci_cmd_buffer);
|
||||
|
||||
/** support custom init sequences after RESET command - cmd has to be stored in hci_cmd_buffer
|
||||
* @return have command
|
||||
*/
|
||||
int (*next_cmd)(void *config, uint8_t * hci_cmd_buffer);
|
||||
|
||||
void (*register_for_power_notifications)(void (*cb)(POWER_NOTIFICATION_t event));
|
||||
|
||||
void (*hw_error)(void);
|
||||
|
||||
/** support for vendor-specific way to set BD ADDR - cmd has to be stored in hci_cmd_buffer
|
||||
* @return have command
|
||||
*/
|
||||
int (*set_bd_addr_cmd)(void * config, bd_addr_t addr, uint8_t *hci_cmd_buffer);
|
||||
|
||||
} bt_control_t;
|
||||
|
||||
#if defined __cplusplus
|
||||
|
43
src/hci.c
43
src/hci.c
@ -919,7 +919,7 @@ static void hci_initializing_run(void){
|
||||
break;
|
||||
case HCI_INIT_SEND_BAUD_CHANGE: {
|
||||
uint32_t baud_rate = hci_transport_uart_get_main_baud_rate();
|
||||
hci_stack->control->baudrate_cmd(hci_stack->config, baud_rate, hci_stack->hci_packet_buffer);
|
||||
hci_stack->chipset->set_baudrate_command(baud_rate, hci_stack->hci_packet_buffer);
|
||||
hci_stack->last_cmd_opcode = READ_BT_16(hci_stack->hci_packet_buffer, 0);
|
||||
hci_stack->substate = HCI_INIT_W4_SEND_BAUD_CHANGE;
|
||||
hci_send_cmd_packet(hci_stack->hci_packet_buffer, 3 + hci_stack->hci_packet_buffer[2]);
|
||||
@ -933,7 +933,7 @@ static void hci_initializing_run(void){
|
||||
}
|
||||
case HCI_INIT_SEND_BAUD_CHANGE_BCM: {
|
||||
uint32_t baud_rate = hci_transport_uart_get_main_baud_rate();
|
||||
hci_stack->control->baudrate_cmd(hci_stack->config, baud_rate, hci_stack->hci_packet_buffer);
|
||||
hci_stack->chipset->set_baudrate_command(baud_rate, hci_stack->hci_packet_buffer);
|
||||
hci_stack->last_cmd_opcode = READ_BT_16(hci_stack->hci_packet_buffer, 0);
|
||||
hci_stack->substate = HCI_INIT_W4_SEND_BAUD_CHANGE_BCM;
|
||||
hci_send_cmd_packet(hci_stack->hci_packet_buffer, 3 + hci_stack->hci_packet_buffer[2]);
|
||||
@ -942,8 +942,8 @@ static void hci_initializing_run(void){
|
||||
case HCI_INIT_CUSTOM_INIT:
|
||||
log_info("Custom init");
|
||||
// Custom initialization
|
||||
if (hci_stack->control && hci_stack->control->next_cmd){
|
||||
int valid_cmd = (*hci_stack->control->next_cmd)(hci_stack->config, hci_stack->hci_packet_buffer);
|
||||
if (hci_stack->chipset && hci_stack->chipset->next_command){
|
||||
int valid_cmd = (*hci_stack->chipset->next_command)(hci_stack->hci_packet_buffer);
|
||||
if (valid_cmd){
|
||||
int size = 3 + hci_stack->hci_packet_buffer[2];
|
||||
hci_stack->last_cmd_opcode = READ_BT_16(hci_stack->hci_packet_buffer, 0);
|
||||
@ -960,8 +960,8 @@ static void hci_initializing_run(void){
|
||||
btstack_run_loop_add_timer(&hci_stack->timeout);
|
||||
if (hci_stack->manufacturer == COMPANY_ID_CAMBRIDGE_SILICON_RADIO
|
||||
&& hci_stack->config
|
||||
&& hci_stack->control
|
||||
// && hci_stack->control->baudrate_cmd -- there's no such command
|
||||
&& hci_stack->chipset
|
||||
// && hci_stack->chipset->set_baudrate_command -- there's no such command
|
||||
&& hci_stack->hci_transport->set_baudrate
|
||||
&& hci_transport_uart_get_main_baud_rate()){
|
||||
hci_stack->substate = HCI_INIT_W4_SEND_BAUD_CHANGE;
|
||||
@ -978,8 +978,8 @@ static void hci_initializing_run(void){
|
||||
// Init script download causes baud rate to reset on Broadcom chipsets, restore UART baud rate if needed
|
||||
if (hci_stack->manufacturer == COMPANY_ID_BROADCOM_CORPORATION){
|
||||
int need_baud_change = hci_stack->config
|
||||
&& hci_stack->control
|
||||
&& hci_stack->control->baudrate_cmd
|
||||
&& hci_stack->chipset
|
||||
&& hci_stack->chipset->set_baudrate_command
|
||||
&& hci_stack->hci_transport->set_baudrate
|
||||
&& ((hci_transport_config_uart_t *)hci_stack->config)->baudrate_main;
|
||||
if (need_baud_change) {
|
||||
@ -995,7 +995,7 @@ static void hci_initializing_run(void){
|
||||
break;
|
||||
case HCI_INIT_SET_BD_ADDR:
|
||||
log_info("Set Public BD ADDR to %s", bd_addr_to_str(hci_stack->custom_bd_addr));
|
||||
hci_stack->control->set_bd_addr_cmd(hci_stack->config, hci_stack->custom_bd_addr, hci_stack->hci_packet_buffer);
|
||||
hci_stack->chipset->set_bd_addr_command(hci_stack->custom_bd_addr, hci_stack->hci_packet_buffer);
|
||||
hci_stack->last_cmd_opcode = READ_BT_16(hci_stack->hci_packet_buffer, 0);
|
||||
hci_stack->substate = HCI_INIT_W4_SET_BD_ADDR;
|
||||
hci_send_cmd_packet(hci_stack->hci_packet_buffer, 3 + hci_stack->hci_packet_buffer[2]);
|
||||
@ -1154,14 +1154,14 @@ static void hci_initializing_event_handler(uint8_t * packet, uint16_t size){
|
||||
if (!command_completed) return;
|
||||
|
||||
int need_baud_change = hci_stack->config
|
||||
&& hci_stack->control
|
||||
&& hci_stack->control->baudrate_cmd
|
||||
&& hci_stack->chipset
|
||||
&& hci_stack->chipset->set_baudrate_command
|
||||
&& hci_stack->hci_transport->set_baudrate
|
||||
&& ((hci_transport_config_uart_t *)hci_stack->config)->baudrate_main;
|
||||
|
||||
int need_addr_change = hci_stack->custom_bd_addr_set
|
||||
&& hci_stack->control
|
||||
&& hci_stack->control->set_bd_addr_cmd;
|
||||
&& hci_stack->chipset
|
||||
&& hci_stack->chipset->set_bd_addr_command;
|
||||
|
||||
switch(hci_stack->substate){
|
||||
case HCI_INIT_W4_SEND_RESET:
|
||||
@ -1947,6 +1947,18 @@ void hci_init(hci_transport_t *transport, void *config, bt_control_t *control, r
|
||||
hci_state_reset();
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Configure Bluetooth chipset driver. Has to be called before power on, or right after receiving the local version information
|
||||
*/
|
||||
void hci_set_chipset(const btstack_chipset_t *chipset_driver){
|
||||
hci_stack->chipset = chipset_driver;
|
||||
|
||||
// reset chipset driver - init is also called on power_up
|
||||
if (hci_stack->chipset && hci_stack->chipset->init){
|
||||
hci_stack->chipset->init(hci_stack->config);
|
||||
}
|
||||
}
|
||||
|
||||
void hci_close(void){
|
||||
// close remote device db
|
||||
if (hci_stack->remote_device_db) {
|
||||
@ -2000,6 +2012,11 @@ static int hci_power_control_on(void){
|
||||
return err;
|
||||
}
|
||||
|
||||
// reset chipset driver
|
||||
if (hci_stack->chipset && hci_stack->chipset->init){
|
||||
hci_stack->chipset->init(hci_stack->config);
|
||||
}
|
||||
|
||||
// open low-level device
|
||||
err = hci_stack->hci_transport->open(hci_stack->config);
|
||||
if (err){
|
||||
|
10
src/hci.h
10
src/hci.h
@ -47,13 +47,13 @@
|
||||
|
||||
#include "btstack_config.h"
|
||||
|
||||
|
||||
#include "btstack_chipset.h"
|
||||
#include "btstack_control.h"
|
||||
#include "btstack_linked_list.h"
|
||||
#include "btstack_util.h"
|
||||
#include "classic/remote_device_db.h"
|
||||
#include "hci_cmd.h"
|
||||
#include "hci_transport.h"
|
||||
#include "btstack_linked_list.h"
|
||||
#include "btstack_util.h"
|
||||
|
||||
#include <stdint.h>
|
||||
#include <stdlib.h>
|
||||
@ -515,7 +515,7 @@ typedef struct {
|
||||
typedef struct {
|
||||
// transport component with configuration
|
||||
hci_transport_t * hci_transport;
|
||||
btstack_chipset_t * chipset;
|
||||
const btstack_chipset_t * chipset;
|
||||
void * config;
|
||||
|
||||
// basic configuration
|
||||
@ -762,7 +762,7 @@ void hci_init(hci_transport_t *transport, void *config, bt_control_t *control, r
|
||||
/**
|
||||
* @brief Configure Bluetooth chipset driver. Has to be called before power on, or right after receiving the local version information
|
||||
*/
|
||||
void hci_set_chipset(btstack_chipset_t *chipset_driver);
|
||||
void hci_set_chipset(const btstack_chipset_t *chipset_driver);
|
||||
|
||||
/**
|
||||
* @brief Set class of device that will be set during Bluetooth init.
|
||||
|
Loading…
x
Reference in New Issue
Block a user