Classes | Macros | Typedefs | Enumerations | Functions | Variables
drv_pwm.c File Reference
#include <stdint.h>
#include <stdbool.h>
#include <stdlib.h>
#include "stm32f10x_conf.h"
#include "drv_gpio.h"
#include "drv_timer.h"
#include "drv_pwm.h"
#include "drv_system.h"
Include dependency graph for drv_pwm.c:

Go to the source code of this file.

Classes

struct  pwmPortData_t
 

Macros

#define PWM_TIMER_8_MHZ   8
 
#define PWM_TIMER_MHZ   1
 

Typedefs

typedef void(* pwmWriteFuncPtr) (uint8_t index, uint16_t value)
 

Enumerations

enum  { TYPE_IP = 0x10, TYPE_IW = 0x20, TYPE_M = 0x40, TYPE_S = 0x80 }
 
enum  { TYPE_PWM_IN_OUT = 0x000, TYPE_GPIO_OUTPUT = 0x100 }
 

Functions

static void configureSonar (uint8_t port)
 
static void ppmCallback (uint8_t port, uint16_t capture)
 
static void pwmCallback (uint8_t port, uint16_t capture)
 
static void pwmGPIOConfig (GPIO_TypeDef *gpio, uint32_t pin, GPIO_Mode mode)
 
static void pwmICConfig (TIM_TypeDef *tim, uint8_t channel, uint16_t polarity)
 
static pwmPortData_tpwmInConfig (uint8_t port, timerCCCallbackPtr callback, uint8_t channel)
 
void pwmInit (bool useCPPM, bool usePwmFilter, bool fastPWM, uint32_t motorPwmRate, uint16_t idlePulseUsec)
 
uint32_t pwmLastUpdate ()
 
bool pwmNewData ()
 
static void pwmOCConfig (TIM_TypeDef *tim, uint8_t channel, uint16_t value)
 
static pwmPortData_tpwmOutConfig (uint8_t port, uint8_t mhz, uint16_t period, uint16_t value)
 
uint16_t pwmRead (uint8_t channel)
 
static void pwmWriteBrushed (uint8_t index, uint16_t value)
 
void pwmWriteMotor (uint8_t index, uint16_t value)
 
static void pwmWriteStandard (uint8_t index, uint16_t value)
 
static void sonarCallback (uint8_t port, uint16_t capture)
 
bool sonarPresent ()
 
float sonarRead (uint8_t channel)
 

Variables

static uint16_t captures [MAX_INPUTS]
 
static pwmPortData_tmotors [MAX_PORTS]
 
static const uint16_t multiPPM []
 
static const uint16_t multiPPMSONAR []
 
static const uint16_t multiPWM []
 
static bool new_data = false
 
static uint8_t numInputs = 0
 
static uint8_t numMotors = 0
 
static uint8_t pwmFilter = 0
 
static uint32_t pwmLastUpdateTime_ms = 0
 
static pwmPortData_t pwmPorts [MAX_PORTS]
 
static pwmWriteFuncPtr pwmWritePtr = NULL
 
static bool sonar_present = false
 
static uint16_t sonar_reads [MAX_INPUTS]
 
static uint8_t sonar_trigger_port
 

Macro Definition Documentation

#define PWM_TIMER_8_MHZ   8

Definition at line 77 of file drv_pwm.c.

#define PWM_TIMER_MHZ   1

Definition at line 76 of file drv_pwm.c.

Typedef Documentation

typedef void(* pwmWriteFuncPtr) (uint8_t index, uint16_t value)

Definition at line 65 of file drv_pwm.c.

Enumeration Type Documentation

anonymous enum
Enumerator
TYPE_IP 
TYPE_IW 
TYPE_M 
TYPE_S 

Definition at line 274 of file drv_pwm.c.

anonymous enum
Enumerator
TYPE_PWM_IN_OUT 
TYPE_GPIO_OUTPUT 

Definition at line 281 of file drv_pwm.c.

Function Documentation

static void configureSonar ( uint8_t  port)
static

Definition at line 259 of file drv_pwm.c.

static void ppmCallback ( uint8_t  port,
uint16_t  capture 
)
static

Definition at line 191 of file drv_pwm.c.

static void pwmCallback ( uint8_t  port,
uint16_t  capture 
)
static

Definition at line 216 of file drv_pwm.c.

static void pwmGPIOConfig ( GPIO_TypeDef gpio,
uint32_t  pin,
GPIO_Mode  mode 
)
static

Definition at line 128 of file drv_pwm.c.

static void pwmICConfig ( TIM_TypeDef tim,
uint8_t  channel,
uint16_t  polarity 
)
static

Definition at line 114 of file drv_pwm.c.

static pwmPortData_t* pwmInConfig ( uint8_t  port,
timerCCCallbackPtr  callback,
uint8_t  channel 
)
static

Definition at line 170 of file drv_pwm.c.

void pwmInit ( bool  useCPPM,
bool  usePwmFilter,
bool  fastPWM,
uint32_t  motorPwmRate,
uint16_t  idlePulseUsec 
)

Definition at line 353 of file drv_pwm.c.

uint32_t pwmLastUpdate ( )

Definition at line 186 of file drv_pwm.c.

bool pwmNewData ( )

Definition at line 422 of file drv_pwm.c.

static void pwmOCConfig ( TIM_TypeDef tim,
uint8_t  channel,
uint16_t  value 
)
static

Definition at line 79 of file drv_pwm.c.

static pwmPortData_t* pwmOutConfig ( uint8_t  port,
uint8_t  mhz,
uint16_t  period,
uint16_t  value 
)
static

Definition at line 138 of file drv_pwm.c.

uint16_t pwmRead ( uint8_t  channel)

Definition at line 409 of file drv_pwm.c.

static void pwmWriteBrushed ( uint8_t  index,
uint16_t  value 
)
static

Definition at line 343 of file drv_pwm.c.

void pwmWriteMotor ( uint8_t  index,
uint16_t  value 
)

Definition at line 403 of file drv_pwm.c.

static void pwmWriteStandard ( uint8_t  index,
uint16_t  value 
)
static

Definition at line 348 of file drv_pwm.c.

static void sonarCallback ( uint8_t  port,
uint16_t  capture 
)
static

Definition at line 238 of file drv_pwm.c.

bool sonarPresent ( )

Definition at line 432 of file drv_pwm.c.

float sonarRead ( uint8_t  channel)

Definition at line 427 of file drv_pwm.c.

Variable Documentation

uint16_t captures[MAX_INPUTS]
static

Definition at line 68 of file drv_pwm.c.

pwmPortData_t* motors[MAX_PORTS]
static

Definition at line 339 of file drv_pwm.c.

const uint16_t multiPPM[]
static
Initial value:
= {
0xFFF
}
Definition: drv_pwm.h:39
Definition: drv_pwm.h:40
Definition: drv_pwm.h:31
Definition: drv_pwm.h:44
Definition: drv_pwm.h:36
Definition: drv_pwm.h:41
Definition: drv_pwm.h:37
Definition: drv_pwm.h:38
Definition: drv_pwm.h:43
Definition: drv_pwm.h:35
Definition: drv_pwm.h:42

Definition at line 286 of file drv_pwm.c.

const uint16_t multiPPMSONAR[]
static
Initial value:
= {
0xFFF
}
Definition: drv_pwm.h:39
Definition: drv_pwm.h:40
Definition: drv_pwm.h:31
Definition: drv_pwm.h:44
Definition: drv_pwm.h:36
Definition: drv_pwm.h:33
Definition: drv_pwm.h:41
Definition: drv_pwm.h:37
Definition: drv_pwm.h:38
Definition: drv_pwm.h:34
Definition: drv_pwm.h:43
Definition: drv_pwm.h:35
Definition: drv_pwm.h:42
Definition: drv_pwm.h:32

Definition at line 301 of file drv_pwm.c.

const uint16_t multiPWM[]
static
Initial value:
= {
0xFFF
}
Definition: drv_pwm.h:39
Definition: drv_pwm.h:40
Definition: drv_pwm.h:31
Definition: drv_pwm.h:44
Definition: drv_pwm.h:36
Definition: drv_pwm.h:33
Definition: drv_pwm.h:41
Definition: drv_pwm.h:37
Definition: drv_pwm.h:38
Definition: drv_pwm.h:34
Definition: drv_pwm.h:43
Definition: drv_pwm.h:35
Definition: drv_pwm.h:42
Definition: drv_pwm.h:32

Definition at line 320 of file drv_pwm.c.

bool new_data = false
static

Definition at line 73 of file drv_pwm.c.

uint8_t numInputs = 0
static

Definition at line 341 of file drv_pwm.c.

uint8_t numMotors = 0
static

Definition at line 340 of file drv_pwm.c.

uint8_t pwmFilter = 0
static

Definition at line 71 of file drv_pwm.c.

uint32_t pwmLastUpdateTime_ms = 0
static

Definition at line 72 of file drv_pwm.c.

pwmPortData_t pwmPorts[MAX_PORTS]
static

Definition at line 67 of file drv_pwm.c.

pwmWriteFuncPtr pwmWritePtr = NULL
static

Definition at line 70 of file drv_pwm.c.

bool sonar_present = false
static

Definition at line 74 of file drv_pwm.c.

uint16_t sonar_reads[MAX_INPUTS]
static

Definition at line 69 of file drv_pwm.c.

uint8_t sonar_trigger_port
static

Definition at line 63 of file drv_pwm.c.



rosflight_firmware
Author(s): Daniel Koch , James Jackson
autogenerated on Thu Apr 15 2021 05:07:50