DHCOM_HAL
Hardware-abstraction library (HAL) for multiple targets, including DHCOM modules
 All Data Structures Namespaces Files Functions Typedefs Enumerations Enumerator Macros Pages
SPI.h
Go to the documentation of this file.
1 /*
2  * spi.h
3  *
4  * Created on: 07.11.2012
5  * Author: Peter Kishalov (PK), DH electronics GmbH
6  */
7 
8 
9 #ifndef SPI_H_
10 #define SPI_H_
11 
12 
13 #include <DHCOM_HAL.h>
14 #include <hal/Types.h>
15 #include <stddef.h>
16 
17 
18 namespace dhcom
19 {
20 
21 
22 class SPIImpl;
23 
24 
26 {
27 public:
29  enum DEVICE
30  {
31  DEVICE_SPI1 = 1,
32  DEVICE_SPI2 = 2,
33  };
34 
37  {
38  CS_0 = 0,
39  CS_1 = 1,
40  CS_2 = 2,
41  };
42 
44  enum MODE
45  {
46  MODE_0, MODE_1, MODE_2, MODE_3,
47  };
48 
49  SPI(DEVICE device, CHIPSELECT chipSelect);
50  ~SPI();
51 
52  STATUS open();
53  STATUS close();
54  bool isOpen() const;
55 
56  STATUS setCommParams(MODE mode, uint8_t bits, uint32_t freqHZ);
57  int transceive(const uint8_t *outputBuffer, uint8_t *inputBuffer, uint32_t count, STATUS *status = NULL);
58 
59 private:
60  SPIImpl * const impl_;
61 };
62 
63 
126 }
127 
128 
129 #endif /* SPI_H_ */