diff options
author | Christian Starkjohann <cs+github@obdev.at> | 2008-06-17 18:13:38 +0000 |
---|---|---|
committer | Christian Starkjohann <cs+github@obdev.at> | 2008-06-17 18:13:38 +0000 |
commit | 4f0353ba8355196550a842576f8f5af47392f4a7 (patch) | |
tree | 5d46facbfe2854530177ef357db0c41460444647 | |
parent | dfb2c5fd5e27c6b82466a01ebc59a3ee00d125dc (diff) | |
download | v-usb-4f0353ba8355196550a842576f8f5af47392f4a7.tar.gz v-usb-4f0353ba8355196550a842576f8f5af47392f4a7.tar.bz2 v-usb-4f0353ba8355196550a842576f8f5af47392f4a7.zip |
- removed iarcompat.h in favor of usbportability.h which is intended to take
care of ports to other compilers such as CodeVision as well.
-rw-r--r-- | usbdrv/Readme.txt | 2 | ||||
-rw-r--r-- | usbdrv/iarcompat.h | 65 | ||||
-rw-r--r-- | usbdrv/oddebug.h | 5 | ||||
-rw-r--r-- | usbdrv/usbdrv.c | 6 | ||||
-rw-r--r-- | usbdrv/usbdrv.h | 2 | ||||
-rw-r--r-- | usbdrv/usbdrvasm.S | 7 | ||||
-rw-r--r-- | usbdrv/usbportability.h | 106 |
7 files changed, 112 insertions, 81 deletions
diff --git a/usbdrv/Readme.txt b/usbdrv/Readme.txt index cb1a70e..96a79d0 100644 --- a/usbdrv/Readme.txt +++ b/usbdrv/Readme.txt @@ -33,7 +33,7 @@ The driver consists of the following files: defined to a value greater than 0. Link this module to your code! oddebug.h .............. Interface definitions of the debug module. - iarcompat.h ............ Compatibility definitions for IAR C-compiler. + usbportability.h ....... Header with compiler-dependent stuff. usbdrvasm.asm .......... Compatibility stub for IAR-C-compiler. Use this module instead of usbdrvasm.S when you assembler with IAR's tools. diff --git a/usbdrv/iarcompat.h b/usbdrv/iarcompat.h deleted file mode 100644 index 418a485..0000000 --- a/usbdrv/iarcompat.h +++ /dev/null @@ -1,65 +0,0 @@ -/* Name: iarcompat.h - * Project: AVR USB driver - * Author: Christian Starkjohann - * Creation Date: 2006-03-01 - * Tabsize: 4 - * Copyright: (c) 2006 by OBJECTIVE DEVELOPMENT Software GmbH - * License: GNU GPL v2 (see License.txt) or proprietary (CommercialLicense.txt) - * This Revision: $Id$ - */ - -/* -General Description: -This header is included when we compile with the IAR C-compiler and assembler. -It defines macros for cross compatibility between gcc and IAR-cc. - -Thanks to Oleg Semyonov for his help with the IAR tools port! -*/ - -#ifndef __iarcompat_h_INCLUDED__ -#define __iarcompat_h_INCLUDED__ - -#if defined __IAR_SYSTEMS_ICC__ || defined __IAR_SYSTEMS_ASM__ - -/* Enable bit definitions */ -#ifndef ENABLE_BIT_DEFINITIONS -# define ENABLE_BIT_DEFINITIONS 1 -#endif - -/* Include IAR headers */ -#include <ioavr.h> -#ifndef __IAR_SYSTEMS_ASM__ -# include <inavr.h> -#endif - -#define __attribute__(arg) - -#ifdef __IAR_SYSTEMS_ASM__ -# define __ASSEMBLER__ -#endif - -#ifdef __HAS_ELPM__ -# define PROGMEM __farflash -#else -# define PROGMEM __flash -#endif - -#define PRG_RDB(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. - */ -#define cli() __disable_interrupt() -#define sei() __enable_interrupt() -#define wdt_reset() __watchdog_reset() - -/* 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 - * register with an #ifdef. If the autodetection mechanism fails, include - * definitions for the required USB_INTR_* macros in your usbconfig.h. See - * usbconfig-prototype.h and usbdrv.h for details. - */ - -#endif /* defined __IAR_SYSTEMS_ICC__ || defined __IAR_SYSTEMS_ASM__ */ -#endif /* __iarcompat_h_INCLUDED__ */ diff --git a/usbdrv/oddebug.h b/usbdrv/oddebug.h index eba868a..80d9760 100644 --- a/usbdrv/oddebug.h +++ b/usbdrv/oddebug.h @@ -29,10 +29,7 @@ the output and a memory block to dump in hex ('data' and 'len'). #endif /* make sure we have the UART defines: */ -#include "iarcompat.h" -#ifndef __IAR_SYSTEMS_ICC__ -# include <avr/io.h> -#endif +#include "usbportability.h" #ifndef uchar # define uchar unsigned char diff --git a/usbdrv/usbdrv.c b/usbdrv/usbdrv.c index eed2d52..0168a44 100644 --- a/usbdrv/usbdrv.c +++ b/usbdrv/usbdrv.c @@ -8,11 +8,7 @@ * This Revision: $Id$ */ -#include "iarcompat.h" -#ifndef __IAR_SYSTEMS_ICC__ -# include <avr/io.h> -# include <avr/pgmspace.h> -#endif +#include "usbportability.h" #include "usbdrv.h" #include "oddebug.h" diff --git a/usbdrv/usbdrv.h b/usbdrv/usbdrv.h index e2c08ec..b77b984 100644 --- a/usbdrv/usbdrv.h +++ b/usbdrv/usbdrv.h @@ -11,7 +11,7 @@ #ifndef __usbdrv_h_included__ #define __usbdrv_h_included__ #include "usbconfig.h" -#include "iarcompat.h" +#include "usbportability.h" /* Hardware Prerequisites: diff --git a/usbdrv/usbdrvasm.S b/usbdrv/usbdrvasm.S index 2c06421..119b738 100644 --- a/usbdrv/usbdrvasm.S +++ b/usbdrv/usbdrvasm.S @@ -15,12 +15,9 @@ general code (preprocessor acrobatics and CRC computation) and then includes the file appropriate for the given clock rate. */ -#include "iarcompat.h" +#define __SFR_OFFSET 0 /* used by avr-libc's register definitions */ +#include "usbportability.h" #ifndef __IAR_SYSTEMS_ASM__ - /* configs for io.h */ -# define __SFR_OFFSET 0 -# define _VECTOR(N) __vector_ ## N /* io.h does not define this for asm */ -# include <avr/io.h> /* for CPU I/O register definitions and vectors */ # define macro .macro /* GNU Assembler macro definition */ # define endm .endm /* End of GNU Assembler macro definition */ #endif /* __IAR_SYSTEMS_ASM__ */ diff --git a/usbdrv/usbportability.h b/usbdrv/usbportability.h new file mode 100644 index 0000000..e2db604 --- /dev/null +++ b/usbdrv/usbportability.h @@ -0,0 +1,106 @@ +/* Name: usbportability.h + * Project: AVR USB driver + * Author: Christian Starkjohann + * Creation Date: 2008-06-17 + * Tabsize: 4 + * Copyright: (c) 2008 by OBJECTIVE DEVELOPMENT Software GmbH + * License: GNU GPL v2 (see License.txt) or proprietary (CommercialLicense.txt) + * This Revision: $Id$ + */ + +/* +General Description: +This header is intended to contain all (or at least most of) the compiler +and library dependent stuff. The C code is written for avr-gcc and avr-libc. +The API of other development environments is converted to gcc's and avr-libc's +API by means of defines. + +This header also contains all system includes since they depend on the +development environment. + +Thanks to Oleg Semyonov for his help with the IAR tools port! +*/ + +#ifndef __usbportability_h_INCLUDED__ +#define __usbportability_h_INCLUDED__ + +/* 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 */ +#endif + +/* Include IAR headers */ +#include <ioavr.h> +#ifndef __IAR_SYSTEMS_ASM__ +# include <inavr.h> +#endif + +#define __attribute__(arg) /* not supported on IAR */ + +#ifdef __IAR_SYSTEMS_ASM__ +# define __ASSEMBLER__ /* IAR does not define standard macro for asm */ +#endif + +#ifdef __HAS_ELPM__ +# define PROGMEM __farflash +#else +# define PROGMEM __flash +#endif + +#define PRG_RDB(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. + */ +#define cli() __disable_interrupt() +#define sei() __enable_interrupt() +#define wdt_reset() __watchdog_reset() +#define _BV(x) (1 << (x)) + +/* 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 + * register with an #ifdef. If the autodetection mechanism fails, include + * definitions for the required USB_INTR_* macros in your usbconfig.h. See + * usbconfig-prototype.h and usbdrv.h for details. + */ + +#elif __CODEVISIONAVR__ /* check for CodeVision AVR */ + +#define F_CPU _MCU_CLOCK_FREQUENCY_ + +#include <io.h> +#include <delay.h> + +#define __attribute__(arg) /* not supported on IAR */ + +#define PROGMEM __flash +#define PRG_RDB(addr) (*(PROGMEM char *)(addr)) + +#ifndef __ASSEMBLER__ +static inline void cli(void) +{ + #asm("cli"); +} +static inline void sei(void) +{ + #asm("sei"); +} +#endif +#define _delay_ms(t) delay_ms(t) +#define _BV(x) (1 << (x)) + +#else /* default development environment is avr-gcc/avr-libc */ + +#include <avr/io.h> +#ifdef __ASSEMBLER__ +# define _VECTOR(N) __vector_ ## N /* io.h does not define this for asm */ +#else +# include <avr/pgmspace.h> +#endif + +#endif /* development environment */ +#endif /* __usbportability_h_INCLUDED__ */ |