U8 chb_tx(U8 *hdr, U8 *data, U8 len) { U8 state = chb_get_state(); pcb_t *pcb = chb_get_pcb(); if ((state == BUSY_TX) || (state == BUSY_TX_ARET)) { return RADIO_WRONG_STATE; } // transition to the Transmit state chb_set_state(TX_ARET_ON); // write frame to buffer. first write header into buffer (add 1 for len byte), then data. chb_frame_write(hdr, CHB_HDR_SZ + 1, data, len); //Do frame transmission. pcb->tx_busy = true; chb_reg_read_mod_write(TRX_STATE, CMD_TX_START, 0x1F); // wait for the transmission to end, signalled by the TRX END flag while (!pcb->tx_end); pcb->tx_end = false; // check the status of the transmission return chb_get_status(); }
U8 chb_tx(U8 *hdr, U8 *data, U8 len) { U8 state = chb_get_state(); chb_pcb_t *pcb = chb_get_pcb(); if ((state == BUSY_TX) || (state == BUSY_TX_ARET)) { return RADIO_WRONG_STATE; } // TODO: check why we need to transition to the off state before we go to tx_aret_on chb_set_state(TRX_OFF); chb_set_state(TX_ARET_ON); // TODO: try and start the frame transmission by writing TX_START command instead of toggling // sleep pin...i just feel like it's kind of weird... // write frame to buffer. first write header into buffer (add 1 for len byte), then data. chb_frame_write(hdr, CHB_HDR_SZ + 1, data, len); //Do frame transmission chb_reg_read_mod_write(TRX_STATE, CMD_TX_START, 0x1F); // wait for the transmission to end, signalled by the TRX END flag while (!pcb->tx_end); pcb->tx_end = false; // check the status of the transmission return chb_get_status(); }
U8 chb_tx(U8 *hdr, U8 *data, U8 len) { U8 state = chb_get_state(); pcb_t *pcb = chb_get_pcb(); if ((state == BUSY_TX) || (state == BUSY_TX_ARET)) { return RADIO_WRONG_STATE; } // TODO: check why we need to transition to the off state before we go to tx_aret_on chb_set_state(TRX_OFF); chb_set_state(TX_ARET_ON); // TODO: try and start the frame transmission by writing TX_START command instead of toggling // sleep pin...i just feel like it's kind of weird... // write frame to buffer. first write header into buffer (add 1 for len byte), then data. chb_frame_write(hdr, CHB_HDR_SZ + 1, data, len); // TEST - check data in buffer //{ // U8 i, len, tmp[30]; // // len = 1 + CHB_HDR_SZ + len; // chb_sram_read(0, len, tmp); // for (i=0; i<len; i++) // { // printf("%02X ", tmp[i]); // } // printf("\n"); // state = chb_get_state(); // printf("State = %02X.\n", state); //} //TEST //Do frame transmission. Toggle the SLP_TR pin to initiate the frame transmission. CHB_SLPTR_ENABLE(); CHB_SLPTR_DISABLE(); // wait for the transmission to end, signalled by the TRX END flag while (!pcb->tx_end); pcb->tx_end = false; // check the status of the transmission return chb_get_status(); }