-
Notifications
You must be signed in to change notification settings - Fork 57
/
main.c
143 lines (113 loc) · 3.39 KB
/
main.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
/*
Test!
Just to see if it compiles, does not do anything usefull!
This is missing everything to make this a demo:
- init of the target-controller
- init of the I/O pins
- init of the SPI
*/
#include "EVE_target.h"
#include "tft.h"
#if 0
#if defined (STM32L0) /* set with "build_flags = -D STM32L0" in platformio.ini */
#include "stm32l0xx.h"
#endif
#if defined (STM32F0) /* set with "build_flags = -D STM32F0" in platformio.ini */
#include "stm32f0xx.h"
#endif
#if defined (STM32F1) /* set with "build_flags = -D STM32F1" in platformio.ini */
#include "stm32f1xx.h"
#endif
#if defined (STM32F3) /* set with "build_flags = -D STM32F3" in platformio.ini */
#include "stm32f3xx.h"
#endif
#if defined (STM32F4) /* set in platformio.ini */
#include "stm32f4xx.h"
#endif
/* generated with STM32CubeMX for Nucleo-64 STM32F446RE */
/**
* @brief This function is executed in case of error occurrence.
* @retval None
*/
void Error_Handler(void)
{
/* USER CODE BEGIN Error_Handler_Debug */
/* User can add his own implementation to report the HAL error return state */
__disable_irq();
while (1)
{
}
/* USER CODE END Error_Handler_Debug */
}
/**
* @brief System Clock Configuration
* @retval None
*/
void SystemClock_Config(void)
{
RCC_OscInitTypeDef RCC_OscInitStruct = {0};
RCC_ClkInitTypeDef RCC_ClkInitStruct = {0};
/** Configure the main internal regulator output voltage
*/
__HAL_RCC_PWR_CLK_ENABLE();
__HAL_PWR_VOLTAGESCALING_CONFIG(PWR_REGULATOR_VOLTAGE_SCALE3);
/** Initializes the RCC Oscillators according to the specified parameters
* in the RCC_OscInitTypeDef structure.
*/
RCC_OscInitStruct.OscillatorType = RCC_OSCILLATORTYPE_HSI;
RCC_OscInitStruct.HSIState = RCC_HSI_ON;
RCC_OscInitStruct.HSICalibrationValue = RCC_HSICALIBRATION_DEFAULT;
RCC_OscInitStruct.PLL.PLLState = RCC_PLL_ON;
RCC_OscInitStruct.PLL.PLLSource = RCC_PLLSOURCE_HSI;
RCC_OscInitStruct.PLL.PLLM = 16;
RCC_OscInitStruct.PLL.PLLN = 336;
RCC_OscInitStruct.PLL.PLLP = RCC_PLLP_DIV4;
RCC_OscInitStruct.PLL.PLLQ = 2;
RCC_OscInitStruct.PLL.PLLR = 2;
if (HAL_RCC_OscConfig(&RCC_OscInitStruct) != HAL_OK)
{
Error_Handler();
}
/** Initializes the CPU, AHB and APB buses clocks
*/
RCC_ClkInitStruct.ClockType = RCC_CLOCKTYPE_HCLK|RCC_CLOCKTYPE_SYSCLK
|RCC_CLOCKTYPE_PCLK1|RCC_CLOCKTYPE_PCLK2;
RCC_ClkInitStruct.SYSCLKSource = RCC_SYSCLKSOURCE_PLLCLK;
RCC_ClkInitStruct.AHBCLKDivider = RCC_SYSCLK_DIV1;
RCC_ClkInitStruct.APB1CLKDivider = RCC_HCLK_DIV2;
RCC_ClkInitStruct.APB2CLKDivider = RCC_HCLK_DIV1;
if (HAL_RCC_ClockConfig(&RCC_ClkInitStruct, FLASH_LATENCY_2) != HAL_OK)
{
Error_Handler();
}
}
#endif
volatile uint8_t system_tick = 0;
void SysTick_Handler(void) /* the HAL definition for this is inconsistent across STM32 families, so we roll our own */
{
system_tick = 42;
}
int main(void)
{
uint8_t display_delay = 0;
HAL_Init();
// SystemClock_Config();
HAL_SYSTICK_Config(HAL_RCC_GetHCLKFreq()/200U); /*Configure the SysTick to have interrupts in 5ms time basis*/
// EVE_init_spi();
// EVE_init_dma();
TFT_init();
while(1)
{
if(system_tick)
{
system_tick = 0;
TFT_touch();
display_delay++;
if(display_delay > 3)
{
display_delay = 0;
TFT_display();
}
}
}
}