aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/touchpad/ads7843_lld.c
blob: 507a21046bc6a1458017a880163d2ddf1f5bd274 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
#include "ads7843_lld.h"

#ifdef TOUCHPAD_USE_ADS7843

__inline uint16_t lld_readX(void) {
    uint8_t txbuf[1];
    uint8_t rxbuf[2];
    uint16_t x;

    txbuf[0] = 0xd0;
    TP_CS_LOW;
	spiSend(&SPID1, 1, txbuf);
    spiReceive(&SPID1, 2, rxbuf);
    TP_CS_HIGH;

    x = rxbuf[0] << 4;
    x |= rxbuf[1] >> 4;
    
    return x;
}

__inline uint16_t lld_readY(void) {
    uint8_t txbuf[1];
    uint8_t rxbuf[2];
    uint16_t y;

    txbuf[0] = 0x90;
    TP_CS_LOW;
    spiSend(&SPID1, 1, txbuf);
    spiReceive(&SPID1, 2, rxbuf);
    TP_CS_HIGH;

    y = rxbuf[0] << 4;
    y |= rxbuf[1] >> 4;

    return y;
}

__inline uint16_t lld_readZ(void) {
	return 0;
}

#endif