Update config for CH3 output compare
This commit is contained in:
@@ -8,9 +8,16 @@
|
||||
#include "macros.h"
|
||||
#include "main.h"
|
||||
#include "ring_buffer.h"
|
||||
#include "stm32h747xx.h"
|
||||
#include "stm32h7xx.h"
|
||||
#include "stm32h7xx_hal_tim.h"
|
||||
#include "tasks.h"
|
||||
#include <stdint.h>
|
||||
|
||||
static inline void TIM2_CH3_SetOCMode(uint32_t oc_mode) {
|
||||
MODIFY_REG(TIM2->CCMR2, TIM_CCMR2_OC3M | TIM_CCMR2_OC3M_3, oc_mode);
|
||||
}
|
||||
|
||||
void crankHandler(void *argument) {
|
||||
for (;;) {
|
||||
osThreadFlagsWait(0x01, osFlagsWaitAny, osWaitForever);
|
||||
@@ -18,10 +25,10 @@ void crankHandler(void *argument) {
|
||||
ringBufferRead(&state_g.crank_RB, 0));
|
||||
// FILTER
|
||||
float delta_percentage = ((float)(D1A - D1B)) / D1B;
|
||||
if ( delta_percentage> 0.4||delta_percentage < -0.4) {
|
||||
state_g.sync_state = SYNC_NOT_OK;
|
||||
state_g.crank_state = CYCLE_UNKNOWN;
|
||||
continue;
|
||||
if (delta_percentage > 0.4 || delta_percentage < -0.4) {
|
||||
state_g.sync_state = SYNC_NOT_OK;
|
||||
state_g.crank_state = CYCLE_UNKNOWN;
|
||||
continue;
|
||||
}
|
||||
// INCREMENT SWITCH
|
||||
switch (state_g.crank_state) {
|
||||
@@ -72,6 +79,8 @@ void crankHandler(void *argument) {
|
||||
uint32_t d_spark = d1a * (45 - SPARK_ADVANCE) / 180;
|
||||
uint32_t t_spark = CRANK(0) + d_spark;
|
||||
// TODO: schedule spark
|
||||
// __HAL_TIM_SET_COMPARE(&htim2, TIM_CHANNEL_3, t_spark);
|
||||
// TIM2_CH3_SetOCMode(t_spark);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user