aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorChristian Starkjohann <cs+github@obdev.at>2008-06-18 14:05:26 +0000
committerChristian Starkjohann <cs+github@obdev.at>2008-06-18 14:05:26 +0000
commit5280c7cda766ba100065de82407e8414d13e8e9f (patch)
treed7c49d97771059007e130f8d7d0f1f39bc1e982f
parent4f0353ba8355196550a842576f8f5af47392f4a7 (diff)
downloadv-usb-5280c7cda766ba100065de82407e8414d13e8e9f.tar.gz
v-usb-5280c7cda766ba100065de82407e8414d13e8e9f.tar.bz2
v-usb-5280c7cda766ba100065de82407e8414d13e8e9f.zip
- extended concept of usbportability header: moved all portability stuff there
-rw-r--r--usbdrv/Changelog.txt2
-rw-r--r--usbdrv/usbdrv.c13
-rw-r--r--usbdrv/usbdrvasm.S19
-rw-r--r--usbdrv/usbportability.h44
4 files changed, 44 insertions, 34 deletions
diff --git a/usbdrv/Changelog.txt b/usbdrv/Changelog.txt
index 6c1a0d4..6a1348a 100644
--- a/usbdrv/Changelog.txt
+++ b/usbdrv/Changelog.txt
@@ -237,3 +237,5 @@ Scroll down to the bottom to see the most recent changes.
- Added code to command line tool(s) which claims an interface. This code
is disabled by default, but may be necessary on newer Linux kernels.
- Added usbconfig.h option "USB_CFG_CHECK_DATA_TOGGLING".
+ - New header "usbportability.h" prepares ports to other development
+ environments.
diff --git a/usbdrv/usbdrv.c b/usbdrv/usbdrv.c
index 0168a44..4917078 100644
--- a/usbdrv/usbdrv.c
+++ b/usbdrv/usbdrv.c
@@ -55,7 +55,7 @@ static uchar usbMsgFlags; /* flag values see below */
/*
optimizing hints:
- do not post/pre inc/dec integer values in operations
-- assign value of PRG_RDB() to register variables and don't use side effects in arg
+- assign value of USB_READ_FLASH() to register variables and don't use side effects in arg
- use narrow scope for variables which should be in X/Y/Z register
- assign char sized expressions to variables to force 8 bit arithmetics
*/
@@ -194,15 +194,6 @@ PROGMEM char usbDescriptorConfiguration[] = { /* USB configuration descriptor
/* ------------------------------------------------------------------------- */
-/* We don't use prog_int or prog_int16_t for compatibility with various libc
- * versions. Here's an other compatibility hack:
- */
-#ifndef PRG_RDB
-#define PRG_RDB(addr) pgm_read_byte(addr)
-#endif
-
-/* ------------------------------------------------------------------------- */
-
static inline void usbResetDataToggling(void)
{
#if USB_CFG_HAVE_INTRIN_ENDPOINT
@@ -504,7 +495,7 @@ static uchar usbDeviceRead(uchar *data, uchar len)
uchar i = len, *r = usbMsgPtr;
if(usbMsgFlags & USB_FLG_MSGPTR_IS_ROM){ /* ROM data */
do{
- uchar c = PRG_RDB(r); /* assign to char size variable to enforce byte ops */
+ uchar c = USB_READ_FLASH(r); /* assign to char size variable to enforce byte ops */
*data++ = c;
r++;
}while(--i);
diff --git a/usbdrv/usbdrvasm.S b/usbdrv/usbdrvasm.S
index 119b738..cdaa796 100644
--- a/usbdrv/usbdrvasm.S
+++ b/usbdrv/usbdrvasm.S
@@ -17,11 +17,7 @@ the file appropriate for the given clock rate.
#define __SFR_OFFSET 0 /* used by avr-libc's register definitions */
#include "usbportability.h"
-#ifndef __IAR_SYSTEMS_ASM__
-# define macro .macro /* GNU Assembler macro definition */
-# define endm .endm /* End of GNU Assembler macro definition */
-#endif /* __IAR_SYSTEMS_ASM__ */
-#include "usbdrv.h" /* for common defs */
+#include "usbdrv.h" /* for common defs */
/* register names */
#define x1 r16
@@ -37,17 +33,6 @@ the file appropriate for the given clock rate.
/* Some assembler dependent definitions and declarations: */
#ifdef __IAR_SYSTEMS_ASM__
-
-# define nop2 rjmp $+2 /* jump to next instruction */
-# define XL r26
-# define XH r27
-# define YL r28
-# define YH r29
-# define ZL r30
-# define ZH r31
-# define lo8(x) LOW(x)
-# define hi8(x) (((x)>>8) & 0xff) /* not HIGH to allow XLINK to make a proper range check */
-
extern usbRxBuf, usbDeviceAddr, usbNewDeviceAddr, usbInputBufOffset
extern usbCurrentTok, usbRxLen, usbRxToken, usbTxLen
extern usbTxBuf, usbTxStatus1, usbTxStatus3
@@ -70,8 +55,6 @@ the file appropriate for the given clock rate.
#else /* __IAR_SYSTEMS_ASM__ */
-# define nop2 rjmp .+0 /* jump to next instruction */
-
# ifndef USB_INTR_VECTOR /* default to hardware interrupt INT0 */
# define USB_INTR_VECTOR SIG_INTERRUPT0
# endif
diff --git a/usbdrv/usbportability.h b/usbdrv/usbportability.h
index e2db604..43d9a48 100644
--- a/usbdrv/usbportability.h
+++ b/usbdrv/usbportability.h
@@ -26,7 +26,9 @@ Thanks to Oleg Semyonov for his help with the IAR tools port!
/* We check explicitly for IAR and CodeVision. Default is avr-gcc/avr-libc. */
+/* ------------------------------------------------------------------------- */
#if defined __IAR_SYSTEMS_ICC__ || defined __IAR_SYSTEMS_ASM__ /* check for IAR */
+/* ------------------------------------------------------------------------- */
#ifndef ENABLE_BIT_DEFINITIONS
# define ENABLE_BIT_DEFINITIONS 1 /* Enable bit definitions */
@@ -50,7 +52,7 @@ Thanks to Oleg Semyonov for his help with the IAR tools port!
# define PROGMEM __flash
#endif
-#define PRG_RDB(addr) (*(PROGMEM char *)(addr))
+#define USB_READ_FLASH(addr) (*(PROGMEM char *)(addr))
/* The following definitions are not needed by the driver, but may be of some
* help if you port a gcc based project to IAR.
@@ -60,6 +62,17 @@ Thanks to Oleg Semyonov for his help with the IAR tools port!
#define wdt_reset() __watchdog_reset()
#define _BV(x) (1 << (x))
+/* assembler compatibility macros */
+#define nop2 rjmp $+2 /* jump to next instruction */
+#define XL r26
+#define XH r27
+#define YL r28
+#define YH r29
+#define ZL r30
+#define ZH r31
+#define lo8(x) LOW(x)
+#define hi8(x) (((x)>>8) & 0xff) /* not HIGH to allow XLINK to make a proper range check */
+
/* Depending on the device you use, you may get problems with the way usbdrv.h
* handles the differences between devices. Since IAR does not use #defines
* for MCU registers, we can't check for the existence of a particular
@@ -68,17 +81,20 @@ Thanks to Oleg Semyonov for his help with the IAR tools port!
* usbconfig-prototype.h and usbdrv.h for details.
*/
+/* ------------------------------------------------------------------------- */
#elif __CODEVISIONAVR__ /* check for CodeVision AVR */
+/* ------------------------------------------------------------------------- */
+/* This port is not working (yet) */
-#define F_CPU _MCU_CLOCK_FREQUENCY_
+/* #define F_CPU _MCU_CLOCK_FREQUENCY_ seems to be defined automatically */
#include <io.h>
#include <delay.h>
#define __attribute__(arg) /* not supported on IAR */
-#define PROGMEM __flash
-#define PRG_RDB(addr) (*(PROGMEM char *)(addr))
+#define PROGMEM __flash
+#define USB_READ_FLASH(addr) (*(PROGMEM char *)(addr))
#ifndef __ASSEMBLER__
static inline void cli(void)
@@ -91,9 +107,16 @@ static inline void sei(void)
}
#endif
#define _delay_ms(t) delay_ms(t)
-#define _BV(x) (1 << (x))
+#define _BV(x) (1 << (x))
+#define USB_CFG_USE_SWITCH_STATEMENT 1 /* macro for if() cascase fails for unknown reason */
+#define macro .macro
+#define endm .endmacro
+#define nop2 rjmp .+0 /* jump to next instruction */
+
+/* ------------------------------------------------------------------------- */
#else /* default development environment is avr-gcc/avr-libc */
+/* ------------------------------------------------------------------------- */
#include <avr/io.h>
#ifdef __ASSEMBLER__
@@ -102,5 +125,16 @@ static inline void sei(void)
# include <avr/pgmspace.h>
#endif
+#define USB_READ_FLASH(addr) pgm_read_byte(addr)
+
+#define macro .macro
+#define endm .endm
+#define nop2 rjmp .+0 /* jump to next instruction */
+
#endif /* development environment */
+
+/* for conveniecne, ensure that PRG_RDB exists */
+#ifndef PRG_RDB
+# define PRG_RDB(addr) USB_READ_FLASH(addr)
+#endif
#endif /* __usbportability_h_INCLUDED__ */