/********************************************************************* * * Microchip USB C18 Firmware Version 1.0 * ********************************************************************* * FileName: main.c * Dependencies: See INCLUDES section below * Processor: PIC18 * Compiler: C18 2.30.01+ * Company: Microchip Technology, Inc. * * Author Date Comment *~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ * Rawin Rojvanit 19/11/04 Original. * Dario Greggio 03/03/05 . ********************************************************************/ /** I N C L U D E S **********************************************************/ #include #include #include "system\usb\usb.h" // Required #include "io_cfg.h" // Required #include // Optional #include "user\user.h" // Modifiable #include "user\pelucheusb18.h" // Modifiable #include "timers.h" /** V A R I A B L E S ********************************************************/ #pragma udata extern byte CounterL; /** P R I V A T E P R O T O T Y P E S ***************************************/ static void InitializeSystem(void); void USBTasks(void); void ResCnt(void); /** V E C T O R R E M A P P I N G *******************************************/ extern void _startup(void); // See c018i.c in your C18 compiler dir #pragma code _RESET_INTERRUPT_VECTOR = 0x000800 void _reset(void) { _asm goto _startup _endasm } #pragma code /** D E C L A R A T I O N S **************************************************/ /****************************************************************************** * Function: void main(void) * * PreCondition: None * * Input: None * * Output: None * * Side Effects: None * * Overview: Main program entry point. * * Note: None *****************************************************************************/ void main(void) { static word preBoot=65000; // sta merda serve da quando abbiamo Timer0 molto frequente (nonostante Tmr0Base sia altissimo... fuck@#!"[) InitializeSystem(); while(1) { ClrWdt(); USBTasks(); // USB Tasks // passa di qua ogni circa 10-20uSec... if(preBoot) preBoot--; else { ProcessIO(); // See user\user.c & .h if(!(CounterL & 3)) ResCnt(); } } //end while CloseTimer0(); } //end main /****************************************************************************** * Function: static void InitializeSystem(void) * * PreCondition: None * * Input: None * * Output: None * * Side Effects: None * * Overview: InitializeSystem is a centralize initialization routine. * All required USB initialization routines are called from * here. * * User application initialization routine should also be * called from here. * * Note: None *****************************************************************************/ static void InitializeSystem(void) { byte temp; // ADCON=0; // non usato ADCON1 |= 0x0F; // Default all pins to digital // nessun analogico (MA BISOGNA METTERE ST'ISTRUZIONE! non e' Power-On Default!) CMCON=0x7; // questo forse non serve... mInitializeUSBDriver(); // See usbdrv.h UserInit(); // See user.c & .h } //end InitializeSystem /****************************************************************************** * Function: void USBTasks(void) * * PreCondition: InitializeSystem has been called. * * Input: None * * Output: None * * Side Effects: None * * Overview: Service loop for USB tasks. * * Note: None *****************************************************************************/ void USBTasks(void) { /* * Servicing Hardware */ USBCheckBusStatus(); // Must use polling method if(UCFGbits.UTEYE != 1) USBDriverService(); // Interrupt or polling method #if defined(USB_USE_CDC) CDCTxService(); #endif // #if defined(USB_USE_HID) // non esiste un eqv HID... // HIDTxService(); // #endif } // end USBTasks /** EOF main.c ***************************************************************/