Sizeoptimized v-usb added.

This commit is contained in:
Kai Lauterbach 2011-12-18 19:35:12 +01:00
parent c1d91c2448
commit 9d6eb9dfc5
4 changed files with 57 additions and 39 deletions

View file

@ -249,8 +249,8 @@ section at the end of this file).
* obdev's free shared VID/PID pair. See the file USB-IDs-for-free.txt for
* details.
*/
#define USB_CFG_DEVICE_NAME 'M', 'i', 'n', 'i', 'L', 'E', 'D', 'C', 'u', 'b', 'e'
#define USB_CFG_DEVICE_NAME_LEN 11
#define USB_CFG_DEVICE_NAME 'L', 'E', 'D', 'C', 'u', 'b', 'e'
#define USB_CFG_DEVICE_NAME_LEN 7
/* Same as above for the device name. If you don't want a device name, undefine
* the macros. See the file USB-IDs-for-free.txt before you assign a name if
* you use a shared VID/PID.
@ -370,4 +370,6 @@ section at the end of this file).
/* #define USB_INTR_PENDING_BIT INTF0 */
/* #define USB_INTR_VECTOR INT0_vect */
#define USB_CFG_USE_GPIOR 1
#endif /* __usbconfig_h_included__ */

View file

@ -46,8 +46,13 @@ uchar usbCurrentDataToken;/* when we check data toggling to ignore duplica
/* USB status registers / not shared with asm code */
uchar *usbMsgPtr; /* data to transmit next -- ROM or RAM address */
static usbMsgLen_t usbMsgLen = USB_NO_MSG; /* remaining number of bytes */
#ifdef USB_CFG_USE_GPIOR
# define usbMsgFlags (*((uchar*)&GPIOR0))
#else
static uchar usbMsgFlags; /* flag values see below */
#endif
#define USB_FLG_MSGPTR_IS_ROM (1<<6)
#define USB_FLG_USE_USER_RW (1<<7)
@ -194,16 +199,6 @@ PROGMEM char usbDescriptorConfiguration[] = { /* USB configuration descriptor
/* ------------------------------------------------------------------------- */
static inline void usbResetDataToggling(void)
{
#if USB_CFG_HAVE_INTRIN_ENDPOINT && !USB_CFG_SUPPRESS_INTR_CODE
USB_SET_DATATOKEN1(USB_INITIAL_DATATOKEN); /* reset data toggling for interrupt endpoint */
# if USB_CFG_HAVE_INTRIN_ENDPOINT3
USB_SET_DATATOKEN3(USB_INITIAL_DATATOKEN); /* reset data toggling for interrupt endpoint */
# endif
#endif
}
static inline void usbResetStall(void)
{
#if USB_CFG_IMPLEMENT_HALT && USB_CFG_HAVE_INTRIN_ENDPOINT
@ -547,9 +542,9 @@ uchar len;
/* ------------------------------------------------------------------------- */
#ifdef USB_RESET_HOOK
static inline void usbHandleResetHook(uchar notResetState)
{
#ifdef USB_RESET_HOOK
static uchar wasReset;
uchar isReset = !notResetState;
@ -557,8 +552,8 @@ uchar isReset = !notResetState;
USB_RESET_HOOK(isReset);
wasReset = isReset;
}
#endif
}
#endif
/* ------------------------------------------------------------------------- */
@ -591,35 +586,22 @@ uchar i;
for(i = 20; i > 0; i--){
uchar usbLineStatus = USBIN & USBMASK;
if(usbLineStatus != 0) /* SE0 has ended */
#ifdef USB_RESET_HOOK
goto isNotReset;
#else
return;
#endif
}
/* RESET condition, called multiple times during reset */
usbNewDeviceAddr = 0;
usbDeviceAddr = 0;
usbResetStall();
DBG1(0xff, 0, 0);
#ifdef USB_RESET_HOOK
isNotReset:
usbHandleResetHook(i);
}
/* ------------------------------------------------------------------------- */
USB_PUBLIC void usbInit(void)
{
#if USB_INTR_CFG_SET != 0
USB_INTR_CFG |= USB_INTR_CFG_SET;
#endif
#if USB_INTR_CFG_CLR != 0
USB_INTR_CFG &= ~(USB_INTR_CFG_CLR);
#endif
USB_INTR_ENABLE |= (1 << USB_INTR_ENABLE_BIT);
usbResetDataToggling();
#if USB_CFG_HAVE_INTRIN_ENDPOINT && !USB_CFG_SUPPRESS_INTR_CODE
usbTxLen1 = USBPID_NAK;
#if USB_CFG_HAVE_INTRIN_ENDPOINT3
usbTxLen3 = USBPID_NAK;
#endif
#endif
}
/* ------------------------------------------------------------------------- */

View file

@ -165,12 +165,6 @@ USB messages, even if they address another (low-speed) device on the same bus.
struct usbRequest; /* forward declaration */
USB_PUBLIC void usbInit(void);
/* This function must be called before interrupts are enabled and the main
* loop is entered. We exepct that the PORT and DDR bits for D+ and D- have
* not been changed from their default status (which is 0). If you have changed
* them, set both back to 0 (configure them as input with no internal pull-up).
*/
USB_PUBLIC void usbPoll(void);
/* This function must be called at regular intervals from the main loop.
* Maximum delay between calls is somewhat less than 50ms (USB timeout for
@ -732,4 +726,40 @@ typedef struct usbRequest{
/* ------------------------------------------------------------------------- */
#ifndef __ASSEMBLER__
static inline void usbResetDataToggling(void)
{
#if USB_CFG_HAVE_INTRIN_ENDPOINT && !USB_CFG_SUPPRESS_INTR_CODE
USB_SET_DATATOKEN1(USB_INITIAL_DATATOKEN); /* reset data toggling for interrupt endpoint */
# if USB_CFG_HAVE_INTRIN_ENDPOINT3
USB_SET_DATATOKEN3(USB_INITIAL_DATATOKEN); /* reset data toggling for interrupt endpoint */
# endif
#endif
}
static inline void usbInit(void)
{
#if USB_INTR_CFG_SET != 0
USB_INTR_CFG |= USB_INTR_CFG_SET;
#endif
#if USB_INTR_CFG_CLR != 0
USB_INTR_CFG &= ~(USB_INTR_CFG_CLR);
#endif
USB_INTR_ENABLE |= (1 << USB_INTR_ENABLE_BIT);
usbResetDataToggling();
#if USB_CFG_HAVE_INTRIN_ENDPOINT && !USB_CFG_SUPPRESS_INTR_CODE
usbTxLen1 = USBPID_NAK;
#if USB_CFG_HAVE_INTRIN_ENDPOINT3
usbTxLen3 = USBPID_NAK;
#endif
#endif
}
/* This function must be called before interrupts are enabled and the main
* loop is entered. We exepct that the PORT and DDR bits for D+ and D- have
* not been changed from their default status (which is 0). If you have changed
* them, set both back to 0 (configure them as input with no internal pull-up).
*/
#endif /* __ASSEMBLER */
#endif /* __usbdrv_h_included__ */

View file

@ -368,6 +368,10 @@ usbMFTimeout:
# endif
#endif
/* place the interrupt routine in .vectors, after the jump to __init.
Warning: This depends on correct linking order. Link crt0 before usbdrasm! */
.section .vectors
#if USB_CFG_CHECK_CRC /* separate dispatcher for CRC type modules */
# if USB_CFG_CLOCK_KHZ == 18000
# include "usbdrvasm18-crc.inc"