UART
Posted: Tue Apr 28, 2020 10:44 am
Hi,
I am trying to ge the LCDs to work with a UART connected to a MCU. I have the following LCD:
GTT43A-TPC-BLM-B0-H1-CT-V5
GTT70A-TPC-BLM-B0-H1-CT-V5
I have it all setup and configured through the GTT Designer to be a Serial connection.
This is the code:
All I want for now is to log text on my terminal when something happens on the screen.
I added the clear screen
and the code hangs.
when I debug, I get the following issue which is where the program hangs:
in gtt_packet_builder
within the gtt_parser-waitpacket
in gtt_parser.c
and ultimately ends in this call always returning a -1. So no char in the buffer.
Can you help me look into this? I am trying to see if this is a initialization issue, a setup issue, or a function/code issue.
I am only calling the clear screen command. I am not calling gtt_parser_process(gtt); in a loop.
Which leads me to my other question.
with UART, do i need to poll, or can I just tie an interrupt to my UART, and the interrupt will call gtt_parser_process(gtt) everytime a char is received?
Thanks,
H-
I am trying to ge the LCDs to work with a UART connected to a MCU. I have the following LCD:
GTT43A-TPC-BLM-B0-H1-CT-V5
GTT70A-TPC-BLM-B0-H1-CT-V5
I have it all setup and configured through the GTT Designer to be a Serial connection.
This is the code:
Code: Select all
int uart_generic_read(gtt_device *device)
{
(void)device;
uint8_t c;
/* Check if there is anything to read in the RX buffer */
if(cyhal_uart_readable(&uartUserManagementDisp) == 0)
{
/* Return -1 is no character exists */
return -1;
}
else
{
cyhal_uart_getc(&uartUserManagementDisp, &c, 10);
}
/* Return read character */
return c;
}
int uart_generic_write(gtt_device *device, uint8_t *data, size_t length)
{
(void)device;
/* Write the passed data and return the actual length sent */
cyhal_uart_write(&uartUserManagementDisp, data, &length);
return length;
}
void my_gtt_event_key(gtt_device* device, uint8_t key, eKeypadRepeatMode type)
{
(void)device;
(void)key;
(void)type;
Log_Message(info, "event key\r\n");
}
void my_gtt_event_sliderchange(gtt_device* device, eTouchReportingType type, uint8_t slider, int16_t value)
{
(void)device;
(void)type;
(void)slider;
(void)value;
Log_Message(info, "event slider change\r\n");
}
void my_gtt_event_touch(gtt_device* device, eTouchReportingType type, uint16_t x , uint16_t y)
{
(void)device;
Log_MessageVariadic(info, "Event Touch %d x=%d y=%d\r\n",type,x,y);
}
void my_gtt_event_regiontouch(gtt_device* device, eTouchReportingType type, uint8_t region)
{
(void)device;
Log_MessageVariadic(info, "Region Touch %d region=%d\r\n",type,region);
}
void my_gtt_event_baseobject_on_property_change(gtt_device* device, uint16_t ObjectID, uint16_t PropertyID)
{
(void)device;
(void)ObjectID;
(void)PropertyID;
Log_Message(info, "event on property change\r\n");
}
void my_gtt_event_visualobject_on_key(gtt_device* device, uint16_t ObjectID, uint8_t Row, uint8_t Col, uint8_t ScanCode, uint8_t Down)
{
(void)device;
(void)ObjectID;
(void)Row;
(void)Col;
(void)Down;
(void)ScanCode;
Log_Message(info, "event on key\r\n");
}
void my_gtt_event_button_click(gtt_device* device, uint16_t ObjectID, uint8_t State)
{
(void)device;
(void)ObjectID;
(void)State;
Log_Message(info, "event button click\r\n");
}
gtt_events myEvents = {
.sliderchange = my_gtt_event_sliderchange,
.touch = my_gtt_event_touch,
.regiontouch = my_gtt_event_regiontouch,
.baseobject_on_property_change = my_gtt_event_baseobject_on_property_change,
.visualobject_on_key = my_gtt_event_visualobject_on_key,
.button_click = my_gtt_event_button_click
};
gtt_device gtt_device_instance = {
.Write = uart_generic_write,
.Read = uart_generic_read,
.secured_packets = 1,
.rx_buffer = rx_buffer,
.rx_buffer_size = sizeof(rx_buffer),
.tx_buffer = tx_buffer,
.tx_buffer_size = sizeof(tx_buffer),
.events = {
.sliderchange = my_gtt_event_sliderchange,
.touch = my_gtt_event_touch,
.regiontouch = my_gtt_event_regiontouch,
.baseobject_on_property_change = my_gtt_event_baseobject_on_property_change,
.visualobject_on_key = my_gtt_event_visualobject_on_key,
.button_click = my_gtt_event_button_click
},
};
I added the clear screen
Code: Select all
/* Clear the screen */
gtt_clear_screen(gtt);
when I debug, I get the following issue which is where the program hangs:
in gtt_packet_builder
Code: Select all
void gtt_packetbuilder_send(gtt_device *device)
{
if (device->secured_packets)
{
size_t index = 0;
do
{
device->Write(device, device->tx_buffer, device->tx_index);
index = [highlight=yellow]gtt_parser_waitpacket(device, 251);[/highlight]
} while (device->rx_buffer[index] != 0);
}
else
{
device->Write(device, device->tx_buffer, device->tx_index);
}
packetStarted = 0;
}
in gtt_parser.c
Code: Select all
size_t gtt_parser_waitpacket(gtt_device *device,int packetType)
{
gtt_waitlist_item *item = &device->waitlist[device->wait_idx++];
item->Command = packetType;
item->SubCommand = 0;
item->Done = 0;
while (!item->Done)
[highlight=yellow]gtt_parser_process(device);[/highlight]
size_t result = item->PacketStart;
device->Parser.Index = item->PacketStart;
device->wait_idx--;
return result;
}
Code: Select all
uint8_t gtt_parser_process(gtt_device *device)
{
int Res = device->Read(device);
[highlight=yellow]if (Res != -1)[/highlight]
.
.
.
}
I am only calling the clear screen command. I am not calling gtt_parser_process(gtt); in a loop.
Which leads me to my other question.
with UART, do i need to poll, or can I just tie an interrupt to my UART, and the interrupt will call gtt_parser_process(gtt) everytime a char is received?
Thanks,
H-