We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent 91be125 commit 1eb877cCopy full SHA for 1eb877c
1 file changed
src/pi_spi_din_8ai.c
@@ -1,25 +1,21 @@
1
#include <spi.h>
2
-#include <wiringPi.h>
3
-//#include <wiringPiSPI.h>
4
5
#include "pi_spi_din.h"
6
+#define MAX_SPI_FREQ 100000
+
7
uint16_t pi_spi_din_8ai_read_single(enum chip_enable ce, uint8_t channel)
8
{
9
channel = channel > 7 ? 7 : channel;
10
11
uint8_t data[3] =
12
13
- 0x06 | (channel >> 2 & 0x01),
14
- channel << 6 & 0xC0,
+ 0x06 | ((channel >> 2) & 0x01),
+ (channel << 6) & 0xC0,
15
0
16
};
17
18
- /*digitalWrite(chip_enable, LOW);
19
- wiringPiSPIDataRW(0, data, 3);
20
- digitalWrite(chip_enable, HIGH);*/
21
-
22
- spi_open(ce, 500000);
+ spi_open(ce, MAX_SPI_FREQ);
23
spi_transfer(data, 3);
24
25
return (((uint16_t)data[1] & 0x0F) << 8) | data[2];
0 commit comments