A low cost DIY sound pressure level sensor for enabling environmental noise awareness. https://lukasschwarz.org/noise-sensor
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

defs.h 2.1 KiB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879
  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. // use this for packed structures
  54. // (this is seldom necessary on an 8-bit architecture like AVR,
  55. // but can assist in code portability to AVR)
  56. #define GNUC_PACKED __attribute__((packed))
  57. // port address helpers
  58. #define DDR(x) ((x)-1) // address of data direction register of port x
  59. #define PIN(x) ((x)-2) // address of input register of port x
  60. // MIN/MAX/ABS macros
  61. #define MIN(a,b) ((a<b)?(a):(b))
  62. #define MAX(a,b) ((a>b)?(a):(b))
  63. #define ABS(x) ((x>0)?(x):(-x))
  64. // constants
  65. #define PI 3.14159265359
  66. //Math
  67. #define sq(x) ((x)*(x))
  68. #define constrain(amt,low,high) ((amt)<(low)?(low):((amt)>(high)?(high):(amt)))
  69. #endif