Microchip® Advanced Software Framework

avr32/applications/rz600-uc3a-wireless-uart/main.c File Reference

Main file of the AVR UC3 A3 Wireless UART application.

Copyright (c) 2014-2018 Microchip Technology Inc. and its subsidiaries.

#include <string.h>
#include "compiler.h"
#include "board.h"
#include "sysclk.h"
#include "conf_usb.h"
#include "conf_at86rfx.h"
#include "udd.h"
#include "udc.h"
#include "udi_cdc.h"
#include "at86rfx_driver.h"

Macros

#define BUFFER_SIZE   (200)
 

Typedefs

typedef enum tx_state_tag tx_state_t
 Enum to store the current TX state of application. More...
 

Enumerations

enum  tx_state_tag {
  TX_IDLE = 0,
  TX_ONGOING
}
 Enum to store the current TX state of application. More...
 

Functions

static void app_task (void)
 Application task responsible for transferring bytes received from USB to RF module. More...
 
void at86rfx_tal_rx_frame_cb (uint8_t *rx_frame_array)
 Callback that is called once a frame is received. More...
 
void at86rfx_tal_tx_status_cb (uint8_t status)
 Callback that is called once tx is done. More...
 
int main (void)
 Main function. Execution starts here. More...
 
void main_cdc_disable (void)
 Called by UDI interface Callback running when USB Host disable CDC interface. More...
 
bool main_cdc_enable (void)
 Called by UDI interface Callback running when USB Host enable CDC interface. More...
 
void usb_rx_notify (void)
 This function is called by the USB data receive Interrupt The Receive buffer is filled in this function. More...
 
static void usb_task (void)
 USB task responsible for extracting the bytes received from USB buffer. More...
 

Variables

static volatile bool main_b_cdc_enable = false
 
static uint8_t tx_buffer [BUFFER_SIZE]
 
static tx_state_t tx_state = TX_IDLE
 
static uint8_t usb_rx_buff_len = 0
 
static uint8_t usb_rx_buffer [BUFFER_SIZE]
 
static volatile bool usb_rx_byte_rcvd = false
 

#define BUFFER_SIZE   (200)

Referenced by usb_task().

typedef enum tx_state_tag tx_state_t

Enum to store the current TX state of application.

Enum to store the current TX state of application.

Enumerator
TX_IDLE 
TX_ONGOING 

static void app_task ( void  )
static

Application task responsible for transferring bytes received from USB to RF module.

References at86rfx_tx_frame(), cpu_irq_disable, cpu_irq_enable, FCS_LEN, PHY_MAX_LENGTH, tx_buffer, TX_IDLE, TX_ONGOING, tx_state, usb_rx_buff_len, and usb_rx_buffer.

Referenced by main().

void at86rfx_tal_rx_frame_cb ( uint8_t *  rx_frame_array)

Callback that is called once a frame is received.

Parameters
rx_frame_arrayPointer for the received frame

References FCS_LEN, and udi_cdc_write_buf().

void at86rfx_tal_tx_status_cb ( uint8_t  status)

Callback that is called once tx is done.

Parameters
statusStatus of the transmission procedure

References AT86RFX_CHANNEL_ACCESS_FAILURE, AT86RFX_SUCCESS, at86rfx_tx_frame(), FCS_LEN, test_assert_true, tx_buffer, TX_IDLE, tx_state, and udi_cdc_write_buf().

int main ( void  )
void main_cdc_disable ( void  )

Called by UDI interface Callback running when USB Host disable CDC interface.

Called by CDC interface Callback running when USB Host disable cdc interface.

References main_b_cdc_enable, and main_b_cdc_enumerated.

bool main_cdc_enable ( void  )

Called by UDI interface Callback running when USB Host enable CDC interface.

Called by CDC interface Callback running when USB Host enable CDC interface.

Return values
trueif CDC startup is ok

References main_b_cdc_enable, and main_b_cdc_enumerated.

static void usb_task ( void  )
static

USB task responsible for extracting the bytes received from USB buffer.

volatile bool main_b_cdc_enable = false
static
uint8_t tx_buffer[BUFFER_SIZE]
static
tx_state_t tx_state = TX_IDLE
static
uint8_t usb_rx_buff_len = 0
static

Referenced by app_task(), and usb_task().

uint8_t usb_rx_buffer[BUFFER_SIZE]
static

Referenced by app_task(), and usb_task().

volatile bool usb_rx_byte_rcvd = false
static

Referenced by usb_rx_notify(), and usb_task().