This commit is contained in:
leo 2021-03-30 15:16:51 +02:00
parent 6e55b2fa19
commit 28e812de22

View file

@ -112,8 +112,7 @@ void StartDefaultTask(void const * argument);
* @brief The application entry point.
* @retval int
*/
int main(void)
{
int main(void) {
/* USER CODE BEGIN 1 */
char text[50] = { };
static TS_StateTypeDef TS_State;
@ -162,7 +161,8 @@ int main(void)
/* USER CODE BEGIN 2 */
BSP_LCD_Init();
BSP_LCD_LayerDefaultInit(0, LCD_FB_START_ADDRESS);
BSP_LCD_LayerDefaultInit(1, LCD_FB_START_ADDRESS+ BSP_LCD_GetXSize()*BSP_LCD_GetYSize()*4);
BSP_LCD_LayerDefaultInit(1,
LCD_FB_START_ADDRESS + BSP_LCD_GetXSize() * BSP_LCD_GetYSize() * 4);
BSP_LCD_DisplayOn();
BSP_LCD_SelectLayer(1);
BSP_LCD_Clear(LCD_COLOR_LIGHTGREEN);
@ -201,41 +201,46 @@ int main(void)
/* Start scheduler */
//osKernelStart();
/* We should never get here as control is now taken by the scheduler */
/* Infinite loop */
/* USER CODE BEGIN WHILE */
while (1)
{
while (1) {
/* Code de base */
HAL_GPIO_WritePin(LED13_GPIO_Port,LED13_Pin,HAL_GPIO_ReadPin(BP1_GPIO_Port,BP1_Pin));
HAL_GPIO_WritePin(LED14_GPIO_Port,LED14_Pin,HAL_GPIO_ReadPin(BP2_GPIO_Port,BP2_Pin));
HAL_GPIO_WritePin(LED13_GPIO_Port, LED13_Pin,
HAL_GPIO_ReadPin(BP1_GPIO_Port, BP1_Pin));
HAL_GPIO_WritePin(LED14_GPIO_Port, LED14_Pin,
HAL_GPIO_ReadPin(BP2_GPIO_Port, BP2_Pin));
sprintf(text, "BP1 : %d", HAL_GPIO_ReadPin(BP1_GPIO_Port, BP1_Pin));
BSP_LCD_DisplayStringAtLine(5, (uint8_t*) text);
sConfig.Channel = ADC_CHANNEL_6;
HAL_ADC_ConfigChannel(&hadc3, &sConfig);
HAL_ADC_Start(&hadc3);
while(HAL_ADC_PollForConversion(&hadc3, 100)!=HAL_OK);
while (HAL_ADC_PollForConversion(&hadc3, 100) != HAL_OK)
;
potr = HAL_ADC_GetValue(&hadc3);
sConfig.Channel = ADC_CHANNEL_7;
HAL_ADC_ConfigChannel(&hadc3, &sConfig);
HAL_ADC_Start(&hadc3);
while(HAL_ADC_PollForConversion(&hadc3, 100)!=HAL_OK);
while (HAL_ADC_PollForConversion(&hadc3, 100) != HAL_OK)
;
potl = HAL_ADC_GetValue(&hadc3);
sConfig.Channel = ADC_CHANNEL_8;
HAL_ADC_ConfigChannel(&hadc3, &sConfig);
HAL_ADC_Start(&hadc3);
while(HAL_ADC_PollForConversion(&hadc3, 100)!=HAL_OK);
while (HAL_ADC_PollForConversion(&hadc3, 100) != HAL_OK)
;
joystick_v = HAL_ADC_GetValue(&hadc3);
HAL_ADC_Start(&hadc1);
while(HAL_ADC_PollForConversion(&hadc1, 100)!=HAL_OK);
while (HAL_ADC_PollForConversion(&hadc1, 100) != HAL_OK)
;
joystick_h = HAL_ADC_GetValue(&hadc1);
sprintf(text,"POTL : %4u POTR : %4u joy_v : %4u joy_h : %4u",(uint)potl,(uint)potr,(uint)joystick_v,(uint)joystick_h);
sprintf(text, "POTL : %4u POTR : %4u joy_v : %4u joy_h : %4u",
(uint) potl, (uint) potr, (uint) joystick_v, (uint) joystick_h);
BSP_LCD_DisplayStringAtLine(9, (uint8_t*) text);
BSP_TS_GetState(&TS_State);
@ -256,8 +261,7 @@ int main(void)
* @brief System Clock Configuration
* @retval None
*/
void SystemClock_Config(void)
{
void SystemClock_Config(void) {
RCC_OscInitTypeDef RCC_OscInitStruct = { 0 };
RCC_ClkInitTypeDef RCC_ClkInitStruct = { 0 };
RCC_PeriphCLKInitTypeDef PeriphClkInitStruct = { 0 };
@ -272,7 +276,8 @@ void SystemClock_Config(void)
/** Initializes the RCC Oscillators according to the specified parameters
* in the RCC_OscInitTypeDef structure.
*/
RCC_OscInitStruct.OscillatorType = RCC_OSCILLATORTYPE_LSI|RCC_OSCILLATORTYPE_HSE;
RCC_OscInitStruct.OscillatorType = RCC_OSCILLATORTYPE_LSI
| RCC_OSCILLATORTYPE_HSE;
RCC_OscInitStruct.HSEState = RCC_HSE_ON;
RCC_OscInitStruct.LSIState = RCC_LSI_ON;
RCC_OscInitStruct.PLL.PLLState = RCC_PLL_ON;
@ -281,14 +286,12 @@ void SystemClock_Config(void)
RCC_OscInitStruct.PLL.PLLN = 400;
RCC_OscInitStruct.PLL.PLLP = RCC_PLLP_DIV2;
RCC_OscInitStruct.PLL.PLLQ = 9;
if (HAL_RCC_OscConfig(&RCC_OscInitStruct) != HAL_OK)
{
if (HAL_RCC_OscConfig(&RCC_OscInitStruct) != HAL_OK) {
Error_Handler();
}
/** Activate the Over-Drive mode
*/
if (HAL_PWREx_EnableOverDrive() != HAL_OK)
{
if (HAL_PWREx_EnableOverDrive() != HAL_OK) {
Error_Handler();
}
/** Initializes the CPU, AHB and APB buses clocks
@ -300,14 +303,12 @@ void SystemClock_Config(void)
RCC_ClkInitStruct.APB1CLKDivider = RCC_HCLK_DIV4;
RCC_ClkInitStruct.APB2CLKDivider = RCC_HCLK_DIV2;
if (HAL_RCC_ClockConfig(&RCC_ClkInitStruct, FLASH_LATENCY_6) != HAL_OK)
{
if (HAL_RCC_ClockConfig(&RCC_ClkInitStruct, FLASH_LATENCY_6) != HAL_OK) {
Error_Handler();
}
PeriphClkInitStruct.PeriphClockSelection = RCC_PERIPHCLK_LTDC|RCC_PERIPHCLK_RTC
|RCC_PERIPHCLK_USART1|RCC_PERIPHCLK_USART6
|RCC_PERIPHCLK_UART7|RCC_PERIPHCLK_I2C1
|RCC_PERIPHCLK_I2C3;
PeriphClkInitStruct.PeriphClockSelection = RCC_PERIPHCLK_LTDC
| RCC_PERIPHCLK_RTC | RCC_PERIPHCLK_USART1 | RCC_PERIPHCLK_USART6
| RCC_PERIPHCLK_UART7 | RCC_PERIPHCLK_I2C1 | RCC_PERIPHCLK_I2C3;
PeriphClkInitStruct.PLLSAI.PLLSAIN = 384;
PeriphClkInitStruct.PLLSAI.PLLSAIR = 5;
PeriphClkInitStruct.PLLSAI.PLLSAIQ = 2;
@ -320,8 +321,7 @@ void SystemClock_Config(void)
PeriphClkInitStruct.Uart7ClockSelection = RCC_UART7CLKSOURCE_PCLK1;
PeriphClkInitStruct.I2c1ClockSelection = RCC_I2C1CLKSOURCE_PCLK1;
PeriphClkInitStruct.I2c3ClockSelection = RCC_I2C3CLKSOURCE_PCLK1;
if (HAL_RCCEx_PeriphCLKConfig(&PeriphClkInitStruct) != HAL_OK)
{
if (HAL_RCCEx_PeriphCLKConfig(&PeriphClkInitStruct) != HAL_OK) {
Error_Handler();
}
}
@ -331,8 +331,7 @@ void SystemClock_Config(void)
* @param None
* @retval None
*/
static void MX_ADC1_Init(void)
{
static void MX_ADC1_Init(void) {
/* USER CODE BEGIN ADC1_Init 0 */
@ -357,8 +356,7 @@ static void MX_ADC1_Init(void)
hadc1.Init.NbrOfConversion = 1;
hadc1.Init.DMAContinuousRequests = DISABLE;
hadc1.Init.EOCSelection = ADC_EOC_SINGLE_CONV;
if (HAL_ADC_Init(&hadc1) != HAL_OK)
{
if (HAL_ADC_Init(&hadc1) != HAL_OK) {
Error_Handler();
}
/** Configure for the selected ADC regular channel its corresponding rank in the sequencer and its sample time.
@ -366,8 +364,7 @@ static void MX_ADC1_Init(void)
sConfig.Channel = ADC_CHANNEL_0;
sConfig.Rank = ADC_REGULAR_RANK_1;
sConfig.SamplingTime = ADC_SAMPLETIME_3CYCLES;
if (HAL_ADC_ConfigChannel(&hadc1, &sConfig) != HAL_OK)
{
if (HAL_ADC_ConfigChannel(&hadc1, &sConfig) != HAL_OK) {
Error_Handler();
}
/* USER CODE BEGIN ADC1_Init 2 */
@ -381,8 +378,7 @@ static void MX_ADC1_Init(void)
* @param None
* @retval None
*/
static void MX_ADC3_Init(void)
{
static void MX_ADC3_Init(void) {
/* USER CODE BEGIN ADC3_Init 0 */
@ -407,8 +403,7 @@ static void MX_ADC3_Init(void)
hadc3.Init.NbrOfConversion = 1;
hadc3.Init.DMAContinuousRequests = DISABLE;
hadc3.Init.EOCSelection = ADC_EOC_SINGLE_CONV;
if (HAL_ADC_Init(&hadc3) != HAL_OK)
{
if (HAL_ADC_Init(&hadc3) != HAL_OK) {
Error_Handler();
}
/** Configure for the selected ADC regular channel its corresponding rank in the sequencer and its sample time.
@ -416,8 +411,7 @@ static void MX_ADC3_Init(void)
sConfig.Channel = ADC_CHANNEL_6;
sConfig.Rank = ADC_REGULAR_RANK_1;
sConfig.SamplingTime = ADC_SAMPLETIME_3CYCLES;
if (HAL_ADC_ConfigChannel(&hadc3, &sConfig) != HAL_OK)
{
if (HAL_ADC_ConfigChannel(&hadc3, &sConfig) != HAL_OK) {
Error_Handler();
}
/* USER CODE BEGIN ADC3_Init 2 */
@ -431,8 +425,7 @@ static void MX_ADC3_Init(void)
* @param None
* @retval None
*/
static void MX_DAC_Init(void)
{
static void MX_DAC_Init(void) {
/* USER CODE BEGIN DAC_Init 0 */
@ -446,16 +439,14 @@ static void MX_DAC_Init(void)
/** DAC Initialization
*/
hdac.Instance = DAC;
if (HAL_DAC_Init(&hdac) != HAL_OK)
{
if (HAL_DAC_Init(&hdac) != HAL_OK) {
Error_Handler();
}
/** DAC channel OUT1 config
*/
sConfig.DAC_Trigger = DAC_TRIGGER_NONE;
sConfig.DAC_OutputBuffer = DAC_OUTPUTBUFFER_ENABLE;
if (HAL_DAC_ConfigChannel(&hdac, &sConfig, DAC_CHANNEL_1) != HAL_OK)
{
if (HAL_DAC_ConfigChannel(&hdac, &sConfig, DAC_CHANNEL_1) != HAL_OK) {
Error_Handler();
}
/* USER CODE BEGIN DAC_Init 2 */
@ -469,8 +460,7 @@ static void MX_DAC_Init(void)
* @param None
* @retval None
*/
static void MX_DMA2D_Init(void)
{
static void MX_DMA2D_Init(void) {
/* USER CODE BEGIN DMA2D_Init 0 */
@ -487,12 +477,10 @@ static void MX_DMA2D_Init(void)
hdma2d.LayerCfg[1].InputColorMode = DMA2D_INPUT_ARGB8888;
hdma2d.LayerCfg[1].AlphaMode = DMA2D_NO_MODIF_ALPHA;
hdma2d.LayerCfg[1].InputAlpha = 0;
if (HAL_DMA2D_Init(&hdma2d) != HAL_OK)
{
if (HAL_DMA2D_Init(&hdma2d) != HAL_OK) {
Error_Handler();
}
if (HAL_DMA2D_ConfigLayer(&hdma2d, 1) != HAL_OK)
{
if (HAL_DMA2D_ConfigLayer(&hdma2d, 1) != HAL_OK) {
Error_Handler();
}
/* USER CODE BEGIN DMA2D_Init 2 */
@ -506,8 +494,7 @@ static void MX_DMA2D_Init(void)
* @param None
* @retval None
*/
static void MX_I2C1_Init(void)
{
static void MX_I2C1_Init(void) {
/* USER CODE BEGIN I2C1_Init 0 */
@ -525,20 +512,18 @@ static void MX_I2C1_Init(void)
hi2c1.Init.OwnAddress2Masks = I2C_OA2_NOMASK;
hi2c1.Init.GeneralCallMode = I2C_GENERALCALL_DISABLE;
hi2c1.Init.NoStretchMode = I2C_NOSTRETCH_DISABLE;
if (HAL_I2C_Init(&hi2c1) != HAL_OK)
{
if (HAL_I2C_Init(&hi2c1) != HAL_OK) {
Error_Handler();
}
/** Configure Analogue filter
*/
if (HAL_I2CEx_ConfigAnalogFilter(&hi2c1, I2C_ANALOGFILTER_ENABLE) != HAL_OK)
{
if (HAL_I2CEx_ConfigAnalogFilter(&hi2c1, I2C_ANALOGFILTER_ENABLE)
!= HAL_OK) {
Error_Handler();
}
/** Configure Digital filter
*/
if (HAL_I2CEx_ConfigDigitalFilter(&hi2c1, 0) != HAL_OK)
{
if (HAL_I2CEx_ConfigDigitalFilter(&hi2c1, 0) != HAL_OK) {
Error_Handler();
}
/* USER CODE BEGIN I2C1_Init 2 */
@ -552,8 +537,7 @@ static void MX_I2C1_Init(void)
* @param None
* @retval None
*/
static void MX_I2C3_Init(void)
{
static void MX_I2C3_Init(void) {
/* USER CODE BEGIN I2C3_Init 0 */
@ -571,20 +555,18 @@ static void MX_I2C3_Init(void)
hi2c3.Init.OwnAddress2Masks = I2C_OA2_NOMASK;
hi2c3.Init.GeneralCallMode = I2C_GENERALCALL_DISABLE;
hi2c3.Init.NoStretchMode = I2C_NOSTRETCH_DISABLE;
if (HAL_I2C_Init(&hi2c3) != HAL_OK)
{
if (HAL_I2C_Init(&hi2c3) != HAL_OK) {
Error_Handler();
}
/** Configure Analogue filter
*/
if (HAL_I2CEx_ConfigAnalogFilter(&hi2c3, I2C_ANALOGFILTER_ENABLE) != HAL_OK)
{
if (HAL_I2CEx_ConfigAnalogFilter(&hi2c3, I2C_ANALOGFILTER_ENABLE)
!= HAL_OK) {
Error_Handler();
}
/** Configure Digital filter
*/
if (HAL_I2CEx_ConfigDigitalFilter(&hi2c3, 0) != HAL_OK)
{
if (HAL_I2CEx_ConfigDigitalFilter(&hi2c3, 0) != HAL_OK) {
Error_Handler();
}
/* USER CODE BEGIN I2C3_Init 2 */
@ -598,8 +580,7 @@ static void MX_I2C3_Init(void)
* @param None
* @retval None
*/
static void MX_LTDC_Init(void)
{
static void MX_LTDC_Init(void) {
/* USER CODE BEGIN LTDC_Init 0 */
@ -626,8 +607,7 @@ static void MX_LTDC_Init(void)
hltdc.Init.Backcolor.Blue = 0;
hltdc.Init.Backcolor.Green = 0;
hltdc.Init.Backcolor.Red = 0;
if (HAL_LTDC_Init(&hltdc) != HAL_OK)
{
if (HAL_LTDC_Init(&hltdc) != HAL_OK) {
Error_Handler();
}
pLayerCfg.WindowX0 = 0;
@ -645,8 +625,7 @@ static void MX_LTDC_Init(void)
pLayerCfg.Backcolor.Blue = 0;
pLayerCfg.Backcolor.Green = 0;
pLayerCfg.Backcolor.Red = 0;
if (HAL_LTDC_ConfigLayer(&hltdc, &pLayerCfg, 0) != HAL_OK)
{
if (HAL_LTDC_ConfigLayer(&hltdc, &pLayerCfg, 0) != HAL_OK) {
Error_Handler();
}
/* USER CODE BEGIN LTDC_Init 2 */
@ -660,8 +639,7 @@ static void MX_LTDC_Init(void)
* @param None
* @retval None
*/
static void MX_RTC_Init(void)
{
static void MX_RTC_Init(void) {
/* USER CODE BEGIN RTC_Init 0 */
@ -683,8 +661,7 @@ static void MX_RTC_Init(void)
hrtc.Init.OutPut = RTC_OUTPUT_DISABLE;
hrtc.Init.OutPutPolarity = RTC_OUTPUT_POLARITY_HIGH;
hrtc.Init.OutPutType = RTC_OUTPUT_TYPE_OPENDRAIN;
if (HAL_RTC_Init(&hrtc) != HAL_OK)
{
if (HAL_RTC_Init(&hrtc) != HAL_OK) {
Error_Handler();
}
@ -699,16 +676,14 @@ static void MX_RTC_Init(void)
sTime.Seconds = 0x0;
sTime.DayLightSaving = RTC_DAYLIGHTSAVING_NONE;
sTime.StoreOperation = RTC_STOREOPERATION_RESET;
if (HAL_RTC_SetTime(&hrtc, &sTime, RTC_FORMAT_BCD) != HAL_OK)
{
if (HAL_RTC_SetTime(&hrtc, &sTime, RTC_FORMAT_BCD) != HAL_OK) {
Error_Handler();
}
sDate.WeekDay = RTC_WEEKDAY_MONDAY;
sDate.Month = RTC_MONTH_JANUARY;
sDate.Date = 0x1;
sDate.Year = 0x0;
if (HAL_RTC_SetDate(&hrtc, &sDate, RTC_FORMAT_BCD) != HAL_OK)
{
if (HAL_RTC_SetDate(&hrtc, &sDate, RTC_FORMAT_BCD) != HAL_OK) {
Error_Handler();
}
/** Enable the Alarm A
@ -724,21 +699,19 @@ static void MX_RTC_Init(void)
sAlarm.AlarmDateWeekDaySel = RTC_ALARMDATEWEEKDAYSEL_DATE;
sAlarm.AlarmDateWeekDay = 0x1;
sAlarm.Alarm = RTC_ALARM_A;
if (HAL_RTC_SetAlarm(&hrtc, &sAlarm, RTC_FORMAT_BCD) != HAL_OK)
{
if (HAL_RTC_SetAlarm(&hrtc, &sAlarm, RTC_FORMAT_BCD) != HAL_OK) {
Error_Handler();
}
/** Enable the Alarm B
*/
sAlarm.Alarm = RTC_ALARM_B;
if (HAL_RTC_SetAlarm(&hrtc, &sAlarm, RTC_FORMAT_BCD) != HAL_OK)
{
if (HAL_RTC_SetAlarm(&hrtc, &sAlarm, RTC_FORMAT_BCD) != HAL_OK) {
Error_Handler();
}
/** Enable the TimeStamp
*/
if (HAL_RTCEx_SetTimeStamp(&hrtc, RTC_TIMESTAMPEDGE_RISING, RTC_TIMESTAMPPIN_POS1) != HAL_OK)
{
if (HAL_RTCEx_SetTimeStamp(&hrtc, RTC_TIMESTAMPEDGE_RISING,
RTC_TIMESTAMPPIN_POS1) != HAL_OK) {
Error_Handler();
}
/* USER CODE BEGIN RTC_Init 2 */
@ -752,8 +725,7 @@ static void MX_RTC_Init(void)
* @param None
* @retval None
*/
static void MX_SPI2_Init(void)
{
static void MX_SPI2_Init(void) {
/* USER CODE BEGIN SPI2_Init 0 */
@ -777,8 +749,7 @@ static void MX_SPI2_Init(void)
hspi2.Init.CRCPolynomial = 7;
hspi2.Init.CRCLength = SPI_CRC_LENGTH_DATASIZE;
hspi2.Init.NSSPMode = SPI_NSS_PULSE_ENABLE;
if (HAL_SPI_Init(&hspi2) != HAL_OK)
{
if (HAL_SPI_Init(&hspi2) != HAL_OK) {
Error_Handler();
}
/* USER CODE BEGIN SPI2_Init 2 */
@ -792,8 +763,7 @@ static void MX_SPI2_Init(void)
* @param None
* @retval None
*/
static void MX_TIM1_Init(void)
{
static void MX_TIM1_Init(void) {
/* USER CODE BEGIN TIM1_Init 0 */
@ -812,20 +782,18 @@ static void MX_TIM1_Init(void)
htim1.Init.ClockDivision = TIM_CLOCKDIVISION_DIV1;
htim1.Init.RepetitionCounter = 0;
htim1.Init.AutoReloadPreload = TIM_AUTORELOAD_PRELOAD_DISABLE;
if (HAL_TIM_Base_Init(&htim1) != HAL_OK)
{
if (HAL_TIM_Base_Init(&htim1) != HAL_OK) {
Error_Handler();
}
sClockSourceConfig.ClockSource = TIM_CLOCKSOURCE_INTERNAL;
if (HAL_TIM_ConfigClockSource(&htim1, &sClockSourceConfig) != HAL_OK)
{
if (HAL_TIM_ConfigClockSource(&htim1, &sClockSourceConfig) != HAL_OK) {
Error_Handler();
}
sMasterConfig.MasterOutputTrigger = TIM_TRGO_RESET;
sMasterConfig.MasterOutputTrigger2 = TIM_TRGO2_RESET;
sMasterConfig.MasterSlaveMode = TIM_MASTERSLAVEMODE_DISABLE;
if (HAL_TIMEx_MasterConfigSynchronization(&htim1, &sMasterConfig) != HAL_OK)
{
if (HAL_TIMEx_MasterConfigSynchronization(&htim1, &sMasterConfig)
!= HAL_OK) {
Error_Handler();
}
/* USER CODE BEGIN TIM1_Init 2 */
@ -839,8 +807,7 @@ static void MX_TIM1_Init(void)
* @param None
* @retval None
*/
static void MX_TIM2_Init(void)
{
static void MX_TIM2_Init(void) {
/* USER CODE BEGIN TIM2_Init 0 */
@ -858,19 +825,17 @@ static void MX_TIM2_Init(void)
htim2.Init.Period = 4294967295;
htim2.Init.ClockDivision = TIM_CLOCKDIVISION_DIV1;
htim2.Init.AutoReloadPreload = TIM_AUTORELOAD_PRELOAD_DISABLE;
if (HAL_TIM_Base_Init(&htim2) != HAL_OK)
{
if (HAL_TIM_Base_Init(&htim2) != HAL_OK) {
Error_Handler();
}
sClockSourceConfig.ClockSource = TIM_CLOCKSOURCE_INTERNAL;
if (HAL_TIM_ConfigClockSource(&htim2, &sClockSourceConfig) != HAL_OK)
{
if (HAL_TIM_ConfigClockSource(&htim2, &sClockSourceConfig) != HAL_OK) {
Error_Handler();
}
sMasterConfig.MasterOutputTrigger = TIM_TRGO_RESET;
sMasterConfig.MasterSlaveMode = TIM_MASTERSLAVEMODE_DISABLE;
if (HAL_TIMEx_MasterConfigSynchronization(&htim2, &sMasterConfig) != HAL_OK)
{
if (HAL_TIMEx_MasterConfigSynchronization(&htim2, &sMasterConfig)
!= HAL_OK) {
Error_Handler();
}
/* USER CODE BEGIN TIM2_Init 2 */
@ -884,8 +849,7 @@ static void MX_TIM2_Init(void)
* @param None
* @retval None
*/
static void MX_TIM3_Init(void)
{
static void MX_TIM3_Init(void) {
/* USER CODE BEGIN TIM3_Init 0 */
@ -905,37 +869,33 @@ static void MX_TIM3_Init(void)
htim3.Init.Period = 65535;
htim3.Init.ClockDivision = TIM_CLOCKDIVISION_DIV1;
htim3.Init.AutoReloadPreload = TIM_AUTORELOAD_PRELOAD_DISABLE;
if (HAL_TIM_Base_Init(&htim3) != HAL_OK)
{
if (HAL_TIM_Base_Init(&htim3) != HAL_OK) {
Error_Handler();
}
sClockSourceConfig.ClockSource = TIM_CLOCKSOURCE_INTERNAL;
if (HAL_TIM_ConfigClockSource(&htim3, &sClockSourceConfig) != HAL_OK)
{
if (HAL_TIM_ConfigClockSource(&htim3, &sClockSourceConfig) != HAL_OK) {
Error_Handler();
}
if (HAL_TIM_PWM_Init(&htim3) != HAL_OK)
{
if (HAL_TIM_PWM_Init(&htim3) != HAL_OK) {
Error_Handler();
}
sSlaveConfig.SlaveMode = TIM_SLAVEMODE_DISABLE;
sSlaveConfig.InputTrigger = TIM_TS_ITR0;
if (HAL_TIM_SlaveConfigSynchro(&htim3, &sSlaveConfig) != HAL_OK)
{
if (HAL_TIM_SlaveConfigSynchro(&htim3, &sSlaveConfig) != HAL_OK) {
Error_Handler();
}
sMasterConfig.MasterOutputTrigger = TIM_TRGO_RESET;
sMasterConfig.MasterSlaveMode = TIM_MASTERSLAVEMODE_DISABLE;
if (HAL_TIMEx_MasterConfigSynchronization(&htim3, &sMasterConfig) != HAL_OK)
{
if (HAL_TIMEx_MasterConfigSynchronization(&htim3, &sMasterConfig)
!= HAL_OK) {
Error_Handler();
}
sConfigOC.OCMode = TIM_OCMODE_PWM1;
sConfigOC.Pulse = 0;
sConfigOC.OCPolarity = TIM_OCPOLARITY_HIGH;
sConfigOC.OCFastMode = TIM_OCFAST_DISABLE;
if (HAL_TIM_PWM_ConfigChannel(&htim3, &sConfigOC, TIM_CHANNEL_1) != HAL_OK)
{
if (HAL_TIM_PWM_ConfigChannel(&htim3, &sConfigOC, TIM_CHANNEL_1)
!= HAL_OK) {
Error_Handler();
}
/* USER CODE BEGIN TIM3_Init 2 */
@ -950,8 +910,7 @@ static void MX_TIM3_Init(void)
* @param None
* @retval None
*/
static void MX_TIM5_Init(void)
{
static void MX_TIM5_Init(void) {
/* USER CODE BEGIN TIM5_Init 0 */
@ -969,19 +928,17 @@ static void MX_TIM5_Init(void)
htim5.Init.Period = 4294967295;
htim5.Init.ClockDivision = TIM_CLOCKDIVISION_DIV1;
htim5.Init.AutoReloadPreload = TIM_AUTORELOAD_PRELOAD_DISABLE;
if (HAL_TIM_Base_Init(&htim5) != HAL_OK)
{
if (HAL_TIM_Base_Init(&htim5) != HAL_OK) {
Error_Handler();
}
sClockSourceConfig.ClockSource = TIM_CLOCKSOURCE_INTERNAL;
if (HAL_TIM_ConfigClockSource(&htim5, &sClockSourceConfig) != HAL_OK)
{
if (HAL_TIM_ConfigClockSource(&htim5, &sClockSourceConfig) != HAL_OK) {
Error_Handler();
}
sMasterConfig.MasterOutputTrigger = TIM_TRGO_RESET;
sMasterConfig.MasterSlaveMode = TIM_MASTERSLAVEMODE_DISABLE;
if (HAL_TIMEx_MasterConfigSynchronization(&htim5, &sMasterConfig) != HAL_OK)
{
if (HAL_TIMEx_MasterConfigSynchronization(&htim5, &sMasterConfig)
!= HAL_OK) {
Error_Handler();
}
/* USER CODE BEGIN TIM5_Init 2 */
@ -995,8 +952,7 @@ static void MX_TIM5_Init(void)
* @param None
* @retval None
*/
static void MX_TIM8_Init(void)
{
static void MX_TIM8_Init(void) {
/* USER CODE BEGIN TIM8_Init 0 */
@ -1017,24 +973,21 @@ static void MX_TIM8_Init(void)
htim8.Init.ClockDivision = TIM_CLOCKDIVISION_DIV1;
htim8.Init.RepetitionCounter = 0;
htim8.Init.AutoReloadPreload = TIM_AUTORELOAD_PRELOAD_DISABLE;
if (HAL_TIM_Base_Init(&htim8) != HAL_OK)
{
if (HAL_TIM_Base_Init(&htim8) != HAL_OK) {
Error_Handler();
}
sClockSourceConfig.ClockSource = TIM_CLOCKSOURCE_INTERNAL;
if (HAL_TIM_ConfigClockSource(&htim8, &sClockSourceConfig) != HAL_OK)
{
if (HAL_TIM_ConfigClockSource(&htim8, &sClockSourceConfig) != HAL_OK) {
Error_Handler();
}
if (HAL_TIM_PWM_Init(&htim8) != HAL_OK)
{
if (HAL_TIM_PWM_Init(&htim8) != HAL_OK) {
Error_Handler();
}
sMasterConfig.MasterOutputTrigger = TIM_TRGO_RESET;
sMasterConfig.MasterOutputTrigger2 = TIM_TRGO2_RESET;
sMasterConfig.MasterSlaveMode = TIM_MASTERSLAVEMODE_DISABLE;
if (HAL_TIMEx_MasterConfigSynchronization(&htim8, &sMasterConfig) != HAL_OK)
{
if (HAL_TIMEx_MasterConfigSynchronization(&htim8, &sMasterConfig)
!= HAL_OK) {
Error_Handler();
}
sConfigOC.OCMode = TIM_OCMODE_PWM1;
@ -1043,8 +996,8 @@ static void MX_TIM8_Init(void)
sConfigOC.OCFastMode = TIM_OCFAST_DISABLE;
sConfigOC.OCIdleState = TIM_OCIDLESTATE_RESET;
sConfigOC.OCNIdleState = TIM_OCNIDLESTATE_RESET;
if (HAL_TIM_PWM_ConfigChannel(&htim8, &sConfigOC, TIM_CHANNEL_4) != HAL_OK)
{
if (HAL_TIM_PWM_ConfigChannel(&htim8, &sConfigOC, TIM_CHANNEL_4)
!= HAL_OK) {
Error_Handler();
}
sBreakDeadTimeConfig.OffStateRunMode = TIM_OSSR_DISABLE;
@ -1058,8 +1011,8 @@ static void MX_TIM8_Init(void)
sBreakDeadTimeConfig.Break2Polarity = TIM_BREAK2POLARITY_HIGH;
sBreakDeadTimeConfig.Break2Filter = 0;
sBreakDeadTimeConfig.AutomaticOutput = TIM_AUTOMATICOUTPUT_DISABLE;
if (HAL_TIMEx_ConfigBreakDeadTime(&htim8, &sBreakDeadTimeConfig) != HAL_OK)
{
if (HAL_TIMEx_ConfigBreakDeadTime(&htim8, &sBreakDeadTimeConfig)
!= HAL_OK) {
Error_Handler();
}
/* USER CODE BEGIN TIM8_Init 2 */
@ -1074,8 +1027,7 @@ static void MX_TIM8_Init(void)
* @param None
* @retval None
*/
static void MX_UART7_Init(void)
{
static void MX_UART7_Init(void) {
/* USER CODE BEGIN UART7_Init 0 */
@ -1094,8 +1046,7 @@ static void MX_UART7_Init(void)
huart7.Init.OverSampling = UART_OVERSAMPLING_16;
huart7.Init.OneBitSampling = UART_ONE_BIT_SAMPLE_DISABLE;
huart7.AdvancedInit.AdvFeatureInit = UART_ADVFEATURE_NO_INIT;
if (HAL_UART_Init(&huart7) != HAL_OK)
{
if (HAL_UART_Init(&huart7) != HAL_OK) {
Error_Handler();
}
/* USER CODE BEGIN UART7_Init 2 */
@ -1109,8 +1060,7 @@ static void MX_UART7_Init(void)
* @param None
* @retval None
*/
static void MX_USART1_UART_Init(void)
{
static void MX_USART1_UART_Init(void) {
/* USER CODE BEGIN USART1_Init 0 */
@ -1129,8 +1079,7 @@ static void MX_USART1_UART_Init(void)
huart1.Init.OverSampling = UART_OVERSAMPLING_16;
huart1.Init.OneBitSampling = UART_ONE_BIT_SAMPLE_DISABLE;
huart1.AdvancedInit.AdvFeatureInit = UART_ADVFEATURE_NO_INIT;
if (HAL_UART_Init(&huart1) != HAL_OK)
{
if (HAL_UART_Init(&huart1) != HAL_OK) {
Error_Handler();
}
/* USER CODE BEGIN USART1_Init 2 */
@ -1144,8 +1093,7 @@ static void MX_USART1_UART_Init(void)
* @param None
* @retval None
*/
static void MX_USART6_UART_Init(void)
{
static void MX_USART6_UART_Init(void) {
/* USER CODE BEGIN USART6_Init 0 */
@ -1164,8 +1112,7 @@ static void MX_USART6_UART_Init(void)
huart6.Init.OverSampling = UART_OVERSAMPLING_16;
huart6.Init.OneBitSampling = UART_ONE_BIT_SAMPLE_DISABLE;
huart6.AdvancedInit.AdvFeatureInit = UART_ADVFEATURE_NO_INIT;
if (HAL_UART_Init(&huart6) != HAL_OK)
{
if (HAL_UART_Init(&huart6) != HAL_OK) {
Error_Handler();
}
/* USER CODE BEGIN USART6_Init 2 */
@ -1175,8 +1122,7 @@ static void MX_USART6_UART_Init(void)
}
/* FMC initialization function */
static void MX_FMC_Init(void)
{
static void MX_FMC_Init(void) {
/* USER CODE BEGIN FMC_Init 0 */
@ -1211,8 +1157,7 @@ static void MX_FMC_Init(void)
SdramTiming.RPDelay = 16;
SdramTiming.RCDDelay = 16;
if (HAL_SDRAM_Init(&hsdram1, &SdramTiming) != HAL_OK)
{
if (HAL_SDRAM_Init(&hsdram1, &SdramTiming) != HAL_OK) {
Error_Handler();
}
@ -1226,8 +1171,7 @@ static void MX_FMC_Init(void)
* @param None
* @retval None
*/
static void MX_GPIO_Init(void)
{
static void MX_GPIO_Init(void) {
GPIO_InitTypeDef GPIO_InitStruct = { 0 };
/* GPIO Ports Clock Enable */
@ -1247,7 +1191,8 @@ static void MX_GPIO_Init(void)
HAL_GPIO_WritePin(GPIOE, LED14_Pin | LED15_Pin, GPIO_PIN_RESET);
/*Configure GPIO pin Output Level */
HAL_GPIO_WritePin(OTG_FS_PowerSwitchOn_GPIO_Port, OTG_FS_PowerSwitchOn_Pin, GPIO_PIN_SET);
HAL_GPIO_WritePin(OTG_FS_PowerSwitchOn_GPIO_Port, OTG_FS_PowerSwitchOn_Pin,
GPIO_PIN_SET);
/*Configure GPIO pin Output Level */
HAL_GPIO_WritePin(LED16_GPIO_Port, LED16_Pin, GPIO_PIN_RESET);
@ -1262,8 +1207,9 @@ static void MX_GPIO_Init(void)
HAL_GPIO_WritePin(LCD_DISP_GPIO_Port, LCD_DISP_Pin, GPIO_PIN_SET);
/*Configure GPIO pin Output Level */
HAL_GPIO_WritePin(GPIOH, LED13_Pin|LED17_Pin|LED11_Pin|LED12_Pin
|LED2_Pin|LED18_Pin, GPIO_PIN_RESET);
HAL_GPIO_WritePin(GPIOH,
LED13_Pin | LED17_Pin | LED11_Pin | LED12_Pin | LED2_Pin | LED18_Pin,
GPIO_PIN_RESET);
/*Configure GPIO pin Output Level */
HAL_GPIO_WritePin(EXT_RST_GPIO_Port, EXT_RST_Pin, GPIO_PIN_RESET);
@ -1413,12 +1359,10 @@ static void MX_GPIO_Init(void)
* @retval None
*/
/* USER CODE END Header_StartDefaultTask */
void StartDefaultTask(void const * argument)
{
void StartDefaultTask(void const *argument) {
/* USER CODE BEGIN 5 */
/* Infinite loop */
for(;;)
{
for (;;) {
osDelay(1);
}
/* USER CODE END 5 */
@ -1432,8 +1376,7 @@ void StartDefaultTask(void const * argument)
* @param htim : TIM handle
* @retval None
*/
void HAL_TIM_PeriodElapsedCallback(TIM_HandleTypeDef *htim)
{
void HAL_TIM_PeriodElapsedCallback(TIM_HandleTypeDef *htim) {
/* USER CODE BEGIN Callback 0 */
/* USER CODE END Callback 0 */
@ -1449,13 +1392,11 @@ void HAL_TIM_PeriodElapsedCallback(TIM_HandleTypeDef *htim)
* @brief This function is executed in case of error occurrence.
* @retval None
*/
void Error_Handler(void)
{
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)
{
while (1) {
}
/* USER CODE END Error_Handler_Debug */
}