#include <p24FJ64GA002.h>
#include "types.h"
#include "librtc.h"
#include "libps2.h"
マクロ定義 | |
#define | GPIO_PS2_CLK PORTBbits.RB8 |
#define | GPIO_PS2_DAT PORTBbits.RB9 |
#define | PS2_KEY_BUFFER_SIZE 5 |
#define | PS2_CODE_BUFFER_SIZE 16 |
関数 | |
void | __attribute__ ((interrupt, auto_psv)) |
void | PS2_init (void) |
BOOL | PS2_main (void) |
void | PS2_key_buf_clear (void) |
unsigned char | PS2_key_get (void) |
unsigned char | PS2_key_check (void) |
変数 | |
PS2_T | ps2 |
#define GPIO_PS2_CLK PORTBbits.RB8 |
参照元 __attribute__().
#define GPIO_PS2_DAT PORTBbits.RB9 |
参照元 __attribute__().
#define PS2_KEY_BUFFER_SIZE 5 |
参照元 PS2_key_get().
void __attribute__ | ( | (interrupt, auto_psv) | ) |
参照先 GPIO_PS2_CLK, GPIO_PS2_DAT, rtc, RTC_get_ticks(), と RTC::tick.
{ static unsigned int last = 0x0000; static unsigned int buf = 0x0000; static unsigned char count = 0x00; IFS1bits.CNIF = 0; /* クロックが送られてきたら、処理を行う */ if(GPIO_PS2_CLK == 0){ /* 久しぶりのクロックならば、バッファをクリアする */ if(RTC_get_ticks(last, rtc.tick) > 5){ buf = 0x0000; count = 0x00; } last = rtc.tick; /* データ受信処理 */ buf = (buf << 1) + GPIO_PS2_DAT; count++; /* 正しいパケットならば、スキャンコードバッファへ送る */ if(count > 10){ PS2_code_put(reverse(buf >> 2)); /* パリティビットは無視 */ buf = 0x0000; count = 0x00; } } else { /* 立ち上がりエッジでは、何もしない */ } return; }
void PS2_init | ( | void | ) |
参照先 PS2_key_buf_clear(), と PS2::wait.
参照元 main().
{ PS2_key_buf_clear(); PS2_code_buf_clear(); ps2.wait = 3000; CNEN2bits.CN22IE = 1; IPC4bits.CNIP = 5; IEC1bits.CNIE = 1; IFS1bits.CNIF = 0; return; }
void PS2_key_buf_clear | ( | void | ) |
参照元 PS2_init(), と SCREEN_main().
{
key_stptr = 0x00;
key_enptr = 0x00;
PS2_code_buf_clear();
return;
}
unsigned char PS2_key_check | ( | void | ) |
参照元 SCREEN_main().
{ /* Buffer is Empty */ if(key_stptr == key_enptr){ return(0x00); } return(key_buf[ key_stptr ]); }
unsigned char PS2_key_get | ( | void | ) |
参照先 PS2_KEY_BUFFER_SIZE.
参照元 SCREEN_main().
{ unsigned char buf, nxptr; /* Buffer is Empty */ if(key_stptr == key_enptr){ return(0x00); } buf = key_buf[ key_stptr ]; nxptr = key_stptr + 1; if(nxptr >= PS2_KEY_BUFFER_SIZE) nxptr = 0; key_stptr = nxptr; return(buf); }
BOOL PS2_main | ( | void | ) |
参照元 SCREEN_main().