Rev 3514 Rev 3516
Line 42... Line 42...
42 #include <avr/pgmspace.h> 42 #include <avr/pgmspace.h>
43 #include <avr/wdt.h> 43 #include <avr/wdt.h>
44   44  
45 #include <util/delay.h> 45 #include <util/delay.h>
46   46  
47 #ifndef USBTINY -  
48 // use avrusb library -  
49 #include "usbdrv.h" -  
50 #include "oddebug.h" 47 #include "config.h"
51 #else -  
52 // use usbtiny library -  
53 #include "usb.h" -  
54 #include "usbtiny.h" -  
55 typedef byte_t uchar; -  
56   -  
57 #if! defined (__AVR_ATtiny45__) -  
58 #define USBDDR DDRC -  
59 #define USB_CFG_IOPORT PORTC -  
60 #else -  
61 #define USBDDR DDRB -  
62 #define USB_CFG_IOPORT PORTB -  
63 #endif -  
64   48  
65 #define USB_CFG_DMINUS_BIT USBTINY_DMINUS 49 // Include USB library (AVRUSB or USBTINY)
66 #define USB_CFG_DPLUS_BIT USBTINY_DPLUS 50 // -------------------
67   51  
-   52 #ifndef USBTINY
-   53 // use avrusb library
-   54 #include "usbdrv.h"
-   55 #include "oddebug.h"
-   56 #else
-   57 // use usbtiny library
-   58 #include "usb.h"
-   59 #include "usbtiny.h"
-   60 typedef byte_t uchar;
68 #define usbInit() usb_init() 61 #define usbInit() usb_init()
69 #define usbPoll() usb_poll() 62 #define usbPoll() usb_poll()
70 #endif 63 #endif
71   64  
72 #define ENABLE_SCL_EXPAND -  
73   -  
74 /* commands from USB, must e.g. match command ids in kernel driver */ 65 /* commands from USB, must e.g. match command ids in kernel driver */
75 #define CMD_ECHO 0 66 #define CMD_ECHO 0
76 #define CMD_GET_FUNC 1 67 #define CMD_GET_FUNC 1
77 #define CMD_SET_DELAY 2 68 #define CMD_SET_DELAY 2
78 #define CMD_GET_STATUS 3 69 #define CMD_GET_STATUS 3
Line 551... Line 542...
551 #ifdef DEBUG 542 #ifdef DEBUG
552 i2c_scan(); 543 i2c_scan();
553 #endif 544 #endif
554   545  
555 /* clear usb ports */ 546 /* clear usb ports */
556 USB_CFG_IOPORT &= (uchar)~((1<<USB_CFG_DMINUS_BIT)|(1<<USB_CFG_DPLUS_BIT)); 547 PORT(CONFIG_USB_PORT) &= (uchar)~((1<<CONFIG_USB_DMINUS)|(1<<CONFIG_USB_DPLUS));
557   548  
558 /* make usb data lines outputs */ 549 /* make usb data lines outputs */
559 USBDDR |= ((1<<USB_CFG_DMINUS_BIT)|(1<<USB_CFG_DPLUS_BIT)); 550 DDR(CONFIG_USB_PORT) |= ((1<<CONFIG_USB_DMINUS)|(1<<CONFIG_USB_DPLUS));
560   551  
561 /* USB Reset by device only required on Watchdog Reset */ 552 /* USB Reset by device only required on Watchdog Reset */
562 _delay_loop_2(40000); // 10ms 553 _delay_loop_2(40000); // 10ms
563   554  
564 /* make usb data lines inputs */ 555 /* make usb data lines inputs */
565 USBDDR &= ~((1<<USB_CFG_DMINUS_BIT)|(1<<USB_CFG_DPLUS_BIT)); 556 DDR(CONFIG_USB_PORT) &= ~((1<<CONFIG_USB_DMINUS)|(1<<CONFIG_USB_DPLUS));
566   557  
567 usbInit(); 558 usbInit();
568   559  
569 sei(); 560 sei();
570 for(;;) { /* main event loop */ 561 for(;;) { /* main event loop */