BrickUp API Service for Docker version.

defs.h 2.2KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687
  1. /*! \file avrlibdefs.h \brief AVRlib global defines and macros. */
  2. //*****************************************************************************
  3. //
  4. // File Name : 'avrlibdefs.h'
  5. // Title : AVRlib global defines and macros include file
  6. // Author : Pascal Stang
  7. // Created : 7/12/2001
  8. // Revised : 9/30/2002
  9. // Version : 1.1
  10. // Target MCU : Atmel AVR series
  11. // Editor Tabs : 4
  12. //
  13. // Description : This include file is designed to contain items useful to all
  14. // code files and projects, regardless of specific implementation.
  15. //
  16. // This code is distributed under the GNU Public License
  17. // which can be found at http://www.gnu.org/licenses/gpl.txt
  18. //
  19. //*****************************************************************************
  20. #ifndef AVRLIBDEFS_H
  21. #define AVRLIBDEFS_H
  22. //#define F_CPU 4000000
  23. #define MEM_TYPE 1
  24. // Code compatibility to new AVR-libc
  25. // outb(), inb(), inw(), outw(), BV(), sbi(), cbi(), sei(), cli()
  26. #ifndef outb
  27. #define outb(addr, data) addr = (data)
  28. #endif
  29. #ifndef inb
  30. #define inb(addr) (addr)
  31. #endif
  32. #ifndef outw
  33. #define outw(addr, data) addr = (data)
  34. #endif
  35. #ifndef inw
  36. #define inw(addr) (addr)
  37. #endif
  38. #ifndef BV
  39. #define BV(bit) (1<<(bit))
  40. #endif
  41. //#ifndef cbi
  42. // #define cbi(reg,bit) reg &= ~(BV(bit))
  43. //#endif
  44. //#ifndef sbi
  45. // #define sbi(reg,bit) reg |= (BV(bit))
  46. //#endif
  47. #ifndef cli
  48. #define cli() __asm__ __volatile__ ("cli" ::)
  49. #endif
  50. #ifndef sei
  51. #define sei() __asm__ __volatile__ ("sei" ::)
  52. #endif
  53. // support for individual port pin naming in the mega128
  54. // see port128.h for details
  55. #ifdef __AVR_ATmega128__
  56. // not currently necessary due to inclusion
  57. // of these defines in newest AVR-GCC
  58. // do a quick test to see if include is needed
  59. #ifndef PD0
  60. //#include "port128.h"
  61. #endif
  62. #endif
  63. // use this for packed structures
  64. // (this is seldom necessary on an 8-bit architecture like AVR,
  65. // but can assist in code portability to AVR)
  66. #define GNUC_PACKED __attribute__((packed))
  67. // port address helpers
  68. #define DDR(x) ((x)-1) // address of data direction register of port x
  69. #define PIN(x) ((x)-2) // address of input register of port x
  70. // MIN/MAX/ABS macros
  71. #define MIN(a,b) ((a<b)?(a):(b))
  72. #define MAX(a,b) ((a>b)?(a):(b))
  73. #define ABS(x) ((x>0)?(x):(-x))
  74. // constants
  75. #define PI 3.14159265359
  76. #endif