?? main.c
字號:
/*----------------------------------------------------------------------------------
*
* COPYRIGHT (c) 2001 by Singing Electrons, Inc. All rights reserved.
*
*
* Module Name : C:\se\adi\hidclass\source\main.c
*
* Description : The Main entrypoint
*
*
* Revision History : At bottom of the file.
*
*---------------------------------------------------------------------------------*/
/** include files **/
#include <sys/exception.h>
#include <sys/excause.h>
#include <defBF535.h>
#include "register.h"
#include "dtype.h"
#include "usb.h"
#include "usbdriver.h"
#include "msclass.h"
#include "dprintf.h"
/** local definitions **/
#define DisplayError //Later on we will do something special to display the error?
//This is for Eagle-35 only!
#define kVal 0xff00
#define kValSome 0xaa00
#define kValClear 0x7f00 //do not want to reset the AC97!
static inline void initLEDs(void) {
*(volatile uint16 *)FIO_DIR = (uint16)kVal;
asm("ssync;");
}
static inline void setLEDs(void) {
*(volatile uint16 *)FIO_FLAG_S = (uint16)kVal;
asm("ssync;");
}
static inline void setSomeLEDs(void) {
*(volatile uint16 *)FIO_FLAG_S = (uint16)kValSome;
asm("ssync;");
}
static inline void clearLEDs(void) {
*(volatile uint16 *)FIO_FLAG_C = (uint16)kValClear;
asm("ssync;");
}
static inline uint16 getPushBtns(void) {
uint16 val = *(volatile uint16 *)FIO_FLAG_S;
asm("ssync;");
return val;
}
#define DELAY_LOOP 300000
#define VENDOR_ID 0xCB00
#define PRODUCT_ID 0x0007
#define DEVICE_RELEASE 0x0002 //0.02
/* default settings */
/** external functions **/
/** external data **/
/** internal functions **/
static void delay(void);
/** public data **/
/** private data **/
int dumpDprintf = 0;
/** public functions **/
/** private functions **/
/** callbacks **/
static void OnSuspend (void);
static void OnResume (void);
static void OnReset (void);
#define IAR_SPORT0_MASK 0x00ff0000;
#define IAR_USB_MASK 0x00000f00;
/*------------------------------------------------------------
* main
*
* Parameters:
* None
*
* Globals Used:
* None
*
* Description:
* This is the entry-point.
*
* Returns:
* Nothing
*
*
*------------------------------------------------------------*/
void main (void)
{
UINT regValue;
InitDprintf ();
if (!MSCLASS_Init (VENDOR_ID, PRODUCT_ID, DEVICE_RELEASE,
OnSuspend, OnResume, OnReset))
goto done;
//printf ("Init complete\n");
//A real application would at this point do something!
initLEDs();
clearLEDs();
while(1)
{
clearLEDs();
delay();
if (gIsTransferActive)
setLEDs();
else
setSomeLEDs();
delay();
if (dumpDprintf)
{
DumpDprintf (dumpDprintf);
dumpDprintf = 0;
}
}
done:
//Run happily ever after
while (1)
;
}
void delay(void)
{
unsigned long i;
for(i=0; i<DELAY_LOOP; i++)
{
asm ("nop;nop;nop;nop;nop;");
}
}
/*------------------------------------------------------------
* OnSuspend
*
* Parameters:
*
* Globals Used:
* None
*
* Description:
* This routine will be called when USBDriver detects a
* suspend condition. Currently, it does nothing.
*
* Returns:
* Nothing.
*
*------------------------------------------------------------*/
void OnSuspend (void)
{
}
/*------------------------------------------------------------
* OnResume
*
* Parameters:
*
* Globals Used:
* None
*
* Description:
* This routine will be called when the USBDriver detects that
* the bus is out of suspend. Currently, it does nothing for custom
* device. For the mouse, it prepares the IN endpoint with the report.
*
* Returns:
* Nothing.
*
*------------------------------------------------------------*/
void OnResume (void)
{
}
/*------------------------------------------------------------
* OnReset
*
* Parameters:
*
* Globals Used:
* None
*
* Description:
* This routine will be called when the USBDriver detects reset
* signalling on the bus. Currently, it does nothing
*
* Returns:
* Nothing.
*
*------------------------------------------------------------*/
void OnReset (void)
{
}
/*----------------------------------------------------------------------------------
* $Log: main.c,v $
* Revision 1.2 2003/03/03 21:26:41 Devendra
* - BugFix: Writes were not working correctly.
* - Changed to using the SDRAM for disk data storage.
* - Increased the disk capacity to 16MB.
* - Added disk init. routine to make it look like a FAT formatted 16MB disk.
*
* Revision 1.1 2003/03/03 18:13:45 Devendra
* First Rev, the device enumerates as Mass Storage Class
*
* Revision 1.8 2003/01/17 00:51:13 Devendra
* Updated version number.
*
* Revision 1.7 2003/01/16 19:06:45 Devendra
* - Changed foreground task to blink the LEDs after initialization.
* - Changed foreground task to blink "all" the LEDs when playback is active.
* - Added support for AudioClass to perform non-ISR(foreground) tasks.
*
* Revision 1.6 2003/01/15 01:34:15 Devendra
* Updated version number.
*
* Revision 1.5 2003/01/13 20:00:25 Devendra
* Updated version number.
*
* Revision 1.4 2003/01/13 19:50:40 Devendra
* Removed DMA buffer init from main()
* Changed the priorities of interrupts - now SPORT0 is ivg7, USB is ivg8
*
* Revision 1.2 2003/01/10 01:41:32 Devendra
* Changed the revision number.
*
* Revision 1.1 2003/01/09 01:16:36 Devendra
* First Rev of AudioClass - have the device enumerated as audio device, and the volume control and mute are functional!
*
* Revision 1.2 2003/01/08 01:41:56 Devendra
* - Changes to remove divide operations (to improve DSP cycle utilization).
* - Supressed dprintfs
*
* Revision 1.1 2002/10/31 00:30:59 Devendra
* Moved all files in one folder to avoid IDE related problems.
*
* Revision 1.3 2002/10/30 02:36:40 Devendra
* - Added more abstraction to HIDCLASS. So that it's possible to build
* different devices without making any changes to the HIDCLASS module.
* - Added proper support for handling USB SUSPEND, RESUME, and RESET events.
*
* Revision 1.2 2002/10/22 17:47:47 Devendra
* - Refine LED blinking, etc.
* - Change output location.
*
* Revision 1.1 2002/10/22 17:23:39 Devendra
* Rearranged file locations.
*
* Revision 1.6 2002/10/14 05:16:04 Devendra
* - Custom Device now using Feature reports for I/O
* - Added compiler define/project configuration to switch between mouse and custom device.
*
* Revision 1.5 2002/10/14 01:33:15 Devendra
* Got "custom" device functional with buttons and lights!
*
* Revision 1.4 2002/10/09 17:09:32 Devendra
* - Added support for handling IN endpoints.
* - Added HID descriptors (HID and HID Report)
* - Modified the Interface descriptors to comply to HID Class Spec.
* - Added functionality to use the push-buttons on the Eagle-35 as a mouse (for buttons as well as for movement).
* - The device is now a fully functioning USB Mouse!
*
* Revision 1.3 2002/10/08 20:44:03 Devendra
* - Separated the printf logging to a different c module.
*
* Revision 1.2 2002/10/08 19:57:02 Devendra
* - Added specific callbacks for getting Device, Config, and String descriptors.
* - BugFix: Max. Packet Size was not being set correctly in ArmEndpoint.
* - Added internal buffer based logging to allow real-time "printfs".
* - Added String descriptors.
*
* Revision 1.1 2002/09/20 06:51:30 Devendra
* First Rev.
*
*
*---------------------------------------------------------------------------------*/
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -