2007年12月25日火曜日

Pull up/down

Pull up/down

これまたすばらしいページです。
世にあまたある情報かもしれませんが、
ググルのカミが上位に上げたので、リンクを保存…

プルアップとかプルダウンとか
さっぱり分からなかったけど、
なんとなく分かってきました。

2007年12月20日木曜日

PSoCでUSBマウスを作る (dinop.com)

PSoCでUSBマウスを作る (dinop.com)


なんかヒントがありそうな気がする。
やっぱり割り込みを使ってボールの移動量を増減しているようだ。
使ってるチップもサイプレスの「CY8C24794-24LFXI」だし。


以下は上記ページから転載。。。。

#pragma interrupt_handler GPIO_INT

void GPIO_INT(void)

{

if((SW_1_PORT & SW_1_A) == 0)

{

if(SW_1_PORT & SW_1_B)

abMouseData[1] -= 10; //move to left

else

abMouseData[1] += 10; //move to right

}



if((SW_2_PORT & SW_2_A) == 0)

{

if(SW_2_PORT & SW_2_B)

abMouseData[2] -= 10; //move to up

else

abMouseData[2] += 10; //move to down

}



if(PRT1DR & 0x10)

abMouseData[0] |= 0x01; //left button down

else

abMouseData[0] &= ~0x01; //left button up



if(PRT1DR & 0x20)

abMouseData[0] |= 0x02; //right button down

else

abMouseData[0] &= ~0x02; //right button up

}