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.

70 lines
1.3 KiB

  1. /**
  2. * @file spi.h
  3. * Class declaration for SPI helper files
  4. */
  5. #ifndef SPI_H
  6. #define SPI_H
  7. /**
  8. * Example of spi.h class declaration for SPI portability
  9. *
  10. * @defgroup Porting_SPI Porting: SPI
  11. *
  12. * @{
  13. */
  14. #include <stdio.h>
  15. #include <inttypes.h>
  16. using namespace std;
  17. class SPI {
  18. public:
  19. /**
  20. * SPI default constructor
  21. */
  22. SPI();
  23. /**
  24. * Start SPI communication
  25. * @param pin used for SPI
  26. */
  27. void begin(int);
  28. /**
  29. * Transfer a single byte of data
  30. * @param tx Byte to send
  31. * @return Data returned via spi
  32. */
  33. uint8_t transfer(uint8_t);
  34. /**
  35. * Transfer a buffer of data using rx and tx buffer
  36. * @param tbuf Transmit buffer
  37. * @param rbuf Receive buffer
  38. * @param len Length of the data
  39. */
  40. void transfernb(char*, char*, uint32_t);
  41. /**
  42. * Transfer a buffer of data without using an rx buffer
  43. * @param buf Pointer to a buffer of data
  44. * @param len Length of the data
  45. */
  46. void transfern(char*, const uint32_t);
  47. /**
  48. * SPI destructor
  49. */
  50. virtual ~SPI();
  51. private:
  52. int fd;
  53. uint8_t msg[32 + 1];
  54. uint8_t msgByte;
  55. };
  56. /*@}*/
  57. #endif /* SPI_H */