Files
x1key/src.original/x1key.h
Philip Smart 6ac7fa5563 First push
2022-02-17 13:17:58 +00:00

59 lines
1.7 KiB
C
Raw Permalink Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
/*
PS/2 キーボードを SHARP X1 につなぐ
X1 キーボードの送信処理
2014年7月22日 作成
佐藤恭一 http://kyoutan.jpn.org/
無保証です。
佐藤恭一が作成した部分は用途に制限を設けません。商用・非商用にかかわらず自由に使用して頂いて構いません。
勝手に複製したり、改造したり、配布したり、売ったりしても良いということです。
連絡不要です。
*/
/*
18.432MHz
1周期 = 1/18.432 = 0.0543[us]
256周期 = 256/18.432 = 13.89[us]
65536周期 = 65536/18.432 = 3555[us]
1750[us] 1750/(1/18.432) = 1750*(18.432/1) = 1750*18.432
= 32256 = 0x7E00
1000[us] = 1000 *18.432 = 18432 周期 = 0x4800
750[us] = 13824 = 0x3600
700[us] = 12902 = 0x3266
250[us] = 250*18.432 = 4608 = 0x1200
タイマーRB2のプログラム波形生成モードがいいかと思ったけど、プライマリ期間の
アンダーフローで割り込み要求できないようだったので、
タイマーRJ2のパルス出力モードを使うことにする。
*/
#define TRJ1750us (0x7E00 - 2)
#define TRJ1000us (0x4800 - 0) // タイマー停止状態で使うので、ここは引かない
#define TRJ750us (0x3600 - 2)
#define TRJ700us (0x3266 - 1)
#define TRJ250us (0x1200 - 2)
#define TRJSTOP (0xFFFF) // ストップビット後のおやすみ期間
// TRJレジスタに書いてから、リロードレジスタに転送されるまで 23サイクルかかるので
// そのぶん引いておく
void X1_send(unsigned short data);
void x1key_init(void);
unsigned char tochar(unsigned char a);
void puth2(unsigned char a);
//extern volatile unsigned short SEND_DATA; // X1送信データ
// b15 : 0=テンキーからの入力
// b14 : 0=キー入力有り
// b13 : 0=リピート有り
// b12 : 0=GRAPH ON
// b11 : 0=CAPS ON
// b10 : 0=カナ ON
// b09 : 0=SHIFT ON
// b08 : 0=CTRL ON
// b07-00 : ASCII CODE (0x00=KEY OFF)