diff --git a/.config b/.config index 6c1eec8..ea608dd 100644 --- a/.config +++ b/.config @@ -185,7 +185,11 @@ CONFIG_RT_USING_SERIAL_V1=y CONFIG_RT_SERIAL_RB_BUFSZ=512 # CONFIG_RT_USING_CAN is not set # CONFIG_RT_USING_CPUTIME is not set -# CONFIG_RT_USING_I2C is not set +CONFIG_RT_USING_I2C=y +# CONFIG_RT_I2C_DEBUG is not set +CONFIG_RT_USING_I2C_BITOPS=y +# CONFIG_RT_I2C_BITOPS_DEBUG is not set +# CONFIG_RT_USING_SOFT_I2C is not set # CONFIG_RT_USING_PHY is not set # CONFIG_RT_USING_ADC is not set # CONFIG_RT_USING_DAC is not set @@ -222,7 +226,7 @@ CONFIG_RT_USING_WDT=y # CONFIG_RT_USING_AUDIO is not set # CONFIG_RT_USING_SENSOR is not set CONFIG_RT_USING_TOUCH=y -# CONFIG_RT_TOUCH_PIN_IRQ is not set +CONFIG_RT_TOUCH_PIN_IRQ=y CONFIG_RT_USING_LCD=y # CONFIG_RT_USING_HWCRYPTO is not set # CONFIG_RT_USING_PULSE_ENCODER is not set @@ -542,7 +546,7 @@ CONFIG_PKG_LVGL_THREAD_STACK_SIZE=4096 CONFIG_PKG_LVGL_DISP_REFR_PERIOD=5 # CONFIG_PKG_USING_LVGL_SQUARELINE is not set # CONFIG_PKG_LVGL_USING_EXAMPLES is not set -# CONFIG_PKG_LVGL_USING_DEMOS is not set +CONFIG_PKG_LVGL_USING_DEMOS=y CONFIG_PKG_LVGL_USING_V080311=y # CONFIG_PKG_LVGL_USING_V080310 is not set # CONFIG_PKG_LVGL_USING_V08039 is not set @@ -1027,7 +1031,11 @@ CONFIG_PKG_LITTLEFS_VER="v2.11.2" # CONFIG_PKG_USING_GT917S is not set # CONFIG_PKG_USING_GT911 is not set # CONFIG_PKG_USING_FT6206 is not set -# CONFIG_PKG_USING_FT5426 is not set +CONFIG_PKG_USING_FT5426=y +CONFIG_PKG_FT5426_PATH="/packages/peripherals/touch/ft5426" +# CONFIG_PKG_USING_FT5426_SAMPLE is not set +CONFIG_PKG_USING_FT5426_LATEST_VERSION=y +CONFIG_PKG_FT5426_VER="latest" # CONFIG_PKG_USING_FT6236 is not set # CONFIG_PKG_USING_XPT2046_TOUCH is not set # CONFIG_PKG_USING_CST816X is not set diff --git a/.cproject b/.cproject index 55f928c..5788b07 100644 --- a/.cproject +++ b/.cproject @@ -81,6 +81,13 @@ + + + + + + + @@ -143,6 +150,7 @@ + @@ -263,6 +271,13 @@ + + + + + + + @@ -325,6 +340,7 @@ + @@ -414,6 +430,13 @@ + + + + + + + @@ -476,6 +499,7 @@ + @@ -563,6 +587,13 @@ + + + + + + + @@ -625,6 +656,7 @@ + @@ -712,6 +744,13 @@ + + + + + + + @@ -774,6 +813,7 @@ + @@ -810,7 +850,7 @@ - + @@ -830,7 +870,7 @@ - + diff --git a/.project b/.project index 350c330..f059ea4 100644 --- a/.project +++ b/.project @@ -1,6 +1,6 @@ - project + 828F diff --git a/.settings/language.settings.xml b/.settings/language.settings.xml index 0bc0db6..0b2c578 100644 --- a/.settings/language.settings.xml +++ b/.settings/language.settings.xml @@ -5,7 +5,7 @@ - + diff --git a/applications/lvgl/lv__user_gui.c b/applications/lvgl/lv__user_gui.c index 428c2a2..e3bec6d 100644 --- a/applications/lvgl/lv__user_gui.c +++ b/applications/lvgl/lv__user_gui.c @@ -11,6 +11,7 @@ #include #include #include "lvgl.h" +#include "lv_demo_widgets.h" #define DBG_TAG "gui" #define DBG_LVL DBG_LOG @@ -43,7 +44,8 @@ static void btn_led_off_evt_handler(lv_event_t *e) void lv_user_gui_init(void) { - lv_obj_t *scr = lv_scr_act(); + lv_demo_widgets(); + /* lv_obj_t *scr = lv_scr_act(); // 创建“按钮” —— 实际是一个可点击的普通对象 lv_obj_t *btn_on = lv_obj_create(scr); @@ -69,5 +71,5 @@ void lv_user_gui_init(void) lv_label_set_text(label_off, "LED OFF"); lv_obj_center(label_off); - lv_obj_add_event_cb(btn_off, btn_led_off_evt_handler, LV_EVENT_CLICKED, NULL); + lv_obj_add_event_cb(btn_off, btn_led_off_evt_handler, LV_EVENT_CLICKED, NULL);*/ } diff --git a/applications/lvgl/lv_port_indev.c b/applications/lvgl/lv_port_indev.c index 26a3176..1784aa4 100644 --- a/applications/lvgl/lv_port_indev.c +++ b/applications/lvgl/lv_port_indev.c @@ -11,7 +11,11 @@ *********************/ #include "lv_port_indev.h" #include "../../lvgl.h" +#include "ft5426.h" +#define DBG_TAG "LVGL_DEV" +#define DBG_LVL DBG_LOG +#include /********************* * DEFINES *********************/ @@ -29,18 +33,18 @@ static void touchpad_read(lv_indev_drv_t * indev_drv, lv_indev_data_t * data); static bool touchpad_is_pressed(void); static void touchpad_get_xy(lv_coord_t * x, lv_coord_t * y); -static void mouse_init(void); -static void mouse_read(lv_indev_drv_t * indev_drv, lv_indev_data_t * data); -static bool mouse_is_pressed(void); -static void mouse_get_xy(lv_coord_t * x, lv_coord_t * y); +//static void mouse_init(void); +//static void mouse_read(lv_indev_drv_t * indev_drv, lv_indev_data_t * data); +//static bool mouse_is_pressed(void); +//static void mouse_get_xy(lv_coord_t * x, lv_coord_t * y); -static void keypad_init(void); -static void keypad_read(lv_indev_drv_t * indev_drv, lv_indev_data_t * data); -static uint32_t keypad_get_key(void); +//static void keypad_init(void); +//static void keypad_read(lv_indev_drv_t * indev_drv, lv_indev_data_t * data); +//static uint32_t keypad_get_key(void); -static void encoder_init(void); -static void encoder_read(lv_indev_drv_t * indev_drv, lv_indev_data_t * data); -static void encoder_handler(void); +//static void encoder_init(void); +//static void encoder_read(lv_indev_drv_t * indev_drv, lv_indev_data_t * data); +//static void encoder_handler(void); static void button_init(void); static void button_read(lv_indev_drv_t * indev_drv, lv_indev_data_t * data); @@ -51,13 +55,13 @@ static bool button_is_pressed(uint8_t id); * STATIC VARIABLES **********************/ lv_indev_t * indev_touchpad; -lv_indev_t * indev_mouse; -lv_indev_t * indev_keypad; -lv_indev_t * indev_encoder; +//lv_indev_t * indev_mouse; +//lv_indev_t * indev_keypad; +//lv_indev_t * indev_encoder; lv_indev_t * indev_button; -static int32_t encoder_diff; -static lv_indev_state_t encoder_state; +//static int32_t encoder_diff; +//static lv_indev_state_t encoder_state; /********************** * MACROS @@ -81,7 +85,7 @@ void lv_port_indev_init(void) * You should shape them according to your hardware */ - static lv_indev_drv_t indev_drv; + static lv_indev_drv_t indev_touch_drv ,indev_button_drv; /*------------------ * Touchpad @@ -91,41 +95,41 @@ void lv_port_indev_init(void) touchpad_init(); /*Register a touchpad input device*/ - lv_indev_drv_init(&indev_drv); - indev_drv.type = LV_INDEV_TYPE_POINTER; - indev_drv.read_cb = touchpad_read; - indev_touchpad = lv_indev_drv_register(&indev_drv); + lv_indev_drv_init(&indev_touch_drv); + indev_touch_drv.type = LV_INDEV_TYPE_POINTER; + indev_touch_drv.read_cb = touchpad_read; + indev_touchpad = lv_indev_drv_register(&indev_touch_drv); /*------------------ * Mouse * -----------------*/ /*Initialize your mouse if you have*/ - mouse_init(); + //mouse_init(); /*Register a mouse input device*/ - lv_indev_drv_init(&indev_drv); - indev_drv.type = LV_INDEV_TYPE_POINTER; - indev_drv.read_cb = mouse_read; - indev_mouse = lv_indev_drv_register(&indev_drv); + //lv_indev_drv_init(&indev_drv); + //indev_drv.type = LV_INDEV_TYPE_POINTER; + //indev_drv.read_cb = mouse_read; + //indev_mouse = lv_indev_drv_register(&indev_drv); /*Set cursor. For simplicity set a HOME symbol now.*/ - lv_obj_t * mouse_cursor = lv_img_create(lv_scr_act()); - lv_img_set_src(mouse_cursor, LV_SYMBOL_HOME); - lv_indev_set_cursor(indev_mouse, mouse_cursor); + //lv_obj_t * mouse_cursor = lv_img_create(lv_scr_act()); + //lv_img_set_src(mouse_cursor, LV_SYMBOL_HOME); + //lv_indev_set_cursor(indev_mouse, mouse_cursor); /*------------------ * Keypad * -----------------*/ /*Initialize your keypad or keyboard if you have*/ - keypad_init(); + //keypad_init(); /*Register a keypad input device*/ - lv_indev_drv_init(&indev_drv); - indev_drv.type = LV_INDEV_TYPE_KEYPAD; - indev_drv.read_cb = keypad_read; - indev_keypad = lv_indev_drv_register(&indev_drv); + //lv_indev_drv_init(&indev_drv); + //indev_drv.type = LV_INDEV_TYPE_KEYPAD; + //indev_drv.read_cb = keypad_read; + //indev_keypad = lv_indev_drv_register(&indev_drv); /*Later you should create group(s) with `lv_group_t * group = lv_group_create()`, *add objects to the group with `lv_group_add_obj(group, obj)` @@ -137,13 +141,13 @@ void lv_port_indev_init(void) * -----------------*/ /*Initialize your encoder if you have*/ - encoder_init(); + //encoder_init(); /*Register a encoder input device*/ - lv_indev_drv_init(&indev_drv); - indev_drv.type = LV_INDEV_TYPE_ENCODER; - indev_drv.read_cb = encoder_read; - indev_encoder = lv_indev_drv_register(&indev_drv); + //lv_indev_drv_init(&indev_drv); + //indev_drv.type = LV_INDEV_TYPE_ENCODER; + //indev_drv.read_cb = encoder_read; + //indev_encoder = lv_indev_drv_register(&indev_drv); /*Later you should create group(s) with `lv_group_t * group = lv_group_create()`, *add objects to the group with `lv_group_add_obj(group, obj)` @@ -158,10 +162,10 @@ void lv_port_indev_init(void) button_init(); /*Register a button input device*/ - lv_indev_drv_init(&indev_drv); - indev_drv.type = LV_INDEV_TYPE_BUTTON; - indev_drv.read_cb = button_read; - indev_button = lv_indev_drv_register(&indev_drv); + lv_indev_drv_init(&indev_button_drv); + indev_button_drv.type = LV_INDEV_TYPE_BUTTON; + indev_button_drv.read_cb = button_read; + indev_button = lv_indev_drv_register(&indev_button_drv); /*Assign buttons to points on the screen*/ static const lv_point_t btn_points[2] = { @@ -180,6 +184,42 @@ void lv_port_indev_init(void) * -----------------*/ /*Initialize your touchpad*/ +struct rt_touch_data *read_data; +rt_device_t touch; + +void touchpad_thread_entry(void *parameter) +{ + read_data = (struct rt_touch_data *)rt_calloc(1, sizeof(struct rt_touch_data)); + + while(1) + { + rt_device_read(touch, 0, read_data, 1); + + rt_thread_delay(10); + } +} + +int touchpad_example(void) +{ + struct rt_touch_config cfg; + + cfg.dev_name = "i2c1"; + rt_hw_ft5426_init("touch", &cfg); + touch = rt_device_find("touch"); + rt_device_open(touch, RT_DEVICE_FLAG_RDONLY); + + rt_thread_t touchpad_thread = rt_thread_create("touch", touchpad_thread_entry, RT_NULL, 800, 10, 20); + if (touchpad_thread == RT_NULL) + { + LOG_D("create touchpad thread err"); + return -RT_ENOMEM; + } + + rt_thread_startup(touchpad_thread); + return RT_EOK; +} +INIT_APP_EXPORT(touchpad_example); + static void touchpad_init(void) { /*Your code comes here*/ @@ -194,15 +234,16 @@ static void touchpad_read(lv_indev_drv_t * indev_drv, lv_indev_data_t * data) /*Save the pressed coordinates and the state*/ if(touchpad_is_pressed()) { touchpad_get_xy(&last_x, &last_y); + + /*Set the last pressed coordinates*/ + data->point.x = last_y; + data->point.y = last_x; + data->state = LV_INDEV_STATE_PR; } else { data->state = LV_INDEV_STATE_REL; } - - /*Set the last pressed coordinates*/ - data->point.x = last_x; - data->point.y = last_y; } /*Return true is the touchpad is pressed*/ @@ -210,6 +251,9 @@ static bool touchpad_is_pressed(void) { /*Your code comes here*/ + if (read_data->event == RT_TOUCH_EVENT_DOWN) return true; + if (read_data->event == RT_TOUCH_EVENT_MOVE) return true; + if (read_data->event == RT_TOUCH_EVENT_UP) return true; return false; } @@ -217,78 +261,78 @@ static bool touchpad_is_pressed(void) static void touchpad_get_xy(lv_coord_t * x, lv_coord_t * y) { /*Your code comes here*/ - - (*x) = 0; - (*y) = 0; + (*x) = read_data->x_coordinate; + (*y) = read_data->y_coordinate; } + /*------------------ * Mouse * -----------------*/ /*Initialize your mouse*/ -static void mouse_init(void) -{ +//static void mouse_init(void) +//{ /*Your code comes here*/ -} +//} /*Will be called by the library to read the mouse*/ -static void mouse_read(lv_indev_drv_t * indev_drv, lv_indev_data_t * data) -{ +//static void mouse_read(lv_indev_drv_t * indev_drv, lv_indev_data_t * data) +//{ /*Get the current x and y coordinates*/ - mouse_get_xy(&data->point.x, &data->point.y); +// mouse_get_xy(&data->point.x, &data->point.y); /*Get whether the mouse button is pressed or released*/ - if(mouse_is_pressed()) { - data->state = LV_INDEV_STATE_PR; - } - else { - data->state = LV_INDEV_STATE_REL; - } -} +// if(mouse_is_pressed()) { +// data->state = LV_INDEV_STATE_PR; +// } +// else { +// data->state = LV_INDEV_STATE_REL; +// } +//} /*Return true is the mouse button is pressed*/ -static bool mouse_is_pressed(void) -{ +//static bool mouse_is_pressed(void) +//{ /*Your code comes here*/ - return false; -} +// return false; +//} /*Get the x and y coordinates if the mouse is pressed*/ -static void mouse_get_xy(lv_coord_t * x, lv_coord_t * y) -{ +//static void mouse_get_xy(lv_coord_t * x, lv_coord_t * y) +//{ /*Your code comes here*/ - (*x) = 0; - (*y) = 0; -} +// (*x) = 0; +// (*y) = 0; +//} /*------------------ * Keypad * -----------------*/ /*Initialize your keypad*/ -static void keypad_init(void) -{ +//static void keypad_init(void) +//{ /*Your code comes here*/ -} +//} /*Will be called by the library to read the mouse*/ -static void keypad_read(lv_indev_drv_t * indev_drv, lv_indev_data_t * data) -{ - static uint32_t last_key = 0; +//static void keypad_read(lv_indev_drv_t * indev_drv, lv_indev_data_t * data) +//{ +// static uint32_t last_key = 0; /*Get the current x and y coordinates*/ - mouse_get_xy(&data->point.x, &data->point.y); +// mouse_get_xy(&data->point.x, &data->point.y); /*Get whether the a key is pressed and save the pressed key*/ - uint32_t act_key = keypad_get_key(); - if(act_key != 0) { - data->state = LV_INDEV_STATE_PR; +// uint32_t act_key = keypad_get_key(); +// if(act_key != 0) { +// data->state = LV_INDEV_STATE_PR; /*Translate the keys to LVGL control characters according to your key definitions*/ - switch(act_key) { +/* switch(act_key) { case 1: act_key = LV_KEY_NEXT; break; @@ -312,43 +356,43 @@ static void keypad_read(lv_indev_drv_t * indev_drv, lv_indev_data_t * data) data->state = LV_INDEV_STATE_REL; } - data->key = last_key; -} + data->key = last_key;*/ +//} /*Get the currently being pressed key. 0 if no key is pressed*/ -static uint32_t keypad_get_key(void) -{ +//static uint32_t keypad_get_key(void) +//{ /*Your code comes here*/ - return 0; -} +// return 0; +//} /*------------------ * Encoder * -----------------*/ /*Initialize your keypad*/ -static void encoder_init(void) -{ +//static void encoder_init(void) +//{ /*Your code comes here*/ -} +//} /*Will be called by the library to read the encoder*/ -static void encoder_read(lv_indev_drv_t * indev_drv, lv_indev_data_t * data) -{ +//static void encoder_read(lv_indev_drv_t * indev_drv, lv_indev_data_t * data) +//{ - data->enc_diff = encoder_diff; - data->state = encoder_state; -} +// data->enc_diff = encoder_diff; +// data->state = encoder_state; +//} /*Call this function in an interrupt to process encoder events (turn, press)*/ -static void encoder_handler(void) -{ +//static void encoder_handler(void) +//{ /*Your code comes here*/ - encoder_diff += 0; - encoder_state = LV_INDEV_STATE_REL; -} +// encoder_diff += 0; +// encoder_state = LV_INDEV_STATE_REL; +//} /*------------------ * Button diff --git a/cubemx/Src/main.c b/cubemx/Src/main.c index f649ccd..1b5005d 100644 --- a/cubemx/Src/main.c +++ b/cubemx/Src/main.c @@ -712,7 +712,7 @@ static void MX_GPIO_Init(void) HAL_GPIO_WritePin(GPIOB, GPIO_PIN_0|GPIO_PIN_1, GPIO_PIN_RESET); /*Configure GPIO pin Output Level */ - HAL_GPIO_WritePin(GPIOD, GPIO_PIN_11|GPIO_PIN_12, GPIO_PIN_RESET); + HAL_GPIO_WritePin(GPIOD, GPIO_PIN_11, GPIO_PIN_RESET); /*Configure GPIO pins : PB0 PB1 */ GPIO_InitStruct.Pin = GPIO_PIN_0|GPIO_PIN_1; @@ -721,13 +721,19 @@ static void MX_GPIO_Init(void) GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_LOW; HAL_GPIO_Init(GPIOB, &GPIO_InitStruct); - /*Configure GPIO pins : PD11 PD12 */ - GPIO_InitStruct.Pin = GPIO_PIN_11|GPIO_PIN_12; + /*Configure GPIO pin : PD11 */ + GPIO_InitStruct.Pin = GPIO_PIN_11; GPIO_InitStruct.Mode = GPIO_MODE_OUTPUT_PP; GPIO_InitStruct.Pull = GPIO_NOPULL; GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_LOW; HAL_GPIO_Init(GPIOD, &GPIO_InitStruct); + /*Configure GPIO pins : PD12 PD13 */ + GPIO_InitStruct.Pin = GPIO_PIN_12|GPIO_PIN_13; + GPIO_InitStruct.Mode = GPIO_MODE_ANALOG; + GPIO_InitStruct.Pull = GPIO_NOPULL; + HAL_GPIO_Init(GPIOD, &GPIO_InitStruct); + /* USER CODE BEGIN MX_GPIO_Init_2 */ /* USER CODE END MX_GPIO_Init_2 */ diff --git a/cubemx/Src/stm32h7xx_hal_msp.c b/cubemx/Src/stm32h7xx_hal_msp.c index 761a63f..f2d92b3 100644 --- a/cubemx/Src/stm32h7xx_hal_msp.c +++ b/cubemx/Src/stm32h7xx_hal_msp.c @@ -84,13 +84,13 @@ void HAL_MspInit(void) */ void HAL_DMA2D_MspInit(DMA2D_HandleTypeDef* hdma2d) { - //if(hdma2d->Instance==DMA2D) + if(hdma2d->Instance==DMA2D) { /* USER CODE BEGIN DMA2D_MspInit 0 */ /* USER CODE END DMA2D_MspInit 0 */ /* Peripheral clock enable */ - // __HAL_RCC_DMA2D_CLK_ENABLE(); + __HAL_RCC_DMA2D_CLK_ENABLE(); /* USER CODE BEGIN DMA2D_MspInit 1 */ /* USER CODE END DMA2D_MspInit 1 */ @@ -127,143 +127,8 @@ void HAL_DMA2D_MspDeInit(DMA2D_HandleTypeDef* hdma2d) * @param hltdc: LTDC handle pointer * @retval None */ -/*void HAL_LTDC_MspInit(LTDC_HandleTypeDef* hltdc) -{ - GPIO_InitTypeDef GPIO_InitStruct = {0}; - RCC_PeriphCLKInitTypeDef PeriphClkInitStruct = {0}; - if(hltdc->Instance==LTDC) - { - // USER CODE BEGIN LTDC_MspInit 0 - // USER CODE END LTDC_MspInit 0 - - // Initializes the peripherals clock - - PeriphClkInitStruct.PeriphClockSelection = RCC_PERIPHCLK_LTDC; - PeriphClkInitStruct.PLL3.PLL3M = 32; - PeriphClkInitStruct.PLL3.PLL3N = 129; - PeriphClkInitStruct.PLL3.PLL3P = 2; - PeriphClkInitStruct.PLL3.PLL3Q = 2; - PeriphClkInitStruct.PLL3.PLL3R = 5; - PeriphClkInitStruct.PLL3.PLL3RGE = RCC_PLL3VCIRANGE_1; - PeriphClkInitStruct.PLL3.PLL3VCOSEL = RCC_PLL3VCOWIDE; - PeriphClkInitStruct.PLL3.PLL3FRACN = 0; - if (HAL_RCCEx_PeriphCLKConfig(&PeriphClkInitStruct) != HAL_OK) - { - Error_Handler(); - } - // Peripheral clock enable - __HAL_RCC_LTDC_CLK_ENABLE(); - - __HAL_RCC_GPIOE_CLK_ENABLE(); - __HAL_RCC_GPIOI_CLK_ENABLE(); - __HAL_RCC_GPIOF_CLK_ENABLE(); - __HAL_RCC_GPIOA_CLK_ENABLE(); - __HAL_RCC_GPIOH_CLK_ENABLE(); - __HAL_RCC_GPIOG_CLK_ENABLE(); - __HAL_RCC_GPIOD_CLK_ENABLE(); - //LTDC GPIO Configuration - PE5 ------> LTDC_G0 - PE6 ------> LTDC_G1 - PI9 ------> LTDC_VSYNC - PI10 ------> LTDC_HSYNC - PF10 ------> LTDC_DE - PA2 ------> LTDC_R1 - PH8 ------> LTDC_R2 - PH9 ------> LTDC_R3 - PH10 ------> LTDC_R4 - PH11 ------> LTDC_R5 - PH12 ------> LTDC_R6 - PG6 ------> LTDC_R7 - PG7 ------> LTDC_CLK - PA8 ------> LTDC_B3 - PH13 ------> LTDC_G2 - PH14 ------> LTDC_G3 - PH15 ------> LTDC_G4 - PI0 ------> LTDC_G5 - PI1 ------> LTDC_G6 - PI2 ------> LTDC_G7 - PD6 ------> LTDC_B2 - PG12 ------> LTDC_B1 - PG13 ------> LTDC_R0 - PG14 ------> LTDC_B0 - PI4 ------> LTDC_B4 - PI5 ------> LTDC_B5 - PI6 ------> LTDC_B6 - //PI7 ------> LTDC_B7 - - GPIO_InitStruct.Pin = GPIO_PIN_5|GPIO_PIN_6; - GPIO_InitStruct.Mode = GPIO_MODE_AF_PP; - GPIO_InitStruct.Pull = GPIO_NOPULL; - GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_LOW; - GPIO_InitStruct.Alternate = GPIO_AF14_LTDC; - HAL_GPIO_Init(GPIOE, &GPIO_InitStruct); - - GPIO_InitStruct.Pin = GPIO_PIN_9|GPIO_PIN_10|GPIO_PIN_0|GPIO_PIN_1 - |GPIO_PIN_2|GPIO_PIN_4|GPIO_PIN_5|GPIO_PIN_6 - |GPIO_PIN_7; - GPIO_InitStruct.Mode = GPIO_MODE_AF_PP; - GPIO_InitStruct.Pull = GPIO_NOPULL; - GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_LOW; - GPIO_InitStruct.Alternate = GPIO_AF14_LTDC; - HAL_GPIO_Init(GPIOI, &GPIO_InitStruct); - - GPIO_InitStruct.Pin = GPIO_PIN_10; - GPIO_InitStruct.Mode = GPIO_MODE_AF_PP; - GPIO_InitStruct.Pull = GPIO_NOPULL; - GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_LOW; - GPIO_InitStruct.Alternate = GPIO_AF14_LTDC; - HAL_GPIO_Init(GPIOF, &GPIO_InitStruct); - - GPIO_InitStruct.Pin = GPIO_PIN_2; - GPIO_InitStruct.Mode = GPIO_MODE_AF_PP; - GPIO_InitStruct.Pull = GPIO_NOPULL; - GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_LOW; - GPIO_InitStruct.Alternate = GPIO_AF14_LTDC; - HAL_GPIO_Init(GPIOA, &GPIO_InitStruct); - - GPIO_InitStruct.Pin = GPIO_PIN_8|GPIO_PIN_9|GPIO_PIN_10|GPIO_PIN_11 - |GPIO_PIN_12|GPIO_PIN_13|GPIO_PIN_14|GPIO_PIN_15; - GPIO_InitStruct.Mode = GPIO_MODE_AF_PP; - GPIO_InitStruct.Pull = GPIO_NOPULL; - GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_LOW; - GPIO_InitStruct.Alternate = GPIO_AF14_LTDC; - HAL_GPIO_Init(GPIOH, &GPIO_InitStruct); - - GPIO_InitStruct.Pin = GPIO_PIN_6|GPIO_PIN_7|GPIO_PIN_12|GPIO_PIN_13 - |GPIO_PIN_14; - GPIO_InitStruct.Mode = GPIO_MODE_AF_PP; - GPIO_InitStruct.Pull = GPIO_NOPULL; - GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_LOW; - GPIO_InitStruct.Alternate = GPIO_AF14_LTDC; - HAL_GPIO_Init(GPIOG, &GPIO_InitStruct); - - GPIO_InitStruct.Pin = GPIO_PIN_8; - GPIO_InitStruct.Mode = GPIO_MODE_AF_PP; - GPIO_InitStruct.Pull = GPIO_NOPULL; - GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_LOW; - GPIO_InitStruct.Alternate = GPIO_AF13_LTDC; - HAL_GPIO_Init(GPIOA, &GPIO_InitStruct); - - GPIO_InitStruct.Pin = GPIO_PIN_6; - GPIO_InitStruct.Mode = GPIO_MODE_AF_PP; - GPIO_InitStruct.Pull = GPIO_NOPULL; - GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_LOW; - GPIO_InitStruct.Alternate = GPIO_AF14_LTDC; - HAL_GPIO_Init(GPIOD, &GPIO_InitStruct); - - //LTDC interrupt Init - HAL_NVIC_SetPriority(LTDC_IRQn, 0, 0); - HAL_NVIC_EnableIRQ(LTDC_IRQn); - // USER CODE BEGIN LTDC_MspInit 1 - - // USER CODE END LTDC_MspInit 1 - - } - -} -*/ /** * @brief LTDC MSP De-Initialization * This function freeze the hardware resources used in this example diff --git a/cubemx/cubemx.ioc b/cubemx/cubemx.ioc index dabe74a..35d0418 100644 --- a/cubemx/cubemx.ioc +++ b/cubemx/cubemx.ioc @@ -132,55 +132,56 @@ Mcu.Pin48=PD10 Mcu.Pin49=PD11 Mcu.Pin5=PF1 Mcu.Pin50=PD12 -Mcu.Pin51=PD14 -Mcu.Pin52=PD15 -Mcu.Pin53=PG2 -Mcu.Pin54=PG4 -Mcu.Pin55=PG5 -Mcu.Pin56=PG6 -Mcu.Pin57=PG7 -Mcu.Pin58=PG8 -Mcu.Pin59=PC8 +Mcu.Pin51=PD13 +Mcu.Pin52=PD14 +Mcu.Pin53=PD15 +Mcu.Pin54=PG2 +Mcu.Pin55=PG4 +Mcu.Pin56=PG5 +Mcu.Pin57=PG6 +Mcu.Pin58=PG7 +Mcu.Pin59=PG8 Mcu.Pin6=PF2 -Mcu.Pin60=PC9 -Mcu.Pin61=PA8 -Mcu.Pin62=PA9 -Mcu.Pin63=PA10 -Mcu.Pin64=PH13 -Mcu.Pin65=PH14 -Mcu.Pin66=PH15 -Mcu.Pin67=PI0 -Mcu.Pin68=PI1 -Mcu.Pin69=PI2 +Mcu.Pin60=PC8 +Mcu.Pin61=PC9 +Mcu.Pin62=PA8 +Mcu.Pin63=PA9 +Mcu.Pin64=PA10 +Mcu.Pin65=PH13 +Mcu.Pin66=PH14 +Mcu.Pin67=PH15 +Mcu.Pin68=PI0 +Mcu.Pin69=PI1 Mcu.Pin7=PF3 -Mcu.Pin70=PC10 -Mcu.Pin71=PC11 -Mcu.Pin72=PC12 -Mcu.Pin73=PD0 -Mcu.Pin74=PD1 -Mcu.Pin75=PD2 -Mcu.Pin76=PD5 -Mcu.Pin77=PD6 -Mcu.Pin78=PG12 -Mcu.Pin79=PG13 +Mcu.Pin70=PI2 +Mcu.Pin71=PC10 +Mcu.Pin72=PC11 +Mcu.Pin73=PC12 +Mcu.Pin74=PD0 +Mcu.Pin75=PD1 +Mcu.Pin76=PD2 +Mcu.Pin77=PD5 +Mcu.Pin78=PD6 +Mcu.Pin79=PG12 Mcu.Pin8=PF4 -Mcu.Pin80=PG14 -Mcu.Pin81=PG15 -Mcu.Pin82=PB6 -Mcu.Pin83=PE0 -Mcu.Pin84=PE1 -Mcu.Pin85=PI4 -Mcu.Pin86=PI5 -Mcu.Pin87=PI6 -Mcu.Pin88=PI7 -Mcu.Pin89=VP_DMA2D_VS_DMA2D +Mcu.Pin80=PG13 +Mcu.Pin81=PG14 +Mcu.Pin82=PG15 +Mcu.Pin83=PB6 +Mcu.Pin84=PE0 +Mcu.Pin85=PE1 +Mcu.Pin86=PI4 +Mcu.Pin87=PI5 +Mcu.Pin88=PI6 +Mcu.Pin89=PI7 Mcu.Pin9=PF5 -Mcu.Pin90=VP_IWDG1_VS_IWDG -Mcu.Pin91=VP_RTC_VS_RTC_Activate -Mcu.Pin92=VP_RTC_VS_RTC_Calendar -Mcu.Pin93=VP_SYS_VS_Systick -Mcu.Pin94=VP_MEMORYMAP_VS_MEMORYMAP -Mcu.PinsNb=95 +Mcu.Pin90=VP_DMA2D_VS_DMA2D +Mcu.Pin91=VP_IWDG1_VS_IWDG +Mcu.Pin92=VP_RTC_VS_RTC_Activate +Mcu.Pin93=VP_RTC_VS_RTC_Calendar +Mcu.Pin94=VP_SYS_VS_Systick +Mcu.Pin95=VP_MEMORYMAP_VS_MEMORYMAP +Mcu.PinsNb=96 Mcu.ThirdPartyNb=0 Mcu.UserConstants= Mcu.UserName=STM32H743IITx @@ -241,7 +242,9 @@ PD10.Signal=FMC_D15_DA15 PD11.Locked=true PD11.Signal=GPIO_Output PD12.Locked=true -PD12.Signal=GPIO_Output +PD12.Signal=GPIO_Analog +PD13.Locked=true +PD13.Signal=GPIO_Analog PD14.Signal=FMC_D0_DA0 PD15.Signal=FMC_D1_DA1 PD2.Mode=SD_4_bits_Wide_bus @@ -417,17 +420,18 @@ RCC.DFSDMFreq_Value=120000000 RCC.DIVM1=4 RCC.DIVN1=60 RCC.DIVN2=200 +RCC.DIVN3=128 RCC.DIVP1Freq_Value=480000000 RCC.DIVP2Freq_Value=200000000 -RCC.DIVP3Freq_Value=129000000 +RCC.DIVP3Freq_Value=128000000 RCC.DIVQ1=6 RCC.DIVQ1Freq_Value=160000000 RCC.DIVQ2Freq_Value=200000000 -RCC.DIVQ3Freq_Value=129000000 +RCC.DIVQ3Freq_Value=128000000 RCC.DIVR1Freq_Value=480000000 RCC.DIVR2Freq_Value=200000000 RCC.DIVR3=5 -RCC.DIVR3Freq_Value=51600000 +RCC.DIVR3Freq_Value=51200000 RCC.FDCANFreq_Value=160000000 RCC.FMCCLockSelection=RCC_FMCCLKSOURCE_PLL RCC.FMCFreq_Value=160000000 @@ -438,12 +442,12 @@ RCC.HPRE=RCC_HCLK_DIV2 RCC.HRTIMFreq_Value=240000000 RCC.I2C123Freq_Value=120000000 RCC.I2C4Freq_Value=120000000 -RCC.IPParameters=ADCFreq_Value,AHB12Freq_Value,AHB4Freq_Value,APB1Freq_Value,APB2Freq_Value,APB3Freq_Value,APB4Freq_Value,AXIClockFreq_Value,CECFreq_Value,CKPERFreq_Value,CortexFreq_Value,CpuClockFreq_Value,D1CPREFreq_Value,D1PPRE,D2PPRE1,D2PPRE2,D3PPRE,DFSDMACLkFreq_Value,DFSDMFreq_Value,DIVM1,DIVN1,DIVN2,DIVP1Freq_Value,DIVP2Freq_Value,DIVP3Freq_Value,DIVQ1,DIVQ1Freq_Value,DIVQ2Freq_Value,DIVQ3Freq_Value,DIVR1Freq_Value,DIVR2Freq_Value,DIVR3,DIVR3Freq_Value,FDCANFreq_Value,FMCCLockSelection,FMCFreq_Value,FamilyName,HCLK3ClockFreq_Value,HCLKFreq_Value,HPRE,HRTIMFreq_Value,I2C123Freq_Value,I2C4Freq_Value,LPTIM1Freq_Value,LPTIM2Freq_Value,LPTIM345Freq_Value,LPUART1Freq_Value,LTDCFreq_Value,MCO1PinFreq_Value,MCO2PinFreq_Value,PLL2FRACN,PLL2_VCI_Range-AdvancedSettings,PLL3FRACN,PLLFRACN,QSPICLockSelection,QSPIFreq_Value,RNGFreq_Value,RTCFreq_Value,SAI1Freq_Value,SAI23Freq_Value,SAI4AFreq_Value,SAI4BFreq_Value,SDMMC1CLockSelection,SDMMCFreq_Value,SPDIFRXFreq_Value,SPI123Freq_Value,SPI45Freq_Value,SPI6Freq_Value,SWPMI1Freq_Value,SYSCLKFreq_VALUE,SYSCLKSource,Tim1OutputFreq_Value,Tim2OutputFreq_Value,TraceFreq_Value,USART16Freq_Value,USART234578Freq_Value,USBFreq_Value,VCO1OutputFreq_Value,VCO2OutputFreq_Value,VCO3OutputFreq_Value,VCOInput1Freq_Value,VCOInput2Freq_Value,VCOInput3Freq_Value +RCC.IPParameters=ADCFreq_Value,AHB12Freq_Value,AHB4Freq_Value,APB1Freq_Value,APB2Freq_Value,APB3Freq_Value,APB4Freq_Value,AXIClockFreq_Value,CECFreq_Value,CKPERFreq_Value,CortexFreq_Value,CpuClockFreq_Value,D1CPREFreq_Value,D1PPRE,D2PPRE1,D2PPRE2,D3PPRE,DFSDMACLkFreq_Value,DFSDMFreq_Value,DIVM1,DIVN1,DIVN2,DIVN3,DIVP1Freq_Value,DIVP2Freq_Value,DIVP3Freq_Value,DIVQ1,DIVQ1Freq_Value,DIVQ2Freq_Value,DIVQ3Freq_Value,DIVR1Freq_Value,DIVR2Freq_Value,DIVR3,DIVR3Freq_Value,FDCANFreq_Value,FMCCLockSelection,FMCFreq_Value,FamilyName,HCLK3ClockFreq_Value,HCLKFreq_Value,HPRE,HRTIMFreq_Value,I2C123Freq_Value,I2C4Freq_Value,LPTIM1Freq_Value,LPTIM2Freq_Value,LPTIM345Freq_Value,LPUART1Freq_Value,LTDCFreq_Value,MCO1PinFreq_Value,MCO2PinFreq_Value,PLL2FRACN,PLL2_VCI_Range-AdvancedSettings,PLL3FRACN,PLLFRACN,QSPICLockSelection,QSPIFreq_Value,RNGFreq_Value,RTCFreq_Value,SAI1Freq_Value,SAI23Freq_Value,SAI4AFreq_Value,SAI4BFreq_Value,SDMMC1CLockSelection,SDMMCFreq_Value,SPDIFRXFreq_Value,SPI123Freq_Value,SPI45Freq_Value,SPI6Freq_Value,SWPMI1Freq_Value,SYSCLKFreq_VALUE,SYSCLKSource,Tim1OutputFreq_Value,Tim2OutputFreq_Value,TraceFreq_Value,USART16Freq_Value,USART234578Freq_Value,USBFreq_Value,VCO1OutputFreq_Value,VCO2OutputFreq_Value,VCO3OutputFreq_Value,VCOInput1Freq_Value,VCOInput2Freq_Value,VCOInput3Freq_Value RCC.LPTIM1Freq_Value=120000000 RCC.LPTIM2Freq_Value=120000000 RCC.LPTIM345Freq_Value=120000000 RCC.LPUART1Freq_Value=120000000 -RCC.LTDCFreq_Value=51600000 +RCC.LTDCFreq_Value=51200000 RCC.MCO1PinFreq_Value=64000000 RCC.MCO2PinFreq_Value=480000000 RCC.PLL2FRACN=0 @@ -475,7 +479,7 @@ RCC.USART234578Freq_Value=120000000 RCC.USBFreq_Value=160000000 RCC.VCO1OutputFreq_Value=960000000 RCC.VCO2OutputFreq_Value=400000000 -RCC.VCO3OutputFreq_Value=258000000 +RCC.VCO3OutputFreq_Value=256000000 RCC.VCOInput1Freq_Value=16000000 RCC.VCOInput2Freq_Value=2000000 RCC.VCOInput3Freq_Value=2000000 diff --git a/drivers/board.h b/drivers/board.h index 667465a..fb50514 100644 --- a/drivers/board.h +++ b/drivers/board.h @@ -125,12 +125,16 @@ extern "C" */ /*#define BSP_USING_I2C1*/ +#define BSP_USING_I2C1 + #ifdef BSP_USING_I2C1 -#define BSP_I2C1_SCL_PIN GET_PIN(port, pin) -#define BSP_I2C1_SDA_PIN GET_PIN(port, pin) +#define BSP_I2C1_SCL_PIN GET_PIN(B, 12) +#define BSP_I2C1_SDA_PIN GET_PIN(B, 13) #endif /*#define BSP_USING_I2C2*/ +//#define BSP_USING_I2C2 + #ifdef BSP_USING_I2C2 #define BSP_I2C2_SCL_PIN GET_PIN(port, pin) #define BSP_I2C2_SDA_PIN GET_PIN(port, pin) diff --git a/drivers/ltdc.c b/drivers/ltdc.c index 0564340..0977b33 100644 --- a/drivers/ltdc.c +++ b/drivers/ltdc.c @@ -456,9 +456,9 @@ int ltdc_init(void) else if (lcdid == 0X7016) { lcdltdc.pwidth = 1024; lcdltdc.pheight = 600; - lcdltdc.hsw = 20; lcdltdc.hbp = 140; lcdltdc.hfp = 160; - lcdltdc.vsw = 3; lcdltdc.vbp = 20; lcdltdc.vfp = 12; - ltdc_clk_set(129, 32, 5); + lcdltdc.hsw = 70; lcdltdc.hbp = 160; lcdltdc.hfp = 160; + lcdltdc.vsw = 10; lcdltdc.vbp = 23; lcdltdc.vfp = 12; + ltdc_clk_set(128, 32, 5); } else if (lcdid == 0X7018) { @@ -539,18 +539,27 @@ int ltdc_init(void) g_ltdc_handle.Instance = LTDC; if (lcdid == 0X8081) + { g_ltdc_handle.Init.HSPolarity = LTDC_HSPOLARITY_AH; + } else + { g_ltdc_handle.Init.HSPolarity = LTDC_HSPOLARITY_AL; + } g_ltdc_handle.Init.VSPolarity = LTDC_VSPOLARITY_AL; g_ltdc_handle.Init.DEPolarity = LTDC_DEPOLARITY_AL; g_ltdc_handle.State = HAL_LTDC_STATE_RESET; + if (lcdid == 0X1018 || lcdid == 0X8081) + { g_ltdc_handle.Init.PCPolarity = LTDC_PCPOLARITY_IIPC; + } else + { g_ltdc_handle.Init.PCPolarity = LTDC_PCPOLARITY_IPC; + } g_ltdc_handle.Init.HorizontalSync = lcdltdc.hsw - 1; g_ltdc_handle.Init.VerticalSync = lcdltdc.vsw - 1; diff --git a/packages/LVGL-v8.3.11/demos/widgets/lv_demo_widgets.h b/packages/LVGL-v8.3.11/demos/widgets/lv_demo_widgets.h index 8d70df1..dd59ccd 100644 --- a/packages/LVGL-v8.3.11/demos/widgets/lv_demo_widgets.h +++ b/packages/LVGL-v8.3.11/demos/widgets/lv_demo_widgets.h @@ -22,7 +22,6 @@ extern "C" { /********************** * TYPEDEFS **********************/ - /********************** * GLOBAL PROTOTYPES **********************/ diff --git a/packages/LVGL-v8.3.11/lv_conf.h b/packages/LVGL-v8.3.11/lv_conf.h index bed77fb..2502f40 100644 --- a/packages/LVGL-v8.3.11/lv_conf.h +++ b/packages/LVGL-v8.3.11/lv_conf.h @@ -749,10 +749,10 @@ ====================*/ /*Show some widget. It might be required to increase `LV_MEM_SIZE` */ -#define LV_USE_DEMO_WIDGETS 0 -#if LV_USE_DEMO_WIDGETS -#define LV_DEMO_WIDGETS_SLIDESHOW 0 -#endif +//#define LV_USE_DEMO_WIDGETS 1 +//#if LV_USE_DEMO_WIDGETS +//#define LV_DEMO_WIDGETS_SLIDESHOW 0 +//#endif /*Demonstrate the usage of encoder and keyboard*/ #define LV_USE_DEMO_KEYPAD_AND_ENCODER 0 diff --git a/packages/LVGL-v8.3.11/lvgl.h b/packages/LVGL-v8.3.11/lvgl.h index 47700d4..9f6d1ac 100644 --- a/packages/LVGL-v8.3.11/lvgl.h +++ b/packages/LVGL-v8.3.11/lvgl.h @@ -18,6 +18,7 @@ extern "C" { #define LVGL_VERSION_PATCH 11 #define LVGL_VERSION_INFO "" +#define LV_USE_DEMO_WIDGETS 1 /********************* * INCLUDES *********************/ diff --git a/packages/pkgs.json b/packages/pkgs.json index 42363e7..1f506f4 100644 --- a/packages/pkgs.json +++ b/packages/pkgs.json @@ -24,6 +24,11 @@ "ver": "v2.11.2", "name": "LITTLEFS" }, + { + "path": "/packages/peripherals/touch/ft5426", + "ver": "latest", + "name": "FT5426" + }, { "path": "/packages/peripherals/rs485", "ver": "v1.06", diff --git a/rtconfig.h b/rtconfig.h index 3f276d3..1cdd2b2 100644 --- a/rtconfig.h +++ b/rtconfig.h @@ -127,6 +127,8 @@ #define RT_USING_SERIAL #define RT_USING_SERIAL_V1 #define RT_SERIAL_RB_BUFSZ 512 +#define RT_USING_I2C +#define RT_USING_I2C_BITOPS #define RT_USING_MTD_NOR #define RT_USING_RTC #define RT_USING_SDIO @@ -145,6 +147,7 @@ #define RT_SFUD_SPI_MAX_HZ 50000000 #define RT_USING_WDT #define RT_USING_TOUCH +#define RT_TOUCH_PIN_IRQ #define RT_USING_LCD #define RT_USING_DEV_BUS #define RT_USING_PIN @@ -258,6 +261,7 @@ #define PKG_LVGL_THREAD_PRIO 20 #define PKG_LVGL_THREAD_STACK_SIZE 4096 #define PKG_LVGL_DISP_REFR_PERIOD 5 +#define PKG_LVGL_USING_DEMOS #define PKG_LVGL_USING_V080311 #define PKG_LVGL_VER_NUM 0x080311 /* end of LVGL: powerful and easy-to-use embedded GUI library */ @@ -355,6 +359,8 @@ /* touch drivers */ +#define PKG_USING_FT5426 +#define PKG_USING_FT5426_LATEST_VERSION /* end of touch drivers */ #define PKG_USING_RS485 #define RS485_USING_DEV