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.

47 lines
1.0 KiB

  1. #include "spi.h"
  2. #include "mraa.h"
  3. SPI::SPI() {
  4. mspi = NULL;
  5. }
  6. void SPI::begin(int busNo) {
  7. mspi = new mraa::Spi(busNo); // init mraa spi bus, it will handle chip select internally. For CS pin wiring user must check SPI details in hardware manual
  8. mspi->mode(mraa::SPI_MODE0);
  9. mspi->bitPerWord(8);
  10. mspi->frequency(8000000); // Prophet: this will try to set 8MHz, however MRAA will reset to max platform speed and syslog a message of it
  11. }
  12. void SPI::end() {
  13. // Prophet: we should check for existence of mspi before deleting it
  14. if (mspi != NULL)
  15. delete mspi;
  16. }
  17. void SPI::setBitOrder(uint8_t bit_order) {
  18. if (mspi != NULL)
  19. mspi->lsbmode((mraa_boolean_t)bit_order); // Prophet: bit_order
  20. }
  21. void SPI::setDataMode(uint8_t data_mode) {
  22. if (mspi != NULL)
  23. mspi->mode((mraa::Spi_Mode)data_mode);
  24. }
  25. void SPI::setClockDivider(uint32_t spi_speed) {
  26. if (mspi != NULL)
  27. mspi->frequency(spi_speed);
  28. }
  29. void SPI::chipSelect(int csn_pin){
  30. }
  31. SPI::~SPI() {
  32. // Prophet: we should call end here to free used memory and unexport SPI interface
  33. this->end();
  34. }