Skip to content

Commit

Permalink
Removed software servo driver, fixed hw servo driver to work with all…
Browse files Browse the repository at this point in the history
… hardwares
  • Loading branch information
vedderb committed Feb 28, 2018
1 parent 264946d commit bf27cb6
Show file tree
Hide file tree
Showing 54 changed files with 69 additions and 1,048 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
=== FW 3.35 ===
* Added option to disable nRF transmission (option in Transmit Power parameter).
* Fixed servo output driver for all hardwares and removed software servo driver.

=== FW 3.34 ===
* Added motor PID position to COMM_GET_VALUES.
* Inverted direction angle normalization in mc_interface.
Expand Down
1 change: 0 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,6 @@ CSRC = $(STARTUPSRC) \
mcpwm.c \
servo_dec.c \
utils.c \
servo.c \
servo_simple.c \
packet.c \
terminal.c \
Expand Down
Binary file modified build_all/410_o_411_o_412/VESC_0005ohm.bin
Binary file not shown.
Binary file modified build_all/410_o_411_o_412/VESC_default.bin
Binary file not shown.
Binary file modified build_all/410_o_411_o_412/VESC_default_no_hw_limits.bin
Binary file not shown.
Binary file modified build_all/410_o_411_o_412/VESC_ws2811.bin
Binary file not shown.
Binary file modified build_all/46_o_47/VESC_0005ohm.bin
Binary file not shown.
Binary file modified build_all/46_o_47/VESC_33k.bin
Binary file not shown.
Binary file modified build_all/46_o_47/VESC_default.bin
Binary file not shown.
Binary file modified build_all/46_o_47/VESC_ws2811.bin
Binary file not shown.
Binary file modified build_all/46_o_47/VESC_ws2811_33k.bin
Binary file not shown.
Binary file modified build_all/48/VESC_0005ohm.bin
Binary file not shown.
Binary file modified build_all/48/VESC_default.bin
Binary file not shown.
Binary file modified build_all/48/VESC_ws2811.bin
Binary file not shown.
Binary file modified build_all/60/VESC_default.bin
Binary file not shown.
Binary file modified build_all/60/VESC_default_no_hw_limits.bin
Binary file not shown.
Binary file modified build_all/60/VESC_servoout.bin
Binary file not shown.
Binary file modified build_all/60/VESC_ws2811.bin
Binary file not shown.
Binary file modified build_all/DAS_RS/VESC_default.bin
Binary file not shown.
5 changes: 0 additions & 5 deletions commands.c
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@
#include "hal.h"
#include "mc_interface.h"
#include "stm32f4xx_conf.h"
#include "servo.h"
#include "servo_simple.h"
#include "buffer.h"
#include "terminal.h"
Expand Down Expand Up @@ -241,11 +240,7 @@ void commands_process_packet(unsigned char *data, unsigned int len) {
case COMM_SET_SERVO_POS:
#if SERVO_OUT_ENABLE
ind = 0;
#if SERVO_OUT_SIMPLE
servo_simple_set_output(buffer_get_float16(data, 1000.0, &ind));
#else
servos[0].pos = (int16_t)(buffer_get_float16(data, 1000.0, &ind) * 255.0);
#endif
#endif
break;

Expand Down
1 change: 0 additions & 1 deletion conf_general.h
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,6 @@
#ifndef SERVO_OUT_ENABLE
#define SERVO_OUT_ENABLE 0 // Enable servo output
#endif
#define SERVO_OUT_SIMPLE 1 // Use simple HW-based driver (recommended)
#define SERVO_OUT_PULSE_MIN_US 1000 // Minimum pulse length in microseconds
#define SERVO_OUT_PULSE_MAX_US 2000 // Maximum pulse length in microseconds
#define SERVO_OUT_RATE_HZ 50 // Update rate in Hz
Expand Down
1 change: 0 additions & 1 deletion hwconf/hw.h
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,6 @@
// Functions
void hw_init_gpio(void);
void hw_setup_adc_channels(void);
void hw_setup_servo_outputs(void);
void hw_start_i2c(void);
void hw_stop_i2c(void);
void hw_try_restore_i2c(void);
Expand Down
17 changes: 0 additions & 17 deletions hwconf/hw_40.c
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@
#include "ch.h"
#include "hal.h"
#include "stm32f4xx_conf.h"
#include "servo.h"

// Variables
static volatile bool i2c_running = false;
Expand Down Expand Up @@ -139,22 +138,6 @@ void hw_setup_adc_channels(void) {
ADC_InjectedChannelConfig(ADC2, ADC_Channel_6, 2, ADC_SampleTime_15Cycles);
}

void hw_setup_servo_outputs(void) {
// Set up GPIO ports
RCC_AHB1PeriphClockCmd(RCC_AHB1Periph_GPIOB, ENABLE);

// Set up servo structures
servos[0].gpio = GPIOB;
servos[0].pin = 5;
servos[0].offset = 0;
servos[0].pos = 128;

servos[1].gpio = GPIOB;
servos[1].pin = 4;
servos[1].offset = 0;
servos[1].pos = 0;
}

void hw_start_i2c(void) {
i2cAcquireBus(&HW_I2C_DEV);

Expand Down
4 changes: 3 additions & 1 deletion hwconf/hw_40.h
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@
// NTC Termistors
#define NTC_RES(adc_val) (0.0)
#define NTC_TEMP(adc_ind) (32.0)
#define NTC_TEMP_MOTOR() (0.0)
#define NTC_TEMP_MOTOR(beta) (0.0)

// Double samples in beginning and end for positive current measurement.
// Useful when the shunt sense traces have noise that causes offset.
Expand All @@ -121,6 +121,8 @@
#define HW_UART_RX_PIN 7

// ICU Peripheral for servo decoding
#define HW_ICU_TIMER TIM3
#define HW_ICU_TIM_CLK_EN() RCC_APB1PeriphClockCmd(RCC_APB1Periph_TIM3, ENABLE)
#define HW_ICU_DEV ICUD3
#define HW_ICU_CHANNEL ICU_CHANNEL_2
#define HW_ICU_GPIO_AF GPIO_AF_TIM3
Expand Down
17 changes: 0 additions & 17 deletions hwconf/hw_410.c
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@
#include "ch.h"
#include "hal.h"
#include "stm32f4xx_conf.h"
#include "servo.h"

// Variables
static volatile bool i2c_running = false;
Expand Down Expand Up @@ -131,22 +130,6 @@ void hw_setup_adc_channels(void) {
ADC_InjectedChannelConfig(ADC2, ADC_Channel_9, 2, ADC_SampleTime_15Cycles);
}

void hw_setup_servo_outputs(void) {
// Set up GPIO ports
RCC_AHB1PeriphClockCmd(RCC_AHB1Periph_GPIOB, ENABLE);

// Set up servo structures
servos[0].gpio = GPIOB;
servos[0].pin = 5;
servos[0].offset = 0;
servos[0].pos = 128;

servos[1].gpio = GPIOB;
servos[1].pin = 4;
servos[1].offset = 0;
servos[1].pos = 0;
}

void hw_start_i2c(void) {
i2cAcquireBus(&HW_I2C_DEV);

Expand Down
2 changes: 2 additions & 0 deletions hwconf/hw_410.h
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,8 @@
#define HW_UART_RX_PIN 7

// ICU Peripheral for servo decoding
#define HW_ICU_TIMER TIM3
#define HW_ICU_TIM_CLK_EN() RCC_APB1PeriphClockCmd(RCC_APB1Periph_TIM3, ENABLE)
#define HW_ICU_DEV ICUD3
#define HW_ICU_CHANNEL ICU_CHANNEL_2
#define HW_ICU_GPIO_AF GPIO_AF_TIM3
Expand Down
17 changes: 0 additions & 17 deletions hwconf/hw_45.c
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@
#include "ch.h"
#include "hal.h"
#include "stm32f4xx_conf.h"
#include "servo.h"
#include "commands.h"

// Threads
Expand Down Expand Up @@ -148,22 +147,6 @@ void hw_setup_adc_channels(void) {
chThdCreateStatic(temp_thread_wa, sizeof(temp_thread_wa), NORMALPRIO, temp_thread, NULL);
}

void hw_setup_servo_outputs(void) {
// Set up GPIO ports
RCC_AHB1PeriphClockCmd(RCC_AHB1Periph_GPIOB, ENABLE);

// Set up servo structures
servos[0].gpio = GPIOB;
servos[0].pin = 5;
servos[0].offset = 0;
servos[0].pos = 128;

servos[1].gpio = GPIOB;
servos[1].pin = 4;
servos[1].offset = 0;
servos[1].pos = 0;
}

void hw_start_i2c(void) {
i2cAcquireBus(&HW_I2C_DEV);

Expand Down
2 changes: 2 additions & 0 deletions hwconf/hw_45.h
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,8 @@
#define HW_UART_RX_PIN 7

// ICU Peripheral for servo decoding
#define HW_ICU_TIMER TIM3
#define HW_ICU_TIM_CLK_EN() RCC_APB1PeriphClockCmd(RCC_APB1Periph_TIM3, ENABLE)
#define HW_ICU_DEV ICUD3
#define HW_ICU_CHANNEL ICU_CHANNEL_2
#define HW_ICU_GPIO_AF GPIO_AF_TIM3
Expand Down
17 changes: 0 additions & 17 deletions hwconf/hw_46.c
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@
#include "ch.h"
#include "hal.h"
#include "stm32f4xx_conf.h"
#include "servo.h"

// Variables
static volatile bool i2c_running = false;
Expand Down Expand Up @@ -139,22 +138,6 @@ void hw_setup_adc_channels(void) {
ADC_InjectedChannelConfig(ADC2, ADC_Channel_6, 2, ADC_SampleTime_15Cycles);
}

void hw_setup_servo_outputs(void) {
// Set up GPIO ports
RCC_AHB1PeriphClockCmd(RCC_AHB1Periph_GPIOB, ENABLE);

// Set up servo structures
servos[0].gpio = GPIOB;
servos[0].pin = 5;
servos[0].offset = 0;
servos[0].pos = 128;

servos[1].gpio = GPIOB;
servos[1].pin = 4;
servos[1].offset = 0;
servos[1].pos = 0;
}

void hw_start_i2c(void) {
i2cAcquireBus(&HW_I2C_DEV);

Expand Down
2 changes: 2 additions & 0 deletions hwconf/hw_46.h
Original file line number Diff line number Diff line change
Expand Up @@ -125,6 +125,8 @@
#define HW_UART_RX_PIN 7

// ICU Peripheral for servo decoding
#define HW_ICU_TIMER TIM3
#define HW_ICU_TIM_CLK_EN() RCC_APB1PeriphClockCmd(RCC_APB1Periph_TIM3, ENABLE)
#define HW_ICU_DEV ICUD3
#define HW_ICU_CHANNEL ICU_CHANNEL_2
#define HW_ICU_GPIO_AF GPIO_AF_TIM3
Expand Down
17 changes: 0 additions & 17 deletions hwconf/hw_48.c
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@

#include "ch.h"
#include "hal.h"
#include "servo.h"

// Variables
static volatile bool i2c_running = false;
Expand Down Expand Up @@ -131,22 +130,6 @@ void hw_setup_adc_channels(void) {
ADC_InjectedChannelConfig(ADC2, ADC_Channel_6, 2, ADC_SampleTime_15Cycles);
}

void hw_setup_servo_outputs(void) {
// Set up GPIO ports
RCC_AHB1PeriphClockCmd(RCC_AHB1Periph_GPIOB, ENABLE);

// Set up servo structures
servos[0].gpio = GPIOB;
servos[0].pin = 5;
servos[0].offset = 0;
servos[0].pos = 128;

servos[1].gpio = GPIOB;
servos[1].pin = 4;
servos[1].offset = 0;
servos[1].pos = 0;
}

void hw_start_i2c(void) {
i2cAcquireBus(&HW_I2C_DEV);

Expand Down
2 changes: 2 additions & 0 deletions hwconf/hw_48.h
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,8 @@
#define HW_UART_RX_PIN 7

// ICU Peripheral for servo decoding
#define HW_ICU_TIMER TIM3
#define HW_ICU_TIM_CLK_EN() RCC_APB1PeriphClockCmd(RCC_APB1Periph_TIM3, ENABLE)
#define HW_ICU_DEV ICUD3
#define HW_ICU_CHANNEL ICU_CHANNEL_2
#define HW_ICU_GPIO_AF GPIO_AF_TIM3
Expand Down
17 changes: 0 additions & 17 deletions hwconf/hw_49.c
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@
#include "ch.h"
#include "hal.h"
#include "stm32f4xx_conf.h"
#include "servo.h"

// Variables
static volatile bool i2c_running = false;
Expand Down Expand Up @@ -132,22 +131,6 @@ void hw_setup_adc_channels(void) {
ADC_InjectedChannelConfig(ADC2, ADC_Channel_9, 2, ADC_SampleTime_15Cycles);
}

void hw_setup_servo_outputs(void) {
// Set up GPIO ports
RCC_AHB1PeriphClockCmd(RCC_AHB1Periph_GPIOB, ENABLE);

// Set up servo structures
servos[0].gpio = GPIOB;
servos[0].pin = 5;
servos[0].offset = 0;
servos[0].pos = 128;

servos[1].gpio = GPIOB;
servos[1].pin = 4;
servos[1].offset = 0;
servos[1].pos = 0;
}

void hw_start_i2c(void) {
i2cAcquireBus(&HW_I2C_DEV);

Expand Down
2 changes: 2 additions & 0 deletions hwconf/hw_49.h
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,8 @@
#define HW_UART_RX_PIN 7

// ICU Peripheral for servo decoding
#define HW_ICU_TIMER TIM3
#define HW_ICU_TIM_CLK_EN() RCC_APB1PeriphClockCmd(RCC_APB1Periph_TIM3, ENABLE)
#define HW_ICU_DEV ICUD3
#define HW_ICU_CHANNEL ICU_CHANNEL_2
#define HW_ICU_GPIO_AF GPIO_AF_TIM3
Expand Down
17 changes: 0 additions & 17 deletions hwconf/hw_60.c
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@
#include "ch.h"
#include "hal.h"
#include "stm32f4xx_conf.h"
#include "servo.h"
#include "utils.h"
#include "drv8301.h"

Expand Down Expand Up @@ -144,22 +143,6 @@ void hw_setup_adc_channels(void) {
ADC_InjectedChannelConfig(ADC3, ADC_Channel_12, 3, ADC_SampleTime_15Cycles);
}

void hw_setup_servo_outputs(void) {
// Set up GPIO ports
RCC_AHB1PeriphClockCmd(RCC_AHB1Periph_GPIOB, ENABLE);
RCC_AHB1PeriphClockCmd(RCC_AHB1Periph_GPIOD, ENABLE);

servos[0].gpio = GPIOB;
servos[0].pin = 5;
servos[0].offset = 0;
servos[0].pos = 128;

servos[1].gpio = GPIOD;
servos[1].pin = 2;
servos[1].offset = 0;
servos[1].pos = 0;
}

void hw_start_i2c(void) {
i2cAcquireBus(&HW_I2C_DEV);

Expand Down
2 changes: 2 additions & 0 deletions hwconf/hw_60.h
Original file line number Diff line number Diff line change
Expand Up @@ -139,6 +139,8 @@
#define HW_UART_RX_PIN 11

// ICU Peripheral for servo decoding
#define HW_ICU_TIMER TIM4
#define HW_ICU_TIM_CLK_EN() RCC_APB1PeriphClockCmd(RCC_APB1Periph_TIM4, ENABLE)
#define HW_ICU_DEV ICUD4
#define HW_ICU_CHANNEL ICU_CHANNEL_1
#define HW_ICU_GPIO_AF GPIO_AF_TIM4
Expand Down
17 changes: 0 additions & 17 deletions hwconf/hw_das_rs.c
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@
#include "ch.h"
#include "hal.h"
#include "stm32f4xx_conf.h"
#include "servo.h"
#include "utils.h"

// Variables
Expand Down Expand Up @@ -125,22 +124,6 @@ void hw_setup_adc_channels(void) {
ADC_InjectedChannelConfig(ADC3, ADC_Channel_12, 3, ADC_SampleTime_15Cycles);
}

void hw_setup_servo_outputs(void) {
// Set up GPIO ports
RCC_AHB1PeriphClockCmd(RCC_AHB1Periph_GPIOB, ENABLE);
RCC_AHB1PeriphClockCmd(RCC_AHB1Periph_GPIOD, ENABLE);

servos[0].gpio = GPIOB;
servos[0].pin = 5;
servos[0].offset = 0;
servos[0].pos = 128;

servos[1].gpio = GPIOD;
servos[1].pin = 2;
servos[1].offset = 0;
servos[1].pos = 0;
}

void hw_start_i2c(void) {
i2cAcquireBus(&HW_I2C_DEV);

Expand Down
2 changes: 2 additions & 0 deletions hwconf/hw_das_rs.h
Original file line number Diff line number Diff line change
Expand Up @@ -151,6 +151,8 @@
#define HW_UART_RX_PIN 11

// ICU Peripheral for servo decoding
#define HW_ICU_TIMER TIM4
#define HW_ICU_TIM_CLK_EN() RCC_APB1PeriphClockCmd(RCC_APB1Periph_TIM4, ENABLE)
#define HW_ICU_DEV ICUD4
#define HW_ICU_CHANNEL ICU_CHANNEL_1
#define HW_ICU_GPIO_AF GPIO_AF_TIM4
Expand Down
Loading

0 comments on commit bf27cb6

Please sign in to comment.