Microchip® Advanced Software Framework

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 CDC interface Callback running when USB Host disable cdc interface. More...
 
bool main_cdc_enable (void)
 Called by CDC interface Callback running when USB Host enable CDC interface. More...
 
void usb_rx_notify (void)
 Callback that is called once a byte is received from USB. 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, LED0, LED_Toggle(), 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, LED1, LED_Toggle(), tx_buffer, TX_IDLE, tx_state, and udi_cdc_write_buf().

int main ( void  )
void main_cdc_disable ( void  )

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

References main_b_cdc_enable.

bool main_cdc_enable ( void  )

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

Return values
trueif cdc startup is successfully done

References main_b_cdc_enable.

void usb_rx_notify ( void  )

Callback that is called once a byte is received from USB.

References usb_rx_byte_rcvd.

static void usb_task ( void  )
static

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

References BUFFER_SIZE, cpu_irq_disable, cpu_irq_enable, main_b_cdc_enable, udi_cdc_getc(), udi_cdc_is_rx_ready(), usb_rx_buff_len, usb_rx_buffer, and usb_rx_byte_rcvd.

Referenced by main().

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().