Du kannst nicht mehr als 25 Themen auswählen Themen müssen mit entweder einem Buchstaben oder einer Ziffer beginnen. Sie können Bindestriche („-“) enthalten und bis zu 35 Zeichen lang sein.

usbportability.h 4.4KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140
  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. General Description:
  12. This header is intended to contain all (or at least most of) the compiler
  13. and library dependent stuff. The C code is written for avr-gcc and avr-libc.
  14. The API of other development environments is converted to gcc's and avr-libc's
  15. API by means of defines.
  16. This header also contains all system includes since they depend on the
  17. development environment.
  18. Thanks to Oleg Semyonov for his help with the IAR tools port!
  19. */
  20. #ifndef __usbportability_h_INCLUDED__
  21. #define __usbportability_h_INCLUDED__
  22. /* We check explicitly for IAR and CodeVision. Default is avr-gcc/avr-libc. */
  23. /* ------------------------------------------------------------------------- */
  24. #if defined __IAR_SYSTEMS_ICC__ || defined __IAR_SYSTEMS_ASM__ /* check for IAR */
  25. /* ------------------------------------------------------------------------- */
  26. #ifndef ENABLE_BIT_DEFINITIONS
  27. # define ENABLE_BIT_DEFINITIONS 1 /* Enable bit definitions */
  28. #endif
  29. /* Include IAR headers */
  30. #include <ioavr.h>
  31. #ifndef __IAR_SYSTEMS_ASM__
  32. # include <inavr.h>
  33. #endif
  34. #define __attribute__(arg) /* not supported on IAR */
  35. #ifdef __IAR_SYSTEMS_ASM__
  36. # define __ASSEMBLER__ /* IAR does not define standard macro for asm */
  37. #endif
  38. #ifdef __HAS_ELPM__
  39. # define PROGMEM __farflash
  40. #else
  41. # define PROGMEM __flash
  42. #endif
  43. #define USB_READ_FLASH(addr) (*(PROGMEM char *)(addr))
  44. /* The following definitions are not needed by the driver, but may be of some
  45. * help if you port a gcc based project to IAR.
  46. */
  47. #define cli() __disable_interrupt()
  48. #define sei() __enable_interrupt()
  49. #define wdt_reset() __watchdog_reset()
  50. #define _BV(x) (1 << (x))
  51. /* assembler compatibility macros */
  52. #define nop2 rjmp $+2 /* jump to next instruction */
  53. #define XL r26
  54. #define XH r27
  55. #define YL r28
  56. #define YH r29
  57. #define ZL r30
  58. #define ZH r31
  59. #define lo8(x) LOW(x)
  60. #define hi8(x) (((x)>>8) & 0xff) /* not HIGH to allow XLINK to make a proper range check */
  61. /* Depending on the device you use, you may get problems with the way usbdrv.h
  62. * handles the differences between devices. Since IAR does not use #defines
  63. * for MCU registers, we can't check for the existence of a particular
  64. * register with an #ifdef. If the autodetection mechanism fails, include
  65. * definitions for the required USB_INTR_* macros in your usbconfig.h. See
  66. * usbconfig-prototype.h and usbdrv.h for details.
  67. */
  68. /* ------------------------------------------------------------------------- */
  69. #elif __CODEVISIONAVR__ /* check for CodeVision AVR */
  70. /* ------------------------------------------------------------------------- */
  71. /* This port is not working (yet) */
  72. /* #define F_CPU _MCU_CLOCK_FREQUENCY_ seems to be defined automatically */
  73. #include <io.h>
  74. #include <delay.h>
  75. #define __attribute__(arg) /* not supported on IAR */
  76. #define PROGMEM __flash
  77. #define USB_READ_FLASH(addr) (*(PROGMEM char *)(addr))
  78. #ifndef __ASSEMBLER__
  79. static inline void cli(void)
  80. {
  81. #asm("cli");
  82. }
  83. static inline void sei(void)
  84. {
  85. #asm("sei");
  86. }
  87. #endif
  88. #define _delay_ms(t) delay_ms(t)
  89. #define _BV(x) (1 << (x))
  90. #define USB_CFG_USE_SWITCH_STATEMENT 1 /* macro for if() cascase fails for unknown reason */
  91. #define macro .macro
  92. #define endm .endmacro
  93. #define nop2 rjmp .+0 /* jump to next instruction */
  94. /* ------------------------------------------------------------------------- */
  95. #else /* default development environment is avr-gcc/avr-libc */
  96. /* ------------------------------------------------------------------------- */
  97. #include <avr/io.h>
  98. #ifdef __ASSEMBLER__
  99. # define _VECTOR(N) __vector_ ## N /* io.h does not define this for asm */
  100. #else
  101. # include <avr/pgmspace.h>
  102. #endif
  103. #define USB_READ_FLASH(addr) pgm_read_byte(addr)
  104. #define macro .macro
  105. #define endm .endm
  106. #define nop2 rjmp .+0 /* jump to next instruction */
  107. #endif /* development environment */
  108. /* for conveniecne, ensure that PRG_RDB exists */
  109. #ifndef PRG_RDB
  110. # define PRG_RDB(addr) USB_READ_FLASH(addr)
  111. #endif
  112. #endif /* __usbportability_h_INCLUDED__ */