|
@@ -124,41 +124,55 @@ static void boardInit(void) {
|
|
//GPIOB->ODR |= (GPIO_PIN_4 | GPIO_PIN_5);
|
|
//GPIOB->ODR |= (GPIO_PIN_4 | GPIO_PIN_5);
|
|
//GPIOB->CR2 |= (GPIO_PIN_4 | GPIO_PIN_5);
|
|
//GPIOB->CR2 |= (GPIO_PIN_4 | GPIO_PIN_5);
|
|
|
|
|
|
- /** Configure ADC */
|
|
|
|
- /* De-Init ADC peripheral*/
|
|
|
|
- ADC1_DeInit();
|
|
|
|
-
|
|
|
|
- /* Init ADC1 peripheral */
|
|
|
|
- ADC1_Init(ADC1_CONVERSIONMODE_SINGLE, ADC_CHNLU, ADC1_PRESSEL_FCPU_D12, \
|
|
|
|
- ADC1_EXTTRIG_TIM, ENABLE, ADC1_ALIGN_RIGHT, ADC_SCHTU, DISABLE);
|
|
|
|
-
|
|
|
|
- /* Enable EOC interrupt */
|
|
|
|
- ADC1_ITConfig(ADC1_IT_EOCIE, ENABLE);
|
|
|
|
-
|
|
|
|
|
|
+ /** Configure ADC1 peripheral */
|
|
|
|
+ /* Configure the data alignment */
|
|
|
|
+ ADC1->CR2 |= (uint8_t)(ADC1_CR2_ALIGN);
|
|
|
|
+ /* Set the single conversion mode */
|
|
|
|
+ ADC1->CR1 &= (uint8_t)(~ADC1_CR1_CONT);
|
|
|
|
+ /* Clear the ADC1 channels */
|
|
|
|
+ ADC1->CSR &= (uint8_t)(~ADC1_CSR_CH);
|
|
|
|
+ /* Select the ADC1 channel */
|
|
|
|
+ ADC1->CSR |= (uint8_t)(ADC_CHNLU);
|
|
|
|
+ /* Clear the SPSEL bits */
|
|
|
|
+ ADC1->CR1 &= (uint8_t)(~ADC1_CR1_SPSEL);
|
|
|
|
+ /* Select the prescaler division factor according to ADC1_PrescalerSelection values */
|
|
|
|
+ ADC1->CR1 |= (uint8_t)(ADC1_PRESSEL_FCPU_D2);
|
|
|
|
+ /* Enable the external Trigger */
|
|
|
|
+ ADC1->CR2 |= (uint8_t)(ADC1_CR2_EXTTRIG);
|
|
|
|
+ /* Set the 'Internal TIM1 TRGO event' as external trigger */
|
|
|
|
+ ADC1->CR2 &= (uint8_t)~(ADC1_CR2_EXTSEL);
|
|
|
|
+ /* disables the ADC1 Schmitt Trigger on a selected channel(s) */
|
|
|
|
+ ADC1->TDRL |= (uint8_t)((uint8_t)0x01 << (uint8_t)ADC_SCHTU);
|
|
|
|
+ /* Enable the ADC1 peripheral */
|
|
|
|
+ ADC1->CR1 |= ADC1_CR1_ADON;
|
|
|
|
+ /* Enable the ADC1 EOC interrupt */
|
|
|
|
+ ADC1->CSR |= (uint8_t)ADC1_IT_EOCIE;
|
|
/*Start Conversion */
|
|
/*Start Conversion */
|
|
- ADC1_StartConversion();
|
|
|
|
-
|
|
|
|
- /** Configure TIM1 */
|
|
|
|
- //TIM1_DeInit();
|
|
|
|
|
|
+ ADC1->CR1 |= ADC1_CR1_ADON;
|
|
|
|
|
|
- /* Time Base configuration */
|
|
|
|
- /*
|
|
|
|
|
|
+ /** Configure TIM1 peripheral. Time Base configuration:
|
|
Timer period - 3,125 ms
|
|
Timer period - 3,125 ms
|
|
TIM1_Period = 50
|
|
TIM1_Period = 50
|
|
TIM1_Prescaler = 1000
|
|
TIM1_Prescaler = 1000
|
|
TIM1_CounterMode = TIM1_COUNTERMODE_UP
|
|
TIM1_CounterMode = TIM1_COUNTERMODE_UP
|
|
TIM1_RepetitionCounter = 0
|
|
TIM1_RepetitionCounter = 0
|
|
*/
|
|
*/
|
|
- //TIM1_TimeBaseInit(999, TIM1_COUNTERMODE_UP, 49, 0);
|
|
|
|
-
|
|
|
|
|
|
+ /* Set the Autoreload value */
|
|
|
|
+ TIM1->ARRH = (uint8_t)(49 >> 8);
|
|
|
|
+ TIM1->ARRL = (uint8_t)(49);
|
|
|
|
+ /* Set the Prescaler value */
|
|
|
|
+ TIM1->PSCRH = (uint8_t)(999 >> 8);
|
|
|
|
+ TIM1->PSCRL = (uint8_t)(999);
|
|
|
|
+ /* Select the Counter Mode */
|
|
|
|
+ TIM1->CR1 = 0x0;
|
|
|
|
+ /* Set the Repetition Counter value */
|
|
|
|
+ TIM1->RCR = 0;
|
|
/* Trigrer configuration */
|
|
/* Trigrer configuration */
|
|
- //TIM1_SelectOutputTrigger(TIM1_TRGOSOURCE_UPDATE);
|
|
|
|
-
|
|
|
|
|
|
+ TIM1->CR2 = (uint8_t)TIM1_TRGOSOURCE_UPDATE;
|
|
/* Update Interrupt Enable */
|
|
/* Update Interrupt Enable */
|
|
- ////TIM1_ITConfig(TIM1_IT_UPDATE, ENABLE);
|
|
|
|
-
|
|
|
|
|
|
+ //TIM1->IER |= (uint8_t)TIM1_IT_UPDATE;
|
|
/* Enable TIM1 */
|
|
/* Enable TIM1 */
|
|
- //TIM1_Cmd(ENABLE);
|
|
|
|
|
|
+ TIM1->CR1 |= TIM1_CR1_CEN;
|
|
|
|
|
|
/**
|
|
/**
|
|
TIM4 configuration:
|
|
TIM4 configuration:
|