修正但仍有误
This commit is contained in:
16
board/ports/cherryusb/SConscript
Normal file
16
board/ports/cherryusb/SConscript
Normal file
@@ -0,0 +1,16 @@
|
||||
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('cherryusb-port', src, depend = ['RT_CHERRYUSB_DEVICE'], CPPPATH = CPPPATH)
|
||||
Return('group')
|
53
board/ports/cherryusb/cherryusb.c
Normal file
53
board/ports/cherryusb/cherryusb.c
Normal file
@@ -0,0 +1,53 @@
|
||||
/*
|
||||
* Copyright (c) 2025, RT-Thread Development Team
|
||||
*
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*
|
||||
* Change Logs:
|
||||
* Date Author Notes
|
||||
* 2025-01-17 Supperthomas first version
|
||||
*/
|
||||
#include "board.h"
|
||||
#include "rtthread.h"
|
||||
#include "drv_config.h"
|
||||
|
||||
static PCD_HandleTypeDef hpcd_USB_OTG_FS;
|
||||
void usb_dc_low_level_init(uint8_t busid)
|
||||
{
|
||||
hpcd_USB_OTG_FS.Instance = USB_OTG_FS;
|
||||
HAL_PCD_MspInit(&hpcd_USB_OTG_FS);
|
||||
}
|
||||
|
||||
void usb_dc_low_level_deinit(uint8_t busid)
|
||||
{
|
||||
HAL_PCD_MspDeInit(&hpcd_USB_OTG_FS);
|
||||
}
|
||||
|
||||
#ifdef RT_CHERRYUSB_DEVICE_TEMPLATE_CDC_ACM
|
||||
/* Register the EMAC device */
|
||||
static int rt_hw_stm32_cherryusb_cdc_init(void)
|
||||
{
|
||||
extern void cdc_acm_init(uint8_t busid, uintptr_t reg_base);
|
||||
cdc_acm_init(0, USB_OTG_FS_PERIPH_BASE);
|
||||
|
||||
return 0;
|
||||
}
|
||||
INIT_COMPONENT_EXPORT(rt_hw_stm32_cherryusb_cdc_init);
|
||||
static int cherry_usb_cdc_send(int argc, char **argv)
|
||||
{
|
||||
extern void cdc_acm_data_send_with_dtr_test(uint8_t busid);
|
||||
cdc_acm_data_send_with_dtr_test(0);
|
||||
return 0;
|
||||
}
|
||||
MSH_CMD_EXPORT(cherry_usb_cdc_send, send the cdc data for test)
|
||||
#endif
|
||||
|
||||
#ifdef USBD_IRQ_HANDLER
|
||||
void USBD_IRQ_HANDLER(void)
|
||||
{
|
||||
extern void USBD_IRQHandler(uint8_t busid);
|
||||
USBD_IRQHandler(0);
|
||||
}
|
||||
#else
|
||||
#error USBD_IRQ_HANDLER need to USB IRQ like #define USBD_IRQ_HANDLER OTG_HS_IRQHandler
|
||||
#endif
|
239
board/ports/cherryusb/usb_config.h
Normal file
239
board/ports/cherryusb/usb_config.h
Normal file
@@ -0,0 +1,239 @@
|
||||
/*
|
||||
* Copyright (c) 2025, RT-Thread Development Team
|
||||
*
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*
|
||||
* Change Logs:
|
||||
* Date Author Notes
|
||||
* 2025-01-17 Supperthomas first version
|
||||
*/
|
||||
#ifndef CHERRYUSB_CONFIG_H
|
||||
#define CHERRYUSB_CONFIG_H
|
||||
|
||||
/* ================ USB common Configuration ================ */
|
||||
|
||||
#define CONFIG_USB_PRINTF(...) printf(__VA_ARGS__)
|
||||
|
||||
#ifndef CONFIG_USB_DBG_LEVEL
|
||||
#define CONFIG_USB_DBG_LEVEL USB_DBG_INFO
|
||||
#endif
|
||||
|
||||
/* Enable print with color */
|
||||
#define CONFIG_USB_PRINTF_COLOR_ENABLE
|
||||
|
||||
/* data align size when use dma */
|
||||
#ifndef CONFIG_USB_ALIGN_SIZE
|
||||
#define CONFIG_USB_ALIGN_SIZE 4
|
||||
#endif
|
||||
|
||||
/* attribute data into no cache ram */
|
||||
#define USB_NOCACHE_RAM_SECTION __attribute__((section(".noncacheable")))
|
||||
|
||||
/* ================= USB Device Stack Configuration ================ */
|
||||
|
||||
/* Ep0 in and out transfer buffer */
|
||||
#ifndef CONFIG_USBDEV_REQUEST_BUFFER_LEN
|
||||
#define CONFIG_USBDEV_REQUEST_BUFFER_LEN 512
|
||||
#endif
|
||||
|
||||
/* Setup packet log for debug */
|
||||
// #define CONFIG_USBDEV_SETUP_LOG_PRINT
|
||||
|
||||
/* Check if the input descriptor is correct */
|
||||
// #define CONFIG_USBDEV_DESC_CHECK
|
||||
|
||||
/* Enable test mode */
|
||||
// #define CONFIG_USBDEV_TEST_MODE
|
||||
|
||||
#ifndef CONFIG_USBDEV_MSC_MAX_LUN
|
||||
#define CONFIG_USBDEV_MSC_MAX_LUN 1
|
||||
#endif
|
||||
|
||||
#ifndef CONFIG_USBDEV_MSC_MAX_BUFSIZE
|
||||
#define CONFIG_USBDEV_MSC_MAX_BUFSIZE 512
|
||||
#endif
|
||||
|
||||
#ifndef CONFIG_USBDEV_MSC_MANUFACTURER_STRING
|
||||
#define CONFIG_USBDEV_MSC_MANUFACTURER_STRING ""
|
||||
#endif
|
||||
|
||||
#ifndef CONFIG_USBDEV_MSC_PRODUCT_STRING
|
||||
#define CONFIG_USBDEV_MSC_PRODUCT_STRING ""
|
||||
#endif
|
||||
|
||||
#ifndef CONFIG_USBDEV_MSC_VERSION_STRING
|
||||
#define CONFIG_USBDEV_MSC_VERSION_STRING "0.01"
|
||||
#endif
|
||||
|
||||
// #define CONFIG_USBDEV_MSC_THREAD
|
||||
|
||||
#ifndef CONFIG_USBDEV_MSC_PRIO
|
||||
#define CONFIG_USBDEV_MSC_PRIO 4
|
||||
#endif
|
||||
|
||||
#ifndef CONFIG_USBDEV_MSC_STACKSIZE
|
||||
#define CONFIG_USBDEV_MSC_STACKSIZE 2048
|
||||
#endif
|
||||
|
||||
#ifndef CONFIG_USBDEV_RNDIS_RESP_BUFFER_SIZE
|
||||
#define CONFIG_USBDEV_RNDIS_RESP_BUFFER_SIZE 156
|
||||
#endif
|
||||
|
||||
#ifndef CONFIG_USBDEV_RNDIS_ETH_MAX_FRAME_SIZE
|
||||
#define CONFIG_USBDEV_RNDIS_ETH_MAX_FRAME_SIZE 2048
|
||||
#endif
|
||||
|
||||
#ifndef CONFIG_USBDEV_RNDIS_VENDOR_ID
|
||||
#define CONFIG_USBDEV_RNDIS_VENDOR_ID 0x0000ffff
|
||||
#endif
|
||||
|
||||
#ifndef CONFIG_USBDEV_RNDIS_VENDOR_DESC
|
||||
#define CONFIG_USBDEV_RNDIS_VENDOR_DESC "CherryUSB"
|
||||
#endif
|
||||
|
||||
#define CONFIG_USBDEV_RNDIS_USING_LWIP
|
||||
|
||||
/* ================ USB HOST Stack Configuration ================== */
|
||||
|
||||
#define CONFIG_USBHOST_MAX_RHPORTS 1
|
||||
#define CONFIG_USBHOST_MAX_EXTHUBS 1
|
||||
#define CONFIG_USBHOST_MAX_EHPORTS 4
|
||||
#define CONFIG_USBHOST_MAX_INTERFACES 8
|
||||
#define CONFIG_USBHOST_MAX_INTF_ALTSETTINGS 8
|
||||
#define CONFIG_USBHOST_MAX_ENDPOINTS 4
|
||||
|
||||
#define CONFIG_USBHOST_MAX_CDC_ACM_CLASS 4
|
||||
#define CONFIG_USBHOST_MAX_HID_CLASS 4
|
||||
#define CONFIG_USBHOST_MAX_MSC_CLASS 2
|
||||
#define CONFIG_USBHOST_MAX_AUDIO_CLASS 1
|
||||
#define CONFIG_USBHOST_MAX_VIDEO_CLASS 1
|
||||
|
||||
#define CONFIG_USBHOST_DEV_NAMELEN 16
|
||||
|
||||
#ifndef CONFIG_USBHOST_PSC_PRIO
|
||||
#define CONFIG_USBHOST_PSC_PRIO 0
|
||||
#endif
|
||||
#ifndef CONFIG_USBHOST_PSC_STACKSIZE
|
||||
#define CONFIG_USBHOST_PSC_STACKSIZE 2048
|
||||
#endif
|
||||
|
||||
//#define CONFIG_USBHOST_GET_STRING_DESC
|
||||
|
||||
// #define CONFIG_USBHOST_MSOS_ENABLE
|
||||
#ifndef CONFIG_USBHOST_MSOS_VENDOR_CODE
|
||||
#define CONFIG_USBHOST_MSOS_VENDOR_CODE 0x00
|
||||
#endif
|
||||
|
||||
/* Ep0 max transfer buffer */
|
||||
#ifndef CONFIG_USBHOST_REQUEST_BUFFER_LEN
|
||||
#define CONFIG_USBHOST_REQUEST_BUFFER_LEN 512
|
||||
#endif
|
||||
|
||||
#ifndef CONFIG_USBHOST_CONTROL_TRANSFER_TIMEOUT
|
||||
#define CONFIG_USBHOST_CONTROL_TRANSFER_TIMEOUT 500
|
||||
#endif
|
||||
|
||||
#ifndef CONFIG_USBHOST_MSC_TIMEOUT
|
||||
#define CONFIG_USBHOST_MSC_TIMEOUT 5000
|
||||
#endif
|
||||
|
||||
/* This parameter affects usb performance, and depends on (TCP_WND)tcp eceive windows size,
|
||||
* you can change with 2K,4K,8K,16K,default is 2K to get one TCP_MSS
|
||||
*/
|
||||
#ifndef CONFIG_USBHOST_RNDIS_ETH_MAX_RX_SIZE
|
||||
#define CONFIG_USBHOST_RNDIS_ETH_MAX_RX_SIZE (2048)
|
||||
#endif
|
||||
#ifndef CONFIG_USBHOST_RNDIS_ETH_MAX_TX_SIZE
|
||||
#define CONFIG_USBHOST_RNDIS_ETH_MAX_TX_SIZE (2048)
|
||||
#endif
|
||||
|
||||
/* This parameter affects usb performance, and depends on (TCP_WND)tcp eceive windows size,
|
||||
* you can change with 2K,4K,8K,16K,default is 2K to get one TCP_MSS
|
||||
*/
|
||||
#ifndef CONFIG_USBHOST_CDC_NCM_ETH_MAX_RX_SIZE
|
||||
#define CONFIG_USBHOST_CDC_NCM_ETH_MAX_RX_SIZE (2048)
|
||||
#endif
|
||||
#ifndef CONFIG_USBHOST_CDC_NCM_ETH_MAX_TX_SIZE
|
||||
#define CONFIG_USBHOST_CDC_NCM_ETH_MAX_TX_SIZE (2048)
|
||||
#endif
|
||||
|
||||
#define CONFIG_USBHOST_BLUETOOTH_HCI_H4
|
||||
// #define CONFIG_USBHOST_BLUETOOTH_HCI_LOG
|
||||
|
||||
#ifndef CONFIG_USBHOST_BLUETOOTH_TX_SIZE
|
||||
#define CONFIG_USBHOST_BLUETOOTH_TX_SIZE 2048
|
||||
#endif
|
||||
#ifndef CONFIG_USBHOST_BLUETOOTH_RX_SIZE
|
||||
#define CONFIG_USBHOST_BLUETOOTH_RX_SIZE 2048
|
||||
#endif
|
||||
|
||||
/* ================ USB Device Port Configuration ================*/
|
||||
|
||||
#ifndef CONFIG_USBDEV_MAX_BUS
|
||||
#define CONFIG_USBDEV_MAX_BUS 1 // for now, bus num must be 1 except hpm ip
|
||||
#endif
|
||||
|
||||
#ifndef CONFIG_USBDEV_EP_NUM
|
||||
#define CONFIG_USBDEV_EP_NUM 4
|
||||
#endif
|
||||
|
||||
/* ---------------- FSDEV Configuration ---------------- */
|
||||
//#define CONFIG_USBDEV_FSDEV_PMA_ACCESS 2 // maybe 1 or 2, many chips may have a difference
|
||||
|
||||
/* ---------------- DWC2 Configuration ---------------- */
|
||||
// #define CONFIG_USB_DWC2_RXALL_FIFO_SIZE (1024 / 4)
|
||||
#define CONFIG_USB_DWC2_TX0_FIFO_SIZE (64 / 4)
|
||||
#define CONFIG_USB_DWC2_TX1_FIFO_SIZE (64 / 4)
|
||||
#define CONFIG_USB_DWC2_TX2_FIFO_SIZE (64 / 4)
|
||||
#define CONFIG_USB_DWC2_TX3_FIFO_SIZE (64 / 4)
|
||||
// #define CONFIG_USB_DWC2_TX4_FIFO_SIZE (0 / 4)
|
||||
// #define CONFIG_USB_DWC2_TX5_FIFO_SIZE (0 / 4)
|
||||
// #define CONFIG_USB_DWC2_TX6_FIFO_SIZE (0 / 4)
|
||||
// #define CONFIG_USB_DWC2_TX7_FIFO_SIZE (0 / 4)
|
||||
// #define CONFIG_USB_DWC2_TX8_FIFO_SIZE (0 / 4)
|
||||
|
||||
/* ---------------- MUSB Configuration ---------------- */
|
||||
// #define CONFIG_USB_MUSB_SUNXI
|
||||
|
||||
/* ================ USB Host Port Configuration ==================*/
|
||||
#ifndef CONFIG_USBHOST_MAX_BUS
|
||||
#define CONFIG_USBHOST_MAX_BUS 1
|
||||
#endif
|
||||
|
||||
#ifndef CONFIG_USBHOST_PIPE_NUM
|
||||
#define CONFIG_USBHOST_PIPE_NUM 12
|
||||
#endif
|
||||
|
||||
/* ---------------- EHCI Configuration ---------------- */
|
||||
|
||||
#define CONFIG_USB_EHCI_HCCR_OFFSET (0x0)
|
||||
#define CONFIG_USB_EHCI_FRAME_LIST_SIZE 1024
|
||||
#define CONFIG_USB_EHCI_QH_NUM CONFIG_USBHOST_PIPE_NUM
|
||||
#define CONFIG_USB_EHCI_QTD_NUM 3
|
||||
#define CONFIG_USB_EHCI_ITD_NUM 20
|
||||
// #define CONFIG_USB_EHCI_HCOR_RESERVED_DISABLE
|
||||
// #define CONFIG_USB_EHCI_CONFIGFLAG
|
||||
// #define CONFIG_USB_EHCI_ISO
|
||||
// #define CONFIG_USB_EHCI_WITH_OHCI
|
||||
|
||||
/* ---------------- OHCI Configuration ---------------- */
|
||||
#define CONFIG_USB_OHCI_HCOR_OFFSET (0x0)
|
||||
|
||||
/* ---------------- XHCI Configuration ---------------- */
|
||||
#define CONFIG_USB_XHCI_HCCR_OFFSET (0x0)
|
||||
|
||||
/* ---------------- DWC2 Configuration ---------------- */
|
||||
/* largest non-periodic USB packet used / 4 */
|
||||
// #define CONFIG_USB_DWC2_NPTX_FIFO_SIZE (512 / 4)
|
||||
/* largest periodic USB packet used / 4 */
|
||||
// #define CONFIG_USB_DWC2_PTX_FIFO_SIZE (1024 / 4)
|
||||
/*
|
||||
* (largest USB packet used / 4) + 1 for status information + 1 transfer complete +
|
||||
* 1 location each for Bulk/Control endpoint for handling NAK/NYET scenario
|
||||
*/
|
||||
// #define CONFIG_USB_DWC2_RX_FIFO_SIZE ((1012 - CONFIG_USB_DWC2_NPTX_FIFO_SIZE - CONFIG_USB_DWC2_PTX_FIFO_SIZE))
|
||||
|
||||
/* ---------------- MUSB Configuration ---------------- */
|
||||
// #define CONFIG_USB_MUSB_SUNXI
|
||||
|
||||
#endif
|
@@ -56,7 +56,6 @@ static int onboard_fal_mount(void)
|
||||
fal_init();
|
||||
/* 在 spi flash 中名为 "filesystem" 的分区上创建一个块设备 */
|
||||
struct rt_device *flash_dev = fal_blk_device_create(FS_PARTITION_NAME);
|
||||
// fal_blk_device_create("font");
|
||||
if (flash_dev == NULL)
|
||||
{
|
||||
LOG_E("Can't create a block device on '%s' partition.", FS_PARTITION_NAME);
|
||||
@@ -73,50 +72,10 @@ static int onboard_fal_mount(void)
|
||||
}
|
||||
else
|
||||
{
|
||||
dfs_mkfs("elm", flash_dev->parent.name);
|
||||
if (dfs_mount(flash_dev->parent.name, "/fal", "elm", 0, 0) == 0)
|
||||
{
|
||||
LOG_I("Filesystem initialized!");
|
||||
}
|
||||
else
|
||||
{
|
||||
LOG_E("Failed to initialize filesystem!");
|
||||
LOG_D("You should create a filesystem on the block device first!");
|
||||
}
|
||||
LOG_E("Failed to initialize filesystem!");
|
||||
LOG_D("You should create a filesystem on the block device first!");
|
||||
}
|
||||
|
||||
int ret;
|
||||
|
||||
// /* 创建目录 */
|
||||
// ret = mkdir("/fal/test", 0x777);
|
||||
// if (ret < 0)
|
||||
// {
|
||||
// /* 创建目录失败 */
|
||||
// rt_kprintf("dir error!\n");
|
||||
// }
|
||||
// else
|
||||
// {
|
||||
// /* 创建目录成功 */
|
||||
// rt_kprintf("mkdir ok!\n");
|
||||
// }
|
||||
// /* 挂载块设备"font"到 DFS 目录/fal/test中 */
|
||||
// if (dfs_mount("font", "/fal/test", "elm", 0, 0) == 0)
|
||||
// {
|
||||
// LOG_I("font initialized!");
|
||||
// }
|
||||
// else
|
||||
// {
|
||||
// dfs_mkfs("elm", "font");
|
||||
// if (dfs_mount("font", "/fal/test", "elm", 0, 0) == 0)
|
||||
// {
|
||||
// LOG_I("font initialized!");
|
||||
// }
|
||||
// else
|
||||
// {
|
||||
// LOG_E("Failed to initialize font!");
|
||||
// LOG_D("You should create a filesystem(font) on the block device first!");
|
||||
// }
|
||||
// }
|
||||
return RT_EOK;
|
||||
}
|
||||
#endif /*BSP_USING_FLASH_FATFS*/
|
||||
|
@@ -57,7 +57,7 @@ static const struct fal_partition *part = NULL;
|
||||
*
|
||||
* @return result
|
||||
*/
|
||||
EfErrCode ef_port_init(ef_env const **default_env, size_t *default_env_size) {
|
||||
EfErrCode ef_port_init(ef_env const **default_env, rt_size_t *default_env_size) {
|
||||
EfErrCode result = EF_NO_ERR;
|
||||
|
||||
*default_env = default_env_set;
|
||||
@@ -81,10 +81,10 @@ EfErrCode ef_port_init(ef_env const **default_env, size_t *default_env_size) {
|
||||
*
|
||||
* @return result
|
||||
*/
|
||||
EfErrCode ef_port_read(uint32_t addr, uint32_t *buf, size_t size) {
|
||||
EfErrCode ef_port_read(rt_uint32_t addr, rt_uint32_t *buf, rt_size_t size) {
|
||||
EfErrCode result = EF_NO_ERR;
|
||||
|
||||
fal_partition_read(part, addr, (uint8_t *)buf, size);
|
||||
fal_partition_read(part, addr, (rt_uint8_t *)buf, size);
|
||||
|
||||
return result;
|
||||
}
|
||||
@@ -99,7 +99,7 @@ EfErrCode ef_port_read(uint32_t addr, uint32_t *buf, size_t size) {
|
||||
*
|
||||
* @return result
|
||||
*/
|
||||
EfErrCode ef_port_erase(uint32_t addr, size_t size) {
|
||||
EfErrCode ef_port_erase(rt_uint32_t addr, rt_size_t size) {
|
||||
EfErrCode result = EF_NO_ERR;
|
||||
|
||||
/* make sure the start address is a multiple of FLASH_ERASE_MIN_SIZE */
|
||||
@@ -123,10 +123,10 @@ EfErrCode ef_port_erase(uint32_t addr, size_t size) {
|
||||
*
|
||||
* @return result
|
||||
*/
|
||||
EfErrCode ef_port_write(uint32_t addr, const uint32_t *buf, size_t size) {
|
||||
EfErrCode ef_port_write(rt_uint32_t addr, const rt_uint32_t *buf, rt_size_t size) {
|
||||
EfErrCode result = EF_NO_ERR;
|
||||
|
||||
if (fal_partition_write(part, addr, (uint8_t *)buf, size) < 0)
|
||||
if (fal_partition_write(part, addr, (rt_uint8_t *)buf, size) < 0)
|
||||
{
|
||||
result = EF_WRITE_ERR;
|
||||
}
|
||||
|
@@ -12,13 +12,13 @@
|
||||
#include <sfud.h>
|
||||
|
||||
#ifdef RT_USING_SFUD
|
||||
#include <spi_flash_sfud.h>
|
||||
#include <dev_spi_flash_sfud.h>
|
||||
#endif
|
||||
|
||||
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 int read(long offset, rt_uint8_t *buf, rt_size_t size);
|
||||
static int write(long offset, const rt_uint8_t *buf, rt_size_t size);
|
||||
static int erase(long offset, rt_size_t size);
|
||||
|
||||
static sfud_flash_t sfud_dev = NULL;
|
||||
struct fal_flash_dev w25q64 =
|
||||
@@ -46,19 +46,19 @@ static int init(void)
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int read(long offset, uint8_t *buf, size_t size)
|
||||
static int read(long offset, rt_uint8_t *buf, rt_size_t size)
|
||||
{
|
||||
assert(sfud_dev);
|
||||
assert(sfud_dev->init_ok);
|
||||
RT_ASSERT(sfud_dev);
|
||||
RT_ASSERT(sfud_dev->init_ok);
|
||||
sfud_read(sfud_dev, w25q64.addr + offset, size, buf);
|
||||
|
||||
return size;
|
||||
}
|
||||
|
||||
static int write(long offset, const uint8_t *buf, size_t size)
|
||||
static int write(long offset, const rt_uint8_t *buf, rt_size_t size)
|
||||
{
|
||||
assert(sfud_dev);
|
||||
assert(sfud_dev->init_ok);
|
||||
RT_ASSERT(sfud_dev);
|
||||
RT_ASSERT(sfud_dev->init_ok);
|
||||
if (sfud_write(sfud_dev, w25q64.addr + offset, size, buf) != SFUD_SUCCESS)
|
||||
{
|
||||
return -1;
|
||||
@@ -67,10 +67,10 @@ static int write(long offset, const uint8_t *buf, size_t size)
|
||||
return size;
|
||||
}
|
||||
|
||||
static int erase(long offset, size_t size)
|
||||
static int erase(long offset, rt_size_t size)
|
||||
{
|
||||
assert(sfud_dev);
|
||||
assert(sfud_dev->init_ok);
|
||||
RT_ASSERT(sfud_dev);
|
||||
RT_ASSERT(sfud_dev->init_ok);
|
||||
if (sfud_erase(sfud_dev, w25q64.addr + offset, size) != SFUD_SUCCESS)
|
||||
{
|
||||
return -1;
|
||||
|
@@ -45,19 +45,16 @@ const uint8_t tile[] = {2, 7};
|
||||
|
||||
// 常见颜色定义
|
||||
|
||||
const RGBColor_TypeDef LED_DARK = {0, 0, 0};
|
||||
const RGBColor_TypeDef LED_GREEN = {255, 0, 0};
|
||||
const RGBColor_TypeDef LED_RED = {0, 255, 0};
|
||||
const RGBColor_TypeDef LED_BLUE = {0, 0, 255};
|
||||
const RGBColor_TypeDef LED_WHITE = {255, 255, 255};
|
||||
const RGBColor_TypeDef DARK = {0, 0, 0};
|
||||
const RGBColor_TypeDef GREEN = {255, 0, 0};
|
||||
const RGBColor_TypeDef RED = {0, 255, 0};
|
||||
const RGBColor_TypeDef BLUE = {0, 0, 255};
|
||||
const RGBColor_TypeDef WHITE = {255, 255, 255};
|
||||
const RGBColor_TypeDef LT_RED = {0, 32, 0};
|
||||
const RGBColor_TypeDef LT_GREEN = {32, 0, 0};
|
||||
const RGBColor_TypeDef LT_BLUE = {0, 0, 32};
|
||||
const RGBColor_TypeDef LT_WHITE = {16, 16, 16};
|
||||
|
||||
|
||||
|
||||
|
||||
// 灯颜色缓存
|
||||
RGBColor_TypeDef RGB_Data[LED_NUM] = {0};
|
||||
|
||||
@@ -250,16 +247,16 @@ void led_matrix_fill_test(uint8_t index)
|
||||
void led_matrix_test1()
|
||||
{
|
||||
rt_memset(RGB_Data, 0x00, sizeof(RGB_Data));
|
||||
Set_LEDColor(0, LED_RED);
|
||||
Set_LEDColor(1, LED_GREEN);
|
||||
Set_LEDColor(2, LED_BLUE);
|
||||
Set_LEDColor(3, LED_RED);
|
||||
Set_LEDColor(4, LED_GREEN);
|
||||
Set_LEDColor(5, LED_BLUE);
|
||||
Set_LEDColor(6, LED_RED);
|
||||
Set_LEDColor(7, LED_GREEN);
|
||||
Set_LEDColor(8, LED_BLUE);
|
||||
Set_LEDColor(9, LED_WHITE);
|
||||
Set_LEDColor(0, RED);
|
||||
Set_LEDColor(1, GREEN);
|
||||
Set_LEDColor(2, BLUE);
|
||||
Set_LEDColor(3, RED);
|
||||
Set_LEDColor(4, GREEN);
|
||||
Set_LEDColor(5, BLUE);
|
||||
Set_LEDColor(6, RED);
|
||||
Set_LEDColor(7, GREEN);
|
||||
Set_LEDColor(8, BLUE);
|
||||
Set_LEDColor(9, WHITE);
|
||||
// led_matrix_rst();
|
||||
RGB_Reflash();
|
||||
}
|
||||
@@ -268,22 +265,22 @@ MSH_CMD_EXPORT(led_matrix_test1, Test led matrix on board)
|
||||
void led_matrix_test2()
|
||||
{
|
||||
rt_memset(RGB_Data, 0x00, sizeof(RGB_Data));
|
||||
Set_LEDColor(0, LED_BLUE);
|
||||
Set_LEDColor(1, LED_RED);
|
||||
Set_LEDColor(2, LED_GREEN);
|
||||
Set_LEDColor(3, LED_BLUE);
|
||||
Set_LEDColor(4, LED_RED);
|
||||
Set_LEDColor(5, LED_GREEN);
|
||||
Set_LEDColor(6, LED_BLUE);
|
||||
Set_LEDColor(7, LED_RED);
|
||||
Set_LEDColor(8, LED_GREEN);
|
||||
Set_LEDColor(9, LED_RED);
|
||||
Set_LEDColor(0, BLUE);
|
||||
Set_LEDColor(1, RED);
|
||||
Set_LEDColor(2, GREEN);
|
||||
Set_LEDColor(3, BLUE);
|
||||
Set_LEDColor(4, RED);
|
||||
Set_LEDColor(5, GREEN);
|
||||
Set_LEDColor(6, BLUE);
|
||||
Set_LEDColor(7, RED);
|
||||
Set_LEDColor(8, GREEN);
|
||||
Set_LEDColor(9, RED);
|
||||
|
||||
Set_LEDColor(14, LED_GREEN);
|
||||
Set_LEDColor(15, LED_GREEN);
|
||||
Set_LEDColor(16, LED_BLUE);
|
||||
Set_LEDColor(17, LED_RED);
|
||||
Set_LEDColor(18, LED_WHITE);
|
||||
Set_LEDColor(14, GREEN);
|
||||
Set_LEDColor(15, GREEN);
|
||||
Set_LEDColor(16, BLUE);
|
||||
Set_LEDColor(17, RED);
|
||||
Set_LEDColor(18, WHITE);
|
||||
|
||||
RGB_Reflash();
|
||||
}
|
||||
|
@@ -9,19 +9,13 @@ typedef struct RGBColor_TypeDef
|
||||
uint8_t B;
|
||||
} RGBColor_TypeDef; // 颜色结构体
|
||||
|
||||
// extern const RGBColor_TypeDef DARK;
|
||||
// extern const RGBColor_TypeDef GREEN;
|
||||
// extern const RGBColor_TypeDef RED;
|
||||
// extern const RGBColor_TypeDef BLUE;
|
||||
// extern const RGBColor_TypeDef WHITE;
|
||||
|
||||
// //灯处于特定颜色还是闪烁状态
|
||||
// extern uint8_t LED_Blink_Staue[LED_NUM]={0};
|
||||
// // 灯闪烁颜色缓存
|
||||
// extern RGBColor_TypeDef LED_Blink_Color[LED_NUM] = {0};
|
||||
|
||||
extern const RGBColor_TypeDef LED_DARK;
|
||||
extern const RGBColor_TypeDef LED_GREEN;
|
||||
extern const RGBColor_TypeDef LED_RED;
|
||||
extern const RGBColor_TypeDef LED_BLUE;
|
||||
extern const RGBColor_TypeDef LED_WHITE;
|
||||
extern void Set_LEDColor(uint16_t LedId, RGBColor_TypeDef Color);
|
||||
|
||||
extern void RGB_Reflash(void);
|
||||
extern void led_matrix_rst();
|
||||
#endif
|
||||
|
@@ -14,30 +14,27 @@
|
||||
#include <rtconfig.h>
|
||||
|
||||
#define LV_COLOR_DEPTH 16
|
||||
#define LV_USE_PERF_MONITOR 1
|
||||
#define MY_DISP_HOR_RES 240
|
||||
#define MY_DISP_VER_RES 240
|
||||
//#define LV_USE_LOG 1
|
||||
|
||||
#ifdef PKG_USING_LV_MUSIC_DEMO
|
||||
/* music player demo */
|
||||
#define LV_HOR_RES_MAX MY_DISP_HOR_RES
|
||||
#define LV_VER_RES_MAX MY_DISP_VER_RES
|
||||
#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 1
|
||||
|
||||
#ifdef PKG_USING_LV_MUSIC_DEMO
|
||||
#define LV_USE_DEMO_MUSIC 1
|
||||
#define LV_HOR_RES_MAX MY_DISP_HOR_RES
|
||||
#define LV_VER_RES_MAX MY_DISP_VER_RES
|
||||
#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 1
|
||||
#endif
|
||||
|
||||
|
||||
#define LV_USE_SYSMON 1
|
||||
#define LV_USE_PERF_MONITOR 1
|
||||
#define LV_USE_DEMO_WIDGETS 1
|
||||
#define LV_FONT_MONTSERRAT_20 1
|
||||
#define LV_FONT_MONTSERRAT_24 1
|
||||
#define LV_FONT_MONTSERRAT_26 1
|
||||
#define LV_USE_DEMO_BENCHMARK 1
|
||||
|
||||
|
||||
//#define LV_USE_DEMO_WIDGETS 1
|
||||
|
||||
|
||||
//#define LV_USE_DEMO_MUSIC 1
|
||||
|
||||
#endif
|
||||
|
@@ -26,6 +26,14 @@
|
||||
#define MY_DISP_VER_RES 240
|
||||
#endif
|
||||
|
||||
#if (PKG_LVGL_VER_NUM >= 0x090000)
|
||||
#define LV_DISP_TYPE lv_display_t
|
||||
#define lv_COLOR_TYPE uint8_t
|
||||
#else
|
||||
#define LV_DISP_TYPE lv_disp_drv_t
|
||||
#define lv_COLOR_TYPE lv_color_t
|
||||
#endif
|
||||
|
||||
/**********************
|
||||
* TYPEDEFS
|
||||
**********************/
|
||||
@@ -35,9 +43,7 @@
|
||||
**********************/
|
||||
static void disp_init(void);
|
||||
|
||||
static void disp_flush(lv_disp_drv_t * disp_drv, const lv_area_t * area, lv_color_t * color_p);
|
||||
//static void gpu_fill(lv_disp_drv_t * disp_drv, lv_color_t * dest_buf, lv_coord_t dest_width,
|
||||
// const lv_area_t * fill_area, lv_color_t color);
|
||||
static void disp_flush(LV_DISP_TYPE * disp_drv, const lv_area_t * area, lv_COLOR_TYPE * color_p);
|
||||
|
||||
/**********************
|
||||
* STATIC VARIABLES
|
||||
@@ -83,9 +89,6 @@ void lv_port_disp_init(void)
|
||||
* and you only need to change the frame buffer's address.
|
||||
*/
|
||||
|
||||
/* Example for 1) */
|
||||
static lv_disp_draw_buf_t draw_buf_dsc_1;
|
||||
|
||||
/*GCC*/
|
||||
#if defined ( __GNUC__ )
|
||||
static lv_color_t buf_1[MY_DISP_HOR_RES * MY_DISP_HOR_RES / 2] __attribute__((section(".LVGLccm"))); /*A buffer for 10 rows*/
|
||||
@@ -94,16 +97,29 @@ void lv_port_disp_init(void)
|
||||
__attribute__((at(0x10000000))) lv_color_t buf_1[LCD_H * LCD_W / 2];
|
||||
#endif
|
||||
|
||||
lv_disp_draw_buf_init(&draw_buf_dsc_1, buf_1, NULL, MY_DISP_HOR_RES * MY_DISP_HOR_RES / 2); /*Initialize the display buffer*/
|
||||
/*-----------------------------------
|
||||
* Register the display in LVGL
|
||||
*----------------------------------*/
|
||||
|
||||
#if (PKG_LVGL_VER_NUM >= 0x090000)
|
||||
|
||||
lv_display_t *display = lv_display_create(MY_DISP_HOR_RES, MY_DISP_VER_RES);
|
||||
lv_display_set_buffers(display, buf_1, NULL, sizeof(buf_1), LV_DISPLAY_RENDER_MODE_PARTIAL); /*Initialize the display buffer.*/
|
||||
lv_display_set_flush_cb(display, disp_flush);
|
||||
|
||||
#else
|
||||
|
||||
/* Example for 1) */
|
||||
static lv_disp_draw_buf_t draw_buf_dsc_1;
|
||||
|
||||
lv_disp_draw_buf_init(&draw_buf_dsc_1, buf_1, NULL, MY_DISP_HOR_RES * MY_DISP_HOR_RES / 2); /*Initialize the display buffer*/
|
||||
|
||||
/*-----------------------------------
|
||||
* Register the display in LVGL
|
||||
*----------------------------------*/
|
||||
static lv_disp_drv_t disp_drv; /*Descriptor of a display driver*/
|
||||
lv_disp_drv_init(&disp_drv); /*Basic initialization*/
|
||||
|
||||
/*Set up the functions to access to your display*/
|
||||
|
||||
/*Set the resolution of the display*/
|
||||
disp_drv.hor_res = MY_DISP_HOR_RES;
|
||||
disp_drv.ver_res = MY_DISP_VER_RES;
|
||||
@@ -114,16 +130,11 @@ void lv_port_disp_init(void)
|
||||
/*Set a display buffer*/
|
||||
disp_drv.draw_buf = &draw_buf_dsc_1;
|
||||
|
||||
/*Required for Example 3)*/
|
||||
//disp_drv.full_refresh = 1;
|
||||
|
||||
/* Fill a memory array with a color if you have GPU.
|
||||
* Note that, in lv_conf.h you can enable GPUs that has built-in support in LVGL.
|
||||
* But if you have a different GPU you can use with this callback.*/
|
||||
//disp_drv.gpu_fill_cb = gpu_fill;
|
||||
|
||||
/*Finally register the driver*/
|
||||
lv_disp_drv_register(&disp_drv);
|
||||
|
||||
#endif
|
||||
|
||||
}
|
||||
|
||||
/**********************
|
||||
@@ -155,35 +166,16 @@ void disp_disable_update(void)
|
||||
/*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)
|
||||
static void disp_flush(LV_DISP_TYPE * disp_drv, const lv_area_t * area, lv_COLOR_TYPE * color_p)
|
||||
{
|
||||
extern 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);
|
||||
lcd_fill_array(area->x1, area->y1, area->x2, area->y2, color_p);
|
||||
|
||||
lv_disp_flush_ready(disp_drv);
|
||||
}
|
||||
|
||||
/*OPTIONAL: GPU INTERFACE*/
|
||||
|
||||
/*If your MCU has hardware accelerator (GPU) then you can use it to fill a memory with a color*/
|
||||
//static void gpu_fill(lv_disp_drv_t * disp_drv, lv_color_t * dest_buf, lv_coord_t dest_width,
|
||||
// const lv_area_t * fill_area, lv_color_t color)
|
||||
//{
|
||||
// /*It's an example code which should be done by your GPU*/
|
||||
// int32_t x, y;
|
||||
// dest_buf += dest_width * fill_area->y1; /*Go to the first line*/
|
||||
//
|
||||
// for(y = fill_area->y1; y <= fill_area->y2; y++) {
|
||||
// for(x = fill_area->x1; x <= fill_area->x2; x++) {
|
||||
// dest_buf[x] = color;
|
||||
// }
|
||||
// dest_buf+=dest_width; /*Go to the next line*/
|
||||
// }
|
||||
//}
|
||||
|
||||
|
||||
#else /*Enable this file at the top*/
|
||||
|
||||
/*This dummy typedef exists purely to silence -Wpedantic.*/
|
||||
typedef int keep_pedantic_happy;
|
||||
#endif
|
||||
#endif
|
@@ -9,8 +9,8 @@
|
||||
*/
|
||||
|
||||
#include <rtthread.h>
|
||||
#include "spi_flash.h"
|
||||
#include "spi_flash_sfud.h"
|
||||
#include "dev_spi_flash.h"
|
||||
#include "dev_spi_flash_sfud.h"
|
||||
#include <drv_spi.h>
|
||||
#include <drv_soft_spi.h>
|
||||
|
||||
|
@@ -9,8 +9,8 @@
|
||||
*/
|
||||
|
||||
#include <rtthread.h>
|
||||
#include "spi_flash.h"
|
||||
#include "spi_flash_sfud.h"
|
||||
#include "dev_spi_flash.h"
|
||||
#include "dev_spi_flash_sfud.h"
|
||||
#include <drv_spi.h>
|
||||
#include <drv_gpio.h>
|
||||
|
||||
|
Reference in New Issue
Block a user