You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
141 lines
3.7 KiB
141 lines
3.7 KiB
/* USER CODE BEGIN Header */ |
|
/** |
|
****************************************************************************** |
|
* @file lcd.c |
|
* @brief This file provides code for the configuration |
|
* of the LCD instances. |
|
****************************************************************************** |
|
* @attention |
|
* |
|
* Copyright (c) 2022 STMicroelectronics. |
|
* All rights reserved. |
|
* |
|
* This software is licensed under terms that can be found in the LICENSE file |
|
* in the root directory of this software component. |
|
* If no LICENSE file comes with this software, it is provided AS-IS. |
|
* |
|
****************************************************************************** |
|
*/ |
|
/* USER CODE END Header */ |
|
/* Includes ------------------------------------------------------------------*/ |
|
#include "lcd.h" |
|
|
|
/* USER CODE BEGIN 0 */ |
|
|
|
/* USER CODE END 0 */ |
|
|
|
LCD_HandleTypeDef hlcd; |
|
|
|
/* LCD init function */ |
|
void MX_LCD_Init(void) |
|
{ |
|
|
|
/* USER CODE BEGIN LCD_Init 0 */ |
|
|
|
/* USER CODE END LCD_Init 0 */ |
|
|
|
/* USER CODE BEGIN LCD_Init 1 */ |
|
|
|
/* USER CODE END LCD_Init 1 */ |
|
hlcd.Instance = LCD; |
|
hlcd.Init.Prescaler = LCD_PRESCALER_1; |
|
hlcd.Init.Divider = LCD_DIVIDER_16; |
|
hlcd.Init.Duty = LCD_DUTY_STATIC; |
|
hlcd.Init.Bias = LCD_BIAS_1_4; |
|
hlcd.Init.VoltageSource = LCD_VOLTAGESOURCE_INTERNAL; |
|
hlcd.Init.Contrast = LCD_CONTRASTLEVEL_0; |
|
hlcd.Init.DeadTime = LCD_DEADTIME_0; |
|
hlcd.Init.PulseOnDuration = LCD_PULSEONDURATION_0; |
|
hlcd.Init.MuxSegment = LCD_MUXSEGMENT_DISABLE; |
|
hlcd.Init.BlinkMode = LCD_BLINKMODE_OFF; |
|
hlcd.Init.BlinkFrequency = LCD_BLINKFREQUENCY_DIV8; |
|
hlcd.Init.HighDrive = LCD_HIGHDRIVE_DISABLE; |
|
if (HAL_LCD_Init(&hlcd) != HAL_OK) |
|
{ |
|
Error_Handler(); |
|
} |
|
/* USER CODE BEGIN LCD_Init 2 */ |
|
|
|
/* USER CODE END LCD_Init 2 */ |
|
|
|
} |
|
|
|
void HAL_LCD_MspInit(LCD_HandleTypeDef* lcdHandle) |
|
{ |
|
|
|
GPIO_InitTypeDef GPIO_InitStruct = {0}; |
|
RCC_PeriphCLKInitTypeDef PeriphClkInit = {0}; |
|
if(lcdHandle->Instance==LCD) |
|
{ |
|
/* USER CODE BEGIN LCD_MspInit 0 */ |
|
|
|
/* USER CODE END LCD_MspInit 0 */ |
|
|
|
/** Initializes the peripherals clock |
|
*/ |
|
PeriphClkInit.PeriphClockSelection = RCC_PERIPHCLK_RTC; |
|
PeriphClkInit.RTCClockSelection = RCC_RTCCLKSOURCE_LSI; |
|
if (HAL_RCCEx_PeriphCLKConfig(&PeriphClkInit) != HAL_OK) |
|
{ |
|
Error_Handler(); |
|
} |
|
|
|
/* LCD clock enable */ |
|
__HAL_RCC_LCD_CLK_ENABLE(); |
|
|
|
__HAL_RCC_GPIOA_CLK_ENABLE(); |
|
__HAL_RCC_GPIOC_CLK_ENABLE(); |
|
/**LCD GPIO Configuration |
|
PA8 ------> LCD_COM0 |
|
PC3 ------> LCD_VLCD |
|
PA1 ------> LCD_SEG0 |
|
*/ |
|
GPIO_InitStruct.Pin = GPIO_PIN_8|GPIO_PIN_1; |
|
GPIO_InitStruct.Mode = GPIO_MODE_AF_PP; |
|
GPIO_InitStruct.Pull = GPIO_NOPULL; |
|
GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_LOW; |
|
GPIO_InitStruct.Alternate = GPIO_AF11_LCD; |
|
HAL_GPIO_Init(GPIOA, &GPIO_InitStruct); |
|
|
|
GPIO_InitStruct.Pin = GPIO_PIN_3; |
|
GPIO_InitStruct.Mode = GPIO_MODE_AF_PP; |
|
GPIO_InitStruct.Pull = GPIO_NOPULL; |
|
GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_LOW; |
|
GPIO_InitStruct.Alternate = GPIO_AF11_LCD; |
|
HAL_GPIO_Init(GPIOC, &GPIO_InitStruct); |
|
|
|
/* USER CODE BEGIN LCD_MspInit 1 */ |
|
|
|
/* USER CODE END LCD_MspInit 1 */ |
|
} |
|
} |
|
|
|
void HAL_LCD_MspDeInit(LCD_HandleTypeDef* lcdHandle) |
|
{ |
|
|
|
if(lcdHandle->Instance==LCD) |
|
{ |
|
/* USER CODE BEGIN LCD_MspDeInit 0 */ |
|
|
|
/* USER CODE END LCD_MspDeInit 0 */ |
|
/* Peripheral clock disable */ |
|
__HAL_RCC_LCD_CLK_DISABLE(); |
|
|
|
/**LCD GPIO Configuration |
|
PA8 ------> LCD_COM0 |
|
PC3 ------> LCD_VLCD |
|
PA1 ------> LCD_SEG0 |
|
*/ |
|
HAL_GPIO_DeInit(GPIOA, GPIO_PIN_8|GPIO_PIN_1); |
|
|
|
HAL_GPIO_DeInit(GPIOC, GPIO_PIN_3); |
|
|
|
/* USER CODE BEGIN LCD_MspDeInit 1 */ |
|
|
|
/* USER CODE END LCD_MspDeInit 1 */ |
|
} |
|
} |
|
|
|
/* USER CODE BEGIN 1 */ |
|
|
|
/* USER CODE END 1 */
|
|
|