drv_mb1030.c
Go to the documentation of this file.
1 #include <stdint.h>
2 #include <stdbool.h>
3 #include <stdlib.h>
4 
5 #include "stm32f10x_conf.h"
6 #include "core_cm3.h"
7 
8 #include "drv_gpio.h"
9 #include "drv_timer.h"
10 #include "drv_pwm.h"
11 
12 typedef struct{
15  uint32_t pin;
16  uint8_t channel;
17  uint8_t irq;
18 } sonar_t;
19 
20 static sonar_t sonar_hardware[6] = {
21  { TIM2, GPIOA, Pin_1, TIM_Channel_2, TIM2_IRQn }, // RC2
22  { TIM2, GPIOA, Pin_2, TIM_Channel_3, TIM2_IRQn }, // RC3
23  { TIM2, GPIOA, Pin_3, TIM_Channel_4, TIM2_IRQn }, // RC4
24  { TIM3, GPIOA, Pin_6, TIM_Channel_1, TIM3_IRQn }, // RC5
25  { TIM3, GPIOA, Pin_7, TIM_Channel_2, TIM3_IRQn }, // RC6
26  { TIM3, GPIOB, Pin_0, TIM_Channel_3, TIM3_IRQn }, // RC7
27 };
28 
30 {
31  for(int i = 0; i < 6; i++)
32  {
33  pwmGPIOConfig(sonar_hardware[i].gpio, sonar_hardware[i].pin, Mode_IPD);
34  pwmICConfig(sonar_hardware[i].tim, sonar_hardware[i].channel, TIM_ICPolarity_Rising);
35 }
Definition: drv_gpio.h:44
uint32_t pin
Definition: drv_mb1030.c:15
#define TIM_Channel_3
#define GPIOA
Definition: stm32f4xx.h:2110
#define TIM3
Definition: stm32f4xx.h:2038
#define TIM2
Definition: stm32f4xx.h:2037
#define GPIOB
Definition: stm32f4xx.h:2111
#define TIM_Channel_2
static void pwmICConfig(TIM_TypeDef *tim, uint8_t channel, uint16_t polarity)
Definition: drv_pwm.c:114
#define TIM_Channel_4
static void pwmGPIOConfig(GPIO_TypeDef *gpio, uint32_t pin, GPIO_Mode mode)
Definition: drv_pwm.c:128
Definition: drv_gpio.h:48
GPIO_TypeDef * gpio
Definition: drv_mb1030.c:14
static sonar_t sonar_hardware[6]
Definition: drv_mb1030.c:20
TIM_TypeDef * tim
Definition: drv_mb1030.c:13
General Purpose I/O.
Definition: stm32f4xx.h:1281
void mb1030_init()
Definition: drv_mb1030.c:29
Definition: drv_gpio.h:45
#define TIM_Channel_1
#define TIM_ICPolarity_Rising
Definition: drv_gpio.h:43
uint8_t channel
Definition: drv_mb1030.c:16
uint8_t irq
Definition: drv_mb1030.c:17
Definition: drv_gpio.h:42
Definition: drv_gpio.h:49


rosflight_firmware
Author(s): Daniel Koch , James Jackson
autogenerated on Thu Oct 24 2019 03:17:18