Пример #1
0
/**
 * @brief Callback that is called if data has been received by trx.
 *
 * @param rx_frame_array Pointer to data array containing received frame
 */
void tal_rx_frame_cb(uint8_t *rx_frame_array)
{
    uint8_t rx_payload_len = rx_frame_array[0] - FRAME_OVERHEAD;
    uint8_t *rx_payload_ptr = rx_frame_array + FRAME_OVERHEAD + LENGTH_FIELD_LEN - FCS_LEN;
    uint8_t sio_len_rx;

    /* Print received data to terminal program. */
    bool sio_ongoing = true;

    do
    {
        sio_len_rx = pal_sio_tx(SIO_CHANNEL, rx_payload_ptr, rx_payload_len);

        if (sio_len_rx < rx_payload_len)
        {
            rx_payload_len -= sio_len_rx;
            rx_payload_ptr += sio_len_rx;
            pal_task();
        }
        else
        {
            sio_ongoing = false;
        }
    } while (sio_ongoing);

    pal_led(LED_DATA_RX, LED_TOGGLE);    // indicating data recption
}
Пример #2
0
/**
 * \brief Main function of the Performance Analyzer application
 * \ingroup group_app_init
 */
int main(void)
{
        irq_initialize_vectors();

	/* Initialize the board.
	 * The board-specific conf_board.h file contains the configuration of
	 * the board initialization.
	 */
	board_init();
	sysclk_init();
        
    /*
     * Power ON - so set the board to INIT state. All hardware, PAL, TAL and
     * stack level initialization must be done using this function
     */
    set_main_state(INIT, NULL);

    cpu_irq_enable();
    
	sio2host_init();

    
    /* INIT was a success - so change to WAIT_FOR_EVENT state */
    set_main_state(WAIT_FOR_EVENT, NULL);

    /* Endless while loop */
    while (1)
    {
        pal_task(); /* Handle platform specific tasks, like serial interface */
        tal_task(); /* Handle transceiver specific tasks */
        app_task(); /* Application task */
        serial_data_handler();
    }
}
Пример #3
0
bool wpan_task(void)
{
    bool event_processed;
    uint8_t *event = NULL;

    /* mac_task returns true if a request was processed completely */
    event_processed = mac_task();

    /*
     * MAC to NHLE event queue should be dispatched
     * irrespective of the dispatcher state.
     */
    event = (uint8_t *)qmm_queue_remove(&mac_nhle_q, NULL);

    /* If an event has been detected, handle it. */
    if (NULL != event) {
        dispatch_event(event);
        event_processed = true;
    }

#ifdef ENABLE_RTB
    rtb_task();
#endif  /* ENABLE_RTB */
    tal_task();
    pal_task();

    return (event_processed);
}
Пример #4
0
/**
 * @brief Main function of the Wireless UART application
 */
int main(void)
{
    /* Initialize the TAL layer */
    if (tal_init() != MAC_SUCCESS)
    {
        // something went wrong during initialization
        pal_alert();
    }

    /* Calibrate MCU's RC oscillator */
    pal_calibrate_rc_osc();

    /* Initialize LEDs */
    pal_led_init();
    pal_led(LED_START, LED_ON);     // indicating application is started
    pal_led(LED_DATA_RX, LED_OFF);  // indicating data reception
    pal_led(LED_DATA_TX, LED_OFF);  // indicating successfull data transmission

    /*
     * The stack is initialized above, hence the global interrupts are enabled
     * here.
     */
    pal_global_irq_enable();

    /* Initialize the serial interface used for communication with terminal program */
    if (pal_sio_init(SIO_CHANNEL) != MAC_SUCCESS)
    {
        // something went wrong during initialization
        pal_alert();
    }

    /* Configure TX frame and transceiver */
    configure_frame_sending();

    /* Switch receiver on */
    tal_rx_enable(PHY_RX_ON);

#if(SEND_BLOCKWISE==true)
    start_timer();
#endif

    /* Endless while loop */
    while (1)
    {
        pal_task(); /* Handle platform specific tasks, like serial interface */
        tal_task(); /* Handle transceiver specific tasks */
#if(!(SEND_BLOCKWISE==true))
        app_task(); /* Application task */
#endif
    }
}
Пример #5
0
/**
 * @brief Main function of the Sniffer application
 */
int main(void)
{

   /* Initialize the TAL layer */
    if (tal_init() != MAC_SUCCESS)
    {
        /* something went wrong during initialization*/
        pal_alert();
    }

    /* Calibrate MCU's RC oscillator */
    pal_calibrate_rc_osc();

    /* Initialize LEDs */
    pal_led_init();


    /*
     * The stack is initialized above, hence the global interrupts are enabled
     * here.
     */
    pal_global_irq_enable();

    /* Initialize the serial interface used for communication with sniffer
       GUI */
    if (pal_sio_init(SIO_CHANNEL) != MAC_SUCCESS)
    {
        /* something went wrong during initialization */
        pal_alert();
    }

    //sio_getchar();

    Wireshark_Settings = INIT_STATE ;

    /* Endless while loop */
    while (1)
    {
        pal_task();
        tal_task();
        app_task();
    }
}
Пример #6
0
/**
 * @brief Callback that is called once tx is done.
 *
 * @param status    Status of the transmission procedure
 */
void tal_tx_frame_done_cb(retval_t status)
{
    if (status == MAC_SUCCESS)
    {
        uint8_t tx_payload_len = tx_buffer[0] - FRAME_OVERHEAD;
        uint8_t *tx_payload_ptr = tx_buffer + FRAME_OVERHEAD + LENGTH_FIELD_LEN - FCS_LEN;
        uint8_t sio_len_tx;

        /* Print transmitted bytes to terminal program. */

        bool sio_ongoing = true;

        do
        {
            sio_len_tx = pal_sio_tx(SIO_CHANNEL, tx_payload_ptr, tx_payload_len);

            if (sio_len_tx < tx_payload_len)
            {
                tx_payload_len -= sio_len_tx;
                tx_payload_ptr += sio_len_tx;
                pal_task();
            }
            else
            {
                sio_ongoing = false;
            }
        } while (sio_ongoing);

        pal_led(LED_DATA_TX, LED_TOGGLE);    // indicating successfull data transmission

        /* After transmission is completed, allow next transmission. */
        tx_state = TX_IDLE;
    }
    else if (status == MAC_CHANNEL_ACCESS_FAILURE)
        /*
         * Channel access failure is the only transmission failure that makes sense
         * to be handled within this application. For handling other status codes,
         * such as MAC_NO_ACK, this is probably the wrong application on the wrong layer.
         * For absolutely reliable transmission, please use a MAC or TAL based
         * application. The Tiny-TAL is not designed for such a purpose.
         *
         * In case of channel access failure the frame is retried.
         */
    {
        /* Transmission was not successful, initiate retry. */
        tx_state = TX_RETRY;
        //TODO: retry counter?
    }
    else
        /*
         * Other transmission status codes, such as MAC_NO_ACK are not handled
         * within this application.
         * The transmission is considered as beeing completed for this frame.
         */
    {
        tx_state = TX_IDLE;

#if(ALERT_ON_ERROR==true)
        pal_alert();
#endif
    }
}