VECX Vectrex emulator port

Pyrofer
 
Posts: 61
Joined: Tue Oct 21, 2014 11:35 am

VECX Vectrex emulator port

Wed Feb 04, 2015 11:14 am

Pretty much running full speed with an SPI LCD.

https://www.youtube.com/watch?v=pax7kA2gCFs

Greenwire-Elektronik
 
Posts: 101
Joined: Thu Dec 04, 2014 6:31 am

Re: VECX Vectrex emulator port

Wed Feb 04, 2015 1:32 pm

Which SPI frequency did you use?
Buy now - breakout board for VoCore to easy adapting your idea!

Follow us on Twitter or facebook!

Pyrofer
 
Posts: 61
Joined: Tue Oct 21, 2014 11:35 am

Re: VECX Vectrex emulator port

Wed Feb 04, 2015 2:25 pm

None. It's manually bitbanging the GPIO to control the LCD.

This is actually quicker than the hardware SPI in this instance. Due to the overhead of calling the hardware SPI routines it's very slow to send a single byte. It's also only 8bit hardware SPI with no provision for a D/C select.
The LCD requires a dedicated D/C pin. In order to plot a line I need to send each pixel individually. Each pixel requires sending 9 bytes (3 for xpos, 3 for ypos and 3 for colour), toggling the D/C pin between them to denote a command byte or data for that command. There is no way to make the hardware SPI port do this.

The way I am memory mapping the GPIO and toggling the register directly is much quicker than the hardware SPI calls for single byte transfers and suits this application well.

Greenwire-Elektronik
 
Posts: 101
Joined: Thu Dec 04, 2014 6:31 am

Re: VECX Vectrex emulator port

Wed Feb 04, 2015 5:27 pm

I know the problem with the D/C select - the 5110 display is also needing it. What i saw so far was that the longest amount of time was needed to switch the GPIOs (using /sys/class/gpio) - the lowest frequency of hw spi is 1 MHz - i am really wondering which frequency you meet with this bit banging. I assume that you write to the GPIOs directly?

I got away from direct writing into the RT5350 - it is a good way for hardware guys like us, but it may interfere if it is not the only program running.
Buy now - breakout board for VoCore to easy adapting your idea!

Follow us on Twitter or facebook!

Pyrofer
 
Posts: 61
Joined: Tue Oct 21, 2014 11:35 am

Re: VECX Vectrex emulator port

Wed Feb 04, 2015 11:33 pm

Not sure of the exact frequency but it's pretty fast. This is soft GPIO SPI,
https://www.youtube.com/watch?v=IaRMiQkniKg

as is this,
https://www.youtube.com/watch?v=aiSgUTlXrms

I have the problem now that I have no clue how to READ a GPIO by similar method.

Greenwire-Elektronik
 
Posts: 101
Joined: Thu Dec 04, 2014 6:31 am

Re: VECX Vectrex emulator port

Thu Feb 05, 2015 7:34 am

Which method are you using?

You can use the direct method:
Code: Select all
int ris_edge;
int* gpio;

 gpio = (unsigned int*) mmap(0, 4096, PROT_READ|PROT_WRITE, MAP_SHARED, fd, 0x10000000);

ris_edge=gpio[0x608>>2];


or the more official but indirect method via the kernel driver:
Code: Select all
static const char *gpio_dc_dir = "/sys/class/gpio/gpio0/direction";
int fd_dc_dir;
char value;

fd_dc_dir = open(gpio_dc_dir, O_RDONLY);

write(fd_dc_dir, &value, 1);


For the second method, i suggest this page.
Buy now - breakout board for VoCore to easy adapting your idea!

Follow us on Twitter or facebook!

Pyrofer
 
Posts: 61
Joined: Tue Oct 21, 2014 11:35 am

Re: VECX Vectrex emulator port

Thu Feb 05, 2015 10:20 am

First method as it's the quickest.

I was trying to integrate the touch screen on my LCD, while using the hardware SPI I hooked the gpio up to the touch controller and wanted to read in the inputs from it.

So, "ris_edge=gpio[0x608>>2];" where >>2 is the gpio pin? so >>19 for gpio19 ?

Greenwire-Elektronik
 
Posts: 101
Joined: Thu Dec 04, 2014 6:31 am

Re: VECX Vectrex emulator port

Thu Feb 05, 2015 11:37 am

I am sorry - ris_edge would hold the whole register, not a single bit. The Adressing [0x608>>2] is necessary due to the 32-to-8 bit conversion.
The variables are 32-bit wide -> means a single array field in gpio is 32 bit. The registers i want to address has to be address 8 bit wide - so i divde by 4 (right shift by 2).

You could just mask the gpio you want to read

Code: Select all
#define GPIO19 19

if (ris_edge & (1 << GPIO19) != 0)
     printf("HIGH");
else
     printf("LOW");


or in short

Code: Select all

bGPIO19 = (ris_edge & (1 << GPIO19) != 0) ? true : false;



This uses the so-called "conditional expression" -> msdn example
Buy now - breakout board for VoCore to easy adapting your idea!

Follow us on Twitter or facebook!

Pyrofer
 
Posts: 61
Joined: Tue Oct 21, 2014 11:35 am

Re: VECX Vectrex emulator port

Fri Feb 06, 2015 11:12 am

it just doesn't work for me.

gpio[0x608>>2] ALWAYS gives 0.

No matter the state of the input pin, which I have verified works by doing cat /sys/class/gpio/gpio19/value and it shows as 1 or 0 as it should.

Pyrofer
 
Posts: 61
Joined: Tue Oct 21, 2014 11:35 am

Re: VECX Vectrex emulator port

Fri Feb 06, 2015 1:21 pm

So looking at the data sheet Apparently the "static state" of the pin is at offset 0x0620 not 0x0608. the 08 offset is for rising edge changes.

However, when checking the state at 0x0620 I STILL only get zero!

NOTHING I can do makes this bloody thing read in the right value.

Next
Return to VoCore & VoCore+Dock

Who is online

Users browsing this forum: No registered users and 67 guests