[refactor] move component port from common into component

This commit is contained in:
jzlv 2022-12-08 10:58:41 +08:00
parent 44c8bf854d
commit d4473020d6
14 changed files with 129 additions and 22 deletions

View File

@ -21,6 +21,8 @@
*
*/
#if defined(BL616) || defined(BL808) || defined(BL628) || defined(BL606P)
#include "sdh_sdcard.h"
#include "bflb_mtimer.h"
#include "bflb_l1c.h"
@ -30,9 +32,9 @@
/* Private variables ---------------------------------------------------------*/
static uint32_t sdhClockInit = 400000ul;
static uint32_t sdhClockSrc = 96000000ul;
static uint32_t sdhClockTransfer = 48000000ul;
static uint32_t sdhClockInit = 100ul;
static uint32_t sdhClockSrc = 100ul;
static uint32_t sdhClockTransfer = 100ul;
static sd_card_t *pSDCardInfo = NULL;
static SDH_Cfg_Type SDH_Cfg_Type_Instance;
@ -316,6 +318,8 @@ static status_t SDH_SendCardCommand(SDH_CMD_Cfg_Type *cmd)
static void SDH_HostInit(void)
{
GLB_Set_SDH_CLK(ENABLE, GLB_SDH_CLK_WIFIPLL_96M, 7);
/* initialise SDH controller*/
SDH_Cfg_Type_Instance.vlot18Enable = DISABLE;
SDH_Cfg_Type_Instance.highSpeed = ENABLE;
@ -816,6 +820,8 @@ static status_t SD_SetDataBusWidth(sd_card_t *card, SDH_Data_Bus_Width_Type widt
goto out;
}
GLB_Set_SDH_CLK(ENABLE, GLB_SDH_CLK_WIFIPLL_96M, 1);
/* reinitialise SDH controller*/
SDH_Cfg_Type_Instance.vlot18Enable = DISABLE;
SDH_Cfg_Type_Instance.highSpeed = ENABLE;
@ -1170,14 +1176,14 @@ static status_t SDH_SDCardInit(uint32_t bus_wide, sd_card_t *card)
* @brief Initializes SD Card clock.
* @retval SD status
*/
status_t SDH_ClockSet(uint32_t clockInit, uint32_t clockSrc, uint32_t clockTransfer)
{
sdhClockInit = clockInit;
sdhClockSrc = clockSrc;
sdhClockTransfer = clockTransfer;
// status_t SDH_ClockSet(uint32_t clockInit, uint32_t clockSrc, uint32_t clockTransfer)
// {
// sdhClockInit = clockInit;
// sdhClockSrc = clockSrc;
// sdhClockTransfer = clockTransfer;
return Status_Success;
}
// return Status_Success;
// }
/**
* @brief Initializes the SD card device.
@ -1622,3 +1628,5 @@ status_t SDH_WriteMultiBlocks(uint8_t *writebuff, uint32_t WriteAddr, uint16_t B
out:
return (errorstatus);
}
#endif

View File

@ -21,8 +21,8 @@
*
*/
#ifndef __SDIO_SDCARD_H
#define __SDIO_SDCARD_H
#ifndef _SDH_SDCARD_H
#define _SDH_SDCARD_H
#include <stdint.h>
@ -38,7 +38,17 @@
#include "bl616_common.h"
#include "bl616_glb.h"
#include "bl616_sdh.h"
#elif defined(BL628)
#include "bl628_common.h"
#include "bl628_glb.h"
#include "bl628_smih.h"
#else
#define _SDH_SDCARD_CHECK
#endif
#ifndef _SDH_SDCARD_CHECK
#define _SDH_SDCARD_CHECK
/*! @brief Reverse byte sequence in uint32_t */
#define SWAP_WORD_BYTE_SEQUENCE(x) (__REV(x))
@ -512,4 +522,6 @@ status_t SDH_Init(uint32_t bus_wide, sd_card_t *pOutCardInfo);
status_t SD_Erase(uint32_t startaddr, uint32_t endaddr);
status_t SDH_ReadMultiBlocks(uint8_t *readbuff, uint32_t ReadAddr, uint16_t BlockSize, uint32_t NumberOfBlocks);
status_t SDH_WriteMultiBlocks(uint8_t *writebuff, uint32_t WriteAddr, uint16_t BlockSize, uint32_t NumberOfBlocks);
#endif /* __SDCARD_H */
#endif
#endif

View File

@ -6,3 +6,13 @@ sdk_library_add_sources(ffunicode.c)
sdk_library_add_sources(diskio.c)
sdk_add_include_directories(.)
sdk_add_compile_definitions(-DCONFIG_FATFS)
if(CONFIG_FF_FS_REENTRANT)
sdk_add_compile_definitions(-DFF_FS_REENTRANT=${CONFIG_FF_FS_REENTRANT})
endif()
# fatfs use sdcard over sdio
if(CONFIG_FATFS_SDH_SDCARD)
sdk_add_compile_definitions(-DCONFIG_FATFS_SDH_SDCARD)
sdk_library_add_sources(port/fatfs_sdh_sdcard.c)
endif()

View File

@ -2,22 +2,32 @@
/ FatFs Functional Configurations
/---------------------------------------------------------------------------*/
#if defined(CONFIG_FFCONF_USER) && (CONFIG_FFCONF_USER)
#include "ffconf_user.h"
#endif
#define FFCONF_DEF 86606 /* Revision ID */
/*---------------------------------------------------------------------------/
/ Function Configurations
/---------------------------------------------------------------------------*/
#ifndef FF_FS_CONTINUOUS
#define FF_FS_CONTINUOUS 1
#endif
/* Read and write as much data as possible at one time, regardless of the cluster size */
#ifndef FF_FS_READONLY
#define FF_FS_READONLY 0
#endif
/* This option switches read-only configuration. (0:Read/Write or 1:Read-only)
/ Read-only configuration removes writing API functions, f_write(), f_sync(),
/ f_unlink(), f_mkdir(), f_chmod(), f_rename(), f_truncate(), f_getfree()
/ and optional writing functions as well. */
#ifndef FF_FS_MINIMIZE
#define FF_FS_MINIMIZE 0
#endif
/* This option defines minimization level to remove some basic API functions.
/
/ 0: Basic functions are fully enabled.
@ -26,42 +36,60 @@
/ 2: f_opendir(), f_readdir() and f_closedir() are removed in addition to 1.
/ 3: f_lseek() function is removed in addition to 2. */
#ifndef FF_USE_STRFUNC
#define FF_USE_STRFUNC 2
#endif
/* This option switches string functions, f_gets(), f_putc(), f_puts() and f_printf().
/
/ 0: Disable string functions.
/ 1: Enable without LF-CRLF conversion.
/ 2: Enable with LF-CRLF conversion. */
#ifndef FF_USE_FIND
#define FF_USE_FIND 0
#endif
/* This option switches filtered directory read functions, f_findfirst() and
/ f_findnext(). (0:Disable, 1:Enable 2:Enable with matching altname[] too) */
#ifndef FF_USE_MKFS
#define FF_USE_MKFS 1
#endif
/* This option switches f_mkfs() function. (0:Disable or 1:Enable) */
#ifndef FF_USE_FASTSEEK
#define FF_USE_FASTSEEK 1
#endif
/* This option switches fast seek function. (0:Disable or 1:Enable) */
#ifndef FF_USE_EXPAND
#define FF_USE_EXPAND 0
#endif
/* This option switches f_expand function. (0:Disable or 1:Enable) */
#ifndef FF_USE_CHMOD
#define FF_USE_CHMOD 0
#endif
/* This option switches attribute manipulation functions, f_chmod() and f_utime().
/ (0:Disable or 1:Enable) Also FF_FS_READONLY needs to be 0 to enable this option. */
#ifndef FF_USE_LABEL
#define FF_USE_LABEL 0
#endif
/* This option switches volume label functions, f_getlabel() and f_setlabel().
/ (0:Disable or 1:Enable) */
#ifndef FF_USE_FORWARD
#define FF_USE_FORWARD 0
#endif
/* This option switches f_forward() function. (0:Disable or 1:Enable) */
/*---------------------------------------------------------------------------/
/ Locale and Namespace Configurations
/---------------------------------------------------------------------------*/
#ifndef FF_CODE_PAGE
#define FF_CODE_PAGE 437
#endif
/* This option specifies the OEM code page to be used on the target system.
/ Incorrect code page setting can cause a file open failure.
/
@ -108,7 +136,9 @@
/ memory for the working buffer, memory management functions, ff_memalloc() and
/ ff_memfree() exemplified in ffsystem.c, need to be added to the project. */
#ifndef FF_LFN_UNICODE
#define FF_LFN_UNICODE 0
#endif
/* This option switches the character encoding on the API when LFN is enabled.
/
/ 0: ANSI/OEM in current CP (TCHAR = char)
@ -119,14 +149,21 @@
/ Also behavior of string I/O functions will be affected by this option.
/ When LFN is not enabled, this option has no effect. */
#ifndef FF_LFN_BUF
#define FF_LFN_BUF 255
#endif
#ifndef FF_SFN_BUF
#define FF_SFN_BUF 12
#endif
/* This set of options defines size of file name members in the FILINFO structure
/ which is used to read out directory items. These values should be suffcient for
/ the file names to read. The maximum possible length of the read file name depends
/ on character encoding. When LFN is not enabled, these options have no effect. */
#ifndef FF_STRF_ENCODE
#define FF_STRF_ENCODE 3
#endif
/* When FF_LFN_UNICODE >= 1 with LFN enabled, string I/O functions, f_gets(),
/ f_putc(), f_puts and f_printf() convert the character encoding in it.
/ This option selects assumption of character encoding ON THE FILE to be
@ -138,7 +175,9 @@
/ 3: Unicode in UTF-8
*/
#ifndef FF_FS_RPATH
#define FF_FS_RPATH 2
#endif
/* This option configures support for relative path.
/
/ 0: Disable relative path and remove related functions.
@ -166,7 +205,9 @@
/ const char* VolumeStr[FF_VOLUMES] = {"ram","flash","sd","usb",...
*/
#ifndef FF_MULTI_PARTITION
#define FF_MULTI_PARTITION 0
#endif
/* This option switches support for multiple volumes on the physical drive.
/ By default (0), each logical drive number is bound to the same physical drive
/ number and only an FAT volume found on the physical drive will be mounted.
@ -174,7 +215,10 @@
/ arbitrary physical drive and partition listed in the VolToPart[]. Also f_fdisk()
/ funciton will be available. */
#ifndef FF_MIN_SS
#define FF_MIN_SS 512
#endif
#ifndef FF_MAX_SS
#define FF_MAX_SS 512
#endif
@ -185,15 +229,21 @@
/ for variable sector size mode and disk_ioctl() function needs to implement
/ GET_SECTOR_SIZE command. */
#ifndef FF_LBA64
#define FF_LBA64 0
#endif
/* This option switches support for 64-bit LBA. (0:Disable or 1:Enable)
/ To enable the 64-bit LBA, also exFAT needs to be enabled. (FF_FS_EXFAT == 1) */
#ifndef FF_MIN_GPT
#define FF_MIN_GPT 0x100000000
#endif
/* Minimum number of sectors to switch GPT format to create partition in f_mkfs and
/ f_fdisk function. 0x100000000 max. This option has no effect when FF_LBA64 == 0. */
#ifndef FF_USE_TRIM
#define FF_USE_TRIM 0
#endif
/* This option switches support for ATA-TRIM. (0:Disable or 1:Enable)
/ To enable Trim function, also CTRL_TRIM command should be implemented to the
/ disk_ioctl() function. */
@ -202,21 +252,36 @@
/ System Configurations
/---------------------------------------------------------------------------*/
#ifndef FF_FS_TINY
#define FF_FS_TINY 0
#endif
/* This option switches tiny buffer configuration. (0:Normal or 1:Tiny)
/ At the tiny configuration, size of file object (FIL) is shrinked FF_MAX_SS bytes.
/ Instead of private sector buffer eliminated from the file object, common sector
/ buffer in the filesystem object (FATFS) is used for the file data transfer. */
#ifndef FF_FS_EXFAT
#define FF_FS_EXFAT 0
#endif
/* This option switches support for exFAT filesystem. (0:Disable or 1:Enable)
/ To enable exFAT, also LFN needs to be enabled. (FF_USE_LFN >= 1)
/ Note that enabling exFAT discards ANSI C (C89) compatibility. */
#ifndef FF_FS_NORTC
#define FF_FS_NORTC 1
#endif
#ifndef FF_NORTC_MON
#define FF_NORTC_MON 1
#endif
#ifndef FF_NORTC_MDAY
#define FF_NORTC_MDAY 1
#define FF_NORTC_YEAR 2019
#endif
#ifndef FF_NORTC_YEAR
#define FF_NORTC_YEAR 2022
#endif
/* The option FF_FS_NORTC switches timestamp functiton. If the system does not have
/ any RTC function or valid timestamp is not needed, set FF_FS_NORTC = 1 to disable
/ the timestamp function. Every object modified by FatFs will have a fixed timestamp
@ -226,7 +291,9 @@
/ FF_NORTC_MDAY and FF_NORTC_YEAR have no effect.
/ These options have no effect in read-only configuration (FF_FS_READONLY = 1). */
#ifndef FF_FS_NOFSINFO
#define FF_FS_NOFSINFO 0
#endif
/* If you need to know correct free space on the FAT32 volume, set bit 0 of this
/ option, and f_getfree() function at first time after volume mount will force
/ a full FAT scan. Bit 1 controls the use of last allocated cluster number.
@ -237,7 +304,9 @@
/ bit1=1: Do not trust last allocated cluster number in the FSINFO.
*/
#ifndef FF_FS_LOCK
#define FF_FS_LOCK 0
#endif
/* The option FF_FS_LOCK switches file lock function to control duplicated file open
/ and illegal operation to open objects. This option must be 0 when FF_FS_READONLY
/ is 1.
@ -249,13 +318,15 @@
/ lock control is independent of re-entrancy. */
/* #include <somertos.h> // O/S definitions */
#ifndef FF_FS_REENTRANT
#define FF_FS_REENTRANT 0
#endif
#if (FF_FS_REENTRANT)
#include "FreeRTOS.h"
#include "task.h"
#include "semphr.h"
#define FF_FS_TIMEOUT 5000
#define FF_FS_TIMEOUT 1000
#define FF_SYNC_t SemaphoreHandle_t
#endif
/* The option FF_FS_REENTRANT switches the re-entrancy (thread safe) of the FatFs

View File

@ -30,6 +30,8 @@
/* storage control modules to the FatFs module with a defined API. */
/*-----------------------------------------------------------------------*/
#if defined(BL616) || defined(BL808) || defined(BL628) || defined(BL606P)
#include "ff.h" /* Obtains integer types */
#include "diskio.h" /* Declarations of disk functions */
#include "sdh_sdcard.h"
@ -104,7 +106,6 @@ int MMC_disk_ioctl(BYTE cmd, void *buff)
return 0;
}
DSTATUS Translate_Result_Code(int result)
{
// MSG("%s\r\n",FR_Table[result]);
@ -135,3 +136,5 @@ void fatfs_sdh_driver_register(void)
bflb_irq_attach(33, sdh_isr, NULL);
bflb_irq_enable(33);
}
#endif

View File

@ -32,6 +32,7 @@ sdk_library_add_sources(core/src/lundump.c)
sdk_library_add_sources(core/src/lutf8lib.c)
sdk_library_add_sources(core/src/lvm.c)
sdk_library_add_sources(core/src/lzio.c)
sdk_library_add_sources(start/lua_start.c)
sdk_add_include_directories(core/inc)
sdk_add_compile_definitions(-DCONFIG_LUA)

View File

@ -3,4 +3,6 @@ sdk_generate_library()
file(GLOB_RECURSE sources "${CMAKE_CURRENT_SOURCE_DIR}/*.c")
sdk_library_add_sources(${sources})
sdk_add_include_directories(port)
sdk_add_include_directories(.)

View File

@ -11,7 +11,7 @@
*********************/
#include "lvgl.h"
#include "lv_port_disp.h"
#include "../lcd/lcd.h"
#include "lcd.h"
/*********************
* DEFINES

View File

@ -4,7 +4,7 @@
*/
/*Copy this file as "lv_port_fs.c" and set this value to "1" to enable content*/
#if 1
#if 0
/*********************
* INCLUDES

View File

@ -4,7 +4,7 @@
*/
/*Copy this file as "lv_port_indev.c" and set this value to "1" to enable content*/
#if 1
#if 0
/*********************
* INCLUDES