PlatformIO package of the Teensy core framework compatible with GCC 10 & C++20
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.

111 satır
3.1KB

  1. /*
  2. wiring.h - Partial implementation of the Wiring API for the ATmega8.
  3. Part of Arduino - http://www.arduino.cc/
  4. Copyright (c) 2005-2006 David A. Mellis
  5. This library is free software; you can redistribute it and/or
  6. modify it under the terms of the GNU Lesser General Public
  7. License as published by the Free Software Foundation; either
  8. version 2.1 of the License, or (at your option) any later version.
  9. This library is distributed in the hope that it will be useful,
  10. but WITHOUT ANY WARRANTY; without even the implied warranty of
  11. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  12. Lesser General Public License for more details.
  13. You should have received a copy of the GNU Lesser General
  14. Public License along with this library; if not, write to the
  15. Free Software Foundation, Inc., 59 Temple Place, Suite 330,
  16. Boston, MA 02111-1307 USA
  17. $Id: wiring.h 387 2008-03-08 21:30:00Z mellis $
  18. */
  19. #ifndef Wiring_h
  20. #define Wiring_h
  21. #include <avr/io.h>
  22. #include <stdlib.h>
  23. #include <stdbool.h>
  24. #include <math.h>
  25. #include "binary.h"
  26. #include "core_id.h"
  27. #include "core_pins.h"
  28. #ifdef ID
  29. #undef ID // ID bit in USBSTA conflicts with user's code
  30. #endif
  31. #ifdef __cplusplus
  32. extern "C"{
  33. #endif
  34. #define PI 3.1415926535897932384626433832795
  35. #define HALF_PI 1.5707963267948966192313216916398
  36. #define TWO_PI 6.283185307179586476925286766559
  37. #define DEG_TO_RAD 0.017453292519943295769236907684886
  38. #define RAD_TO_DEG 57.295779513082320876798154814105
  39. #define SERIAL 0
  40. #define DISPLAY 1
  41. #define CHANGE 1
  42. #define FALLING 2
  43. #define RISING 3
  44. #define INTERNAL 3
  45. #define INTERNAL2V56 3
  46. #define DEFAULT 1
  47. #define EXTERNAL 0
  48. // undefine stdlib's abs if encountered
  49. #ifdef abs
  50. #undef abs
  51. #endif
  52. #define min(a,b) ((a)<(b)?(a):(b))
  53. #define max(a,b) ((a)>(b)?(a):(b))
  54. #define abs(x) ((x)>0?(x):-(x))
  55. #define constrain(amt,low,high) ((amt)<(low)?(low):((amt)>(high)?(high):(amt)))
  56. #define round(x) ((x)>=0?(long)((x)+0.5):(long)((x)-0.5))
  57. #define radians(deg) ((deg)*DEG_TO_RAD)
  58. #define degrees(rad) ((rad)*RAD_TO_DEG)
  59. #define sq(x) ((x)*(x))
  60. #define interrupts() sei()
  61. #define noInterrupts() cli()
  62. #define clockCyclesPerMicrosecond() ( F_CPU / 1000000L )
  63. #define clockCyclesToMicroseconds(a) ( (a) / clockCyclesPerMicrosecond() )
  64. #define microsecondsToClockCycles(a) ( (a) * clockCyclesPerMicrosecond() )
  65. #define lowByte(w) ((uint8_t)((w) & 0xFF))
  66. #define highByte(w) ((uint8_t)((w) >> 8))
  67. #define bitRead(value, bit) (((value) >> (bit)) & 0x01)
  68. #define bitSet(value, bit) ((value) |= (1UL << (bit)))
  69. #define bitClear(value, bit) ((value) &= ~(1UL << (bit)))
  70. #define bitWrite(value, bit, bitvalue) ((bitvalue) ? bitSet((value), (bit)) : bitClear((value), (bit)))
  71. typedef unsigned int word;
  72. #define bit(b) (1UL << (b))
  73. typedef bool boolean;
  74. typedef uint8_t byte;
  75. unsigned long pulseIn(uint8_t pin, uint8_t state, unsigned long timeout);
  76. void shiftOut(uint8_t dataPin, uint8_t clockPin, uint8_t bitOrder, byte val);
  77. void attachInterrupt(uint8_t, void (*)(void), uint8_t mode);
  78. void detachInterrupt(uint8_t);
  79. void setup(void);
  80. void loop(void);
  81. #ifdef __cplusplus
  82. } // extern "C"
  83. #endif
  84. #endif