PIOS interface to read and write from servo PWM ports.
More...
|
int32_t | PIOS_PWM_Init (uintptr_t *pwm_id, const struct pios_pwm_cfg *cfg) |
|
int | PIOS_Servo_GetPins (dio_tag_t *dios, int max_dio) |
|
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 Synchronous updates (e.g. SyncPWM/OneShot), otherwise normal PWM at the specified output rate. SyncPWM uses hardware one-pulse mode. Timer prescaler and related parameters are calculated based on the channel with highest max pulse length on each timer. A deadtime is provided to ensure SyncPWM pulses cannot merge. The information required to convert from us to compare value is cached for each channel (not timer) to facilitate PIOS_Servo_Set. More...
|
|
void | PIOS_Servo_SetFraction (uint8_t servo, uint16_t fraction, uint16_t max_val, uint16_t min_val) |
|
void | PIOS_Servo_DisableChannel (int channel) |
|
void | PIOS_Servo_PrepareForReset () |
| Determines the APB clock used by a given timer. More...
|
|
void | PIOS_Servo_Set (uint8_t servo, float position) |
|
void | PIOS_Servo_Update (void) |
|
bool | PIOS_Servo_IsDshot (uint8_t servo) |
|
int32_t | PIOS_Servo_Init (const struct pios_servo_cfg *cfg) |
|
enum dshot_gpio | __attribute__ ((packed)) |
|
static uint32_t | timer_apb_clock (TIM_TypeDef *timer) |
|
static uint32_t | max_timer_clock (TIM_TypeDef *timer) |
| Determines the maximum clock rate for a given timer (i.e. no prescale) More...
|
|
static void | ChannelSetup_DShot (int j, uint16_t rate) |
|
static int | BankSetup_DShot (struct timer_bank *bank) |
|
static int | BankSetup_OneShot (struct timer_bank *bank, int32_t max_tim_clock) |
|
static int | BankSetup_PWM (struct timer_bank *bank, int32_t max_tim_clock, uint16_t rate) |
|
static void | PIOS_Servo_SetRaw (uint8_t servo, uint32_t raw_position) |
|
static int | DSHOT_Update () |
|
PIOS interface to read and write from servo PWM ports.
Code to do set RC servo output.
#define PIOS_SERVO_MAX_BANKS 8 |
The counter rate for the channel, used to calculate compare values.
Definition at line 61 of file pios_servo.c.
Enumerator |
---|
SHOT_ONESHOT |
|
SHOT_DSHOT300 |
|
SHOT_DSHOT600 |
|
SHOT_DSHOT1200 |
|
Definition at line 40 of file pios_servo.h.
static int BankSetup_DShot |
( |
struct timer_bank * |
bank | ) |
|
|
static |
static int BankSetup_OneShot |
( |
struct timer_bank * |
bank, |
|
|
int32_t |
max_tim_clock |
|
) |
| |
|
static |
static int BankSetup_PWM |
( |
struct timer_bank * |
bank, |
|
|
int32_t |
max_tim_clock, |
|
|
uint16_t |
rate |
|
) |
| |
|
static |
static void ChannelSetup_DShot |
( |
int |
j, |
|
|
uint16_t |
rate |
|
) |
| |
|
static |
static int DSHOT_Update |
( |
| ) |
|
|
static |
static uint32_t max_timer_clock |
( |
TIM_TypeDef * |
timer | ) |
|
|
static |
Determines the maximum clock rate for a given timer (i.e. no prescale)
- Parameters
-
[in] | timer | Pointer to the base register of the timer to check |
- Return values
-
Definition at line 957 of file pios_servo.c.
int32_t PIOS_PWM_Init |
( |
uintptr_t * |
pwm_id, |
|
|
const struct pios_pwm_cfg * |
cfg |
|
) |
| |
void PIOS_Servo_DisableChannel |
( |
int |
channel | ) |
|
int PIOS_Servo_GetPins |
( |
dio_tag_t * |
dios, |
|
|
int |
max_dio |
|
) |
| |
bool PIOS_Servo_IsDshot |
( |
uint8_t |
servo | ) |
|
void PIOS_Servo_PrepareForReset |
( |
| ) |
|
Determines the APB clock used by a given timer.
- Parameters
-
[in] | timer | Pointer to the base register of the timer to check |
- Return values
-
Clock | frequency in Hz Prepare for IAP reset. Stop PWM, so ESCs disarm. |
Definition at line 948 of file pios_servo.c.
void PIOS_Servo_Set |
( |
uint8_t |
servo, |
|
|
float |
position |
|
) |
| |
Set servo position
- Parameters
-
[in] | Servo | Servo number (0->num_channels-1) |
[in] | Position | Servo position in microseconds |
Definition at line 624 of file pios_servo.c.
void PIOS_Servo_SetFraction |
( |
uint8_t |
servo, |
|
|
uint16_t |
fraction, |
|
|
uint16_t |
max_val, |
|
|
uint16_t |
min_val |
|
) |
| |
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 Synchronous updates (e.g. SyncPWM/OneShot), otherwise normal PWM at the specified output rate. SyncPWM uses hardware one-pulse mode. Timer prescaler and related parameters are calculated based on the channel with highest max pulse length on each timer. A deadtime is provided to ensure SyncPWM pulses cannot merge. The information required to convert from us to compare value is cached for each channel (not timer) to facilitate PIOS_Servo_Set.
- Parameters
-
out_rate | array of output rate in Hz, banks elements |
banks | maximum number of banks |
channel_max | array of max pulse lengths, number of channels elements |
- Todo:
- attempts to just fall back to bitbanging, which seems not ideal– no benefit to doing DMA if we are bitbanging at the same time.
Definition at line 304 of file pios_servo.c.
static void PIOS_Servo_SetRaw |
( |
uint8_t |
servo, |
|
|
uint32_t |
raw_position |
|
) |
| |
|
static |
void PIOS_Servo_Update |
( |
void |
| ) |
|
Update the timer for HPWM/OneShot
Definition at line 865 of file pios_servo.c.
static uint32_t timer_apb_clock |
( |
TIM_TypeDef * |
timer | ) |
|
|
static |
uint32_t channel_mask = 0 |
|
static |
uint32_t timer_bank::clk_rate |
union { ... } output_channel::i |
uint16_t timer_bank::max_pulse |
uint16_t timer_bank::period |
uint16_t timer_bank::prescaler |
uint32_t output_channel::pwm_res |
uint32_t { ... } ::pwm_res |
TIM_TypeDef* timer_bank::timer |
uint16_t dshot_info::value |