mirror of
https://github.com/RT-Thread/rt-thread.git
synced 2026-09-19 16:26:55 +08:00
[bsp/stm32] upgrade to rt-thread 5.0
This commit is contained in:
@@ -158,27 +158,35 @@ int stm32_flash_erase(rt_uint32_t addr, size_t size)
|
||||
|
||||
rt_uint32_t addr_bank1 = 0;
|
||||
rt_uint32_t size_bank1 = 0;
|
||||
#ifdef FLASH_BANK_2
|
||||
rt_uint32_t addr_bank2 = 0;
|
||||
rt_uint32_t size_bank2 = 0;
|
||||
#endif
|
||||
|
||||
if((addr + size) < FLASH_BANK2_BASE)
|
||||
{
|
||||
addr_bank1 = addr;
|
||||
size_bank1 = size;
|
||||
#ifdef FLASH_BANK_2
|
||||
size_bank2 = 0;
|
||||
#endif
|
||||
}
|
||||
else if(addr >= FLASH_BANK2_BASE)
|
||||
{
|
||||
size_bank1 = 0;
|
||||
#ifdef FLASH_BANK_2
|
||||
addr_bank2 = addr;
|
||||
size_bank2 = size;
|
||||
#endif
|
||||
}
|
||||
else
|
||||
{
|
||||
addr_bank1 = addr;
|
||||
size_bank1 = FLASH_BANK2_BASE - addr_bank1;
|
||||
#ifdef FLASH_BANK_2
|
||||
addr_bank2 = FLASH_BANK2_BASE;
|
||||
size_bank2 = addr + size - FLASH_BANK2_BASE;
|
||||
#endif
|
||||
}
|
||||
|
||||
/*Variable used for Erase procedure*/
|
||||
@@ -201,6 +209,7 @@ int stm32_flash_erase(rt_uint32_t addr, size_t size)
|
||||
}
|
||||
}
|
||||
|
||||
#ifdef FLASH_BANK_2
|
||||
if(size_bank2)
|
||||
{
|
||||
EraseInitStruct.Sector = (addr_bank2 - FLASH_BANK2_BASE) / FLASH_SECTOR_SIZE;
|
||||
@@ -212,6 +221,7 @@ int stm32_flash_erase(rt_uint32_t addr, size_t size)
|
||||
goto __exit;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
__exit:
|
||||
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -8,14 +8,14 @@ config BSP_DIR
|
||||
config RTT_DIR
|
||||
string
|
||||
option env="RTT_ROOT"
|
||||
default "rt-thread"
|
||||
default "../../.."
|
||||
|
||||
config PKGS_DIR
|
||||
string
|
||||
option env="PKGS_ROOT"
|
||||
default "packages"
|
||||
|
||||
|
||||
source "$RTT_DIR/Kconfig"
|
||||
source "$PKGS_DIR/Kconfig"
|
||||
source "libraries/Kconfig"
|
||||
source "../libraries/Kconfig"
|
||||
source "board/Kconfig"
|
||||
|
||||
@@ -14,7 +14,7 @@
|
||||
|
||||
## 开发板介绍
|
||||
|
||||
STM32H7xx Core Board 是 WeAct Studio 推出的一款基于 ARM Cortex-M7 内核的核心板,最高频率为480Mhz,具有128KB ROM(实际上为2MB)、1MB RAM,外接8MB SPI Flash和8MB QSPI Flash,所具有的按键和接口如下:
|
||||
STM32H7xx Core Board 是 WeAct Studio 推出的一款基于 ARM Cortex-M7 内核的核心板,最高频率为480Mhz,具有128KB ROM(实际上 2MB ROM 可用)、1MB RAM,外接8MB SPI Flash和8MB QSPI Flash,所具有的按键和接口如下:
|
||||
|
||||
* 2*22 Pin 2.54mm I/O x 2
|
||||
* 4 Pin 2.54mm SW x 1
|
||||
@@ -90,9 +90,9 @@ STM32H7xx Core Board 是 WeAct Studio 推出的一款基于 ARM Cortex-M7 内核
|
||||
```bash
|
||||
\ | /
|
||||
- RT - Thread Operating System
|
||||
/ | \ 4.0.3 build Aug 6 2020
|
||||
2006 - 2020 Copyright by rt-thread team
|
||||
msh >
|
||||
/ | \ 5.0.0 build Oct 15 2022 16:28:21
|
||||
2006 - 2022 Copyright by RT-Thread team
|
||||
msh />
|
||||
```
|
||||
### 进阶使用
|
||||
|
||||
@@ -110,6 +110,10 @@ msh >
|
||||
|
||||
## 注意事项
|
||||
|
||||
- 如果固件超过 128k ,且使用 Keil 下载请注意:
|
||||
- 在 keil 中芯片选为 H743 ,此时会出现 2MB Flash 的下载算法,选择此下载算法下载程序
|
||||
- 将该文件夹下 STM32H7x_2048.FLM 放到 `Keil安装目录\Keil_v5\ARM\Flash` 中,并选择此下载算法
|
||||
- 其余方式下载代码情况类似
|
||||
- 调试串口为串口1 映射说明
|
||||
|
||||
PB14 ------> USART1_TX
|
||||
|
||||
@@ -7,10 +7,6 @@ if os.getenv('RTT_ROOT'):
|
||||
else:
|
||||
RTT_ROOT = os.path.normpath(os.getcwd() + '/../../..')
|
||||
|
||||
# set RTT_ROOT
|
||||
if not os.getenv("RTT_ROOT"):
|
||||
RTT_ROOT="rt-thread"
|
||||
|
||||
sys.path = sys.path + [os.path.join(RTT_ROOT, 'tools')]
|
||||
try:
|
||||
from building import *
|
||||
@@ -24,14 +20,14 @@ TARGET = 'rt-thread.' + rtconfig.TARGET_EXT
|
||||
DefaultEnvironment(tools=[])
|
||||
env = Environment(tools = ['mingw'],
|
||||
AS = rtconfig.AS, ASFLAGS = rtconfig.AFLAGS,
|
||||
CC = rtconfig.CC, CCFLAGS = rtconfig.CFLAGS,
|
||||
CC = rtconfig.CC, CFLAGS = rtconfig.CFLAGS,
|
||||
AR = rtconfig.AR, ARFLAGS = '-rc',
|
||||
CXX = rtconfig.CXX, CXXFLAGS = rtconfig.CXXFLAGS,
|
||||
LINK = rtconfig.LINK, LINKFLAGS = rtconfig.LFLAGS)
|
||||
env.PrependENVPath('PATH', rtconfig.EXEC_PATH)
|
||||
|
||||
if rtconfig.PLATFORM == 'iar':
|
||||
env.Replace(CCCOM = ['$CC $CCFLAGS $CPPFLAGS $_CPPDEFFLAGS $_CPPINCFLAGS -o $TARGET $SOURCES'])
|
||||
if rtconfig.PLATFORM in ['iccarm']:
|
||||
env.Replace(CCCOM = ['$CC $CFLAGS $CPPFLAGS $_CPPDEFFLAGS $_CPPINCFLAGS -o $TARGET $SOURCES'])
|
||||
env.Replace(ARFLAGS = [''])
|
||||
env.Replace(LINKCOM = env["LINKCOM"] + ' --map rt-thread.map')
|
||||
|
||||
|
||||
Binary file not shown.
@@ -1,12 +1,16 @@
|
||||
import rtconfig
|
||||
from building import *
|
||||
import os
|
||||
|
||||
cwd = GetCurrentDir()
|
||||
CPPPATH = [cwd, str(Dir('#'))]
|
||||
src = Split("""
|
||||
main.c
|
||||
""")
|
||||
cwd = GetCurrentDir()
|
||||
path = [cwd]
|
||||
src = Glob('*.c')
|
||||
|
||||
group = DefineGroup('Applications', src, depend = [''])
|
||||
group = DefineGroup('Applications', src, depend = [''], CPPPATH = path)
|
||||
|
||||
Return('group')
|
||||
list = os.listdir(cwd)
|
||||
for item in list:
|
||||
if os.path.isfile(os.path.join(cwd, item, 'SConscript')):
|
||||
group = group + SConscript(os.path.join(item, 'SConscript'))
|
||||
|
||||
Return('group')
|
||||
@@ -16,7 +16,7 @@ menu "Onboard Peripheral Drivers"
|
||||
select RT_USING_DFS
|
||||
select PKG_USING_LITTLEFS
|
||||
select RT_USING_MTD_NOR
|
||||
select PKG_USING_FAL
|
||||
select RT_USING_FAL
|
||||
select FAL_USING_SFUD_PORT
|
||||
select RT_USING_SFUD
|
||||
select RT_SFUD_USING_SFDP
|
||||
@@ -25,6 +25,7 @@ menu "Onboard Peripheral Drivers"
|
||||
config BSP_USING_QSPI_FLASH
|
||||
bool "Enable QSPI FLASH (W25Q64)"
|
||||
select BSP_USING_QSPI
|
||||
select FAL_USING_SFUD_PORT
|
||||
select RT_USING_SFUD
|
||||
select RT_SFUD_USING_QSPI
|
||||
default n
|
||||
@@ -39,10 +40,16 @@ menu "Onboard Peripheral Drivers"
|
||||
select BSP_USING_PWM1
|
||||
select BSP_USING_PWM1_CH2
|
||||
default n
|
||||
|
||||
if BSP_USING_LCD_SPI
|
||||
config LCD_BACKLIGHT_USING_PWM
|
||||
bool "Enable back light(tim1_ch2 pwm1)"
|
||||
default y
|
||||
choice
|
||||
prompt "choice back light"
|
||||
default LCD_BACKLIGHT_USING_GPIO
|
||||
config LCD_BACKLIGHT_USING_PWM
|
||||
bool "LCD_BACKLIGHT_USING_PWM(tim1_ch2 pwm1)"
|
||||
config LCD_BACKLIGHT_USING_GPIO
|
||||
bool "LCD_BACKLIGHT_USING_GPIO(PE10)"
|
||||
endchoice
|
||||
endif
|
||||
|
||||
endmenu
|
||||
@@ -89,10 +96,6 @@ menu "On-chip Peripheral Drivers"
|
||||
default n
|
||||
endif
|
||||
|
||||
config BSP_QSPI_USING_DMA
|
||||
bool "Enable QSPI DMA support"
|
||||
default n
|
||||
|
||||
menuconfig BSP_USING_I2C1
|
||||
bool "Enable I2C1 BUS (software simulation)"
|
||||
default n
|
||||
@@ -173,7 +176,7 @@ menu "On-chip Peripheral Drivers"
|
||||
select BSP_USBD_PHY_ULPI
|
||||
default n
|
||||
|
||||
source "libraries/HAL_Drivers/Kconfig"
|
||||
source "../libraries/HAL_Drivers/Kconfig"
|
||||
|
||||
endmenu
|
||||
|
||||
|
||||
@@ -1,38 +1,47 @@
|
||||
import os
|
||||
import rtconfig
|
||||
from building import *
|
||||
|
||||
Import('SDK_LIB')
|
||||
|
||||
objs = []
|
||||
cwd = GetCurrentDir()
|
||||
list = os.listdir(cwd)
|
||||
|
||||
path = [cwd]
|
||||
path += [cwd + '/CubeMX_Config/Inc']
|
||||
path += [cwd + '/ports']
|
||||
path += [cwd + '/port']
|
||||
|
||||
# add the general drivers.
|
||||
src = Glob('board.c')
|
||||
src += Glob('CubeMX_Config/Src/stm32h7xx_hal_msp.c')
|
||||
|
||||
if GetDepend(['BSP_USING_SPI_FLASH']):
|
||||
src += Glob('ports/drv_spi_flash.c')
|
||||
src += Glob('port/drv_spi_flash.c')
|
||||
|
||||
if GetDepend(['BSP_USING_QSPI_FLASH']):
|
||||
src += Glob('ports/drv_qspi_flash.c')
|
||||
src += Glob('port/drv_qspi_flash.c')
|
||||
|
||||
if GetDepend('BSP_USING_LCD_SPI'):
|
||||
src = src + ['ports/drv_lcd_spi.c']
|
||||
src = src + ['ports/st7735/lcd.c']
|
||||
src = src + ['ports/st7735/st7735.c']
|
||||
src = src + ['ports/st7735/st7735_reg.c']
|
||||
src = src + ['ports/st7735/logo.c']
|
||||
path += [cwd + '/ports/st7735']
|
||||
src = src + ['port/drv_lcd_spi.c']
|
||||
src = src + ['port/st7735/lcd.c']
|
||||
src = src + ['port/st7735/st7735.c']
|
||||
src = src + ['port/st7735/st7735_reg.c']
|
||||
src = src + ['port/st7735/logo.c']
|
||||
path += [cwd + '/port/st7735']
|
||||
|
||||
for item in list:
|
||||
if os.path.isfile(os.path.join(cwd, item, 'SConscript')):
|
||||
objs = objs + SConscript(os.path.join(item, 'SConscript'))
|
||||
|
||||
startup_path_prefix = SDK_LIB
|
||||
|
||||
if rtconfig.CROSS_TOOL == 'gcc':
|
||||
src += [cwd + '/../libraries/STM32H7xx_HAL/CMSIS/Device/ST/STM32H7xx/Source/Templates/gcc/startup_stm32h750xx.s']
|
||||
elif rtconfig.CROSS_TOOL == 'keil':
|
||||
src += [cwd + '/../libraries/STM32H7xx_HAL/CMSIS/Device/ST/STM32H7xx/Source/Templates/arm/startup_stm32h750xx.s']
|
||||
elif rtconfig.CROSS_TOOL == 'iar':
|
||||
src += [cwd + '/../libraries/STM32H7xx_HAL/CMSIS/Device/ST/STM32H7xx/Source/Templates/iar/startup_stm32h750xx.s']
|
||||
if rtconfig.PLATFORM in ['gcc']:
|
||||
src += [startup_path_prefix + '/STM32H7xx_HAL/CMSIS/Device/ST/STM32H7xx/Source/Templates/gcc/startup_stm32h750xx.s']
|
||||
elif rtconfig.PLATFORM in ['armcc', 'armclang']:
|
||||
src += [startup_path_prefix + '/STM32H7xx_HAL/CMSIS/Device/ST/STM32H7xx/Source/Templates/arm/startup_stm32h750xx.s']
|
||||
elif rtconfig.PLATFORM in ['iccarm']:
|
||||
src += [startup_path_prefix + '/STM32H7xx_HAL/CMSIS/Device/ST/STM32H7xx/Source/Templates/iar/startup_stm32h750xx.s']
|
||||
|
||||
# STM32H743xx || STM32H750xx || STM32F753xx
|
||||
# You can select chips from the list above
|
||||
|
||||
@@ -21,14 +21,64 @@
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#define STM32_FLASH_START_ADRESS ((uint32_t)0x08000000)
|
||||
#define STM32_FLASH_SIZE (128 * 1024)
|
||||
#define STM32_FLASH_END_ADDRESS ((uint32_t)(STM32_FLASH_START_ADRESS + STM32_FLASH_SIZE))
|
||||
/*-------------------------- CHIP CONFIG BEGIN --------------------------*/
|
||||
|
||||
#define STM32_SRAM_SIZE (128)//DTCM
|
||||
#define STM32_SRAM_END (0x20000000 + STM32_SRAM_SIZE * 1024)
|
||||
#define CHIP_FAMILY_STM32
|
||||
#define CHIP_SERIES_STM32H7
|
||||
#define CHIP_NAME_STM32H750XBHX
|
||||
|
||||
#if defined(__CC_ARM) || defined(__CLANG_ARM)
|
||||
/*-------------------------- CHIP CONFIG END --------------------------*/
|
||||
|
||||
/*-------------------------- ROM/RAM CONFIG BEGIN --------------------------*/
|
||||
#define ROM_START ((uint32_t)0x80000000)
|
||||
#define ROM_SIZE (128)
|
||||
#define ROM_END ((uint32_t)(ROM_START + ROM_SIZE * 1024))
|
||||
|
||||
#define RAM_START (0x20000000)//DTCM_region
|
||||
#define RAM_SIZE (128)
|
||||
#define RAM_END (RAM_START + RAM_SIZE * 1024)
|
||||
|
||||
/*-------------------------- ROM/RAM CONFIG END --------------------------*/
|
||||
|
||||
/*-------------------------- CLOCK CONFIG BEGIN --------------------------*/
|
||||
|
||||
#define BSP_CLOCK_SOURCE ("HSE")
|
||||
#define BSP_CLOCK_SOURCE_FREQ_MHZ ((int32_t)0)
|
||||
#define BSP_CLOCK_SYSTEM_FREQ_MHZ ((int32_t)480)
|
||||
|
||||
/*-------------------------- CLOCK CONFIG END --------------------------*/
|
||||
|
||||
/*-------------------------- UART CONFIG BEGIN --------------------------*/
|
||||
|
||||
/** After configuring corresponding UART or UART DMA, you can use it.
|
||||
*
|
||||
* STEP 1, define macro define related to the serial port opening based on the serial port number
|
||||
* such as #define BSP_USING_UATR1
|
||||
*
|
||||
* STEP 2, according to the corresponding pin of serial port, define the related serial port information macro
|
||||
* such as #define BSP_UART1_TX_PIN "PA9"
|
||||
* #define BSP_UART1_RX_PIN "PA10"
|
||||
*
|
||||
* STEP 3, if you want using SERIAL DMA, you must open it in the RT-Thread Settings.
|
||||
* RT-Thread Setting -> Components -> Device Drivers -> Serial Device Drivers -> Enable Serial DMA Mode
|
||||
*
|
||||
* STEP 4, according to serial port number to define serial port tx/rx DMA function in the board.h file
|
||||
* such as #define BSP_UART1_RX_USING_DMA
|
||||
*
|
||||
*/
|
||||
|
||||
#define BSP_UART1_RX_BUFSIZE 256
|
||||
#define BSP_UART1_TX_BUFSIZE 256
|
||||
|
||||
#define STM32_FLASH_START_ADRESS ROM_START
|
||||
#define STM32_FLASH_SIZE ROM_SIZE
|
||||
#define STM32_FLASH_END_ADDRESS ROM_END
|
||||
|
||||
#define STM32_SRAM_SIZE RAM_SIZE
|
||||
#define STM32_SRAM_START RAM_START
|
||||
#define STM32_SRAM_END RAM_END
|
||||
|
||||
#if defined(__ARMCC_VERSION)
|
||||
extern int Image$$RW_IRAM1$$ZI$$Limit;
|
||||
#define HEAP_BEGIN (&Image$$RW_IRAM1$$ZI$$Limit)
|
||||
#elif __ICCARM__
|
||||
|
||||
+3
-68
@@ -11,10 +11,11 @@
|
||||
#include <board.h>
|
||||
|
||||
#ifdef BSP_USING_LCD_SPI
|
||||
#include <lcd.h>
|
||||
#include <lcd_port.h>
|
||||
#include <string.h>
|
||||
|
||||
// #define DRV_DEBUG
|
||||
#define DRV_DEBUG
|
||||
#define LOG_TAG "drv.lcd"
|
||||
#include <drv_log.h>
|
||||
|
||||
@@ -53,46 +54,6 @@ static rt_err_t drv_lcd_control(struct rt_device *device, int cmd, void *args)
|
||||
case RTGRAPHIC_CTRL_RECT_UPDATE:
|
||||
{
|
||||
LCD_FillRGBRect(0, 0, _lcd.lcd_info.framebuffer, _lcd.lcd_info.width, _lcd.lcd_info.height);
|
||||
/* update */
|
||||
// if (_lcd.cur_buf)
|
||||
// {
|
||||
// /* back_buf is being used */
|
||||
// memcpy(_lcd.front_buf, _lcd.lcd_info.framebuffer, LCD_BUF_SIZE);
|
||||
// /* Configure the color frame buffer start address */
|
||||
// LCD_FillRGBRect(0, 0, _lcd.front_buf, _lcd.lcd_info.width, _lcd.lcd_info.height);
|
||||
// _lcd.cur_buf = 0;
|
||||
// }
|
||||
// else
|
||||
// {
|
||||
// /* front_buf is being used */
|
||||
// memcpy(_lcd.back_buf, _lcd.lcd_info.framebuffer, LCD_BUF_SIZE);
|
||||
// /* Configure the color frame buffer start address */
|
||||
// LCD_FillRGBRect(0, 0, _lcd.back_buf, _lcd.lcd_info.width, _lcd.lcd_info.height);
|
||||
// _lcd.cur_buf = 1;
|
||||
// }
|
||||
// rt_sem_take(&_lcd.lcd_lock, RT_TICK_PER_SECOND / 20);
|
||||
|
||||
// /* update */
|
||||
// if (_lcd.cur_buf)
|
||||
// {
|
||||
// /* back_buf is being used */
|
||||
// memcpy(_lcd.front_buf, _lcd.lcd_info.framebuffer, LCD_BUF_SIZE);
|
||||
// /* Configure the color frame buffer start address */
|
||||
// LTDC_LAYER(&LtdcHandle, 0)->CFBAR &= ~(LTDC_LxCFBAR_CFBADD);
|
||||
// LTDC_LAYER(&LtdcHandle, 0)->CFBAR = (uint32_t)(_lcd.front_buf);
|
||||
// _lcd.cur_buf = 0;
|
||||
// }
|
||||
// else
|
||||
// {
|
||||
// /* front_buf is being used */
|
||||
// memcpy(_lcd.back_buf, _lcd.lcd_info.framebuffer, LCD_BUF_SIZE);
|
||||
// /* Configure the color frame buffer start address */
|
||||
// LTDC_LAYER(&LtdcHandle, 0)->CFBAR &= ~(LTDC_LxCFBAR_CFBADD);
|
||||
// LTDC_LAYER(&LtdcHandle, 0)->CFBAR = (uint32_t)(_lcd.back_buf);
|
||||
// _lcd.cur_buf = 1;
|
||||
// }
|
||||
// rt_sem_take(&_lcd.lcd_lock, RT_TICK_PER_SECOND / 20);
|
||||
// HAL_LTDC_Relaod(&LtdcHandle, LTDC_SRCR_VBR);
|
||||
}
|
||||
break;
|
||||
|
||||
@@ -137,32 +98,6 @@ rt_err_t stm32_lcd_init(struct drv_lcd_device *lcd)
|
||||
|
||||
return result;
|
||||
}
|
||||
#if defined(LCD_BACKLIGHT_USING_PWM)
|
||||
void turn_on_lcd_backlight(void)
|
||||
{
|
||||
struct rt_device_pwm *pwm_dev;
|
||||
|
||||
/* turn on the LCD backlight */
|
||||
pwm_dev = (struct rt_device_pwm *)rt_device_find(LCD_PWM_DEV_NAME);
|
||||
/* pwm frequency:100K = 10000ns */
|
||||
rt_pwm_set(pwm_dev, LCD_PWM_DEV_CHANNEL, 10000, 5000);
|
||||
rt_pwm_enable(pwm_dev, LCD_PWM_DEV_CHANNEL);
|
||||
}
|
||||
#elif defined(LCD_BACKLIGHT_USING_GPIO)
|
||||
void turn_on_lcd_backlight(void)
|
||||
{
|
||||
rt_pin_mode(LCD_BL_GPIO_NUM, PIN_MODE_OUTPUT);
|
||||
rt_pin_mode(LCD_DISP_GPIO_NUM, PIN_MODE_OUTPUT);
|
||||
|
||||
rt_pin_write(LCD_DISP_GPIO_NUM, PIN_HIGH);
|
||||
rt_pin_write(LCD_BL_GPIO_NUM, PIN_HIGH);
|
||||
}
|
||||
#else
|
||||
void turn_on_lcd_backlight(void)
|
||||
{
|
||||
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifdef RT_USING_DEVICE_OPS
|
||||
const static struct rt_device_ops lcd_ops =
|
||||
@@ -234,7 +169,7 @@ int drv_lcd_hw_init(void)
|
||||
}
|
||||
else
|
||||
{
|
||||
turn_on_lcd_backlight();
|
||||
LCD_SetBrightness(MAX_BRIGHTNESS);
|
||||
}
|
||||
|
||||
__exit:
|
||||
+54
-125
@@ -28,111 +28,17 @@
|
||||
#include <drv_log.h>
|
||||
|
||||
|
||||
#define QSPI_CS_PIN GET_PIN(B, 6)
|
||||
#define FS_PARTITION_NAME "fs_qspi"
|
||||
#define FAL_USING_NOR_FLASH_2_DEV_NAME "W25Q64_q"
|
||||
|
||||
#define FS_PARTITION_NAME "fs_qspi"
|
||||
#define FAL_USING_NOR_FLASH_2_DEV_NAME "W25Q64_q"
|
||||
|
||||
static sfud_flash_t sfud_dev = NULL;
|
||||
|
||||
static int init(void);
|
||||
static int read(long offset, uint8_t *buf, size_t size);
|
||||
static int write(long offset, const uint8_t *buf, size_t size);
|
||||
static int erase(long offset, size_t size);
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
static char w25qxx_read_status_register2(struct rt_qspi_device *device)
|
||||
{
|
||||
/* 0x35 read status register2 */
|
||||
char instruction = 0x35, status;
|
||||
|
||||
rt_qspi_send_then_recv(device, &instruction, 1, &status, 1);
|
||||
|
||||
return status;
|
||||
}
|
||||
|
||||
static void w25qxx_write_enable(struct rt_qspi_device *device)
|
||||
{
|
||||
/* 0x06 write enable */
|
||||
char instruction = 0x06;
|
||||
|
||||
rt_qspi_send(device, &instruction, 1);
|
||||
}
|
||||
|
||||
static void w25qxx_enter_qspi_mode(struct rt_qspi_device *device)
|
||||
{
|
||||
char status = 0;
|
||||
/* 0x38 enter qspi mode */
|
||||
char instruction = 0x38;
|
||||
char write_status2_buf[2] = {0};
|
||||
|
||||
/* 0x31 write status register2 */
|
||||
write_status2_buf[0] = 0x31;
|
||||
|
||||
status = w25qxx_read_status_register2(device);
|
||||
if (!(status & 0x02))
|
||||
{
|
||||
status |= 1 << 1;
|
||||
w25qxx_write_enable(device);
|
||||
write_status2_buf[1] = status;
|
||||
// rt_qspi_send(device, &write_status2_buf, 2);
|
||||
rt_qspi_send(device, write_status2_buf, 2);
|
||||
rt_qspi_send(device, &instruction, 1);
|
||||
rt_kprintf("flash already enter qspi mode\n");
|
||||
rt_thread_mdelay(10);
|
||||
}
|
||||
}
|
||||
|
||||
/* read the JEDEC SFDP command must run at 50 MHz or less */
|
||||
#define RT_SFUD_DEFAULT_SPI_CFG \
|
||||
{ \
|
||||
.mode = RT_SPI_MODE_2 | RT_SPI_MSB, \
|
||||
.data_width = 8, \
|
||||
.max_hz = 20000000, \
|
||||
}
|
||||
|
||||
#ifdef SFUD_USING_QSPI
|
||||
#define RT_SFUD_DEFAULT_QSPI_CFG \
|
||||
{ \
|
||||
RT_SFUD_DEFAULT_SPI_CFG, \
|
||||
.medium_size = 0x800000, \
|
||||
.ddr_mode = 0, \
|
||||
.qspi_dl_width = 4, \
|
||||
}
|
||||
#endif /* SFUD_USING_QSPI */
|
||||
|
||||
static int rt_hw_qspi_flash_with_sfud_init(void)
|
||||
{
|
||||
stm32_qspi_bus_attach_device("qspi1", "qspi10", RT_NULL, 4, RT_NULL, RT_NULL);
|
||||
// stm32_qspi_bus_attach_device("qspi1", "qspi10", RT_NULL, 4, w25qxx_enter_qspi_mode, RT_NULL);
|
||||
// stm32_qspi_bus_attach_device("qspi1", "qspi10", QSPI_CS_PIN, 4, w25qxx_enter_qspi_mode, RT_NULL);
|
||||
|
||||
/* init W25Q16 , And register as a block device */
|
||||
|
||||
struct rt_spi_configuration cfg = RT_SFUD_DEFAULT_SPI_CFG;
|
||||
struct rt_qspi_configuration qspi_cfg = RT_SFUD_DEFAULT_QSPI_CFG;
|
||||
// // return rt_sfud_flash_probe_ex(FAL_USING_NOR_FLASH_2_DEV_NAME, "qspi10", &cfg, &qspi_cfg);
|
||||
if(RT_NULL == rt_sfud_flash_probe_ex(FAL_USING_NOR_FLASH_2_DEV_NAME, "qspi10", &cfg, &qspi_cfg))
|
||||
|
||||
|
||||
// if (RT_NULL == rt_sfud_flash_probe(FAL_USING_NOR_FLASH_2_DEV_NAME, "qspi10"))
|
||||
{
|
||||
return -RT_ERROR;
|
||||
}
|
||||
return RT_EOK;
|
||||
}
|
||||
INIT_DEVICE_EXPORT(rt_hw_qspi_flash_with_sfud_init);
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
static sfud_flash_t sfud_dev = NULL;
|
||||
struct fal_flash_dev nor_flash1 =
|
||||
{
|
||||
.name = FAL_USING_NOR_FLASH_2_DEV_NAME,
|
||||
@@ -140,7 +46,7 @@ struct fal_flash_dev nor_flash1 =
|
||||
.len = 8 * 1024 * 1024,
|
||||
.blk_size = 4096,
|
||||
.ops = {init, read, write, erase},
|
||||
.write_gran = 1
|
||||
.write_gran = 4
|
||||
};
|
||||
|
||||
static int init(void)
|
||||
@@ -205,40 +111,63 @@ static int erase(long offset, size_t size)
|
||||
|
||||
|
||||
|
||||
static int mnt_qspi(void)
|
||||
{
|
||||
struct rt_device *mtd_dev = RT_NULL;
|
||||
|
||||
mtd_dev = fal_mtd_nor_device_create(FS_PARTITION_NAME);
|
||||
if (!mtd_dev)
|
||||
|
||||
|
||||
char w25qxx_read_status_register2(struct rt_qspi_device *device)
|
||||
{
|
||||
/* 0x35 read status register2 */
|
||||
char instruction = 0x35, status;
|
||||
|
||||
rt_qspi_send_then_recv(device, &instruction, 1, &status, 1);
|
||||
|
||||
return status;
|
||||
}
|
||||
|
||||
void w25qxx_write_enable(struct rt_qspi_device *device)
|
||||
{
|
||||
/* 0x06 write enable */
|
||||
char instruction = 0x06;
|
||||
|
||||
rt_qspi_send(device, &instruction, 1);
|
||||
}
|
||||
|
||||
void w25qxx_enter_qspi_mode(struct rt_qspi_device *device)
|
||||
{
|
||||
char status = 0;
|
||||
/* 0x38 enter qspi mode */
|
||||
char instruction = 0x38;
|
||||
char write_status2_buf[2] = {0};
|
||||
|
||||
/* 0x31 write status register2 */
|
||||
write_status2_buf[0] = 0x31;
|
||||
|
||||
status = w25qxx_read_status_register2(device);
|
||||
if (!(status & 0x02))
|
||||
{
|
||||
LOG_E("Can't create a mtd device on '%s' partition.", FS_PARTITION_NAME);
|
||||
status |= 1 << 1;
|
||||
w25qxx_write_enable(device);
|
||||
write_status2_buf[1] = status;
|
||||
rt_qspi_send(device, &write_status2_buf, 2);
|
||||
rt_qspi_send(device, &instruction, 1);
|
||||
rt_kprintf("flash already enter qspi mode\n");
|
||||
rt_thread_mdelay(10);
|
||||
}
|
||||
else
|
||||
}
|
||||
|
||||
static int rt_qspi_flash_init(void)
|
||||
{
|
||||
extern rt_spi_flash_device_t rt_sfud_flash_probe(const char *spi_flash_dev_name, const char *spi_dev_name);
|
||||
|
||||
stm32_qspi_bus_attach_device("qspi1", "qspi10", RT_NULL, 4, w25qxx_enter_qspi_mode, RT_NULL);
|
||||
if (RT_NULL == rt_sfud_flash_probe(FAL_USING_NOR_FLASH_2_DEV_NAME, "qspi10"))
|
||||
{
|
||||
/* mount littlefs */
|
||||
if (dfs_mount(FS_PARTITION_NAME, "/qspi", "lfs", 0, 0) == 0)
|
||||
{
|
||||
LOG_I("Filesystem initialized!");
|
||||
}
|
||||
else
|
||||
{
|
||||
dfs_mkfs("lfs", FS_PARTITION_NAME);
|
||||
/* mount littlefs */
|
||||
if (dfs_mount(FS_PARTITION_NAME, "/qspi", "lfs", 0, 0) == 0)
|
||||
{
|
||||
LOG_I("Filesystem initialized!");
|
||||
}
|
||||
else
|
||||
{
|
||||
LOG_E("Failed to initialize filesystem!");
|
||||
}
|
||||
}
|
||||
LOG_E("Failed to probe flash device "FAL_USING_NOR_FLASH_2_DEV_NAME);
|
||||
return -RT_ERROR;
|
||||
}
|
||||
return RT_EOK;
|
||||
}
|
||||
INIT_APP_EXPORT(mnt_qspi);
|
||||
|
||||
INIT_DEVICE_EXPORT(rt_qspi_flash_init);
|
||||
|
||||
|
||||
#endif/* BSP_USING_QSPI_FLASH */
|
||||
+13
-7
@@ -7,17 +7,22 @@
|
||||
* Date Author Notes
|
||||
* 2020-08-07 NU-LL first version
|
||||
*/
|
||||
#include <rtthread.h>
|
||||
#include <rtdevice.h>
|
||||
#include <drv_spi.h>
|
||||
#include <spi_flash.h>
|
||||
#include <spi_flash_sfud.h>
|
||||
#include <fal.h>
|
||||
#include <dfs_fs.h>
|
||||
|
||||
// #define DRV_DEBUG
|
||||
#define LOG_TAG "drv.spiflash"
|
||||
#define DRV_DEBUG
|
||||
#define LOG_TAG "drv.spiflash"
|
||||
#include <drv_log.h>
|
||||
|
||||
#define FS_PARTITION_NAME "filesystem"
|
||||
#define FS_PARTITION_NAME "filesystem"
|
||||
|
||||
#define SPI_CS_GPIO GPIOD
|
||||
#define SPI_CS_PIN GPIO_PIN_6
|
||||
#define SPI_CS_GPIO GPIOD
|
||||
#define SPI_CS_PIN GPIO_PIN_6
|
||||
|
||||
static int rt_hw_spi_flash_with_sfud_init(void)
|
||||
{
|
||||
@@ -25,8 +30,9 @@ static int rt_hw_spi_flash_with_sfud_init(void)
|
||||
rt_hw_spi_device_attach("spi1", "spi10", SPI_CS_GPIO, SPI_CS_PIN);
|
||||
|
||||
/* init W25Q16 , And register as a block device */
|
||||
if (RT_NULL == rt_sfud_flash_probe("W25Q64", "spi10"))
|
||||
if (RT_NULL == rt_sfud_flash_probe(FAL_USING_NOR_FLASH_DEV_NAME, "spi10"))
|
||||
{
|
||||
LOG_E("Failed to probe flash device "FAL_USING_NOR_FLASH_DEV_NAME);
|
||||
return -RT_ERROR;
|
||||
}
|
||||
return err;
|
||||
@@ -59,7 +65,7 @@ static int mnt(void)
|
||||
if (dfs_mount(FS_PARTITION_NAME, "/", "lfs", 0, 0) == 0)
|
||||
{
|
||||
mkdir("/qspi",0x777);
|
||||
LOG_I("Filesystem initialized!");
|
||||
LOG_I("mkdir /qspi. Filesystem initialized!");
|
||||
}
|
||||
else
|
||||
{
|
||||
+10
-6
@@ -25,10 +25,12 @@
|
||||
#ifndef _FAL_CFG_H_
|
||||
#define _FAL_CFG_H_
|
||||
|
||||
#ifdef RT_USING_FAL
|
||||
|
||||
#include <rtconfig.h>
|
||||
#include <board.h>
|
||||
|
||||
#define NOR_FLASH_DEV_NAME "W25Q64"
|
||||
#define FLASH_SIZE_GRANULARITY_128K (16 * 128 * 1024)
|
||||
|
||||
/* ===================== Flash device Configuration ========================= */
|
||||
extern const struct fal_flash_dev stm32_onchip_flash_128k;
|
||||
@@ -45,12 +47,14 @@ extern struct fal_flash_dev nor_flash1;
|
||||
/* ====================== Partition Configuration ========================== */
|
||||
#ifdef FAL_PART_HAS_TABLE_CFG
|
||||
/* partition table */
|
||||
#define FAL_PART_TABLE \
|
||||
{ \
|
||||
{FAL_PART_MAGIC_WORD, "bootloader", "onchip_flash_128k", 0, 128*1024, 0}, \
|
||||
{FAL_PART_MAGIC_WORD, "filesystem", NOR_FLASH_DEV_NAME, 0, 8*1024*1024, 0}, \
|
||||
{FAL_PART_MAGIC_WORD, "fs_qspi", "W25Q64_q", 0, 8*1024*1024, 0}, \
|
||||
#define FAL_PART_TABLE \
|
||||
{ \
|
||||
{FAL_PART_MAGIC_WORD, "bootloader", "onchip_flash_128k", 0, 128*1024, 0}, \
|
||||
{FAL_PART_MAGIC_WORD, "filesystem", FAL_USING_NOR_FLASH_DEV_NAME, 0, 8*1024*1024, 0}, \
|
||||
{FAL_PART_MAGIC_WORD, "fs_qspi", "W25Q64_q", 0, 8*1024*1024, 0}, \
|
||||
}
|
||||
#endif /* FAL_PART_HAS_TABLE_CFG */
|
||||
|
||||
#endif /* RT_USING_FAL */
|
||||
|
||||
#endif /* _FAL_CFG_H_ */
|
||||
+18
-18
@@ -1,23 +1,23 @@
|
||||
#ifndef __FONT_H
|
||||
#define __FONT_H
|
||||
#define __FONT_H
|
||||
|
||||
|
||||
//32*32汉字字模
|
||||
const unsigned char hanzi32[]={
|
||||
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x40,0x00,0x00,0x30,0xC0,0x01,0x00,0xE0,0xE0,0x01,0x00,0xC0,0xE1,0x00,0x00,0xC0,0x61,0x00,0x18,0x80,0xF1,0xFF,0x3F,0x00,0x70,0x00,0x18,0x00,0x3E,0x00,0x18,0x04,0xDA,0x01,0x18,0x1C,0xEE,0x01,0x18,0x38,0x6F,0x60,0x18,0x78,0xF7,0xFF,0x18,0x70,0x31,0x86,0x18,0xB0,0x19,0x06,0x18,0x80,0x09,0x06,0x18,0x80,0x05,0x86,0x19,0xC0,0xFE,0xFF,0x1B,0xC0,0x00,0x06,0x1A,0xC0,0x30,0x66,0x18,0xE0,0x70,0xE6,0x19,0x7C,0x30,0xE6,0x18,0x70,0x30,0xE6,0x18,0x60,0x30,0xE6,0x18,0x70,0xF8,0xFF,0x1C,0x70,0x30,0xE0,0x1C,0x70,0x00,0x00,0x1C,0x70,0x00,0xF0,0x1F,0x70,0x00,0x80,0x0F,0x00,0x00,0x00,0x07,0x00,0x00,0x00,0x00,//淘
|
||||
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x80,0x00,0x00,0x0E,0xC0,0x01,0x00,0xFE,0xFF,0x03,0x00,0x0E,0xC0,0x01,0x00,0x0E,0xC0,0x01,0x00,0x0E,0xC0,0x01,0x00,0xFE,0xFF,0x01,0x00,0x0E,0xC0,0x01,0x00,0x0E,0xC0,0x01,0x00,0x0E,0xC0,0x01,0x00,0xFE,0xFF,0x01,0x00,0x0E,0xC0,0x01,0x00,0x06,0x40,0x00,0x00,0x00,0x00,0x00,0x30,0x70,0x0C,0x18,0xF0,0xFF,0xFC,0x3F,0x70,0x70,0x0C,0x18,0x70,0x70,0x0C,0x18,0x70,0x70,0x0C,0x18,0x70,0x70,0x0C,0x18,0xF0,0x7F,0xFC,0x1F,0x70,0x70,0x0C,0x18,0x70,0x70,0x0C,0x18,0x70,0x70,0x0C,0x18,0x70,0x70,0x0C,0x18,0x70,0x70,0x0C,0x18,0xF0,0x7F,0xFC,0x1F,0x70,0x70,0x0C,0x18,0x10,0x00,0x04,0x00,0x00,0x00,0x00,0x00,//晶
|
||||
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x30,0x00,0x00,0x00,0x70,0x00,0x00,0x1C,0x70,0x00,0xFC,0x1F,0x70,0x00,0x00,0x8C,0x71,0x00,0x20,0x8C,0x77,0x00,0xE0,0x8C,0x73,0x04,0xF0,0x8E,0x73,0x1E,0x70,0x8E,0xF3,0x1F,0x70,0x8E,0xFB,0x0C,0x70,0x8E,0x7F,0x0C,0x70,0xFE,0x73,0x0C,0x30,0x86,0x73,0x0C,0x30,0x86,0x73,0x0C,0x30,0x96,0x73,0x0C,0xF8,0xBF,0x73,0x0C,0x38,0xF8,0x73,0x0C,0x00,0xB8,0x73,0x0C,0x00,0xB8,0xF3,0x0F,0x00,0xBE,0x73,0x06,0xE0,0x9B,0x73,0x30,0x7E,0x98,0x73,0x30,0x1C,0x98,0x13,0x30,0x08,0x9C,0x03,0x30,0x00,0x9C,0x03,0x30,0x00,0x8C,0x03,0x78,0xE0,0x0F,0xFF,0x7F,0x80,0x07,0x00,0x00,0x00,0x03,0x00,0x00,0x00,0x00,0x00,0x00,//驰
|
||||
//32*32汉字字模
|
||||
const unsigned char hanzi32[]={
|
||||
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x40,0x00,0x00,0x30,0xC0,0x01,0x00,0xE0,0xE0,0x01,0x00,0xC0,0xE1,0x00,0x00,0xC0,0x61,0x00,0x18,0x80,0xF1,0xFF,0x3F,0x00,0x70,0x00,0x18,0x00,0x3E,0x00,0x18,0x04,0xDA,0x01,0x18,0x1C,0xEE,0x01,0x18,0x38,0x6F,0x60,0x18,0x78,0xF7,0xFF,0x18,0x70,0x31,0x86,0x18,0xB0,0x19,0x06,0x18,0x80,0x09,0x06,0x18,0x80,0x05,0x86,0x19,0xC0,0xFE,0xFF,0x1B,0xC0,0x00,0x06,0x1A,0xC0,0x30,0x66,0x18,0xE0,0x70,0xE6,0x19,0x7C,0x30,0xE6,0x18,0x70,0x30,0xE6,0x18,0x60,0x30,0xE6,0x18,0x70,0xF8,0xFF,0x1C,0x70,0x30,0xE0,0x1C,0x70,0x00,0x00,0x1C,0x70,0x00,0xF0,0x1F,0x70,0x00,0x80,0x0F,0x00,0x00,0x00,0x07,0x00,0x00,0x00,0x00,//淘
|
||||
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x80,0x00,0x00,0x0E,0xC0,0x01,0x00,0xFE,0xFF,0x03,0x00,0x0E,0xC0,0x01,0x00,0x0E,0xC0,0x01,0x00,0x0E,0xC0,0x01,0x00,0xFE,0xFF,0x01,0x00,0x0E,0xC0,0x01,0x00,0x0E,0xC0,0x01,0x00,0x0E,0xC0,0x01,0x00,0xFE,0xFF,0x01,0x00,0x0E,0xC0,0x01,0x00,0x06,0x40,0x00,0x00,0x00,0x00,0x00,0x30,0x70,0x0C,0x18,0xF0,0xFF,0xFC,0x3F,0x70,0x70,0x0C,0x18,0x70,0x70,0x0C,0x18,0x70,0x70,0x0C,0x18,0x70,0x70,0x0C,0x18,0xF0,0x7F,0xFC,0x1F,0x70,0x70,0x0C,0x18,0x70,0x70,0x0C,0x18,0x70,0x70,0x0C,0x18,0x70,0x70,0x0C,0x18,0x70,0x70,0x0C,0x18,0xF0,0x7F,0xFC,0x1F,0x70,0x70,0x0C,0x18,0x10,0x00,0x04,0x00,0x00,0x00,0x00,0x00,//晶
|
||||
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x30,0x00,0x00,0x00,0x70,0x00,0x00,0x1C,0x70,0x00,0xFC,0x1F,0x70,0x00,0x00,0x8C,0x71,0x00,0x20,0x8C,0x77,0x00,0xE0,0x8C,0x73,0x04,0xF0,0x8E,0x73,0x1E,0x70,0x8E,0xF3,0x1F,0x70,0x8E,0xFB,0x0C,0x70,0x8E,0x7F,0x0C,0x70,0xFE,0x73,0x0C,0x30,0x86,0x73,0x0C,0x30,0x86,0x73,0x0C,0x30,0x96,0x73,0x0C,0xF8,0xBF,0x73,0x0C,0x38,0xF8,0x73,0x0C,0x00,0xB8,0x73,0x0C,0x00,0xB8,0xF3,0x0F,0x00,0xBE,0x73,0x06,0xE0,0x9B,0x73,0x30,0x7E,0x98,0x73,0x30,0x1C,0x98,0x13,0x30,0x08,0x9C,0x03,0x30,0x00,0x9C,0x03,0x30,0x00,0x8C,0x03,0x78,0xE0,0x0F,0xFF,0x7F,0x80,0x07,0x00,0x00,0x00,0x03,0x00,0x00,0x00,0x00,0x00,0x00,//驰
|
||||
};
|
||||
//16*16汉字字模
|
||||
const unsigned char hanzi16[]={
|
||||
0x80,0x00,0x80,0x00,0x80,0x00,0xFC,0x1F,0x40,0x00,0x40,0x00,0xFF,0x7F,0x20,0x00,0x10,0x00,0xF0,0x0F,0x00,0x08,0x00,0x04,0x60,0x02,0x80,0x01,0x00,0x02,0x00,0x04,//专
|
||||
0x00,0x01,0x04,0x02,0x08,0x00,0xE8,0x3F,0x01,0x02,0x02,0x02,0x02,0x02,0x08,0x02,0xC8,0x3F,0x04,0x02,0x07,0x02,0x04,0x02,0x04,0x02,0x04,0x02,0xF4,0x7F,0x00,0x00,//注
|
||||
0x00,0x00,0xF8,0x0F,0x08,0x08,0x08,0x08,0xF8,0x0F,0x08,0x08,0x08,0x08,0xF8,0x0F,0x20,0x02,0x22,0x22,0x24,0x22,0x28,0x12,0x28,0x0A,0x20,0x02,0xFF,0x7F,0x00,0x00,//显
|
||||
0x00,0x00,0xFC,0x1F,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xFF,0x7F,0x80,0x00,0x80,0x00,0x88,0x08,0x88,0x10,0x84,0x20,0x82,0x40,0x81,0x40,0xA0,0x00,0x40,0x00,//示
|
||||
0x40,0x00,0x80,0x00,0x80,0x00,0xFF,0x7F,0x20,0x00,0x20,0x00,0x20,0x00,0xE0,0x0F,0x20,0x08,0x20,0x08,0x20,0x08,0x10,0x08,0x10,0x08,0x08,0x08,0x04,0x05,0x02,0x02,//方
|
||||
0x80,0x00,0xFE,0x3F,0x02,0x20,0x20,0x00,0xFF,0x7F,0x10,0x04,0x78,0x02,0xC0,0x03,0x3C,0x1C,0x80,0x00,0xFF,0x7F,0xA0,0x02,0x90,0x04,0x8C,0x18,0x83,0x60,0x80,0x00,//案
|
||||
//16*16汉字字模
|
||||
const unsigned char hanzi16[]={
|
||||
0x80,0x00,0x80,0x00,0x80,0x00,0xFC,0x1F,0x40,0x00,0x40,0x00,0xFF,0x7F,0x20,0x00,0x10,0x00,0xF0,0x0F,0x00,0x08,0x00,0x04,0x60,0x02,0x80,0x01,0x00,0x02,0x00,0x04,//专
|
||||
0x00,0x01,0x04,0x02,0x08,0x00,0xE8,0x3F,0x01,0x02,0x02,0x02,0x02,0x02,0x08,0x02,0xC8,0x3F,0x04,0x02,0x07,0x02,0x04,0x02,0x04,0x02,0x04,0x02,0xF4,0x7F,0x00,0x00,//注
|
||||
0x00,0x00,0xF8,0x0F,0x08,0x08,0x08,0x08,0xF8,0x0F,0x08,0x08,0x08,0x08,0xF8,0x0F,0x20,0x02,0x22,0x22,0x24,0x22,0x28,0x12,0x28,0x0A,0x20,0x02,0xFF,0x7F,0x00,0x00,//显
|
||||
0x00,0x00,0xFC,0x1F,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xFF,0x7F,0x80,0x00,0x80,0x00,0x88,0x08,0x88,0x10,0x84,0x20,0x82,0x40,0x81,0x40,0xA0,0x00,0x40,0x00,//示
|
||||
0x40,0x00,0x80,0x00,0x80,0x00,0xFF,0x7F,0x20,0x00,0x20,0x00,0x20,0x00,0xE0,0x0F,0x20,0x08,0x20,0x08,0x20,0x08,0x10,0x08,0x10,0x08,0x08,0x08,0x04,0x05,0x02,0x02,//方
|
||||
0x80,0x00,0xFE,0x3F,0x02,0x20,0x20,0x00,0xFF,0x7F,0x10,0x04,0x78,0x02,0xC0,0x03,0x3C,0x1C,0x80,0x00,0xFF,0x7F,0xA0,0x02,0x90,0x04,0x8C,0x18,0x83,0x60,0x80,0x00,//案
|
||||
};
|
||||
//QQ图像
|
||||
//QQ图像
|
||||
const unsigned char qqimage[3200]={ /* 0X00,0X10,0X28,0X00,0X28,0X00,0X01,0X1B,*/
|
||||
0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,
|
||||
0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XBE,0XF7,0X7D,0XEF,
|
||||
@@ -316,8 +316,8 @@ const unsigned char asc2_1206[95][12]={
|
||||
{0x00,0x00,0x00,0x00,0x00,0x00,0xFF,0xF0,0x00,0x00,0x00,0x00},/*"|",92*/
|
||||
{0x00,0x00,0x40,0x20,0x7B,0xE0,0x04,0x00,0x00,0x00,0x00,0x00},/*"}",93*/
|
||||
{0x40,0x00,0x80,0x00,0x40,0x00,0x20,0x00,0x20,0x00,0x40,0x00},/*"~",94*/
|
||||
};
|
||||
const unsigned char asc2_1608[95][16]={
|
||||
};
|
||||
const unsigned char asc2_1608[95][16]={
|
||||
{0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00},/*" ",0*/
|
||||
{0x00,0x00,0x00,0x00,0x00,0x00,0x1F,0xCC,0x00,0x0C,0x00,0x00,0x00,0x00,0x00,0x00},/*"!",1*/
|
||||
{0x00,0x00,0x08,0x00,0x30,0x00,0x60,0x00,0x08,0x00,0x30,0x00,0x60,0x00,0x00,0x00},/*""",2*/
|
||||
@@ -413,5 +413,5 @@ const unsigned char asc2_1608[95][16]={
|
||||
{0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xFF,0xFF,0x00,0x00,0x00,0x00,0x00,0x00},/*"|",92*/
|
||||
{0x00,0x00,0x40,0x02,0x40,0x02,0x3E,0xFC,0x01,0x00,0x00,0x00,0x00,0x00,0x00,0x00},/*"}",93*/
|
||||
{0x00,0x00,0x60,0x00,0x80,0x00,0x80,0x00,0x40,0x00,0x40,0x00,0x20,0x00,0x20,0x00},/*"~",94*/
|
||||
};
|
||||
};
|
||||
#endif
|
||||
+115
-122
@@ -1,28 +1,10 @@
|
||||
#include "lcd.h"
|
||||
#include "rttlogo.h"
|
||||
#include "font.h"
|
||||
|
||||
// #define DRV_DEBUG
|
||||
#define DRV_DEBUG
|
||||
#define LOG_TAG "spi.lcd"
|
||||
#include <drv_log.h>
|
||||
|
||||
|
||||
#define LCD_SPI_DEVICE_NAME "spi40"
|
||||
#define LCD_PWM_DEV_NAME "pwm1"
|
||||
#define LCD_PWM_DEV_CHANNEL (2)
|
||||
#define LCD_PWM_DEV_TIME (10000)//pwm frequency:100K = 10000ns
|
||||
|
||||
#define WR_RS_PIN GET_PIN(E, 13)
|
||||
#define CS_PIN GET_PIN(E, 11)
|
||||
//SPI显示屏接口
|
||||
//LCD_RS
|
||||
#define LCD_RS_SET rt_pin_write(WR_RS_PIN, PIN_HIGH)
|
||||
#define LCD_RS_RESET rt_pin_write(WR_RS_PIN, PIN_LOW)
|
||||
//LCD_CS
|
||||
#define LCD_CS_SET rt_pin_write(CS_PIN, PIN_HIGH)
|
||||
#define LCD_CS_RESET rt_pin_write(CS_PIN, PIN_LOW)
|
||||
|
||||
|
||||
static int32_t lcd_init(void);
|
||||
static int32_t lcd_writereg(uint8_t reg,uint8_t* pdata,uint32_t length);
|
||||
static int32_t lcd_readreg(uint8_t reg,uint8_t* pdata);
|
||||
@@ -42,106 +24,51 @@ ST7735_IO_t st7735_pIO = {
|
||||
ST7735_Object_t st7735_pObj;
|
||||
uint32_t st7735_id;
|
||||
static struct rt_spi_device *spi_dev_lcd;
|
||||
#ifdef LCD_BACKLIGHT_USING_PWM
|
||||
static struct rt_device_pwm *lcd_pwm_dev;
|
||||
static uint32_t NowBrightness;
|
||||
#endif
|
||||
extern unsigned char WeActStudiologo[];
|
||||
|
||||
#ifdef DRV_DEBUG
|
||||
#ifdef FINSH_USING_MSH
|
||||
static int show_logo(int argc, char **argv)
|
||||
{
|
||||
uint8_t text[20];
|
||||
// ST7735_LCD_Driver.ReadID(&st7735_pObj,&st7735_id);
|
||||
|
||||
// LCD_Light(LCD_PWM_DEV_TIME, 300);
|
||||
|
||||
ST7735_LCD_Driver.DrawBitmap(&st7735_pObj,0,0,WeActStudiologo);
|
||||
LCD_SetBrightness(LCD_PWM_DEV_TIME-1);
|
||||
rt_thread_mdelay(1000);
|
||||
// LCD_SetBrightness(0);
|
||||
|
||||
// ST7735_LCD_Driver.FillRect(&st7735_pObj,0,0,160,80,BLACK);
|
||||
|
||||
// sprintf((char *)&text,"WeAct Studio");
|
||||
// LCD_ShowString(4,4,160,16,16,text);
|
||||
// sprintf((char *)&text,"STM32H7xx 0x%X",HAL_GetDEVID());
|
||||
// LCD_ShowString(4,22,160,16,16,text);
|
||||
// sprintf((char *)&text,"LCD ID: 0x%X",st7735_id);
|
||||
// LCD_ShowString(4,40,160,16,16,text);
|
||||
return 0;
|
||||
}
|
||||
MSH_CMD_EXPORT(show_logo, show logo);
|
||||
#endif /* FINSH_USING_MSH */
|
||||
#endif /* DRV_DEBUG */
|
||||
|
||||
static int LCD_Init(void)
|
||||
{
|
||||
rt_pin_mode(WR_RS_PIN, PIN_MODE_OUTPUT);
|
||||
rt_pin_mode(CS_PIN, PIN_MODE_OUTPUT);
|
||||
|
||||
spi_dev_lcd = (struct rt_spi_device *)rt_device_find(LCD_SPI_DEVICE_NAME);
|
||||
if (!spi_dev_lcd)
|
||||
{
|
||||
LOG_E("tft-lcd init failed! can't find %s device!\n", LCD_SPI_DEVICE_NAME);
|
||||
return -RT_ERROR;
|
||||
}
|
||||
|
||||
ST7735_RegisterBusIO(&st7735_pObj,&st7735_pIO);
|
||||
if(ST7735_ERROR == ST7735_LCD_Driver.Init(&st7735_pObj,ST7735_FORMAT_RBG565,ST7735_ORIENTATION_LANDSCAPE_ROT180))
|
||||
{
|
||||
LOG_E("st7735 init failed!");
|
||||
// return ;
|
||||
}
|
||||
ST7735_LCD_Driver.FillRect(&st7735_pObj,0,0,160,80,BLACK);
|
||||
ST7735_LCD_Driver.ReadID(&st7735_pObj,&st7735_id);
|
||||
ST7735_LCD_Driver.DisplayOn(&st7735_pObj);
|
||||
LOG_D("lcd id:0X%08X", st7735_id);
|
||||
LOG_D("chip id:0X%08X", HAL_GetDEVID());
|
||||
|
||||
/* turn on the LCD backlight */
|
||||
lcd_pwm_dev = (struct rt_device_pwm *)rt_device_find(LCD_PWM_DEV_NAME);
|
||||
if (!lcd_pwm_dev)
|
||||
{
|
||||
LOG_E("lcd pwm pin init failed! can't find %s device!\n", LCD_SPI_DEVICE_NAME);
|
||||
return -RT_ERROR;
|
||||
}
|
||||
/* pwm frequency:100K = 10000ns */
|
||||
rt_pwm_set(lcd_pwm_dev, LCD_PWM_DEV_CHANNEL, LCD_PWM_DEV_TIME, 5000);
|
||||
rt_pwm_enable(lcd_pwm_dev, LCD_PWM_DEV_CHANNEL);
|
||||
|
||||
ST7735_LCD_Driver.DrawBitmap(&st7735_pObj,0,0,WeActStudiologo);
|
||||
// ST7735_LCD_Driver.FillRGBRect(&st7735_pObj, 0, 0, (uint8_t *)image_rttlogo, 240, 69);
|
||||
return RT_EOK;
|
||||
}
|
||||
INIT_COMPONENT_EXPORT(LCD_Init);
|
||||
//LCD_RS
|
||||
#define LCD_RS_SET rt_pin_write(WR_RS_PIN, PIN_HIGH)
|
||||
#define LCD_RS_RESET rt_pin_write(WR_RS_PIN, PIN_LOW)
|
||||
//LCD_CS
|
||||
#define LCD_CS_SET rt_pin_write(CS_PIN, PIN_HIGH)
|
||||
#define LCD_CS_RESET rt_pin_write(CS_PIN, PIN_LOW)
|
||||
|
||||
|
||||
void LCD_SetBrightness(uint32_t Brightness)
|
||||
{
|
||||
Brightness = ((Brightness >= LCD_PWM_DEV_TIME)?(LCD_PWM_DEV_TIME-1):Brightness);
|
||||
rt_pwm_set(lcd_pwm_dev, LCD_PWM_DEV_CHANNEL, LCD_PWM_DEV_TIME, Brightness);
|
||||
#ifdef LCD_BACKLIGHT_USING_PWM
|
||||
Brightness = ((Brightness >= MAX_BRIGHTNESS)?(MAX_BRIGHTNESS-1):Brightness);
|
||||
rt_pwm_set(lcd_pwm_dev, LCD_PWM_DEV_CHANNEL, MAX_BRIGHTNESS, Brightness);
|
||||
NowBrightness = Brightness;
|
||||
#else
|
||||
rt_pin_mode(LCD_DISP_GPIO_NUM, PIN_MODE_OUTPUT);
|
||||
rt_pin_write(LCD_DISP_GPIO_NUM, PIN_LOW);
|
||||
#endif
|
||||
}
|
||||
|
||||
uint32_t LCD_GetBrightness(void)
|
||||
{
|
||||
#ifdef LCD_BACKLIGHT_USING_PWM
|
||||
return NowBrightness;
|
||||
#else
|
||||
return 0;
|
||||
#endif
|
||||
}
|
||||
|
||||
uint16_t POINT_COLOR=0xFFFF; //画笔颜色
|
||||
uint16_t BACK_COLOR=BLACK; //背景色
|
||||
//在指定位置显示一个字符
|
||||
//x,y:起始坐标
|
||||
//num:要显示的字符:" "--->"~"
|
||||
//size:字体大小 12/16
|
||||
//mode:叠加方式(1)还是非叠加方式(0)
|
||||
|
||||
//在指定位置显示一个字符
|
||||
//x,y:起始坐标
|
||||
//num:要显示的字符:" "--->"~"
|
||||
//size:字体大小 12/16
|
||||
//mode:叠加方式(1)还是非叠加方式(0)
|
||||
void LCD_ShowChar(uint16_t x,uint16_t y,uint8_t num,uint8_t size,uint8_t mode)
|
||||
{
|
||||
uint8_t temp,t1,t;
|
||||
uint16_t y0=y;
|
||||
uint16_t x0=x;
|
||||
uint16_t colortemp=POINT_COLOR;
|
||||
uint32_t h,w;
|
||||
|
||||
uint16_t write[size][size==12?6:8];
|
||||
@@ -150,85 +77,83 @@ void LCD_ShowChar(uint16_t x,uint16_t y,uint8_t num,uint8_t size,uint8_t mode)
|
||||
ST7735_GetXSize(&st7735_pObj,&w);
|
||||
ST7735_GetYSize(&st7735_pObj,&h);
|
||||
|
||||
//设置窗口
|
||||
num=num-' ';//得到偏移后的值
|
||||
//设置窗口
|
||||
num=num-' ';//得到偏移后的值
|
||||
count = 0;
|
||||
|
||||
if(!mode) //非叠加方式
|
||||
if(!mode) //非叠加方式
|
||||
{
|
||||
for(t=0;t<size;t++)
|
||||
{
|
||||
if(size==12)temp=asc2_1206[num][t]; //调用1206字体
|
||||
else temp=asc2_1608[num][t]; //调用1608字体
|
||||
if(size==12)temp=asc2_1206[num][t]; //调用1206字体
|
||||
else temp=asc2_1608[num][t]; //调用1608字体
|
||||
|
||||
for(t1=0;t1<8;t1++)
|
||||
{
|
||||
if(temp&0x80)
|
||||
POINT_COLOR=(colortemp&0xFF)<<8|colortemp>>8;
|
||||
write[count][t/2]=(BRUSH_POINT_COLOR&0xFF)<<8|BRUSH_POINT_COLOR>>8;
|
||||
else
|
||||
POINT_COLOR=(BACK_COLOR&0xFF)<<8|BACK_COLOR>>8;
|
||||
write[count][t/2]=(BRUSH_BACK_COLOR&0xFF)<<8|BRUSH_BACK_COLOR>>8;
|
||||
|
||||
write[count][t/2]=POINT_COLOR;
|
||||
count ++;
|
||||
if(count >= size) count =0;
|
||||
|
||||
temp<<=1;
|
||||
y++;
|
||||
if(y>=h){POINT_COLOR=colortemp;return;}//超区域了
|
||||
if(y>=h){return;}//超区域了
|
||||
if((y-y0)==size)
|
||||
{
|
||||
y=y0;
|
||||
x++;
|
||||
if(x>=w){POINT_COLOR=colortemp;return;}//超区域了
|
||||
if(x>=w){return;}//超区域了
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
else//叠加方式
|
||||
else//叠加方式
|
||||
{
|
||||
for(t=0;t<size;t++)
|
||||
{
|
||||
if(size==12)temp=asc2_1206[num][t]; //调用1206字体
|
||||
else temp=asc2_1608[num][t]; //调用1608字体
|
||||
if(size==12)temp=asc2_1206[num][t]; //调用1206字体
|
||||
else temp=asc2_1608[num][t]; //调用1608字体
|
||||
for(t1=0;t1<8;t1++)
|
||||
{
|
||||
if(temp&0x80)
|
||||
write[count][t/2]=(POINT_COLOR&0xFF)<<8|POINT_COLOR>>8;
|
||||
write[count][t/2]=(BRUSH_POINT_COLOR&0xFF)<<8|BRUSH_POINT_COLOR>>8;
|
||||
count ++;
|
||||
if(count >= size) count =0;
|
||||
|
||||
temp<<=1;
|
||||
y++;
|
||||
if(y>=h){POINT_COLOR=colortemp;return;}//超区域了
|
||||
if(y>=h){return;}//超区域了
|
||||
if((y-y0)==size)
|
||||
{
|
||||
y=y0;
|
||||
x++;
|
||||
if(x>=w){POINT_COLOR=colortemp;return;}//超区域了
|
||||
if(x>=w){return;}//超区域了
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
ST7735_FillRGBRect(&st7735_pObj,x0,y0,(uint8_t *)&write,size==12?6:8,size);
|
||||
POINT_COLOR=colortemp;
|
||||
}
|
||||
|
||||
//显示字符串
|
||||
//x,y:起点坐标
|
||||
//width,height:区域大小
|
||||
//size:字体大小
|
||||
//*p:字符串起始地址
|
||||
//显示字符串
|
||||
//x,y:起点坐标
|
||||
//width,height:区域大小
|
||||
//size:字体大小
|
||||
//*p:字符串起始地址
|
||||
void LCD_ShowString(uint16_t x,uint16_t y,uint16_t width,uint16_t height,uint8_t size,uint8_t *p)
|
||||
{
|
||||
uint8_t x0=x;
|
||||
width+=x;
|
||||
height+=y;
|
||||
while((*p<='~')&&(*p>=' '))//判断是不是非法字符!
|
||||
while((*p<='~')&&(*p>=' '))//判断是不是非法字符!
|
||||
{
|
||||
if(x>=width){x=x0;y+=size;}
|
||||
if(y>=height)break;//退出
|
||||
if(y>=height)break;//退出
|
||||
LCD_ShowChar(x,y,*p,size,0);
|
||||
x+=size/2;
|
||||
p++;
|
||||
@@ -291,3 +216,71 @@ static int32_t lcd_recvdata(uint8_t* pdata,uint32_t length)
|
||||
return ((result == length)?0:-1);
|
||||
}
|
||||
|
||||
static int LCD_Init(void)
|
||||
{
|
||||
rt_pin_mode(WR_RS_PIN, PIN_MODE_OUTPUT);
|
||||
rt_pin_mode(CS_PIN, PIN_MODE_OUTPUT);
|
||||
|
||||
spi_dev_lcd = (struct rt_spi_device *)rt_device_find(LCD_SPI_DEVICE_NAME);
|
||||
if (!spi_dev_lcd)
|
||||
{
|
||||
LOG_E("tft-lcd init failed! can't find %s device!\n", LCD_SPI_DEVICE_NAME);
|
||||
return -RT_ERROR;
|
||||
}
|
||||
|
||||
ST7735_RegisterBusIO(&st7735_pObj,&st7735_pIO);
|
||||
if(ST7735_ERROR == ST7735_LCD_Driver.Init(&st7735_pObj,ST7735_FORMAT_RBG565,ST7735_ORIENTATION_LANDSCAPE_ROT180))
|
||||
{
|
||||
LOG_E("st7735 init failed!");
|
||||
// return ;
|
||||
}
|
||||
ST7735_LCD_Driver.FillRect(&st7735_pObj,0,0,160,80,BLACK);
|
||||
ST7735_LCD_Driver.ReadID(&st7735_pObj,&st7735_id);
|
||||
ST7735_LCD_Driver.DisplayOn(&st7735_pObj);
|
||||
LOG_D("lcd id:0X%08X", st7735_id);
|
||||
LOG_D("chip id:0X%08X", HAL_GetDEVID());
|
||||
|
||||
#ifdef LCD_BACKLIGHT_USING_PWM
|
||||
/* turn on the LCD backlight */
|
||||
lcd_pwm_dev = (struct rt_device_pwm *)rt_device_find(LCD_PWM_DEV_NAME);
|
||||
if (!lcd_pwm_dev)
|
||||
{
|
||||
LOG_E("lcd pwm pin init failed! can't find %s device!\n", LCD_SPI_DEVICE_NAME);
|
||||
return -RT_ERROR;
|
||||
}
|
||||
/* pwm frequency:100K = 10000ns */
|
||||
rt_pwm_set(lcd_pwm_dev, LCD_PWM_DEV_CHANNEL, LCD_PWM_DEV_TIME, 5000);
|
||||
rt_pwm_enable(lcd_pwm_dev, LCD_PWM_DEV_CHANNEL);
|
||||
#endif
|
||||
LCD_SetBrightness(MAX_BRIGHTNESS);
|
||||
|
||||
ST7735_LCD_Driver.DrawBitmap(&st7735_pObj,0,0,WeActStudiologo);
|
||||
return RT_EOK;
|
||||
}
|
||||
INIT_COMPONENT_EXPORT(LCD_Init);
|
||||
|
||||
#ifdef DRV_DEBUG
|
||||
#ifdef FINSH_USING_MSH
|
||||
static int show_logo(int argc, char **argv)
|
||||
{
|
||||
uint8_t text[20];
|
||||
|
||||
LCD_SetBrightness(MAX_BRIGHTNESS);
|
||||
|
||||
ST7735_LCD_Driver.DrawBitmap(&st7735_pObj,0,0,WeActStudiologo);
|
||||
rt_thread_mdelay(1000);
|
||||
|
||||
ST7735_LCD_Driver.FillRect(&st7735_pObj,0,0,160,80,BLACK);
|
||||
|
||||
sprintf((char *)&text,"WeAct Studio");
|
||||
LCD_ShowString(4,4,160,16,16,text);
|
||||
sprintf((char *)&text,"STM32H7xx 0x%X",HAL_GetDEVID());
|
||||
LCD_ShowString(4,22,160,16,16,text);
|
||||
sprintf((char *)&text,"LCD ID: 0x%X",st7735_id);
|
||||
LCD_ShowString(4,40,160,16,16,text);
|
||||
return 0;
|
||||
}
|
||||
MSH_CMD_EXPORT(show_logo, show logo);
|
||||
#endif /* FINSH_USING_MSH */
|
||||
#endif /* DRV_DEBUG */
|
||||
|
||||
+23
-10
@@ -18,20 +18,33 @@
|
||||
#define GREEN 0x07E0
|
||||
#define CYAN 0x7FFF
|
||||
#define YELLOW 0xFFE0
|
||||
#define BROWN 0XBC40 //רɫ
|
||||
#define BRRED 0XFC07 //רºìÉ«
|
||||
#define GRAY 0X8430 //»ÒÉ«
|
||||
#define DARKBLUE 0X01CF //ÉîÀ¶É«
|
||||
#define LIGHTBLUE 0X7D7C //dzÀ¶É«
|
||||
#define GRAYBLUE 0X5458 //»ÒÀ¶É«
|
||||
#define BROWN 0XBC40 //棕色
|
||||
#define BRRED 0XFC07 //棕红色
|
||||
#define GRAY 0X8430 //灰色
|
||||
#define DARKBLUE 0X01CF //深蓝色
|
||||
#define LIGHTBLUE 0X7D7C //浅蓝色
|
||||
#define GRAYBLUE 0X5458 //灰蓝色
|
||||
|
||||
// lcd spi
|
||||
#define LCD_SPI_DEVICE_NAME "spi40"
|
||||
#define LCD_PWM_DEV_NAME "pwm1"
|
||||
#define LCD_PWM_DEV_CHANNEL (2)
|
||||
#define LCD_PWM_DEV_TIME (10000)//pwm frequency:100K = 10000ns
|
||||
#define MAX_BRIGHTNESS LCD_PWM_DEV_TIME
|
||||
|
||||
#define WR_RS_PIN GET_PIN(E, 13)
|
||||
#define CS_PIN GET_PIN(E, 11)
|
||||
|
||||
//lcd display gpio
|
||||
#define LCD_DISP_GPIO_NUM GET_PIN(E, 10)
|
||||
|
||||
// lcd brush color
|
||||
#define BRUSH_POINT_COLOR WHITE
|
||||
#define BRUSH_BACK_COLOR BLACK
|
||||
|
||||
extern ST7735_Object_t st7735_pObj;
|
||||
extern uint32_t st7735_id;
|
||||
|
||||
extern uint16_t POINT_COLOR; //»±ÊÑÕÉ«
|
||||
extern uint16_t BACK_COLOR; //±³¾°É«
|
||||
|
||||
|
||||
void LCD_SetBrightness(uint32_t Brightness);
|
||||
uint32_t LCD_GetBrightness(void);
|
||||
void LCD_ShowChar(uint16_t x,uint16_t y,uint8_t num,uint8_t size,uint8_t mode);
|
||||
File diff suppressed because it is too large
Load Diff
@@ -13,10 +13,16 @@
|
||||
#define RT_TICK_PER_SECOND 1000
|
||||
#define RT_USING_OVERFLOW_CHECK
|
||||
#define RT_USING_HOOK
|
||||
#define RT_HOOK_USING_FUNC_PTR
|
||||
#define RT_USING_IDLE_HOOK
|
||||
#define RT_IDLE_HOOK_LIST_SIZE 4
|
||||
#define IDLE_THREAD_STACK_SIZE 256
|
||||
|
||||
/* kservice optimization */
|
||||
|
||||
#define RT_KSERVICE_USING_STDLIB
|
||||
#define RT_DEBUG
|
||||
#define RT_DEBUG_COLOR
|
||||
|
||||
/* Inter-Thread communication */
|
||||
|
||||
@@ -30,7 +36,9 @@
|
||||
|
||||
#define RT_USING_MEMPOOL
|
||||
#define RT_USING_MEMHEAP
|
||||
#define RT_MEMHEAP_FAST_MODE
|
||||
#define RT_USING_MEMHEAP_AS_HEAP
|
||||
#define RT_USING_MEMHEAP_AUTO_BINDING
|
||||
#define RT_USING_HEAP
|
||||
|
||||
/* Kernel Device Object */
|
||||
@@ -39,7 +47,7 @@
|
||||
#define RT_USING_CONSOLE
|
||||
#define RT_CONSOLEBUF_SIZE 128
|
||||
#define RT_CONSOLE_DEVICE_NAME "uart1"
|
||||
#define RT_VER_NUM 0x40003
|
||||
#define RT_VER_NUM 0x50000
|
||||
#define ARCH_ARM
|
||||
#define RT_USING_CPU_FFS
|
||||
#define ARCH_ARM_CORTEX_M
|
||||
@@ -51,42 +59,39 @@
|
||||
#define RT_USING_USER_MAIN
|
||||
#define RT_MAIN_THREAD_STACK_SIZE 2048
|
||||
#define RT_MAIN_THREAD_PRIORITY 10
|
||||
|
||||
/* C++ features */
|
||||
|
||||
|
||||
/* Command shell */
|
||||
|
||||
#define RT_USING_MSH
|
||||
#define RT_USING_FINSH
|
||||
#define FINSH_USING_MSH
|
||||
#define FINSH_THREAD_NAME "tshell"
|
||||
#define FINSH_THREAD_PRIORITY 20
|
||||
#define FINSH_THREAD_STACK_SIZE 4096
|
||||
#define FINSH_USING_HISTORY
|
||||
#define FINSH_HISTORY_LINES 5
|
||||
#define FINSH_USING_SYMTAB
|
||||
#define FINSH_USING_DESCRIPTION
|
||||
#define FINSH_THREAD_PRIORITY 20
|
||||
#define FINSH_THREAD_STACK_SIZE 4096
|
||||
#define FINSH_CMD_SIZE 80
|
||||
#define FINSH_USING_MSH
|
||||
#define FINSH_USING_MSH_DEFAULT
|
||||
#define FINSH_USING_MSH_ONLY
|
||||
#define MSH_USING_BUILT_IN_COMMANDS
|
||||
#define FINSH_USING_DESCRIPTION
|
||||
#define FINSH_ARG_MAX 10
|
||||
|
||||
/* Device virtual file system */
|
||||
|
||||
#define RT_USING_DFS
|
||||
#define DFS_USING_POSIX
|
||||
#define DFS_USING_WORKDIR
|
||||
#define DFS_FILESYSTEMS_MAX 4
|
||||
#define DFS_FILESYSTEM_TYPES_MAX 4
|
||||
#define DFS_FD_MAX 16
|
||||
#define RT_USING_DFS_DEVFS
|
||||
#define RT_USING_FAL
|
||||
#define FAL_DEBUG_CONFIG
|
||||
#define FAL_DEBUG 1
|
||||
#define FAL_PART_HAS_TABLE_CFG
|
||||
#define FAL_USING_SFUD_PORT
|
||||
#define FAL_USING_NOR_FLASH_DEV_NAME "norflash0"
|
||||
|
||||
/* Device Drivers */
|
||||
|
||||
#define RT_USING_DEVICE_IPC
|
||||
#define RT_PIPE_BUFSZ 512
|
||||
#define RT_USING_SERIAL
|
||||
#define RT_USING_SERIAL_V2
|
||||
#define RT_SERIAL_USING_DMA
|
||||
#define RT_SERIAL_RB_BUFSZ 64
|
||||
#define RT_USING_PIN
|
||||
#define RT_USING_PWM
|
||||
#define RT_USING_MTD_NOR
|
||||
@@ -96,36 +101,33 @@
|
||||
#define RT_SFUD_USING_SFDP
|
||||
#define RT_SFUD_USING_FLASH_INFO_TABLE
|
||||
#define RT_SFUD_USING_QSPI
|
||||
#define RT_SFUD_SPI_MAX_HZ 50000000
|
||||
#define RT_SFUD_SPI_MAX_HZ 10000000
|
||||
|
||||
/* Using USB */
|
||||
|
||||
|
||||
/* POSIX layer and C standard library */
|
||||
/* C/C++ and POSIX layer */
|
||||
|
||||
#define RT_LIBC_DEFAULT_TIMEZONE 8
|
||||
|
||||
/* POSIX (Portable Operating System Interface) layer */
|
||||
|
||||
|
||||
/* Interprocess Communication (IPC) */
|
||||
|
||||
|
||||
/* Socket is in the 'Network' category */
|
||||
|
||||
#define RT_USING_LIBC
|
||||
#define RT_USING_POSIX
|
||||
|
||||
/* Network */
|
||||
|
||||
/* Socket abstraction layer */
|
||||
|
||||
|
||||
/* Network interface device */
|
||||
|
||||
|
||||
/* light weight TCP/IP stack */
|
||||
|
||||
|
||||
/* AT commands */
|
||||
|
||||
|
||||
/* VBUS(Virtual Software BUS) */
|
||||
|
||||
|
||||
/* Utilities */
|
||||
|
||||
|
||||
/* RT-Thread Utestcases */
|
||||
|
||||
|
||||
/* RT-Thread online packages */
|
||||
|
||||
/* IoT - internet of things */
|
||||
@@ -147,23 +149,39 @@
|
||||
|
||||
/* language packages */
|
||||
|
||||
/* JSON: JavaScript Object Notation, a lightweight data-interchange format */
|
||||
|
||||
|
||||
/* XML: Extensible Markup Language */
|
||||
|
||||
|
||||
/* multimedia packages */
|
||||
|
||||
/* LVGL: powerful and easy-to-use embedded GUI library */
|
||||
|
||||
|
||||
/* u8g2: a monochrome graphic library */
|
||||
|
||||
|
||||
/* PainterEngine: A cross-platform graphics application framework written in C language */
|
||||
|
||||
|
||||
/* tools packages */
|
||||
|
||||
|
||||
/* system packages */
|
||||
|
||||
#define PKG_USING_FAL
|
||||
#define FAL_DEBUG_CONFIG
|
||||
#define FAL_DEBUG 1
|
||||
#define FAL_PART_HAS_TABLE_CFG
|
||||
#define FAL_USING_SFUD_PORT
|
||||
#define FAL_USING_NOR_FLASH_DEV_NAME "W25Q64"
|
||||
#define PKG_USING_FAL_V00500
|
||||
#define PKG_FAL_VER_NUM 0x00500
|
||||
/* enhanced kernel services */
|
||||
|
||||
|
||||
/* acceleration: Assembly language or algorithmic acceleration packages */
|
||||
|
||||
|
||||
/* CMSIS: ARM Cortex-M Microcontroller Software Interface Standard */
|
||||
|
||||
|
||||
/* Micrium: Micrium software products porting for RT-Thread */
|
||||
|
||||
#define PKG_USING_LITTLEFS
|
||||
#define PKG_USING_LITTLEFS_V205
|
||||
#define LFS_READ_SIZE 256
|
||||
@@ -171,17 +189,61 @@
|
||||
#define LFS_BLOCK_SIZE 4096
|
||||
#define LFS_CACHE_SIZE 256
|
||||
#define LFS_BLOCK_CYCLES 100
|
||||
#define LFS_THREADSAFE
|
||||
#define LFS_LOOKAHEAD_MAX 128
|
||||
|
||||
/* peripheral libraries and drivers */
|
||||
|
||||
#define BSP_USING_SPI1
|
||||
|
||||
/* Kendryte SDK */
|
||||
|
||||
|
||||
/* AI packages */
|
||||
|
||||
|
||||
/* miscellaneous packages */
|
||||
|
||||
/* project laboratory */
|
||||
|
||||
/* samples: kernel and components samples */
|
||||
|
||||
|
||||
/* entertainment: terminal games and other interesting software packages */
|
||||
|
||||
|
||||
/* Arduino libraries */
|
||||
|
||||
|
||||
/* Projects */
|
||||
|
||||
|
||||
/* Sensors */
|
||||
|
||||
|
||||
/* Display */
|
||||
|
||||
|
||||
/* Timing */
|
||||
|
||||
|
||||
/* Data Processing */
|
||||
|
||||
|
||||
/* Data Storage */
|
||||
|
||||
/* Communication */
|
||||
|
||||
|
||||
/* Device Control */
|
||||
|
||||
|
||||
/* Other */
|
||||
|
||||
/* Signal IO */
|
||||
|
||||
|
||||
/* Uncategorized */
|
||||
|
||||
#define SOC_FAMILY_STM32
|
||||
#define SOC_SERIES_STM32H7
|
||||
|
||||
@@ -194,7 +256,7 @@
|
||||
#define BSP_USING_SPI_FLASH
|
||||
#define BSP_USING_QSPI_FLASH
|
||||
#define BSP_USING_LCD_SPI
|
||||
#define LCD_BACKLIGHT_USING_PWM
|
||||
#define LCD_BACKLIGHT_USING_GPIO
|
||||
|
||||
/* On-chip Peripheral Drivers */
|
||||
|
||||
@@ -203,6 +265,7 @@
|
||||
#define BSP_USING_UART1
|
||||
#define BSP_USING_QSPI
|
||||
#define BSP_USING_SPI
|
||||
#define BSP_USING_SPI1
|
||||
#define BSP_USING_SPI4
|
||||
#define BSP_USING_PWM
|
||||
#define BSP_USING_PWM1
|
||||
|
||||
@@ -17,13 +17,13 @@ if os.getenv('RTT_ROOT'):
|
||||
# EXEC_PATH is the compiler execute path, for example, CodeSourcery, Keil MDK, IAR
|
||||
if CROSS_TOOL == 'gcc':
|
||||
PLATFORM = 'gcc'
|
||||
EXEC_PATH = r'C:\Users\XXYYZZ'
|
||||
EXEC_PATH = r'/opt/gcc-arm-none-eabi/bin/'
|
||||
elif CROSS_TOOL == 'keil':
|
||||
PLATFORM = 'armcc'
|
||||
EXEC_PATH = r'C:/Keil_v5'
|
||||
EXEC_PATH = r'D:/Keil/Keil_v5'
|
||||
elif CROSS_TOOL == 'iar':
|
||||
PLATFORM = 'iar'
|
||||
EXEC_PATH = r'C:/Program Files (x86)/IAR Systems/Embedded Workbench 8.0'
|
||||
PLATFORM = 'iccarm'
|
||||
EXEC_PATH = r'C:/Program Files (x86)/IAR Systems/Embedded Workbench 8.3'
|
||||
|
||||
if os.getenv('RTT_EXEC_PATH'):
|
||||
EXEC_PATH = os.getenv('RTT_EXEC_PATH')
|
||||
@@ -57,7 +57,7 @@ if PLATFORM == 'gcc':
|
||||
else:
|
||||
CFLAGS += ' -O2'
|
||||
|
||||
CXXFLAGS = CFLAGS
|
||||
CXXFLAGS = CFLAGS
|
||||
CFLAGS += ' -std=c99'
|
||||
|
||||
POST_ACTION = OBJCPY + ' -O binary $TARGET rtthread.bin\n' + SIZE + ' $TARGET \n'
|
||||
@@ -89,12 +89,46 @@ elif PLATFORM == 'armcc':
|
||||
else:
|
||||
CFLAGS += ' -O2'
|
||||
|
||||
CXXFLAGS = CFLAGS
|
||||
CXXFLAGS = CFLAGS
|
||||
CFLAGS += ' -std=c99'
|
||||
|
||||
POST_ACTION = 'fromelf --bin $TARGET --output rtthread.bin \nfromelf -z $TARGET'
|
||||
|
||||
elif PLATFORM == 'iar':
|
||||
elif PLATFORM == 'armclang':
|
||||
# toolchains
|
||||
CC = 'armclang'
|
||||
CXX = 'armclang'
|
||||
AS = 'armasm'
|
||||
AR = 'armar'
|
||||
LINK = 'armlink'
|
||||
TARGET_EXT = 'axf'
|
||||
|
||||
DEVICE = ' --cpu Cortex-M7.fp.sp '
|
||||
CFLAGS = ' --target=arm-arm-none-eabi -mcpu=cortex-M7 '
|
||||
CFLAGS += ' -mcpu=cortex-M7 -mfpu=fpv4-sp-d16 '
|
||||
CFLAGS += ' -mfloat-abi=hard -c -fno-rtti -funsigned-char -fshort-enums -fshort-wchar '
|
||||
CFLAGS += ' -gdwarf-3 -ffunction-sections '
|
||||
AFLAGS = DEVICE + ' --apcs=interwork '
|
||||
LFLAGS = DEVICE + ' --info sizes --info totals --info unused --info veneers '
|
||||
LFLAGS += ' --list rt-thread.map '
|
||||
LFLAGS += r' --strict --scatter "board\linker_scripts\link.sct" '
|
||||
CFLAGS += ' -I' + EXEC_PATH + '/ARM/ARMCLANG/include'
|
||||
LFLAGS += ' --libpath=' + EXEC_PATH + '/ARM/ARMCLANG/lib'
|
||||
|
||||
EXEC_PATH += '/ARM/ARMCLANG/bin/'
|
||||
|
||||
if BUILD == 'debug':
|
||||
CFLAGS += ' -g -O1' # armclang recommend
|
||||
AFLAGS += ' -g'
|
||||
else:
|
||||
CFLAGS += ' -O2'
|
||||
|
||||
CXXFLAGS = CFLAGS
|
||||
CFLAGS += ' -std=c99'
|
||||
|
||||
POST_ACTION = 'fromelf --bin $TARGET --output rtthread.bin \nfromelf -z $TARGET'
|
||||
|
||||
elif PLATFORM == 'iccarm':
|
||||
# toolchains
|
||||
CC = 'iccarm'
|
||||
CXX = 'iccarm'
|
||||
@@ -115,20 +149,20 @@ elif PLATFORM == 'iar':
|
||||
CFLAGS += ' --no_clustering'
|
||||
CFLAGS += ' --no_scheduling'
|
||||
CFLAGS += ' --endian=little'
|
||||
CFLAGS += ' --cpu=Cortex-M7'
|
||||
CFLAGS += ' -e'
|
||||
CFLAGS += ' --cpu=Cortex-M7'
|
||||
CFLAGS += ' -e'
|
||||
CFLAGS += ' --fpu=VFPv5_sp'
|
||||
CFLAGS += ' --dlib_config "' + EXEC_PATH + '/arm/INC/c/DLib_Config_Normal.h"'
|
||||
CFLAGS += ' --silent'
|
||||
|
||||
|
||||
AFLAGS = DEVICE
|
||||
AFLAGS += ' -s+'
|
||||
AFLAGS += ' -w+'
|
||||
AFLAGS += ' -r'
|
||||
AFLAGS += ' --cpu Cortex-M7'
|
||||
AFLAGS += ' --fpu VFPv5_sp'
|
||||
AFLAGS += ' -S'
|
||||
|
||||
AFLAGS += ' -s+'
|
||||
AFLAGS += ' -w+'
|
||||
AFLAGS += ' -r'
|
||||
AFLAGS += ' --cpu Cortex-M7'
|
||||
AFLAGS += ' --fpu VFPv5_sp'
|
||||
AFLAGS += ' -S'
|
||||
|
||||
if BUILD == 'debug':
|
||||
CFLAGS += ' --debug'
|
||||
CFLAGS += ' -On'
|
||||
@@ -139,7 +173,7 @@ elif PLATFORM == 'iar':
|
||||
LFLAGS += ' --entry __iar_program_start'
|
||||
|
||||
CXXFLAGS = CFLAGS
|
||||
|
||||
|
||||
EXEC_PATH = EXEC_PATH + '/arm/bin/'
|
||||
POST_ACTION = 'ielftool --bin $TARGET rtthread.bin'
|
||||
|
||||
|
||||
Reference in New Issue
Block a user