Hello All,
I am relatively new to the wide world of Toradex/Embedded Linux (Most of my embedded experience has been in the PIC32/FreeRTOS land) and I am running into an issue. We have a 256x64 OLED display that is connected via GPIO to the apalis iMX6Q with a Preemptive RT Linux Kernel. This GPIO is in an 8-bit configuration. The unfortunate thing is that we are forced to use this horizontal screen in a vertical orientation which now means that for every screen update, 256 * 8 bytes of data must be clocked out to the display. Now I have accomplished this and have a functioning display. However, the maximum refresh that I am able to achieve is ~1.8 Hz. This is really not fast enough, I am hoping to get ~10 Hz. Based on investigation, this is a result of slow execution of Linux’s sysfs file writes and priorities of execution. I have read that there is really no direct way to manipulate the GPIO hardware, that a linux kernel driver is about as close as one could safely get. I have no idea how to accomplish this and I would really like to avoid having to recompile the OS. Below is my write function that is called in a loop to clock out the display data, any thoughts on how to speed this up, or make it such that linux is forced to execute this and only this every time it is called? Thanks!
void WritePort(unsigned char data)
{
static char in[1] = {0};
static bool ok;
// Before we can write the port, we have to ensure that the data buffer
// on the display is ready for more data. How this is done depends on
// whether or not pin 3 is set up for PBUSY or not
#if NORITAKE_OLED_BUSY_CONNECTED == 1
// Wait for BUSY line to be de-asserted
do
{
read(fdCFG, in, 1);
}
while(!atoi(in));
#else
write(dirfd, "in", 2);
do
{
write(fdRD, "0", 1);
usleep(1);
read(fdDBUS[7], in, 1);
ok = in[0];
write(fdRD, "1", 1);
}
while (ok);
write(dirfd, "out", 3);
#endif
if(data & 0x01) write(fdDBUS[0], "1", 1); else write(fdDBUS[0], "0", 1);
if(data & 0x02) write(fdDBUS[1], "1", 1); else write(fdDBUS[1], "0", 1);
if(data & 0x04) write(fdDBUS[2], "1", 1); else write(fdDBUS[2], "0", 1);
if(data & 0x08) write(fdDBUS[3], "1", 1); else write(fdDBUS[3], "0", 1);
if(data & 0x10) write(fdDBUS[4], "1", 1); else write(fdDBUS[4], "0", 1);
if(data & 0x20) write(fdDBUS[5], "1", 1); else write(fdDBUS[5], "0", 1);
if(data & 0x40) write(fdDBUS[6], "1", 1); else write(fdDBUS[6], "0", 1);
if(data & 0x80) write(fdDBUS[7], "1", 1); else write(fdDBUS[7], "0", 1);
// Toggle write pin
usleep(1);
write(fdWR, "0", 1);
usleep(1);
write(fdWR, "1", 1);
}