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.

80 lines
1.2 KiB

  1. /**
  2. * @file spi.h
  3. * Class declaration for SPI helper files
  4. */
  5. /**
  6. * Example of spi.h class declaration for SPI portability
  7. *
  8. * @defgroup Porting_SPI Porting: SPI
  9. *
  10. *
  11. * @{
  12. */
  13. #include <string>
  14. #include <stdint.h>
  15. #include <unistd.h>
  16. #include <stdio.h>
  17. #include <stdlib.h>
  18. #include <getopt.h>
  19. #include <fcntl.h>
  20. #include <sys/ioctl.h>
  21. #include <inttypes.h>
  22. #include <linux/types.h>
  23. #include <linux/spi/spidev.h>
  24. using namespace std;
  25. //class SPI {
  26. public:
  27. /**
  28. * SPI constructor
  29. */
  30. SPI();
  31. /**
  32. * Start SPI
  33. */
  34. void begin(int busNo);
  35. /**
  36. * Transfer a single byte
  37. * @param tx_ Byte to send
  38. * @return Data returned via spi
  39. */
  40. uint8_t transfer(uint8_t tx_);
  41. /**
  42. * Transfer a buffer of data
  43. * @param tbuf Transmit buffer
  44. * @param rbuf Receive buffer
  45. * @param len Length of the data
  46. */
  47. void transfernb(char* tbuf, char* rbuf, uint32_t len);
  48. /**
  49. * Transfer a buffer of data without an rx buffer
  50. * @param buf Pointer to a buffer of data
  51. * @param len Length of the data
  52. */
  53. void transfern(char* buf, uint32_t len);
  54. virtual ~SPI();
  55. private:
  56. /** Default SPI device */
  57. string device;
  58. /** SPI Mode set */
  59. uint8_t mode;
  60. /** word size*/
  61. uint8_t bits;
  62. /** Set SPI speed*/
  63. uint32_t speed;
  64. int fd;
  65. void init();
  66. };
  67. /*@}*/