41 lines
1,021 B
C++
41 lines
1,021 B
C++
#ifndef C9ED230E_05FF_4E41_87B9_664DF1FD835C
|
|
#define C9ED230E_05FF_4E41_87B9_664DF1FD835C
|
|
/*
|
|
*******************************************************************************
|
|
* INCLUDE
|
|
*******************************************************************************
|
|
*/
|
|
#include <stdint.h>
|
|
|
|
namespace Hardware
|
|
{
|
|
/*
|
|
*******************************************************************************
|
|
* CLASS DECLARE
|
|
*******************************************************************************
|
|
*/
|
|
class SPI
|
|
{
|
|
public:
|
|
static const uint8_t MODE_0;
|
|
static const uint8_t MODE_1;
|
|
static const uint8_t MODE_2;
|
|
static const uint8_t MODE_3;
|
|
|
|
public:
|
|
SPI(int bus, int cs);
|
|
~SPI();
|
|
|
|
public:
|
|
int setSpeed(uint32_t speed);
|
|
int setMode(uint8_t mode);
|
|
int setBitsPerWord(uint8_t bits);
|
|
int setLSBFirst(bool enable);
|
|
|
|
int writeThenRead(const uint8_t* tx, int txlen, uint8_t* rx, int rxlen);
|
|
|
|
private:
|
|
int _fd;
|
|
};
|
|
}
|
|
#endif
|