Ejemplo n.º 1
0
Archivo: main.c Proyecto: Mazetti/asf
void at86rfx_tal_tx_status_cb(uint8_t status)
{
	if (status == AT86RFX_SUCCESS) {
		/* LED indication for successful frame transmission. */
		LED_Toggle(LED1);
		udi_cdc_write_buf((const int *)&tx_buffer[1],
				tx_buffer[0] - FCS_LEN);
		tx_state = TX_IDLE;
	} else if (status == AT86RFX_CHANNEL_ACCESS_FAILURE) {
		/*
		 * Channel access failure is the only transmission failure that is handled
		 * within this application.
		 *
		 * In case of channel access failure the frame is retransmitted
		 */
		at86rfx_tx_frame(tx_buffer);
	} else {
		/*
		 * Other transmission status codes are not handled
		 * within this application.
		 * The transmission is considered as been completed for this frame.
		 */
		tx_state = TX_IDLE;
	}
}
Ejemplo n.º 2
0
Archivo: main.c Proyecto: Mazetti/asf
static void app_task(void)
{
	if (tx_state == TX_IDLE) {
		/* If bytes are received via USB, transmit the bytes.  */
		if (usb_rx_buff_len > 0) {
			tx_state = TX_ONGOING;

			/* Introducing critical section to avoid buffer corruption. */
			cpu_irq_disable();

			/* Check for maximum allowed frame length as per IEEE 802.15.4. */
			if (usb_rx_buff_len > (PHY_MAX_LENGTH - FCS_LEN)) {
				usb_rx_buff_len = PHY_MAX_LENGTH - FCS_LEN;
			}

			/* Update ppdu length within frame. */
			tx_buffer[0] = usb_rx_buff_len + FCS_LEN;

			/*
			 * Copy PSDU (actual PHY payload) into frame.
			 * Length of frame has to be first byte during transmission.
			*/
			memcpy(&tx_buffer[1], usb_rx_buffer, usb_rx_buff_len);
			usb_rx_buff_len = 0;

			cpu_irq_enable();

			/* AT86RFx API to transmit the frame. */
			at86rfx_tx_frame(tx_buffer);
		}
	}
}
Ejemplo n.º 3
0
/**
 * \brief Test the frame transmission on AT86RFx module
 *
 * This function will form a frame with length followed by payload.
 * Then call the \ref at86rfx_tx_frame for frame transmission
 * \ref at86rfx_tal_tx_status_cb gives the status of this transmission
 *
 * \param test Current test case.
 */
static void run_at86rfx_tx_test(const struct test_case *test)
{
	/* Buffer to hold frame to be transmitted. */
	uint8_t tx_buffer[20] = " Test frame";

	/* FCS length has to be added to length. */
	tx_buffer[0] = sizeof(" Test frame") + FCS_LEN;

	temp_test = (struct test_case *)test;

	/* AT86RFx API to transmit the frame. */
	at86rfx_tx_frame(tx_buffer);
}