在CH579/CH573/CH57x 上使用RF_PHY 实现BLE广播

本文由来

  • 有时候,我们的应用很简单,并不需要建立BLE连接,只需要广播,比如各种beacon应用,而ble的协议栈是比较庞大的,而用2.4G的方式直接写,则可以做到非常的轻量.

实现

初始化

void RF_Init( void ) {
    uint8 state;
    rfConfig_t rfConfig;

    taskID = TMOS_ProcessEventRegister( RF_ProcessEvent );
#if defined(CH573)
    rfConfig.accessAddress = 0x8E89BED6;
    rfConfig.CRCInit = 0x555555;
#elif defined(CH579)
    rfConfig.TxAccessAddress = 0x8E89BED6;
    rfConfig.RxAccessAddress = 0x8E89BED6;
    rfConfig.TxCRCInit = 0x555555;
    rfConfig.RxCRCInit = 0x555555;
#else
    #error "You must define CH573 or CH579 first!"
#endif
    rfConfig.Channel = 37;
    rfConfig.LLEMode = LLE_MODE_BASIC;
    rfConfig.rfStatusCB = RF_2G4StatusCallBack;
    state = RF_Config( &rfConfig );
    PRINT("rf 2.4g init state for ble adv test: %x\n",state);
}

构造数据

//ble adv data for RF-PHY test
static uint8_t ble_adv_test_data[] = {
                                0x3c,0x10,0x2D, 0xE4, 0xC2, 0x84,\\MAC ADDR
                                9,0x09,'A','D','V','-','T','E','S','T' \\ADV data
                              };

发送

uint8_t ble_adv_tx(void) {
    RF_Shut( );
   //tx type :0X02 for no connected adv 
   return RF_Tx( TX_DATA,sizeof(TX_DATA), 0x02, 0xFF );
}
上一篇:ubuntu


下一篇:CH579/CH57x/CH58x ADC的使用