12345678910111213141516171819202122232425262728293031323334353637383940414243444546 |
- #include "cirque_pinnacle.h"
- #include "spi_master.h"
- #define WRITE_MASK 0x80
- #define READ_MASK 0xA0
- #define FILLER_BYTE 0xFC
- extern bool touchpad_init;
- void RAP_ReadBytes(uint8_t address, uint8_t* data, uint8_t count) {
- uint8_t cmdByte = READ_MASK | address;
- if (touchpad_init) {
- if (spi_start(CIRQUE_PINNACLE_SPI_CS_PIN, CIRQUE_PINNACLE_SPI_LSBFIRST, CIRQUE_PINNACLE_SPI_MODE, CIRQUE_PINNACLE_SPI_DIVISOR)) {
- spi_write(cmdByte);
- spi_write(FILLER_BYTE);
- spi_write(FILLER_BYTE);
- for (uint8_t i = 0; i < count; i++) {
- data[i] = spi_write(FILLER_BYTE);
- }
- } else {
- pd_dprintf("error cirque_pinnacle spi_start read\n");
- touchpad_init = false;
- }
- spi_stop();
- }
- }
- void RAP_Write(uint8_t address, uint8_t data) {
- uint8_t cmdByte = WRITE_MASK | address;
- if (touchpad_init) {
- if (spi_start(CIRQUE_PINNACLE_SPI_CS_PIN, CIRQUE_PINNACLE_SPI_LSBFIRST, CIRQUE_PINNACLE_SPI_MODE, CIRQUE_PINNACLE_SPI_DIVISOR)) {
- spi_write(cmdByte);
- spi_write(data);
- } else {
- pd_dprintf("error cirque_pinnacle spi_start write\n");
- touchpad_init = false;
- }
- spi_stop();
- }
- }
|