diff --git a/discovery/src/ll_touch.c b/discovery/src/ll_touch.c index e9b51ac..31f5d8b 100644 --- a/discovery/src/ll_touch.c +++ b/discovery/src/ll_touch.c @@ -1,6 +1,102 @@ #include "ll_touch.h" -bool ll_touch_init() { - return false; +void ll_touch_read(const u16 RegisterStartAddress, const u8 NumberOfRegisters, u16 *DataBuffer, const u16 OffsetInBuffer) +{ + u16 ControlValue; + u8 i,j, RegisterIndex; + u16 InputValue; + + ControlValue = 0xE400 | (RegisterStartAddress & 0x03FF); // Create the 16-bit header + + for (i=0;i<100;i++); // delay + + //Write out the control word + GPIO_ResetBits(GPIOA, GPIO_Pin_4); // CS low + SPI_I2S_SendData(SPI1, ControlValue); + while(SPI_I2S_GetFlagStatus(SPI1, SPI_I2S_FLAG_BSY) != RESET); + while(SPI_I2S_GetFlagStatus(SPI1, SPI_I2S_FLAG_RXNE) == RESET); + InputValue = SPI_I2S_ReceiveData(SPI1); // Read dummy + + //Copy each register in the buffer contiguously. + //Read data in. + for (RegisterIndex=0; RegisterIndex