Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
RT-Thread
rt-thread
提交
d4e70e15
R
rt-thread
项目概览
RT-Thread
/
rt-thread
9 个月 前同步成功
通知
752
Star
8909
Fork
4735
代码
文件
提交
分支
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,体验更适合开发者的 AI 搜索 >>
提交
d4e70e15
编写于
3月 13, 2023
作者:
R
Rbb666
提交者:
guo
3月 14, 2023
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
[Renesas]Add ra6m4-cpk lvgl for spi-lcd support and update rt_spi_bus_attach_device_cspin function
上级
64cd64ba
变更
18
隐藏空白更改
内联
并排
Showing
18 changed file
with
702 addition
and
46 deletion
+702
-46
bsp/renesas/libraries/HAL_Drivers/drv_spi.c
bsp/renesas/libraries/HAL_Drivers/drv_spi.c
+31
-20
bsp/renesas/libraries/HAL_Drivers/drv_spi.h
bsp/renesas/libraries/HAL_Drivers/drv_spi.h
+1
-1
bsp/renesas/ra6m3-ek/board/ports/ili9341/lcd_ili9341.c
bsp/renesas/ra6m3-ek/board/ports/ili9341/lcd_ili9341.c
+1
-15
bsp/renesas/ra6m4-cpk/board/Kconfig
bsp/renesas/ra6m4-cpk/board/Kconfig
+25
-0
bsp/renesas/ra6m4-cpk/board/lvgl/SConscript
bsp/renesas/ra6m4-cpk/board/lvgl/SConscript
+16
-0
bsp/renesas/ra6m4-cpk/board/lvgl/demo/SConscript
bsp/renesas/ra6m4-cpk/board/lvgl/demo/SConscript
+17
-0
bsp/renesas/ra6m4-cpk/board/lvgl/demo/lv_demo.c
bsp/renesas/ra6m4-cpk/board/lvgl/demo/lv_demo.c
+17
-0
bsp/renesas/ra6m4-cpk/board/lvgl/lv_conf.h
bsp/renesas/ra6m4-cpk/board/lvgl/lv_conf.h
+35
-0
bsp/renesas/ra6m4-cpk/board/lvgl/lv_port_disp.c
bsp/renesas/ra6m4-cpk/board/lvgl/lv_port_disp.c
+60
-0
bsp/renesas/ra6m4-cpk/board/lvgl/lv_port_indev.c
bsp/renesas/ra6m4-cpk/board/lvgl/lv_port_indev.c
+15
-0
bsp/renesas/ra6m4-cpk/board/ports/SConscript
bsp/renesas/ra6m4-cpk/board/ports/SConscript
+9
-3
bsp/renesas/ra6m4-cpk/board/ports/drv_rw007.c
bsp/renesas/ra6m4-cpk/board/ports/drv_rw007.c
+1
-1
bsp/renesas/ra6m4-cpk/board/ports/ili9341/SConscript
bsp/renesas/ra6m4-cpk/board/ports/ili9341/SConscript
+22
-0
bsp/renesas/ra6m4-cpk/board/ports/ili9341/lcd_ili9341.c
bsp/renesas/ra6m4-cpk/board/ports/ili9341/lcd_ili9341.c
+329
-0
bsp/renesas/ra6m4-cpk/board/ports/ili9341/lcd_ili9341.h
bsp/renesas/ra6m4-cpk/board/ports/ili9341/lcd_ili9341.h
+89
-0
bsp/renesas/ra6m4-cpk/board/ports/lcd_port.h
bsp/renesas/ra6m4-cpk/board/ports/lcd_port.h
+34
-0
bsp/renesas/ra6m4-cpk/ra_cfg/fsp_cfg/bsp/board_cfg.h
bsp/renesas/ra6m4-cpk/ra_cfg/fsp_cfg/bsp/board_cfg.h
+0
-5
bsp/renesas/ra6m4-cpk/ra_cfg/fsp_cfg/bsp/bsp_cfg.h
bsp/renesas/ra6m4-cpk/ra_cfg/fsp_cfg/bsp/bsp_cfg.h
+0
-1
未找到文件。
bsp/renesas/libraries/HAL_Drivers/drv_spi.c
浏览文件 @
d4e70e15
...
...
@@ -88,11 +88,11 @@ static rt_err_t ra_wait_complete(rt_event_t event, const char bus_name[RT_NAME_M
static
spi_bit_width_t
ra_width_shift
(
rt_uint8_t
data_width
)
{
spi_bit_width_t
bit_width
=
SPI_BIT_WIDTH_8_BITS
;
if
(
data_width
==
1
)
if
(
data_width
==
1
)
bit_width
=
SPI_BIT_WIDTH_8_BITS
;
else
if
(
data_width
==
2
)
else
if
(
data_width
==
2
)
bit_width
=
SPI_BIT_WIDTH_16_BITS
;
else
if
(
data_width
==
4
)
else
if
(
data_width
==
4
)
bit_width
=
SPI_BIT_WIDTH_32_BITS
;
return
bit_width
;
...
...
@@ -101,7 +101,6 @@ static spi_bit_width_t ra_width_shift(rt_uint8_t data_width)
static
rt_err_t
ra_write_message
(
struct
rt_spi_device
*
device
,
const
void
*
send_buf
,
const
rt_size_t
len
)
{
RT_ASSERT
(
device
!=
NULL
);
RT_ASSERT
(
device
->
parent
.
user_data
!=
NULL
);
RT_ASSERT
(
send_buf
!=
NULL
);
RT_ASSERT
(
len
>
0
);
rt_err_t
err
=
RT_EOK
;
...
...
@@ -172,7 +171,6 @@ static rt_err_t ra_hw_spi_configure(struct rt_spi_device *device,
rt_err_t
err
=
RT_EOK
;
struct
ra_spi
*
spi_dev
=
rt_container_of
(
device
->
bus
,
struct
ra_spi
,
bus
);
spi_dev
->
cs_pin
=
(
rt_uint32_t
)
device
->
parent
.
user_data
;
/**< data_width : 1 -> 8 bits , 2 -> 16 bits, 4 -> 32 bits, default 32 bits*/
rt_uint8_t
data_width
=
configuration
->
data_width
/
8
;
...
...
@@ -183,7 +181,7 @@ static rt_err_t ra_hw_spi_configure(struct rt_spi_device *device,
spi_extended_cfg_t
*
spi_cfg
=
(
spi_extended_cfg_t
*
)
spi_dev
->
ra_spi_handle_t
->
spi_cfg_t
->
p_extend
;
/**< Configure Select Line */
rt_pin_write
(
spi_dev
->
cs_pin
,
PIN_HIGH
);
rt_pin_write
(
device
->
cs_pin
,
PIN_HIGH
);
/**< config bitrate */
R_SPI_CalculateBitrate
(
spi_dev
->
rt_spi_cfg_t
->
max_hz
,
&
spi_cfg
->
spck_div
);
...
...
@@ -199,7 +197,7 @@ static rt_err_t ra_hw_spi_configure(struct rt_spi_device *device,
return
RT_EOK
;
}
static
rt_
uint32
_t
ra_spixfer
(
struct
rt_spi_device
*
device
,
struct
rt_spi_message
*
message
)
static
rt_
ssize
_t
ra_spixfer
(
struct
rt_spi_device
*
device
,
struct
rt_spi_message
*
message
)
{
RT_ASSERT
(
device
!=
RT_NULL
);
RT_ASSERT
(
device
->
bus
!=
RT_NULL
);
...
...
@@ -207,14 +205,13 @@ static rt_uint32_t ra_spixfer(struct rt_spi_device *device, struct rt_spi_messag
rt_err_t
err
=
RT_EOK
;
struct
ra_spi
*
spi_dev
=
rt_container_of
(
device
->
bus
,
struct
ra_spi
,
bus
);
spi_dev
->
cs_pin
=
(
rt_uint32_t
)
device
->
parent
.
user_data
;
if
(
message
->
cs_take
&&
!
(
device
->
config
.
mode
&
RT_SPI_NO_CS
))
if
(
message
->
cs_take
&&
!
(
device
->
config
.
mode
&
RT_SPI_NO_CS
)
&&
(
device
->
cs_pin
!=
PIN_NONE
)
)
{
if
(
device
->
config
.
mode
&
RT_SPI_CS_HIGH
)
rt_pin_write
(
spi_dev
->
cs_pin
,
PIN_HIGH
);
rt_pin_write
(
device
->
cs_pin
,
PIN_HIGH
);
else
rt_pin_write
(
spi_dev
->
cs_pin
,
PIN_LOW
);
rt_pin_write
(
device
->
cs_pin
,
PIN_LOW
);
}
if
(
message
->
length
>
0
)
...
...
@@ -236,7 +233,7 @@ static rt_uint32_t ra_spixfer(struct rt_spi_device *device, struct rt_spi_messag
}
}
if
(
message
->
cs_release
&&
!
(
device
->
config
.
mode
&
RT_SPI_NO_CS
))
if
(
message
->
cs_release
&&
!
(
device
->
config
.
mode
&
RT_SPI_NO_CS
)
&&
(
device
->
cs_pin
!=
PIN_NONE
)
)
{
if
(
device
->
config
.
mode
&
RT_SPI_CS_HIGH
)
rt_pin_write
(
spi_dev
->
cs_pin
,
PIN_LOW
);
...
...
@@ -276,17 +273,31 @@ int ra_hw_spi_init(void)
}
INIT_BOARD_EXPORT
(
ra_hw_spi_init
);
#endif
void
rt_hw_spi_device_attach
(
struct
rt_spi_device
*
device
,
const
char
*
device_name
,
const
char
*
bus_name
,
void
*
user_data
)
/**
* Attach the spi device to SPI bus, this function must be used after initialization.
*/
rt_err_t
rt_hw_spi_device_attach
(
const
char
*
bus_name
,
const
char
*
device_name
,
rt_base_t
cs_pin
,
void
*
user_data
)
{
RT_ASSERT
(
device
!=
NULL
);
RT_ASSERT
(
device_name
!=
NULL
);
RT_ASSERT
(
bus_name
!=
NULL
);
RT_ASSERT
(
user_data
!=
NULL
);
RT_ASSERT
(
bus_name
!=
RT_NULL
);
RT_ASSERT
(
device_name
!=
RT_NULL
);
rt_err_t
err
=
rt_spi_bus_attach_device
(
device
,
device_name
,
bus_name
,
user_data
);
if
(
RT_EOK
!=
err
)
rt_err_t
result
;
struct
rt_spi_device
*
spi_device
;
/* attach the device to spi bus*/
spi_device
=
(
struct
rt_spi_device
*
)
rt_malloc
(
sizeof
(
struct
rt_spi_device
));
RT_ASSERT
(
spi_device
!=
RT_NULL
);
result
=
rt_spi_bus_attach_device_cspin
(
spi_device
,
device_name
,
bus_name
,
cs_pin
,
user_data
);
if
(
result
!=
RT_EOK
)
{
LOG_E
(
"%s attach
failed."
,
bus_name
);
LOG_E
(
"%s attach
to %s faild, %d
\n
"
,
device_name
,
bus_name
,
result
);
}
RT_ASSERT
(
result
==
RT_EOK
);
LOG_D
(
"%s attach to %s done"
,
device_name
,
bus_name
);
return
result
;
}
#endif
/* RT_USING_SPI */
bsp/renesas/libraries/HAL_Drivers/drv_spi.h
浏览文件 @
d4e70e15
...
...
@@ -40,7 +40,7 @@ struct ra_spi
};
#endif
void
rt_hw_spi_device_attach
(
struct
rt_spi_device
*
device
,
const
char
*
device_name
,
const
char
*
bus_name
,
void
*
user_data
);
rt_err_t
rt_hw_spi_device_attach
(
const
char
*
bus_name
,
const
char
*
device_name
,
rt_base_t
cs_pin
,
void
*
user_data
);
#ifdef __cplusplus
}
...
...
bsp/renesas/ra6m3-ek/board/ports/ili9341/lcd_ili9341.c
浏览文件 @
d4e70e15
...
...
@@ -23,24 +23,11 @@
_lcd_dev
lcddev
;
static
struct
rt_spi_device
*
lcd_dev
;
static
void
rt_hw_spi_device_attach
(
const
char
*
bus_name
,
const
char
*
device_name
,
void
*
cs_Pin
)
{
struct
rt_spi_device
*
spi_device
;
RT_ASSERT
(
device_name
!=
NULL
&&
bus_name
!=
NULL
);
spi_device
=
(
struct
rt_spi_device
*
)
rt_malloc
(
sizeof
(
struct
rt_spi_device
));
RT_ASSERT
(
spi_device
!=
RT_NULL
);
rt_err_t
err
=
rt_spi_bus_attach_device
(
spi_device
,
device_name
,
bus_name
,
cs_Pin
);
if
(
RT_EOK
!=
err
)
{
rt_kprintf
(
"%s attach failed."
,
bus_name
);
}
}
rt_err_t
spi_lcd_init
(
void
)
{
rt_err_t
res
=
RT_EOK
;
rt_hw_spi_device_attach
(
"spi0"
,
"spi30"
,
(
void
*
)
LCD_CS_PIN
);
rt_hw_spi_device_attach
(
"spi0"
,
"spi30"
,
LCD_CS_PIN
,
RT_NULL
);
lcd_dev
=
(
struct
rt_spi_device
*
)
rt_device_find
(
"spi30"
);
if
(
lcd_dev
!=
RT_NULL
)
{
...
...
@@ -59,7 +46,6 @@ rt_err_t spi_lcd_init(void)
return
res
;
}
MSH_CMD_EXPORT
(
spi_lcd_init
,
lcd_spi_init
);
void
LCD_RESET
(
void
)
{
...
...
bsp/renesas/ra6m4-cpk/board/Kconfig
浏览文件 @
d4e70e15
...
...
@@ -448,6 +448,31 @@ menu "Hardware Drivers Config"
default n
endif
config BSP_USING_SPI_LCD
bool "Enable SPI LCD"
select BSP_USING_GPIO
select BSP_USING_SPI
select BSP_USING_SPI1
default n
menuconfig BSP_USING_LVGL
bool "Enable LVGL for LCD"
select PKG_USING_LVGL
default n
if BSP_USING_LVGL
config BSP_USING_LCD_ILI9431
bool "Enable LVGL for LCD_ILI9431"
select BSP_USING_SPI_LCD
default n
endif
if BSP_USING_LVGL
config BSP_USING_LVGL_DEMO
bool "Enable LVGL demo"
select PKG_USING_LV_MUSIC_DEMO
default y
endif
endmenu
menu "Board extended module Drivers"
...
...
bsp/renesas/ra6m4-cpk/board/lvgl/SConscript
0 → 100644
浏览文件 @
d4e70e15
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
=
group
+
DefineGroup
(
'LVGL-port'
,
src
,
depend
=
[
'BSP_USING_LVGL'
],
CPPPATH
=
CPPPATH
)
Return
(
'group'
)
bsp/renesas/ra6m4-cpk/board/lvgl/demo/SConscript
0 → 100644
浏览文件 @
d4e70e15
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
=
group
+
DefineGroup
(
'LVGL-demo'
,
src
,
depend
=
[
'BSP_USING_LVGL'
,
'BSP_USING_LVGL_DEMO'
],
CPPPATH
=
CPPPATH
)
Return
(
'group'
)
bsp/renesas/ra6m4-cpk/board/lvgl/demo/lv_demo.c
0 → 100644
浏览文件 @
d4e70e15
/*
* Copyright (c) 2006-2023, RT-Thread Development Team
*
* SPDX-License-Identifier: Apache-2.0
*
* Change Logs:
* Date Author Notes
* 2021-10-17 Meco Man First version
* 2022-05-10 Meco Man improve rt-thread initialization process
*/
void
lv_user_gui_init
(
void
)
{
/* display demo; you may replace with your LVGL application at here */
extern
void
lv_demo_music
(
void
);
lv_demo_music
();
}
bsp/renesas/ra6m4-cpk/board/lvgl/lv_conf.h
0 → 100644
浏览文件 @
d4e70e15
/*
* Copyright (c) 2006-2023, RT-Thread Development Team
*
* SPDX-License-Identifier: Apache-2.0
*
* Change Logs:
* Date Author Notes
* 2023-02-22 Rbb666 First version
*/
#ifndef LV_CONF_H
#define LV_CONF_H
#include <rtconfig.h>
#define LV_USE_PERF_MONITOR 1
#define LV_COLOR_DEPTH 16
#ifdef BSP_USING_SPI_LCD
#define LV_HOR_RES_MAX 240
#define LV_VER_RES_MAX 320
#define LV_COLOR_16_SWAP 1
#define LV_DPI_DEF 99
#endif
#ifdef PKG_USING_LV_MUSIC_DEMO
/* music player demo */
#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
#define LV_COLOR_SCREEN_TRANSP 0
#endif
/* PKG_USING_LV_MUSIC_DEMO */
#endif
bsp/renesas/ra6m4-cpk/board/lvgl/lv_port_disp.c
0 → 100644
浏览文件 @
d4e70e15
/*
* Copyright (c) 2006-2023, RT-Thread Development Team
*
* SPDX-License-Identifier: Apache-2.0
*
* Change Logs:
* Date Author Notes
* 2021-11-24 Rbb666 The first version
*/
#include <lvgl.h>
#include "hal_data.h"
#ifdef BSP_USING_SPI_LCD
#include "lcd_ili9341.h"
#endif
#define COLOR_BUFFER (LV_HOR_RES_MAX * LV_VER_RES_MAX / 4)
/*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*/
// 0x1FFE0000 0x20040000
static
lv_color_t
buf_1
[
COLOR_BUFFER
];
static
lv_color_t
buf_2
[
COLOR_BUFFER
];
static
void
disp_flush
(
lv_disp_drv_t
*
disp_drv
,
const
lv_area_t
*
area
,
lv_color_t
*
color_p
)
{
#ifdef BSP_USING_SPI_LCD
lcd_fill_array_spi
(
area
->
x1
,
area
->
y1
,
area
->
x2
,
area
->
y2
,
color_p
);
#endif
lv_disp_flush_ready
(
disp_drv
);
}
void
lv_port_disp_init
(
void
)
{
#ifdef BSP_USING_SPI_LCD
spi_lcd_init
();
#endif
/*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
,
buf_2
,
COLOR_BUFFER
);
lv_disp_drv_init
(
&
disp_drv
);
/*Basic initialization*/
/*Set the resolution of the display*/
disp_drv
.
hor_res
=
LV_HOR_RES_MAX
;
disp_drv
.
ver_res
=
LV_VER_RES_MAX
;
/*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/renesas/ra6m4-cpk/board/lvgl/lv_port_indev.c
0 → 100644
浏览文件 @
d4e70e15
/*
* Copyright (c) 2006-2023, 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 <rtdevice.h>
void
lv_port_indev_init
(
void
)
{
}
bsp/renesas/ra6m4-cpk/board/ports/SConscript
浏览文件 @
d4e70e15
from
building
import
*
import
rtconfig
import
os
cwd
=
GetCurrentDir
()
objs
=
[]
src
=
[]
if
GetDepend
([
'BSP_USING_RW007'
]):
...
...
@@ -16,7 +17,12 @@ if rtconfig.PLATFORM in ['gcc', 'armclang']:
LOCAL_CFLAGS
+=
' -std=c99'
elif
rtconfig
.
PLATFORM
in
[
'armcc'
]:
LOCAL_CFLAGS
+=
' --c99'
objs
=
DefineGroup
(
'Drivers'
,
src
,
depend
=
[
''
],
CPPPATH
=
CPPPATH
)
list
=
os
.
listdir
(
cwd
)
for
item
in
list
:
if
os
.
path
.
isfile
(
os
.
path
.
join
(
cwd
,
item
,
'SConscript'
)):
objs
=
objs
+
SConscript
(
os
.
path
.
join
(
item
,
'SConscript'
))
group
=
DefineGroup
(
'Drivers'
,
src
,
depend
=
[],
CPPPATH
=
CPPPATH
,
LOCAL_CFLAGS
=
LOCAL_CFLAGS
)
Return
(
'objs'
)
Return
(
'group'
)
bsp/renesas/ra6m4-cpk/board/ports/drv_rw007.c
浏览文件 @
d4e70e15
...
...
@@ -37,7 +37,7 @@ int wifi_spi_device_init(void)
uint32_t
cs_pin
=
RA_RW007_CS_PIN
;
rw007_gpio_init
();
rt_hw_spi_device_attach
(
&
rw007_dev
,
"wspi"
,
RA_RW007_SPI_BUS_NAME
,
(
void
*
)
cs_pin
);
rt_hw_spi_device_attach
(
RA_RW007_SPI_BUS_NAME
,
"wspi"
,
cs_pin
,
RT_NULL
);
rt_hw_wifi_init
(
"wspi"
);
rt_wlan_set_mode
(
RT_WLAN_DEVICE_STA_NAME
,
RT_WLAN_STATION
);
...
...
bsp/renesas/ra6m4-cpk/board/ports/ili9341/SConscript
0 → 100644
浏览文件 @
d4e70e15
from
building
import
*
import
rtconfig
cwd
=
GetCurrentDir
()
src
=
[]
if
GetDepend
([
'BSP_USING_SPI_LCD'
]):
src
+=
Glob
(
'lcd_ili9341.c'
)
CPPPATH
=
[
cwd
]
LOCAL_CFLAGS
=
''
if
rtconfig
.
PLATFORM
in
[
'gcc'
,
'armclang'
]:
LOCAL_CFLAGS
+=
' -std=c99'
elif
rtconfig
.
PLATFORM
in
[
'armcc'
]:
LOCAL_CFLAGS
+=
' --c99'
group
=
DefineGroup
(
'ili9341'
,
src
,
depend
=
[],
CPPPATH
=
CPPPATH
,
LOCAL_CFLAGS
=
LOCAL_CFLAGS
)
Return
(
'group'
)
bsp/renesas/ra6m4-cpk/board/ports/ili9341/lcd_ili9341.c
0 → 100644
浏览文件 @
d4e70e15
/*
* Copyright (c) 2006-2023, RT-Thread Development Team
*
* SPDX-License-Identifier: Apache-2.0
*
* Change Logs:
* Date Author Notes
* 2023-02-23 Rbb666 First version
*/
#include <rtdevice.h>
#ifdef BSP_USING_SPI_LCD
#include "lcd_ili9341.h"
#include "drv_spi.h"
/* 2.8 inch LCD module */
/* res pin -> P6_11 */
/* d/c pin -> P4_15 */
/* cs pin -> P4_13 */
/* sda pin -> p4_11 */
/* scl pin -> p4_12 */
_lcd_dev
lcddev
;
static
struct
rt_spi_device
*
lcd_dev
;
rt_err_t
spi_lcd_init
(
void
)
{
rt_err_t
res
=
RT_EOK
;
rt_hw_spi_device_attach
(
"spi1"
,
"spi30"
,
LCD_CS_PIN
,
RT_NULL
);
lcd_dev
=
(
struct
rt_spi_device
*
)
rt_device_find
(
"spi30"
);
if
(
lcd_dev
!=
RT_NULL
)
{
struct
rt_spi_configuration
spi_config
;
spi_config
.
data_width
=
8
;
spi_config
.
max_hz
=
25
*
1000
*
1000
;
spi_config
.
mode
=
RT_SPI_MASTER
|
RT_SPI_MODE_0
|
RT_SPI_MSB
;
rt_spi_configure
(
lcd_dev
,
&
spi_config
);
}
else
{
res
=
RT_ERROR
;
}
LCD_Init
();
return
res
;
}
void
LCD_RESET
(
void
)
{
LCD_RES_CLR
;
DELAY
(
100
);
LCD_RES_SET
;
DELAY
(
100
);
}
void
LCD_WR_REG
(
uint8_t
reg
)
{
LCD_DC_CLR
;
rt_spi_send
(
lcd_dev
,
&
reg
,
1
);
LCD_DC_SET
;
}
void
LCD_WR_DATA
(
uint8_t
data
)
{
LCD_DC_SET
;
rt_spi_send
(
lcd_dev
,
&
data
,
1
);
}
void
LCD_ReadData
(
uint8_t
*
data
,
uint16_t
length
)
{
LCD_DC_SET
;
rt_spi_transfer
(
lcd_dev
,
RT_NULL
,
&
data
,
length
);
}
void
LCD_WriteReg
(
uint8_t
reg
,
uint16_t
regdata
)
{
LCD_WR_REG
(
reg
);
LCD_WR_DATA
(
regdata
);
}
void
LCD_WriteRAM_Prepare
(
void
)
{
LCD_WR_REG
(
lcddev
.
wramcmd
);
}
void
LCD_WriteData_16Bit
(
uint16_t
Data
)
{
uint8_t
buf
[
2
];
LCD_DC_SET
;
buf
[
0
]
=
Data
>>
8
;
buf
[
1
]
=
Data
&
0xff
;
rt_spi_send
(
lcd_dev
,
buf
,
2
);
}
void
LCD_direction
(
uint8_t
direction
)
{
lcddev
.
setxcmd
=
0x2A
;
lcddev
.
setycmd
=
0x2B
;
lcddev
.
wramcmd
=
0x2C
;
switch
(
direction
)
{
case
0
:
lcddev
.
width
=
LCD_W
;
lcddev
.
height
=
LCD_H
;
LCD_WriteReg
(
0x36
,
(
1
<<
3
)
|
(
0
<<
6
)
|
(
0
<<
7
));
/* BGR==1,MY==0,MX==0,MV==0 */
break
;
case
1
:
lcddev
.
width
=
LCD_H
;
lcddev
.
height
=
LCD_W
;
LCD_WriteReg
(
0x36
,
(
1
<<
3
)
|
(
0
<<
7
)
|
(
1
<<
6
)
|
(
1
<<
5
));
/* BGR==1,MY==1,MX==0,MV==1 */
break
;
case
2
:
lcddev
.
width
=
LCD_W
;
lcddev
.
height
=
LCD_H
;
LCD_WriteReg
(
0x36
,
(
1
<<
3
)
|
(
1
<<
6
)
|
(
1
<<
7
));
/* BGR==1,MY==0,MX==0,MV==0 */
break
;
case
3
:
lcddev
.
width
=
LCD_H
;
lcddev
.
height
=
LCD_W
;
LCD_WriteReg
(
0x36
,
(
1
<<
3
)
|
(
1
<<
7
)
|
(
1
<<
5
));
/* BGR==1,MY==1,MX==0,MV==1 */
break
;
default:
break
;
}
}
void
LCD_SetWindows
(
uint16_t
xStar
,
uint16_t
yStar
,
uint16_t
xEnd
,
uint16_t
yEnd
)
{
LCD_WR_REG
(
lcddev
.
setxcmd
);
LCD_WR_DATA
(
xStar
>>
8
);
LCD_WR_DATA
(
0x00FF
&
xStar
);
LCD_WR_DATA
(
xEnd
>>
8
);
LCD_WR_DATA
(
0x00FF
&
xEnd
);
LCD_WR_REG
(
lcddev
.
setycmd
);
LCD_WR_DATA
(
yStar
>>
8
);
LCD_WR_DATA
(
0x00FF
&
yStar
);
LCD_WR_DATA
(
yEnd
>>
8
);
LCD_WR_DATA
(
0x00FF
&
yEnd
);
LCD_WriteRAM_Prepare
();
}
void
LCD_SetCursor
(
uint16_t
Xpos
,
uint16_t
Ypos
)
{
LCD_SetWindows
(
Xpos
,
Ypos
,
Xpos
,
Ypos
);
}
void
LCD_Clear
(
uint16_t
Color
)
{
unsigned
int
i
,
m
;
uint8_t
buf
[
80
];
for
(
i
=
0
;
i
<
40
;
i
++
)
{
buf
[
2
*
i
]
=
Color
>>
8
;
buf
[
2
*
i
+
1
]
=
Color
&
0xff
;
}
LCD_SetWindows
(
0
,
0
,
lcddev
.
width
-
1
,
lcddev
.
height
-
1
);
LCD_DC_SET
;
for
(
i
=
0
;
i
<
lcddev
.
height
;
i
++
)
{
for
(
m
=
0
;
m
<
lcddev
.
width
;)
{
m
+=
40
;
rt_spi_send
(
lcd_dev
,
buf
,
80
);
}
}
}
void
LCD_Fill
(
uint16_t
xsta
,
uint16_t
ysta
,
uint16_t
xend
,
uint16_t
yend
,
uint16_t
color
)
{
uint16_t
i
,
j
;
LCD_SetWindows
(
xsta
,
ysta
,
xend
-
1
,
yend
-
1
);
for
(
i
=
ysta
;
i
<
yend
;
i
++
)
{
for
(
j
=
xsta
;
j
<
xend
;
j
++
)
{
LCD_WriteData_16Bit
(
color
);
}
}
}
void
lcd_fill_array_spi
(
uint16_t
Xstart
,
uint16_t
Ystart
,
uint16_t
Xend
,
uint16_t
Yend
,
void
*
Image
)
{
rt_uint32_t
size
=
0
;
size
=
(
Xend
-
Xstart
+
1
)
*
(
Yend
-
Ystart
+
1
)
*
2
;
/*16bit*/
LCD_SetWindows
(
Xstart
,
Ystart
,
Xend
,
Yend
);
LCD_DC_SET
;
rt_spi_send
(
lcd_dev
,
Image
,
size
);
}
static
void
_ili9341_init
(
void
)
{
LCD_WR_REG
(
0xCF
);
LCD_WR_DATA
(
0x00
);
LCD_WR_DATA
(
0X83
);
LCD_WR_DATA
(
0X30
);
LCD_WR_REG
(
0xED
);
LCD_WR_DATA
(
0x64
);
LCD_WR_DATA
(
0x03
);
LCD_WR_DATA
(
0X12
);
LCD_WR_DATA
(
0X81
);
LCD_WR_REG
(
0xE8
);
LCD_WR_DATA
(
0x85
);
LCD_WR_DATA
(
0x00
);
LCD_WR_DATA
(
0x79
);
LCD_WR_REG
(
0xCB
);
LCD_WR_DATA
(
0x39
);
LCD_WR_DATA
(
0x2C
);
LCD_WR_DATA
(
0x00
);
LCD_WR_DATA
(
0x34
);
LCD_WR_DATA
(
0x02
);
LCD_WR_REG
(
0xF7
);
LCD_WR_DATA
(
0x20
);
LCD_WR_REG
(
0xEA
);
LCD_WR_DATA
(
0x00
);
LCD_WR_DATA
(
0x00
);
LCD_WR_REG
(
0xC0
);
/* Power control */
LCD_WR_DATA
(
0x26
);
/* VRH[5:0] */
LCD_WR_REG
(
0xC1
);
/* Power control */
LCD_WR_DATA
(
0x11
);
/* SAP[2:0];BT[3:0] */
LCD_WR_REG
(
0xC5
);
/* VCM control */
LCD_WR_DATA
(
0x35
);
LCD_WR_DATA
(
0x3E
);
LCD_WR_REG
(
0xC7
);
/* VCM control2 */
LCD_WR_DATA
(
0XBE
);
LCD_WR_REG
(
0x36
);
/* Memory Access Control */
LCD_WR_DATA
(
0x28
);
LCD_WR_REG
(
0x3A
);
LCD_WR_DATA
(
0x55
);
LCD_WR_REG
(
0xB1
);
LCD_WR_DATA
(
0x00
);
LCD_WR_DATA
(
0x1B
);
LCD_WR_REG
(
0xB6
);
/* Display Function Control */
LCD_WR_DATA
(
0x0A
);
LCD_WR_DATA
(
0xA2
);
LCD_WR_REG
(
0xF2
);
/* 3Gamma Function Disable */
LCD_WR_DATA
(
0x08
);
LCD_WR_REG
(
0x26
);
/* Gamma curve selected */
LCD_WR_DATA
(
0x01
);
LCD_WR_REG
(
0xE0
);
/* set Gamma */
LCD_WR_DATA
(
0X1F
);
LCD_WR_DATA
(
0X1A
);
LCD_WR_DATA
(
0X18
);
LCD_WR_DATA
(
0X0A
);
LCD_WR_DATA
(
0X0F
);
LCD_WR_DATA
(
0X06
);
LCD_WR_DATA
(
0X45
);
LCD_WR_DATA
(
0X87
);
LCD_WR_DATA
(
0X32
);
LCD_WR_DATA
(
0X0A
);
LCD_WR_DATA
(
0X07
);
LCD_WR_DATA
(
0X02
);
LCD_WR_DATA
(
0X07
);
LCD_WR_DATA
(
0X05
);
LCD_WR_DATA
(
0X00
);
LCD_WR_REG
(
0xE1
);
/* set Gamma */
LCD_WR_DATA
(
0X00
);
LCD_WR_DATA
(
0X25
);
LCD_WR_DATA
(
0X27
);
LCD_WR_DATA
(
0X05
);
LCD_WR_DATA
(
0X10
);
LCD_WR_DATA
(
0X09
);
LCD_WR_DATA
(
0X3A
);
LCD_WR_DATA
(
0X78
);
LCD_WR_DATA
(
0X4D
);
LCD_WR_DATA
(
0X05
);
LCD_WR_DATA
(
0X18
);
LCD_WR_DATA
(
0X0D
);
LCD_WR_DATA
(
0X38
);
LCD_WR_DATA
(
0X3A
);
LCD_WR_DATA
(
0X2F
);
LCD_WR_REG
(
0x29
);
}
void
LCD_Init
(
void
)
{
LCD_RESET
();
/* LCD Hardware Reset */
LCD_WR_REG
(
0x11
);
/* Sleep out */
DELAY
(
120
);
/* Delay 120ms */
_ili9341_init
();
LCD_direction
(
USE_HORIZONTAL
);
}
static
uint16_t
color_array
[]
=
{
WHITE
,
BLACK
,
BLUE
,
BRED
,
GRED
,
GBLUE
,
RED
,
YELLOW
};
static
rt_err_t
lcd_spi_test
()
{
uint8_t
index
=
0
;
for
(
index
=
0
;
index
<
sizeof
(
color_array
)
/
sizeof
(
color_array
[
0
]);
index
++
)
{
LCD_Clear
(
color_array
[
index
]);
DELAY
(
200
);
}
return
RT_EOK
;
}
MSH_CMD_EXPORT
(
lcd_spi_test
,
lcd_spi_test
);
#endif
bsp/renesas/ra6m4-cpk/board/ports/ili9341/lcd_ili9341.h
0 → 100644
浏览文件 @
d4e70e15
/*
* Copyright (c) 2006-2023, RT-Thread Development Team
*
* SPDX-License-Identifier: Apache-2.0
*
* Change Logs:
* Date Author Notes
* 2023-02-23 Rbb666 First version
*/
#ifndef __LCD_ILI9341_H__
#define __LCD_ILI9341_H__
#ifdef __cplusplus
extern
"C"
{
#endif
#include "hal_data.h"
#include <stdint.h>
#include <rtthread.h>
typedef
struct
{
uint16_t
width
;
/* LCD width */
uint16_t
height
;
/* LCD high */
uint32_t
id
;
/* LCD ID */
uint8_t
dir
;
/* 0:Vertical | 1:Vertical */
uint16_t
wramcmd
;
/* gram cmd */
uint16_t
setxcmd
;
/* set x cmd */
uint16_t
setycmd
;
/* set y cmd */
}
_lcd_dev
;
/* LCD param */
extern
_lcd_dev
lcddev
;
#define USE_HORIZONTAL 0
/* 0-0째|1-90째|2-180째|-270째 */
/* lcd size */
#define LCD_W 240
#define LCD_H 320
#define WHITE 0xFFFF
#define BLACK 0x0000
#define BLUE 0x001F
#define BRED 0XF81F
#define GRED 0XFFE0
#define GBLUE 0X07FF
#define RED 0xF800
#define MAGENTA 0xF81F
#define GREEN 0x07E0
#define CYAN 0x7FFF
#define YELLOW 0xFFE0
#define BROWN 0XBC40
#define BRRED 0XFC07
#define GRAY 0X8430
#define LCD_DC_PIN BSP_IO_PORT_04_PIN_15
#define LCD_RES_PIN BSP_IO_PORT_06_PIN_11
#define LCD_CS_PIN BSP_IO_PORT_04_PIN_13
#define LCD_DC_CLR rt_pin_write(LCD_DC_PIN, PIN_LOW)
#define LCD_DC_SET rt_pin_write(LCD_DC_PIN, PIN_HIGH)
#define LCD_RES_CLR rt_pin_write(LCD_RES_PIN, PIN_LOW)
#define LCD_RES_SET rt_pin_write(LCD_RES_PIN, PIN_HIGH)
#define DELAY rt_thread_mdelay
/* res pin -> P6_11 */
/* d/c pin -> P4_15 */
/* cs pin -> P4_13 */
void
LCD_RESET
(
void
);
void
LCD_WR_REG
(
uint8_t
reg
);
void
LCD_WR_DATA
(
uint8_t
data
);
void
LCD_WriteReg
(
uint8_t
reg
,
uint16_t
regdata
);
void
LCD_WriteRAM_Prepare
(
void
);
void
LCD_WriteData_16Bit
(
uint16_t
Data
);
void
LCD_direction
(
uint8_t
direction
);
void
LCD_SetWindows
(
uint16_t
xStar
,
uint16_t
yStar
,
uint16_t
xEnd
,
uint16_t
yEnd
);
void
LCD_SetCursor
(
uint16_t
Xpos
,
uint16_t
Ypos
);
void
LCD_Clear
(
uint16_t
Color
);
void
LCD_Fill
(
uint16_t
xsta
,
uint16_t
ysta
,
uint16_t
xend
,
uint16_t
yend
,
uint16_t
color
);
void
lcd_fill_array_spi
(
uint16_t
x_start
,
uint16_t
y_start
,
uint16_t
x_end
,
uint16_t
y_end
,
void
*
pcolor
);
void
LCD_Init
(
void
);
rt_err_t
spi_lcd_init
(
void
);
#ifdef __cplusplus
}
#endif
#endif
bsp/renesas/ra6m4-cpk/board/ports/lcd_port.h
0 → 100644
浏览文件 @
d4e70e15
/*
* Copyright (c) 2006-2023, RT-Thread Development Team
*
* SPDX-License-Identifier: Apache-2.0
*
* Change Logs:
* Date Author Notes
* 2018-07-28 liu2guang the first version for STM32F469NI-Discovery.
*/
#ifndef __DRV_LCD_H_
#define __DRV_LCD_H_
#include <rtthread.h>
#include <rtdevice.h>
#include <board.h>
typedef
enum
{
ROTATION_ZERO
=
0
,
ROTATION_090
=
90
,
ROTATION_180
=
180
,
ROTATION_270
=
270
,
}
bsp_rotation
;
#define LCD_WIDTH DISPLAY_HSIZE_INPUT0
#define LCD_HEIGHT DISPLAY_VSIZE_INPUT0
#define LCD_BITS_PER_PIXEL DISPLAY_BITS_PER_PIXEL_INPUT1
#define LCD_PIXEL_FORMAT RTGRAPHIC_PIXEL_FORMAT_RGB565
#define LCD_BUF_SIZE (LCD_WIDTH * LCD_HEIGHT * LCD_BITS_PER_PIXEL / 8)
#define LCD_BL_PIN BSP_IO_PORT_06_PIN_03
#endif
bsp/renesas/ra6m4-cpk/ra_cfg/fsp_cfg/bsp/board_cfg.h
已删除
100644 → 0
浏览文件 @
64cd64ba
/* generated configuration header file - do not edit */
#ifndef BOARD_CFG_H_
#define BOARD_CFG_H_
#include "../../../ra/board/ra6m4_cpk/board.h"
#endif
/* BOARD_CFG_H_ */
bsp/renesas/ra6m4-cpk/ra_cfg/fsp_cfg/bsp/bsp_cfg.h
浏览文件 @
d4e70e15
...
...
@@ -3,7 +3,6 @@
#define BSP_CFG_H_
#include "bsp_clock_cfg.h"
#include "bsp_mcu_family_cfg.h"
#include "board_cfg.h"
#define RA_NOT_DEFINED 0
#ifndef BSP_CFG_RTOS
#if (RA_NOT_DEFINED) != (RA_NOT_DEFINED)
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录