mirror of
https://github.com/odriverobotics/ODrive.git
synced 2026-09-20 22:49:22 +08:00
ADC trig dir set by adc trig edge, CC irq dir set by Center aligned mode 1,2,3
This commit is contained in:
+13
-2
@@ -2,6 +2,7 @@
|
||||
#include "test.h"
|
||||
|
||||
#include "cmsis_os.h"
|
||||
#include "stm32f405xx.h"
|
||||
#include "stm32f4xx.h"
|
||||
#include "stm32f4xx_hal_adc.h"
|
||||
#include "stm32f4xx_hal_adc_ex.h"
|
||||
@@ -12,11 +13,15 @@
|
||||
|
||||
static void test_read_ADC(void);
|
||||
|
||||
static int test_base = 0;
|
||||
static int test = 0;
|
||||
static int test2 = 0;
|
||||
|
||||
void test_main(void) {
|
||||
|
||||
//Set trigger to mid phase to check for trigger polarity
|
||||
htim1.Instance->CCR4 = 2048;
|
||||
|
||||
HAL_TIM_PWM_Start_IT(&htim1, TIM_CHANNEL_4);
|
||||
__HAL_ADC_ENABLE(&hadc2);
|
||||
|
||||
@@ -45,13 +50,19 @@ void HAL_ADCEx_InjectedConvCpltCallback(ADC_HandleTypeDef* hadc) {
|
||||
assert(hadc == &hadc2);
|
||||
|
||||
float unknown_ch_volts = read_ADC_volts(hadc, 1);
|
||||
test++;
|
||||
uint32_t cnt = htim1.Instance->CNT;
|
||||
int dir = htim1.Instance->CR1 & TIM_CR1_DIR;
|
||||
if(dir){
|
||||
test++;
|
||||
} else {
|
||||
test2++;
|
||||
}
|
||||
}
|
||||
|
||||
void HAL_TIM_OC_DelayElapsedCallback(TIM_HandleTypeDef *htim) {
|
||||
|
||||
//We only expect the timing driving channel to trigger an interrupt.
|
||||
assert(htim->Channel == HAL_TIM_ACTIVE_CHANNEL_4);
|
||||
test2++;
|
||||
test_base++;
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user