Ein Roboter mit bürstenlosem Antrieb, differenzial und NRF24L01 Funk. Großflächig gebaut um ein großes Solarpanel aufzunehmen. https://gitlab.informatik.hs-fulda.de/fdai5253/roboter
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.

89 lines
1.5 KiB

  1. /*
  2. * https://github.com/mrshu/GPIOlib
  3. * Copyright (c) 2011, Copyright (c) 2011 mr.Shu
  4. * All rights reserved.
  5. *
  6. * Modified on 24 June 2012, 11:06 AM
  7. * File: gpio.h
  8. * Author: purinda (purinda@gmail.com)
  9. *
  10. */
  11. #ifndef H
  12. #define H
  13. #include <cstdio>
  14. #include <map>
  15. #include <stdexcept>
  16. /** Specific excpetion for SPI errors */
  17. class GPIOException : public std::runtime_error {
  18. public:
  19. explicit GPIOException(const std::string& msg) : std::runtime_error(msg) { }
  20. };
  21. /**
  22. * @file gpio.h
  23. * \cond HIDDEN_SYMBOLS
  24. * Class declaration for GPIO helper files
  25. */
  26. /**
  27. * Example GPIO.h file
  28. *
  29. * @defgroup GPIO GPIO Example
  30. *
  31. * See RF24_arch_config.h for additional information
  32. * @{
  33. */
  34. typedef int GPIOfdCache_t;
  35. class GPIO {
  36. public:
  37. /* Constants */
  38. static const int DIRECTION_OUT = 1;
  39. static const int DIRECTION_IN = 0;
  40. static const int OUTPUT_HIGH = 1;
  41. static const int OUTPUT_LOW = 0;
  42. GPIO();
  43. /**
  44. * Similar to Arduino pinMode(pin,mode);
  45. * @param port
  46. * @param DDR
  47. */
  48. static void open(int port, int DDR);
  49. /**
  50. *
  51. * @param port
  52. */
  53. static void close(int port);
  54. /**
  55. * Similar to Arduino digitalRead(pin);
  56. * @param port
  57. * @param value
  58. */
  59. static int read(int port);
  60. /**
  61. * Similar to Arduino digitalWrite(pin,state);
  62. * @param port
  63. * @param value
  64. */
  65. static void write(int port,int value);
  66. virtual ~GPIO();
  67. private:
  68. /* fd cache */
  69. static std::map<int,GPIOfdCache_t> cache;
  70. };
  71. /**
  72. * \endcond
  73. */
  74. /*@}*/
  75. #endif /* H */