]>
git.zerfleddert.de Git - fnordlicht-mini/blob - firmware/fnordlicht-controller/usbdrv/usbportability.h
1 /* Name: usbportability.h
2 * Project: V-USB, virtual USB port for Atmel's(r) AVR(r) microcontrollers
3 * Author: Christian Starkjohann
4 * Creation Date: 2008-06-17
6 * Copyright: (c) 2008 by OBJECTIVE DEVELOPMENT Software GmbH
7 * License: GNU GPL v2 (see License.txt), GNU GPL v3 or proprietary (CommercialLicense.txt)
8 * This Revision: $Id: usbportability.h 740 2009-04-13 18:23:31Z cs $
13 This header is intended to contain all (or at least most of) the compiler
14 and library dependent stuff. The C code is written for avr-gcc and avr-libc.
15 The API of other development environments is converted to gcc's and avr-libc's
16 API by means of defines.
18 This header also contains all system includes since they depend on the
19 development environment.
21 Thanks to Oleg Semyonov for his help with the IAR tools port!
24 #ifndef __usbportability_h_INCLUDED__
25 #define __usbportability_h_INCLUDED__
27 /* We check explicitly for IAR and CodeVision. Default is avr-gcc/avr-libc. */
29 /* ------------------------------------------------------------------------- */
30 #if defined __IAR_SYSTEMS_ICC__ || defined __IAR_SYSTEMS_ASM__ /* check for IAR */
31 /* ------------------------------------------------------------------------- */
33 #ifndef ENABLE_BIT_DEFINITIONS
34 # define ENABLE_BIT_DEFINITIONS 1 /* Enable bit definitions */
37 /* Include IAR headers */
39 #ifndef __IAR_SYSTEMS_ASM__
43 #define __attribute__(arg) /* not supported on IAR */
45 #ifdef __IAR_SYSTEMS_ASM__
46 # define __ASSEMBLER__ /* IAR does not define standard macro for asm */
50 # define PROGMEM __farflash
52 # define PROGMEM __flash
55 #define USB_READ_FLASH(addr) (*(PROGMEM char *)(addr))
57 /* The following definitions are not needed by the driver, but may be of some
58 * help if you port a gcc based project to IAR.
60 #define cli() __disable_interrupt()
61 #define sei() __enable_interrupt()
62 #define wdt_reset() __watchdog_reset()
63 #define _BV(x) (1 << (x))
65 /* assembler compatibility macros */
66 #define nop2 rjmp $+2 /* jump to next instruction */
74 #define hi8(x) (((x)>>8) & 0xff) /* not HIGH to allow XLINK to make a proper range check */
76 /* Depending on the device you use, you may get problems with the way usbdrv.h
77 * handles the differences between devices. Since IAR does not use #defines
78 * for MCU registers, we can't check for the existence of a particular
79 * register with an #ifdef. If the autodetection mechanism fails, include
80 * definitions for the required USB_INTR_* macros in your usbconfig.h. See
81 * usbconfig-prototype.h and usbdrv.h for details.
84 /* ------------------------------------------------------------------------- */
85 #elif __CODEVISIONAVR__ /* check for CodeVision AVR */
86 /* ------------------------------------------------------------------------- */
87 /* This port is not working (yet) */
89 /* #define F_CPU _MCU_CLOCK_FREQUENCY_ seems to be defined automatically */
94 #define __attribute__(arg) /* not supported on IAR */
96 #define PROGMEM __flash
97 #define USB_READ_FLASH(addr) (*(PROGMEM char *)(addr))
100 static inline void cli(void)
104 static inline void sei(void)
109 #define _delay_ms(t) delay_ms(t)
110 #define _BV(x) (1 << (x))
111 #define USB_CFG_USE_SWITCH_STATEMENT 1 /* macro for if() cascase fails for unknown reason */
114 #define endm .endmacro
115 #define nop2 rjmp .+0 /* jump to next instruction */
117 /* ------------------------------------------------------------------------- */
118 #else /* default development environment is avr-gcc/avr-libc */
119 /* ------------------------------------------------------------------------- */
123 # define _VECTOR(N) __vector_ ## N /* io.h does not define this for asm */
125 # include <avr/pgmspace.h>
128 #define USB_READ_FLASH(addr) pgm_read_byte(addr)
132 #define nop2 rjmp .+0 /* jump to next instruction */
134 #endif /* development environment */
136 /* for conveniecne, ensure that PRG_RDB exists */
138 # define PRG_RDB(addr) USB_READ_FLASH(addr)
140 #endif /* __usbportability_h_INCLUDED__ */