SAMV71 Xplained Ultra Software Package 1.5

main.c

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