Part Number:CC2340R5Other Parts Discussed in Thread:CC2640R2F,
在cc2640R2F或cc2642R1F的SDK中,通常用
Mac0 = HWREG(FCFG1_BASE + FCFG1_O_MAC_BLE_0);
Mac1 = HWREG(FCFG1_BASE + FCFG1_O_MAC_BLE_1);
来获取芯片MAC地址,在CC2340R5中这样似乎不行。应该怎么获取呢
Nick Sun:
您好,
您现在在使用的CC2340R5是最终量产版本吗还是量产前的测试版本?
如果是量产前的测试版本没有提供蓝牙MAC地址。如果是量产版本应该是和之前芯片的使用方法相同。
,
Nick Yao:
应该是量产版吧?用的是CCS Resource Explorer里下载的CC2340R5最新SDK
我已经读到了Mac地址。
包含头文件#include <ti/devices/cc23x0r5/inc/hw_fcfg.h>
uint8_t MacAddress[6];
MacAddress[5] = fcfg->deviceInfo.bleAddr[0]; MacAddress[4] = fcfg->deviceInfo.bleAddr[1]; MacAddress[3] = fcfg->deviceInfo.bleAddr[2]; MacAddress[2] = fcfg->deviceInfo.bleAddr[3]; MacAddress[1] = fcfg->deviceInfo.bleAddr[4]; MacAddress[0] = fcfg->deviceInfo.bleAddr[5];
,
Nick Sun:
您好,
量产版读Mac address的代码如下:
#include <string.h> #include <ti/devices/DeviceFamily.h> #include DeviceFamily_constructPath(inc/hw_fcfg.h)uint8_t bleAddressRead[6] = {0}; // fcfg->deviceInfo.bleaddr is little-endian memcpy(bleAddressRead, fcfg->deviceInfo.bleAddr, 6); // Print the address MenuModule_printf(APP_MENU_PROFILE_STATUS_LINE4, 0, "bleAddressRead = 0x%x%x%x%x%x%x", bleAddressRead[5], bleAddressRead[4], bleAddressRead[3], bleAddressRead[2], bleAddressRead[1], bleAddressRead[0]);注意这样读出来的地址是小的在前的,所以打印显示的时候bleAddressRead[5]在最前面,bleAddressRead[0]在最后。