mirror of
https://github.com/bluekitchen/btstack.git
synced 2025-01-01 00:28:18 +00:00
set baudrate during custom init for csr chipssets
This commit is contained in:
parent
7b0d76671f
commit
baf36f076c
@ -55,34 +55,35 @@
|
|||||||
// minimal CSR init script
|
// minimal CSR init script
|
||||||
static const uint8_t init_script[] = {
|
static const uint8_t init_script[] = {
|
||||||
// BCCMD set ANA_Freq PSKEY to 26MHz
|
// BCCMD set ANA_Freq PSKEY to 26MHz
|
||||||
0x01, 0x00, 0xFC, 0x13, 0xc2, 0x02, 0x00, 0x09, 0x00, 0x1e, 0x00, 0x03, 0x70, 0x00, 0x00, 0xfe, 0x01, 0x01, 0x00, 0x00, 0x00, 0x90, 0x65,
|
0x01, 0x00, 0xFC, 0x13, 0xc2, 0x02, 0x00, 0x09, 0x00, 0x01, 0x00, 0x03, 0x70, 0x00, 0x00, 0xfe, 0x01, 0x01, 0x00, 0x00, 0x00, 0x90, 0x65,
|
||||||
|
// BCCMD set UART baudrate to 115200
|
||||||
|
0x01, 0x00, 0xFC, 0x15, 0xc2, 0x02, 0x00, 0x0a, 0x00, 0x02, 0x00, 0x03, 0x70, 0x00, 0x00, 0xea, 0x01, 0x02, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0xc2,
|
||||||
// BCCMD WarmReset
|
// BCCMD WarmReset
|
||||||
0x01, 0x00, 0xFC, 0x13, 0xc2, 0x02, 0x00, 0x09, 0x00, 0x4d, 0x0e, 0x02, 0x40, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
0x01, 0x00, 0xFC, 0x13, 0xc2, 0x02, 0x00, 0x09, 0x00, 0x03, 0x0e, 0x02, 0x40, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||||
};
|
};
|
||||||
static const uint16_t init_script_size = sizeof(init_script);
|
static const uint16_t init_script_size = sizeof(init_script);
|
||||||
|
|
||||||
//
|
//
|
||||||
static uint32_t init_script_offset = 0;
|
static uint32_t init_script_offset = 0;
|
||||||
static int16_t init_power_in_dB = 13; // 13 dBm
|
|
||||||
|
|
||||||
static int bt_control_csr_on(void *config){
|
static int bt_control_csr_on(void *config){
|
||||||
init_script_offset = 0;
|
init_script_offset = 0;
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
// UART Baud Rate control from: http://e2e.ti.com/support/low_power_rf/f/660/p/134850/484763.aspx
|
// set baud rate
|
||||||
// static int csr_baudrate_cmd(void * config, uint32_t baudrate, uint8_t *hci_cmd_buffer){
|
static void bt_control_csr_update_command(hci_uart_config_t *config, uint8_t *hci_cmd_buffer){
|
||||||
// hci_cmd_buffer[0] = 0x36;
|
uint16_t varid = READ_BT_16(hci_cmd_buffer, 10);
|
||||||
// hci_cmd_buffer[1] = 0xFF;
|
if (varid != 0x7003) return;
|
||||||
// hci_cmd_buffer[2] = 0x04;
|
uint16_t key = READ_BT_16(hci_cmd_buffer, 14);
|
||||||
// hci_cmd_buffer[3] = baudrate & 0xff;
|
if (key != 0x01ea) return;
|
||||||
// hci_cmd_buffer[4] = (baudrate >> 8) & 0xff;
|
uint32_t baudrate = config->baudrate_main;
|
||||||
// hci_cmd_buffer[5] = (baudrate >> 16) & 0xff;
|
if (baudrate == 0){
|
||||||
// hci_cmd_buffer[6] = 0;
|
baudrate = config->baudrate_init;
|
||||||
// return 0;
|
}
|
||||||
// }
|
// uint32_t is stored as 2 x uint16_t with most important 16 bits first
|
||||||
|
bt_store_16(hci_cmd_buffer, 20, baudrate >> 16);
|
||||||
static void bt_control_csr_update_command(uint8_t *hci_cmd_buffer){
|
bt_store_16(hci_cmd_buffer, 22, baudrate & 0xffff);
|
||||||
}
|
}
|
||||||
|
|
||||||
static int bt_control_csr_next_cmd(void *config, uint8_t *hci_cmd_buffer){
|
static int bt_control_csr_next_cmd(void *config, uint8_t *hci_cmd_buffer){
|
||||||
@ -101,7 +102,7 @@ static int bt_control_csr_next_cmd(void *config, uint8_t *hci_cmd_buffer){
|
|||||||
memcpy(&hci_cmd_buffer[3], (uint8_t *) &init_script[init_script_offset], payload_len);
|
memcpy(&hci_cmd_buffer[3], (uint8_t *) &init_script[init_script_offset], payload_len);
|
||||||
|
|
||||||
// support for on-the-fly configuration updates
|
// support for on-the-fly configuration updates
|
||||||
bt_control_csr_update_command(hci_cmd_buffer);
|
bt_control_csr_update_command((hci_uart_config_t*)config, hci_cmd_buffer);
|
||||||
|
|
||||||
init_script_offset += payload_len;
|
init_script_offset += payload_len;
|
||||||
|
|
||||||
@ -124,7 +125,7 @@ static const bt_control_t bt_control_csr = {
|
|||||||
NULL, // wake
|
NULL, // wake
|
||||||
NULL, // valid
|
NULL, // valid
|
||||||
NULL, // name
|
NULL, // name
|
||||||
NULL, /* csr_baudrate_cmd, */ // baudrate_cmd
|
NULL, // baudrate_cmd
|
||||||
bt_control_csr_next_cmd, // next_cmd
|
bt_control_csr_next_cmd, // next_cmd
|
||||||
NULL, // register_for_power_notifications
|
NULL, // register_for_power_notifications
|
||||||
NULL, // hw_error
|
NULL, // hw_error
|
||||||
@ -140,7 +141,6 @@ static const hci_uart_config_t hci_uart_config_csr = {
|
|||||||
|
|
||||||
// MARK: public API
|
// MARK: public API
|
||||||
void bt_control_csr_set_power(int16_t power_in_dB){
|
void bt_control_csr_set_power(int16_t power_in_dB){
|
||||||
init_power_in_dB = power_in_dB;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
bt_control_t *bt_control_csr_instance(void){
|
bt_control_t *bt_control_csr_instance(void){
|
||||||
|
Loading…
Reference in New Issue
Block a user