First Release

Dependencies:   USBDevice

Embed: (wiki syntax)

« Back to documentation index

Show/hide line numbers Out_FC.cpp Source File

Out_FC.cpp

00001 #include "Out_FC.h"
00002 #include "C_Out_FC.h"
00003 
00004 //
00005 // Constructor
00006 //
00007 Out_FC::Out_FC(
00008     PinName pn_LATCH, PinName pn_DATA, PinName pn_CLOCK, PinName pn_POWDETECT,
00009     InputStatus *inputStatus)
00010     : _INTR_LATCH(pn_LATCH), _OUT_DATA(pn_DATA), _INTR_CLOCK(pn_CLOCK), _INTR_POWDETECT(pn_POWDETECT)
00011 {
00012     
00013     _InputStatus = inputStatus;
00014     
00015     Initialize();
00016 
00017     // C function Initializer
00018     
00019     _pEnableInput.attach(this, &Out_FC::EnableInput);
00020     _pDisableInput.attach(this, &Out_FC::DisableInput);
00021     
00022     C_Out_FC_Initialize(
00023         &_INTR_LATCH,
00024         &_OUT_DATA,
00025         &_INTR_CLOCK,
00026         &_INTR_POWDETECT,
00027         &_Buttons,
00028         &_Ch0,
00029         &_Ch1,
00030         &_Ch2,
00031     //  &_RapidFireValue,
00032         &_InputDeviceType,
00033         &_pEnableInput,
00034         &_pDisableInput
00035     );
00036 }
00037 
00038 //
00039 // Initialize
00040 //
00041 void Out_FC::Initialize()
00042 {
00043 //  InitInterruptPriority();
00044     
00045     // Pin Setting
00046     _INTR_LATCH.mode(PullUp);
00047     _INTR_CLOCK.mode(PullUp);
00048 
00049     // Ticker Setting
00050     _RenewFCInputTicker.attach_us(
00051         this, 
00052         &Out_FC::RenewFCInputDataPeriodically, 
00053         FC_INPUTSTATE_RENEWINTERVAL__MICROSEC
00054     );
00055     
00056 }
00057 
00058 
00059 //
00060 // 入力データ更新Ticker処理
00061 //
00062 void Out_FC::RenewFCInputDataPeriodically(void)
00063 {
00064     _Buttons         = _InputStatus->Buttons;
00065     _Ch0             = _InputStatus->Ch0;
00066     _Ch1             = _InputStatus->Ch1;
00067     _Ch2             = _InputStatus->Ch2;
00068     _InputDeviceType = _InputStatus->InputDeviceType;
00069 }
00070 
00071 
00072 
00073 void Out_FC::SetupInputControll(void (*startInputFunction)(void), void (*stopInputFunction)(void))
00074 {
00075     StartInputFunction = startInputFunction;
00076     StopInputFunction  = stopInputFunction;
00077 }
00078 
00079 void Out_FC::EnableInput(void)
00080 {
00081     // Ticker Setting
00082     _RenewFCInputTicker.attach_us(
00083         this, 
00084         &Out_FC::RenewFCInputDataPeriodically, 
00085         FC_INPUTSTATE_RENEWINTERVAL__MICROSEC
00086     );
00087 
00088     if(_InputInstance && StartInputMethod)
00089     {
00090         (_InputInstance->*StartInputMethod)();
00091     }
00092     else if(StartInputFunction)
00093     {
00094         StartInputFunction();
00095     }
00096 }
00097 
00098 void Out_FC::DisableInput(void)
00099 {
00100     _RenewFCInputTicker.detach();
00101     
00102     if(_InputInstance && StopInputMethod)
00103     {
00104         (_InputInstance->*StopInputMethod)();
00105     }
00106     else if(StopInputFunction)
00107     {
00108         StopInputFunction();
00109     }
00110 }
00111 
00112