VS1063 Developer Board buttons scan?

Writing software that controls the system and peripherals such as displays, SD cards, Buttons, LEDs, Serial Ports etc.
Post Reply
lijinqiu1
User
Posts: 2
Joined: Thu 2018-09-06 13:19

VS1063 Developer Board buttons scan?

Post by lijinqiu1 »

I am new here.I am reading the "VS10X3 DeveloperBoard" code, and I have a question with the buttons scan!
I read the buttons sch and the code

Code: Select all

u_int16 GetKeyState() {
	u_int16 g;
	USEX(SER_DREQ) = 0;
	USEX(GPIO_ODATA) &= ~((1<<3)|(1<<5));
	g = (USEX(GPIO_IDATA) & ((1<<10)|(1<<8)|(1<<11))) >> 8; 	
	USEX(SER_DREQ) = 1;	
	g |= (USEX(GPIO_IDATA) & ((1<<10)|(1<<8)|(1<<11))) >> 4;
	USEX(SER_DREQ) = 0;
	USEX(GPIO_ODATA) |= ((1<<3)|(1<<5));
	g |= (USEX(GPIO_IDATA) & ((1<<10)|(1<<8)|(1<<11))) >> 0;
	{
		static u_int16 lastKeypress = 0;
		u_int16 result = g;
		if (g != lastKeypress)
		{ 
			result = 0; //Glitch removal
		}
		lastKeypress = g;
		return result;
	}
}
As the code writed,I think when I push "SW3"(UP Button),the result should be "0x100",but macro define the "sw3 = 1".
This my doubt?
Attachments
vs1063dev13-sch.pdf
(2.05 MiB) Downloaded 423 times
User avatar
Panu
VSDSP Expert
Posts: 2829
Joined: Tue 2010-06-22 13:43

Re: VS1063 Developer Board buttons scan?

Post by Panu »

Hi!

Hmm... I wrote the code something like 6 or 7 years ago... so I don't remember exactly how it works. But I remember that it does work and that I got the switch values by printing the values that actually end up into g in the real board. There's a lot of shifting going on to set GPIO bits into different, non-clashing positions when multiplexing the keys, so it's rather difficult to see from the code where each GPIO bit actually does end up, for me anyway.

I remember that the code worked, and nobody has complained about it so far. That doesn't mean that there cannot be any errors, so please report me how exactly your real board behaves and we can take a look at it.

-Panu
User avatar
pasi
VLSI Staff
Posts: 2120
Joined: Thu 2010-07-15 16:04

Re: VS1063 Developer Board buttons scan?

Post by pasi »

Panu mentioned shifting, so should
g |= (USEX(GPIO_IDATA) & ((1<<10)|(1<<8)|(1<<11))) >> 0;
be
g |= (USEX(GPIO_IDATA) & ((1<<10)|(1<<8)|(1<<11))) >> 8;
?
(Why shift with 0?)
Visit https://www.facebook.com/VLSISolution VLSI Solution on Facebook
Post Reply