Use SysTick instead of TIM3 for printing

This commit is contained in:
fruchti 2018-08-05 13:04:30 +02:00
parent d47ef99119
commit 8247add832
2 changed files with 40 additions and 48 deletions

View file

@ -1 +1 @@
233
323

View file

@ -24,11 +24,13 @@ static volatile State_t State = {State_Idle};
static void InitStepper(void)
{
RCC->APB2ENR |= RCC_APB2ENR_IOPAEN;
RCC->APB1ENR |= RCC_APB1ENR_TIM3EN;
// PA15 is used for stepper control, so JTAG has to be disabled
AFIO->MAPR |= AFIO_MAPR_SWJ_CFG_1;
GPIOA->BRR = (1 << PIN_STEPPER_AM) | (1 << PIN_STEPPER_AP)
| (1 << PIN_STEPPER_BM) | (1 << PIN_STEPPER_BP);
GPIOA->CRH = (GPIOA->CRH
& ~(0x0f << (4 * PIN_STEPPER_AM - 32))
& ~(0x0f << (4 * PIN_STEPPER_AP - 32))
@ -40,13 +42,8 @@ static void InitStepper(void)
| (0x01 << (4 * PIN_STEPPER_BP - 32)) // Output, max. 10 MHz
;
TIM3->PSC = 48000000 / 100 / LTP1245_MAX_DRIVE_FREQ - 1;
TIM3->ARR = 100;
TIM3->DIER = TIM_DIER_UIE;
TIM3->CR1 = TIM_CR1_CEN;
NVIC_SetPriority(TIM3_IRQn, 1);
NVIC_EnableIRQ(TIM3_IRQn);
// The SysTick is clocked by AHB / 8
SysTick_Config(48000000 / 8 / LTP1245_MAX_DRIVE_FREQ - 1);
}
static void InitSensors(void)
@ -380,9 +377,7 @@ void AdvanceStateMachine(void)
State = State.fn();
}
void TIM3_IRQHandler(void)
{
if(TIM3->SR & TIM_SR_UIF)
void SysTick_Handler(void)
{
static int substep = 0;
static bool off;
@ -425,9 +420,6 @@ void TIM3_IRQHandler(void)
}
AdvanceStateMachine();
TIM3->SR &= ~TIM_SR_UIF;
}
}
void ADC1_2_IRQHandler(void)