dji_mfio.hpp
Go to the documentation of this file.
1 
30 #ifndef DJI_MFIO_H
31 #define DJI_MFIO_H
32 
33 #include "dji_vehicle_callback.hpp"
34 
35 namespace DJI
36 {
37 namespace OSDK
38 {
39 
40 // Forward Declarations
41 class Vehicle;
42 
56 class MFIO
57 {
58 public:
59  typedef enum MODE {
60  MODE_PWM_OUT = 0,
61  MODE_PWM_IN = 1,
62  MODE_GPIO_OUT = 2,
63  MODE_GPIO_IN = 3,
64  MODE_ADC = 4
65  } MODE;
66 
67  typedef enum CHANNEL {
68  CHANNEL_0 = 0,
69  CHANNEL_1 = 1,
70  CHANNEL_2 = 2,
71  CHANNEL_3 = 3,
72  CHANNEL_4 = 4,
73  CHANNEL_5 = 5,
74  CHANNEL_6 = 6,
75  CHANNEL_7 = 7,
76  } CHANNEL;
77 
78 public:
79  MFIO(Vehicle* vehicle);
80  ~MFIO();
81 
82  // Non-blocking API
83 
95  void config(MODE mode, CHANNEL channel, uint32_t defaultValue, uint16_t freq,
96  VehicleCallBack fn = 0, UserData userData = 0);
97 
107  void setValue(CHANNEL channel, uint32_t value, VehicleCallBack fn = 0,
108  UserData data = 0);
109 
118  void getValue(CHANNEL channel, VehicleCallBack fn = 0, UserData data = 0);
119 
120  // Blocking API
121 
132  ACK::ErrorCode config(MODE mode, CHANNEL channel, uint32_t defaultValue,
133  uint16_t freq, int wait_timeout);
134 
143  ACK::ErrorCode setValue(CHANNEL channel, uint32_t value, int wait_timeout);
144 
152  ACK::MFIOGet getValue(CHANNEL channel, int wait_timeout);
153 
154 private:
155  static void initCallback(Vehicle *vehicle, RecvContainer recvFrame,
156  UserData data);
157  static void setValueCallback(Vehicle *vehicle, RecvContainer recvFrame,
158  UserData data);
159  static void getValueCallback(Vehicle *vehicle, RecvContainer recvFrame,
160  UserData data);
161 
162 private:
163  Vehicle* vehicle;
164 
165  uint8_t channelUsage;
166 
167 private:
168 #pragma pack(1)
169  typedef struct InitData
170  {
171  uint8_t channel;
172  uint8_t mode;
173  uint32_t value;
174  uint16_t freq;
175  } InitData; // pack(1)
176 
177  typedef struct SetData
178  {
179  uint8_t channel;
180  uint32_t value;
181  } SetData; // pack(1)
182 
183  typedef uint32_t GetData;
184 
185  typedef struct GetResult
186  {
187  uint8_t reserved;
188  uint32_t value;
189  } GetResult; // pack(1)
190 
191 #pragma pack()
192 }; // class MFIO
193 
194 } // OSDK
195 } // DJI
196 
197 #endif // DJI_MFIO_H
void * UserData
This is used as the datatype for all data arguments in callbacks.
Definition: dji_type.hpp:75
This struct is returned from all blocking calls, except certain mission calls that have explicit type...
Definition: dji_ack.hpp:146
Type definition for new Vehicle-style callbacks.
APIs for Multi-Function Input-Output functionality.
Definition: dji_mfio.hpp:56
void(* VehicleCallBack)(Vehicle *vehicle, RecvContainer recvFrame, UserData userData)
Function prototype for all callback functions used in the OSDK.
Definition: dji_vehicle_callback.hpp:76
void getValue(CHANNEL channel, VehicleCallBack fn=0, UserData data=0)
Non-blocking call for getting data from an MFIO channel.
Definition: dji_mfio.cpp:180
void config(MODE mode, CHANNEL channel, uint32_t defaultValue, uint16_t freq, VehicleCallBack fn=0, UserData userData=0)
Non-blocking call for initializing an MFIO channel.
Definition: dji_mfio.cpp:47
Received info.
Definition: dji_vehicle_callback.hpp:59
void setValue(CHANNEL channel, uint32_t value, VehicleCallBack fn=0, UserData data=0)
Non-blocking call for setting an MFIO value to a channel.
Definition: dji_mfio.cpp:127
This struct is returned from the DJI::OSDK::MFIO::getValue blocking API.
Definition: dji_ack.hpp:173
Definition: dji_ack.cpp:38