⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 main.c

📁 ATMEL 90usb128 USB source,include USB protocol stack.
💻 C
字号:
//!
//! @file main.c,v
//!
//! Copyright (c) 2006 Atmel.
//!
//! Please read file license.txt for copyright notice.
//!
//! @brief Main for USB application.
//!
//! @version 1.4 at90usb128-usbkey-demo-3enum-host-mouse-1_0_4 $Id: main.c,v 1.4 2006/08/02 14:52:09 rletendu Exp $
//!
//! @mainpage AT90USBxxx USB dual role demonstration
//!
//! @section intro License
//! Use of this program is subject to Atmel's End User License Agreement.
//!
//! Please read file  \ref lic_page for copyright notice.
//!
//! @section install Description
//! This embedded application source code illustrates how to implement a dual role application with
//! the AT90USBxxx controller.
//!
//! As the AT90USBxxx implements  a device/host usb controller, the embedded application can operates
//! in one of the following usb operating modes:
//! - USB device
//! - USB reduced host controller
//!
//! This sample application can be configured for both STK525 or AT90USBKey hardware, see #TARGET_BOARD
//! define value in config.h file.
//!
//! @section src_code About the source code
//! This source code is usable with the following compilers:
//! - IAR Embedded Workbench (4.20a and higher)
//! - AVRGCC (WinAVR 20060421), please read \ref GCC_page.
//!
//! Support for other compilers may required modifications or attention for:
//! - compiler.h file 
//! - special registers declaration file
//! - interrupt subroutines declarations
//!
//! @section sample About the sample application
//! By default the demonstration is preconfigured for dual role USB application.
//! It means that the code generated allows to operate as a device or a host depending on the USB ID pin:
//! - Attached to a mini B plug (ID pin unconnected) the application will be used in the device operating mode.
//! Thus the application can be connected to a system host (PC) to operate with the three modes:
//!   -# Usb mouse (using joystick)
//!   -# Usb mass storage
//!   -# Usb generic HID (read temperature, potentiometer, LEDS control)
//! @image html appli_pc.gif
//! - Attached to a mini A plug (ID pin tied to ground) the application will operate in reduced host mode.
//! This mode allows to connect a standard USB mouse or another application in B device mode. 
//! @image html appli_host.gif
//!
//! Thus two instances of this application can be connected together with a miniA-miniB cable.
//! - The host operating mode of the application (that we call A device) can manage the connection
//! and the enumeration of a device application connected in device operating mode (that we call B device).
//! Once the device has been enumerated, the host high level application can operate USB applicative exchanges
//! with the B device. Here the sample host application writes 64 byte through a USB OUT pipe and read back
//! these data with an IN pipe.
//! - The device operating mode of the application (B device) answers to the enumeration requests (setup requests)
//! of the host controller. Once it has been properly enumerated the high level device application receives 64 data
//! through its OUT enpoint and when the host controller request for an IN exchange on its IN endpoints,
//! sends it back (loopback application).
//!
//! @section arch Architecture
//! As illustrated in the figure bellow, the application entry point is located is the main.c file.
//! The main function first performs the initialization of a scheduler module and then runs it in an infinite loop.
//! The scheduler is a simple infinite loop calling all its tasks defined in the conf_scheduler.h file.
//! No real time schedule is performed, when a task ends, the scheduler calls the next task defined in
//! the configuration file (conf_scheduler.h).
//!
//! The sample dual role application is based on four different tasks:
//! - The usb_task  (usb_task.c associated source file), is the task performing the USB low level
//! enumeration process in device or host mode.
//! Once this task has detected that the usb connection is fully operationnal, it updates different status flags
//! that can be check within the high level application tasks.
//! - The storage task performs SCSI bulk only protocol decoding and performs flash memory access.
//! - The hid task performs the high level device application operation.
//! Once the device is fully enumerated (DEVICE SET_CONFIGURATION request received), the task
//! checks for received data on its OUT endpoint and transmit  data on its IN endpoint.
//! - The mouse task performs mouse events decoding and report construction to the USB host.
//! - The host mouse task is active in reduce mode and manage events received from the USB mouse connected
//!
//! \image html arch_full.gif
//!

//_____  I N C L U D E S ___________________________________________________

#include "config.h"
#include "modules/scheduler/scheduler.h"
#include "lib_mcu/wdt/wdt_drv.h"
#include "lib_mcu/power/power_drv.h"

//_____ M A C R O S ________________________________________________________

//_____ D E F I N I T I O N S ______________________________________________

int main(void)
{
#ifndef  AVRGCC
   Wdt_off();
#else
   wdt_reset();
   Wdt_clear_flag();
   Wdt_change_enable();
   Wdt_stop();
#endif
   Clear_prescaler();
   scheduler();
	return 0;
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -