Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
AdRainty
rt-thread
提交
8e50ef53
R
rt-thread
项目概览
AdRainty
/
rt-thread
与 Fork 源项目一致
Fork自
RT-Thread / rt-thread
通知
1
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
DevOps
流水线
流水线任务
计划
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
R
rt-thread
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
DevOps
DevOps
流水线
流水线任务
计划
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
流水线任务
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
8e50ef53
编写于
12月 29, 2021
作者:
L
liuxianliang
提交者:
Bernard Xiong
12月 30, 2021
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
[add] proting 'lvgl' for stm32f407-atk-explorer.
上级
8ab54c30
变更
21
展开全部
隐藏空白更改
内联
并排
Showing
21 changed file
with
3021 addition
and
75 deletion
+3021
-75
bsp/stm32/stm32f407-atk-explorer/README.md
bsp/stm32/stm32f407-atk-explorer/README.md
+5
-3
bsp/stm32/stm32f407-atk-explorer/applications/lvgl/SConscript
...stm32/stm32f407-atk-explorer/applications/lvgl/SConscript
+16
-0
bsp/stm32/stm32f407-atk-explorer/applications/lvgl/demo/SConscript
.../stm32f407-atk-explorer/applications/lvgl/demo/SConscript
+16
-0
bsp/stm32/stm32f407-atk-explorer/applications/lvgl/demo/lv_demo_calendar.c
...07-atk-explorer/applications/lvgl/demo/lv_demo_calendar.c
+51
-0
bsp/stm32/stm32f407-atk-explorer/applications/lvgl/demo/lv_demo_calendar.h
...07-atk-explorer/applications/lvgl/demo/lv_demo_calendar.h
+6
-0
bsp/stm32/stm32f407-atk-explorer/applications/lvgl/lv_conf.h
bsp/stm32/stm32f407-atk-explorer/applications/lvgl/lv_conf.h
+26
-0
bsp/stm32/stm32f407-atk-explorer/applications/lvgl/lv_demo.c
bsp/stm32/stm32f407-atk-explorer/applications/lvgl/lv_demo.c
+65
-0
bsp/stm32/stm32f407-atk-explorer/applications/lvgl/lv_port_disp.c
...2/stm32f407-atk-explorer/applications/lvgl/lv_port_disp.c
+70
-0
bsp/stm32/stm32f407-atk-explorer/applications/lvgl/lv_port_disp.h
...2/stm32f407-atk-explorer/applications/lvgl/lv_port_disp.h
+23
-0
bsp/stm32/stm32f407-atk-explorer/applications/lvgl/lv_port_indev.c
.../stm32f407-atk-explorer/applications/lvgl/lv_port_indev.c
+46
-0
bsp/stm32/stm32f407-atk-explorer/applications/lvgl/lv_port_indev.h
.../stm32f407-atk-explorer/applications/lvgl/lv_port_indev.h
+28
-0
bsp/stm32/stm32f407-atk-explorer/board/CubeMX_Config/Src/stm32f4xx_hal_msp.c
...-atk-explorer/board/CubeMX_Config/Src/stm32f4xx_hal_msp.c
+4
-2
bsp/stm32/stm32f407-atk-explorer/board/Kconfig
bsp/stm32/stm32f407-atk-explorer/board/Kconfig
+48
-11
bsp/stm32/stm32f407-atk-explorer/board/SConscript
bsp/stm32/stm32f407-atk-explorer/board/SConscript
+9
-3
bsp/stm32/stm32f407-atk-explorer/board/linker_scripts/link.lds
...tm32/stm32f407-atk-explorer/board/linker_scripts/link.lds
+14
-4
bsp/stm32/stm32f407-atk-explorer/board/ports/drv_lcd.c
bsp/stm32/stm32f407-atk-explorer/board/ports/drv_lcd.c
+1988
-0
bsp/stm32/stm32f407-atk-explorer/board/ports/drv_lcd.h
bsp/stm32/stm32f407-atk-explorer/board/ports/drv_lcd.h
+74
-0
bsp/stm32/stm32f407-atk-explorer/board/ports/touch/drv_touch.c
...tm32/stm32f407-atk-explorer/board/ports/touch/drv_touch.c
+208
-0
bsp/stm32/stm32f407-atk-explorer/board/ports/touch/drv_touch.h
...tm32/stm32f407-atk-explorer/board/ports/touch/drv_touch.h
+55
-0
bsp/stm32/stm32f407-atk-explorer/board/ports/touch/drv_touch_ft.c
...2/stm32f407-atk-explorer/board/ports/touch/drv_touch_ft.c
+240
-0
bsp/stm32/stm32f407-atk-explorer/rtconfig.h
bsp/stm32/stm32f407-atk-explorer/rtconfig.h
+29
-52
未找到文件。
bsp/stm32/stm32f407-atk-explorer/README.md
浏览文件 @
8e50ef53
...
...
@@ -44,7 +44,9 @@
| COM3 | 支持 | |
| MPU6050 | 支持 | |
| Flash | 支持 | |
| SRAM | 支持 | |
| SRAM | 支持 | LVGL 会使用到,但此时不能启用 RT_USING_MEMHEAP_AS_HEAP 内存算法 |
| TFTLCD | 支持 | F407 不带 LTDC 外设,所以需要使用 MCU LCD,而不能直接驱动 RGB 屏幕 |
| LCD-TOUCH | 支持 | 仅测试过 GT9147, 其他触摸驱动需要添加适配 |
| SD卡 | 支持 | 支持FATFS文件系统 |
| W25Q128 | 支持 | 支持LittleFS文件系统 |
| 以太网 | 支持 | |
...
...
@@ -53,7 +55,7 @@
| GPIO | 支持 | PA0, PA1... PH1 ---> PIN: 0, 1...144 |
| UART | 支持 | UART1/2/3 |
| SPI | 支持 | SPI1/2/3 |
| I2C | 支持 |
软件 I2C
|
| I2C | 支持 |
软件 I2C1, I2C2[仅触摸屏使用]
|
| ADC | 支持 | |
| RTC | 支持 | 支持外部晶振和内部低速时钟 |
| WDT | 支持 | |
...
...
@@ -129,4 +131,4 @@ msh >
维护人:
-
[
guozhanxin
](
https://github.com/Guozhanxin
)
\ No newline at end of file
-
[
guozhanxin
](
https://github.com/Guozhanxin
)
\ No newline at end of file
bsp/stm32/stm32f407-atk-explorer/applications/lvgl/SConscript
0 → 100644
浏览文件 @
8e50ef53
from
building
import
*
import
os
cwd
=
GetCurrentDir
()
group
=
[]
src
=
Glob
(
'*.c'
)
CPPPATH
=
[
cwd
]
list
=
os
.
listdir
(
cwd
)
for
d
in
list
:
path
=
os
.
path
.
join
(
cwd
,
d
)
if
os
.
path
.
isfile
(
os
.
path
.
join
(
path
,
'SConscript'
)):
group
=
group
+
SConscript
(
os
.
path
.
join
(
d
,
'SConscript'
))
group
+=
DefineGroup
(
'LVGL-port'
,
src
,
depend
=
[
'PKG_USING_LVGL'
],
CPPPATH
=
CPPPATH
)
Return
(
'group'
)
bsp/stm32/stm32f407-atk-explorer/applications/lvgl/demo/SConscript
0 → 100644
浏览文件 @
8e50ef53
from
building
import
*
import
os
cwd
=
GetCurrentDir
()
group
=
[]
src
=
Glob
(
'*.c'
)
CPPPATH
=
[
cwd
]
list
=
os
.
listdir
(
cwd
)
for
d
in
list
:
path
=
os
.
path
.
join
(
cwd
,
d
)
if
os
.
path
.
isfile
(
os
.
path
.
join
(
path
,
'SConscript'
)):
group
=
group
+
SConscript
(
os
.
path
.
join
(
d
,
'SConscript'
))
group
+=
DefineGroup
(
'LVGL-port'
,
src
,
depend
=
[
'PKG_USING_LVGL'
],
CPPPATH
=
CPPPATH
)
Return
(
'group'
)
bsp/stm32/stm32f407-atk-explorer/applications/lvgl/demo/lv_demo_calendar.c
0 → 100644
浏览文件 @
8e50ef53
#include <lvgl.h>
#include "lv_demo_calendar.h"
#include <board.h>
#include <drv_lcd.h>
static
void
event_handler
(
lv_event_t
*
e
)
{
lv_event_code_t
code
=
lv_event_get_code
(
e
);
lv_obj_t
*
obj
=
lv_event_get_current_target
(
e
);
if
(
code
==
LV_EVENT_VALUE_CHANGED
)
{
lv_calendar_date_t
date
;
if
(
lv_calendar_get_pressed_date
(
obj
,
&
date
))
{
LV_LOG_USER
(
"Clicked date: %02d.%02d.%d"
,
date
.
day
,
date
.
month
,
date
.
year
);
}
}
}
void
lv_demo_calendar
(
void
)
{
lv_obj_t
*
calendar
=
lv_calendar_create
(
lv_scr_act
());
lv_obj_set_size
(
calendar
,
LCD_W
,
LCD_H
);
lv_obj_align
(
calendar
,
LV_ALIGN_CENTER
,
0
,
0
);
lv_obj_add_event_cb
(
calendar
,
event_handler
,
LV_EVENT_ALL
,
NULL
);
lv_calendar_set_today_date
(
calendar
,
2021
,
02
,
23
);
lv_calendar_set_showed_date
(
calendar
,
2021
,
02
);
/*Highlight a few days*/
static
lv_calendar_date_t
highlighted_days
[
3
];
/*Only its pointer will be saved so should be static*/
highlighted_days
[
0
].
year
=
2021
;
highlighted_days
[
0
].
month
=
02
;
highlighted_days
[
0
].
day
=
6
;
highlighted_days
[
1
].
year
=
2021
;
highlighted_days
[
1
].
month
=
02
;
highlighted_days
[
1
].
day
=
11
;
highlighted_days
[
2
].
year
=
2022
;
highlighted_days
[
2
].
month
=
02
;
highlighted_days
[
2
].
day
=
22
;
lv_calendar_set_highlighted_dates
(
calendar
,
highlighted_days
,
3
);
#if LV_USE_CALENDAR_HEADER_DROPDOWN
lv_calendar_header_dropdown_create
(
calendar
);
#elif LV_USE_CALENDAR_HEADER_ARROW
lv_calendar_header_arrow_create
(
calendar
);
#endif
lv_calendar_set_showed_date
(
calendar
,
2021
,
10
);
}
bsp/stm32/stm32f407-atk-explorer/applications/lvgl/demo/lv_demo_calendar.h
0 → 100644
浏览文件 @
8e50ef53
#ifndef __LV_DEMO_CALENDAR_H__
#define __LV_DEMO_CALENDAR_H__
void
lv_demo_calendar
(
void
);
#endif
bsp/stm32/stm32f407-atk-explorer/applications/lvgl/lv_conf.h
0 → 100644
浏览文件 @
8e50ef53
/*
* Copyright (c) 2006-2021, RT-Thread Development Team
*
* SPDX-License-Identifier: Apache-2.0
*
* Change Logs:
* Date Author Notes
* 2021-10-18 Meco Man First version
*/
#ifndef LV_CONF_H
#define LV_CONF_H
#define LV_COLOR_16_SWAP 0
#define LV_COLOR_DEPTH 16
#define LV_USE_PERF_MONITOR 1
#include <rtconfig.h>
#define LV_HOR_RES_MAX 800
#define LV_VER_RES_MAX 480
#define LV_USE_DEMO_RTT_MUSIC 1
#define LV_DEMO_RTT_MUSIC_AUTO_PLAY 1
#define LV_FONT_MONTSERRAT_12 1
#define LV_FONT_MONTSERRAT_16 1
#endif
bsp/stm32/stm32f407-atk-explorer/applications/lvgl/lv_demo.c
0 → 100644
浏览文件 @
8e50ef53
/*
* Copyright (c) 2006-2021, RT-Thread Development Team
*
* SPDX-License-Identifier: Apache-2.0
*
* Change Logs:
* Date Author Notes
* 2021-10-17 Meco Man First version
*/
#include <rtthread.h>
#include <lvgl.h>
#include <lv_port_indev.h>
#include <lv_demo_calendar.h>
#define DBG_TAG "LVGL.demo"
#define DBG_LVL DBG_INFO
#include <rtdbg.h>
#ifndef LV_THREAD_STACK_SIZE
#define LV_THREAD_STACK_SIZE 4096
#endif
#ifndef LV_THREAD_PRIO
#define LV_THREAD_PRIO (RT_THREAD_PRIORITY_MAX*2/3)
#endif
static
void
lvgl_thread
(
void
*
parameter
)
{
/*assign buttons to coordinates*/
const
lv_point_t
points_array
[]
=
{{
200
,
35
},{
0
,
0
},{
70
,
35
},{
0
,
0
}};
lv_indev_set_button_points
(
button_indev
,
points_array
);
/* display demo; you may replace with your LVGL application at here */
#ifdef PKG_USING_LV_MUSIC_DEMO
extern
void
lv_demo_music
(
void
);
lv_demo_music
();
#else
lv_demo_calendar
();
#endif
/* handle the tasks of LVGL */
while
(
1
)
{
lv_task_handler
();
rt_thread_mdelay
(
10
);
}
}
static
int
lvgl_demo_init
(
void
)
{
rt_thread_t
tid
;
rt_device_t
lcd
=
RT_NULL
;
lcd
=
rt_device_find
(
"lcd"
);
rt_device_init
(
lcd
);
tid
=
rt_thread_create
(
"LVGL"
,
lvgl_thread
,
RT_NULL
,
LV_THREAD_STACK_SIZE
,
LV_THREAD_PRIO
,
0
);
if
(
tid
==
RT_NULL
)
{
LOG_E
(
"Fail to create 'LVGL' thread"
);
}
rt_thread_startup
(
tid
);
return
0
;
}
INIT_APP_EXPORT
(
lvgl_demo_init
);
bsp/stm32/stm32f407-atk-explorer/applications/lvgl/lv_port_disp.c
0 → 100644
浏览文件 @
8e50ef53
/*
* Copyright (c) 2006-2021, RT-Thread Development Team
*
* SPDX-License-Identifier: Apache-2.0
*
* Change Logs:
* Date Author Notes
* 2021-10-18 Meco Man The first version
*/
#include <lvgl.h>
#include <board.h>
#include <drv_lcd.h>
// #define MY_DISP_HOR_RES LCD_W
// #define DISP_BUFFER_LINES 70
/*A static or global variable to store the buffers*/
static
lv_disp_draw_buf_t
disp_buf
;
/*Descriptor of a display driver*/
static
lv_disp_drv_t
disp_drv
;
/*Static or global buffer(s). The second buffer is optional*/
#if defined ( __ICCARM__ )
/*!< IAR Compiler */
#pragma location=0x68000000
lv_color_t
buf_1
[
LCD_H
*
LCD_W
];
#elif defined ( __CC_ARM )
/* MDK ARM Compiler */
__attribute__
((
at
(
0x68000000
)))
lv_color_t
buf_1
[
LCD_H
*
LCD_W
];
#elif defined ( __CLANG_ARM )
/* MDK ARM Compiler v6 */
__attribute__
((
section
(
".ARM.__at_0x68000000"
)))
lv_color_t
buf_1
[
LCD_H
*
LCD_W
];
#elif defined ( __GNUC__ )
/* GNU Compiler */
lv_color_t
buf_1
[
LCD_H
*
LCD_W
]
__attribute__
((
section
(
".MCUlcdgrambysram"
)));
#ifdef RT_USING_MEMHEAP_AS_HEAP
#error "You should modify this logic, such as use 'rt_malloc' to create lvgl buf"
#endif
#endif
/*Flush the content of the internal buffer the specific area on the display
*You can use DMA or any hardware acceleration to do this operation in the background but
*'lv_disp_flush_ready()' has to be called when finished.*/
static
void
disp_flush
(
lv_disp_drv_t
*
disp_drv
,
const
lv_area_t
*
area
,
lv_color_t
*
color_p
)
{
/* color_p is a buffer pointer; the buffer is provided by LVGL */
lcd_fill_array
(
area
->
x1
,
area
->
y1
,
area
->
x2
,
area
->
y2
,
color_p
);
/*IMPORTANT!!!
*Inform the graphics library that you are ready with the flushing*/
lv_disp_flush_ready
(
disp_drv
);
}
void
lv_port_disp_init
(
void
)
{
/*Initialize `disp_buf` with the buffer(s). With only one buffer use NULL instead buf_2 */
lv_disp_draw_buf_init
(
&
disp_buf
,
buf_1
,
NULL
,
LCD_H
*
LCD_W
);
lv_disp_drv_init
(
&
disp_drv
);
/*Basic initialization*/
/*Set the resolution of the display*/
disp_drv
.
hor_res
=
LCD_W
;
disp_drv
.
ver_res
=
LCD_H
;
/*Set a display buffer*/
disp_drv
.
draw_buf
=
&
disp_buf
;
/*Used to copy the buffer's content to the display*/
disp_drv
.
flush_cb
=
disp_flush
;
/*Finally register the driver*/
lv_disp_drv_register
(
&
disp_drv
);
}
bsp/stm32/stm32f407-atk-explorer/applications/lvgl/lv_port_disp.h
0 → 100644
浏览文件 @
8e50ef53
/*
* Copyright (c) 2006-2021, RT-Thread Development Team
*
* SPDX-License-Identifier: Apache-2.0
*
* Change Logs:
* Date Author Notes
* 2021-10-18 Meco Man The first version
*/
#ifndef LV_PORT_DISP_H
#define LV_PORT_DISP_H
#ifdef __cplusplus
extern
"C"
{
#endif
void
lv_port_disp_init
(
void
);
#ifdef __cplusplus
}
/*extern "C"*/
#endif
#endif
bsp/stm32/stm32f407-atk-explorer/applications/lvgl/lv_port_indev.c
0 → 100644
浏览文件 @
8e50ef53
/*
* Copyright (c) 2006-2021, RT-Thread Development Team
*
* SPDX-License-Identifier: Apache-2.0
*
* Change Logs:
* Date Author Notes
* 2021-10-18 Meco Man The first version
*/
#include <lvgl.h>
#include <stdbool.h>
#include <rtdevice.h>
#include <board.h>
#include <drv_lcd.h>
static
lv_indev_state_t
last_state
=
LV_INDEV_STATE_REL
;
static
rt_int16_t
last_x
=
0
;
static
rt_int16_t
last_y
=
0
;
static
void
input_read
(
lv_indev_drv_t
*
indev_drv
,
lv_indev_data_t
*
data
)
{
data
->
point
.
x
=
last_x
;
data
->
point
.
y
=
last_y
;
data
->
state
=
last_state
;
}
void
lv_port_indev_input
(
rt_int16_t
x
,
rt_int16_t
y
,
lv_indev_state_t
state
)
{
last_state
=
state
;
last_x
=
LCD_W
-
y
;
last_y
=
x
;
}
lv_indev_t
*
button_indev
;
void
lv_port_indev_init
(
void
)
{
static
lv_indev_drv_t
indev_drv
;
lv_indev_drv_init
(
&
indev_drv
);
/*Basic initialization*/
indev_drv
.
type
=
LV_INDEV_TYPE_POINTER
;
indev_drv
.
read_cb
=
input_read
;
/*Register the driver in LVGL and save the created input device object*/
button_indev
=
lv_indev_drv_register
(
&
indev_drv
);
}
bsp/stm32/stm32f407-atk-explorer/applications/lvgl/lv_port_indev.h
0 → 100644
浏览文件 @
8e50ef53
/*
* Copyright (c) 2006-2021, RT-Thread Development Team
*
* SPDX-License-Identifier: Apache-2.0
*
* Change Logs:
* Date Author Notes
* 2021-10-18 Meco Man The first version
*/
#ifndef LV_PORT_INDEV_H
#define LV_PORT_INDEV_H
#ifdef __cplusplus
extern
"C"
{
#endif
#include <lv_hal_indev.h>
extern
lv_indev_t
*
button_indev
;
void
lv_port_indev_init
(
void
);
void
lv_port_indev_input
(
rt_int16_t
x
,
rt_int16_t
y
,
lv_indev_state_t
state
);
#ifdef __cplusplus
}
/*extern "C"*/
#endif
#endif
bsp/stm32/stm32f407-atk-explorer/board/CubeMX_Config/Src/stm32f4xx_hal_msp.c
浏览文件 @
8e50ef53
...
...
@@ -953,6 +953,7 @@ static void HAL_FSMC_MspInit(void){
PD4 ------> FSMC_NOE
PD5 ------> FSMC_NWE
PG10 ------> FSMC_NE3
PG12 ------> FSMC_NE4
PE0 ------> FSMC_NBL0
PE1 ------> FSMC_NBL1
*/
...
...
@@ -966,7 +967,7 @@ static void HAL_FSMC_MspInit(void){
HAL_GPIO_Init
(
GPIOF
,
&
GPIO_InitStruct
);
GPIO_InitStruct
.
Pin
=
GPIO_PIN_0
|
GPIO_PIN_1
|
GPIO_PIN_2
|
GPIO_PIN_3
|
GPIO_PIN_4
|
GPIO_PIN_5
|
GPIO_PIN_10
;
|
GPIO_PIN_4
|
GPIO_PIN_5
|
GPIO_PIN_10
|
GPIO_PIN_12
;
GPIO_InitStruct
.
Mode
=
GPIO_MODE_AF_PP
;
GPIO_InitStruct
.
Pull
=
GPIO_NOPULL
;
GPIO_InitStruct
.
Speed
=
GPIO_SPEED_FREQ_VERY_HIGH
;
...
...
@@ -1058,6 +1059,7 @@ static void HAL_FSMC_MspDeInit(void){
PD4 ------> FSMC_NOE
PD5 ------> FSMC_NWE
PG10 ------> FSMC_NE3
PG12 ------> FSMC_NE4
PE0 ------> FSMC_NBL0
PE1 ------> FSMC_NBL1
*/
...
...
@@ -1066,7 +1068,7 @@ static void HAL_FSMC_MspDeInit(void){
|
GPIO_PIN_14
|
GPIO_PIN_15
);
HAL_GPIO_DeInit
(
GPIOG
,
GPIO_PIN_0
|
GPIO_PIN_1
|
GPIO_PIN_2
|
GPIO_PIN_3
|
GPIO_PIN_4
|
GPIO_PIN_5
|
GPIO_PIN_10
);
|
GPIO_PIN_4
|
GPIO_PIN_5
|
GPIO_PIN_10
|
GPIO_PIN_12
);
HAL_GPIO_DeInit
(
GPIOE
,
GPIO_PIN_7
|
GPIO_PIN_8
|
GPIO_PIN_9
|
GPIO_PIN_10
|
GPIO_PIN_11
|
GPIO_PIN_12
|
GPIO_PIN_13
|
GPIO_PIN_14
...
...
bsp/stm32/stm32f407-atk-explorer/board/Kconfig
浏览文件 @
8e50ef53
...
...
@@ -27,13 +27,33 @@ menu "Onboard Peripheral Drivers"
select BSP_USING_UART
select BSP_USING_UART3
default n
config BSP_USING_SRAM
bool "Enable SRAM"
select BSP_USING_EXT_FMC_IO
select BSP_USING_FMC
default n
config BSP_USING_MCU_LCD
bool "Enable ATK LCD"
select BSP_USING_SDRAM
default n
if BSP_USING_MCU_LCD
config BSP_USING_MCU_LCD_TEST
bool "Enable lcd fill test"
default y
endif
config BSP_USING_TOUCH
bool "Use LCD TOUCH"
select BSP_USING_I2C2
default n
if BSP_USING_TOUCH
config BSP_TOUCH_INT_PIN
int "Touch interrupt pin, PB1"
default 17
endif
config BSP_USING_SPI_FLASH
bool "Enable SPI FLASH (W25Q128 spi1)"
select BSP_USING_SPI
...
...
@@ -46,7 +66,7 @@ menu "Onboard Peripheral Drivers"
bool "Enable I2C EEPROM (i2c1)"
select BSP_USING_I2C1
default n
config BSP_USING_ETH
bool "Enable Ethernet"
default n
...
...
@@ -96,7 +116,7 @@ menu "Onboard Peripheral Drivers"
select RT_USING_DFS
select RT_USING_DFS_ROMFS
select RT_USING_MTD_NOR
select BSP_USING_SPI_FLASH
select BSP_USING_SPI_FLASH
select BSP_USING_FS
select PKG_USING_FAL
select FAL_USING_AUTO_INIT
...
...
@@ -155,7 +175,7 @@ menu "On-chip Peripheral Drivers"
config BSP_UART3_RX_USING_DMA
bool "Enable UART3 RX DMA"
depends on BSP_USING_UART3 && RT_SERIAL_USING_DMA
default n
default n
config BSP_UART3_TX_USING_DMA
bool "Enable UART3 TX DMA"
...
...
@@ -169,7 +189,7 @@ menu "On-chip Peripheral Drivers"
config BSP_UART4_RX_USING_DMA
bool "Enable UART4 RX DMA"
depends on BSP_USING_UART4 && RT_SERIAL_USING_DMA
default n
default n
config BSP_UART4_TX_USING_DMA
bool "Enable UART4 TX DMA"
...
...
@@ -183,7 +203,7 @@ menu "On-chip Peripheral Drivers"
config BSP_UART5_RX_USING_DMA
bool "Enable UART5 RX DMA"
depends on BSP_USING_UART5 && RT_SERIAL_USING_DMA
default n
default n
config BSP_UART5_TX_USING_DMA
bool "Enable UART5 TX DMA"
...
...
@@ -197,7 +217,7 @@ menu "On-chip Peripheral Drivers"
config BSP_UART6_RX_USING_DMA
bool "Enable UART6 RX DMA"
depends on BSP_USING_UART6 && RT_SERIAL_USING_DMA
default n
default n
config BSP_UART6_TX_USING_DMA
bool "Enable UART6 TX DMA"
...
...
@@ -255,7 +275,7 @@ menu "On-chip Peripheral Drivers"
bool "Enable SPI1 TX DMA"
depends on BSP_USING_SPI1
default n
config BSP_SPI1_RX_USING_DMA
bool "Enable SPI1 RX DMA"
depends on BSP_USING_SPI1
...
...
@@ -270,7 +290,7 @@ menu "On-chip Peripheral Drivers"
bool "Enable SPI2 TX DMA"
depends on BSP_USING_SPI2
default n
config BSP_SPI2_RX_USING_DMA
bool "Enable SPI2 RX DMA"
depends on BSP_USING_SPI2
...
...
@@ -305,6 +325,23 @@ menu "On-chip Peripheral Drivers"
default 25
endif
menuconfig BSP_USING_I2C2
bool "Enable LCD Touch BUS (software simulation)"
default y
select RT_USING_I2C
select RT_USING_I2C_BITOPS
select RT_USING_PIN
if BSP_USING_I2C2
config BSP_I2C2_SCL_PIN
int "i2c2 scl pin number, PB0"
range 0 143
default 16
config BSP_I2C2_SDA_PIN
int "I2C2 sda pin number, PF11"
range 0 143
default 91
endif
menuconfig BSP_USING_DAC
bool "Enable DAC"
default n
...
...
@@ -373,7 +410,7 @@ menu "On-chip Peripheral Drivers"
default n
endif
config BSP_USING_EXT_FMC_IO
bool
default n
...
...
@@ -382,7 +419,7 @@ menu "On-chip Peripheral Drivers"
bool
default n
source "../libraries/HAL_Drivers/Kconfig"
endmenu
menu "Board extended module Drivers"
...
...
bsp/stm32/stm32f407-atk-explorer/board/SConscript
浏览文件 @
8e50ef53
...
...
@@ -11,6 +11,9 @@ src = Split('''
board.c
CubeMX_Config/Src/stm32f4xx_hal_msp.c
'''
)
path
=
[
cwd
]
path
+=
[
cwd
+
'/CubeMX_Config/Inc'
]
path
+=
[
cwd
+
'/ports'
]
if
GetDepend
([
'BSP_USING_ETH'
]):
src
+=
Glob
(
'ports/phy_reset.c'
)
...
...
@@ -26,9 +29,12 @@ if GetDepend(['BSP_USING_FS']):
if
GetDepend
([
'BSP_USING_SRAM'
]):
src
+=
Glob
(
'ports/drv_sram.c'
)
path
=
[
cwd
]
path
+=
[
cwd
+
'/CubeMX_Config/Inc'
]
path
+=
[
cwd
+
'/ports'
]
if
GetDepend
([
'BSP_USING_MCU_LCD'
]):
src
+=
Glob
(
'ports/drv_lcd.c'
)
if
GetDepend
([
'BSP_USING_TOUCH'
]):
src
+=
Glob
(
'ports/touch/*.c'
)
path
+=
[
cwd
+
'/ports/touch'
]
startup_path_prefix
=
SDK_LIB
...
...
bsp/stm32/stm32f407-atk-explorer/board/linker_scripts/link.lds
浏览文件 @
8e50ef53
...
...
@@ -10,6 +10,7 @@ MEMORY
CODE (rx) : ORIGIN = 0x08000000, LENGTH = 1024k /* 1024KB flash */
RAM1 (rw) : ORIGIN = 0x20000000, LENGTH = 128k /* 128K sram */
RAM2 (rw) : ORIGIN = 0x10000000, LENGTH = 64k /* 64K sram */
MCUlcdgrambysram (rw) : ORIGIN =0x68000000, LENGTH = 1024k
}
ENTRY(Reset_Handler)
_system_stack_size = 0x400;
...
...
@@ -54,9 +55,9 @@ SECTIONS
KEEP (*(SORT(.init_array.*)))
KEEP (*(.init_array))
PROVIDE(__ctors_end__ = .);
. = ALIGN(4);
_etext = .;
} > CODE = 0
...
...
@@ -93,7 +94,7 @@ SECTIONS
_edata = . ;
} >RAM1
.stack :
.stack :
{
. = ALIGN(4);
_sstack = .;
...
...
@@ -116,11 +117,20 @@ SECTIONS
. = ALIGN(4);
/* This is used by the startup in order to initialize the .bss secion */
_ebss = . ;
*(.bss.init)
} > RAM1
__bss_end = .;
.MCUlcdgrambysram (NOLOAD) : ALIGN(4)
{
. = ALIGN(4);
*(.MCUlcdgrambysram)
*(.MCUlcdgrambysram.*)
. = ALIGN(4);
__MCUlcdgrambysram_free__ = .;
} > MCUlcdgrambysram
_end = .;
/* Stabs debugging sections. */
...
...
bsp/stm32/stm32f407-atk-explorer/board/ports/drv_lcd.c
0 → 100644
浏览文件 @
8e50ef53
此差异已折叠。
点击以展开。
bsp/stm32/stm32f407-atk-explorer/board/ports/drv_lcd.h
0 → 100644
浏览文件 @
8e50ef53
/*
* Copyright (c) 2006-2021, RT-Thread Development Team
*
* SPDX-License-Identifier: Apache-2.0
*
* Change Logs:
* Date Author Notes
* 2021-12-28 unknow copy by STemwin
*/
#ifndef __DRV_LCD_H
#define __DRV_LCD_H
#include <rtthread.h>
#include "rtdevice.h"
#include <drv_common.h>
#define LCD_W 800
#define LCD_H 480
//LCD重要参数集
typedef
struct
{
uint16_t
width
;
//LCD 宽度
uint16_t
height
;
//LCD 高度
uint16_t
id
;
//LCD ID
uint8_t
dir
;
//横屏还是竖屏控制:0,竖屏;1,横屏。
uint16_t
wramcmd
;
//开始写gram指令
uint16_t
setxcmd
;
//设置x坐标指令
uint16_t
setycmd
;
//设置y坐标指令
}
_lcd_dev
;
//LCD参数
extern
_lcd_dev
lcddev
;
//管理LCD重要参数
typedef
struct
{
__IO
uint16_t
REG
;
__IO
uint16_t
RAM
;
}
LCD_CONTROLLER_TypeDef
;
//扫描方向定义
#define L2R_U2D 0 //从左到右,从上到下
#define L2R_D2U 1 //从左到右,从下到上
#define R2L_U2D 2 //从右到左,从上到下
#define R2L_D2U 3 //从右到左,从下到上
#define U2D_L2R 4 //从上到下,从左到右
#define U2D_R2L 5 //从上到下,从右到左
#define D2U_L2R 6 //从下到上,从左到右
#define D2U_R2L 7 //从下到上,从右到左
#define DFT_SCAN_DIR L2R_U2D //默认的扫描方向
//LCD分辨率设置
#define SSD_HOR_RESOLUTION 800 //LCD水平分辨率
#define SSD_VER_RESOLUTION 480 //LCD垂直分辨率
//LCD驱动参数设置
#define SSD_HOR_PULSE_WIDTH 1 //水平脉宽
#define SSD_HOR_BACK_PORCH 46 //水平前廊
#define SSD_HOR_FRONT_PORCH 210 //水平后廊
#define SSD_VER_PULSE_WIDTH 1 //垂直脉宽
#define SSD_VER_BACK_PORCH 23 //垂直前廊
#define SSD_VER_FRONT_PORCH 22 //垂直前廊
//如下几个参数,自动计算
#define SSD_HT (SSD_HOR_RESOLUTION+SSD_HOR_BACK_PORCH+SSD_HOR_FRONT_PORCH)
#define SSD_HPS (SSD_HOR_BACK_PORCH)
#define SSD_VT (SSD_VER_RESOLUTION+SSD_VER_BACK_PORCH+SSD_VER_FRONT_PORCH)
#define SSD_VPS (SSD_VER_BACK_PORCH)
void
lcd_fill_array
(
rt_uint16_t
x_start
,
rt_uint16_t
y_start
,
rt_uint16_t
x_end
,
rt_uint16_t
y_end
,
void
*
pcolor
);
#endif
bsp/stm32/stm32f407-atk-explorer/board/ports/touch/drv_touch.c
0 → 100644
浏览文件 @
8e50ef53
/*
* Copyright (c) 2006-2021, RT-Thread Development Team
*
* SPDX-License-Identifier: Apache-2.0
*
* Change Logs:
* Date Author Notes
* 2018-02-08 Zhangyihong the first version
*/
#include "drv_touch.h"
#include <string.h>
#ifdef BSP_USING_TOUCH
#ifdef PKG_USING_GUIENGINE
#include <rtgui/event.h>
#include <rtgui/rtgui_server.h>
#elif defined(PKG_USING_LITTLEVGL2RTT)
#include <littlevgl2rtt.h>
#elif defined(PKG_USING_LVGL)
#include <lvgl.h>
#include <lv_port_indev.h>
static
rt_bool_t
touch_down
=
RT_FALSE
;
#endif
#define BSP_TOUCH_SAMPLE_HZ (50)
#define DBG_ENABLE
#define DBG_SECTION_NAME "TOUCH"
#define DBG_LEVEL DBG_INFO
#define DBG_COLOR
#include <rtdbg.h>
static
rt_list_t
driver_list
;
void
rt_touch_drivers_register
(
touch_drv_t
drv
)
{
rt_list_insert_before
(
&
driver_list
,
&
drv
->
list
);
}
static
void
post_down_event
(
rt_uint16_t
x
,
rt_uint16_t
y
,
rt_tick_t
ts
)
{
#ifdef PKG_USING_GUIENGINE
struct
rtgui_event_mouse
emouse
;
emouse
.
parent
.
sender
=
RT_NULL
;
emouse
.
wid
=
RT_NULL
;
emouse
.
parent
.
type
=
RTGUI_EVENT_MOUSE_BUTTON
;
emouse
.
button
=
RTGUI_MOUSE_BUTTON_LEFT
|
RTGUI_MOUSE_BUTTON_DOWN
;
emouse
.
x
=
x
;
emouse
.
y
=
y
;
emouse
.
ts
=
rt_tick_get
();
emouse
.
id
=
ts
;
rtgui_server_post_event
(
&
emouse
.
parent
,
sizeof
(
emouse
));
#elif defined(PKG_USING_LITTLEVGL2RTT)
littlevgl2rtt_send_input_event
(
x
,
y
,
LITTLEVGL2RTT_INPUT_DOWN
);
#elif defined(PKG_USING_LVGL)
touch_down
=
RT_TRUE
;
lv_port_indev_input
(
x
,
y
,
(
touch_down
==
RT_TRUE
)
?
LV_INDEV_STATE_PR
:
LV_INDEV_STATE_REL
);
#endif
}
static
void
post_motion_event
(
rt_uint16_t
x
,
rt_uint16_t
y
,
rt_tick_t
ts
)
{
#ifdef PKG_USING_GUIENGINE
struct
rtgui_event_mouse
emouse
;
emouse
.
parent
.
sender
=
RT_NULL
;
emouse
.
wid
=
RT_NULL
;
emouse
.
button
=
RTGUI_MOUSE_BUTTON_LEFT
|
RTGUI_MOUSE_BUTTON_DOWN
;
emouse
.
parent
.
type
=
RTGUI_EVENT_MOUSE_MOTION
;
emouse
.
x
=
x
;
emouse
.
y
=
y
;
emouse
.
ts
=
rt_tick_get
();
emouse
.
id
=
ts
;
rtgui_server_post_event
(
&
emouse
.
parent
,
sizeof
(
emouse
));
#elif defined(PKG_USING_LITTLEVGL2RTT)
littlevgl2rtt_send_input_event
(
x
,
y
,
LITTLEVGL2RTT_INPUT_MOVE
);
#elif defined(PKG_USING_LVGL)
lv_port_indev_input
(
x
,
y
,
(
touch_down
==
RT_TRUE
)
?
LV_INDEV_STATE_PR
:
LV_INDEV_STATE_REL
);
#endif
}
static
void
post_up_event
(
rt_uint16_t
x
,
rt_uint16_t
y
,
rt_tick_t
ts
)
{
#ifdef PKG_USING_GUIENGINE
struct
rtgui_event_mouse
emouse
;
emouse
.
parent
.
sender
=
RT_NULL
;
emouse
.
wid
=
RT_NULL
;
emouse
.
parent
.
type
=
RTGUI_EVENT_MOUSE_BUTTON
;
emouse
.
button
=
RTGUI_MOUSE_BUTTON_LEFT
|
RTGUI_MOUSE_BUTTON_UP
;
emouse
.
x
=
x
;
emouse
.
y
=
y
;
emouse
.
ts
=
rt_tick_get
();
emouse
.
id
=
ts
;
rtgui_server_post_event
(
&
emouse
.
parent
,
sizeof
(
emouse
));
#elif defined(PKG_USING_LITTLEVGL2RTT)
littlevgl2rtt_send_input_event
(
x
,
y
,
LITTLEVGL2RTT_INPUT_MOVE
);
#elif defined(PKG_USING_LVGL)
touch_down
=
RT_FALSE
;
lv_port_indev_input
(
x
,
y
,
(
touch_down
==
RT_TRUE
)
?
LV_INDEV_STATE_PR
:
LV_INDEV_STATE_REL
);
#endif
}
static
void
touch_thread_entry
(
void
*
parameter
)
{
touch_drv_t
touch
=
(
touch_drv_t
)
parameter
;
struct
touch_message
msg
;
rt_tick_t
emouse_id
=
0
;
touch
->
ops
->
isr_enable
(
RT_TRUE
);
while
(
1
)
{
if
(
rt_sem_take
(
touch
->
isr_sem
,
10
)
!=
RT_EOK
)
{
continue
;
}
while
(
touch
->
ops
->
read_point
(
&
msg
)
==
RT_EOK
)
{
switch
(
msg
.
event
)
{
case
TOUCH_EVENT_UP
:
post_up_event
(
msg
.
x
,
msg
.
y
,
emouse_id
);
break
;
case
TOUCH_EVENT_DOWN
:
emouse_id
=
rt_tick_get
();
post_down_event
(
msg
.
x
,
msg
.
y
,
emouse_id
);
break
;
case
TOUCH_EVENT_MOVE
:
post_motion_event
(
msg
.
x
,
msg
.
y
,
emouse_id
);
break
;
default:
break
;
}
rt_thread_delay
(
RT_TICK_PER_SECOND
/
BSP_TOUCH_SAMPLE_HZ
);
}
touch
->
ops
->
isr_enable
(
RT_TRUE
);
}
}
static
int
rt_touch_driver_init
(
void
)
{
rt_list_init
(
&
driver_list
);
return
0
;
}
INIT_BOARD_EXPORT
(
rt_touch_driver_init
);
static
struct
rt_i2c_bus_device
*
i2c_bus
=
RT_NULL
;
static
int
rt_touch_thread_init
(
void
)
{
rt_list_t
*
l
;
touch_drv_t
current_driver
;
rt_thread_t
tid
=
RT_NULL
;
i2c_bus
=
(
struct
rt_i2c_bus_device
*
)
rt_device_find
(
"i2c2"
);
RT_ASSERT
(
i2c_bus
);
current_driver
=
RT_NULL
;
if
(
rt_device_open
((
rt_device_t
)
i2c_bus
,
RT_DEVICE_OFLAG_RDWR
)
!=
RT_EOK
)
return
-
1
;
for
(
l
=
driver_list
.
next
;
l
!=
&
driver_list
;
l
=
l
->
next
)
{
if
(
rt_list_entry
(
l
,
struct
touch_drivers
,
list
)
->
probe
(
i2c_bus
))
{
current_driver
=
rt_list_entry
(
l
,
struct
touch_drivers
,
list
);
break
;
}
}
if
(
current_driver
==
RT_NULL
)
{
LOG_E
(
"no touch screen or do not have driver"
);
rt_device_close
((
rt_device_t
)
i2c_bus
);
return
-
1
;
}
current_driver
->
ops
->
init
(
i2c_bus
);
LOG_I
(
"touch screen found driver"
);
tid
=
rt_thread_create
(
"touch"
,
touch_thread_entry
,
current_driver
,
2048
,
27
,
20
);
if
(
tid
==
RT_NULL
)
{
current_driver
->
ops
->
deinit
();
rt_device_close
((
rt_device_t
)
i2c_bus
);
return
-
1
;
}
rt_thread_startup
(
tid
);
return
0
;
}
static
void
touch_init_thread_entry
(
void
*
parameter
)
{
rt_touch_thread_init
();
}
static
int
touc_bg_init
(
void
)
{
rt_thread_t
tid
=
RT_NULL
;
tid
=
rt_thread_create
(
"touchi"
,
touch_init_thread_entry
,
RT_NULL
,
2048
,
28
,
20
);
if
(
tid
==
RT_NULL
)
{
return
-
1
;
}
rt_thread_startup
(
tid
);
return
0
;
}
INIT_APP_EXPORT
(
touc_bg_init
);
#endif
bsp/stm32/stm32f407-atk-explorer/board/ports/touch/drv_touch.h
0 → 100644
浏览文件 @
8e50ef53
/*
* Copyright (c) 2006-2021, RT-Thread Development Team
*
* SPDX-License-Identifier: Apache-2.0
*
* Change Logs:
* Date Author Notes
* 2018-02-08 Zhangyihong the first version
*/
#ifndef __DRV_TOUCH_H__
#define __DRV_TOUCH_H__
#include "rtthread.h"
#include "rtdevice.h"
#define TOUCH_DBG_LEVEL DBG_INFO
#define IIC_RETRY_NUM 2
#define TOUCH_EVENT_UP (0x01)
#define TOUCH_EVENT_DOWN (0x02)
#define TOUCH_EVENT_MOVE (0x03)
#define TOUCH_EVENT_NONE (0x80)
struct
touch_message
{
rt_uint16_t
x
;
rt_uint16_t
y
;
rt_uint8_t
event
;
};
typedef
struct
touch_message
*
touch_msg_t
;
struct
touch_ops
{
void
(
*
isr_enable
)(
rt_bool_t
);
rt_err_t
(
*
read_point
)(
touch_msg_t
);
void
(
*
init
)(
struct
rt_i2c_bus_device
*
);
void
(
*
deinit
)(
void
);
};
typedef
struct
touch_ops
*
touch_ops_t
;
struct
touch_drivers
{
rt_list_t
list
;
unsigned
char
address
;
rt_bool_t
(
*
probe
)(
struct
rt_i2c_bus_device
*
i2c_bus
);
rt_sem_t
isr_sem
;
touch_ops_t
ops
;
void
*
user_data
;
};
typedef
struct
touch_drivers
*
touch_drv_t
;
extern
void
rt_touch_drivers_register
(
touch_drv_t
drv
);
#endif
bsp/stm32/stm32f407-atk-explorer/board/ports/touch/drv_touch_ft.c
0 → 100644
浏览文件 @
8e50ef53
/*
* Copyright (c) 2006-2021, RT-Thread Development Team
*
* SPDX-License-Identifier: Apache-2.0
*
* Change Logs:
* Date Author Notes
* 2017-08-08 Yang the first version
* 2019-04-23 WillianChan porting to ft6206
* 2021-12-28 xiangxistu copy by stm32f429-atk-apollo
* 2021-04-23 xiangxistu porting to GT9147
*/
#include <rtthread.h>
#include <rthw.h>
#include <rtdevice.h>
#include "drv_touch.h"
#include <stdint.h>
#include <string.h>
#ifdef BSP_USING_TOUCH
#define DBG_ENABLE
#define DBG_SECTION_NAME "TOUCH.ft"
#define DBG_LEVEL TOUCH_DBG_LEVEL
#define DBG_COLOR
#include <rtdbg.h>
static
struct
rt_i2c_bus_device
*
ft_i2c_bus
;
static
struct
touch_drivers
ft_driver
;
static
int
ft_read
(
struct
rt_i2c_bus_device
*
i2c_bus
,
rt_uint16_t
addr
,
rt_uint8_t
*
buffer
,
rt_size_t
length
)
{
int
ret
=
-
1
;
int
retries
=
0
;
rt_uint8_t
register_16
[
3
];
register_16
[
0
]
=
addr
>>
8
;
register_16
[
1
]
=
addr
&
0xff
;
struct
rt_i2c_msg
msgs
[]
=
{
{
.
addr
=
ft_driver
.
address
,
.
flags
=
RT_I2C_WR
,
.
len
=
2
,
.
buf
=
register_16
,
},
{
.
addr
=
ft_driver
.
address
,
.
flags
=
RT_I2C_RD
,
.
len
=
length
,
.
buf
=
buffer
,
},
};
while
(
retries
<
IIC_RETRY_NUM
)
{
ret
=
rt_i2c_transfer
(
i2c_bus
,
msgs
,
sizeof
(
msgs
)
/
sizeof
(
struct
rt_i2c_msg
));
if
(
ret
==
2
)
break
;
retries
++
;
}
if
(
retries
>=
IIC_RETRY_NUM
)
{
LOG_E
(
"%s i2c read error: %d"
,
__func__
,
ret
);
return
-
1
;
}
return
ret
;
}
static
void
ft_write
(
struct
rt_i2c_bus_device
*
i2c_bus
,
rt_uint16_t
addr
,
rt_uint8_t
*
buffer
,
rt_size_t
length
)
{
rt_uint8_t
*
send_buffer
=
rt_malloc
(
length
+
2
);
RT_ASSERT
(
send_buffer
);
send_buffer
[
0
]
=
addr
>>
8
;;
send_buffer
[
1
]
=
addr
&
0xff
;
memcpy
(
send_buffer
+
2
,
buffer
,
length
);
struct
rt_i2c_msg
msgs
[]
=
{
{
.
addr
=
ft_driver
.
address
,
.
flags
=
RT_I2C_WR
,
.
len
=
length
+
2
,
.
buf
=
send_buffer
,
}
};
length
=
rt_i2c_transfer
(
i2c_bus
,
msgs
,
1
);
rt_free
(
send_buffer
);
send_buffer
=
RT_NULL
;
}
static
void
ft_isr_enable
(
rt_bool_t
enable
)
{
rt_pin_irq_enable
(
BSP_TOUCH_INT_PIN
,
enable
);
}
static
void
ft_touch_isr
(
void
*
parameter
)
{
ft_isr_enable
(
RT_FALSE
);
rt_sem_release
(
ft_driver
.
isr_sem
);
}
static
rt_err_t
ft_read_point
(
touch_msg_t
msg
)
{
int
ret
=
-
1
;
uint8_t
state
=
0
;
uint8_t
clear_state
=
0
;
static
uint8_t
s_tp_down
=
0
;
uint8_t
point
[
5
];
ret
=
ft_read
(
ft_i2c_bus
,
0X814E
,
&
state
,
1
);
if
(
ret
<
0
)
{
return
RT_ERROR
;
}
/* According this state, to get point info */
if
(
state
&
0X80
&&
((
state
&
0XF
)
<
6
))
{
clear_state
=
0
;
ft_write
(
ft_i2c_bus
,
0X814E
,
&
clear_state
,
1
);
}
else
{
if
(
s_tp_down
)
{
s_tp_down
=
0
;
msg
->
event
=
TOUCH_EVENT_UP
;
return
RT_EOK
;
}
msg
->
event
=
TOUCH_EVENT_NONE
;
return
RT_ERROR
;
}
/* Only support one point */
ret
=
ft_read
(
ft_i2c_bus
,
0X8150
,
point
,
4
);
if
(
ret
<
0
)
{
return
RT_ERROR
;
}
msg
->
x
=
(
point
[
1
]
&
0x0F
)
<<
8
|
point
[
0
];
msg
->
y
=
(
point
[
3
]
&
0x0F
)
<<
8
|
point
[
2
];
LOG_D
(
"x:%03d, y:%03d"
,
msg
->
x
,
msg
->
y
);
if
(
s_tp_down
)
{
msg
->
event
=
TOUCH_EVENT_MOVE
;
return
RT_EOK
;
}
msg
->
event
=
TOUCH_EVENT_DOWN
;
s_tp_down
=
1
;
return
RT_EOK
;
}
static
void
ft_init
(
struct
rt_i2c_bus_device
*
i2c_bus
)
{
if
(
ft_i2c_bus
==
RT_NULL
)
{
ft_i2c_bus
=
i2c_bus
;
}
ft_driver
.
isr_sem
=
rt_sem_create
(
"ft"
,
0
,
RT_IPC_FLAG_FIFO
);
RT_ASSERT
(
ft_driver
.
isr_sem
);
rt_pin_mode
(
BSP_TOUCH_INT_PIN
,
PIN_MODE_INPUT_PULLUP
);
rt_pin_attach_irq
(
BSP_TOUCH_INT_PIN
,
PIN_IRQ_MODE_FALLING
,
ft_touch_isr
,
RT_NULL
);
rt_thread_mdelay
(
200
);
}
static
void
ft_deinit
(
void
)
{
if
(
ft_driver
.
isr_sem
)
{
rt_sem_delete
(
ft_driver
.
isr_sem
);
ft_driver
.
isr_sem
=
RT_NULL
;
}
}
struct
touch_ops
ft_ops
=
{
ft_isr_enable
,
ft_read_point
,
ft_init
,
ft_deinit
,
};
static
rt_bool_t
ft_probe
(
struct
rt_i2c_bus_device
*
i2c_bus
)
{
#define TOUCH_CID_SIZE 4
int
err
=
0
;
uint8_t
cid
[
TOUCH_CID_SIZE
+
1
]
=
{
0
};
ft_i2c_bus
=
i2c_bus
;
/* FT6206 Chip identification register address is 0xA8
*
* GT9147 -> 0X8140, CID
*
**/
rt_memset
(
cid
,
0
,
TOUCH_CID_SIZE
+
1
);
err
=
ft_read
(
ft_i2c_bus
,
0X8140
,
(
uint8_t
*
)
&
cid
,
TOUCH_CID_SIZE
);
if
(
err
<
0
)
{
LOG_E
(
"%s failed: %d"
,
__func__
,
err
);
return
RT_FALSE
;
}
LOG_I
(
"touch CID:0x%c%c%c%c"
,
cid
[
0
],
cid
[
1
],
cid
[
2
],
cid
[
3
]);
/* FT6206 ID Value is 0x11
* GT9147 ID will be 0x9147
*/
if
(
rt_strncmp
((
char
*
)
cid
,
"9147"
,
TOUCH_CID_SIZE
)
==
0x0
)
{
return
RT_TRUE
;
}
return
RT_FALSE
;
}
int
ft_driver_register
(
void
)
{
/* TouchScreen FT6206 Slave I2C address is 0x54
* 0x54 << 1 = 0x2A
* 0x5D, 0x14 ------> GT9147
*/
ft_driver
.
address
=
0x14
;
ft_driver
.
probe
=
ft_probe
;
ft_driver
.
ops
=
&
ft_ops
;
ft_driver
.
user_data
=
RT_NULL
;
rt_touch_drivers_register
(
&
ft_driver
);
return
0
;
}
INIT_DEVICE_EXPORT
(
ft_driver_register
);
#endif
bsp/stm32/stm32f407-atk-explorer/rtconfig.h
浏览文件 @
8e50ef53
#ifndef RT_CONFIG_H__
#define RT_CONFIG_H__
/* Generated by Kconfiglib (https://github.com/ulfalizer/Kconfiglib) */
/* Automatically generated file; DO NOT EDIT. */
/* RT-Thread Configuration */
/* RT-Thread Kernel */
...
...
@@ -18,7 +19,6 @@
/* kservice optimization */
/* end of kservice optimization */
#define RT_DEBUG
#define RT_DEBUG_COLOR
...
...
@@ -29,7 +29,6 @@
#define RT_USING_EVENT
#define RT_USING_MAILBOX
#define RT_USING_MESSAGEQUEUE
/* end of Inter-Thread communication */
/* Memory Management */
...
...
@@ -37,7 +36,6 @@
#define RT_USING_SMALL_MEM
#define RT_USING_SMALL_MEM_AS_HEAP
#define RT_USING_HEAP
/* end of Memory Management */
/* Kernel Device Object */
...
...
@@ -45,9 +43,7 @@
#define RT_USING_CONSOLE
#define RT_CONSOLEBUF_SIZE 128
#define RT_CONSOLE_DEVICE_NAME "uart1"
/* end of Kernel Device Object */
#define RT_VER_NUM 0x40100
/* end of RT-Thread Kernel */
#define ARCH_ARM
#define RT_USING_CPU_FFS
#define ARCH_ARM_CORTEX_M
...
...
@@ -62,7 +58,6 @@
/* C++ features */
/* end of C++ features */
/* Command shell */
...
...
@@ -79,25 +74,26 @@
#define MSH_USING_BUILT_IN_COMMANDS
#define FINSH_USING_DESCRIPTION
#define FINSH_ARG_MAX 10
/* end of Command shell */
/* Device virtual file system */
/* end of Device virtual file system */
/* Device Drivers */
#define RT_USING_DEVICE_IPC
#define RT_USING_SYSTEM_WORKQUEUE
#define RT_SYSTEM_WORKQUEUE_STACKSIZE 2048
#define RT_SYSTEM_WORKQUEUE_PRIORITY 23
#define RT_USING_SERIAL
#define RT_USING_SERIAL_V1
#define RT_SERIAL_USING_DMA
#define RT_SERIAL_RB_BUFSZ 64
#define RT_USING_I2C
#define RT_USING_I2C_BITOPS
#define RT_USING_PIN
/* Using USB */
/* end of Using USB */
/* end of Device Drivers */
/* POSIX layer and C standard library */
...
...
@@ -112,41 +108,28 @@
/* Socket is in the 'Network' category */
/* end of Interprocess Communication (IPC) */
/* end of POSIX (Portable Operating System Interface) layer */
/* end of POSIX layer and C standard library */
/* Network */
/* Socket abstraction layer */
/* end of Socket abstraction layer */
/* Network interface device */
/* end of Network interface device */
/* light weight TCP/IP stack */
/* end of light weight TCP/IP stack */
/* AT commands */
/* end of AT commands */
/* end of Network */
/* VBUS(Virtual Software BUS) */
/* end of VBUS(Virtual Software BUS) */
/* Utilities */
/* end of Utilities */
/* end of RT-Thread Components */
/* RT-Thread Utestcases */
/* end of RT-Thread Utestcases */
/* RT-Thread online packages */
...
...
@@ -157,83 +140,72 @@
/* Marvell WiFi */
/* end of Marvell WiFi */
/* Wiced WiFi */
/* end of Wiced WiFi */
/* end of Wi-Fi */
/* IoT Cloud */
/* end of IoT Cloud */
/* end of IoT - internet of things */
/* security packages */
/* end of security packages */
/* language packages */
/* end of language packages */
/* multimedia packages */
/* LVGL: powerful and easy-to-use embedded GUI library */
/* end of LVGL: powerful and easy-to-use embedded GUI library */
#define PKG_USING_LVGL
#define PKG_USING_LVGL_V810
#define PKG_LVGL_VER_NUM 0x08010
#define PKG_USING_LV_MUSIC_DEMO
#define PKG_USING_LV_MUSIC_DEMO_LATEST_VERSION
/* u8g2: a monochrome graphic library */
/* end of u8g2: a monochrome graphic library */
/* PainterEngine: A cross-platform graphics application framework written in C language */
/* end of PainterEngine: A cross-platform graphics application framework written in C language */
/* end of multimedia packages */
/* tools packages */
/* end of tools packages */
/* system packages */
/* enhanced kernel services */
/* end of enhanced kernel services */
/* acceleration: Assembly language or algorithmic acceleration packages */
/* end of acceleration: Assembly language or algorithmic acceleration packages */
/* CMSIS: ARM Cortex-M Microcontroller Software Interface Standard */
/* end of CMSIS: ARM Cortex-M Microcontroller Software Interface Standard */
/* Micrium: Micrium software products porting for RT-Thread */
/* end of Micrium: Micrium software products porting for RT-Thread */
/* end of system packages */
/* peripheral libraries and drivers */
/* end of peripheral libraries and drivers */
/* AI packages */
/* end of AI packages */
/* miscellaneous packages */
/* samples: kernel and components samples */
/* end of samples: kernel and components samples */
/* entertainment: terminal games and other interesting software packages */
/* end of entertainment: terminal games and other interesting software packages */
/* end of miscellaneous packages */
/* end of RT-Thread online packages */
/* Privated Packages of RealThread */
/* Network Utilities */
#define SOC_FAMILY_STM32
#define SOC_SERIES_STM32F4
...
...
@@ -244,22 +216,27 @@
/* Onboard Peripheral Drivers */
#define BSP_USING_USB_TO_USART
#define BSP_USING_SRAM
#define BSP_USING_MCU_LCD
#define BSP_USING_MCU_LCD_TEST
#define BSP_USING_TOUCH
#define BSP_TOUCH_INT_PIN 17
/* Enable File System */
/* end of Enable File System */
/* end of Onboard Peripheral Drivers */
/* On-chip Peripheral Drivers */
#define BSP_USING_GPIO
#define BSP_USING_UART
#define BSP_USING_UART1
/* end of On-chip Peripheral Drivers */
#define BSP_USING_I2C2
#define BSP_I2C2_SCL_PIN 16
#define BSP_I2C2_SDA_PIN 91
#define BSP_USING_EXT_FMC_IO
#define BSP_USING_FMC
/* Board extended module Drivers */
/* end of Board extended module Drivers */
/* end of Hardware Drivers Config */
#endif
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录