1 | /**
|
2 | * @brief Main program.
|
3 | * @param None
|
4 | * @retval None
|
5 | */
|
6 | int main(void)
|
7 | {
|
8 | /* Configure the MPU attributes as Write Through */
|
9 | // MPU_Config();
|
10 |
|
11 | /* Enable the CPU Cache */
|
12 | CPU_CACHE_Enable();
|
13 |
|
14 | /* STM32F7xx HAL library initialization:
|
15 | - Configure the Flash prefetch
|
16 | - Systick timer is configured by default as source of time base, but user
|
17 | can eventually implement his proper time base source (a general purpose
|
18 | timer for example or other time source), keeping in mind that Time base
|
19 | duration should be kept 1ms since PPP_TIMEOUT_VALUEs are defined and
|
20 | handled in milliseconds basis.
|
21 | - Set NVIC Group Priority to 4
|
22 | - Low Level Initialization
|
23 | */
|
24 | HAL_Init();
|
25 |
|
26 | /* Configure the system clock to 216 MHz */
|
27 | SystemClock_Config();
|
28 |
|
29 | /* Configure LED1 */
|
30 | BSP_LED_Init(LED1);
|
31 |
|
32 | /* Configure the LCD peripheral */
|
33 | LCD_Config();
|
34 |
|
35 | /* Configure the ADC peripheral */
|
36 | TIM_Config(1999, 49999);
|
37 |
|
38 | /* Configure the ADC peripheral */
|
39 | ADC_Config();
|
40 |
|
41 | /* Start ADC with TMR based conversion process and enable DMA */
|
42 | ADC_StartDma();
|
43 |
|
44 | /* Start TMR */
|
45 | TMR_StartInterrupt();
|
46 |
|
47 | /* Infinite loop */
|
48 | while (1)
|
49 | {
|
50 | /* Display the TMR value */
|
51 | LCD_ShowValue(htim.Instance->CNT, 0, "TMR");
|
52 |
|
53 | /* Display the ADC value */
|
54 | LCD_ShowValue(AdcBuffer[0], 2, "ADC0");
|
55 | LCD_ShowValue(AdcBuffer[1], 3, "ADC1");
|
56 | LCD_ShowValue(AdcBuffer[2], 4, "ADC2");
|
57 | LCD_ShowValue(AdcBuffer[3], 5, "ADC3");
|
58 | LCD_ShowValue(AdcBuffer[4], 6, "ADC4");
|
59 | LCD_ShowValue(AdcBuffer[5], 7, "ADC5");
|
60 | LCD_ShowValue(AdcBuffer[6], 8, "ADC6");
|
61 | LCD_ShowValue(AdcBuffer[7], 9, "ADC7");
|
62 |
|
63 | LCD_ShowValue(AdcValue, 11, "VAL");
|
64 | }
|
65 | }
|
66 |
|
67 | /**
|
68 | * @brief Period elapsed callback in non blocking mode
|
69 | * @param htim : TIM handle
|
70 | * @retval None
|
71 | */
|
72 | void HAL_TIM_PeriodElapsedCallback(TIM_HandleTypeDef *htim)
|
73 | {
|
74 | /* Increase ADC cycle counter */
|
75 | AdcCycleNumber += 1;
|
76 | LCD_ShowValue(AdcCycleNumber, 1, "CYC");
|
77 | }
|
78 |
|
79 | /**
|
80 | * @brief Conversion complete callback in non blocking mode
|
81 | * @param hadc: hadc handle
|
82 | * @retval None
|
83 | */
|
84 | void HAL_ADC_ConvCpltCallback(ADC_HandleTypeDef* hadc)
|
85 | {
|
86 | uint32_t DmaOffsetBefore = 0, DmaOffsetAfter = 0;
|
87 |
|
88 | /* DMA timings by saving the value of the NDTR (remaining amount of values) */
|
89 | DmaOffsetBefore = ADC_BUFFER_SIZE - ADCxyz_DMA_STREAM->NDTR;
|
90 |
|
91 | /* Do something */
|
92 |
|
93 | /* DMA timings, BUFFER_SIZE can be adjusted, otherwise use HAL_ADC_ConvHalfCpltCallback() */
|
94 | DmaOffsetAfter = ADC_BUFFER_SIZE - ADCxyz_DMA_STREAM->NDTR;
|
95 |
|
96 | LCD_ShowValue(DmaOffsetBefore-DmaOffsetAfter, 13, "DMA");
|
97 | }
|
98 |
|
99 | /**
|
100 | * @brief Regular conversion half DMA transfer callback in non blocking mode
|
101 | * @param hadc: pointer to a ADC_HandleTypeDef structure that contains
|
102 | * the configuration information for the specified ADC.
|
103 | * @retval None
|
104 | */
|
105 | void HAL_ADC_ConvHalfCpltCallback(ADC_HandleTypeDef* hadc)
|
106 | {
|
107 | uint32_t DmaOffsetBefore = 0, DmaOffsetAfter = 0;
|
108 |
|
109 | /* DMA timings by saving the value of the NDTR (remaining amount of values) */
|
110 | DmaOffsetBefore = ADC_BUFFER_SIZE - ADCxyz_DMA_STREAM->NDTR;
|
111 |
|
112 | /* Do something */
|
113 |
|
114 | /* DMA timings, BUFFER_SIZE can be adjusted, otherwise use HAL_ADC_ConvHalfCpltCallback() */
|
115 | DmaOffsetAfter = ADC_BUFFER_SIZE - ADCxyz_DMA_STREAM->NDTR;
|
116 |
|
117 | LCD_ShowValue(DmaOffsetBefore-DmaOffsetAfter, 13, "DMA");
|
118 | }
|