SAMV71 Xplained Ultra Software Package 1.4

main.c

00001 /* ----------------------------------------------------------------------------
00002  *         SAM Software Package License
00003  * ----------------------------------------------------------------------------
00004  * Copyright (c) 2015, Atmel Corporation
00005  *
00006  * All rights reserved.
00007  *
00008  * Redistribution and use in source and binary forms, with or without
00009  * modification, are permitted provided that the following conditions are met:
00010  *
00011  * - Redistributions of source code must retain the above copyright notice,
00012  * this list of conditions and the disclaimer below.
00013  *
00014  * Atmel's name may not be used to endorse or promote products derived from
00015  * this software without specific prior written permission.
00016  *
00017  * DISCLAIMER: THIS SOFTWARE IS PROVIDED BY ATMEL "AS IS" AND ANY EXPRESS OR
00018  * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
00019  * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT ARE
00020  * DISCLAIMED. IN NO EVENT SHALL ATMEL BE LIABLE FOR ANY DIRECT, INDIRECT,
00021  * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
00022  * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA,
00023  * OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
00024  * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
00025  * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
00026  * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
00027  * ----------------------------------------------------------------------------
00028  */
00029 
00030 /**
00031  *  \page usb_host_cdc USB Host CDC Example
00032  *
00033  *  \section Purpose
00034  *
00035  * This example shows how to implement a USB host CDC
00036  * on SAM V71 Xplained Ultra board.
00037  *
00038  *  \section Requirements
00039  *  This package can be used with SAM V71 Xplained Ultra board.
00040  *
00041  *  \section Description
00042  *
00043  * After loading the application, connect the board to a USB
00044  * device CDC.
00045  * The example is a bridge between a USART from the main microchip
00046  * and the USB host CDC interface
00047  *
00048  *  \section Usage
00049  *
00050  *  -# Build the program and download it inside the SAM V71 Xplained Ultra board.
00051  *  Please refer to the Getting Started with SAM V71 Microcontrollers.pdf
00052  *  -# On the computer, open and configure a terminal application
00053  *     (e.g. HyperTerminal on Microsoft Windows) with these settings:
00054  *    - 115200 baud rates
00055  *    - 8 bits of data
00056  *    - No parity
00057  *    - 1 stop bit
00058  *    - No flow control
00059  *  -# Connect the CDC device such as another board with usb device cdc 
00060  *     application to SAM V71 Xplained Ultra board with the OTG wire.
00061  *  -# Start the application. In the terminal window, the
00062  *     following text should appear (values depend on the board and chip used):
00063  *     \code
00064  *      -- USB HOST CDC Example xxx --
00065  *      -- xxxxxx-xx
00066  *      -- Compiled: xxx xx xxxx xx:xx:xx --
00067  *     \endcode
00068  *  -# Human interface on SAM V71 Xplained Ultra board.:
00069  *   - SAM V71 USART used USART2 on J505 connector
00070  *   - Led 0 is continuously on when a device is connected
00071  *   - Led 0 blinks when USB host has checked and enabled CDC interface
00072  *   - The blink is slow (1s) with low speed device
00073  *   - The blink is normal (0.5s) with full speed device
00074  *   - The blink is fast (0.25s) with high speed device
00075  *   - Led 1 is on during data transfer between CDC and UART
00076  *
00077  *  \section References
00078  *  - usb_host_cdc/main.c
00079  *  - usb_host_cdc/ui.c
00080  *  - usb_host_cdc/usart_cdc.c
00081  *  - led.c
00082  *  - USBH.c
00083  *  - USBH_HAL.c
00084  *  - uhi_cdc.c
00085  */
00086 
00087 #include "board.h"
00088 #include "conf_usb_host.h"
00089 #include "ui.h"
00090 
00091 const Pin USB_HOST[] = PINS_VBUS_EN;
00092 /**  Pins to configure for the application.*/
00093 const Pin UsartPins[] = {PINS_USART};
00094 /*! \brief Main function. Execution starts here.
00095  */
00096 int main(void)
00097 {
00098 
00099     WDT_Disable( WDT ) ;
00100   
00101     SCB_EnableICache();
00102     SCB_EnableDCache();
00103 
00104     /* Output example information */
00105     printf("-- USB HOST CDC Example %s --\n\r", SOFTPACK_VERSION);
00106     printf("-- %s\n\r", BOARD_NAME);
00107     printf( "-- Compiled: %s %s  With %s--\n\r", __DATE__, __TIME__ , COMPILER_NAME) ;
00108 
00109     TimeTick_Configure();
00110     PIO_Configure(USB_HOST, PIO_LISTSIZE(USB_HOST));
00111     /* Configure USART pins*/
00112     PIO_Configure( UsartPins, PIO_LISTSIZE( UsartPins ) ) ;
00113     PIO_Clear(USB_HOST);
00114 
00115     /* Initialize interrupts */
00116     irq_initialize_vectors();
00117     cpu_irq_enable();
00118 
00119     
00120     /* Initialize the user interface */
00121     ui_init();
00122 
00123     /* Start USB host stack */
00124     USBH_start();
00125 
00126     /* The main loop manages only the power mode
00127        because the USB management is done by interrupt */
00128     while (true) {
00129         //sleepmgr_enter_sleep();
00130     }
00131 }
00132 
 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Defines