First Release
Embed:
(wiki syntax)
Show/hide line numbers
Out_MD.h
00001 /** Class: Out_MD 00002 * 00003 * Used for writing to Megadrive analog joystick input mode 00004 * 00005 */ 00006 00007 #include "mbed.h" 00008 #include "InputStatus.h" 00009 00010 class Out_MD 00011 { 00012 public: 00013 /** Constructor: Out_MD 00014 * 00015 * Parameters: 00016 * pn_D0 - DigitalOut for Megadrive's D0 (D-Sub 9pin connector's pin1) 00017 * pn_D1 - DigitalOut for D1 (D-Sub9 pin2) 00018 * pn_D2 - DigitalOut for D2 (D-Sub9 pin3) 00019 * pn_D3 - DigitalOut for D3 (D-Sub9 pin4) 00020 * pn_LH - DigitalOut for L/H (D-Sub9 pin6) 00021 * pn_REQ - InterruptIn for Req (D-Sub9 pin7) 00022 * pn_ACK - DigitalOut for Ack (D-Sub9 pin9) 00023 * inputStatus - The variable holds input status 00024 */ 00025 00026 Out_MD( 00027 PinName pn_D0, PinName pn_D1, PinName pn_D2, PinName pn_D3, 00028 PinName pn_LH, PinName pn_REQ, PinName pn_ACK, 00029 InputStatus *inputStatus 00030 ); 00031 /* 00032 void ShowReqInterval(); 00033 */ 00034 void SetupInputControll(void (*startInputFunction)(void), void (*stopInputFunction)(void)); 00035 class CDummy; 00036 template<class T> 00037 void SetupInputControll(T* inputInstance, void (T::*startInputMethod)(void), void (T::*stopInputMethod)(void)) 00038 { 00039 _InputInstance = (CDummy*) inputInstance; 00040 StartInputMethod = (void (CDummy::*)(void)) startInputMethod; 00041 StopInputMethod = (void (CDummy::*)(void)) stopInputMethod; 00042 } 00043 00044 // Public constants 00045 static const int DIGITAL_PERIODICPOLLING_COUNTERMAX = 12000;//7300; // 周期ポーリングカウンタ最大値 00046 // (ポーリングに使うカウンタ最大値) 00047 00048 00049 private: 00050 // Private constants 00051 static const int REQUESTINTERVAL__MICROSEC = 10000; // reading period 10msec 00052 static const int TRANSFERSPEED_MAX__MICROSEC = 50; // from AJOY_SUB.DOC 00053 static const int TRANSFERSPEED_1_2__MICROSEC = 96; 00054 static const int TRANSFERSPEED_1_3__MICROSEC = 144; 00055 static const int TRANSFERSPEED_1_4__MICROSEC = 192; 00056 00057 static const int DIGITAL_PERIODICPOLLING_INTERVAL__MICROSEC = 7000;//10000; // 周期ポーリングの間隔 00058 // (フレーム毎のゲーム機からのパッド読み取りの 00059 // 前後のみ、集中してポーリングを行う) 00060 00061 static const int DIGITAL_STATE_RENEW_INTERVAL__MICROSEC = 2000; // 周期ポーリングの休みの間、デジタルパッド更新 00062 static const int MODECHECK_INTERVAL__MICROSEC = 2000; // InputStatusのデジタルモード・アナログモード切替を見張る間隔 00063 00064 // mbed pins 00065 DigitalOut _OUT_D0; 00066 DigitalOut _OUT_D1; 00067 DigitalOut _OUT_D2; 00068 DigitalOut _OUT_D3; 00069 DigitalOut _OUT_LH; 00070 InterruptIn _INTR_REQ; 00071 DigitalOut _OUT_ACK; 00072 BusOut _DataBus; 00073 00074 // Variables 00075 InputStatus *_InputStatus; 00076 volatile char _InputMode; 00077 int _TransferSpeed; 00078 Ticker _DigitalStateRenewTicker; 00079 Ticker _DigitalPeriodicPollingTicker; 00080 Ticker _ModeChecker; 00081 volatile int _ButtonStatus; 00082 char _SwapAC; // Aボタン-Cボタンをスワップする?(マスターシステム向け) 00083 char _AnalogMUSHAMethod; // 武者アレスタ向けAnalog処理を使う? 00084 00085 CDummy* _InputInstance; 00086 00087 00088 // Private Method 00089 void Initialize(void); 00090 // void InitInterruptPriority(void); 00091 void ISR_Analog_ReqFall(void); 00092 void SetPinValue(int val); 00093 void SetData_Analog_PhaseOf(char phase); 00094 00095 void DigitalStateRenewMethod(void); 00096 void EnableDigitalStateRenew(void); 00097 void DisableDigitalStateRenew(void); 00098 void RenewDigitalPadStatus(char phase); 00099 00100 void RestartDigitalPeriodicPolling(void); 00101 void DigitalPeriodicPollingMethod(void); 00102 00103 void EnableModeChecker(void); 00104 void DisableModeChecker(void); 00105 void ModeCheckerMethod(void); 00106 00107 00108 00109 00110 void (CDummy::*StartInputMethod)(void); 00111 void (CDummy::*StopInputMethod)(void); 00112 void (*StartInputFunction)(void); 00113 void (*StopInputFunction)(void); 00114 00115 void EnableInput(void); 00116 void DisableInput(void); 00117 }; 00118
Generated on Thu Jul 14 2022 14:49:55 by 1.7.2