Page 1 of 1

VS1063 Developer Board buttons scan?

Posted: Tue 2018-09-11 9:55
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?