- /***************** Functions ****************/
- /**
- * Set up a message to be sent. First load it into the outbound tx buffer
- * on the chip, then attempt to send it.
- * @param *p_msg Pointer to the message that needs to be sent
- * @param cca TRUE if this transmit should use clear channel assessment
- */
- error_t load( ieee154_txframe_t *data) {
- atomic {
- if (m_state == S_CANCEL) {
- return ECANCEL;
- }
-
- if ( m_state != S_STARTED ) {
- return FAIL;
- }
-
- m_state = S_LOAD;
-/* m_msg = p_msg;*/
- m_data = data;
- totalCcaChecks = 0;
- }
-
- if ( acquireSpiResource() == SUCCESS ) {
- loadTXFIFO();
- }
-
- return SUCCESS;
- }
-
- /**
- * Resend a packet that already exists in the outbound tx buffer on the
- * chip
- * @param cca TRUE if this transmit should use clear channel assessment
- */
-/* error_t resend( bool cca ) {*/
-
-/* atomic {*/
-/* if (m_state == S_LOAD_CANCEL*/
-/* || m_state == S_CCA_CANCEL*/
-/* || m_state == S_TX_CANCEL) {*/
-/* return ECANCEL;*/
-/* }*/
-/* */
-/* if ( m_state != S_STARTED ) {*/
-/* return FAIL;*/
-/* }*/
-/* */
-/* m_cca = cca;*/
-/* m_state = cca ? S_SAMPLE_CCA : S_BEGIN_TRANSMIT;*/
-/* totalCcaChecks = 0;*/
-/* }*/
-/* */
-/* if(m_cca) {*/
-/* signal RadioBackoff.requestInitialBackoff(m_msg);*/
-/* call BackoffAlarm.start( myInitialBackoff );*/
-/* */
-/* } else if ( acquireSpiResource() == SUCCESS ) {*/
-/* attemptSend();*/
-/* }*/
-/* */
-/* return SUCCESS;*/
-/* }*/
-
- /**
- * Attempt to send the packet we have loaded into the tx buffer on
- * the radio chip. The STXONCCA will send the packet immediately if
- * the channel is clear. If we're not concerned about whether or not
- * the channel is clear (i.e. m_cca == FALSE), then STXON will send the
- * packet without checking for a clear channel.
- *
- * If the packet didn't get sent, then congestion == TRUE. In that case,
- * we reset the backoff timer and try again in a moment.
- *
- * If the packet got sent, we should expect an SFD interrupt to take
- * over, signifying the packet is getting sent.
- */
- void attemptSend(bool cca) {
- uint8_t status;
- bool congestion = TRUE;
-
- atomic {
- call CSN.set();
- call CSN.clr();