Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
PS2MS.h
00001 /** 00002 * PS/2 mouse interface control class (Version 0.0.1) 00003 * 00004 * Copyright (C) 2010 Shinichiro Nakamura (CuBeatSystems) 00005 * http://shinta.main.jp/ 00006 */ 00007 00008 #ifndef _PS2MS_H_ 00009 #define _PS2MS_H_ 00010 00011 #include "mbed.h" 00012 00013 /** 00014 * PS/2 mouse interface control class. 00015 */ 00016 class PS2MS { 00017 public: 00018 /** 00019 * Create. 00020 * 00021 * @param clk_pin Clock pin. 00022 * @param dat_pin Data pin. 00023 */ 00024 PS2MS(PinName clk_pin, PinName dat_pin); 00025 00026 /** 00027 * Destory. 00028 */ 00029 virtual ~PS2MS(); 00030 00031 /** 00032 * Get a data from a PS/2 device. 00033 * 00034 * @return A data from a PS/2 device. 00035 */ 00036 virtual int getc(void); 00037 00038 /** 00039 * Set timeout. 00040 * 00041 * @param ms Timeout ms. 00042 */ 00043 virtual void setTimeout(int ms); 00044 void init_work(void); 00045 void detatch(void); 00046 int sendCommand(char c); 00047 private: 00048 static const int RINGBUFSIZ = 2048; 00049 static const int MAX_RETRY = 1000000; 00050 static const int CLOCK_DOWN_EDGE_WAIT_MS = 1000000; 00051 volatile bool mSending; 00052 volatile bool mInFuncFall; 00053 00054 InterruptIn clk; /**< Interrupt input for CLK. */ 00055 DigitalInOut clkOut; /**< Digital input/output for CLK. */ 00056 DigitalInOut dat; /**< Digital input/output for DAT. */ 00057 Timeout wdt; /**< Watch dog timer. */ 00058 Timer tot; /**< Timeout timer. */ 00059 int timeout; /**< Timeout[ms] for getc(). */ 00060 00061 typedef struct { 00062 int bitcnt; 00063 int cStart; 00064 int cEnd; 00065 uint8_t buffer[RINGBUFSIZ]; 00066 } work_t; 00067 work_t work; 00068 00069 void func_timeout(void); 00070 void func_fall(void); 00071 bool waitClockDownEdge(void); 00072 bool waitClockUpLevel(void); 00073 00074 }; 00075 00076 #endif
Generated on Wed Jul 13 2022 15:37:35 by
1.7.2