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.

36 lines
1.1 KiB

8 years ago
​
8 years ago
​
​
​
​
​
​
​
​
​
​
​
​
​
8 years ago
​
​
​
​
​
8 years ago
​
​
​
​
​
8 years ago
​
​
​
​
  1. #ifndef __SPI_PORT_HEADER__
  2. #define __SPI_PORT_HEADER__
  3. #include "../../components/base/basicTypes.h"
  4. #include "../../data/transport/transportBus.h"
  5. #include <getopt.h>
  6. #include <fcntl.h>
  7. #include <sys/ioctl.h>
  8. #include <linux/types.h>
  9. #include <linux/spi/spidev.h>
  10. typedef enum E_SPI_MODES{
  11. SPI_ADDR_8 = 0,
  12. SPI_ADDR_16 = 1
  13. } SPI_MODE;
  14. class spiPort {
  15. private:
  16. basicLogCollection * m_pLog;
  17. int m_nFID;
  18. uint8_t m_bRegAddrBytes;
  19. int _write( int fd, uint16_t offset, const char* data, int data_len );
  20. int _read( int fd, uint16_t offset, char* data, int data_len );
  21. public:
  22. explicit spiPort( CSTR DevicePath, int Speed );
  23. virtual ~spiPort();
  24. bool readMZ( uint16_t offset, uint8_t *buffer, int len );
  25. bool writeMZ( uint16_t offset, uint8_t *buffer, int len );
  26. uint8_t read8( uint16_t offset );
  27. bool write8( uint16_t offset, uint8_t byte );
  28. };
  29. #endif