void radio_init() { #ifdef EUI64_TRUNK_ID { uint8_t *eui = ST_RadioGetEui64(); my_addr8_ = eui[0]; my_addr16_ = my_addr8_; } #else { my_addr8_ = MY_ADDR; my_addr16_ = MY_ADDR; } #endif result_1 = ST_RadioSetPowerMode(0x00); #ifdef _STM32W_HIGH_POWER_ // For High Power Module use this uint16_t txPowerMode = 0x0001; //USER_TX_POWER_MODE; // Boost and alternate Tx/RX result_1 = ST_RadioSetPowerMode(txPowerMode); GPIO_PCCFGH = GPIO_PCCFGH & 0xFFFFFF0F; // PC5 GPIO_PCCFGH = GPIO_PCCFGH | 0x00000090; // PC5 = 0x9 - Special function (TX select) // Prepare PB5, PB6, PB7 for controlling the external amplifier GPIO_PBCFGH = GPIO_PBCFGH & 0xFFFF000F; GPIO_PBCFGH = GPIO_PBCFGH | 0x00001110; GPIO_PBCLR = 0x000000E0; GPIO_PBSET = 0x000000C0; // 0xC - enable LNA and activate chip, 0x4 - enable chip (exit sleep) #endif //_STM32W_HIGH_POWER_ my_rf_channel_ = DEFAULT_RF_CHANNEL; my_tx_power_ = DEFAULT_TX_POWER; // configured power level (default for orodinary communication stradio_retransmit_req_ = 0; ST_RadioSetNodeId(MY_ADDR); ST_RadioSetPanId(MY_PAN_ID); result_1 = ST_RadioSetChannel(my_rf_channel_); phy_set_power_level ( my_tx_power_ ); stradio_pending_len_ = 0; stradio_pending_data_ = NULL; stradio_pending_dst_ = 0; sch_add_loop((sch_loop_func_t)radio_loop); // GPIO_PBOUT = }
/******************************************************************************* ** 函数名称: Zigbee_Transmit ** 函数功能: zigbee发送函数处理主函数 ** 入口参数: ** 出口参数: ** 备 注: *******************************************************************************/ void Zigbee_Transmit(void) { ST_RadioEnableOverflowNotification(FALSE); ST_RadioSetPowerMode(ST_TX_POWER_MODE_DEFAULT); ST_RadioEnableAddressFiltering(FALSE); ST_RadioEnableAutoAck(FALSE); ST_RadioSetPower(RF_Power); ST_RadioSetChannel(Send_Channel); ST_RadioInit(ST_RADIO_POWER_MODE_OFF); Card_Cmd[10] |= (0x00|(battery.stat<<5)|(help_flag<<7)); //电池电量及求助状态 txBuf[0] =(int8u)(sizeof(Card_Cmd)+2); for(int8u ct = 0; ct < (int8u)sizeof(Card_Cmd); ct++) txBuf[ct + 1] = Card_Cmd[ct]; txPacketInFlight = TRUE; if(ST_RadioTransmit(txBuf)==ST_SUCCESS){ while(txPacketInFlight); ST_RadioSleep(); } else SendFailTime++; }