Skip to content

Commit 1eb877c

Browse files
committed
Limit PI-SPI-DIN 8AI SPI frequency to 100kHz
1 parent 91be125 commit 1eb877c

1 file changed

Lines changed: 5 additions & 9 deletions

File tree

src/pi_spi_din_8ai.c

Lines changed: 5 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,21 @@
11
#include <spi.h>
2-
#include <wiringPi.h>
3-
//#include <wiringPiSPI.h>
42

53
#include "pi_spi_din.h"
64

5+
#define MAX_SPI_FREQ 100000
6+
77
uint16_t pi_spi_din_8ai_read_single(enum chip_enable ce, uint8_t channel)
88
{
99
channel = channel > 7 ? 7 : channel;
1010

1111
uint8_t data[3] =
1212
{
13-
0x06 | (channel >> 2 & 0x01),
14-
channel << 6 & 0xC0,
13+
0x06 | ((channel >> 2) & 0x01),
14+
(channel << 6) & 0xC0,
1515
0
1616
};
1717

18-
/*digitalWrite(chip_enable, LOW);
19-
wiringPiSPIDataRW(0, data, 3);
20-
digitalWrite(chip_enable, HIGH);*/
21-
22-
spi_open(ce, 500000);
18+
spi_open(ce, MAX_SPI_FREQ);
2319
spi_transfer(data, 3);
2420

2521
return (((uint16_t)data[1] & 0x0F) << 8) | data[2];

0 commit comments

Comments
 (0)