error_t hw_radio_send_packet(hw_radio_packet_t* packet, tx_packet_callback_t tx_cb)
{
    // TODO error handling EINVAL, ESIZE, EOFF
    if(current_state == HW_RADIO_STATE_TX)
        return EBUSY;

    assert(packet->length < 63); // long packets not yet supported

    tx_packet_callback = tx_cb;

    if(current_state == HW_RADIO_STATE_RX)
    {
        pending_rx_cfg.channel_id = current_channel_id;
        pending_rx_cfg.syncword_class = current_syncword_class;
        should_rx_after_tx_completed = true;
    }

    current_state = HW_RADIO_STATE_TX;
    current_packet = packet;
    cc1101_interface_strobe(RF_SIDLE);
    cc1101_interface_strobe(RF_SFTX);

#ifdef FRAMEWORK_LOG_ENABLED // TODO more granular
    log_print_stack_string(LOG_STACK_PHY, "Data to TX Fifo:");
    log_print_data(packet->data, packet->length + 1);
#endif

    configure_channel((channel_id_t*)&(current_packet->tx_meta.tx_cfg.channel_id));
    configure_eirp(current_packet->tx_meta.tx_cfg.eirp);
    configure_syncword_class(current_packet->tx_meta.tx_cfg.syncword_class);

    cc1101_interface_write_burst_reg(TXFIFO, packet->data, packet->length + 1);
    cc1101_interface_set_interrupts_enabled(true);
    cc1101_interface_strobe(RF_STX);
    return SUCCESS;
}
// *****************************************************************************
// @fn          WriteRfSettings
// @brief       Write the RF configuration register settings
// @param       RF_SETTINGS* rfsettings  Pointer to the structure that holds the rf settings
// @return      none
// *****************************************************************************
void cc1101_interface_write_rfsettings(RF_SETTINGS *rfsettings)
{
    cc1101_interface_write_burst_reg(IOCFG2, (unsigned char*) rfsettings, sizeof(RF_SETTINGS));
}