大家好:
cc8531 data side channel 通信成功了,眼泪与汗水交杂的感觉,有人懂么!!!
为了以后的攻城狮少走弯路,把方法贴出来,算是做一丢丢的贡献吧。
【我还知道获取DeviceID的方法哦哦哦 ,也贴出来吧。毕竟这个是TI没有对外公布的办法,应该有人用得着】
接收方:
if(status & BV_EHIF_EVT_DSC_RX_AVAIL)
{//EHIF_CMD_DSC_RX_DATAGRAM
OS_Printf("+%d CC_I2S[%d]:%s %s\n\r", I2S_Prio[CCOpIndex], HAL_GetTick(), (CCOpIndex==teCCOI_LR)?"LR":"SUB", "DSC_RX_AVAIL");
EHIF_CMD_DSC_TX_DATAGRAM_PARAM_T dscTxDatagram;
dscTxDatagram.addr = 0x00000000;//u32DeviceID[CCOpIndex];
dscTxDatagram.connReset = true;
uint8_t u8Data[32+5];
uint16_t readbcLength = sizeof(u8Data)/sizeof(u8Data[0]);
ehifCmdExecWithReadbc(CCOpIndex, EHIF_EXEC_ALL, EHIF_CMD_DSC_RX_DATAGRAM, sizeof(dscTxDatagram), &dscTxDatagram, &readbcLength, &u8Data[0]);
OS_Printf("Device ID:%x\n\r", u32DeviceID[CCOpIndex]);
for(uint8_t i=0; i<32; i+=8)
OS_Printf("%x %x %x %x %x %x %x %x\n\r", u8Data[0+i], u8Data[1+i], u8Data[2+i], u8Data[3+i], u8Data[4+i], u8Data[5+i], u8Data[6+i], u8Data[7+i]); OS_Printf("%x %x %x %x %x\n\r", u8Data[32], u8Data[33], u8Data[34], u8Data[35], u8Data[36]); }
发送方:
if(VolStatus & BV_EHIF_EVT_DSC_TX_AVAIL)
{//EHIF_CMD_DSC_TX_DATAGRAM
EHIF_CMD_DSC_TX_DATAGRAM_PARAM_T DSCTxData;
extern uint32_t ccnwkId;
DSCTxData.addr = ccnwkId;//(ccnwkId<<24&0xff000000)|(ccnwkId<<8&0x00ff0000)|(ccnwkId>>8&0x0000ff00)|(ccnwkId>>24&0x000000ff);
DSCTxData.connReset = true;
uint8_t u8Data[32];
for(uint8_t i=0; i<32; i++)
u8Data[i] = i;
ehifCmdExecWithWrite(EHIF_EXEC_ALL, EHIF_CMD_DSC_TX_DATAGRAM, sizeof(DSCTxData), &DSCTxData, sizeof(u8Data)/sizeof(u8Data[0]), &u8Data[0]);
}
选中区域为发送方的deivce ID
CCOpIndex是自己定义的,TI提供的函数没有这个参数,需删除
另外获取本地DeviceID方法:
自己拿逻辑分析仪一点点分析出来的 也给广大攻城狮参考 。希望有人懂我留的汗与泪。
代码是在TI提供的示例代码基础上改的,CCOpIndex形参实参删除就是示例代码了。
//***********************************************************
//读设备ID
uint16_t ReadDeviceID(teCCOperatorIndex CCOpIndex)
{
uint16_t status = 0;
uint8_t u8Data[26];
EHIF_PIN_RESET_BEGIN(CCOpIndex);
DelayMs(100);
EHIF_PIN_RESET_END(CCOpIndex);
// Enter the SPI bootloader
ehifBootResetPin(CCOpIndex);
status = ehifBlUnlockSpi(CCOpIndex);
ehifReadID(CCOpIndex, sizeof(u8Data), &u8Data[0]);
u32DeviceID[CCOpIndex] = (u8Data[20] << 24) | (u8Data[21] << 16) | (u8Data[22] << 8) | (u8Data[23] << 0);
u16ChipID[CCOpIndex] = (u8Data[24] << 8) | (u8Data[25] << 0);
return status;
}
uint16_t ehifReadID(teCCOperatorIndex CCOpIndex, uint16_t byteCount, uint8_t* pBuff) {
// Prepare CMD_REQ parameters
uint8_t pParams[2] = {
0x00, 0xAC
};
// Send BL_FLASH_VERIFY
CustomEhifReadDeviceIDCmdReq(CCOpIndex, 0x1F, sizeof(pParams), pParams);
// Get CRC and return status
//ehifWaitReadyMs(15+5);
return ehifRead(CCOpIndex, byteCount, pBuff);
}
uint16_t CustomEhifReadDeviceIDCmdReq(teCCOperatorIndex CCOpIndex, uint8_t cmd, uint8_t length, const uint8_t* pParam) {
// Send type/command code/parameter length, receive status word
uint16_t statusWord;
// Begin operation
EHIF_SPI_BEGIN(CCOpIndex);
ehifWaitReady(CCOpIndex);
statusWord = DriverSPI1ReadWriteByte(0xC0 | cmd) << 8;
EHIF_SPI_WAIT_TXRX();
statusWord |= DriverSPI1ReadWriteByte(length & 0xFF);
EHIF_SPI_WAIT_TXRX();
// Send parameters
while(length–) {
EHIF_SPI_WAIT_TXRX();
DriverSPI1ReadWriteByte(*(pParam++));
}
EHIF_SPI_WAIT_TXRX();
// End operation
EHIF_SPI_END(CCOpIndex);
return statusWord;
} // ehifCmdReq
fangyun You:
漏了一点 ccnwkId:是dongle的 device ID 也是当前CC音频网络ID,配对成功后 即可读取。
readbcLength = sizeof(ehifNwmDoScanData); ehifCmdExecWithReadbc(EHIF_EXEC_DATA, EHIF_CMD_NWM_DO_SCAN, 0, NULL, &readbcLength, &ehifNwmDoScanData);
// If found … if (readbcLength == sizeof(EHIF_CMD_NWM_DO_SCAN_DATA_T)) { // Update the network ID to be used next ccnwkId = ehifNwmDoScanData.deviceId;
// Place the new network ID in CC85XX non-volatile storage DeviceCC85xxInitParam();//initParam();initParam(); ehifCmdParam.nvsSetData.index = 0; ehifCmdParam.nvsSetData.data = ehifNwmDoScanData.deviceId; ehifCmdExec(EHIF_CMD_NVS_SET_DATA, sizeof(EHIF_CMD_NVS_SET_DATA_PARAM_T), &ehifCmdParam); }
// Done currState = CC85XX_STATE_ALONE; targetState = CC85XX_STATE_ACTIVE; DeviceCCPrintf("DeviceCC Slave Pair Over!\n\r");
Viki Shi:
很好的经验分享,感谢
user5758147:
请问,data side channel功能可以实现与Host的数据通讯吗?
我想让Host(PC、Android)发送几个字节的数据给CC8531,CC8531收到后也返回几个字节的数据给Host。