RobertoBenjami/stm32_graphics_display_drivers

Touch xpt2046/ili9341

Isaac-94 opened this issue · 1 comments

Hello Roberto, Thanks a lot for your excellent work. A time ago, I got from china, some recicled boards wich use Illi 9341, ads7846 and stm32f103vct6 and a 2.8 inch Lcd , but I didn´t get any information about firmware (It was for a cryolipolysis machine). Your firmware on the display is working excellent but when I tried to add ts functions I coudnt get to make it work. I have to say the ADS7846 isn´t conected to SPI port, so I had to use the configuration for SPI SOFTWARE. After try reading cordinates results on serial port, I realised that the firmware doesnt write the port and also cant get the coordinates. I wrote my own code and I discoverd that the problem is using bit masking for write/read ports.
Your code write in ts_xpt_2046.c
void TsWrite8(uint8_t d8)
{

GPIOX_ODR(TS_MOSI) = BITBAND_ACCESS(d8, 7);
TS_WRITE_CLK;
GPIOX_ODR(TS_MOSI) = BITBAND_ACCESS(d8, 6);
TS_WRITE_CLK;
GPIOX_ODR(TS_MOSI) = BITBAND_ACCESS(d8, 5);
TS_WRITE_CLK;
GPIOX_ODR(TS_MOSI) = BITBAND_ACCESS(d8, 4);
TS_WRITE_CLK;
GPIOX_ODR(TS_MOSI) = BITBAND_ACCESS(d8, 3);
TS_WRITE_CLK;
GPIOX_ODR(TS_MOSI) = BITBAND_ACCESS(d8, 2);
TS_WRITE_CLK;
GPIOX_ODR(TS_MOSI) = BITBAND_ACCESS(d8, 1);
TS_WRITE_CLK;
GPIOX_ODR(TS_MOSI) = BITBAND_ACCESS(d8, 0);
TS_WRITE_CLK;
}

I tried with that and I got values, but has too much noise, I would like use your code

unsigned char TCS_SPI_Read_Write(unsigned char DataByte)
{
unsigned char Bit,result = 0 ;
for (Bit = 0; Bit < 8; Bit++)
{
// Clock High(Prepared Write Data)
HAL_GPIO_WritePin(GPIOD, GPIO_PIN_15, GPIO_PIN_SET);
// Write Data to MOSI Pin : MSB First
if((DataByte & 0b10000000)== 0b10000000)//0x80)
{
// Set Bit Data(MOSI) = 1
HAL_GPIO_WritePin(GPIOD, GPIO_PIN_13, GPIO_PIN_SET);
}
else
{
// Reset Bit Data(MOSI) = 0
HAL_GPIO_WritePin(GPIOD, GPIO_PIN_13, GPIO_PIN_RESET);
}
// Clock Low(Strobe Data & Read)
HAL_GPIO_WritePin(GPIOD, GPIO_PIN_15, GPIO_PIN_RESET);
// Shift Next Bit Data
DataByte <<= 1;
// Read Data From MISO Pin
result <<= 1;
if ( HAL_GPIO_ReadPin(GPIOD, GPIO_PIN_11) == GPIO_PIN_SET)
{
result |= 0b00000001;//0x01;
} }
return (result);
}

Thanks again, regards from Argentina