dRonin  adbada4
dRonin firmware
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
pios_servo.h
Go to the documentation of this file.
1 
15 /*
16  * This program is free software; you can redistribute it and/or modify
17  * it under the terms of the GNU General Public License as published by
18  * the Free Software Foundation; either version 3 of the License, or
19  * (at your option) any later version.
20  *
21  * This program is distributed in the hope that it will be useful, but
22  * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
23  * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
24  * for more details.
25  *
26  * You should have received a copy of the GNU General Public License along
27  * with this program; if not, see <http://www.gnu.org/licenses/>
28  */
29 
30 #ifndef PIOS_SERVO_H
31 #define PIOS_SERVO_H
32 
33 #include <pios_dio.h>
34 
35 #define PIOS_SERVO_MAX_BANKS 8
36 
37 /* Used in out_rate. If 65535, we really mean 65535Hz. Values close to that
38  * are reserved/abused for dshot support. 0 is used for sync pwm per legacy
39  */
42  SHOT_DSHOT300 = 65532,
43  SHOT_DSHOT600 = 65533,
45 };
46 
48  int (*set_mode)(const uint16_t *out_rate, const int banks,
49  const uint16_t *channel_max, const uint16_t *channel_min);
50 
51  void (*set)(uint8_t servo, float position);
52 
53  void (*update)();
54 };
55 
56 extern int PIOS_Servo_GetPins(dio_tag_t *dios, int max_dio);
57 
58 /* Only applicable to simulation; takes reference to cb */
59 extern void PIOS_Servo_SetCallbacks(const struct pios_servo_callbacks *cb);
60 
61 /* Public Functions */
62 extern int PIOS_Servo_SetMode(const uint16_t *out_rate, const int banks, const uint16_t *channel_max, const uint16_t *channel_min);
63 
64 #ifndef FLIGHT_POSIX
65 extern void PIOS_Servo_SetFraction(uint8_t servo, uint16_t fraction,
66  uint16_t max_val, uint16_t min_val);
67 extern void PIOS_Servo_DisableChannel(int channel);
68 #endif
69 
70 extern void PIOS_Servo_PrepareForReset();
71 extern void PIOS_Servo_Set(uint8_t servo, float position);
72 extern void PIOS_Servo_Update(void);
73 extern bool PIOS_Servo_IsDshot(uint8_t servo);
74 
75 #endif /* PIOS_SERVO_H */
76 
bool PIOS_Servo_IsDshot(uint8_t servo)
Definition: pios_servo.c:605
void PIOS_Servo_Set(uint8_t servo, float position)
Definition: pios_servo.c:624
int(* set_mode)(const uint16_t *out_rate, const int banks, const uint16_t *channel_max, const uint16_t *channel_min)
Definition: pios_servo.h:48
void PIOS_Servo_SetFraction(uint8_t servo, uint16_t fraction, uint16_t max_val, uint16_t min_val)
Definition: pios_servo.c:546
pios_servo_shot_type
Definition: pios_servo.h:40
int PIOS_Servo_GetPins(dio_tag_t *dios, int max_dio)
Definition: pios_servo.c:163
void PIOS_Servo_DisableChannel(int channel)
Definition: pios_servo.c:158
void PIOS_Servo_PrepareForReset()
Determines the APB clock used by a given timer.
Definition: pios_servo.c:948
void PIOS_Servo_SetCallbacks(const struct pios_servo_callbacks *cb)
int PIOS_Servo_SetMode(const uint16_t *out_rate, const int banks, const uint16_t *channel_max, const uint16_t *channel_min)
PIOS_Servo_SetMode Sets the PWM output frequency and resolution. An output rate of 0 indicates Synchr...
Definition: pios_servo.c:304
void * dio_tag_t
Definition: pios_dio.h:12
uint16_t servo[8]
Definition: msp_messages.h:96
void PIOS_Servo_Update(void)
Definition: pios_servo.c:865
void(* set)(uint8_t servo, float position)
Definition: pios_servo.h:51