cc256x: provide btstack_chipset_cc256x_lmp_subversion(), validate in posix-h4 port

This commit is contained in:
Matthias Ringwald 2016-12-14 12:30:44 +01:00
parent 755bc58582
commit ed5d91bab6
3 changed files with 44 additions and 7 deletions

View File

@ -50,9 +50,21 @@ extern "C" {
#include <stdint.h>
#include "btstack_chipset.h"
/**
* Configure output power before HCI POWER_ON
*/
void btstack_chipset_cc256x_set_power(int16_t power_in_dB);
/**
* Get chipset instance for CC256x series
*/
const btstack_chipset_t * btstack_chipset_cc256x_instance(void);
/**
* Get LMP Subversion of compile-time init script
*/
uint16_t btstack_chipset_cc256x_lmp_subversion(void);
#if defined __cplusplus
}
#endif

View File

@ -33,6 +33,14 @@ __attribute__((__progmem__))
#endif
'''
get_lmp_subversion = '''
const uint16_t {prefix}_init_script_lmp_subversion = {lmp_subversion};
uint16_t btstack_chipset_cc256x_lmp_subversion(void){{
return {prefix}_init_script_lmp_subversion;
}}
'''
data_indent = ' '
def read_little_endian_16(f):
@ -99,6 +107,7 @@ def append_calibration_sequence(additions, str_list, data_indent):
str_list.append("0x01, 0x80, 0xfd, 0x06, 0x3c, 0xf0, 0x5f, 0x00, 0x00, 0x00,\n\n")
return 20
def convert_bts(output_file, main_bts_file, bts_add_on, aka, lmp_subversion):
array_name = 'cc256x'
@ -234,7 +243,7 @@ def convert_bts(output_file, main_bts_file, bts_add_on, aka, lmp_subversion):
# if aka != "":
# fout.write( 'const char * {0}_init_script_aka = "{1}";\n'.format(array_name, aka))
if lmp_subversion != 0:
fout.write( 'const uint16_t %s_init_script_lmp_subversion = 0x%04x;\n' % (array_name, lmp_subversion))
fout.write( get_lmp_subversion.format(prefix = array_name, lmp_subversion = "0x%04x" % lmp_subversion))
part = 0
size = 0
for part_size in part_sizes:
@ -285,28 +294,37 @@ if len(sys.argv) == 4:
add_on = sys.argv[2]
output_file = sys.argv[-1]
# get AKA and lmp subversion from file names that include model name
# get AKA from file names that include model name
aka = ""
lmp_subversion = 0
name_lower = main_bts.lower()
if 'cc2560_' in name_lower:
aka = "6.2.31"
lmp_subversion = 0x191f
if 'cc2560a_' in name_lower or 'cc2564_' in name_lower:
aka = "6.6.15"
lmp_subversion = 0x1B0F
if 'cc2560b_' in name_lower or 'cc2564b_' in name_lower:
aka = "6.7.16"
lmp_subversion = 0x1B90
if 'cc2564c_' in name_lower:
aka = "6.12.26"
lmp_subversion = 0x9a1a
# use AKA from .bts file that it
name_parts = re.match('.*TIInit_(\d*\.\d*\.\d*).*.bts', main_bts)
if name_parts:
aka = name_parts.group(1)
# get lmp subversion from AKA
lmp_subversion_for_aka = {
'6.2.31' : 0x191f,
'6.6.15' : 0x1B0F,
'6.7.16' : 0x1B90,
'6.12.26' : 0x9a1a
}
if aka in lmp_subversion_for_aka:
lmp_subversion = lmp_subversion_for_aka[aka]
# print summary
print ("Main file: %s"% main_bts)
if add_on != "":
print ("Add-on file: %s" % add_on)
@ -320,6 +338,6 @@ else:
convert_bts(output_file, main_bts, add_on, aka, lmp_subversion)
print

View File

@ -159,6 +159,12 @@ static void local_version_information_handler(uint8_t * packet){
break;
case COMPANY_ID_TEXAS_INSTRUMENTS_INC:
printf("Texas Instruments - CC256x compatible chipset.\n");
if (lmp_subversion != btstack_chipset_cc256x_lmp_subversion()){
printf("Error: LMP Subversion does not match initscript! ");
printf("Your initscripts is for %s chipset\n", btstack_chipset_cc256x_lmp_subversion() < lmp_subversion ? "an older" : "a newer");
printf("Please update Makefile to include the appropriate bluetooth_init_cc256???.c file\n");
exit(10);
}
use_fast_uart();
hci_set_chipset(btstack_chipset_cc256x_instance());
#ifdef ENABLE_EHCILL
@ -166,6 +172,7 @@ static void local_version_information_handler(uint8_t * packet){
#else
printf("eHCILL disable.\n");
#endif
break;
case COMPANY_ID_BROADCOM_CORPORATION:
printf("Broadcom - using BCM driver.\n");