Microchip® Advanced Software Framework

common/services/usb/class/vendor/device/example/main.c File Reference

Main functions for USB Device vendor example.

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

#include <asf.h>
#include "conf_usb.h"
#include "ui.h"

Functions

int main (void)
 Main function. Execution starts here. More...
 
void main_resume_action (void)
 Called by UDD when the USB line exit of suspend state. More...
 
bool main_setup_in_received (void)
 Manage the reception of setup request IN. More...
 
bool main_setup_out_received (void)
 Manage the reception of setup request OUT. More...
 
void main_sof_action (void)
 Called when a start of frame is received on USB line. More...
 
void main_suspend_action (void)
 Enters the application in low power mode Callback called when USB host sets USB line in suspend state. More...
 
void main_vendor_bulk_in_received (udd_ep_status_t status, iram_size_t nb_transfered, udd_ep_id_t ep)
 
void main_vendor_bulk_out_received (udd_ep_status_t status, iram_size_t nb_transfered, udd_ep_id_t ep)
 
void main_vendor_disable (void)
 Notify via user interface that enumeration is disabled This is called by vendor interface when USB Host disable it. More...
 
bool main_vendor_enable (void)
 Notify via user interface that enumeration is ok This is called by vendor interface when USB Host enable it. More...
 
void main_vendor_int_in_received (udd_ep_status_t status, iram_size_t nb_transfered, udd_ep_id_t ep)
 
void main_vendor_int_out_received (udd_ep_status_t status, iram_size_t nb_transfered, udd_ep_id_t ep)
 
void main_vendor_iso_in_received (udd_ep_status_t status, iram_size_t nb_transfered, udd_ep_id_t ep)
 
void main_vendor_iso_out_received (udd_ep_status_t status, iram_size_t nb_transfered, udd_ep_id_t ep)
 

Variables

static volatile bool main_b_vendor_enable = false
 

Buffer for loopback

#define MAIN_LOOPBACK_SIZE   1024
 Size of buffer used for the loopback. More...
 
static COMPILER_WORD_ALIGNED
uint8_t 
main_buf_loopback [MAIN_LOOPBACK_SIZE]
 
static uint8_t main_buf_iso_sel
 

#define MAIN_LOOPBACK_SIZE   1024

Size of buffer used for the loopback.

int main ( void  )
void main_resume_action ( void  )

Called by UDD when the USB line exit of suspend state.

Turn on a led to notify active mode Called when the USB line is resumed from the suspend state.

References ui_wakeup().

bool main_setup_in_received ( void  )

Manage the reception of setup request IN.

Return values
trueif request accepted

References main_buf_loopback, min, udd_ctrl_request_t::payload, udd_ctrl_request_t::payload_size, udd_ctrl_request_t::req, udd_g_ctrlreq, ui_loop_back_state(), and usb_setup_req_t::wLength.

bool main_setup_out_received ( void  )

Manage the reception of setup request OUT.

Return values
trueif request accepted

References main_buf_loopback, min, udd_ctrl_request_t::payload, udd_ctrl_request_t::payload_size, udd_ctrl_request_t::req, udd_g_ctrlreq, ui_loop_back_state(), and usb_setup_req_t::wLength.

void main_sof_action ( void  )

Called when a start of frame is received on USB line.

Manages the leds behaviors Called when a start of frame is received on USB line each 1ms.

References main_b_vendor_enable, udd_get_frame_number(), and ui_process().

void main_suspend_action ( void  )

Enters the application in low power mode Callback called when USB host sets USB line in suspend state.

References ui_powerdown().

void main_vendor_disable ( void  )

Notify via user interface that enumeration is disabled This is called by vendor interface when USB Host disable it.

References main_b_vendor_enable.

bool main_vendor_enable ( void  )

Notify via user interface that enumeration is ok This is called by vendor interface when USB Host enable it.

Return values
trueif vendor startup is successfully done

References main_b_vendor_enable, main_buf_iso_sel, main_vendor_bulk_in_received(), main_vendor_int_in_received(), main_vendor_iso_out_received(), and UDD_EP_TRANSFER_OK.

void main_vendor_iso_in_received ( udd_ep_status_t  status,
iram_size_t  nb_transfered,
udd_ep_id_t  ep 
)

volatile bool main_b_vendor_enable = false
static
uint8_t main_buf_iso_sel
static