]> git.zerfleddert.de Git - fnordlicht-mini/blame_incremental - firmware/fnordlicht-controller/usbdrv/usbportability.h
remove master mode, disable uart tx
[fnordlicht-mini] / firmware / fnordlicht-controller / usbdrv / usbportability.h
... / ...
CommitLineData
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
5 * Tabsize: 4
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 $
9 */
10
11/*
12General Description:
13This header is intended to contain all (or at least most of) the compiler
14and library dependent stuff. The C code is written for avr-gcc and avr-libc.
15The API of other development environments is converted to gcc's and avr-libc's
16API by means of defines.
17
18This header also contains all system includes since they depend on the
19development environment.
20
21Thanks to Oleg Semyonov for his help with the IAR tools port!
22*/
23
24#ifndef __usbportability_h_INCLUDED__
25#define __usbportability_h_INCLUDED__
26
27/* We check explicitly for IAR and CodeVision. Default is avr-gcc/avr-libc. */
28
29/* ------------------------------------------------------------------------- */
30#if defined __IAR_SYSTEMS_ICC__ || defined __IAR_SYSTEMS_ASM__ /* check for IAR */
31/* ------------------------------------------------------------------------- */
32
33#ifndef ENABLE_BIT_DEFINITIONS
34# define ENABLE_BIT_DEFINITIONS 1 /* Enable bit definitions */
35#endif
36
37/* Include IAR headers */
38#include <ioavr.h>
39#ifndef __IAR_SYSTEMS_ASM__
40# include <inavr.h>
41#endif
42
43#define __attribute__(arg) /* not supported on IAR */
44
45#ifdef __IAR_SYSTEMS_ASM__
46# define __ASSEMBLER__ /* IAR does not define standard macro for asm */
47#endif
48
49#ifdef __HAS_ELPM__
50# define PROGMEM __farflash
51#else
52# define PROGMEM __flash
53#endif
54
55#define USB_READ_FLASH(addr) (*(PROGMEM char *)(addr))
56
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.
59 */
60#define cli() __disable_interrupt()
61#define sei() __enable_interrupt()
62#define wdt_reset() __watchdog_reset()
63#define _BV(x) (1 << (x))
64
65/* assembler compatibility macros */
66#define nop2 rjmp $+2 /* jump to next instruction */
67#define XL r26
68#define XH r27
69#define YL r28
70#define YH r29
71#define ZL r30
72#define ZH r31
73#define lo8(x) LOW(x)
74#define hi8(x) (((x)>>8) & 0xff) /* not HIGH to allow XLINK to make a proper range check */
75
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.
82 */
83
84/* ------------------------------------------------------------------------- */
85#elif __CODEVISIONAVR__ /* check for CodeVision AVR */
86/* ------------------------------------------------------------------------- */
87/* This port is not working (yet) */
88
89/* #define F_CPU _MCU_CLOCK_FREQUENCY_ seems to be defined automatically */
90
91#include <io.h>
92#include <delay.h>
93
94#define __attribute__(arg) /* not supported on IAR */
95
96#define PROGMEM __flash
97#define USB_READ_FLASH(addr) (*(PROGMEM char *)(addr))
98
99#ifndef __ASSEMBLER__
100static inline void cli(void)
101{
102 #asm("cli");
103}
104static inline void sei(void)
105{
106 #asm("sei");
107}
108#endif
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 */
112
113#define macro .macro
114#define endm .endmacro
115#define nop2 rjmp .+0 /* jump to next instruction */
116
117/* ------------------------------------------------------------------------- */
118#else /* default development environment is avr-gcc/avr-libc */
119/* ------------------------------------------------------------------------- */
120
121#include <avr/io.h>
122#ifdef __ASSEMBLER__
123# define _VECTOR(N) __vector_ ## N /* io.h does not define this for asm */
124#else
125# include <avr/pgmspace.h>
126#endif
127
128#define USB_READ_FLASH(addr) pgm_read_byte(addr)
129
130#define macro .macro
131#define endm .endm
132#define nop2 rjmp .+0 /* jump to next instruction */
133
134#endif /* development environment */
135
136/* for conveniecne, ensure that PRG_RDB exists */
137#ifndef PRG_RDB
138# define PRG_RDB(addr) USB_READ_FLASH(addr)
139#endif
140#endif /* __usbportability_h_INCLUDED__ */
Impressum, Datenschutz