dRonin  adbada4
dRonin firmware
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
pios_servo.c File Reference
#include "pios.h"
#include "pios_servo_priv.h"
#include "pios_tim_priv.h"
#include <pios_dio.h>
#include "pios_inlinedelay.h"
#include "pios_irq.h"
#include "misc_math.h"

Go to the source code of this file.

Data Structures

struct  dshot_info
 
struct  output_channel
 
struct  timer_bank
 

Macros

#define CLEAR_BITS(gpio, bits)   do { (gpio)->BSRR = ((uint32_t) bits) << 16; } while (0)
 
#define SET_BITS(gpio, bits)   do { (gpio)->BSRR = bits; } while (0)
 

Enumerations

enum  dshot_gpio
 The counter rate for the channel, used to calculate compare values. More...
 
enum  channel_mode
 

Functions

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...
 
int32_t PIOS_Servo_Init (const struct pios_servo_cfg *cfg)
 
void PIOS_Servo_DisableChannel (int channel)
 
int PIOS_Servo_GetPins (dio_tag_t *dios, int max_dio)
 
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)
 
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...
 
static void PIOS_Servo_SetRaw (uint8_t servo, uint32_t raw_position)
 
void PIOS_Servo_SetFraction (uint8_t servo, uint16_t fraction, uint16_t max_val, uint16_t min_val)
 
bool PIOS_Servo_IsDshot (uint8_t servo)
 
void PIOS_Servo_Set (uint8_t servo, float position)
 
static int DSHOT_Update ()
 
void PIOS_Servo_Update (void)
 
void PIOS_Servo_PrepareForReset ()
 Determines the APB clock used by a given timer. More...
 

Variables

static const struct
pios_servo_cfg
servo_cfg
 
static uint32_t channel_mask = 0
 
 DS_GPIOA = 0
 
 DS_GPIOB
 
 DS_GPIOC
 
 DS_GPIO_NUMVALS
 
 UNCONFIGURED = 0
 
 REGULAR_PWM
 
 REGULAR_INVERTED_PWM
 
 SYNC_PWM
 
 SYNC_DSHOT_300
 
 SYNC_DSHOT_600
 
 SYNC_DSHOT_1200
 
 SYNC_DSHOT_DMA
 
struct dshot_info __attribute__
 
enum channel_mode mode
 
union {
   uint32_t   pwm_res
 
   struct dshot_info   dshot
 
i
 
static struct output_channeloutput_channels
 
static uintptr_t servo_tim_id
 
static bool resetting
 
static bool dshot_in_use
 

Macro Definition Documentation

#define CLEAR_BITS (   gpio,
  bits 
)    do { (gpio)->BSRR = ((uint32_t) bits) << 16; } while (0)
#define SET_BITS (   gpio,
  bits 
)    do { (gpio)->BSRR = bits; } while (0)