Skip to content

Commit

Permalink
Merge branch 'devel'
Browse files Browse the repository at this point in the history
  • Loading branch information
madcowswe committed Aug 5, 2018
2 parents f772860 + b37df26 commit 596b6ab
Show file tree
Hide file tree
Showing 37 changed files with 935 additions and 200 deletions.
29 changes: 16 additions & 13 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,15 @@
Please add a note of your changes below this heading if you make a Pull Request.

# Releases
## [0.4.2] - 2018-07-04
### Added
* Hall sensor feedback
* Configurable RC PWM input
* Ability to read axis FET temperature
* Config settings for:
* `motor.config.requested_current_range`
* `motor.config.current_control_bandwidth` and `motor.set_current_control_bandwidth`. Latter required to invoke gain recalculation.
* `encoder.config.bandwidth`

## [0.4.1] - 2018-07-01
### Fixed
Expand All @@ -12,13 +21,13 @@ Please add a note of your changes below this heading if you make a Pull Request.

## [0.4.0] - 2018-06-10
### Added
* Encoder can now go forever in velocity/torque mode due to using circular encoder space.
* Protocol supports function return values
* bake Git-derived firmware version into firmware binary. The firmware version is exposed through the `fw_version_[...]` properties.
* `make write_otp` command to burn the board version onto the ODrive's one-time programmable memory. If you have an ODrive v3.4 or older, you should run this once for a better firmware update user experience in the future. Run the command without any options for more details. Once set, the board version is exposed through the `hw_version_[...]` properties.
* infrastructure to publish the python tools to PyPi. See `tools/setup.py` for details.
* Automated test script `run_tests.py`
* System stats (e.g. stack usage) are exposed under `<odrv>.system_stats`
* Encoder can now go forever in velocity/torque mode due to using circular encoder space.
* Protocol supports function return values
* bake Git-derived firmware version into firmware binary. The firmware version is exposed through the `fw_version_[...]` properties.
* `make write_otp` command to burn the board version onto the ODrive's one-time programmable memory. If you have an ODrive v3.4 or older, you should run this once for a better firmware update user experience in the future. Run the command without any options for more details. Once set, the board version is exposed through the `hw_version_[...]` properties.
* infrastructure to publish the python tools to PyPi. See `tools/setup.py` for details.
* Automated test script `run_tests.py`
* System stats (e.g. stack usage) are exposed under `<odrv>.system_stats`

### Changed
* DFU script updates
Expand All @@ -45,7 +54,6 @@ Please add a note of your changes below this heading if you make a Pull Request.
* USB issue where the device would stop responding when the host script would quit abruptly or reset the device during operation

## [0.3.6] - 2018-03-26

### Added
* **Storing of configuration parameters to Non Volatile Memory**
* **USB Bootloader**
Expand All @@ -68,7 +76,6 @@ Please add a note of your changes below this heading if you make a Pull Request.
* malloc now fails if we run out of memory (before it would always succeed even if we are out of ram...)

## [0.3.5] - 2018-03-04

### Added
* Reporting error if your encoder CPR is incorrect
* Ability to start anticogging calibration over USB protocol
Expand All @@ -82,12 +89,10 @@ Please add a note of your changes below this heading if you make a Pull Request.
* Build system is now tup instead of make. Please check the [Readme](README.md#installing-prerequisites) for installation instructions.

## [0.3.4] - 2018-02-13

### Fixed
* Broken way to check for python 2. Python 2 not supported yet.

## [0.3.3] - 2018-02-12

### Added
* Liveplotter script
* Automatic recovery of USB halt/stall condition
Expand All @@ -99,14 +104,12 @@ Please add a note of your changes below this heading if you make a Pull Request.
* USB CSC (USB serial) now reports a sensible baud rate

## [0.3.2] - 2018-02-02

### Added
* Gimbal motor mode
* Encoder index pulse support
* `resistance_calib_max_voltage` parameter

## [0.3.1] - 2018-01-18

### Added
* UUID Endpoint
* Reporting of correct ODrive version on USB descriptor
Expand Down
6 changes: 6 additions & 0 deletions Firmware/Board/v3/Inc/gpio.h
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,12 @@ void GPIO_set_to_analog(GPIO_TypeDef* GPIO_port, uint16_t GPIO_pin);
uint16_t get_gpio_pin_by_pin(uint16_t GPIO_pin);
GPIO_TypeDef* get_gpio_port_by_pin(uint16_t GPIO_pin);

#if HW_VERSION_MAJOR == 3 && HW_VERSION_MINOR <= 4
#define GPIO_COUNT 5
#else
#define GPIO_COUNT 8
#endif

/* USER CODE END Prototypes */

#ifdef __cplusplus
Expand Down
1 change: 1 addition & 0 deletions Firmware/Board/v3/Inc/stm32f4xx_it.h
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@ void CAN1_RX0_IRQHandler(void);
void CAN1_RX1_IRQHandler(void);
void CAN1_SCE_IRQHandler(void);
void TIM8_TRG_COM_TIM14_IRQHandler(void);
void TIM5_IRQHandler(void);
void UART4_IRQHandler(void);
void OTG_FS_IRQHandler(void);

Expand Down
2 changes: 2 additions & 0 deletions Firmware/Board/v3/Inc/tim.h
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,7 @@ extern TIM_HandleTypeDef htim1;
extern TIM_HandleTypeDef htim2;
extern TIM_HandleTypeDef htim3;
extern TIM_HandleTypeDef htim4;
extern TIM_HandleTypeDef htim5;
extern TIM_HandleTypeDef htim8;

/* USER CODE BEGIN Private defines */
Expand All @@ -77,6 +78,7 @@ void MX_TIM1_Init(void);
void MX_TIM2_Init(void);
void MX_TIM3_Init(void);
void MX_TIM4_Init(void);
void MX_TIM5_Init(void);
void MX_TIM8_Init(void);

void HAL_TIM_MspPostInit(TIM_HandleTypeDef *htim);
Expand Down
33 changes: 23 additions & 10 deletions Firmware/Board/v3/Odrive.ioc
Original file line number Diff line number Diff line change
Expand Up @@ -133,10 +133,11 @@ Mcu.IP10=TIM1
Mcu.IP11=TIM2
Mcu.IP12=TIM3
Mcu.IP13=TIM4
Mcu.IP14=TIM8
Mcu.IP15=UART4
Mcu.IP16=USB_DEVICE
Mcu.IP17=USB_OTG_FS
Mcu.IP14=TIM5
Mcu.IP15=TIM8
Mcu.IP16=UART4
Mcu.IP17=USB_DEVICE
Mcu.IP18=USB_OTG_FS
Mcu.IP2=ADC3
Mcu.IP3=CAN1
Mcu.IP4=DMA
Expand All @@ -145,7 +146,7 @@ Mcu.IP6=NVIC
Mcu.IP7=RCC
Mcu.IP8=SPI3
Mcu.IP9=SYS
Mcu.IPNb=18
Mcu.IPNb=19
Mcu.Name=STM32F405RGTx
Mcu.Package=LQFP64
Mcu.Pin0=PC13-ANTI_TAMP
Expand Down Expand Up @@ -229,6 +230,7 @@ NVIC.PriorityGroup=NVIC_PRIORITYGROUP_4
NVIC.SVCall_IRQn=true\:0\:0\:false\:false\:false\:false\:true
NVIC.SysTick_IRQn=true\:15\:0\:false\:false\:true\:true\:true
NVIC.TIM1_UP_TIM10_IRQn=true\:0\:0\:false\:false\:false\:false\:true
NVIC.TIM5_IRQn=true\:5\:0\:false\:false\:true\:true\:true
NVIC.TIM8_TRG_COM_TIM14_IRQn=true\:0\:0\:false\:false\:true\:false\:false
NVIC.TIM8_UP_TIM13_IRQn=true\:0\:0\:false\:false\:false\:false\:true
NVIC.TimeBase=TIM8_TRG_COM_TIM14_IRQn
Expand Down Expand Up @@ -266,12 +268,11 @@ PA15.Signal=GPIO_Input
PA2.GPIOParameters=GPIO_Label
PA2.GPIO_Label=GPIO_3
PA2.Locked=true
PA2.Signal=GPIO_Input
PA3.GPIOParameters=GPIO_PuPd,GPIO_Label
PA2.Signal=S_TIM5_CH3
PA3.GPIOParameters=GPIO_Label
PA3.GPIO_Label=GPIO_4
PA3.GPIO_PuPd=GPIO_NOPULL
PA3.Locked=true
PA3.Signal=GPIO_Input
PA3.Signal=S_TIM5_CH4
PA4.GPIOParameters=GPIO_Label
PA4.GPIO_Label=M1_TEMP
PA4.Locked=true
Expand Down Expand Up @@ -457,7 +458,7 @@ ProjectManager.StackSize=0x800
ProjectManager.TargetToolchain=Makefile
ProjectManager.ToolChainLocation=
ProjectManager.UnderRoot=false
ProjectManager.functionlistsort=1-MX_GPIO_Init-GPIO-false-HAL-true,2-MX_DMA_Init-DMA-false-HAL-true,3-MX_ADC1_Init-ADC1-false-HAL-true,4-MX_ADC2_Init-ADC2-false-HAL-true,5-MX_TIM1_Init-TIM1-false-HAL-true,6-MX_TIM8_Init-TIM8-false-HAL-true,7-MX_TIM3_Init-TIM3-false-HAL-true,8-MX_TIM4_Init-TIM4-false-HAL-true,9-MX_SPI3_Init-SPI3-false-HAL-true,10-MX_ADC3_Init-ADC3-false-HAL-true,11-SystemClock_Config-RCC-false-HAL-true,12-MX_TIM2_Init-TIM2-false-HAL-true,13-MX_USB_DEVICE_Init-USB_DEVICE-false-HAL-true,14-MX_UART4_Init-UART4-false-HAL-true,15-MX_CAN1_Init-CAN1-false-HAL-true
ProjectManager.functionlistsort=1-MX_GPIO_Init-GPIO-false-HAL-true,2-MX_DMA_Init-DMA-false-HAL-true,3-MX_ADC1_Init-ADC1-false-HAL-true,4-MX_ADC2_Init-ADC2-false-HAL-true,5-MX_CAN1_Init-CAN1-false-HAL-true,6-MX_TIM1_Init-TIM1-false-HAL-true,7-MX_TIM8_Init-TIM8-false-HAL-true,8-MX_TIM3_Init-TIM3-false-HAL-true,9-MX_TIM4_Init-TIM4-false-HAL-true,10-MX_SPI3_Init-SPI3-false-HAL-true,11-MX_ADC3_Init-ADC3-false-HAL-true,12-SystemClock_Config-RCC-false-HAL-true,13-MX_TIM2_Init-TIM2-false-HAL-true,14-MX_USB_DEVICE_Init-USB_DEVICE-false-HAL-true,15-MX_UART4_Init-UART4-false-HAL-true,16-MX_TIM5_Init-TIM5-false-HAL-true
RCC.48MHZClocksFreq_Value=48000000
RCC.AHBFreq_Value=168000000
RCC.APB1CLKDivider=RCC_HCLK_DIV4
Expand Down Expand Up @@ -538,6 +539,10 @@ SH.S_TIM4_CH1.0=TIM4_CH1,Encoder_Interface
SH.S_TIM4_CH1.ConfNb=1
SH.S_TIM4_CH2.0=TIM4_CH2,Encoder_Interface
SH.S_TIM4_CH2.ConfNb=1
SH.S_TIM5_CH3.0=TIM5_CH3,Input_Capture3_from_TI3
SH.S_TIM5_CH3.ConfNb=1
SH.S_TIM5_CH4.0=TIM5_CH4,Input_Capture4_from_TI4
SH.S_TIM5_CH4.ConfNb=1
SH.S_TIM8_CH1.0=TIM8_CH1,PWM Generation1 CH1 CH1N
SH.S_TIM8_CH1.ConfNb=1
SH.S_TIM8_CH2.0=TIM8_CH2,PWM Generation2 CH2 CH2N
Expand Down Expand Up @@ -605,6 +610,14 @@ TIM4.IC2Filter=4
TIM4.IC2Polarity=TIM_ICPOLARITY_RISING
TIM4.IPParameters=EncoderMode,IC1Polarity,IC2Polarity,IC1Filter,IC2Filter,Period
TIM4.Period=0xffff
TIM5.Channel-Input_Capture3_from_TI3=TIM_CHANNEL_3
TIM5.Channel-Input_Capture4_from_TI4=TIM_CHANNEL_4
TIM5.ICFilter_CH3=15
TIM5.ICFilter_CH4=15
TIM5.ICPolarity_CH3=TIM_INPUTCHANNELPOLARITY_BOTHEDGE
TIM5.ICPolarity_CH4=TIM_INPUTCHANNELPOLARITY_BOTHEDGE
TIM5.IPParameters=Channel-Input_Capture3_from_TI3,Channel-Input_Capture4_from_TI4,ICFilter_CH3,ICFilter_CH4,ICPolarity_CH3,ICPolarity_CH4,Period
TIM5.Period=0xFFFFFFFF
TIM8.Channel-Output\ Compare4\ No\ Output=TIM_CHANNEL_4
TIM8.Channel-PWM\ Generation1\ CH1\ CH1N=TIM_CHANNEL_1
TIM8.Channel-PWM\ Generation2\ CH2\ CH2N=TIM_CHANNEL_2
Expand Down
12 changes: 6 additions & 6 deletions Firmware/Board/v3/Src/gpio.c
Original file line number Diff line number Diff line change
Expand Up @@ -106,12 +106,6 @@ void MX_GPIO_Init(void)
GPIO_InitStruct.Pull = GPIO_NOPULL;
HAL_GPIO_Init(GPIOC, &GPIO_InitStruct);

/*Configure GPIO pins : PAPin PAPin PAPin */
GPIO_InitStruct.Pin = GPIO_3_Pin|GPIO_4_Pin|GPIO_7_Pin;
GPIO_InitStruct.Mode = GPIO_MODE_INPUT;
GPIO_InitStruct.Pull = GPIO_NOPULL;
HAL_GPIO_Init(GPIOA, &GPIO_InitStruct);

/*Configure GPIO pins : PBPin PBPin */
GPIO_InitStruct.Pin = GPIO_6_Pin|GPIO_8_Pin;
GPIO_InitStruct.Mode = GPIO_MODE_INPUT;
Expand All @@ -125,6 +119,12 @@ void MX_GPIO_Init(void)
GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_LOW;
HAL_GPIO_Init(EN_GATE_GPIO_Port, &GPIO_InitStruct);

/*Configure GPIO pin : PtPin */
GPIO_InitStruct.Pin = GPIO_7_Pin;
GPIO_InitStruct.Mode = GPIO_MODE_INPUT;
GPIO_InitStruct.Pull = GPIO_NOPULL;
HAL_GPIO_Init(GPIO_7_GPIO_Port, &GPIO_InitStruct);

/*Configure GPIO pin : PtPin */
GPIO_InitStruct.Pin = nFAULT_Pin;
GPIO_InitStruct.Mode = GPIO_MODE_INPUT;
Expand Down
4 changes: 3 additions & 1 deletion Firmware/Board/v3/Src/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -188,6 +188,7 @@ int main(void)
MX_ADC3_Init();
MX_TIM2_Init();
MX_UART4_Init();
MX_TIM5_Init();
/* USER CODE BEGIN 2 */

//Required to use OC4 for ADC triggering.
Expand Down Expand Up @@ -235,8 +236,9 @@ void SystemClock_Config(void)

/**Initializes the CPU, AHB and APB busses clocks
*/
RCC_OscInitStruct.OscillatorType = RCC_OSCILLATORTYPE_HSE;
RCC_OscInitStruct.OscillatorType = RCC_OSCILLATORTYPE_LSI|RCC_OSCILLATORTYPE_HSE;
RCC_OscInitStruct.HSEState = RCC_HSE_ON;
RCC_OscInitStruct.LSIState = RCC_LSI_ON;
RCC_OscInitStruct.PLL.PLLState = RCC_PLL_ON;
RCC_OscInitStruct.PLL.PLLSource = RCC_PLLSOURCE_HSE;
RCC_OscInitStruct.PLL.PLLM = 4;
Expand Down
41 changes: 41 additions & 0 deletions Firmware/Board/v3/Src/stm32f4xx_it.c
Original file line number Diff line number Diff line change
Expand Up @@ -43,10 +43,14 @@
typedef void (*ADC_handler_t)(ADC_HandleTypeDef* hadc, bool injected);
void ADC_IRQ_Dispatch(ADC_HandleTypeDef* hadc, ADC_handler_t callback);

typedef void (*TIM_capture_callback_t)(int channel, uint32_t timestamp);
void decode_tim_capture(TIM_HandleTypeDef *htim, TIM_capture_callback_t callback);

// TODO: move somewhere else
void pwm_trig_adc_cb(ADC_HandleTypeDef* hadc, bool injected);
void vbus_sense_adc_cb(ADC_HandleTypeDef* hadc, bool injected);
void tim_update_cb(TIM_HandleTypeDef* htim);
void pwm_in_cb(int channel, uint32_t timestamp);

extern TIM_HandleTypeDef htim1;
extern I2C_HandleTypeDef hi2c1;
Expand All @@ -59,6 +63,7 @@ extern ADC_HandleTypeDef hadc1;
extern ADC_HandleTypeDef hadc2;
extern ADC_HandleTypeDef hadc3;
extern CAN_HandleTypeDef hcan1;
extern TIM_HandleTypeDef htim5;
extern TIM_HandleTypeDef htim8;
extern DMA_HandleTypeDef hdma_uart4_rx;
extern DMA_HandleTypeDef hdma_uart4_tx;
Expand Down Expand Up @@ -314,6 +319,23 @@ void TIM8_TRG_COM_TIM14_IRQHandler(void)
/* USER CODE END TIM8_TRG_COM_TIM14_IRQn 1 */
}

/**
* @brief This function handles TIM5 global interrupt.
*/
void TIM5_IRQHandler(void)
{
/* USER CODE BEGIN TIM5_IRQn 0 */

// We know we only use capture mode here, so bypass HAL
decode_tim_capture(&htim5, &pwm_in_cb);

/* USER CODE END TIM5_IRQn 0 */
HAL_TIM_IRQHandler(&htim5);
/* USER CODE BEGIN TIM5_IRQn 1 */

/* USER CODE END TIM5_IRQn 1 */
}

/**
* @brief This function handles UART4 global interrupt.
*/
Expand Down Expand Up @@ -369,6 +391,25 @@ void ADC_IRQ_Dispatch(ADC_HandleTypeDef* hadc, ADC_handler_t callback) {
}
}

void decode_tim_capture(TIM_HandleTypeDef *htim, TIM_capture_callback_t callback) {
if(__HAL_TIM_GET_FLAG(htim, TIM_FLAG_CC1)) {
__HAL_TIM_CLEAR_IT(htim, TIM_IT_CC1);
callback(1, htim->Instance->CCR1);
}
if(__HAL_TIM_GET_FLAG(htim, TIM_FLAG_CC2)) {
__HAL_TIM_CLEAR_IT(htim, TIM_IT_CC2);
callback(2, htim->Instance->CCR2);
}
if(__HAL_TIM_GET_FLAG(htim, TIM_FLAG_CC3)) {
__HAL_TIM_CLEAR_IT(htim, TIM_IT_CC3);
callback(3, htim->Instance->CCR3);
}
if(__HAL_TIM_GET_FLAG(htim, TIM_FLAG_CC4)) {
__HAL_TIM_CLEAR_IT(htim, TIM_IT_CC4);
callback(4, htim->Instance->CCR4);
}
}

/**
* @brief This function handles TIM1 update interrupt and TIM10 global interrupt.
*/
Expand Down
Loading

0 comments on commit 596b6ab

Please sign in to comment.