|
PY32F403C_LVGL028_V0.1.jpg (232.56 KB, 下載次數: 0)
下載附件
2024-12-8 21:37 上傳
普冉的M4單片機系列,資源豐富,價格便宜。實在是太香了,用來驅動2.8寸SPI屏跑LVGL8超值劃算。
/**
******************************************************************************
* 文件名程: main.c
* 作 者: 東莞-鄧凱歌
* 功 能: 主程序
* 硬 件: PY32F403C_KFB_V0.1
* 說明:
* 軟件版本 V1.0.1(2024/4/7 16:02)
******************************************************************************
**/
#include "main.h"
#include "user_uart.h"
#include "user_dma.h"
#include "user_timer.h"
#include "user_gpio.h"
#include "user_spi.h"
#include "lcd_driver.h"
#include "user_touch.h"
#include "lv_port_disp.h"
#include "lv_port_indev.h"
#include "lvgl.h"
#include "gui_guider.h"
#include "events_init.h"
#include "custom.h"
lv_ui guider_ui;
uint8_t aRxBuffer,bRxBuffer;
/* Private define ------------------------------------------------------------*/
/* Private variables ---------------------------------------------------------*/
/* Private user code ---------------------------------------------------------*/
/* Private macro -------------------------------------------------------------*/
/* Private function prototypes -----------------------------------------------*/
static void APP_SystemClockConfig(void);
uint32_t senpwm = 120;
extern uint8_t pwmbit;
uint8_t lcdbit;
/**
* @brief Main program.
* @retval int
*/
int main(void)
{
/* Reset of all peripherals, Initializes the Systick. */
HAL_Init();
/* Configure the system clock */
APP_SystemClockConfig();
MX_DMA_Init();
MX_SPI1_Init();
MX_SPI2_Init();
MX_GPIO_Init();
// APP_GpioConfig();
// MX_USART1_UART_Init();
MX_TIM1_Init();
MX_TIM2_Init();
// MX_TIM6_Init();
// HAL_UART_Receive_IT(&huart1,&aRxBuffer,1);
// LCD_Init();
//// LCD_Fill(0,0,320,240,RED);
//// LCD_Fill(0,0,320,240,WHITE);
//
// LCD_DMA_Fill(0,0,320,240,RED);
// LCD_DMA_Fill(0,0,320,240,WHITE);
lv_init();
lv_port_disp_init();
lv_port_indev_init();
// lv_example_textarea_1();
custom_init(&guider_ui); //自定義的功能要放在UI初始化前面,切記!!!!
setup_ui(&guider_ui);
events_init(&guider_ui);
while (1)
{
if( tp_dev.calibit)
{
TP_Adjust();
}else{
lv_timer_handler();
}
}
}
/**
* @brief System Clock Configuration
* @param None
* @retval None
*/
static void APP_SystemClockConfig(void)
{
RCC_OscInitTypeDef OscInitstruct = {0};
RCC_ClkInitTypeDef ClkInitstruct = {0};
OscInitstruct.OscillatorType = RCC_OSCILLATORTYPE_HSE | RCC_OSCILLATORTYPE_HSI | RCC_OSCILLATORTYPE_LSE |
RCC_OSCILLATORTYPE_LSI | RCC_OSCILLATORTYPE_HSI48M;
OscInitstruct.HSEState = RCC_HSE_ON; /* Enable HSE */
OscInitstruct.HSEFreq = RCC_HSE_16_32MHz; /* HSE working frequency range: 16M~32M */
OscInitstruct.HSI48MState = RCC_HSI48M_OFF; /* Disable HSI48M */
OscInitstruct.HSIState = RCC_HSI_ON; /* Enable HSI */
OscInitstruct.LSEState = RCC_LSE_OFF; /* Disable LSE */
// OscInitstruct.LSEDriver = RCC_LSEDRIVE_HIGH; /* Drive capability level: High */
OscInitstruct.LSIState = RCC_LSI_OFF; /* Disable LSI */
OscInitstruct.PLL.PLLState = RCC_PLL_ON; /* Disable PLL */
OscInitstruct.PLL.PLLSource = RCC_PLLSOURCE_HSE; /* PLL clock source: HSE */
OscInitstruct.PLL.PLLMUL = RCC_PLL_MUL7; /* PLL multiplication factor: 6 */
/* Configure Oscillators */
if(HAL_RCC_OscConfig(&OscInitstruct) != HAL_OK)
{
Error_Handler();
}
ClkInitstruct.ClockType = RCC_CLOCKTYPE_SYSCLK | RCC_CLOCKTYPE_HCLK | RCC_CLOCKTYPE_PCLK1 | RCC_CLOCKTYPE_PCLK2;
ClkInitstruct.SYSCLKSource = RCC_SYSCLKSOURCE_PLLCLK; /* SYSCLK source select as HSE */
ClkInitstruct.AHBCLKDivider = RCC_SYSCLK_DIV1; /* AHB clock not divided */
ClkInitstruct.APB1CLKDivider = RCC_HCLK_DIV1; /* APB1 clock not divided */
ClkInitstruct.APB2CLKDivider = RCC_HCLK_DIV2; /* APB1 clock divided by 2 */
/* Configure Clocks */
if(HAL_RCC_ClockConfig(&ClkInitstruct, FLASH_LATENCY_6) != HAL_OK)
{
Error_Handler();
}
}
/**
* @brief This function is executed in case of error occurrence.
* @param None
* @retval None
*/
void Error_Handler(void)
{
/* Infinite loop */
while (1)
{
}
}
#ifdef USE_FULL_ASSERT
/**
* @brief Reports the name of the source file and the source line number
* where the assert_param error has occurred.
* @param file: pointer to the source file name
* @param line: assert_param error line source number
* @retval None
*/
void assert_failed(uint8_t *file, uint32_t line)
{
/* User can add his own implementation to report the file name and line number,
for example: printf("Wrong parameters value: file %s on line %d\r\n", file, line) */
/* Infinite loop */
while (1)
{
}
}
#endif /* USE_FULL_ASSERT */
|
|