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.

55 lines
954 B

  1. /*
  2. * TMRh20 2015
  3. * SPI layer for RF24
  4. */
  5. #ifndef _SPI_H_INCLUDED
  6. #define _SPI_H_INCLUDED
  7. /**
  8. * @file spi.h
  9. * \cond HIDDEN_SYMBOLS
  10. * Class declaration for SPI helper files
  11. */
  12. #include <stdio.h>
  13. #include "mraa.hpp"
  14. class SPI {
  15. public:
  16. SPI();
  17. virtual ~SPI();
  18. mraa::Spi* mspi;
  19. inline uint8_t transfer(uint8_t _data);
  20. inline void transfernb(char* tbuf, char* rbuf, uint32_t len);
  21. inline void transfern(char* buf, uint32_t len);
  22. void begin(int busNo);
  23. void end();
  24. void setBitOrder(uint8_t bit_order);
  25. void setDataMode(uint8_t data_mode);
  26. void setClockDivider(uint32_t spi_speed);
  27. void chipSelect(int csn_pin);
  28. };
  29. uint8_t SPI::transfer(uint8_t _data)
  30. {
  31. return mspi->writeByte(_data);
  32. }
  33. void SPI::transfernb(char* tbuf, char* rbuf, uint32_t len){
  34. mspi->transfer((uint8_t*)tbuf, (uint8_t*)rbuf, len);
  35. }
  36. void SPI::transfern(char* buf, uint32_t len)
  37. {
  38. transfernb(buf, buf, len);
  39. }
  40. /**
  41. * \endcond
  42. */
  43. #endif