[bsp][Renesas]Modify some drivers and configuration files (#7590)

This commit is contained in:
Rbb666 2023-06-02 15:47:09 +08:00 committed by GitHub
parent 22fb7152d9
commit b3ea130ddd
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
51 changed files with 1981 additions and 127 deletions

View File

@ -9,6 +9,7 @@ RA 系列 BSP 目前支持情况如下表所示:
| [ra6m4-cpk](ra6m4-cpk) | Renesas 官方 CPK-RA6M4 开发板 |
| [ra6m4-iot](ra6m4-iot) | Renesas 官方 IOT-RA6M4 开发板 |
| [ra6m3-ek](ra6m3-ek) | Renesas 官方 RA6M3-EK 开发板 |
| [ra6m3-hmi-board](ra6m3-hmi-board) | Renesas 联合 RT-Thread RA6M3-HMI-Board 开发板 |
| **RA2 系列** | |
| [ra2l1-cpk](ra2l1-cpk) | Renesas 官方 CPK-RA2L1 开发板 |

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2006-2021, RT-Thread Development Team
* Copyright (c) 2006-2023, RT-Thread Development Team
*
* SPDX-License-Identifier: Apache-2.0
*
@ -52,9 +52,6 @@ struct rt_ra6m3_eth
#ifndef PHY_USING_INTERRUPT_MODE
rt_timer_t poll_link_timer;
#endif
/* interface address info, hw address */
rt_uint8_t dev_addr[MAX_ADDR_LEN];
};
static rt_uint8_t *Rx_Buff, *Tx_Buff;
@ -89,7 +86,7 @@ static void dump_hex(const rt_uint8_t *ptr, rt_size_t buflen)
extern void phy_reset(void);
/* EMAC initialization function */
static rt_err_t rt_ra6m3_eth_init(rt_device_t dev)
static rt_err_t rt_ra6m3_eth_init(void)
{
fsp_err_t res;
@ -133,7 +130,7 @@ static rt_err_t rt_ra6m3_eth_control(rt_device_t dev, int cmd, void *args)
/* get mac address */
if (args)
{
SMEMCPY(args, ra6m3_eth_device.dev_addr, 6);
SMEMCPY(args, g_ether0_ctrl.p_ether_cfg->p_mac_address, 6);
}
else
{
@ -385,16 +382,7 @@ static int rt_hw_ra6m3_eth_init(void)
goto __exit;
}
/* OUI 00-80-E1 STMICROELECTRONICS. */
ra6m3_eth_device.dev_addr[0] = 0x00;
ra6m3_eth_device.dev_addr[1] = 0x80;
ra6m3_eth_device.dev_addr[2] = 0xE1;
/* generate MAC addr from 96bit unique ID (only for test). */
ra6m3_eth_device.dev_addr[3] = (10 + 4);
ra6m3_eth_device.dev_addr[4] = (10 + 2);
ra6m3_eth_device.dev_addr[5] = (10 + 0);
ra6m3_eth_device.parent.parent.init = rt_ra6m3_eth_init;
ra6m3_eth_device.parent.parent.init = NULL;
ra6m3_eth_device.parent.parent.open = rt_ra6m3_eth_open;
ra6m3_eth_device.parent.parent.close = rt_ra6m3_eth_close;
ra6m3_eth_device.parent.parent.read = rt_ra6m3_eth_read;
@ -405,6 +393,8 @@ static int rt_hw_ra6m3_eth_init(void)
ra6m3_eth_device.parent.eth_rx = rt_ra6m3_eth_rx;
ra6m3_eth_device.parent.eth_tx = rt_ra6m3_eth_tx;
rt_ra6m3_eth_init();
/* register eth device */
state = eth_device_init(&(ra6m3_eth_device.parent), "e0");
if (RT_EOK == state)

View File

@ -44,6 +44,18 @@ __WEAK void _ra_port_display_callback(display_callback_args_t *p_args)
void turn_on_lcd_backlight(void)
{
#ifdef BSP_USING_PWM5
#define LCD_PWM_DEV_NAME "pwm5"
#define LCD_PWM_DEV_CHANNEL 0
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, 7000);
rt_pwm_enable(pwm_dev, LCD_PWM_DEV_CHANNEL);
#endif
rt_pin_mode(LCD_BL_PIN, PIN_MODE_OUTPUT); /* LCD_BL */
rt_pin_write(LCD_BL_PIN, PIN_HIGH);
}
@ -107,7 +119,7 @@ void ra_bsp_lcd_swap_buffer(void)
void bsp_lcd_draw_pixel(uint32_t x, uint32_t y, uint16_t color)
{
// Verify pixel is within LCD range
if ((x < LCD_WIDTH) && (y < LCD_HEIGHT))
if ((x <= LCD_WIDTH) && (y <= LCD_HEIGHT))
{
switch (screen_rotation)
{

View File

@ -491,7 +491,7 @@ struct rt_mmcsd_host *sdio_host_create(struct ra_sdhi *sdhi_des)
ra_sdhi_enable_sdio_irq(host, 1);
/* ready to change */
mmcsd_change(host);
// mmcsd_change(host);
return host;
}
@ -508,3 +508,8 @@ int rt_hw_sdhi_init(void)
return 0;
}
INIT_DEVICE_EXPORT(rt_hw_sdhi_init);
void sdcard_change(void)
{
mmcsd_change(host);
}

View File

@ -62,4 +62,6 @@ struct ra_sdhi
sdmmc_device_t *media_device;
};
extern void sdcard_change(void);
#endif

View File

@ -47,20 +47,21 @@
<option id="ilg.gnuarmeclipse.managedbuild.cross.option.target.other.2041717463" name="Other target flags" superClass="ilg.gnuarmeclipse.managedbuild.cross.option.target.other" useByScannerDiscovery="true" value="" valueType="string"/>
<option id="ilg.gnuarmeclipse.managedbuild.cross.option.arm.target.fpu.unit.1463655269" name="FPU Type" superClass="ilg.gnuarmeclipse.managedbuild.cross.option.arm.target.fpu.unit" useByScannerDiscovery="true" value="ilg.gnuarmeclipse.managedbuild.cross.option.arm.target.fpu.unit.fpv4spd16" valueType="enumerated"/>
<targetPlatform archList="all" binaryParser="org.eclipse.cdt.core.ELF" id="ilg.gnuarmeclipse.managedbuild.cross.targetPlatform.1798638225" isAbstract="false" osList="all" superClass="ilg.gnuarmeclipse.managedbuild.cross.targetPlatform"/>
<builder buildPath="${workspace_loc:/${ProjName}/Debug" cleanBuildTarget="clean2" id="ilg.gnuarmeclipse.managedbuild.cross.builder.1736709688" keepEnvironmentInBuildfile="false" managedBuildOn="true" name="GNU Make Builder" parallelBuildOn="true" parallelizationNumber="optimal" superClass="ilg.gnuarmeclipse.managedbuild.cross.builder"/>
<tool commandLinePattern="${COMMAND} ${FLAGS} -c ${OUTPUT_FLAG} ${OUTPUT_PREFIX}${OUTPUT} ${INPUTS}" id="ilg.gnuarmeclipse.managedbuild.cross.tool.assembler.1810966071" name="GNU ARM Cross Assembler" superClass="ilg.gnuarmeclipse.managedbuild.cross.tool.assembler">
<builder buildPath="${workspace_loc:/${ProjName}/Debug" cleanBuildTarget="clean2" id="ilg.gnuarmeclipse.managedbuild.cross.builder.1736709688" keepEnvironmentInBuildfile="false" managedBuildOn="true" name="Gnu Make Builder" parallelBuildOn="true" parallelizationNumber="optimal" superClass="ilg.gnuarmeclipse.managedbuild.cross.builder"/>
<tool commandLinePattern="${COMMAND} ${cross_toolchain_flags} ${FLAGS} -c ${OUTPUT_FLAG} ${OUTPUT_PREFIX}${OUTPUT} ${INPUTS}" id="ilg.gnuarmeclipse.managedbuild.cross.tool.assembler.1810966071" name="GNU ARM Cross Assembler" superClass="ilg.gnuarmeclipse.managedbuild.cross.tool.assembler">
<option id="ilg.gnuarmeclipse.managedbuild.cross.option.assembler.usepreprocessor.1072524326" name="Use preprocessor" superClass="ilg.gnuarmeclipse.managedbuild.cross.option.assembler.usepreprocessor" useByScannerDiscovery="false" value="true" valueType="boolean"/>
<option id="ilg.gnuarmeclipse.managedbuild.cross.option.assembler.include.paths.161242639" name="Include paths (-I)" superClass="ilg.gnuarmeclipse.managedbuild.cross.option.assembler.include.paths" useByScannerDiscovery="true"/>
<option id="ilg.gnuarmeclipse.managedbuild.cross.option.assembler.defs.1521934876" name="Defined symbols (-D)" superClass="ilg.gnuarmeclipse.managedbuild.cross.option.assembler.defs" useByScannerDiscovery="true"/>
<option IS_BUILTIN_EMPTY="false" IS_VALUE_EMPTY="false" id="ilg.gnuarmeclipse.managedbuild.cross.option.assembler.flags.1325367962" name="Assembler flags" superClass="ilg.gnuarmeclipse.managedbuild.cross.option.assembler.flags" useByScannerDiscovery="false" valueType="stringList">
<listOptionValue builtIn="false" value="-mimplicit-it=thumb"/>
</option>
<option id="ilg.gnuarmeclipse.managedbuild.cross.option.assembler.other.647856572" name="Other assembler flags" superClass="ilg.gnuarmeclipse.managedbuild.cross.option.assembler.other" useByScannerDiscovery="false" value=" -c -mcpu=cortex-m4 -mthumb -mfpu=fpv5-sp-d16 -mfloat-abi=hard -ffunction-sections -fdata-sections -x assembler-with-cpp -Wa,-mimplicit-it=thumb -gdwarf-2" valueType="string"/>
<option id="ilg.gnuarmeclipse.managedbuild.cross.option.assembler.other.647856572" name="Other assembler flags" superClass="ilg.gnuarmeclipse.managedbuild.cross.option.assembler.other" useByScannerDiscovery="false" value="" valueType="string"/>
<inputType id="ilg.gnuarmeclipse.managedbuild.cross.tool.assembler.input.1843333483" superClass="ilg.gnuarmeclipse.managedbuild.cross.tool.assembler.input"/>
</tool>
<tool commandLinePattern="${COMMAND} ${FLAGS} -c ${OUTPUT_FLAG} ${OUTPUT_PREFIX}${OUTPUT} ${INPUTS}" id="ilg.gnuarmeclipse.managedbuild.cross.tool.c.compiler.1570350559" name="GNU ARM Cross C Compiler" superClass="ilg.gnuarmeclipse.managedbuild.cross.tool.c.compiler">
<tool commandLinePattern="${COMMAND} ${cross_toolchain_flags} ${FLAGS} -c ${OUTPUT_FLAG} ${OUTPUT_PREFIX}${OUTPUT} ${INPUTS}" id="ilg.gnuarmeclipse.managedbuild.cross.tool.c.compiler.1570350559" name="GNU ARM Cross C Compiler" superClass="ilg.gnuarmeclipse.managedbuild.cross.tool.c.compiler">
<option IS_BUILTIN_EMPTY="false" IS_VALUE_EMPTY="false" id="ilg.gnuarmeclipse.managedbuild.cross.option.c.compiler.include.paths.634882052" name="Include paths (-I)" superClass="ilg.gnuarmeclipse.managedbuild.cross.option.c.compiler.include.paths" useByScannerDiscovery="true" valueType="includePath">
<listOptionValue builtIn="false" value="&quot;${workspace_loc://${ProjName}//.}&quot;"/>
<listOptionValue builtIn="false" value="&quot;${workspace_loc://${ProjName}//board/ports/wifi}&quot;"/>
<listOptionValue builtIn="false" value="&quot;${workspace_loc://${ProjName}//board/ports}&quot;"/>
<listOptionValue builtIn="false" value="&quot;${workspace_loc://${ProjName}//board}&quot;"/>
<listOptionValue builtIn="false" value="&quot;${workspace_loc://${ProjName}//libraries/HAL_Drivers/config}&quot;"/>
@ -69,6 +70,7 @@
<listOptionValue builtIn="false" value="&quot;${workspace_loc://${ProjName}//ra/fsp/inc/api}&quot;"/>
<listOptionValue builtIn="false" value="&quot;${workspace_loc://${ProjName}//ra/fsp/inc/instances}&quot;"/>
<listOptionValue builtIn="false" value="&quot;${workspace_loc://${ProjName}//ra/fsp/inc}&quot;"/>
<listOptionValue builtIn="false" value="&quot;${workspace_loc://${ProjName}//ra/tes/dave2d/inc}&quot;"/>
<listOptionValue builtIn="false" value="&quot;${workspace_loc://${ProjName}//ra_cfg/fsp_cfg/bsp}&quot;"/>
<listOptionValue builtIn="false" value="&quot;${workspace_loc://${ProjName}//ra_cfg/fsp_cfg}&quot;"/>
<listOptionValue builtIn="false" value="&quot;${workspace_loc://${ProjName}//ra_gen}&quot;"/>
@ -79,19 +81,18 @@
<listOptionValue builtIn="false" value="&quot;${workspace_loc://${ProjName}//rt-thread/components/libc/posix/io/poll}&quot;"/>
<listOptionValue builtIn="false" value="&quot;${workspace_loc://${ProjName}//rt-thread/components/libc/posix/io/stdio}&quot;"/>
<listOptionValue builtIn="false" value="&quot;${workspace_loc://${ProjName}//rt-thread/components/libc/posix/ipc}&quot;"/>
<listOptionValue builtIn="false" value="&quot;${workspace_loc://${ProjName}//rt-thread/components/utilities/libadt}&quot;"/>
<listOptionValue builtIn="false" value="&quot;${workspace_loc://${ProjName}//rt-thread/include}&quot;"/>
<listOptionValue builtIn="false" value="&quot;${workspace_loc://${ProjName}//rt-thread/libcpu/arm/common}&quot;"/>
<listOptionValue builtIn="false" value="&quot;${workspace_loc://${ProjName}//rt-thread/libcpu/arm/cortex-m4}&quot;"/>
</option>
<option id="ilg.gnuarmeclipse.managedbuild.cross.option.c.compiler.defs.100549972" name="Defined symbols (-D)" superClass="ilg.gnuarmeclipse.managedbuild.cross.option.c.compiler.defs" useByScannerDiscovery="true"/>
<option id="ilg.gnuarmeclipse.managedbuild.cross.option.c.compiler.other.2133065240" name="Other compiler flags" superClass="ilg.gnuarmeclipse.managedbuild.cross.option.c.compiler.other" useByScannerDiscovery="true" value=" -mcpu=cortex-m4 -mthumb -mfpu=fpv5-sp-d16 -mfloat-abi=hard -ffunction-sections -fdata-sections -Dgcc -O0 -gdwarf-2 -g -Wall" valueType="string"/>
<option id="ilg.gnuarmeclipse.managedbuild.cross.option.c.compiler.other.2133065240" name="Other compiler flags" superClass="ilg.gnuarmeclipse.managedbuild.cross.option.c.compiler.other" useByScannerDiscovery="true" value="" valueType="string"/>
<option IS_BUILTIN_EMPTY="false" IS_VALUE_EMPTY="false" id="ilg.gnuarmeclipse.managedbuild.cross.option.c.compiler.include.files.714348818" name="Include files (-include)" superClass="ilg.gnuarmeclipse.managedbuild.cross.option.c.compiler.include.files" useByScannerDiscovery="true" valueType="includeFiles">
<listOptionValue builtIn="false" value="&quot;${workspace_loc:/${ProjName}/rtconfig_preinc.h}&quot;"/>
</option>
<inputType id="ilg.gnuarmeclipse.managedbuild.cross.tool.c.compiler.input.992053063" superClass="ilg.gnuarmeclipse.managedbuild.cross.tool.c.compiler.input"/>
</tool>
<tool commandLinePattern="${COMMAND} ${FLAGS} ${OUTPUT_FLAG} ${OUTPUT_PREFIX}${OUTPUT} ${INPUTS}" id="ilg.gnuarmeclipse.managedbuild.cross.tool.c.linker.869072473" name="Cross ARM C Linker" superClass="ilg.gnuarmeclipse.managedbuild.cross.tool.c.linker">
<tool commandLinePattern="${COMMAND} ${cross_toolchain_flags} ${FLAGS} ${OUTPUT_FLAG} ${OUTPUT_PREFIX}${OUTPUT} ${INPUTS}" id="ilg.gnuarmeclipse.managedbuild.cross.tool.c.linker.869072473" name="Cross ARM C Linker" superClass="ilg.gnuarmeclipse.managedbuild.cross.tool.c.linker">
<option id="ilg.gnuarmeclipse.managedbuild.cross.option.c.linker.gcsections.1167322178" name="Remove unused sections (-Xlinker --gc-sections)" superClass="ilg.gnuarmeclipse.managedbuild.cross.option.c.linker.gcsections" useByScannerDiscovery="false" value="true" valueType="boolean"/>
<option id="ilg.gnuarmeclipse.managedbuild.cross.option.c.linker.nostart.351692886" name="Do not use standard start files (-nostartfiles)" superClass="ilg.gnuarmeclipse.managedbuild.cross.option.c.linker.nostart" useByScannerDiscovery="false" value="false" valueType="boolean"/>
<option id="ilg.gnuarmeclipse.managedbuild.cross.option.c.linker.nostdlibs.1009243715" name="No startup or default libs (-nostdlib)" superClass="ilg.gnuarmeclipse.managedbuild.cross.option.c.linker.nostdlibs" useByScannerDiscovery="false" value="false" valueType="boolean"/>
@ -108,7 +109,7 @@
<option IS_BUILTIN_EMPTY="false" IS_VALUE_EMPTY="false" id="ilg.gnuarmeclipse.managedbuild.cross.option.c.linker.paths.36884122" name="Library search path (-L)" superClass="ilg.gnuarmeclipse.managedbuild.cross.option.c.linker.paths" useByScannerDiscovery="false" valueType="libPaths">
<listOptionValue builtIn="false" value="&quot;${workspace_loc:/${ProjName}/script}&quot;"/>
</option>
<option id="ilg.gnuarmeclipse.managedbuild.cross.option.c.linker.other.396049466" name="Other linker flags" superClass="ilg.gnuarmeclipse.managedbuild.cross.option.c.linker.other" useByScannerDiscovery="false" value="-mcpu=cortex-m4 -mthumb -mfpu=fpv5-sp-d16 -mfloat-abi=hard -ffunction-sections -fdata-sections -Wl,--gc-sections,-Map=rtthread.map,-cref,-u,Reset_Handler -L script/" valueType="string"/>
<option id="ilg.gnuarmeclipse.managedbuild.cross.option.c.linker.other.396049466" name="Other linker flags" superClass="ilg.gnuarmeclipse.managedbuild.cross.option.c.linker.other" useByScannerDiscovery="false" value="" valueType="string"/>
<option id="ilg.gnuarmeclipse.managedbuild.cross.option.c.linker.cref.1645737861" name="Cross reference (-Xlinker --cref)" superClass="ilg.gnuarmeclipse.managedbuild.cross.option.c.linker.cref" useByScannerDiscovery="false" value="true" valueType="boolean"/>
<inputType id="ilg.gnuarmeclipse.managedbuild.cross.tool.c.linker.input.334732222" superClass="ilg.gnuarmeclipse.managedbuild.cross.tool.c.linker.input">
<additionalInput kind="additionalinputdependency" paths="$(USER_OBJS)"/>
@ -156,6 +157,7 @@
<option id="ilg.gnuarmeclipse.managedbuild.cross.option.cpp.compiler.defs.704468062" name="Defined symbols (-D)" superClass="ilg.gnuarmeclipse.managedbuild.cross.option.cpp.compiler.defs" useByScannerDiscovery="true"/>
<option IS_BUILTIN_EMPTY="false" IS_VALUE_EMPTY="false" id="ilg.gnuarmeclipse.managedbuild.cross.option.cpp.compiler.include.paths.302877723" name="Include paths (-I)" superClass="ilg.gnuarmeclipse.managedbuild.cross.option.cpp.compiler.include.paths" useByScannerDiscovery="true" valueType="includePath">
<listOptionValue builtIn="false" value="&quot;${workspace_loc://${ProjName}//.}&quot;"/>
<listOptionValue builtIn="false" value="&quot;${workspace_loc://${ProjName}//board/ports/wifi}&quot;"/>
<listOptionValue builtIn="false" value="&quot;${workspace_loc://${ProjName}//board/ports}&quot;"/>
<listOptionValue builtIn="false" value="&quot;${workspace_loc://${ProjName}//board}&quot;"/>
<listOptionValue builtIn="false" value="&quot;${workspace_loc://${ProjName}//libraries/HAL_Drivers/config}&quot;"/>
@ -164,6 +166,7 @@
<listOptionValue builtIn="false" value="&quot;${workspace_loc://${ProjName}//ra/fsp/inc/api}&quot;"/>
<listOptionValue builtIn="false" value="&quot;${workspace_loc://${ProjName}//ra/fsp/inc/instances}&quot;"/>
<listOptionValue builtIn="false" value="&quot;${workspace_loc://${ProjName}//ra/fsp/inc}&quot;"/>
<listOptionValue builtIn="false" value="&quot;${workspace_loc://${ProjName}//ra/tes/dave2d/inc}&quot;"/>
<listOptionValue builtIn="false" value="&quot;${workspace_loc://${ProjName}//ra_cfg/fsp_cfg/bsp}&quot;"/>
<listOptionValue builtIn="false" value="&quot;${workspace_loc://${ProjName}//ra_cfg/fsp_cfg}&quot;"/>
<listOptionValue builtIn="false" value="&quot;${workspace_loc://${ProjName}//ra_gen}&quot;"/>
@ -174,7 +177,6 @@
<listOptionValue builtIn="false" value="&quot;${workspace_loc://${ProjName}//rt-thread/components/libc/posix/io/poll}&quot;"/>
<listOptionValue builtIn="false" value="&quot;${workspace_loc://${ProjName}//rt-thread/components/libc/posix/io/stdio}&quot;"/>
<listOptionValue builtIn="false" value="&quot;${workspace_loc://${ProjName}//rt-thread/components/libc/posix/ipc}&quot;"/>
<listOptionValue builtIn="false" value="&quot;${workspace_loc://${ProjName}//rt-thread/components/utilities/libadt}&quot;"/>
<listOptionValue builtIn="false" value="&quot;${workspace_loc://${ProjName}//rt-thread/include}&quot;"/>
<listOptionValue builtIn="false" value="&quot;${workspace_loc://${ProjName}//rt-thread/libcpu/arm/common}&quot;"/>
<listOptionValue builtIn="false" value="&quot;${workspace_loc://${ProjName}//rt-thread/libcpu/arm/cortex-m4}&quot;"/>
@ -188,7 +190,7 @@
</toolChain>
</folderInfo>
<sourceEntries>
<entry excluding="//board/lvgl|//libraries/HAL_Drivers/drv_adc.c|//libraries/HAL_Drivers/drv_can.c|//libraries/HAL_Drivers/drv_dac.c|//libraries/HAL_Drivers/drv_flash.c|//libraries/HAL_Drivers/drv_i2c.c|//libraries/HAL_Drivers/drv_lcd.c|//libraries/HAL_Drivers/drv_pwm.c|//libraries/HAL_Drivers/drv_rtc.c|//libraries/HAL_Drivers/drv_sci_spi.c|//libraries/HAL_Drivers/drv_sdhi.c|//libraries/HAL_Drivers/drv_soft_i2c.c|//libraries/HAL_Drivers/drv_spi.c|//libraries/HAL_Drivers/drv_wdt.c|//ra/board|//rt-thread/components/dfs|//rt-thread/components/drivers/audio|//rt-thread/components/drivers/can|//rt-thread/components/drivers/cputime|//rt-thread/components/drivers/fdt|//rt-thread/components/drivers/hwcrypto|//rt-thread/components/drivers/hwtimer|//rt-thread/components/drivers/i2c|//rt-thread/components/drivers/misc/adc.c|//rt-thread/components/drivers/misc/dac.c|//rt-thread/components/drivers/misc/pulse_encoder.c|//rt-thread/components/drivers/misc/rt_dev_bus.c|//rt-thread/components/drivers/misc/rt_drv_pwm.c|//rt-thread/components/drivers/misc/rt_inputcapture.c|//rt-thread/components/drivers/misc/rt_null.c|//rt-thread/components/drivers/misc/rt_random.c|//rt-thread/components/drivers/misc/rt_zero.c|//rt-thread/components/drivers/mtd|//rt-thread/components/drivers/phy|//rt-thread/components/drivers/pm|//rt-thread/components/drivers/rtc|//rt-thread/components/drivers/sdio|//rt-thread/components/drivers/sensor|//rt-thread/components/drivers/sensors|//rt-thread/components/drivers/serial/serial.c|//rt-thread/components/drivers/spi|//rt-thread/components/drivers/touch|//rt-thread/components/drivers/tty|//rt-thread/components/drivers/usb|//rt-thread/components/drivers/virtio|//rt-thread/components/drivers/watchdog|//rt-thread/components/drivers/wlan|//rt-thread/components/fal|//rt-thread/components/finsh/msh_file.c|//rt-thread/components/legacy|//rt-thread/components/libc/compilers/armlibc|//rt-thread/components/libc/compilers/dlib|//rt-thread/components/libc/compilers/musl|//rt-thread/components/libc/cplusplus|//rt-thread/components/libc/posix|//rt-thread/components/lwp|//rt-thread/components/mm|//rt-thread/components/net|//rt-thread/components/utilities/resource|//rt-thread/components/utilities/rt-link|//rt-thread/components/utilities/ulog|//rt-thread/components/utilities/utest|//rt-thread/components/utilities/var_export|//rt-thread/components/utilities/ymodem|//rt-thread/components/utilities/zmodem|//rt-thread/components/vbus|//rt-thread/components/vmm|//rt-thread/libcpu/arm/AT91SAM7S|//rt-thread/libcpu/arm/AT91SAM7X|//rt-thread/libcpu/arm/am335x|//rt-thread/libcpu/arm/arm926|//rt-thread/libcpu/arm/armv6|//rt-thread/libcpu/arm/common/divsi3.S|//rt-thread/libcpu/arm/cortex-a|//rt-thread/libcpu/arm/cortex-m0|//rt-thread/libcpu/arm/cortex-m23|//rt-thread/libcpu/arm/cortex-m3|//rt-thread/libcpu/arm/cortex-m33|//rt-thread/libcpu/arm/cortex-m4/context_iar.S|//rt-thread/libcpu/arm/cortex-m4/context_rvds.S|//rt-thread/libcpu/arm/cortex-m7|//rt-thread/libcpu/arm/cortex-r4|//rt-thread/libcpu/arm/dm36x|//rt-thread/libcpu/arm/lpc214x|//rt-thread/libcpu/arm/lpc24xx|//rt-thread/libcpu/arm/realview-a8-vmm|//rt-thread/libcpu/arm/s3c24x0|//rt-thread/libcpu/arm/s3c44b0|//rt-thread/libcpu/arm/sep4020|//rt-thread/libcpu/arm/zynqmp-r5|//rt-thread/src/cpu.c|//rt-thread/src/driver.c|//rt-thread/src/memheap.c|//rt-thread/src/mempool.c|//rt-thread/src/signal.c|//rt-thread/src/slab.c|//rt-thread/tools" flags="VALUE_WORKSPACE_PATH|RESOLVED" kind="sourcePath" name=""/>
<entry excluding="//board/lvgl|//board/ports|//libraries/HAL_Drivers/drv_adc.c|//libraries/HAL_Drivers/drv_can.c|//libraries/HAL_Drivers/drv_dac.c|//libraries/HAL_Drivers/drv_eth.c|//libraries/HAL_Drivers/drv_flash.c|//libraries/HAL_Drivers/drv_i2c.c|//libraries/HAL_Drivers/drv_lcd.c|//libraries/HAL_Drivers/drv_pwm.c|//libraries/HAL_Drivers/drv_rtc.c|//libraries/HAL_Drivers/drv_sci_spi.c|//libraries/HAL_Drivers/drv_sdhi.c|//libraries/HAL_Drivers/drv_soft_i2c.c|//libraries/HAL_Drivers/drv_spi.c|//libraries/HAL_Drivers/drv_wdt.c|//ra/board|//ra/fsp/src/r_ether_phy/targets|//rt-thread/components/dfs|//rt-thread/components/drivers/audio|//rt-thread/components/drivers/can|//rt-thread/components/drivers/cputime|//rt-thread/components/drivers/fdt|//rt-thread/components/drivers/hwcrypto|//rt-thread/components/drivers/hwtimer|//rt-thread/components/drivers/i2c|//rt-thread/components/drivers/misc/adc.c|//rt-thread/components/drivers/misc/dac.c|//rt-thread/components/drivers/misc/pulse_encoder.c|//rt-thread/components/drivers/misc/rt_dev_bus.c|//rt-thread/components/drivers/misc/rt_drv_pwm.c|//rt-thread/components/drivers/misc/rt_inputcapture.c|//rt-thread/components/drivers/misc/rt_null.c|//rt-thread/components/drivers/misc/rt_random.c|//rt-thread/components/drivers/misc/rt_zero.c|//rt-thread/components/drivers/mtd|//rt-thread/components/drivers/phy|//rt-thread/components/drivers/pm|//rt-thread/components/drivers/rtc|//rt-thread/components/drivers/sdio|//rt-thread/components/drivers/sensor|//rt-thread/components/drivers/serial/serial.c|//rt-thread/components/drivers/spi|//rt-thread/components/drivers/touch|//rt-thread/components/drivers/tty|//rt-thread/components/drivers/usb|//rt-thread/components/drivers/virtio|//rt-thread/components/drivers/watchdog|//rt-thread/components/drivers/wlan|//rt-thread/components/fal|//rt-thread/components/finsh/msh_file.c|//rt-thread/components/legacy|//rt-thread/components/libc/compilers/armlibc|//rt-thread/components/libc/compilers/dlib|//rt-thread/components/libc/compilers/musl|//rt-thread/components/libc/cplusplus|//rt-thread/components/libc/posix|//rt-thread/components/lwp|//rt-thread/components/mm|//rt-thread/components/net|//rt-thread/components/utilities|//rt-thread/components/vbus|//rt-thread/components/vmm|//rt-thread/examples|//rt-thread/libcpu/aarch64|//rt-thread/libcpu/arc|//rt-thread/libcpu/arm/AT91SAM7S|//rt-thread/libcpu/arm/AT91SAM7X|//rt-thread/libcpu/arm/am335x|//rt-thread/libcpu/arm/arm926|//rt-thread/libcpu/arm/armv6|//rt-thread/libcpu/arm/common/divsi3.S|//rt-thread/libcpu/arm/cortex-a|//rt-thread/libcpu/arm/cortex-m0|//rt-thread/libcpu/arm/cortex-m23|//rt-thread/libcpu/arm/cortex-m3|//rt-thread/libcpu/arm/cortex-m33|//rt-thread/libcpu/arm/cortex-m4/context_iar.S|//rt-thread/libcpu/arm/cortex-m4/context_rvds.S|//rt-thread/libcpu/arm/cortex-m7|//rt-thread/libcpu/arm/cortex-r4|//rt-thread/libcpu/arm/dm36x|//rt-thread/libcpu/arm/lpc214x|//rt-thread/libcpu/arm/lpc24xx|//rt-thread/libcpu/arm/realview-a8-vmm|//rt-thread/libcpu/arm/s3c24x0|//rt-thread/libcpu/arm/s3c44b0|//rt-thread/libcpu/arm/sep4020|//rt-thread/libcpu/arm/zynqmp-r5|//rt-thread/libcpu/avr32|//rt-thread/libcpu/blackfin|//rt-thread/libcpu/c-sky|//rt-thread/libcpu/ia32|//rt-thread/libcpu/m16c|//rt-thread/libcpu/mips|//rt-thread/libcpu/nios|//rt-thread/libcpu/ppc|//rt-thread/libcpu/risc-v|//rt-thread/libcpu/rx|//rt-thread/libcpu/sim|//rt-thread/libcpu/sparc-v8|//rt-thread/libcpu/ti-dsp|//rt-thread/libcpu/unicore32|//rt-thread/libcpu/v850|//rt-thread/libcpu/xilinx|//rt-thread/src/cpu.c|//rt-thread/src/driver.c|//rt-thread/src/memheap.c|//rt-thread/src/mempool.c|//rt-thread/src/scheduler_mp.c|//rt-thread/src/signal.c|//rt-thread/src/slab.c|//rt-thread/tools" flags="VALUE_WORKSPACE_PATH|RESOLVED" kind="sourcePath" name=""/>
</sourceEntries>
</configuration>
</storageModule>
@ -208,7 +210,7 @@
<storageModule moduleId="org.eclipse.cdt.core.LanguageSettingsProviders"/>
<storageModule moduleId="refreshScope" versionNumber="2">
<configuration configurationName="Debug">
<resource resourceType="PROJECT" workspacePath="/ra6m3-temp"/>
<resource resourceType="PROJECT" workspacePath="/111"/>
</configuration>
</storageModule>
<storageModule moduleId="org.eclipse.cdt.make.core.buildtargets"/>

View File

@ -138,21 +138,11 @@ void hal_entry(void)
- [瑞萨RA MCU 基础知识](https://www2.renesas.cn/cn/zh/document/gde/1520091)
- [RA6 MCU 快速设计指南](https://www2.renesas.cn/cn/zh/document/apn/ra6-quick-design-guide)
**FSP 配置**
需要修改瑞萨的 BSP 外设配置或添加新的外设端口,需要用到瑞萨的 [FSP](https://www2.renesas.cn/jp/zh/software-tool/flexible-software-package-fsp#document) 配置工具。请务必按照如下步骤完成配置。配置中有任何问题可到[RT-Thread 社区论坛](https://club.rt-thread.org/)中提问。
1. [下载灵活配置软件包 (FSP) | Renesas](https://www.renesas.com/cn/zh/software-tool/flexible-software-package-fsp),请使用 FSP 3.5.0 版本
2. 下载安装完成后,需要添加 EK-RA6M3 开发板的官方板级支持包
> 打开[ EK-RA6M3 开发板详情页](https://www.renesas.cn/cn/zh/products/microcontrollers-microprocessors/ra-cortex-m-mcus/ek-ra6m3-evaluation-kit-ra6m3-mcu-group#document),在 **“下载”** 列表中找到 **” EK-RA6M3板级支持包“** ,点击链接即可下载
3. 如何将 **”EK-RA6M3板级支持包“**添加到 FSP 中,请参考文档[如何导入板级支持包](https://www2.renesas.cn/document/ppt/1527171?language=zh&r=1527191)
4. 请查看文档:[使用 FSP 配置外设驱动](../docs/RA系列使用FSP配置外设驱动.md),在 MDK 中通过添加自定义命名来打开当前工程的 FSP 配置。
**ENV 配置**
- 如何使用 ENV 工具:[RT-Thread env 工具用户手册](https://www.rt-thread.org/document/site/#/development-tools/env/env)
此 BSP 默认只开启了 UART7 的功能,如果需使用更多高级功能例如组件、软件包等,需要利用 ENV 工具进行配置。
此 BSP 默认只开启了 UART9 的功能,如果需使用更多高级功能例如组件、软件包等,需要利用 ENV 工具进行配置。
步骤如下:
1. 在 bsp 下打开 env 工具。
@ -164,6 +154,10 @@ void hal_entry(void)
在使用过程中若您有任何的想法和建议,建议您通过以下方式来联系到我们 [RT-Thread 社区论坛](https://club.rt-thread.org/)
## SDK 仓库
这是 HMI-Board 的 SDK 仓库地址:[sdk-bsp-ra6m3-hmi-board](https://github.com/RT-Thread-Studio/sdk-bsp-ra6m3-hmi-board),该仓库包括了外设驱动以及丰富的示例工程,如果像体验官网/社区提供的开源示例请转移到该仓库进行开发。RT-Thread 主仓库只维护最新的驱动相关代码。
## 贡献代码
如果您对 EK-RA6M3 感兴趣,并且有一些好玩的项目愿意与大家分享的话欢迎给我们贡献代码,您可以参考 [如何向 RT-Thread 代码贡献](https://www.rt-thread.org/document/site/#/rt-thread-version/rt-thread-standard/development-guide/github/github)。
如果您对 RA6M3-HMI-Board 感兴趣,并且有一些好玩的项目愿意与大家分享的话欢迎给我们贡献代码,您可以参考 [如何向 RT-Thread 代码贡献](https://www.rt-thread.org/document/site/#/rt-thread-version/rt-thread-standard/development-guide/github/github)。

View File

@ -0,0 +1,757 @@
/**
* @file lv_file_explorer.c
*
*/
/*********************
* INCLUDES
*********************/
#include "lv_file_explorer.h"
#if LV_USE_FILE_EXPLORER != 0
/*********************
* DEFINES
*********************/
#define MY_CLASS &lv_file_explorer_class
#define FILE_EXPLORER_QUICK_ACCESS_AREA_WIDTH (22)
#define FILE_EXPLORER_BROWSER_AREA_WIDTH (100 - FILE_EXPLORER_QUICK_ACCESS_AREA_WIDTH)
/**********************
* TYPEDEFS
**********************/
/**********************
* STATIC PROTOTYPES
**********************/
static void lv_file_explorer_constructor(const lv_obj_class_t *class_p, lv_obj_t *obj);
static void browser_file_event_handler(lv_event_t *e);
#if LV_FILE_EXPLORER_QUICK_ACCESS
static void quick_access_event_handler(lv_event_t *e);
static void quick_access_area_event_handler(lv_event_t *e);
#endif
static void init_style(lv_obj_t *obj);
static void show_dir(lv_obj_t *obj, const char *path);
static void strip_ext(char *dir);
static void file_explorer_sort(lv_obj_t *obj);
static void sort_by_file_kind(lv_obj_t *tb, int16_t lo, int16_t hi);
static void exch_table_item(lv_obj_t *tb, int16_t i, int16_t j);
static bool is_end_with(const char *str1, const char *str2);
/**********************
* STATIC VARIABLES
**********************/
#if LV_FILE_EXPLORER_QUICK_ACCESS
static lv_style_t quick_access_list_btn_style;
#endif
const lv_obj_class_t lv_file_explorer_class = {
.constructor_cb = lv_file_explorer_constructor,
.width_def = LV_SIZE_CONTENT,
.height_def = LV_SIZE_CONTENT,
.instance_size = sizeof(lv_file_explorer_t),
.base_class = &lv_obj_class};
/**********************
* MACROS
**********************/
/**********************
* GLOBAL FUNCTIONS
**********************/
lv_obj_t *lv_file_explorer_create(lv_obj_t *parent)
{
LV_LOG_INFO("begin");
lv_obj_t *obj = lv_obj_class_create_obj(MY_CLASS, parent);
lv_obj_class_init_obj(obj);
return obj;
}
/*=====================
* Setter functions
*====================*/
#if LV_FILE_EXPLORER_QUICK_ACCESS
void lv_file_explorer_set_quick_access_path(lv_obj_t *obj, lv_file_explorer_dir_t dir, const char *path)
{
LV_ASSERT_OBJ(obj, MY_CLASS);
lv_file_explorer_t *explorer = (lv_file_explorer_t *)obj;
/*If path is unavailable */
if ((path == NULL) || (strlen(path) <= 0))
return;
char **dir_str = NULL;
switch (dir)
{
case LV_EXPLORER_HOME_DIR:
dir_str = &(explorer->home_dir);
break;
case LV_EXPLORER_MUSIC_DIR:
dir_str = &(explorer->music_dir);
break;
case LV_EXPLORER_PICTURES_DIR:
dir_str = &(explorer->pictures_dir);
break;
case LV_EXPLORER_VIDEO_DIR:
dir_str = &(explorer->video_dir);
break;
case LV_EXPLORER_DOCS_DIR:
dir_str = &(explorer->docs_dir);
break;
case LV_EXPLORER_FS_DIR:
dir_str = &(explorer->fs_dir);
break;
default:
return;
break;
}
/*Free the old text*/
if (*dir_str != NULL)
{
lv_free(*dir_str);
*dir_str = NULL;
}
/*Get the size of the text*/
size_t len = strlen(path) + 1;
/*Allocate space for the new text*/
*dir_str = lv_malloc(len);
LV_ASSERT_MALLOC(*dir_str);
if (*dir_str == NULL)
return;
strcpy(*dir_str, path);
}
#endif
void lv_file_explorer_set_sort(lv_obj_t *obj, lv_file_explorer_sort_t sort)
{
LV_ASSERT_OBJ(obj, MY_CLASS);
lv_file_explorer_t *explorer = (lv_file_explorer_t *)obj;
explorer->sort = sort;
file_explorer_sort(obj);
}
/*=====================
* Getter functions
*====================*/
const char *lv_file_explorer_get_selected_file_name(const lv_obj_t *obj)
{
LV_ASSERT_OBJ(obj, MY_CLASS);
lv_file_explorer_t *explorer = (lv_file_explorer_t *)obj;
return explorer->sel_fn;
}
const char *lv_file_explorer_get_current_path(const lv_obj_t *obj)
{
LV_ASSERT_OBJ(obj, MY_CLASS);
lv_file_explorer_t *explorer = (lv_file_explorer_t *)obj;
return explorer->current_path;
}
lv_obj_t *lv_file_explorer_get_file_table(lv_obj_t *obj)
{
LV_ASSERT_OBJ(obj, MY_CLASS);
lv_file_explorer_t *explorer = (lv_file_explorer_t *)obj;
return explorer->file_table;
}
lv_obj_t *lv_file_explorer_get_header(lv_obj_t *obj)
{
LV_ASSERT_OBJ(obj, MY_CLASS);
lv_file_explorer_t *explorer = (lv_file_explorer_t *)obj;
return explorer->head_area;
}
lv_obj_t *lv_file_explorer_get_path_label(lv_obj_t *obj)
{
LV_ASSERT_OBJ(obj, MY_CLASS);
lv_file_explorer_t *explorer = (lv_file_explorer_t *)obj;
return explorer->path_label;
}
#if LV_FILE_EXPLORER_QUICK_ACCESS
lv_obj_t *lv_file_explorer_get_quick_access_area(lv_obj_t *obj)
{
LV_ASSERT_OBJ(obj, MY_CLASS);
lv_file_explorer_t *explorer = (lv_file_explorer_t *)obj;
return explorer->quick_access_area;
}
lv_obj_t *lv_file_explorer_get_places_list(lv_obj_t *obj)
{
LV_ASSERT_OBJ(obj, MY_CLASS);
lv_file_explorer_t *explorer = (lv_file_explorer_t *)obj;
return explorer->list_places;
}
lv_obj_t *lv_file_explorer_get_device_list(lv_obj_t *obj)
{
LV_ASSERT_OBJ(obj, MY_CLASS);
lv_file_explorer_t *explorer = (lv_file_explorer_t *)obj;
return explorer->list_device;
}
#endif
lv_file_explorer_sort_t lv_file_explorer_get_sort(const lv_obj_t *obj)
{
LV_ASSERT_OBJ(obj, MY_CLASS);
lv_file_explorer_t *explorer = (lv_file_explorer_t *)obj;
return explorer->sort;
}
/*=====================
* Other functions
*====================*/
void lv_file_explorer_open_dir(lv_obj_t *obj, const char *dir)
{
LV_ASSERT_OBJ(obj, MY_CLASS);
show_dir(obj, dir);
}
/**********************
* STATIC FUNCTIONS
**********************/
static void lv_file_explorer_constructor(const lv_obj_class_t *class_p, lv_obj_t *obj)
{
LV_UNUSED(class_p);
LV_TRACE_OBJ_CREATE("begin");
lv_file_explorer_t *explorer = (lv_file_explorer_t *)obj;
#if LV_FILE_EXPLORER_QUICK_ACCESS
explorer->home_dir = NULL;
explorer->video_dir = NULL;
explorer->pictures_dir = NULL;
explorer->music_dir = NULL;
explorer->docs_dir = NULL;
explorer->fs_dir = NULL;
#endif
explorer->sort = LV_EXPLORER_SORT_NONE;
lv_memset_00(explorer->current_path, sizeof(explorer->current_path));
lv_obj_set_size(obj, LV_PCT(100), LV_PCT(100));
lv_obj_set_flex_flow(obj, LV_FLEX_FLOW_COLUMN);
explorer->cont = lv_obj_create(obj);
lv_obj_set_width(explorer->cont, LV_PCT(100));
lv_obj_set_flex_grow(explorer->cont, 1);
#if LV_FILE_EXPLORER_QUICK_ACCESS
/*Quick access bar area on the left*/
explorer->quick_access_area = lv_obj_create(explorer->cont);
lv_obj_set_size(explorer->quick_access_area, LV_PCT(FILE_EXPLORER_QUICK_ACCESS_AREA_WIDTH), LV_PCT(100));
lv_obj_set_flex_flow(explorer->quick_access_area, LV_FLEX_FLOW_COLUMN);
lv_obj_add_event_cb(explorer->quick_access_area, quick_access_area_event_handler, LV_EVENT_ALL,
explorer);
#endif
/*File table area on the right*/
explorer->browser_area = lv_obj_create(explorer->cont);
#if LV_FILE_EXPLORER_QUICK_ACCESS
lv_obj_set_size(explorer->browser_area, LV_PCT(FILE_EXPLORER_BROWSER_AREA_WIDTH), LV_PCT(100));
#else
lv_obj_set_size(explorer->browser_area, LV_PCT(100), LV_PCT(100));
#endif
lv_obj_set_flex_flow(explorer->browser_area, LV_FLEX_FLOW_COLUMN);
/*The area displayed above the file browse list(head)*/
explorer->head_area = lv_obj_create(explorer->browser_area);
lv_obj_set_size(explorer->head_area, LV_PCT(100), LV_PCT(14));
lv_obj_clear_flag(explorer->head_area, LV_OBJ_FLAG_SCROLLABLE);
#if LV_FILE_EXPLORER_QUICK_ACCESS
/*Two lists of quick access bar*/
lv_obj_t *btn;
/*list 1*/
explorer->list_device = lv_list_create(explorer->quick_access_area);
lv_obj_set_size(explorer->list_device, LV_PCT(100), LV_SIZE_CONTENT);
lv_obj_set_style_bg_color(lv_list_add_text(explorer->list_device, "DEVICE"), lv_palette_main(LV_PALETTE_ORANGE), 0);
btn = lv_list_add_btn(explorer->list_device, NULL, LV_SYMBOL_DRIVE " File System");
lv_obj_add_event_cb(btn, quick_access_event_handler, LV_EVENT_CLICKED, obj);
/*list 2*/
explorer->list_places = lv_list_create(explorer->quick_access_area);
lv_obj_set_size(explorer->list_places, LV_PCT(100), LV_SIZE_CONTENT);
lv_obj_set_style_bg_color(lv_list_add_text(explorer->list_places, "PLACES"), lv_palette_main(LV_PALETTE_LIME), 0);
btn = lv_list_add_btn(explorer->list_places, NULL, LV_SYMBOL_HOME " HOME");
lv_obj_add_event_cb(btn, quick_access_event_handler, LV_EVENT_CLICKED, obj);
btn = lv_list_add_btn(explorer->list_places, NULL, LV_SYMBOL_VIDEO " Video");
lv_obj_add_event_cb(btn, quick_access_event_handler, LV_EVENT_CLICKED, obj);
btn = lv_list_add_btn(explorer->list_places, NULL, LV_SYMBOL_IMAGE " Pictures");
lv_obj_add_event_cb(btn, quick_access_event_handler, LV_EVENT_CLICKED, obj);
btn = lv_list_add_btn(explorer->list_places, NULL, LV_SYMBOL_AUDIO " Music");
lv_obj_add_event_cb(btn, quick_access_event_handler, LV_EVENT_CLICKED, obj);
btn = lv_list_add_btn(explorer->list_places, NULL, LV_SYMBOL_FILE " Documents");
lv_obj_add_event_cb(btn, quick_access_event_handler, LV_EVENT_CLICKED, obj);
#endif
/*Show current path*/
explorer->path_label = lv_label_create(explorer->head_area);
lv_label_set_text(explorer->path_label, LV_SYMBOL_EYE_OPEN "https://lvgl.io");
lv_obj_center(explorer->path_label);
/*Table showing the contents of the table of contents*/
explorer->file_table = lv_table_create(explorer->browser_area);
lv_obj_set_size(explorer->file_table, LV_PCT(100), LV_PCT(86));
lv_table_set_col_width(explorer->file_table, 0, LV_PCT(100));
lv_table_set_col_cnt(explorer->file_table, 1);
lv_obj_add_event_cb(explorer->file_table, browser_file_event_handler, LV_EVENT_ALL, obj);
/*only scroll up and down*/
lv_obj_set_scroll_dir(explorer->file_table, LV_DIR_TOP | LV_DIR_BOTTOM);
/*Initialize style*/
init_style(obj);
LV_TRACE_OBJ_CREATE("finished");
}
static void init_style(lv_obj_t *obj)
{
lv_file_explorer_t *explorer = (lv_file_explorer_t *)obj;
/*lv_file_explorer obj style*/
lv_obj_set_style_radius(obj, 0, 0);
lv_obj_set_style_bg_color(obj, lv_color_hex(0xf2f1f6), 0);
/*main container style*/
lv_obj_set_style_radius(explorer->cont, 0, 0);
lv_obj_set_style_bg_opa(explorer->cont, LV_OPA_0, 0);
lv_obj_set_style_border_width(explorer->cont, 0, 0);
lv_obj_set_style_outline_width(explorer->cont, 0, 0);
lv_obj_set_style_pad_column(explorer->cont, 0, 0);
lv_obj_set_style_pad_row(explorer->cont, 0, 0);
lv_obj_set_style_flex_flow(explorer->cont, LV_FLEX_FLOW_ROW, 0);
lv_obj_set_style_pad_all(explorer->cont, 0, 0);
lv_obj_set_style_layout(explorer->cont, LV_LAYOUT_FLEX, 0);
/*head cont style*/
lv_obj_set_style_radius(explorer->head_area, 0, 0);
lv_obj_set_style_border_width(explorer->head_area, 0, 0);
lv_obj_set_style_pad_top(explorer->head_area, 0, 0);
#if LV_FILE_EXPLORER_QUICK_ACCESS
/*Quick access bar container style*/
lv_obj_set_style_pad_all(explorer->quick_access_area, 0, 0);
lv_obj_set_style_pad_row(explorer->quick_access_area, 20, 0);
lv_obj_set_style_radius(explorer->quick_access_area, 0, 0);
lv_obj_set_style_border_width(explorer->quick_access_area, 1, 0);
lv_obj_set_style_outline_width(explorer->quick_access_area, 0, 0);
lv_obj_set_style_bg_color(explorer->quick_access_area, lv_color_hex(0xf2f1f6), 0);
#endif
/*File browser container style*/
lv_obj_set_style_pad_all(explorer->browser_area, 0, 0);
lv_obj_set_style_pad_row(explorer->browser_area, 0, 0);
lv_obj_set_style_radius(explorer->browser_area, 0, 0);
lv_obj_set_style_border_width(explorer->browser_area, 0, 0);
lv_obj_set_style_outline_width(explorer->browser_area, 0, 0);
lv_obj_set_style_bg_color(explorer->browser_area, lv_color_hex(0xffffff), 0);
/*Style of the table in the browser container*/
lv_obj_set_style_bg_color(explorer->file_table, lv_color_hex(0xffffff), 0);
lv_obj_set_style_pad_all(explorer->file_table, 0, 0);
lv_obj_set_style_radius(explorer->file_table, 0, 0);
lv_obj_set_style_border_width(explorer->file_table, 0, 0);
lv_obj_set_style_outline_width(explorer->file_table, 0, 0);
#if LV_FILE_EXPLORER_QUICK_ACCESS
/*Style of the list in the quick access bar*/
lv_obj_set_style_border_width(explorer->list_device, 0, 0);
lv_obj_set_style_outline_width(explorer->list_device, 0, 0);
lv_obj_set_style_radius(explorer->list_device, 0, 0);
lv_obj_set_style_pad_all(explorer->list_device, 0, 0);
lv_obj_set_style_border_width(explorer->list_places, 0, 0);
lv_obj_set_style_outline_width(explorer->list_places, 0, 0);
lv_obj_set_style_radius(explorer->list_places, 0, 0);
lv_obj_set_style_pad_all(explorer->list_places, 0, 0);
/*Style of the quick access list btn in the quick access bar*/
lv_style_init(&quick_access_list_btn_style);
lv_style_set_border_width(&quick_access_list_btn_style, 0);
lv_style_set_bg_color(&quick_access_list_btn_style, lv_color_hex(0xf2f1f6));
uint32_t i, j;
for (i = 0; i < lv_obj_get_child_cnt(explorer->quick_access_area); i++)
{
lv_obj_t *child = lv_obj_get_child(explorer->quick_access_area, i);
if (lv_obj_check_type(child, &lv_list_class))
{
for (j = 0; j < lv_obj_get_child_cnt(child); j++)
{
lv_obj_t *list_child = lv_obj_get_child(child, j);
if (lv_obj_check_type(list_child, &lv_list_btn_class))
{
lv_obj_add_style(list_child, &quick_access_list_btn_style, 0);
}
}
}
}
#endif
}
#if LV_FILE_EXPLORER_QUICK_ACCESS
static void quick_access_event_handler(lv_event_t *e)
{
lv_event_code_t code = lv_event_get_code(e);
lv_obj_t *btn = lv_event_get_target(e);
lv_obj_t *obj = lv_event_get_user_data(e);
lv_file_explorer_t *explorer = (lv_file_explorer_t *)obj;
if (code == LV_EVENT_CLICKED)
{
char **path = NULL;
lv_obj_t *label = lv_obj_get_child(btn, -1);
char *label_text = lv_label_get_text(label);
if ((strcmp(label_text, LV_SYMBOL_HOME " HOME") == 0))
{
path = &(explorer->home_dir);
}
else if ((strcmp(label_text, LV_SYMBOL_VIDEO " Video") == 0))
{
path = &(explorer->video_dir);
}
else if ((strcmp(label_text, LV_SYMBOL_IMAGE " Pictures") == 0))
{
path = &(explorer->pictures_dir);
}
else if ((strcmp(label_text, LV_SYMBOL_AUDIO " Music") == 0))
{
path = &(explorer->music_dir);
}
else if ((strcmp(label_text, LV_SYMBOL_FILE " Documents") == 0))
{
path = &(explorer->docs_dir);
}
else if ((strcmp(label_text, LV_SYMBOL_DRIVE " File System") == 0))
{
path = &(explorer->fs_dir);
}
if (path != NULL)
show_dir(obj, *path);
}
}
static void quick_access_area_event_handler(lv_event_t *e)
{
lv_event_code_t code = lv_event_get_code(e);
lv_obj_t *area = lv_event_get_target(e);
lv_obj_t *obj = lv_event_get_user_data(e);
lv_file_explorer_t *explorer = (lv_file_explorer_t *)obj;
if (code == LV_EVENT_LAYOUT_CHANGED)
{
if (lv_obj_has_flag(area, LV_OBJ_FLAG_HIDDEN))
lv_obj_set_size(explorer->browser_area, LV_PCT(100), LV_PCT(100));
else
lv_obj_set_size(explorer->browser_area, LV_PCT(FILE_EXPLORER_BROWSER_AREA_WIDTH), LV_PCT(100));
}
}
#endif
static void browser_file_event_handler(lv_event_t *e)
{
lv_event_code_t code = lv_event_get_code(e);
lv_obj_t *obj = lv_event_get_user_data(e);
lv_file_explorer_t *explorer = (lv_file_explorer_t *)obj;
if (code == LV_EVENT_VALUE_CHANGED)
{
char file_name[LV_FILE_EXPLORER_PATH_MAX_LEN];
const char *str_fn = NULL;
uint16_t row;
uint16_t col;
lv_memset_00(file_name, sizeof(file_name));
lv_table_get_selected_cell(explorer->file_table, &row, &col);
str_fn = lv_table_get_cell_value(explorer->file_table, row, col);
str_fn = str_fn + 5;
if ((strcmp(str_fn, ".") == 0))
return;
if ((strcmp(str_fn, "..") == 0) && (strlen(explorer->current_path) > 3))
{
strip_ext(explorer->current_path);
/*Remove the last '/' character*/
strip_ext(explorer->current_path);
lv_snprintf((char *)file_name, sizeof(file_name), "%s", explorer->current_path);
}
else
{
if (strcmp(str_fn, "..") != 0)
{
lv_snprintf((char *)file_name, sizeof(file_name), "%s%s", explorer->current_path, str_fn);
}
}
lv_fs_dir_t dir;
if (lv_fs_dir_open(&dir, file_name) == LV_FS_RES_OK)
{
lv_fs_dir_close(&dir);
show_dir(obj, (char *)file_name);
}
else
{
if (strcmp(str_fn, "..") != 0)
{
explorer->sel_fn = str_fn;
lv_event_send(obj, LV_EVENT_VALUE_CHANGED, NULL);
}
}
}
else if (code == LV_EVENT_SIZE_CHANGED)
{
lv_table_set_col_width(explorer->file_table, 0, lv_obj_get_width(explorer->file_table));
}
else if ((code == LV_EVENT_CLICKED) || (code == LV_EVENT_RELEASED))
{
lv_event_send(obj, LV_EVENT_CLICKED, NULL);
}
}
static void show_dir(lv_obj_t *obj, const char *path)
{
lv_file_explorer_t *explorer = (lv_file_explorer_t *)obj;
char fn[LV_FILE_EXPLORER_PATH_MAX_LEN];
uint16_t index = 0;
lv_fs_dir_t dir;
lv_fs_res_t res;
res = lv_fs_dir_open(&dir, path);
if (res != LV_FS_RES_OK)
{
LV_LOG_USER("Open dir error %d!", res);
return;
}
lv_table_set_cell_value_fmt(explorer->file_table, index++, 0, LV_SYMBOL_DIRECTORY " %s", ".");
lv_table_set_cell_value_fmt(explorer->file_table, index++, 0, LV_SYMBOL_DIRECTORY " %s", "..");
lv_table_set_cell_value(explorer->file_table, 0, 1, "0");
lv_table_set_cell_value(explorer->file_table, 1, 1, "0");
while (1)
{
res = lv_fs_dir_read(&dir, fn);
if (res != LV_FS_RES_OK)
{
LV_LOG_USER("Driver, file or directory is not exists %d!", res);
break;
}
/*fn is empty, if not more files to read*/
if (strlen(fn) == 0)
{
LV_LOG_USER("Not more files to read!");
break;
}
if ((is_end_with(fn, ".png") == true) || (is_end_with(fn, ".PNG") == true) ||
(is_end_with(fn, ".jpg") == true) || (is_end_with(fn, ".JPG") == true) ||
(is_end_with(fn, ".bmp") == true) || (is_end_with(fn, ".BMP") == true) ||
(is_end_with(fn, ".gif") == true) || (is_end_with(fn, ".GIF") == true))
{
lv_table_set_cell_value_fmt(explorer->file_table, index, 0, LV_SYMBOL_IMAGE " %s", fn);
lv_table_set_cell_value(explorer->file_table, index, 1, "1");
}
else if ((is_end_with(fn, ".mp3") == true) || (is_end_with(fn, ".MP3") == true))
{
lv_table_set_cell_value_fmt(explorer->file_table, index, 0, LV_SYMBOL_AUDIO " %s", fn);
lv_table_set_cell_value(explorer->file_table, index, 1, "2");
}
else if ((is_end_with(fn, ".mp4") == true) || (is_end_with(fn, ".MP4") == true))
{
lv_table_set_cell_value_fmt(explorer->file_table, index, 0, LV_SYMBOL_VIDEO " %s", fn);
lv_table_set_cell_value(explorer->file_table, index, 1, "3");
}
else if ((is_end_with(fn, ".avi") == true))
{
lv_table_set_cell_value_fmt(explorer->file_table, index, 0, LV_SYMBOL_VIDEO " %s", fn);
lv_table_set_cell_value(explorer->file_table, index, 1, "4");
}
else if ((is_end_with(fn, ".") == true) || (is_end_with(fn, "..") == true))
{
/*is dir*/
continue;
}
else if (fn[0] == '/')
{ /*is dir*/
lv_table_set_cell_value_fmt(explorer->file_table, index, 0, LV_SYMBOL_DIRECTORY " %s", fn + 1);
lv_table_set_cell_value(explorer->file_table, index, 1, "0");
}
else
{
lv_table_set_cell_value_fmt(explorer->file_table, index, 0, LV_SYMBOL_FILE " %s", fn);
lv_table_set_cell_value(explorer->file_table, index, 1, "4");
}
index++;
}
lv_fs_dir_close(&dir);
// DIR_CLOSE:
lv_table_set_row_cnt(explorer->file_table, index);
file_explorer_sort(obj);
lv_event_send(obj, LV_EVENT_READY, NULL);
/*Move the table to the top*/
lv_obj_scroll_to_y(explorer->file_table, 0, LV_ANIM_OFF);
lv_memset_00(explorer->current_path, sizeof(explorer->current_path));
strcpy(explorer->current_path, path);
lv_label_set_text_fmt(explorer->path_label, LV_SYMBOL_EYE_OPEN " %s", path);
size_t current_path_len = strlen(explorer->current_path);
if ((*((explorer->current_path) + current_path_len) != '/') && (current_path_len < LV_FILE_EXPLORER_PATH_MAX_LEN))
{
*((explorer->current_path) + current_path_len) = '/';
}
}
/*Remove the specified suffix*/
static void strip_ext(char *dir)
{
char *end = dir + strlen(dir);
while (end >= dir && *end != '/')
{
--end;
}
if (end > dir)
{
*end = '\0';
}
else if (end == dir)
{
*(end + 1) = '\0';
}
}
static void exch_table_item(lv_obj_t *tb, int16_t i, int16_t j)
{
const char *tmp;
tmp = lv_table_get_cell_value(tb, i, 0);
lv_table_set_cell_value(tb, 0, 2, tmp);
lv_table_set_cell_value(tb, i, 0, lv_table_get_cell_value(tb, j, 0));
lv_table_set_cell_value(tb, j, 0, lv_table_get_cell_value(tb, 0, 2));
tmp = lv_table_get_cell_value(tb, i, 1);
lv_table_set_cell_value(tb, 0, 2, tmp);
lv_table_set_cell_value(tb, i, 1, lv_table_get_cell_value(tb, j, 1));
lv_table_set_cell_value(tb, j, 1, lv_table_get_cell_value(tb, 0, 2));
}
static void file_explorer_sort(lv_obj_t *obj)
{
LV_ASSERT_OBJ(obj, MY_CLASS);
lv_file_explorer_t *explorer = (lv_file_explorer_t *)obj;
uint16_t sum = lv_table_get_row_cnt(explorer->file_table);
if (sum > 1)
{
switch (explorer->sort)
{
case LV_EXPLORER_SORT_NONE:
break;
case LV_EXPLORER_SORT_KIND:
sort_by_file_kind(explorer->file_table, 0, (sum - 1));
break;
default:
break;
}
}
}
/*Quick sort 3 way*/
static void sort_by_file_kind(lv_obj_t *tb, int16_t lo, int16_t hi)
{
if (lo >= hi)
return;
int16_t lt = lo;
int16_t i = lo + 1;
int16_t gt = hi;
const char *v = lv_table_get_cell_value(tb, lo, 1);
while (i <= gt)
{
if (strcmp(lv_table_get_cell_value(tb, i, 1), v) < 0)
exch_table_item(tb, lt++, i++);
else if (strcmp(lv_table_get_cell_value(tb, i, 1), v) > 0)
exch_table_item(tb, i, gt--);
else
i++;
}
sort_by_file_kind(tb, lo, lt - 1);
sort_by_file_kind(tb, gt + 1, hi);
}
static bool is_end_with(const char *str1, const char *str2)
{
if (str1 == NULL || str2 == NULL)
return false;
uint16_t len1 = strlen(str1);
uint16_t len2 = strlen(str2);
if ((len1 < len2) || (len1 == 0 || len2 == 0))
return false;
while (len2 >= 1)
{
if (str2[len2 - 1] != str1[len1 - 1])
return false;
len2--;
len1--;
}
return true;
}
#endif /*LV_USE_FILE_EXPLORER*/

View File

@ -0,0 +1,190 @@
/**
* @file lv_file_explorer.h
*
*/
#ifndef LV_FILE_EXPLORER_H
#define LV_FILE_EXPLORER_H
#ifdef __cplusplus
extern "C" {
#endif
/*********************
* INCLUDES
*********************/
#include "../../../lvgl.h"
#if LV_USE_FILE_EXPLORER != 0
/*********************
* DEFINES
*********************/
/**********************
* TYPEDEFS
**********************/
typedef enum {
LV_EXPLORER_SORT_NONE,
LV_EXPLORER_SORT_KIND,
} lv_file_explorer_sort_t;
#if LV_FILE_EXPLORER_QUICK_ACCESS
typedef enum {
LV_EXPLORER_HOME_DIR,
LV_EXPLORER_MUSIC_DIR,
LV_EXPLORER_PICTURES_DIR,
LV_EXPLORER_VIDEO_DIR,
LV_EXPLORER_DOCS_DIR,
LV_EXPLORER_FS_DIR,
} lv_file_explorer_dir_t;
#endif
/*Data of canvas*/
typedef struct {
lv_obj_t obj;
lv_obj_t * cont;
lv_obj_t * head_area;
lv_obj_t * browser_area;
lv_obj_t * file_table;
lv_obj_t * path_label;
#if LV_FILE_EXPLORER_QUICK_ACCESS
lv_obj_t * quick_access_area;
lv_obj_t * list_device;
lv_obj_t * list_places;
char * home_dir;
char * music_dir;
char * pictures_dir;
char * video_dir;
char * docs_dir;
char * fs_dir;
#endif
const char * sel_fn;
char current_path[LV_FILE_EXPLORER_PATH_MAX_LEN];
lv_file_explorer_sort_t sort;
} lv_file_explorer_t;
extern const lv_obj_class_t lv_file_explorer_class;
/***********************
* GLOBAL VARIABLES
***********************/
/**********************
* GLOBAL PROTOTYPES
**********************/
lv_obj_t * lv_file_explorer_create(lv_obj_t * parent);
/*=====================
* Setter functions
*====================*/
#if LV_FILE_EXPLORER_QUICK_ACCESS
/**
* Set file_explorer
* @param obj pointer to a label object
* @param dir the dir from 'lv_file_explorer_dir_t' enum.
*/
void lv_file_explorer_set_quick_access_path(lv_obj_t * obj, lv_file_explorer_dir_t dir, const char * path);
#endif
/**
* Set file_explorer sort
* @param obj pointer to a file explorer object
* @param sort the sort from 'lv_file_explorer_sort_t' enum.
*/
void lv_file_explorer_set_sort(lv_obj_t * obj, lv_file_explorer_sort_t sort);
/*=====================
* Getter functions
*====================*/
/**
* Get file explorer Selected file
* @param obj pointer to a file explorer object
* @return pointer to the file explorer selected file name
*/
const char * lv_file_explorer_get_selected_file_name(const lv_obj_t * obj);
/**
* Get file explorer cur path
* @param obj pointer to a file explorer object
* @return pointer to the file explorer cur path
*/
const char * lv_file_explorer_get_current_path(const lv_obj_t * obj);
/**
* Get file explorer head area obj
* @param obj pointer to a file explorer object
* @return pointer to the file explorer head area obj(lv_obj)
*/
lv_obj_t * lv_file_explorer_get_header(lv_obj_t * obj);
/**
* Get file explorer head area obj
* @param obj pointer to a file explorer object
* @return pointer to the file explorer quick access area obj(lv_obj)
*/
lv_obj_t * lv_file_explorer_get_quick_access_area(lv_obj_t * obj);
/**
* Get file explorer path obj(label)
* @param obj pointer to a file explorer object
* @return pointer to the file explorer path obj(lv_label)
*/
lv_obj_t * lv_file_explorer_get_path_label(lv_obj_t * obj);
#if LV_FILE_EXPLORER_QUICK_ACCESS
/**
* Get file explorer places list obj(lv_list)
* @param obj pointer to a file explorer object
* @return pointer to the file explorer places list obj(lv_list)
*/
lv_obj_t * lv_file_explorer_get_places_list(lv_obj_t * obj);
/**
* Get file explorer device list obj(lv_list)
* @param obj pointer to a file explorer object
* @return pointer to the file explorer device list obj(lv_list)
*/
lv_obj_t * lv_file_explorer_get_device_list(lv_obj_t * obj);
#endif
/**
* Get file explorer file list obj(lv_table)
* @param obj pointer to a file explorer object
* @return pointer to the file explorer file table obj(lv_table)
*/
lv_obj_t * lv_file_explorer_get_file_table(lv_obj_t * obj);
/**
* Set file_explorer sort
* @param obj pointer to a file explorer object
* @return the current mode from 'lv_file_explorer_sort_t'
*/
lv_file_explorer_sort_t lv_file_explorer_get_sort(const lv_obj_t * obj);
/*=====================
* Other functions
*====================*/
/**
* Open a specified path
* @param obj pointer to a file explorer object
* @param dir pointer to the path
*/
void lv_file_explorer_open_dir(lv_obj_t * obj, const char * dir);
/**********************
* MACROS
**********************/
#endif /*LV_USE_FILE_EXPLORER*/
#ifdef __cplusplus
} /*extern "C"*/
#endif
#endif /*LV_FILE_EXPLORER_H*/

View File

@ -16,7 +16,7 @@ void lv_user_gui_init(void)
#ifdef BSP_USING_LVGL_VIDEO_DEMO
extern void lv_video_gui_init(void);
lv_video_gui_init();
#elif BSP_USING_LVGL_MUSIC_DEMO
#else
extern void lv_demo_music(void);
lv_demo_music();
#endif

View File

@ -0,0 +1,17 @@
from building import *
import os
cwd = GetCurrentDir()
group = []
src = Glob('*.c')
CPPPATH = [cwd]
list = os.listdir(cwd)
for d in list:
path = os.path.join(cwd, d)
if os.path.isfile(os.path.join(path, 'SConscript')):
group = group + SConscript(os.path.join(d, 'SConscript'))
group = group + DefineGroup('LVGL-demo', src, depend = ['BSP_USING_LVGL', 'BSP_USING_LVGL_VIDEO_DEMO'], CPPPATH = CPPPATH)
Return('group')

View File

@ -0,0 +1,17 @@
from building import *
import os
cwd = GetCurrentDir()
group = []
src = Glob('*.c')
CPPPATH = [cwd]
list = os.listdir(cwd)
for d in list:
path = os.path.join(cwd, d)
if os.path.isfile(os.path.join(path, 'SConscript')):
group = group + SConscript(os.path.join(d, 'SConscript'))
group = group + DefineGroup('LVGL-demo', src, depend = ['BSP_USING_LVGL', 'BSP_USING_LVGL_VIDEO_DEMO'], CPPPATH = CPPPATH)
Return('group')

View File

@ -46,7 +46,7 @@ const lv_obj_class_t lv_media_class =
static rt_bool_t btn_state_change = RT_FALSE;
static rt_bool_t play_state_change = RT_FALSE;
static uint16_t lv_show_buffer[JPEG_WIDTH * JPEG_HEIGHT] BSP_ALIGN_VARIABLE(16);
static uint16_t lv_show_buffer[JPEG_WIDTH * JPEG_HEIGHT] BSP_ALIGN_VARIABLE(16) BSP_PLACE_IN_SECTION(".bss");
struct player v_player;
static void func_button_create(lv_obj_t *parent);

View File

@ -20,7 +20,7 @@
* performance, bitmaps need to be in correct order */
#define DLG_LVGL_CF_SUB_BYTE_SWAP 0
#define DLG_LVGL_USE_GPU_RA6M3 1
#define DLG_LVGL_USE_GPU_RA6M3 0
#define LV_USE_PERF_MONITOR 1
#define LV_COLOR_DEPTH 16
@ -36,6 +36,7 @@
#define LV_DPI_DEF 89
#endif
#ifdef BSP_USING_LVGL_VIDEO_DEMO
#define LV_USE_FILE_EXPLORER 1
#if LV_USE_FILE_EXPLORER
/*Maximum length of path*/
@ -51,6 +52,7 @@
#define LV_FS_STDIO_PATH "/" /*Set the working directory. File/directory paths will be appended to it.*/
#define LV_FS_STDIO_CACHE_SIZE 0 /*>0 to cache this number of bytes in lv_fs_read()*/
#endif
#endif
#ifdef PKG_USING_LV_MUSIC_DEMO
/* music player demo */

View File

@ -5,11 +5,132 @@
*
* Change Logs:
* Date Author Notes
* 2021-10-18 Meco Man The first version
* 2023-03-09 Rbb666 The first version
*/
#include <lvgl.h>
#include <rtdevice.h>
#include "gt911.h"
#define DBG_TAG "lv_port_indev"
#define DBG_LVL DBG_LOG
#include <rtdbg.h>
#include "hal_data.h"
#define GT911_IRQ_PIN BSP_IO_PORT_00_PIN_04
#define GT911_RST_PIN BSP_IO_PORT_08_PIN_01
static rt_device_t touch_dev;
static lv_indev_t *touch_indev;
struct rt_touch_data *read_data;
volatile static rt_uint8_t touch_detect_flag = 0;
static void touchpad_read(lv_indev_drv_t *indev, lv_indev_data_t *data)
{
if (touch_detect_flag != 1)
return;
rt_device_read(touch_dev, 0, read_data, 1);
if (read_data->event == RT_TOUCH_EVENT_NONE)
return;
data->point.x = read_data->x_coordinate;
data->point.y = read_data->y_coordinate;
if (read_data->event == RT_TOUCH_EVENT_DOWN)
data->state = LV_INDEV_STATE_PR;
if (read_data->event == RT_TOUCH_EVENT_MOVE)
data->state = LV_INDEV_STATE_PR;
if (read_data->event == RT_TOUCH_EVENT_UP)
data->state = LV_INDEV_STATE_REL;
touch_detect_flag = 0;
rt_device_control(touch_dev, RT_TOUCH_CTRL_ENABLE_INT, RT_NULL);
}
static rt_err_t rx_callback(rt_device_t dev, rt_size_t size)
{
touch_detect_flag = 1;
rt_device_control(dev, RT_TOUCH_CTRL_DISABLE_INT, RT_NULL);
return 0;
}
rt_err_t gt911_probe(rt_uint16_t x, rt_uint16_t y)
{
void *id;
touch_dev = rt_device_find("gt911");
if (touch_dev == RT_NULL)
{
rt_kprintf("can't find device gt911\n");
return -1;
}
if (rt_device_open(touch_dev, RT_DEVICE_FLAG_INT_RX) != RT_EOK)
{
rt_kprintf("open device failed!");
return -1;
}
id = rt_malloc(sizeof(rt_uint8_t) * 8);
rt_device_control(touch_dev, RT_TOUCH_CTRL_GET_ID, id);
rt_uint8_t *read_id = (rt_uint8_t *)id;
rt_kprintf("id = GT%d%d%d \n", read_id[0] - '0', read_id[1] - '0', read_id[2] - '0');
rt_device_control(touch_dev, RT_TOUCH_CTRL_SET_X_RANGE, &x); /* if possible you can set your x y coordinate*/
rt_device_control(touch_dev, RT_TOUCH_CTRL_SET_Y_RANGE, &y);
rt_device_control(touch_dev, RT_TOUCH_CTRL_GET_INFO, id);
rt_kprintf("range_x = %d \n", (*(struct rt_touch_info *)id).range_x);
rt_kprintf("range_y = %d \n", (*(struct rt_touch_info *)id).range_y);
rt_kprintf("point_num = %d \n", (*(struct rt_touch_info *)id).point_num);
rt_free(id);
rt_device_set_rx_indicate(touch_dev, rx_callback);
read_data = (struct rt_touch_data *)rt_calloc(1, sizeof(struct rt_touch_data));
if (!read_data)
{
return -RT_ENOMEM;
}
return RT_EOK;
}
#define RST_PIN "p801"
#define INT_PIN "p004"
rt_err_t rt_hw_gt911_register(void)
{
struct rt_touch_config cfg;
rt_base_t int_pin = rt_pin_get(INT_PIN);
rt_base_t rst_pin = rt_pin_get(RST_PIN);
cfg.dev_name = "i2c1";
cfg.irq_pin.pin = int_pin;
cfg.irq_pin.mode = PIN_MODE_INPUT_PULLDOWN;
cfg.user_data = &rst_pin;
rt_hw_gt911_init("gt911", &cfg);
gt911_probe(480, 272);
return RT_EOK;
}
void lv_port_indev_init(void)
{
static lv_indev_drv_t indev_drv; /* Descriptor of a input device driver */
lv_indev_drv_init(&indev_drv); /* Basic initialization */
indev_drv.type = LV_INDEV_TYPE_POINTER; /* Touch pad is a pointer-like device */
indev_drv.read_cb = touchpad_read; /* Set your driver function */
/* Register the driver in LVGL and save the created input device object */
touch_indev = lv_indev_drv_register(&indev_drv);
/* Register touch device */
rt_err_t res = rt_hw_gt911_register();
RT_ASSERT(res == RT_EOK);
}

View File

@ -11,7 +11,7 @@ src += Glob('pwm_audio.c')
CPPPATH = [cwd]
LOCAL_CFLAGS = ''
if rtconfig.PLATFORM in ['gcc', 'armclang', 'llvm-arm']:
if rtconfig.PLATFORM in ['gcc', 'armclang']:
LOCAL_CFLAGS += ' -std=c99'
elif rtconfig.PLATFORM in ['armcc']:
LOCAL_CFLAGS += ' --c99'

View File

@ -8,7 +8,7 @@ src = Glob('*.c')
CPPPATH = [cwd]
LOCAL_CFLAGS = ''
if rtconfig.PLATFORM in ['gcc', 'armclang', 'llvm-arm']:
if rtconfig.PLATFORM in ['gcc', 'armclang']:
LOCAL_CFLAGS += ' -std=c99'
elif rtconfig.PLATFORM in ['armcc']:
LOCAL_CFLAGS += ' --c99'

View File

@ -11,15 +11,22 @@
#ifdef BSP_USING_SDCARD_FS
#include <drv_sdhi.h>
/* SD Card hot plug detection pin */
#define SD_CHECK_PIN "p405"
static rt_base_t sd_check_pin = 0;
static void _sdcard_mount(void)
{
rt_device_t device;
device = rt_device_find("sd");
rt_kprintf("rt_device_find %x \r\n", device);
if (device == NULL)
{
mmcsd_wait_cd_changed(0);
sdcard_change();
mmcsd_wait_cd_changed(RT_WAITING_FOREVER);
device = rt_device_find("sd");
}
@ -37,13 +44,63 @@ static void _sdcard_mount(void)
}
}
static void sd_mount(void)
static void _sdcard_unmount(void)
{
rt_thread_mdelay(200);
dfs_unmount("/sdcard");
LOG_I("Unmount \"/sdcard\"");
mmcsd_wait_cd_changed(0);
sdcard_change();
mmcsd_wait_cd_changed(RT_WAITING_FOREVER);
}
static void sd_auto_mount(void *parameter)
{
rt_uint8_t re_sd_check_pin = 1;
rt_thread_mdelay(20);
if (!rt_pin_read(sd_check_pin))
{
_sdcard_mount();
}
while (1)
{
rt_thread_mdelay(200);
if (re_sd_check_pin && (re_sd_check_pin = rt_pin_read(sd_check_pin)) == 0)
{
_sdcard_mount();
}
if (!re_sd_check_pin && (re_sd_check_pin = rt_pin_read(sd_check_pin)) != 0)
{
_sdcard_unmount();
}
}
}
static void sd_mount(void)
{
rt_thread_t tid;
sd_check_pin = rt_pin_get(SD_CHECK_PIN);
rt_pin_mode(sd_check_pin, PIN_MODE_INPUT_PULLUP);
tid = rt_thread_create("sd_mount", sd_auto_mount, RT_NULL,
2048, RT_THREAD_PRIORITY_MAX - 2, 20);
if (tid != RT_NULL)
{
rt_thread_startup(tid);
}
else
{
LOG_E("create sd_mount thread err!");
return;
}
}
#else
#include <spi_msd.h>
#include "drv_sci_spi.h"

View File

@ -0,0 +1,22 @@
from building import *
import os
group = []
cwd = GetCurrentDir()
src = Glob('*.c')
CPPPATH = [cwd]
LOCAL_CFLAGS = ''
if rtconfig.PLATFORM in ['gcc', 'armclang']:
LOCAL_CFLAGS += ' -std=c99'
elif rtconfig.PLATFORM in ['armcc']:
LOCAL_CFLAGS += ' --c99'
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'))
Return('group')

View File

@ -0,0 +1,52 @@
# Prerequisites
*.d
# Object files
*.o
*.ko
*.obj
*.elf
# Linker output
*.ilk
*.map
*.exp
# Precompiled Headers
*.gch
*.pch
# Libraries
*.lib
*.a
*.la
*.lo
# Shared objects (inc. Windows DLLs)
*.dll
*.so
*.so.*
*.dylib
# Executables
*.exe
*.out
*.app
*.i*86
*.x86_64
*.hex
# Debug files
*.dSYM/
*.su
*.idb
*.pdb
# Kernel Module Compile Results
*.mod*
*.cmd
.tmp_versions/
modules.order
Module.symvers
Mkfile.old
dkms.conf

View File

@ -0,0 +1,17 @@
from building import *
Import('rtconfig')
src = []
cwd = GetCurrentDir()
# add gt911 src files.
if GetDepend('BSP_USING_TOUCH'):
src += Glob('src/gt911.c')
# add gt911 include path.
path = [cwd + '/inc']
# add src and include to group.
group = DefineGroup('gt911', src, depend = ['BSP_USING_TOUCH'], CPPPATH = path)
Return('group')

View File

@ -0,0 +1,41 @@
/*
* Copyright (c) 2006-2023, RT-Thread Development Team
*
* SPDX-License-Identifier: Apache-2.0
*
* Change Logs:
* Date Author Notes
* 2021-01-13 RiceChen the first version
*/
#ifndef __GT911_H__
#define __GT911_H__
#include "rtdevice.h"
#define GT911_ADDR_LEN 2
#define GT911_REGITER_LEN 2
#define GT911_MAX_TOUCH 5
#define GT911_POINT_INFO_NUM 5
#define GT911_ADDRESS_HIGH 0x5D
#define GT911_ADDRESS_LOW 0x14
#define GT911_COMMAND_REG 0x8040
#define GT911_CONFIG_REG 0x8047
#define GT911_PRODUCT_ID 0x8140
#define GT911_VENDOR_ID 0x814A
#define GT911_READ_STATUS 0x814E
#define GT911_POINT1_REG 0x814F
#define GT911_POINT2_REG 0x8157
#define GT911_POINT3_REG 0x815F
#define GT911_POINT4_REG 0x8167
#define GT911_POINT5_REG 0x816F
#define GT911_CHECK_SUM 0x80FF
int rt_hw_gt911_init(const char *name, struct rt_touch_config *cfg);
#endif /* gt911.h */

View File

@ -0,0 +1,513 @@
/*
* Copyright (c) 2006-2023, RT-Thread Development Team
*
* SPDX-License-Identifier: Apache-2.0
*
* Change Logs:
* Date Author Notes
* 2021-01-13 RiceChen the first version
*/
#include <rtthread.h>
#include <rtdevice.h>
#include <string.h>
#define DBG_TAG "gt911"
#define DBG_LVL DBG_INFO
#include <rtdbg.h>
#include "gt911.h"
static struct rt_i2c_client gt911_client;
/* hardware section */
static rt_uint8_t GT911_CFG_TBL[] =
{
0x6b, 0x00, 0x04, 0x58, 0x02, 0x05, 0x0d, 0x00, 0x01, 0x0f,
0x28, 0x0f, 0x50, 0x32, 0x03, 0x05, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x8a, 0x2a, 0x0c,
0x45, 0x47, 0x0c, 0x08, 0x00, 0x00, 0x00, 0x40, 0x03, 0x2c,
0x00, 0x01, 0x00, 0x00, 0x00, 0x03, 0x64, 0x32, 0x00, 0x00,
0x00, 0x28, 0x64, 0x94, 0xd5, 0x02, 0x07, 0x00, 0x00, 0x04,
0x95, 0x2c, 0x00, 0x8b, 0x34, 0x00, 0x82, 0x3f, 0x00, 0x7d,
0x4c, 0x00, 0x7a, 0x5b, 0x00, 0x7a, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x18, 0x16, 0x14, 0x12, 0x10, 0x0e, 0x0c, 0x0a,
0x08, 0x06, 0x04, 0x02, 0xff, 0xff, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x16, 0x18, 0x1c, 0x1d, 0x1e, 0x1f, 0x20, 0x21,
0x22, 0x24, 0x13, 0x12, 0x10, 0x0f, 0x0a, 0x08, 0x06, 0x04,
0x02, 0x00, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x79, 0x01,
};
static rt_err_t gt911_write_reg(struct rt_i2c_client *dev, rt_uint8_t *data, rt_uint8_t len)
{
struct rt_i2c_msg msgs;
msgs.addr = dev->client_addr;
msgs.flags = RT_I2C_WR;
msgs.buf = data;
msgs.len = len;
if (rt_i2c_transfer(dev->bus, &msgs, 1) == 1)
{
return RT_EOK;
}
else
{
return -RT_ERROR;
}
}
static rt_err_t gt911_read_regs(struct rt_i2c_client *dev, rt_uint8_t *reg, rt_uint8_t *data, rt_uint8_t len)
{
struct rt_i2c_msg msgs[2];
msgs[0].addr = dev->client_addr;
msgs[0].flags = RT_I2C_WR;
msgs[0].buf = reg;
msgs[0].len = GT911_REGITER_LEN;
msgs[1].addr = dev->client_addr;
msgs[1].flags = RT_I2C_RD;
msgs[1].buf = data;
msgs[1].len = len;
if (rt_i2c_transfer(dev->bus, msgs, 2) == 2)
{
return RT_EOK;
}
else
{
return -RT_ERROR;
}
}
static rt_err_t gt911_get_product_id(struct rt_i2c_client *dev, rt_uint8_t *data, rt_uint8_t len)
{
rt_uint8_t reg[2];
reg[0] = (rt_uint8_t)(GT911_PRODUCT_ID >> 8);
reg[1] = (rt_uint8_t)(GT911_PRODUCT_ID & 0xff);
if (gt911_read_regs(dev, reg, data, len) != RT_EOK)
{
LOG_E("read id failed");
return -RT_ERROR;
}
return RT_EOK;
}
static rt_err_t gt911_get_info(struct rt_i2c_client *dev, struct rt_touch_info *info)
{
rt_uint8_t reg[2];
rt_uint8_t out_info[7];
rt_uint8_t out_len = 7;
reg[0] = (rt_uint8_t)(GT911_CONFIG_REG >> 8);
reg[1] = (rt_uint8_t)(GT911_CONFIG_REG & 0xFF);
if (gt911_read_regs(dev, reg, out_info, out_len) != RT_EOK)
{
LOG_E("read info failed");
return -RT_ERROR;
}
info->range_x = (out_info[2] << 8) | out_info[1];
info->range_y = (out_info[4] << 8) | out_info[3];
info->point_num = out_info[5] & 0x0f;
return RT_EOK;
}
static rt_err_t gt911_soft_reset(struct rt_i2c_client *dev)
{
rt_uint8_t buf[3];
buf[0] = (rt_uint8_t)(GT911_COMMAND_REG >> 8);
buf[1] = (rt_uint8_t)(GT911_COMMAND_REG & 0xFF);
buf[2] = 0x02;
if (gt911_write_reg(dev, buf, 3) != RT_EOK)
{
LOG_E("soft reset failed");
return -RT_ERROR;
}
return RT_EOK;
}
static int16_t pre_x[GT911_MAX_TOUCH] = {-1, -1, -1, -1, -1};
static int16_t pre_y[GT911_MAX_TOUCH] = {-1, -1, -1, -1, -1};
static int16_t pre_w[GT911_MAX_TOUCH] = {-1, -1, -1, -1, -1};
static rt_uint8_t s_tp_dowm[GT911_MAX_TOUCH];
static struct rt_touch_data *read_data;
static void gt911_touch_up(void *buf, int8_t id)
{
read_data = (struct rt_touch_data *)buf;
if (s_tp_dowm[id] == 1)
{
s_tp_dowm[id] = 0;
read_data[id].event = RT_TOUCH_EVENT_UP;
}
else
{
read_data[id].event = RT_TOUCH_EVENT_NONE;
}
read_data[id].timestamp = rt_touch_get_ts();
read_data[id].width = pre_w[id];
read_data[id].x_coordinate = pre_x[id];
read_data[id].y_coordinate = pre_y[id];
read_data[id].track_id = id;
pre_x[id] = -1; /* last point is none */
pre_y[id] = -1;
pre_w[id] = -1;
}
static void gt911_touch_down(void *buf, int8_t id, int16_t x, int16_t y, int16_t w)
{
read_data = (struct rt_touch_data *)buf;
if (s_tp_dowm[id] == 1)
{
read_data[id].event = RT_TOUCH_EVENT_MOVE;
}
else
{
read_data[id].event = RT_TOUCH_EVENT_DOWN;
s_tp_dowm[id] = 1;
}
read_data[id].timestamp = rt_touch_get_ts();
read_data[id].width = w;
read_data[id].x_coordinate = x;
read_data[id].y_coordinate = y;
read_data[id].track_id = id;
pre_x[id] = x; /* save last point */
pre_y[id] = y;
pre_w[id] = w;
}
static rt_size_t gt911_read_point(struct rt_touch_device *touch, void *buf, rt_size_t read_num)
{
rt_uint8_t point_status = 0;
rt_uint8_t touch_num = 0;
rt_uint8_t write_buf[3];
rt_uint8_t cmd[2];
rt_uint8_t read_buf[8 * GT911_MAX_TOUCH] = {0};
rt_uint8_t read_index;
int8_t read_id = 0;
int16_t input_x = 0;
int16_t input_y = 0;
int16_t input_w = 0;
static rt_uint8_t pre_touch = 0;
static int8_t pre_id[GT911_MAX_TOUCH] = {0};
/* point status register */
cmd[0] = (rt_uint8_t)((GT911_READ_STATUS >> 8) & 0xFF);
cmd[1] = (rt_uint8_t)(GT911_READ_STATUS & 0xFF);
if (gt911_read_regs(&gt911_client, cmd, &point_status, 1) != RT_EOK)
{
LOG_D("read point failed\n");
read_num = 0;
goto exit_;
}
if (point_status == 0) /* no data */
{
read_num = 0;
goto exit_;
}
if ((point_status & 0x80) == 0) /* data is not ready */
{
read_num = 0;
goto exit_;
}
touch_num = point_status & 0x0f; /* get point num */
if (touch_num > GT911_MAX_TOUCH) /* point num is not correct */
{
read_num = 0;
goto exit_;
}
cmd[0] = (rt_uint8_t)((GT911_POINT1_REG >> 8) & 0xFF);
cmd[1] = (rt_uint8_t)(GT911_POINT1_REG & 0xFF);
/* read point num is touch_num */
if (gt911_read_regs(&gt911_client, cmd, read_buf, read_num * GT911_POINT_INFO_NUM) != RT_EOK)
{
LOG_D("read point failed\n");
read_num = 0;
goto exit_;
}
if (pre_touch > touch_num) /* point up */
{
for (read_index = 0; read_index < pre_touch; read_index++)
{
rt_uint8_t j;
for (j = 0; j < touch_num; j++) /* this time touch num */
{
read_id = read_buf[j * 8] & 0x0F;
if (read_id > 0) continue;
if (pre_id[read_index] == read_id) /* this id is not free */
break;
if (j >= touch_num - 1)
{
rt_uint8_t up_id;
up_id = pre_id[read_index];
gt911_touch_up(buf, up_id);
}
}
}
}
if (touch_num) /* point down */
{
rt_uint8_t off_set;
for (read_index = 0; read_index < touch_num; read_index++)
{
off_set = read_index * 8;
read_id = read_buf[off_set] & 0x0f;
if (read_id > 0) continue;
pre_id[read_index] = read_id;
input_x = read_buf[off_set + 1] | (read_buf[off_set + 2] << 8); /* x */
input_y = read_buf[off_set + 3] | (read_buf[off_set + 4] << 8); /* y */
input_w = read_buf[off_set + 5] | (read_buf[off_set + 6] << 8); /* size */
gt911_touch_down(buf, read_id, input_x, input_y, input_w);
}
}
else if (pre_touch)
{
for (read_index = 0; read_index < pre_touch; read_index++)
{
gt911_touch_up(buf, pre_id[read_index]);
}
}
pre_touch = touch_num;
exit_:
write_buf[0] = (rt_uint8_t)((GT911_READ_STATUS >> 8) & 0xFF);
write_buf[1] = (rt_uint8_t)(GT911_READ_STATUS & 0xFF);
write_buf[2] = 0x00;
gt911_write_reg(&gt911_client, write_buf, 3);
return read_num;
}
static rt_err_t gt911_control(struct rt_touch_device *touch, int cmd, void *arg)
{
if (cmd == RT_TOUCH_CTRL_GET_ID)
{
return gt911_get_product_id(&gt911_client, arg, 6);
}
if (cmd == RT_TOUCH_CTRL_GET_INFO)
{
return gt911_get_info(&gt911_client, arg);
}
rt_uint8_t buf[4];
rt_uint8_t i = 0;
rt_uint8_t *config;
config = (rt_uint8_t *)rt_calloc(1, sizeof(GT911_CFG_TBL) + GT911_REGITER_LEN);
if (config == RT_NULL)
{
LOG_D("malloc config memory failed\n");
return -RT_ERROR;
}
config[0] = (rt_uint8_t)((GT911_CONFIG_REG >> 8) & 0xFF);
config[1] = (rt_uint8_t)(GT911_CONFIG_REG & 0xFF);
memcpy(&config[2], GT911_CFG_TBL, sizeof(GT911_CFG_TBL));
switch (cmd)
{
case RT_TOUCH_CTRL_SET_X_RANGE:
{
rt_uint16_t x_range;
x_range = *(rt_uint16_t *)arg;
config[4] = (rt_uint8_t)(x_range >> 8);
config[3] = (rt_uint8_t)(x_range & 0xff);
GT911_CFG_TBL[2] = config[4];
GT911_CFG_TBL[1] = config[3];
break;
}
case RT_TOUCH_CTRL_SET_Y_RANGE:
{
rt_uint16_t y_range;
y_range = *(rt_uint16_t *)arg;
config[6] = (rt_uint8_t)(y_range >> 8);
config[5] = (rt_uint8_t)(y_range & 0xff);
GT911_CFG_TBL[4] = config[6];
GT911_CFG_TBL[3] = config[5];
break;
}
case RT_TOUCH_CTRL_SET_X_TO_Y:
{
config[8] = config[8] ^= (1 << 3);
break;
}
case RT_TOUCH_CTRL_SET_MODE:
{
rt_uint16_t trig_type;
trig_type = *(rt_uint16_t *)arg;
switch (trig_type)
{
case RT_DEVICE_FLAG_INT_RX:
config[8] &= 0xFC;
break;
case RT_DEVICE_FLAG_RDONLY:
config[8] &= 0xFC;
config[8] |= 0x02;
break;
default:
break;
}
break;
}
default:
{
break;
}
}
if (gt911_write_reg(&gt911_client, config, sizeof(GT911_CFG_TBL) + GT911_ADDR_LEN) != RT_EOK)
{
LOG_D("send config failed");
return -1;
}
buf[0] = (rt_uint8_t)((GT911_CHECK_SUM >> 8) & 0xFF);
buf[1] = (rt_uint8_t)(GT911_CHECK_SUM & 0xFF);
buf[2] = 0;
for (i = GT911_ADDR_LEN; i < sizeof(GT911_CFG_TBL) + GT911_ADDR_LEN; i++)
{
buf[GT911_ADDR_LEN] += config[i];
}
buf[2] = (~buf[2]) + 1;
buf[3] = 1;
gt911_write_reg(&gt911_client, buf, 4);
rt_free(config);
return RT_EOK;
}
static struct rt_touch_ops gt911_touch_ops =
{
.touch_readpoint = gt911_read_point,
.touch_control = gt911_control,
};
int gt911_i2c_probe(struct rt_i2c_bus_device *i2c_bus, char addr)
{
unsigned char cmd[1];
cmd[0] = 0;
struct rt_i2c_msg msgs;
msgs.addr = addr;
msgs.flags = RT_I2C_WR;
msgs.buf = cmd;
msgs.len = 0;
return rt_i2c_transfer(i2c_bus, &msgs, 1);
}
int rt_hw_gt911_init(const char *name, struct rt_touch_config *cfg)
{
struct rt_touch_device *touch_device = RT_NULL;
touch_device = (struct rt_touch_device *)rt_malloc(sizeof(struct rt_touch_device));
if (touch_device == RT_NULL)
{
LOG_E("touch device malloc fail");
return -RT_ERROR;
}
rt_memset((void *)touch_device, 0, sizeof(struct rt_touch_device));
/* hw init*/
rt_pin_mode(*(rt_uint8_t *)cfg->user_data, PIN_MODE_OUTPUT);
rt_pin_mode(cfg->irq_pin.pin, PIN_MODE_OUTPUT);
rt_pin_write(*(rt_uint8_t *)cfg->user_data, PIN_LOW);
rt_thread_delay(200);
rt_pin_write(*(rt_uint8_t *)cfg->user_data, PIN_HIGH);
rt_thread_delay(10);
rt_pin_write(cfg->irq_pin.pin, PIN_MODE_INPUT);
rt_thread_delay(100);
gt911_client.bus = (struct rt_i2c_bus_device *)rt_device_find(cfg->dev_name);
if (gt911_client.bus == RT_NULL)
{
LOG_E("Can't find %s device", cfg->dev_name);
return -RT_ERROR;
}
if (rt_device_open((rt_device_t)gt911_client.bus, RT_DEVICE_FLAG_RDWR) != RT_EOK)
{
LOG_E("open %s device failed", cfg->dev_name);
return -RT_ERROR;
}
int res;
res = gt911_i2c_probe(gt911_client.bus, GT911_ADDRESS_LOW);
if (res == 1)
{
LOG_I("GT911 ADDRESS SET LOW");
gt911_client.client_addr = GT911_ADDRESS_LOW;
LOG_I("gt911 id:%x", GT911_ADDRESS_LOW);
}
else
{
LOG_I("GT911 ADDRESS SET HIGH");
gt911_client.client_addr = GT911_ADDRESS_HIGH;
LOG_I("gt911 id:%x", GT911_ADDRESS_HIGH);
}
// gt911_soft_reset(&gt911_client);
/* register touch device */
touch_device->info.type = RT_TOUCH_TYPE_CAPACITANCE;
touch_device->info.vendor = RT_TOUCH_VENDOR_GT;
rt_memcpy(&touch_device->config, cfg, sizeof(struct rt_touch_config));
touch_device->ops = &gt911_touch_ops;
rt_hw_touch_register(touch_device, name, RT_DEVICE_FLAG_INT_RX, RT_NULL);
LOG_I("touch device gt911 init success");
return RT_EOK;
}

View File

@ -12,7 +12,7 @@ if GetDepend(['BSP_USING_RW007']):
CPPPATH = [cwd]
LOCAL_CFLAGS = ''
if rtconfig.PLATFORM in ['gcc', 'armclang', 'llvm-arm']:
if rtconfig.PLATFORM in ['gcc', 'armclang']:
LOCAL_CFLAGS += ' -std=c99'
elif rtconfig.PLATFORM in ['armcc']:
LOCAL_CFLAGS += ' --c99'

View File

@ -0,0 +1,42 @@
#include <rtthread.h>
#include "hal_data.h"
rt_weak void can0_callback(can_callback_args_t *p_args)
{
}
rt_weak void sci_spi3_callback(spi_callback_args_t *p_args)
{
}
rt_weak void sci_spi4_callback(spi_callback_args_t *p_args)
{
}
rt_weak void sci_spi6_callback(spi_callback_args_t *p_args)
{
}
rt_weak void sci_spi7_callback(spi_callback_args_t *p_args)
{
}
rt_weak void cb_timer2(timer_callback_args_t *p_args)
{
}
rt_weak void user_ether0_callback(ether_callback_args_t *p_args)
{
}
rt_weak void i2s_callback(i2s_callback_args_t *p_args)
{
}
rt_weak void decode_callback(jpeg_callback_args_t *p_args)
{
}
rt_weak void _ra_port_display_callback(display_callback_args_t *p_args)
{
}

View File

@ -16883,7 +16883,7 @@ typedef struct /*!< (@ 0x40083000) R_I3C0 Structure
__IOM uint32_t PNDINT : 4; /*!< [3..0] Pending Interrupt */
uint32_t : 1;
__IOM uint32_t PRTE : 1; /*!< [5..5] Protocol Error */
__IOM uint32_t ACTMD : 2; /*!< [7..6] Slave Devices current Activity Mode */
__IOM uint32_t ACTMD : 2; /*!< [7..6] Slave Device’s current Activity Mode */
__IOM uint32_t VDRSV : 8; /*!< [15..8] Vendor Reserved */
uint32_t : 16;
} CGDVST_b;