Merge remote-tracking branch 'upstream/master'
This commit is contained in:
commit
26119affdf
|
@ -76,6 +76,7 @@ CONFIG_FINSH_USING_HISTORY=y
|
|||
CONFIG_FINSH_HISTORY_LINES=5
|
||||
CONFIG_FINSH_USING_SYMTAB=y
|
||||
CONFIG_FINSH_USING_DESCRIPTION=y
|
||||
# CONFIG_FINSH_ECHO_DISABLE_DEFAULT is not set
|
||||
CONFIG_FINSH_THREAD_PRIORITY=20
|
||||
CONFIG_FINSH_THREAD_STACK_SIZE=4096
|
||||
CONFIG_FINSH_CMD_SIZE=80
|
||||
|
@ -297,6 +298,7 @@ CONFIG_LWIP_NETIF_LOOPBACK=0
|
|||
# tools packages
|
||||
#
|
||||
# CONFIG_PKG_USING_CMBACKTRACE is not set
|
||||
# CONFIG_PKG_USING_EASYFLASH is not set
|
||||
# CONFIG_PKG_USING_EASYLOGGER is not set
|
||||
# CONFIG_PKG_USING_SYSTEMVIEW is not set
|
||||
# CONFIG_PKG_USING_IPERF is not set
|
||||
|
@ -307,12 +309,30 @@ CONFIG_LWIP_NETIF_LOOPBACK=0
|
|||
# CONFIG_PKG_USING_FASTLZ is not set
|
||||
# CONFIG_PKG_USING_MINILZO is not set
|
||||
# CONFIG_PKG_USING_QUICKLZ is not set
|
||||
# CONFIG_PKG_USING_MULTIBUTTON is not set
|
||||
|
||||
#
|
||||
# example package: hello
|
||||
#
|
||||
# CONFIG_PKG_USING_HELLO is not set
|
||||
# CONFIG_PKG_USING_MULTIBUTTON is not set
|
||||
CONFIG_SOC_IMXRT1052=y
|
||||
CONFIG_BOARD_RT1050_EVK=y
|
||||
# CONFIG_BOARD_RT1050_FIRE is not set
|
||||
|
||||
#
|
||||
# RT1050_EVK Bsp Config
|
||||
#
|
||||
|
||||
#
|
||||
# Select uart device
|
||||
#
|
||||
CONFIG_RT_USING_UART1=y
|
||||
CONFIG_RT_USING_HP_RTC=y
|
||||
# CONFIG_RT_USING_UART2 is not set
|
||||
# CONFIG_RT_USING_UART3 is not set
|
||||
# CONFIG_RT_USING_UART4 is not set
|
||||
# CONFIG_RT_USING_UART5 is not set
|
||||
# CONFIG_RT_USING_UART6 is not set
|
||||
# CONFIG_RT_USING_UART7 is not set
|
||||
# CONFIG_RT_USING_UART8 is not set
|
||||
CONFIG_RT_USING_SDRAM=y
|
||||
CONFIG_RT_USING_RTC_HP=y
|
||||
|
|
|
@ -23,17 +23,66 @@ config SOC_IMXRT1052
|
|||
select ARCH_ARM_CORTEX_M7
|
||||
default y
|
||||
|
||||
if RT_USING_SERIAL
|
||||
config RT_USING_UART1
|
||||
bool "Using RT_USING_UART1"
|
||||
default y
|
||||
endif
|
||||
# RT1050 board select!
|
||||
choice
|
||||
prompt "RT1050 Board select"
|
||||
default BOARD_RT1050_EVK
|
||||
config BOARD_RT1050_EVK
|
||||
bool "RT1050_EVK"
|
||||
config BOARD_RT1050_FIRE
|
||||
bool "RT1050_FIRE"
|
||||
endchoice
|
||||
|
||||
if RT_USING_RTC
|
||||
config RT_USING_HP_RTC
|
||||
bool "Using RT_USING_HP_RTC"
|
||||
default n
|
||||
endif
|
||||
if BOARD_RT1050_EVK
|
||||
menu "RT1050_EVK Bsp Config"
|
||||
|
||||
menu "Select uart device"
|
||||
config RT_USING_UART1
|
||||
bool "Using uart1"
|
||||
select RT_USING_SERIAL
|
||||
default y
|
||||
config RT_USING_UART2
|
||||
bool "Using uart2"
|
||||
select RT_USING_SERIAL
|
||||
default n
|
||||
config RT_USING_UART3
|
||||
bool "Using uart3"
|
||||
select RT_USING_SERIAL
|
||||
default n
|
||||
config RT_USING_UART4
|
||||
bool "Using uart4"
|
||||
select RT_USING_SERIAL
|
||||
default n
|
||||
config RT_USING_UART5
|
||||
bool "Using uart5"
|
||||
select RT_USING_SERIAL
|
||||
default n
|
||||
config RT_USING_UART6
|
||||
bool "Using uart6"
|
||||
select RT_USING_SERIAL
|
||||
default n
|
||||
config RT_USING_UART7
|
||||
bool "Using uart7"
|
||||
select RT_USING_SERIAL
|
||||
default n
|
||||
config RT_USING_UART8
|
||||
bool "Using uart8"
|
||||
select RT_USING_SERIAL
|
||||
default n
|
||||
endmenu
|
||||
|
||||
#menu "SDRAM drive support"
|
||||
config RT_USING_SDRAM
|
||||
bool "Using sdram"
|
||||
default y
|
||||
#endmenu
|
||||
|
||||
#menu "RTC drive support"
|
||||
config RT_USING_RTC_HP
|
||||
bool "Using hp rtc"
|
||||
select RT_USING_RTC
|
||||
default n
|
||||
#endmenu
|
||||
|
||||
if RT_USING_USB_DEVICE
|
||||
choice
|
||||
|
@ -47,4 +96,59 @@ if RT_USING_USB_DEVICE
|
|||
endchoice
|
||||
endif
|
||||
|
||||
endmenu
|
||||
endif
|
||||
|
||||
if BOARD_RT1050_FIRE
|
||||
menu "RT1050_FIRE Bsp Config"
|
||||
|
||||
menu "Select uart device"
|
||||
config RT_USING_UART1
|
||||
bool "Using uart1"
|
||||
select RT_USING_SERIAL
|
||||
default y
|
||||
config RT_USING_UART2
|
||||
bool "Using uart2"
|
||||
select RT_USING_SERIAL
|
||||
default n
|
||||
config RT_USING_UART3
|
||||
bool "Using uart3"
|
||||
select RT_USING_SERIAL
|
||||
default n
|
||||
config RT_USING_UART4
|
||||
bool "Using uart4"
|
||||
select RT_USING_SERIAL
|
||||
default n
|
||||
config RT_USING_UART5
|
||||
bool "Using uart5"
|
||||
select RT_USING_SERIAL
|
||||
default n
|
||||
config RT_USING_UART6
|
||||
bool "Using uart6"
|
||||
select RT_USING_SERIAL
|
||||
default n
|
||||
config RT_USING_UART7
|
||||
bool "Using uart7"
|
||||
select RT_USING_SERIAL
|
||||
default n
|
||||
config RT_USING_UART8
|
||||
bool "Using uart8"
|
||||
select RT_USING_SERIAL
|
||||
default n
|
||||
endmenu
|
||||
|
||||
#menu "SDRAM drive support"
|
||||
config RT_USING_SDRAM
|
||||
bool "Using sdram"
|
||||
default y
|
||||
#endmenu
|
||||
|
||||
#menu "RTC drive support"
|
||||
config RT_USING_RTC_HP
|
||||
bool "Using hp rtc"
|
||||
select RT_USING_RTC
|
||||
default n
|
||||
#endmenu
|
||||
|
||||
endmenu
|
||||
endif
|
||||
|
|
|
@ -38,29 +38,29 @@
|
|||
|
||||
void dump_clock(void)
|
||||
{
|
||||
rt_kprintf("CPU clock: %d\n", CLOCK_GetFreq(kCLOCK_CpuClk));
|
||||
rt_kprintf("AHB clock : %d\n", CLOCK_GetFreq(kCLOCK_AhbClk));
|
||||
rt_kprintf("SEMC clock : %d\n", CLOCK_GetFreq(kCLOCK_SemcClk));
|
||||
rt_kprintf("IPG clock : %d\n", CLOCK_GetFreq(kCLOCK_IpgClk));
|
||||
rt_kprintf("OSC clock selected : %d\n", CLOCK_GetFreq(kCLOCK_OscClk));
|
||||
rt_kprintf("RTC clock: %d\n", CLOCK_GetFreq(kCLOCK_RtcClk));
|
||||
rt_kprintf("ARMPLLCLK : %d\n", CLOCK_GetFreq(kCLOCK_ArmPllClk));
|
||||
rt_kprintf("USB1PLLCLK : %d\n", CLOCK_GetFreq(kCLOCK_Usb1PllClk));
|
||||
rt_kprintf("USB1PLLPDF0CLK : %d\n", CLOCK_GetFreq(kCLOCK_Usb1PllPfd0Clk));
|
||||
rt_kprintf("USB1PLLPFD1CLK : %d\n", CLOCK_GetFreq(kCLOCK_Usb1PllPfd1Clk));
|
||||
rt_kprintf("USB1PLLPFD2CLK : %d\n", CLOCK_GetFreq(kCLOCK_Usb1PllPfd2Clk));
|
||||
rt_kprintf("USB1PLLPFD3CLK : %d\n", CLOCK_GetFreq(kCLOCK_Usb1PllPfd3Clk));
|
||||
rt_kprintf("USB2PLLCLK : %d\n", CLOCK_GetFreq(kCLOCK_Usb2PllClk));
|
||||
rt_kprintf("SYSPLLCLK : %d\n", CLOCK_GetFreq(kCLOCK_SysPllClk));
|
||||
rt_kprintf("SYSPLLPDF0CLK : %d\n", CLOCK_GetFreq(kCLOCK_SysPllPfd0Clk));
|
||||
rt_kprintf("SYSPLLPFD1CLK : %d\n", CLOCK_GetFreq(kCLOCK_SysPllPfd1Clk));
|
||||
rt_kprintf("SYSPLLPFD2CLK : %d\n", CLOCK_GetFreq(kCLOCK_SysPllPfd2Clk));
|
||||
rt_kprintf("SYSPLLPFD3CLK : %d\n", CLOCK_GetFreq(kCLOCK_SysPllPfd3Clk));
|
||||
rt_kprintf("Enet PLLCLK ref_enetpll0 : %d\n", CLOCK_GetFreq(kCLOCK_EnetPll0Clk));
|
||||
rt_kprintf("Enet PLLCLK ref_enetpll1 : %d\n", CLOCK_GetFreq(kCLOCK_EnetPll1Clk));
|
||||
rt_kprintf("Enet PLLCLK ref_enetpll2 : %d\n", CLOCK_GetFreq(kCLOCK_EnetPll2Clk));
|
||||
rt_kprintf("Audio PLLCLK : %d\n", CLOCK_GetFreq(kCLOCK_AudioPllClk));
|
||||
rt_kprintf("Video PLLCLK : %d\n", CLOCK_GetFreq(kCLOCK_VideoPllClk));
|
||||
rt_kprintf("OSC clock : %d\n", CLOCK_GetFreq(kCLOCK_OscClk));
|
||||
rt_kprintf("RTC clock : %d\n", CLOCK_GetFreq(kCLOCK_RtcClk));
|
||||
rt_kprintf("CPU clock: %d\n", CLOCK_GetFreq(kCLOCK_CpuClk));
|
||||
rt_kprintf("AHB clock : %d\n", CLOCK_GetFreq(kCLOCK_AhbClk));
|
||||
rt_kprintf("SEMC clock : %d\n", CLOCK_GetFreq(kCLOCK_SemcClk));
|
||||
rt_kprintf("IPG clock : %d\n", CLOCK_GetFreq(kCLOCK_IpgClk));
|
||||
rt_kprintf("ARMPLLCLK(PLL1) : %d\n", CLOCK_GetFreq(kCLOCK_ArmPllClk));
|
||||
rt_kprintf("SYSPLLCLK(PLL2/528_PLL) : %d\n", CLOCK_GetFreq(kCLOCK_SysPllClk));
|
||||
rt_kprintf("SYSPLLPDF0CLK : %d\n", CLOCK_GetFreq(kCLOCK_SysPllPfd0Clk));
|
||||
rt_kprintf("SYSPLLPFD1CLK : %d\n", CLOCK_GetFreq(kCLOCK_SysPllPfd1Clk));
|
||||
rt_kprintf("SYSPLLPFD2CLK : %d\n", CLOCK_GetFreq(kCLOCK_SysPllPfd2Clk));
|
||||
rt_kprintf("SYSPLLPFD3CLK : %d\n", CLOCK_GetFreq(kCLOCK_SysPllPfd3Clk));
|
||||
rt_kprintf("USB1PLLCLK(PLL3) : %d\n", CLOCK_GetFreq(kCLOCK_Usb1PllClk));
|
||||
rt_kprintf("USB1PLLPDF0CLK : %d\n", CLOCK_GetFreq(kCLOCK_Usb1PllPfd0Clk));
|
||||
rt_kprintf("USB1PLLPFD1CLK : %d\n", CLOCK_GetFreq(kCLOCK_Usb1PllPfd1Clk));
|
||||
rt_kprintf("USB1PLLPFD2CLK : %d\n", CLOCK_GetFreq(kCLOCK_Usb1PllPfd2Clk));
|
||||
rt_kprintf("USB1PLLPFD3CLK : %d\n", CLOCK_GetFreq(kCLOCK_Usb1PllPfd3Clk));
|
||||
rt_kprintf("Audio PLLCLK(PLL4) : %d\n", CLOCK_GetFreq(kCLOCK_AudioPllClk));
|
||||
rt_kprintf("Video PLLCLK(PLL5) : %d\n", CLOCK_GetFreq(kCLOCK_VideoPllClk));
|
||||
rt_kprintf("Enet PLLCLK ref_enetpll0 : %d\n", CLOCK_GetFreq(kCLOCK_EnetPll0Clk));
|
||||
rt_kprintf("Enet PLLCLK ref_enetpll1 : %d\n", CLOCK_GetFreq(kCLOCK_EnetPll1Clk));
|
||||
rt_kprintf("Enet PLLCLK ref_enetpll2 : %d\n", CLOCK_GetFreq(kCLOCK_EnetPll2Clk));
|
||||
rt_kprintf("USB2PLLCLK(PLL7) : %d\n", CLOCK_GetFreq(kCLOCK_Usb2PllClk));
|
||||
}
|
||||
|
||||
void dump_cc_info(void)
|
||||
|
|
|
@ -8,35 +8,42 @@ cwd = os.path.join(str(Dir('#')), 'drivers')
|
|||
src = Split("""
|
||||
board.c
|
||||
drv_uart.c
|
||||
hyper_flash_boot.c
|
||||
drv_sdram.c
|
||||
""")
|
||||
|
||||
CPPPATH = [cwd]
|
||||
CPPDEFINES = []
|
||||
|
||||
# add sdram driver code
|
||||
if GetDepend('RT_USING_SDRAM'):
|
||||
src = src + ['./drv_sdram.c']
|
||||
|
||||
if GetDepend('RT_USING_PIN'):
|
||||
src += ['drv_pin.c']
|
||||
|
||||
if GetDepend('RT_USING_HP_RTC'):
|
||||
src += ['drv_hp_rtc.c']
|
||||
# add rtc driver code
|
||||
if GetDepend('RT_USING_RTC_HP'):
|
||||
src = src + ['./drv_rtc.c']
|
||||
|
||||
if GetDepend('RT_USING_LWIP'):
|
||||
src += ['drv_eth.c', 'fsl_phy.c']
|
||||
CPPDEFINES += ['FSL_FEATURE_PHYKSZ8081_USE_RMII50M_MODE']
|
||||
|
||||
if GetDepend('RT_USING_SDIO'):
|
||||
src += ['drv_sdio.c']
|
||||
if GetDepend('RT_USING_USB_DEVICE'):
|
||||
src += Glob('usb/phy/*.c')
|
||||
CPPDEFINES += ['ENDIANNESS']
|
||||
|
||||
if GetDepend('RT_USING_USB_DEVICE'):
|
||||
src += ['drv_usbd.c']
|
||||
src += Glob('usb/device/*.c')
|
||||
|
||||
if GetDepend('RT_USING_RTGUI') or GetDepend('PKG_USING_GUIENGINE'):
|
||||
src += ['drv_lcd.c', 'drv_ft5406.c', 'drv_i2c.c']
|
||||
if GetDepend('BOARD_RT1050_EVK'):
|
||||
src += ['hyper_flash_boot.c']
|
||||
|
||||
if GetDepend('RT_USING_LWIP'):
|
||||
src += ['drv_eth.c', 'fsl_phy.c']
|
||||
CPPDEFINES += ['FSL_FEATURE_PHYKSZ8081_USE_RMII50M_MODE']
|
||||
|
||||
if GetDepend('RT_USING_SDIO'):
|
||||
src += ['drv_sdio.c']
|
||||
|
||||
if GetDepend('RT_USING_USB_DEVICE'):
|
||||
src += Glob('usb/phy/*.c')
|
||||
CPPDEFINES += ['ENDIANNESS']
|
||||
|
||||
if GetDepend('RT_USING_USB_DEVICE'):
|
||||
src += ['drv_usbd.c']
|
||||
src += Glob('usb/device/*.c')
|
||||
|
||||
if GetDepend('RT_USING_RTGUI') or GetDepend('PKG_USING_GUIENGINE'):
|
||||
src += ['drv_lcd.c', 'drv_ft5406.c', 'drv_i2c.c']
|
||||
|
||||
group = DefineGroup('Drivers', src, depend = [''], CPPPATH = CPPPATH, CPPDEFINES=CPPDEFINES)
|
||||
|
||||
|
|
|
@ -18,7 +18,9 @@
|
|||
#include "board.h"
|
||||
#include "drv_uart.h"
|
||||
|
||||
#if defined(RT_USING_SDRAM) && defined(RT_USING_MEMHEAP_AS_HEAP)
|
||||
static struct rt_memheap system_heap;
|
||||
#endif
|
||||
|
||||
/* ARM PLL configuration for RUN mode */
|
||||
const clock_arm_pll_config_t armPllConfig = { .loopDivider = 100U };
|
||||
|
@ -162,12 +164,14 @@ void rt_lowlevel_init(void)
|
|||
{
|
||||
BOARD_ConfigMPU();
|
||||
|
||||
#if defined(RT_USING_SDRAM)
|
||||
extern int imxrt_sdram_init(void);
|
||||
imxrt_sdram_init();
|
||||
#endif
|
||||
}
|
||||
|
||||
/**
|
||||
* This function will initial LPC8XX board.
|
||||
* This function will initial rt1050 board.
|
||||
*/
|
||||
void rt_hw_board_init()
|
||||
{
|
||||
|
@ -184,11 +188,18 @@ void rt_hw_board_init()
|
|||
#endif
|
||||
|
||||
#ifdef RT_USING_HEAP
|
||||
rt_kprintf("sdram heap, begin: 0x%p, end: 0x%p\n", SDRAM_BEGIN, SDRAM_END);
|
||||
rt_system_heap_init((void*)SDRAM_BEGIN, (void*)SDRAM_END);
|
||||
|
||||
rt_kprintf("sram heap, begin: 0x%p, end: 0x%p\n", HEAP_BEGIN, HEAP_END);
|
||||
rt_memheap_init(&system_heap, "sram", (void *)HEAP_BEGIN, HEAP_SIZE);
|
||||
#if defined(RT_USING_SDRAM) && defined(RT_USING_MEMHEAP_AS_HEAP)
|
||||
rt_kprintf("sdram heap, begin: 0x%p, end: 0x%p\n", SDRAM_BEGIN, SDRAM_END);
|
||||
rt_system_heap_init((void *)SDRAM_BEGIN, (void*)SDRAM_END);
|
||||
|
||||
rt_kprintf("sram heap, begin: 0x%p, end: 0x%p\n", HEAP_BEGIN, HEAP_END);
|
||||
rt_memheap_init(&system_heap, "sram", (void *)HEAP_BEGIN, HEAP_SIZE);
|
||||
#else
|
||||
rt_kprintf("sram heap, begin: 0x%p, end: 0x%p\n", HEAP_BEGIN, HEAP_END);
|
||||
rt_system_heap_init((void *)HEAP_BEGIN, (void*)HEAP_END);
|
||||
#endif
|
||||
|
||||
#endif
|
||||
}
|
||||
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* File : drv_hp_rtc.c
|
||||
* File : drv_rtc.c
|
||||
* This file is part of RT-Thread RTOS
|
||||
* COPYRIGHT (C) 2006-2013, RT-Thread Development Team
|
||||
*
|
||||
|
@ -11,11 +11,12 @@
|
|||
* Date Author Notes
|
||||
* 2018-03-15 Liuguang the first version.
|
||||
*/
|
||||
#include "drv_hp_rtc.h"
|
||||
#include <time.h>
|
||||
#include "drv_rtc.h"
|
||||
|
||||
#include "fsl_common.h"
|
||||
#include "fsl_snvs_hp.h"
|
||||
#include "fsl_snvs_lp.h"
|
||||
#include <time.h>
|
||||
|
||||
#ifdef RT_USING_RTC
|
||||
|
||||
|
@ -35,7 +36,7 @@ static time_t get_timestamp(void)
|
|||
tm_new.tm_hour = rtcDate.hour;
|
||||
|
||||
tm_new.tm_mday = rtcDate.day;
|
||||
tm_new.tm_mon = rtcDate.month - 1;
|
||||
tm_new.tm_mon = rtcDate.month - 1;
|
||||
tm_new.tm_year = rtcDate.year - 1900;
|
||||
|
||||
return mktime(&tm_new);
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* File : drv_hp_rtc.h
|
||||
* File : drv_rtc.h
|
||||
* This file is part of RT-Thread RTOS
|
||||
* COPYRIGHT (C) 2006-2013, RT-Thread Development Team
|
||||
*
|
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
|
@ -8,9 +8,7 @@
|
|||
|
||||
#define RT_NAME_MAX 8
|
||||
#define RT_ALIGN_SIZE 4
|
||||
/* RT_THREAD_PRIORITY_8 is not set */
|
||||
#define RT_THREAD_PRIORITY_32
|
||||
/* RT_THREAD_PRIORITY_256 is not set */
|
||||
#define RT_THREAD_PRIORITY_MAX 32
|
||||
#define RT_TICK_PER_SECOND 100
|
||||
#define RT_DEBUG
|
||||
|
@ -19,7 +17,6 @@
|
|||
#define RT_DEBUG_THREAD 0
|
||||
#define RT_USING_HOOK
|
||||
#define IDLE_THREAD_STACK_SIZE 256
|
||||
/* RT_USING_TIMER_SOFT is not set */
|
||||
|
||||
/* Inter-Thread communication */
|
||||
|
||||
|
@ -28,26 +25,19 @@
|
|||
#define RT_USING_EVENT
|
||||
#define RT_USING_MAILBOX
|
||||
#define RT_USING_MESSAGEQUEUE
|
||||
/* RT_USING_SIGNALS is not set */
|
||||
|
||||
/* Memory Management */
|
||||
|
||||
/* RT_USING_MEMPOOL is not set */
|
||||
#define RT_USING_MEMHEAP
|
||||
/* RT_USING_NOHEAP is not set */
|
||||
/* RT_USING_SMALL_MEM is not set */
|
||||
/* RT_USING_SLAB is not set */
|
||||
#define RT_USING_MEMHEAP_AS_HEAP
|
||||
#define RT_USING_HEAP
|
||||
|
||||
/* Kernel Device Object */
|
||||
|
||||
#define RT_USING_DEVICE
|
||||
/* RT_USING_INTERRUPT_INFO is not set */
|
||||
#define RT_USING_CONSOLE
|
||||
#define RT_CONSOLEBUF_SIZE 128
|
||||
#define RT_CONSOLE_DEVICE_NAME "uart1"
|
||||
/* RT_USING_MODULE is not set */
|
||||
#define ARCH_ARM
|
||||
#define ARCH_ARM_CORTEX_M
|
||||
#define ARCH_ARM_CORTEX_M7
|
||||
|
@ -60,7 +50,6 @@
|
|||
|
||||
/* C++ features */
|
||||
|
||||
/* RT_USING_CPLUSPLUS is not set */
|
||||
|
||||
/* Command shell */
|
||||
|
||||
|
@ -73,10 +62,8 @@
|
|||
#define FINSH_THREAD_PRIORITY 20
|
||||
#define FINSH_THREAD_STACK_SIZE 4096
|
||||
#define FINSH_CMD_SIZE 80
|
||||
/* FINSH_USING_AUTH is not set */
|
||||
#define FINSH_USING_MSH
|
||||
#define FINSH_USING_MSH_DEFAULT
|
||||
/* FINSH_USING_MSH_ONLY is not set */
|
||||
|
||||
/* Device virtual file system */
|
||||
|
||||
|
@ -91,67 +78,38 @@
|
|||
|
||||
#define RT_DFS_ELM_CODE_PAGE 437
|
||||
#define RT_DFS_ELM_WORD_ACCESS
|
||||
/* RT_DFS_ELM_USE_LFN_0 is not set */
|
||||
/* RT_DFS_ELM_USE_LFN_1 is not set */
|
||||
/* RT_DFS_ELM_USE_LFN_2 is not set */
|
||||
#define RT_DFS_ELM_USE_LFN_3
|
||||
#define RT_DFS_ELM_USE_LFN 3
|
||||
#define RT_DFS_ELM_MAX_LFN 255
|
||||
#define RT_DFS_ELM_DRIVES 2
|
||||
#define RT_DFS_ELM_MAX_SECTOR_SIZE 512
|
||||
/* RT_DFS_ELM_USE_ERASE is not set */
|
||||
#define RT_DFS_ELM_REENTRANT
|
||||
#define RT_USING_DFS_DEVFS
|
||||
/* RT_USING_DFS_NET is not set */
|
||||
/* RT_USING_DFS_ROMFS is not set */
|
||||
/* RT_USING_DFS_RAMFS is not set */
|
||||
/* RT_USING_DFS_UFFS is not set */
|
||||
/* RT_USING_DFS_JFFS2 is not set */
|
||||
/* RT_USING_DFS_NFS is not set */
|
||||
|
||||
/* Device Drivers */
|
||||
|
||||
#define RT_USING_DEVICE_IPC
|
||||
#define RT_USING_SERIAL
|
||||
/* RT_USING_CAN is not set */
|
||||
/* RT_USING_HWTIMER is not set */
|
||||
/* RT_USING_CPUTIME is not set */
|
||||
#define RT_USING_I2C
|
||||
#define RT_USING_I2C_BITOPS
|
||||
#define RT_USING_PIN
|
||||
/* RT_USING_MTD_NOR is not set */
|
||||
/* RT_USING_MTD_NAND is not set */
|
||||
#define RT_USING_RTC
|
||||
/* RT_USING_SOFT_RTC is not set */
|
||||
/* RTC_SYNC_USING_NTP is not set */
|
||||
#define RT_USING_SDIO
|
||||
/* RT_USING_SPI is not set */
|
||||
/* RT_USING_WDT is not set */
|
||||
/* RT_USING_WIFI is not set */
|
||||
|
||||
/* Using USB */
|
||||
|
||||
/* RT_USING_USB_HOST is not set */
|
||||
/* RT_USING_USB_DEVICE is not set */
|
||||
|
||||
/* POSIX layer and C standard library */
|
||||
|
||||
#define RT_USING_LIBC
|
||||
/* RT_USING_PTHREADS is not set */
|
||||
/* RT_USING_POSIX is not set */
|
||||
/* HAVE_SYS_SIGNALS is not set */
|
||||
|
||||
/* Network stack */
|
||||
|
||||
/* light weight TCP/IP stack */
|
||||
|
||||
#define RT_USING_LWIP
|
||||
/* RT_USING_LWIP141 is not set */
|
||||
#define RT_USING_LWIP202
|
||||
/* RT_USING_LWIP_IPV6 is not set */
|
||||
/* RT_LWIP_IGMP is not set */
|
||||
#define RT_LWIP_ICMP
|
||||
/* RT_LWIP_SNMP is not set */
|
||||
#define RT_LWIP_DNS
|
||||
#define RT_LWIP_DHCP
|
||||
#define IP_SOF_BROADCAST 1
|
||||
|
@ -164,8 +122,6 @@
|
|||
#define RT_LWIP_MSKADDR "255.255.255.0"
|
||||
#define RT_LWIP_UDP
|
||||
#define RT_LWIP_TCP
|
||||
/* RT_LWIP_RAW is not set */
|
||||
/* RT_LWIP_PPP is not set */
|
||||
#define RT_MEMP_NUM_NETCONN 8
|
||||
#define RT_LWIP_PBUF_NUM 16
|
||||
#define RT_LWIP_RAW_PCB_NUM 4
|
||||
|
@ -180,33 +136,24 @@
|
|||
#define RT_LWIP_ETHTHREAD_PRIORITY 12
|
||||
#define RT_LWIP_ETHTHREAD_STACKSIZE 1024
|
||||
#define RT_LWIP_ETHTHREAD_MBOX_SIZE 8
|
||||
/* RT_LWIP_REASSEMBLY_FRAG is not set */
|
||||
#define LWIP_NETIF_STATUS_CALLBACK 1
|
||||
#define SO_REUSE 1
|
||||
#define LWIP_SO_RCVTIMEO 1
|
||||
#define LWIP_SO_SNDTIMEO 1
|
||||
#define LWIP_SO_RCVBUF 1
|
||||
/* RT_LWIP_NETIF_LOOPBACK is not set */
|
||||
#define LWIP_NETIF_LOOPBACK 0
|
||||
|
||||
/* Modbus master and slave stack */
|
||||
|
||||
/* RT_USING_MODBUS is not set */
|
||||
/* LWIP_USING_DHCPD is not set */
|
||||
|
||||
/* VBUS(Virtual Software BUS) */
|
||||
|
||||
/* RT_USING_VBUS is not set */
|
||||
|
||||
/* Utilities */
|
||||
|
||||
/* RT_USING_LOGTRACE is not set */
|
||||
/* RT_USING_RYM is not set */
|
||||
|
||||
/* ARM CMSIS */
|
||||
|
||||
/* RT_USING_CMSIS_OS is not set */
|
||||
/* RT_USING_RTT_CMSIS is not set */
|
||||
|
||||
/* RT-Thread online packages */
|
||||
|
||||
|
@ -214,72 +161,44 @@
|
|||
|
||||
/* RT-Thread GUI Engine */
|
||||
|
||||
/* PKG_USING_GUIENGINE is not set */
|
||||
/* PKG_USING_PERSIMMON is not set */
|
||||
/* PKG_USING_LWEXT4 is not set */
|
||||
/* PKG_USING_PARTITION is not set */
|
||||
/* PKG_USING_SQLITE is not set */
|
||||
/* PKG_USING_RTI is not set */
|
||||
|
||||
/* IoT - internet of things */
|
||||
|
||||
/* PKG_USING_PAHOMQTT is not set */
|
||||
/* PKG_USING_WEBCLIENT is not set */
|
||||
/* PKG_USING_MONGOOSE is not set */
|
||||
/* PKG_USING_WEBTERMINAL is not set */
|
||||
/* PKG_USING_CJSON is not set */
|
||||
/* PKG_USING_LJSON is not set */
|
||||
/* PKG_USING_EZXML is not set */
|
||||
/* PKG_USING_NANOPB is not set */
|
||||
/* PKG_USING_GAGENT_CLOUD is not set */
|
||||
|
||||
/* Wi-Fi */
|
||||
|
||||
/* Marvell WiFi */
|
||||
|
||||
/* PKG_USING_WLANMARVELL is not set */
|
||||
|
||||
/* Wiced WiFi */
|
||||
|
||||
/* PKG_USING_WLAN_WICED is not set */
|
||||
/* PKG_USING_COAP is not set */
|
||||
/* PKG_USING_NOPOLL is not set */
|
||||
/* PKG_USING_NETUTILS is not set */
|
||||
|
||||
/* security packages */
|
||||
|
||||
/* PKG_USING_MBEDTLS is not set */
|
||||
/* PKG_USING_libsodium is not set */
|
||||
/* PKG_USING_TINYCRYPT is not set */
|
||||
|
||||
/* language packages */
|
||||
|
||||
/* PKG_USING_JERRYSCRIPT is not set */
|
||||
/* PKG_USING_MICROPYTHON is not set */
|
||||
|
||||
/* multimedia packages */
|
||||
|
||||
/* PKG_USING_OPENMV is not set */
|
||||
|
||||
/* tools packages */
|
||||
|
||||
/* PKG_USING_CMBACKTRACE is not set */
|
||||
/* PKG_USING_EASYLOGGER is not set */
|
||||
/* PKG_USING_SYSTEMVIEW is not set */
|
||||
/* PKG_USING_IPERF is not set */
|
||||
|
||||
/* miscellaneous packages */
|
||||
|
||||
/* PKG_USING_FASTLZ is not set */
|
||||
/* PKG_USING_MINILZO is not set */
|
||||
/* PKG_USING_QUICKLZ is not set */
|
||||
|
||||
/* example package: hello */
|
||||
|
||||
/* PKG_USING_HELLO is not set */
|
||||
/* PKG_USING_MULTIBUTTON is not set */
|
||||
#define SOC_IMXRT1052
|
||||
#define BOARD_RT1050_EVK
|
||||
|
||||
/* RT1050_EVK Bsp Config */
|
||||
|
||||
/* Select uart device */
|
||||
|
||||
#define RT_USING_UART1
|
||||
#define RT_USING_HP_RTC
|
||||
#define RT_USING_SDRAM
|
||||
#define RT_USING_RTC_HP
|
||||
|
||||
#endif
|
||||
|
|
|
@ -0,0 +1,287 @@
|
|||
#
|
||||
# Automatically generated file; DO NOT EDIT.
|
||||
# RT-Thread Configuration
|
||||
#
|
||||
|
||||
#
|
||||
# RT-Thread Kernel
|
||||
#
|
||||
CONFIG_RT_NAME_MAX=10
|
||||
CONFIG_RT_ALIGN_SIZE=8
|
||||
# CONFIG_RT_THREAD_PRIORITY_8 is not set
|
||||
CONFIG_RT_THREAD_PRIORITY_32=y
|
||||
# CONFIG_RT_THREAD_PRIORITY_256 is not set
|
||||
CONFIG_RT_THREAD_PRIORITY_MAX=32
|
||||
CONFIG_RT_TICK_PER_SECOND=1000
|
||||
CONFIG_RT_DEBUG=y
|
||||
CONFIG_RT_USING_OVERFLOW_CHECK=y
|
||||
CONFIG_RT_DEBUG_INIT=0
|
||||
CONFIG_RT_DEBUG_THREAD=0
|
||||
CONFIG_RT_USING_HOOK=y
|
||||
CONFIG_IDLE_THREAD_STACK_SIZE=1024
|
||||
# CONFIG_RT_USING_TIMER_SOFT is not set
|
||||
|
||||
#
|
||||
# Inter-Thread communication
|
||||
#
|
||||
CONFIG_RT_USING_SEMAPHORE=y
|
||||
CONFIG_RT_USING_MUTEX=y
|
||||
CONFIG_RT_USING_EVENT=y
|
||||
CONFIG_RT_USING_MAILBOX=y
|
||||
CONFIG_RT_USING_MESSAGEQUEUE=y
|
||||
# CONFIG_RT_USING_SIGNALS is not set
|
||||
|
||||
#
|
||||
# Memory Management
|
||||
#
|
||||
CONFIG_RT_USING_MEMPOOL=y
|
||||
CONFIG_RT_USING_MEMHEAP=y
|
||||
# CONFIG_RT_USING_NOHEAP is not set
|
||||
CONFIG_RT_USING_SMALL_MEM=y
|
||||
# CONFIG_RT_USING_SLAB is not set
|
||||
# CONFIG_RT_USING_MEMHEAP_AS_HEAP is not set
|
||||
# CONFIG_RT_USING_MEMTRACE is not set
|
||||
CONFIG_RT_USING_HEAP=y
|
||||
|
||||
#
|
||||
# Kernel Device Object
|
||||
#
|
||||
CONFIG_RT_USING_DEVICE=y
|
||||
CONFIG_RT_USING_INTERRUPT_INFO=y
|
||||
CONFIG_RT_USING_CONSOLE=y
|
||||
CONFIG_RT_CONSOLEBUF_SIZE=128
|
||||
CONFIG_RT_CONSOLE_DEVICE_NAME="uart2"
|
||||
# CONFIG_RT_USING_MODULE is not set
|
||||
|
||||
#
|
||||
# RT-Thread Components
|
||||
#
|
||||
CONFIG_RT_USING_COMPONENTS_INIT=y
|
||||
# CONFIG_RT_USING_USER_MAIN is not set
|
||||
|
||||
#
|
||||
# C++ features
|
||||
#
|
||||
# CONFIG_RT_USING_CPLUSPLUS is not set
|
||||
|
||||
#
|
||||
# Command shell
|
||||
#
|
||||
CONFIG_RT_USING_FINSH=y
|
||||
CONFIG_FINSH_THREAD_NAME="tshell"
|
||||
CONFIG_FINSH_USING_HISTORY=y
|
||||
CONFIG_FINSH_HISTORY_LINES=5
|
||||
CONFIG_FINSH_USING_SYMTAB=y
|
||||
CONFIG_FINSH_USING_DESCRIPTION=y
|
||||
CONFIG_FINSH_THREAD_PRIORITY=20
|
||||
CONFIG_FINSH_THREAD_STACK_SIZE=4096
|
||||
CONFIG_FINSH_CMD_SIZE=80
|
||||
# CONFIG_FINSH_USING_AUTH is not set
|
||||
CONFIG_FINSH_USING_MSH=y
|
||||
CONFIG_FINSH_USING_MSH_DEFAULT=y
|
||||
# CONFIG_FINSH_USING_MSH_ONLY is not set
|
||||
|
||||
#
|
||||
# Device virtual file system
|
||||
#
|
||||
CONFIG_RT_USING_DFS=y
|
||||
CONFIG_DFS_USING_WORKDIR=y
|
||||
CONFIG_DFS_FILESYSTEMS_MAX=2
|
||||
CONFIG_DFS_FILESYSTEM_TYPES_MAX=2
|
||||
CONFIG_DFS_FD_MAX=4
|
||||
CONFIG_RT_USING_DFS_ELMFAT=y
|
||||
|
||||
#
|
||||
# elm-chan's FatFs, Generic FAT Filesystem Module
|
||||
#
|
||||
CONFIG_RT_DFS_ELM_CODE_PAGE=936
|
||||
CONFIG_RT_DFS_ELM_WORD_ACCESS=y
|
||||
CONFIG_RT_DFS_ELM_USE_LFN_0=y
|
||||
# CONFIG_RT_DFS_ELM_USE_LFN_1 is not set
|
||||
# CONFIG_RT_DFS_ELM_USE_LFN_2 is not set
|
||||
# CONFIG_RT_DFS_ELM_USE_LFN_3 is not set
|
||||
CONFIG_RT_DFS_ELM_USE_LFN=0
|
||||
CONFIG_RT_DFS_ELM_MAX_LFN=64
|
||||
CONFIG_RT_DFS_ELM_DRIVES=2
|
||||
CONFIG_RT_DFS_ELM_MAX_SECTOR_SIZE=512
|
||||
# CONFIG_RT_DFS_ELM_USE_ERASE is not set
|
||||
CONFIG_RT_DFS_ELM_REENTRANT=y
|
||||
# CONFIG_RT_USING_DFS_DEVFS is not set
|
||||
# CONFIG_RT_USING_DFS_NET is not set
|
||||
# CONFIG_RT_USING_DFS_ROMFS is not set
|
||||
# CONFIG_RT_USING_DFS_RAMFS is not set
|
||||
# CONFIG_RT_USING_DFS_UFFS is not set
|
||||
# CONFIG_RT_USING_DFS_JFFS2 is not set
|
||||
# CONFIG_RT_USING_DFS_NFS is not set
|
||||
|
||||
#
|
||||
# Device Drivers
|
||||
#
|
||||
CONFIG_RT_USING_DEVICE_IPC=y
|
||||
CONFIG_RT_USING_SERIAL=y
|
||||
CONFIG_RT_USING_CAN=y
|
||||
CONFIG_RT_CAN_USING_HDR=y
|
||||
# CONFIG_RT_USING_HWTIMER is not set
|
||||
# CONFIG_RT_USING_CPUTIME is not set
|
||||
CONFIG_RT_USING_I2C=y
|
||||
CONFIG_RT_USING_I2C_BITOPS=y
|
||||
CONFIG_RT_USING_PIN=y
|
||||
# CONFIG_RT_USING_MTD_NOR is not set
|
||||
# CONFIG_RT_USING_MTD_NAND is not set
|
||||
# CONFIG_RT_USING_RTC is not set
|
||||
# CONFIG_RT_USING_SDIO is not set
|
||||
CONFIG_RT_USING_SPI=y
|
||||
CONFIG_RT_USING_SPI_MSD=y
|
||||
# CONFIG_RT_USING_SFUD is not set
|
||||
# CONFIG_RT_USING_W25QXX is not set
|
||||
# CONFIG_RT_USING_GD is not set
|
||||
# CONFIG_RT_USING_ENC28J60 is not set
|
||||
# CONFIG_RT_USING_SPI_WIFI is not set
|
||||
# CONFIG_RT_USING_WDT is not set
|
||||
# CONFIG_RT_USING_WIFI is not set
|
||||
|
||||
#
|
||||
# Using USB
|
||||
#
|
||||
# CONFIG_RT_USING_USB_HOST is not set
|
||||
# CONFIG_RT_USING_USB_DEVICE is not set
|
||||
|
||||
#
|
||||
# POSIX layer and C standard library
|
||||
#
|
||||
CONFIG_RT_USING_LIBC=y
|
||||
CONFIG_RT_USING_PTHREADS=y
|
||||
# CONFIG_RT_USING_POSIX is not set
|
||||
# CONFIG_HAVE_SYS_SIGNALS is not set
|
||||
|
||||
#
|
||||
# Network stack
|
||||
#
|
||||
|
||||
#
|
||||
# light weight TCP/IP stack
|
||||
#
|
||||
CONFIG_RT_USING_LWIP=y
|
||||
CONFIG_RT_USING_LWIP141=y
|
||||
# CONFIG_RT_USING_LWIP202 is not set
|
||||
CONFIG_RT_LWIP_IGMP=y
|
||||
CONFIG_RT_LWIP_ICMP=y
|
||||
# CONFIG_RT_LWIP_SNMP is not set
|
||||
CONFIG_RT_LWIP_DNS=y
|
||||
# CONFIG_RT_LWIP_DHCP is not set
|
||||
|
||||
#
|
||||
# Static IPv4 Address
|
||||
#
|
||||
CONFIG_RT_LWIP_IPADDR="192.168.1.254"
|
||||
CONFIG_RT_LWIP_GWADDR="192.168.1.1"
|
||||
CONFIG_RT_LWIP_MSKADDR="255.255.255.0"
|
||||
CONFIG_RT_LWIP_UDP=y
|
||||
CONFIG_RT_LWIP_TCP=y
|
||||
# CONFIG_RT_LWIP_RAW is not set
|
||||
# CONFIG_RT_LWIP_PPP is not set
|
||||
CONFIG_RT_MEMP_NUM_NETCONN=8
|
||||
CONFIG_RT_LWIP_PBUF_NUM=4
|
||||
CONFIG_RT_LWIP_RAW_PCB_NUM=4
|
||||
CONFIG_RT_LWIP_UDP_PCB_NUM=4
|
||||
CONFIG_RT_LWIP_TCP_PCB_NUM=3
|
||||
CONFIG_RT_LWIP_TCP_SEG_NUM=40
|
||||
CONFIG_RT_LWIP_TCP_SND_BUF=4096
|
||||
CONFIG_RT_LWIP_TCP_WND=2048
|
||||
CONFIG_RT_LWIP_TCPTHREAD_PRIORITY=12
|
||||
CONFIG_RT_LWIP_TCPTHREAD_MBOX_SIZE=8
|
||||
CONFIG_RT_LWIP_TCPTHREAD_STACKSIZE=4096
|
||||
CONFIG_RT_LWIP_ETHTHREAD_PRIORITY=14
|
||||
CONFIG_RT_LWIP_ETHTHREAD_STACKSIZE=512
|
||||
CONFIG_RT_LWIP_ETHTHREAD_MBOX_SIZE=8
|
||||
# CONFIG_RT_LWIP_REASSEMBLY_FRAG is not set
|
||||
CONFIG_LWIP_NETIF_STATUS_CALLBACK=1
|
||||
CONFIG_SO_REUSE=1
|
||||
CONFIG_LWIP_SO_RCVTIMEO=1
|
||||
CONFIG_LWIP_SO_SNDTIMEO=1
|
||||
CONFIG_LWIP_SO_RCVBUF=1
|
||||
# CONFIG_RT_LWIP_NETIF_LOOPBACK is not set
|
||||
CONFIG_LWIP_NETIF_LOOPBACK=0
|
||||
|
||||
#
|
||||
# Modbus master and slave stack
|
||||
#
|
||||
# CONFIG_RT_USING_MODBUS is not set
|
||||
# CONFIG_LWIP_USING_DHCPD is not set
|
||||
|
||||
#
|
||||
# VBUS(Virtual Software BUS)
|
||||
#
|
||||
# CONFIG_RT_USING_VBUS is not set
|
||||
|
||||
#
|
||||
# Utilities
|
||||
#
|
||||
# CONFIG_RT_USING_LOGTRACE is not set
|
||||
# CONFIG_RT_USING_RYM is not set
|
||||
|
||||
#
|
||||
# RT-Thread online packages
|
||||
#
|
||||
|
||||
#
|
||||
# system packages
|
||||
#
|
||||
# CONFIG_PKG_USING_PARTITION is not set
|
||||
# CONFIG_PKG_USING_SQLITE is not set
|
||||
# CONFIG_PKG_USING_RTI is not set
|
||||
|
||||
#
|
||||
# IoT - internet of things
|
||||
#
|
||||
# CONFIG_PKG_USING_PAHOMQTT is not set
|
||||
# CONFIG_PKG_USING_WEBCLIENT is not set
|
||||
# CONFIG_PKG_USING_MONGOOSE is not set
|
||||
# CONFIG_PKG_USING_WEBTERMINAL is not set
|
||||
# CONFIG_PKG_USING_CJSON is not set
|
||||
# CONFIG_PKG_USING_EZXML is not set
|
||||
# CONFIG_PKG_USING_NANOPB is not set
|
||||
|
||||
#
|
||||
# security packages
|
||||
#
|
||||
# CONFIG_PKG_USING_MBEDTLS is not set
|
||||
# CONFIG_PKG_USING_libsodium is not set
|
||||
|
||||
#
|
||||
# language packages
|
||||
#
|
||||
# CONFIG_PKG_USING_JERRYSCRIPT is not set
|
||||
# CONFIG_PKG_USING_MICROPYTHON is not set
|
||||
|
||||
#
|
||||
# multimedia packages
|
||||
#
|
||||
|
||||
#
|
||||
# tools packages
|
||||
#
|
||||
# CONFIG_PKG_USING_CMBACKTRACE is not set
|
||||
# CONFIG_PKG_USING_EASYLOGGER is not set
|
||||
# CONFIG_PKG_USING_SYSTEMVIEW is not set
|
||||
|
||||
#
|
||||
# miscellaneous packages
|
||||
#
|
||||
# CONFIG_PKG_USING_FASTLZ is not set
|
||||
# CONFIG_PKG_USING_MINILZO is not set
|
||||
|
||||
#
|
||||
# example package: hello
|
||||
#
|
||||
# CONFIG_PKG_USING_HELLO is not set
|
||||
CONFIG_RT_USING_UART2=y
|
||||
CONFIG_RT_UART_RX_BUFFER_SIZE=64
|
||||
CONFIG_RT_USING_GMAC_INT_MODE=y
|
||||
CONFIG_RT_USING_FPU=y
|
||||
CONFIG_RT_USING_SPI0=y
|
||||
CONFIG_RT_USING_SPI1=y
|
||||
CONFIG_RT_USING_I2C1=y
|
||||
CONFIG_RT_USING_I2C2=y
|
||||
CONFIG_USING_BXCAN0=y
|
||||
CONFIG_USING_BXCAN1=y
|
|
@ -12,6 +12,7 @@
|
|||
* 2010-06-25 Bernard first version
|
||||
* 2011-08-08 lgnq modified for Loongson LS1B
|
||||
* 2015-07-06 chinesebear modified for Loongson LS1C
|
||||
* 2018-02-08 sundm75 modified for Loongson LS1C SmartLoongV3
|
||||
*/
|
||||
|
||||
#include <rtthread.h>
|
||||
|
@ -20,23 +21,41 @@
|
|||
|
||||
void rt_init_thread_entry(void *parameter)
|
||||
{
|
||||
/* initialization RT-Thread Components */
|
||||
rt_components_init();
|
||||
#ifdef RT_USING_COMPONENTS_INIT
|
||||
/* initialization RT-Thread Components */
|
||||
rt_components_init();
|
||||
#endif
|
||||
#if defined(RT_USING_DFS) && defined(RT_USING_DFS_ELMFAT)
|
||||
/* mount sd card fat partition 1 as root directory */
|
||||
if( dfs_mount("sd0", "/", "elm", 0, 0) == 0)
|
||||
{
|
||||
rt_kprintf("File System initialized!\n");
|
||||
}
|
||||
else
|
||||
{
|
||||
rt_kprintf("File System initialzation failed!\n");
|
||||
}
|
||||
#endif /* RT_USING_DFS && RT_USING_DFS_ELMFAT */
|
||||
|
||||
/*网口EMAC初始化*/
|
||||
rt_hw_eth_init();
|
||||
#if defined(RT_USING_RTGUI)
|
||||
/*触摸屏使用SPI总线SPI1 CS0 初始化*/
|
||||
rtgui_touch_hw_init("spi10");
|
||||
#endif
|
||||
|
||||
// 网口EMAC初始化
|
||||
rt_hw_eth_init();
|
||||
}
|
||||
|
||||
int rt_application_init(void)
|
||||
{
|
||||
rt_thread_t tid;
|
||||
rt_thread_t tid;
|
||||
|
||||
/* create initialization thread */
|
||||
tid = rt_thread_create("init",
|
||||
rt_init_thread_entry, RT_NULL,
|
||||
4096, RT_THREAD_PRIORITY_MAX/3, 20);
|
||||
if (tid != RT_NULL)
|
||||
rt_thread_startup(tid);
|
||||
/* create initialization thread */
|
||||
tid = rt_thread_create("init",
|
||||
rt_init_thread_entry, RT_NULL,
|
||||
4096, RT_THREAD_PRIORITY_MAX/3, 20);
|
||||
if (tid != RT_NULL)
|
||||
rt_thread_startup(tid);
|
||||
|
||||
return 0;
|
||||
return 0;
|
||||
}
|
||||
|
|
|
@ -5,6 +5,10 @@ src = Glob('*.c')
|
|||
|
||||
CPPPATH = [cwd]
|
||||
|
||||
|
||||
if GetDepend('RT_USING_RTGUI') == False:
|
||||
SrcRemove(src, 'touch.c')
|
||||
|
||||
group = DefineGroup('Drivers', src, depend = [''], CPPPATH = CPPPATH)
|
||||
|
||||
objs = []
|
||||
|
|
|
@ -60,12 +60,12 @@ void rt_hw_fpu_init(void)
|
|||
rt_uint32_t c0_status = 0;
|
||||
rt_uint32_t c1_status = 0;
|
||||
|
||||
// 使能协处理器1--FPU
|
||||
// 使能协处理器1--FPU
|
||||
c0_status = read_c0_status();
|
||||
c0_status |= (ST0_CU1 | ST0_FR);
|
||||
write_c0_status(c0_status);
|
||||
|
||||
// 配置FPU
|
||||
// 配置FPU
|
||||
c1_status = read_c1_status();
|
||||
c1_status |= (FPU_CSR_FS | FPU_CSR_FO | FPU_CSR_FN); // set FS, FO, FN
|
||||
c1_status &= ~(FPU_CSR_ALL_E); // disable exception
|
||||
|
@ -81,25 +81,28 @@ void rt_hw_fpu_init(void)
|
|||
*/
|
||||
void rt_hw_board_init(void)
|
||||
{
|
||||
#ifdef RT_USING_UART
|
||||
#ifdef RT_USING_SERIAL
|
||||
/* init hardware UART device */
|
||||
rt_hw_uart_init();
|
||||
#endif
|
||||
|
||||
#ifdef RT_USING_CONSOLE
|
||||
/* set console device */
|
||||
rt_console_set_device("uart2");
|
||||
rt_console_set_device(RT_CONSOLE_DEVICE_NAME);
|
||||
#endif
|
||||
|
||||
/* init operating system timer */
|
||||
rt_hw_timer_init();
|
||||
/* init operating system timer */
|
||||
rt_hw_timer_init();
|
||||
|
||||
#ifdef RT_USING_FPU
|
||||
/* init hardware fpu */
|
||||
rt_hw_fpu_init();
|
||||
#endif
|
||||
|
||||
rt_kprintf("current sr: 0x%08x\n", read_c0_status());
|
||||
#ifdef RT_USING_COMPONENTS_INIT
|
||||
rt_components_board_init();
|
||||
#endif
|
||||
|
||||
rt_kprintf("current sr: 0x%08x\n", read_c0_status());
|
||||
}
|
||||
|
||||
#define __raw_out_put(unr) \
|
||||
|
|
|
@ -0,0 +1,263 @@
|
|||
/*
|
||||
* File :display_controller.c
|
||||
* This file is part of RT-Thread RTOS
|
||||
* COPYRIGHT (C) 2006 - 2017, RT-Thread Development Team
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 2 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License along
|
||||
* with this program; if not, write to the Free Software Foundation, Inc.,
|
||||
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*
|
||||
* Change Logs:
|
||||
* Date Author Notes
|
||||
* 2011-08-09 lgnq first version for LS1B DC
|
||||
* 2015-07-06 chinesebear modified for loongson 1c
|
||||
* 2018-01-06 sundm75 modified for smartloong
|
||||
*/
|
||||
|
||||
#include <rtthread.h>
|
||||
#include "display_controller.h"
|
||||
#include "../../libraries/ls1c_pwm.h"
|
||||
#include "../../libraries/ls1c_public.h"
|
||||
#include "../../libraries/ls1c_gpio.h"
|
||||
#include "../../libraries/ls1c_pin.h"
|
||||
|
||||
#ifdef RT_USING_RTGUI
|
||||
|
||||
struct vga_struct vga_mode[] =
|
||||
{
|
||||
{/*"480x272_60.00"*/ 111000, 480, 482, 523, 525, 272, 274, 284, 286, },
|
||||
{/*"640x480_70.00"*/ 28560, 640, 664, 728, 816, 480, 481, 484, 500, },
|
||||
{/*"640x640_60.00"*/ 33100, 640, 672, 736, 832, 640, 641, 644, 663, },
|
||||
{/*"640x768_60.00"*/ 39690, 640, 672, 736, 832, 768, 769, 772, 795, },
|
||||
{/*"640x800_60.00"*/ 42130, 640, 680, 744, 848, 800, 801, 804, 828, },
|
||||
{/*"800x480_70.00"*/ 35840, 800, 832, 912, 1024, 480, 481, 484, 500, },
|
||||
{/*"800x600_60.00"*/ 38220, 800, 832, 912, 1024, 600, 601, 604, 622, },
|
||||
{/*"800x640_60.00"*/ 40730, 800, 832, 912, 1024, 640, 641, 644, 663, },
|
||||
{/*"832x600_60.00"*/ 40010, 832, 864, 952, 1072, 600, 601, 604, 622, },
|
||||
{/*"832x608_60.00"*/ 40520, 832, 864, 952, 1072, 608, 609, 612, 630, },
|
||||
{/*"1024x480_60.00"*/ 38170, 1024, 1048, 1152, 1280, 480, 481, 484, 497, },
|
||||
{/*"1024x600_60.00"*/ 48960, 1024, 1064, 1168, 1312, 600, 601, 604, 622, },
|
||||
{/*"1024x640_60.00"*/ 52830, 1024, 1072, 1176, 1328, 640, 641, 644, 663, },
|
||||
{/*"1024x768_60.00"*/ 64110, 1024, 1080, 1184, 1344, 768, 769, 772, 795, },
|
||||
{/*"1152x764_60.00"*/ 71380, 1152, 1208, 1328, 1504, 764, 765, 768, 791, },
|
||||
{/*"1280x800_60.00"*/ 83460, 1280, 1344, 1480, 1680, 800, 801, 804, 828, },
|
||||
{/*"1280x1024_55.00"*/ 98600, 1280, 1352, 1488, 1696, 1024, 1025, 1028, 1057, },
|
||||
{/*"1440x800_60.00"*/ 93800, 1440, 1512, 1664, 1888, 800, 801, 804, 828, },
|
||||
{/*"1440x900_67.00"*/ 120280, 1440, 1528, 1680, 1920, 900, 901, 904, 935, },
|
||||
};
|
||||
|
||||
ALIGN(16)
|
||||
volatile rt_uint16_t _rt_framebuffer[FB_YSIZE][FB_XSIZE];
|
||||
static struct rt_device_graphic_info _dc_info;
|
||||
|
||||
static void pwminit(void)
|
||||
{
|
||||
pwm_info_t pwm_info;
|
||||
pwm_info.gpio = LS1C_PWM0_GPIO06; // pwm引脚位gpio06
|
||||
pwm_info.mode = PWM_MODE_NORMAL; // 正常模式--连续输出pwm波形
|
||||
pwm_info.duty = 0.85; // pwm占空比 85%
|
||||
pwm_info.period_ns = 5*1000*1000; // pwm周期5ms
|
||||
|
||||
/*pwm初始化,初始化后立即产生pwm波形*/
|
||||
pwm_init(&pwm_info);
|
||||
|
||||
/* 使能pwm */
|
||||
pwm_enable(&pwm_info);
|
||||
}
|
||||
int caclulate_freq(rt_uint32_t XIN, rt_uint32_t PCLK)
|
||||
{
|
||||
rt_uint32_t divider_int;
|
||||
rt_uint32_t needed_pixclk;
|
||||
rt_uint32_t pll_clk, pix_div;
|
||||
rt_uint32_t regval;
|
||||
|
||||
|
||||
pll_clk = PLL_FREQ; // 读CPU的 PLL及SDRAM 分频系数
|
||||
pll_clk =( pll_clk>>8 )& 0xff;
|
||||
pll_clk = XIN * pll_clk / 4 ;
|
||||
pix_div = PLL_DIV_PARAM;//读CPU的 CPU/CAMERA/DC 分频系数
|
||||
pix_div = (pix_div>>24)&0xff;
|
||||
rt_kprintf("old pll_clk=%d, pix_div=%d\n", pll_clk, pix_div);
|
||||
|
||||
divider_int = pll_clk/(1000000) *PCLK/1000;
|
||||
if(divider_int%1000>=500)
|
||||
divider_int = divider_int/1000+1;
|
||||
else
|
||||
divider_int = divider_int/1000;
|
||||
rt_kprintf("divider_int = %d\n", divider_int);
|
||||
|
||||
/* check whether divisor is too small. */
|
||||
if (divider_int < 1) {
|
||||
rt_kprintf("Warning: clock source is too slow.Try smaller resolution\n");
|
||||
divider_int = 1;
|
||||
}
|
||||
else if(divider_int > 100) {
|
||||
rt_kprintf("Warning: clock source is too fast.Try smaller resolution\n");
|
||||
divider_int = 100;
|
||||
}
|
||||
/* 配置分频寄存器 */
|
||||
{
|
||||
rt_uint32_t regval = 0;
|
||||
regval = PLL_DIV_PARAM;
|
||||
/*首先需要把分频使能位清零 */
|
||||
regval &= ~0x80000030; //PIX_DIV_VALID PIX_SEL 置0
|
||||
regval &= ~(0x3f<<24); //PIX_DIV 清零
|
||||
regval |= divider_int << 24;
|
||||
PLL_DIV_PARAM = regval;
|
||||
regval |= 0x80000030; //PIX_DIV_VALID PIX_SEL 置1
|
||||
PLL_DIV_PARAM = regval;
|
||||
}
|
||||
rt_kprintf("new PLL_FREQ=0x%x, PLL_DIV_PARAM=0x%x\n", PLL_FREQ, PLL_DIV_PARAM);
|
||||
rt_thread_delay(10);
|
||||
return 0;
|
||||
}
|
||||
|
||||
static rt_err_t rt_dc_init(rt_device_t dev)
|
||||
{
|
||||
int i, out, mode=-1;
|
||||
int val;
|
||||
|
||||
rt_kprintf("PWM initied\n");
|
||||
/* Set the back light PWM. */
|
||||
pwminit();
|
||||
|
||||
for (i=0; i<sizeof(vga_mode)/sizeof(struct vga_struct); i++)
|
||||
{
|
||||
if (vga_mode[i].hr == FB_XSIZE && vga_mode[i].vr == FB_YSIZE)
|
||||
{
|
||||
mode=i;
|
||||
/* 计算时钟 配置频率*/
|
||||
caclulate_freq(OSC, vga_mode[i].pclk);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (mode<0)
|
||||
{
|
||||
rt_kprintf("\n\n\nunsupported framebuffer resolution\n\n\n");
|
||||
return;
|
||||
}
|
||||
|
||||
DC_FB_CONFIG = 0x0;
|
||||
DC_FB_CONFIG = 0x3; // // framebuffer configuration RGB565
|
||||
DC_FB_BUFFER_ADDR0 = (rt_uint32_t)_rt_framebuffer - 0x80000000;
|
||||
DC_FB_BUFFER_ADDR1 = (rt_uint32_t)_rt_framebuffer - 0x80000000;
|
||||
DC_DITHER_CONFIG = 0x0; //颜色抖动配置寄存器
|
||||
DC_DITHER_TABLE_LOW = 0x0; //颜色抖动查找表低位寄存器
|
||||
DC_DITHER_TABLE_HIGH = 0x0; //颜色抖动查找表高位寄存器
|
||||
DC_PANEL_CONFIG = 0x80001311; //液晶面板配置寄存器
|
||||
DC_PANEL_TIMING = 0x0;
|
||||
|
||||
DC_HDISPLAY = (vga_mode[mode].hfl<<16) | vga_mode[mode].hr;
|
||||
DC_HSYNC = 0x40000000 | (vga_mode[mode].hse<<16) | vga_mode[mode].hss;
|
||||
DC_VDISPLAY = (vga_mode[mode].vfl<<16) | vga_mode[mode].vr;
|
||||
DC_VSYNC = 0x40000000 | (vga_mode[mode].vse<<16) | vga_mode[mode].vss;
|
||||
|
||||
#if defined(CONFIG_VIDEO_32BPP)
|
||||
DC_FB_CONFIG = 0x00100105;
|
||||
DC_FB_BUFFER_STRIDE = FB_XSIZE*4;
|
||||
#elif defined(CONFIG_VIDEO_24BPP)
|
||||
DC_FB_CONFIG = 0x00100104;
|
||||
DC_FB_BUFFER_STRIDE = (FB_XSIZE*4+255)&(~255);
|
||||
#elif defined(CONFIG_VIDEO_16BPP)// 使用这个选项
|
||||
DC_FB_CONFIG = 0x00100103;
|
||||
DC_FB_BUFFER_STRIDE = (FB_XSIZE*2+255)&(~255);
|
||||
#elif defined(CONFIG_VIDEO_15BPP)
|
||||
DC_FB_CONFIG = 0x00100102;
|
||||
DC_FB_BUFFER_STRIDE = (FB_XSIZE*2+255)&(~255);
|
||||
#elif defined(CONFIG_VIDEO_12BPP)
|
||||
DC_FB_CONFIG = 0x00100101;
|
||||
DC_FB_BUFFER_STRIDE = (FB_XSIZE*2+255)&(~255);
|
||||
#else
|
||||
DC_FB_CONFIG = 0x00100104;
|
||||
DC_FB_BUFFER_STRIDE = (FB_XSIZE*4+255)&(~255);
|
||||
#endif
|
||||
return RT_EOK;
|
||||
}
|
||||
|
||||
static rt_err_t rt_dc_control(rt_device_t dev, int cmd, void *args)
|
||||
{
|
||||
switch (cmd)
|
||||
{
|
||||
case RTGRAPHIC_CTRL_RECT_UPDATE:
|
||||
break;
|
||||
case RTGRAPHIC_CTRL_POWERON:
|
||||
break;
|
||||
case RTGRAPHIC_CTRL_POWEROFF:
|
||||
break;
|
||||
case RTGRAPHIC_CTRL_GET_INFO:
|
||||
rt_memcpy(args, &_dc_info, sizeof(_dc_info));
|
||||
break;
|
||||
case RTGRAPHIC_CTRL_SET_MODE:
|
||||
break;
|
||||
}
|
||||
|
||||
return RT_EOK;
|
||||
}
|
||||
|
||||
void rt_hw_dc_init(void)
|
||||
{
|
||||
rt_device_t dc = rt_malloc(sizeof(struct rt_device));
|
||||
if (dc == RT_NULL)
|
||||
{
|
||||
rt_kprintf("dc == RT_NULL\n");
|
||||
return; /* no memory yet */
|
||||
}
|
||||
|
||||
_dc_info.bits_per_pixel = 16;
|
||||
_dc_info.pixel_format = RTGRAPHIC_PIXEL_FORMAT_RGB565P;
|
||||
_dc_info.framebuffer = (rt_uint8_t*)HW_FB_ADDR;
|
||||
_dc_info.width = FB_XSIZE;
|
||||
_dc_info.height = FB_YSIZE;
|
||||
|
||||
/* init device structure */
|
||||
dc->type = RT_Device_Class_Graphic;
|
||||
dc->init = rt_dc_init;
|
||||
dc->open = RT_NULL;
|
||||
dc->close = RT_NULL;
|
||||
dc->control = rt_dc_control;
|
||||
dc->user_data = (void*)&_dc_info;
|
||||
|
||||
/* register Display Controller device to RT-Thread */
|
||||
rt_device_register(dc, "dc", RT_DEVICE_FLAG_RDWR);
|
||||
|
||||
rt_device_init(dc);
|
||||
}
|
||||
|
||||
#include <rtgui/driver.h>
|
||||
#include "display_controller.h"
|
||||
|
||||
/* initialize for gui driver */
|
||||
int rtgui_lcd_init(void)
|
||||
{
|
||||
rt_device_t dc;
|
||||
rt_kprintf("DC initied\n");
|
||||
|
||||
pin_set_purpose(76, PIN_PURPOSE_OTHER);
|
||||
pin_set_remap(76, PIN_REMAP_DEFAULT);
|
||||
|
||||
/* init Display Controller */
|
||||
rt_hw_dc_init();
|
||||
|
||||
/* find Display Controller device */
|
||||
dc = rt_device_find("dc");
|
||||
|
||||
/* set Display Controller device as rtgui graphic driver */
|
||||
rtgui_graphic_set_device(dc);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
INIT_DEVICE_EXPORT(rtgui_lcd_init);
|
||||
|
||||
#endif
|
|
@ -0,0 +1,59 @@
|
|||
/*
|
||||
* File : display_controller.h
|
||||
* This file is part of RT-Thread RTOS
|
||||
* COPYRIGHT (C) 2006-2012, RT-Thread Develop Team
|
||||
*
|
||||
* The license and distribution terms for this file may be
|
||||
* found in the file LICENSE in this distribution or at
|
||||
* http://www.rt-thread.org/license/LICENSE
|
||||
*
|
||||
* Change Logs:
|
||||
* Date Author Notes
|
||||
* 2011-08-08 lgnq first version for LS1B
|
||||
* 2015-07-06 chinesebear modified for loongson 1c
|
||||
* 2018-01-06 sundm75 modified for smartloong
|
||||
*/
|
||||
|
||||
#ifndef __DISPLAY_CONTROLLER_H__
|
||||
#define __DISPLAY_CONTROLLER_H__
|
||||
|
||||
#include <rtthread.h>
|
||||
#include "ls1c.h"
|
||||
|
||||
#define DC_BASE 0xBC301240 //Display Controller
|
||||
|
||||
/* Frame Buffer registers */
|
||||
#define DC_FB_CONFIG __REG32(DC_BASE + 0x000)
|
||||
#define DC_FB_BUFFER_ADDR0 __REG32(DC_BASE + 0x020)
|
||||
#define DC_FB_BUFFER_STRIDE __REG32(DC_BASE + 0x040)
|
||||
#define DC_FB_BUFFER_ORIGIN __REG32(DC_BASE + 0x060)
|
||||
#define DC_DITHER_CONFIG __REG32(DC_BASE + 0x120)
|
||||
#define DC_DITHER_TABLE_LOW __REG32(DC_BASE + 0x140)
|
||||
#define DC_DITHER_TABLE_HIGH __REG32(DC_BASE + 0x160)
|
||||
#define DC_PANEL_CONFIG __REG32(DC_BASE + 0x180)
|
||||
#define DC_PANEL_TIMING __REG32(DC_BASE + 0x1A0)
|
||||
#define DC_HDISPLAY __REG32(DC_BASE + 0x1C0)
|
||||
#define DC_HSYNC __REG32(DC_BASE + 0x1E0)
|
||||
#define DC_VDISPLAY __REG32(DC_BASE + 0x240)
|
||||
#define DC_VSYNC __REG32(DC_BASE + 0x260)
|
||||
#define DC_FB_BUFFER_ADDR1 __REG32(DC_BASE + 0x340)
|
||||
|
||||
/* Display Controller driver for 1024x768 16bit */
|
||||
#define FB_XSIZE 480
|
||||
#define FB_YSIZE 272
|
||||
#define CONFIG_VIDEO_16BPP
|
||||
|
||||
#define OSC 24000000 /* Hz */
|
||||
|
||||
#define K1BASE 0xA0000000
|
||||
#define KSEG1(addr) ((void *)(K1BASE | (rt_uint32_t)(addr)))
|
||||
#define HW_FB_ADDR KSEG1(_rt_framebuffer)
|
||||
|
||||
struct vga_struct
|
||||
{
|
||||
long pclk;
|
||||
int hr,hss,hse,hfl;
|
||||
int vr,vss,vse,vfl;
|
||||
};
|
||||
|
||||
#endif
|
|
@ -0,0 +1,541 @@
|
|||
/*
|
||||
* File : drv_can.c
|
||||
* This file is part of RT-Thread RTOS
|
||||
* COPYRIGHT (C) 2006 - 2018, RT-Thread Development Team
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 2 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License along
|
||||
* with this program; if not, write to the Free Software Foundation, Inc.,
|
||||
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*
|
||||
* Change Logs:
|
||||
* Date Author Notes
|
||||
* 2018-01-06 sundm75 first version
|
||||
*/
|
||||
|
||||
#include <rtthread.h>
|
||||
#include <rtdevice.h>
|
||||
#include <board.h>
|
||||
#include <rthw.h>
|
||||
|
||||
#include <drv_can.h>
|
||||
|
||||
#include "ls1c.h"
|
||||
#include "../libraries/ls1c_public.h"
|
||||
#include "../libraries/ls1c_regs.h"
|
||||
#include "../libraries/ls1c_clock.h"
|
||||
#include "../libraries/ls1c_can.h"
|
||||
#include "../libraries/ls1c_pin.h"
|
||||
|
||||
|
||||
#ifdef RT_USING_CAN
|
||||
|
||||
CanRxMsg RxMessage;
|
||||
|
||||
struct ls1c_bxcan
|
||||
{
|
||||
CAN_TypeDef *reg;
|
||||
void * irq;
|
||||
};
|
||||
|
||||
static rt_err_t bxmodifyfilter(struct ls1c_bxcan *pbxcan, struct rt_can_filter_item *pitem, rt_uint32_t actived)
|
||||
{
|
||||
rt_int32_t fcase;
|
||||
rt_err_t res;
|
||||
rt_int32_t hdr, fbase, foff;
|
||||
CAN_TypeDef* CANx;
|
||||
CANx = pbxcan->reg;
|
||||
|
||||
/*pitem->mode 1-掩码模式; 0- 滤波器模式 SJA1000中使用以下方式*/
|
||||
/*SJA1000中AFM 1-单滤波器模式; 0- 双滤波器模式 */
|
||||
|
||||
fcase = pitem->mode;/*1-单滤波器模式; 0- 双滤波器模式*/
|
||||
{
|
||||
if (!actived)
|
||||
{
|
||||
return RT_EOK;
|
||||
}
|
||||
else if (pitem->hdr == -1)
|
||||
{
|
||||
res = -1;
|
||||
if (res != RT_EOK)
|
||||
{
|
||||
return res;
|
||||
}
|
||||
}
|
||||
else if (pitem->hdr >= 0)
|
||||
{
|
||||
rt_enter_critical();
|
||||
res = RT_EOK;
|
||||
if (res != RT_EOK)
|
||||
{
|
||||
return res;
|
||||
}
|
||||
hdr = pitem->hdr;
|
||||
rt_exit_critical();
|
||||
}
|
||||
}
|
||||
|
||||
CAN_FilterInitTypeDef CAN_FilterInitStruct;
|
||||
unsigned char ide, rtr, id , idmask, mode;
|
||||
ide = (unsigned char) pitem->ide;
|
||||
rtr = (unsigned char) pitem->rtr;
|
||||
id = pitem->id;
|
||||
idmask = pitem->mask;
|
||||
mode = (unsigned char) pitem->mode;
|
||||
CAN_FilterInitStruct.IDE = ide;
|
||||
CAN_FilterInitStruct.RTR = rtr;
|
||||
CAN_FilterInitStruct.ID = id;
|
||||
CAN_FilterInitStruct.IDMASK = idmask;
|
||||
CAN_FilterInitStruct.MODE = mode;
|
||||
CAN_FilterInit(CANx, &CAN_FilterInitStruct);
|
||||
|
||||
return RT_EOK;
|
||||
}
|
||||
|
||||
static rt_err_t setfilter(struct ls1c_bxcan *pbxcan, struct rt_can_filter_config *pconfig)
|
||||
{
|
||||
struct rt_can_filter_item *pitem = pconfig->items;
|
||||
rt_uint32_t count = pconfig->count;
|
||||
rt_err_t res;
|
||||
while (count)
|
||||
{
|
||||
res = bxmodifyfilter(pbxcan, pitem, pconfig->actived);
|
||||
if (res != RT_EOK)
|
||||
{
|
||||
return res;
|
||||
}
|
||||
pitem++;
|
||||
count--;
|
||||
}
|
||||
return RT_EOK;
|
||||
}
|
||||
static void bxcan0_filter_init(struct rt_can_device *can)
|
||||
{
|
||||
struct ls1c_bxcan *pbxcan;
|
||||
pbxcan = (struct ls1c_bxcan *) can->parent.user_data;
|
||||
|
||||
}
|
||||
|
||||
static void bxcan1_filter_init(struct rt_can_device *can)
|
||||
{
|
||||
struct ls1c_bxcan *pbxcan;
|
||||
pbxcan = (struct ls1c_bxcan *) can->parent.user_data;
|
||||
|
||||
}
|
||||
|
||||
static void bxcan_init(CAN_TypeDef *pcan, rt_uint32_t baud, rt_uint32_t mode)
|
||||
{
|
||||
CAN_InitTypeDef CAN_InitStructure;
|
||||
|
||||
Ls1c_CanBPS_t bps ;
|
||||
|
||||
switch(baud)
|
||||
{
|
||||
case CAN1MBaud:
|
||||
bps = LS1C_CAN1MBaud;
|
||||
break;
|
||||
case CAN800kBaud:
|
||||
bps = LS1C_CAN800kBaud;
|
||||
break;
|
||||
case CAN500kBaud:
|
||||
bps = LS1C_CAN500kBaud;
|
||||
break;
|
||||
case CAN250kBaud:
|
||||
bps = LS1C_CAN250kBaud;
|
||||
break;
|
||||
case CAN125kBaud:
|
||||
bps = LS1C_CAN125kBaud;
|
||||
break;
|
||||
case CAN50kBaud:
|
||||
bps = LS1C_CAN40kBaud;
|
||||
break;
|
||||
default:
|
||||
bps = LS1C_CAN250kBaud;
|
||||
break;
|
||||
}
|
||||
|
||||
switch (mode)
|
||||
{
|
||||
case RT_CAN_MODE_NORMAL:
|
||||
CAN_InitStructure.CAN_Mode = 0x00;
|
||||
break;
|
||||
case RT_CAN_MODE_LISEN:
|
||||
CAN_InitStructure.CAN_Mode = CAN_Mode_LOM;
|
||||
break;
|
||||
case RT_CAN_MODE_LOOPBACK:
|
||||
CAN_InitStructure.CAN_Mode = CAN_Mode_STM;
|
||||
|
||||
break;
|
||||
case RT_CAN_MODE_LOOPBACKANLISEN:
|
||||
CAN_InitStructure.CAN_Mode = CAN_Mode_STM|CAN_Mode_LOM;
|
||||
break;
|
||||
}
|
||||
CAN_InitStructure.CAN_SJW = CAN_SJW_1tq;
|
||||
|
||||
switch (bps)
|
||||
{
|
||||
case LS1C_CAN1MBaud:
|
||||
CAN_InitStructure.CAN_Prescaler = 9;
|
||||
CAN_InitStructure.CAN_BS1 = CAN_BS1_4tq;
|
||||
CAN_InitStructure.CAN_BS2 = CAN_BS2_2tq;
|
||||
break;
|
||||
case LS1C_CAN800kBaud:
|
||||
CAN_InitStructure.CAN_Prescaler = 8;
|
||||
CAN_InitStructure.CAN_BS1 = CAN_BS1_7tq;
|
||||
CAN_InitStructure.CAN_BS2 = CAN_BS2_2tq;
|
||||
break;
|
||||
case LS1C_CAN500kBaud:
|
||||
CAN_InitStructure.CAN_Prescaler = 9;
|
||||
CAN_InitStructure.CAN_BS1 = CAN_BS1_11tq;
|
||||
CAN_InitStructure.CAN_BS2 = CAN_BS2_2tq;
|
||||
break;
|
||||
case LS1C_CAN250kBaud:
|
||||
CAN_InitStructure.CAN_Prescaler = 36;
|
||||
CAN_InitStructure.CAN_BS1 = CAN_BS1_4tq;
|
||||
CAN_InitStructure.CAN_BS2 = CAN_BS2_2tq;
|
||||
break;
|
||||
case LS1C_CAN125kBaud:
|
||||
CAN_InitStructure.CAN_Prescaler = 36;
|
||||
CAN_InitStructure.CAN_BS1 = CAN_BS1_11tq;
|
||||
CAN_InitStructure.CAN_BS2 = CAN_BS2_2tq;
|
||||
break;
|
||||
case LS1C_CAN100kBaud:
|
||||
CAN_InitStructure.CAN_Prescaler = 63;
|
||||
CAN_InitStructure.CAN_BS1 = CAN_BS1_7tq;
|
||||
CAN_InitStructure.CAN_BS2 = CAN_BS2_2tq;
|
||||
break;
|
||||
case LS1C_CAN50kBaud:
|
||||
CAN_InitStructure.CAN_Prescaler = 63;
|
||||
CAN_InitStructure.CAN_BS1 = CAN_BS1_16tq;
|
||||
CAN_InitStructure.CAN_BS2 = CAN_BS2_3tq;
|
||||
break;
|
||||
default: //250K
|
||||
CAN_InitStructure.CAN_Prescaler = 36;
|
||||
CAN_InitStructure.CAN_BS1 = CAN_BS1_4tq;
|
||||
CAN_InitStructure.CAN_BS2 = CAN_BS2_2tq;
|
||||
break;
|
||||
}
|
||||
|
||||
CAN_Init(pcan, &CAN_InitStructure);
|
||||
}
|
||||
|
||||
#ifdef USING_BXCAN0
|
||||
static void bxcan0_hw_init(void)
|
||||
{
|
||||
pin_set_purpose(54, PIN_PURPOSE_OTHER);
|
||||
pin_set_purpose(55, PIN_PURPOSE_OTHER);
|
||||
pin_set_remap(54, PIN_REMAP_THIRD);
|
||||
pin_set_remap(55, PIN_REMAP_THIRD);
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifdef USING_BXCAN1
|
||||
static void bxcan1_hw_init(void)
|
||||
{
|
||||
pin_set_purpose(56, PIN_PURPOSE_GPIO);
|
||||
pin_set_purpose(57, PIN_PURPOSE_GPIO);
|
||||
pin_set_remap(56, PIN_REMAP_DEFAULT);
|
||||
pin_set_remap(57, PIN_REMAP_DEFAULT);
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
static rt_err_t configure(struct rt_can_device *can, struct can_configure *cfg)
|
||||
{
|
||||
CAN_TypeDef *pbxcan;
|
||||
|
||||
pbxcan = ((struct ls1c_bxcan *) can->parent.user_data)->reg;
|
||||
if (pbxcan == CAN0)
|
||||
{
|
||||
#ifdef USING_BXCAN0
|
||||
bxcan0_hw_init();
|
||||
bxcan_init(pbxcan, cfg->baud_rate, cfg->mode);
|
||||
#endif
|
||||
}
|
||||
else if (pbxcan == CAN1)
|
||||
{
|
||||
#ifdef USING_BXCAN1
|
||||
bxcan1_hw_init();
|
||||
bxcan_init(pbxcan, cfg->baud_rate, cfg->mode);
|
||||
#endif
|
||||
}
|
||||
return RT_EOK;
|
||||
}
|
||||
|
||||
static rt_err_t control(struct rt_can_device *can, int cmd, void *arg)
|
||||
{
|
||||
struct ls1c_bxcan *pbxcan;
|
||||
rt_uint32_t argval;
|
||||
|
||||
pbxcan = (struct ls1c_bxcan *) can->parent.user_data;
|
||||
switch (cmd)
|
||||
{
|
||||
case RT_CAN_CMD_SET_FILTER:
|
||||
return setfilter(pbxcan, (struct rt_can_filter_config *) arg);
|
||||
break;
|
||||
case RT_CAN_CMD_SET_MODE:
|
||||
argval = (rt_uint32_t) arg;
|
||||
if (argval != RT_CAN_MODE_NORMAL ||
|
||||
argval != RT_CAN_MODE_LISEN ||
|
||||
argval != RT_CAN_MODE_LOOPBACK ||
|
||||
argval != RT_CAN_MODE_LOOPBACKANLISEN)
|
||||
{
|
||||
return RT_ERROR;
|
||||
}
|
||||
if (argval != can->config.mode)
|
||||
{
|
||||
can->config.mode = argval;
|
||||
return CAN_SetMode(pbxcan->reg, argval);
|
||||
}
|
||||
break;
|
||||
case RT_CAN_CMD_SET_BAUD:
|
||||
argval = (rt_uint32_t) arg;
|
||||
if (argval != CAN1MBaud &&
|
||||
argval != CAN800kBaud &&
|
||||
argval != CAN500kBaud &&
|
||||
argval != CAN250kBaud &&
|
||||
argval != CAN125kBaud &&
|
||||
argval != CAN100kBaud &&
|
||||
argval != CAN50kBaud )
|
||||
{
|
||||
return RT_ERROR;
|
||||
}
|
||||
if (argval != can->config.baud_rate)
|
||||
{
|
||||
can->config.baud_rate = argval;
|
||||
Ls1c_CanBPS_t bps;
|
||||
switch(argval)
|
||||
{
|
||||
case CAN1MBaud:
|
||||
bps = LS1C_CAN1MBaud;
|
||||
break;
|
||||
case CAN800kBaud:
|
||||
bps = LS1C_CAN800kBaud;
|
||||
break;
|
||||
case CAN500kBaud:
|
||||
bps = LS1C_CAN500kBaud;
|
||||
break;
|
||||
case CAN250kBaud:
|
||||
bps = LS1C_CAN250kBaud;
|
||||
break;
|
||||
case CAN125kBaud:
|
||||
bps = LS1C_CAN125kBaud;
|
||||
break;
|
||||
case CAN50kBaud:
|
||||
bps = LS1C_CAN40kBaud;
|
||||
break;
|
||||
default:
|
||||
bps = LS1C_CAN250kBaud;
|
||||
break;
|
||||
}
|
||||
return CAN_SetBps( pbxcan->reg, bps);
|
||||
}
|
||||
break;
|
||||
case RT_CAN_CMD_GET_STATUS:
|
||||
{
|
||||
rt_uint32_t errtype;
|
||||
|
||||
errtype = pbxcan->reg->RXERR;
|
||||
can->status.rcverrcnt = errtype ;
|
||||
errtype = pbxcan->reg->TXERR;
|
||||
can->status.snderrcnt = errtype ;
|
||||
errtype = pbxcan->reg->ECC;
|
||||
can->status.errcode = errtype ;
|
||||
if (arg != &can->status)
|
||||
{
|
||||
rt_memcpy(arg, &can->status, sizeof(can->status));
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
return RT_EOK;
|
||||
}
|
||||
|
||||
static int sendmsg(struct rt_can_device *can, const void *buf, rt_uint32_t boxno)
|
||||
{
|
||||
CAN_TypeDef *pbxcan;
|
||||
CanTxMsg TxMessage;
|
||||
struct rt_can_msg *pmsg = (struct rt_can_msg *) buf;
|
||||
int i;
|
||||
|
||||
pbxcan = ((struct ls1c_bxcan *) can->parent.user_data)->reg;
|
||||
|
||||
TxMessage.StdId = pmsg->id;
|
||||
TxMessage.ExtId = pmsg->id;
|
||||
TxMessage.RTR = pmsg->rtr;
|
||||
TxMessage.IDE = pmsg->ide;
|
||||
TxMessage.DLC = pmsg->len;
|
||||
for( i=0; i<TxMessage.DLC ;i++)
|
||||
{
|
||||
TxMessage.Data[i] = pmsg->data[i];
|
||||
}
|
||||
CAN_Transmit(pbxcan, &TxMessage);
|
||||
|
||||
return RT_EOK;
|
||||
}
|
||||
|
||||
static int recvmsg(struct rt_can_device *can, void *buf, rt_uint32_t boxno)
|
||||
{
|
||||
CAN_TypeDef *pbxcan;
|
||||
|
||||
struct rt_can_msg *pmsg = (struct rt_can_msg *) buf;
|
||||
int i;
|
||||
|
||||
pbxcan = ((struct ls1c_bxcan *) can->parent.user_data)->reg;
|
||||
|
||||
pmsg->ide = (rt_uint32_t) RxMessage.IDE;
|
||||
if(RxMessage.IDE == 1)
|
||||
pmsg->id = RxMessage.ExtId;
|
||||
else
|
||||
pmsg->id = RxMessage.StdId;
|
||||
pmsg->len = RxMessage.DLC;
|
||||
pmsg->rtr = RxMessage.RTR;
|
||||
pmsg->hdr = 0;
|
||||
for(i= 0;i< RxMessage.DLC; i++)
|
||||
{
|
||||
pmsg->data[i] = RxMessage.Data[i];
|
||||
}
|
||||
return RT_EOK;
|
||||
}
|
||||
|
||||
static const struct rt_can_ops canops =
|
||||
{
|
||||
configure,
|
||||
control,
|
||||
sendmsg,
|
||||
recvmsg,
|
||||
};
|
||||
|
||||
#ifdef USING_BXCAN0
|
||||
struct rt_can_device bxcan0;
|
||||
void ls1c_can0_irqhandler(int irq, void *param)
|
||||
{
|
||||
CAN_TypeDef* CANx;
|
||||
unsigned char status;
|
||||
CANx = CAN0;
|
||||
/*读寄存器清除中断*/
|
||||
status = CANx->IR;
|
||||
|
||||
/*接收中断*/
|
||||
if (( status & CAN_IR_RI) == CAN_IR_RI)
|
||||
{
|
||||
/*清除RI 中断*/
|
||||
CAN_Receive(CANx, &RxMessage);
|
||||
CANx->CMR |= CAN_CMR_RRB;
|
||||
CANx->CMR |= CAN_CMR_CDO;
|
||||
rt_hw_can_isr(&bxcan0, RT_CAN_EVENT_RX_IND);
|
||||
rt_kprintf("\r\nCan0 int RX happened!\r\n");
|
||||
}
|
||||
/*发送中断*/
|
||||
else if (( status & CAN_IR_TI) == CAN_IR_TI)
|
||||
{
|
||||
rt_hw_can_isr(&bxcan0, RT_CAN_EVENT_TX_DONE | 0 << 8);
|
||||
rt_kprintf("\r\nCan0 int TX happened!\r\n");
|
||||
}
|
||||
/*数据溢出中断*/
|
||||
else if (( status & CAN_IR_TI) == CAN_IR_DOI)
|
||||
{
|
||||
rt_hw_can_isr(&bxcan0, RT_CAN_EVENT_RXOF_IND);
|
||||
rt_kprintf("\r\nCan0 int RX OF happened!\r\n");
|
||||
}
|
||||
}
|
||||
static struct ls1c_bxcan bxcan0data =
|
||||
{
|
||||
.reg = CAN0,
|
||||
.irq = ls1c_can0_irqhandler,
|
||||
};
|
||||
#endif /*USING_BXCAN0*/
|
||||
|
||||
#ifdef USING_BXCAN1
|
||||
struct rt_can_device bxcan1;
|
||||
void ls1c_can1_irqhandler(int irq, void *param)
|
||||
{
|
||||
CAN_TypeDef* CANx;
|
||||
unsigned char status;
|
||||
CANx = CAN1;
|
||||
/*读寄存器清除中断*/
|
||||
status = CANx->IR;
|
||||
|
||||
/*接收中断*/
|
||||
if (( status & CAN_IR_RI) == CAN_IR_RI)
|
||||
{
|
||||
/*清除RI 中断*/
|
||||
CAN_Receive(CANx, &RxMessage);
|
||||
CANx->CMR |= CAN_CMR_RRB;
|
||||
CANx->CMR |= CAN_CMR_CDO;
|
||||
rt_hw_can_isr(&bxcan1, RT_CAN_EVENT_RX_IND);
|
||||
rt_kprintf("\r\nCan1 int RX happened!\r\n");
|
||||
}
|
||||
/*发送中断*/
|
||||
else if (( status & CAN_IR_TI) == CAN_IR_TI)
|
||||
{
|
||||
rt_hw_can_isr(&bxcan1, RT_CAN_EVENT_TX_DONE | 0 << 8);
|
||||
rt_kprintf("\r\nCan1 int TX happened!\r\n");
|
||||
}
|
||||
/*数据溢出中断*/
|
||||
else if (( status & CAN_IR_TI) == CAN_IR_DOI)
|
||||
{
|
||||
rt_hw_can_isr(&bxcan1, RT_CAN_EVENT_RXOF_IND);
|
||||
rt_kprintf("\r\nCan1 int RX OF happened!\r\n");
|
||||
}
|
||||
}
|
||||
static struct ls1c_bxcan bxcan1data =
|
||||
{
|
||||
.reg = CAN1,
|
||||
.irq = ls1c_can1_irqhandler,
|
||||
};
|
||||
|
||||
#endif /*USING_BXCAN1*/
|
||||
|
||||
int ls1c_bxcan_init(void)
|
||||
{
|
||||
|
||||
#ifdef USING_BXCAN0
|
||||
bxcan0.config.baud_rate = CAN250kBaud;
|
||||
bxcan0.config.msgboxsz = 1;
|
||||
bxcan0.config.sndboxnumber = 1;
|
||||
bxcan0.config.mode = RT_CAN_MODE_NORMAL;
|
||||
bxcan0.config.privmode = 0;
|
||||
bxcan0.config.ticks = 50;
|
||||
#ifdef RT_CAN_USING_HDR
|
||||
bxcan0.config.maxhdr = 2;
|
||||
#endif
|
||||
rt_hw_can_register(&bxcan0, "bxcan0", &canops, &bxcan0data);
|
||||
rt_kprintf("\r\ncan0 register! \r\n");
|
||||
|
||||
rt_hw_interrupt_install(LS1C_CAN0_IRQ,( rt_isr_handler_t)bxcan0data.irq , RT_NULL, "can0");
|
||||
rt_hw_interrupt_umask(LS1C_CAN0_IRQ);
|
||||
#endif
|
||||
#ifdef USING_BXCAN1
|
||||
bxcan1.config.baud_rate = CAN250kBaud;
|
||||
bxcan1.config.msgboxsz = 1;
|
||||
bxcan1.config.sndboxnumber = 1;
|
||||
bxcan1.config.mode = RT_CAN_MODE_NORMAL;
|
||||
bxcan1.config.privmode = 0;
|
||||
bxcan1.config.ticks = 50;
|
||||
#ifdef RT_CAN_USING_HDR
|
||||
bxcan1.config.maxhdr = 2;
|
||||
#endif
|
||||
rt_hw_can_register(&bxcan1, "bxcan1", &canops, &bxcan1data);
|
||||
rt_kprintf("\r\ncan1 register! \r\n");
|
||||
|
||||
rt_hw_interrupt_install(LS1C_CAN1_IRQ,( rt_isr_handler_t)bxcan1data.irq , RT_NULL, "can1");
|
||||
rt_hw_interrupt_umask(LS1C_CAN1_IRQ);
|
||||
#endif
|
||||
return RT_EOK;
|
||||
}
|
||||
|
||||
INIT_BOARD_EXPORT(ls1c_bxcan_init);
|
||||
|
||||
#endif /*RT_USING_CAN*/
|
|
@ -0,0 +1,30 @@
|
|||
/*
|
||||
* File : bxcan.h
|
||||
* This file is part of RT-Thread RTOS
|
||||
* COPYRIGHT (C) 2006 - 2018, RT-Thread Development Team
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 2 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License along
|
||||
* with this program; if not, write to the Free Software Foundation, Inc.,
|
||||
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*
|
||||
* Change Logs:
|
||||
* Date Author Notes
|
||||
* 2018-01-06 sundm75 first version
|
||||
*/
|
||||
|
||||
#ifndef LS1C_DRV_CAN_H
|
||||
#define LS1C_DRV_CAN_H
|
||||
|
||||
extern int ls1c_bxcan_init(void);
|
||||
|
||||
#endif /*DRV_CAN_H_*/
|
|
@ -25,7 +25,9 @@
|
|||
#include <rtthread.h>
|
||||
#include <drivers/spi.h>
|
||||
#include "drv_spi.h"
|
||||
#include "../libraries/ls1c_pin.h"
|
||||
|
||||
#ifdef RT_USING_SPI
|
||||
|
||||
//#define DEBUG
|
||||
|
||||
|
@ -226,4 +228,66 @@ rt_err_t ls1c_spi_bus_register(rt_uint8_t SPI, const char *spi_bus_name)
|
|||
return rt_spi_bus_register(spi_bus, spi_bus_name, &ls1c_spi_ops);
|
||||
}
|
||||
|
||||
int ls1c_hw_spi_init(void)
|
||||
{
|
||||
#ifdef RT_USING_SPI0
|
||||
pin_set_purpose(78, PIN_PURPOSE_OTHER);
|
||||
pin_set_purpose(79, PIN_PURPOSE_OTHER);
|
||||
pin_set_purpose(80, PIN_PURPOSE_OTHER);
|
||||
pin_set_purpose(83, PIN_PURPOSE_OTHER);//cs2 - SD card
|
||||
pin_set_purpose(82, PIN_PURPOSE_OTHER);//cs1
|
||||
|
||||
pin_set_remap(78, PIN_REMAP_FOURTH);
|
||||
pin_set_remap(79, PIN_REMAP_FOURTH);
|
||||
pin_set_remap(80, PIN_REMAP_FOURTH);
|
||||
pin_set_remap(83, PIN_REMAP_FOURTH);//cs2 - SD card
|
||||
pin_set_remap(82, PIN_REMAP_FOURTH);//cs1
|
||||
ls1c_spi_bus_register(LS1C_SPI_0,"spi0");
|
||||
#endif
|
||||
|
||||
#ifdef RT_USING_SPI1
|
||||
pin_set_purpose(46, PIN_PURPOSE_OTHER);
|
||||
pin_set_purpose(47, PIN_PURPOSE_OTHER);
|
||||
pin_set_purpose(48, PIN_PURPOSE_OTHER);
|
||||
pin_set_purpose(49, PIN_PURPOSE_OTHER);//CS0 - touch screen
|
||||
pin_set_remap(46, PIN_REMAP_THIRD);
|
||||
pin_set_remap(47, PIN_REMAP_THIRD);
|
||||
pin_set_remap(48, PIN_REMAP_THIRD);
|
||||
pin_set_remap(49, PIN_REMAP_THIRD);//CS0 - touch screen
|
||||
ls1c_spi_bus_register(LS1C_SPI_1,"spi1");
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
#ifdef RT_USING_SPI0
|
||||
/* attach cs */
|
||||
{
|
||||
static struct rt_spi_device spi_device1;
|
||||
static struct rt_spi_device spi_device2;
|
||||
static struct ls1c_spi_cs spi_cs1;
|
||||
static struct ls1c_spi_cs spi_cs2;
|
||||
|
||||
/* spi02: CS2 SD Card*/
|
||||
spi_cs2.cs = LS1C_SPI_CS_2;
|
||||
rt_spi_bus_attach_device(&spi_device2, "spi02", "spi0", (void*)&spi_cs2);
|
||||
spi_cs1.cs = LS1C_SPI_CS_1;
|
||||
rt_spi_bus_attach_device(&spi_device1, "spi01", "spi0", (void*)&spi_cs1);
|
||||
msd_init("sd0", "spi02");
|
||||
}
|
||||
#endif
|
||||
#ifdef RT_USING_SPI1
|
||||
{
|
||||
static struct rt_spi_device spi_device;
|
||||
static struct ls1c_spi_cs spi_cs;
|
||||
|
||||
/* spi10: CS0 Touch*/
|
||||
spi_cs.cs = LS1C_SPI_CS_0;
|
||||
rt_spi_bus_attach_device(&spi_device, "spi10", "spi1", (void*)&spi_cs);
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
INIT_BOARD_EXPORT(ls1c_hw_spi_init);
|
||||
|
||||
#endif
|
||||
|
||||
|
|
|
@ -0,0 +1,176 @@
|
|||
/*
|
||||
* File :hw_i2c.c
|
||||
* This file is part of RT-Thread RTOS
|
||||
* COPYRIGHT (C) 2006 - 2017, RT-Thread Development Team
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 2 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License along
|
||||
* with this program; if not, write to the Free Software Foundation, Inc.,
|
||||
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*
|
||||
* Change Logs:
|
||||
* Date Author Notes
|
||||
* 2018-01-04 Sundm75 the first version
|
||||
*/
|
||||
|
||||
#include <rtthread.h>
|
||||
#include <rtdevice.h>
|
||||
#include "ls1c_i2c.h"
|
||||
#include "../libraries/ls1c_pin.h"
|
||||
|
||||
#ifdef RT_USING_I2C
|
||||
|
||||
struct ls1c_i2c_bus
|
||||
{
|
||||
struct rt_i2c_bus_device parent;
|
||||
rt_uint32_t u32Module;
|
||||
};
|
||||
|
||||
rt_size_t rt_i2c_master_xfer(struct rt_i2c_bus_device *bus,
|
||||
struct rt_i2c_msg *msgs,
|
||||
rt_uint32_t num)
|
||||
{
|
||||
struct ls1c_i2c_bus * i2c_bus = (struct ls1c_i2c_bus *)bus;
|
||||
ls1c_i2c_info_t i2c_info;
|
||||
struct rt_i2c_msg *msg;
|
||||
int i;
|
||||
rt_int32_t ret = RT_EOK;
|
||||
i2c_info.clock = 50000; // 50kb/s
|
||||
i2c_info.I2Cx = i2c_bus->u32Module;
|
||||
i2c_init(&i2c_info);
|
||||
|
||||
for (i = 0; i < num; i++)
|
||||
{
|
||||
msg = &msgs[i];
|
||||
if (msg->flags == RT_I2C_RD)
|
||||
{
|
||||
i2c_send_start_and_addr(&i2c_info, msg->addr, LS1C_I2C_DIRECTION_READ);
|
||||
i2c_receive_ack(&i2c_info);
|
||||
i2c_receive_data(&i2c_info, (rt_uint8_t *)msg->buf, msg->len);
|
||||
i2c_send_stop(&i2c_info);
|
||||
}
|
||||
else if(msg->flags == RT_I2C_WR)
|
||||
{
|
||||
i2c_send_start_and_addr(&i2c_info, msg->addr, LS1C_I2C_DIRECTION_WRITE);
|
||||
i2c_receive_ack(&i2c_info);
|
||||
i2c_send_data(&i2c_info, (rt_uint8_t *)msg->buf, msg->len);
|
||||
i2c_send_stop(&i2c_info);
|
||||
}
|
||||
ret++;
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
rt_err_t rt_i2c_bus_control(struct rt_i2c_bus_device *bus,
|
||||
rt_uint32_t cmd,
|
||||
rt_uint32_t arg)
|
||||
{
|
||||
struct ls1c_i2c_bus * i2c_bus = (struct ls1c_i2c_bus *)bus;
|
||||
|
||||
RT_ASSERT(bus != RT_NULL);
|
||||
i2c_bus = (struct ls1c_i2c_bus *)bus->parent.user_data;
|
||||
|
||||
RT_ASSERT(i2c_bus != RT_NULL);
|
||||
|
||||
switch (cmd)
|
||||
{
|
||||
case RT_DEVICE_CTRL_CONFIG :
|
||||
break;
|
||||
}
|
||||
|
||||
return RT_EOK;
|
||||
}
|
||||
|
||||
static const struct rt_i2c_bus_device_ops ls1c_i2c_ops =
|
||||
{
|
||||
rt_i2c_master_xfer,
|
||||
RT_NULL,
|
||||
rt_i2c_bus_control
|
||||
};
|
||||
|
||||
|
||||
#ifdef RT_USING_I2C0
|
||||
static struct ls1c_i2c_bus ls1c_i2c_bus_0 =
|
||||
{
|
||||
{1},
|
||||
LS1C_I2C_0,
|
||||
};
|
||||
#endif
|
||||
|
||||
#ifdef RT_USING_I2C1
|
||||
static struct ls1c_i2c_bus ls1c_i2c_bus_1 =
|
||||
{
|
||||
{1},
|
||||
LS1C_I2C_1,
|
||||
};
|
||||
#endif
|
||||
|
||||
#ifdef RT_USING_I2C2
|
||||
static struct ls1c_i2c_bus ls1c_i2c_bus_2 =
|
||||
{
|
||||
{1},
|
||||
LS1C_I2C_2,
|
||||
};
|
||||
#endif
|
||||
|
||||
int ls1c_hw_i2c_init(void)
|
||||
{
|
||||
struct ls1c_i2c_bus* ls1c_i2c;
|
||||
|
||||
#ifdef RT_USING_I2C0
|
||||
/*
|
||||
pin_set_purpose(2, PIN_PURPOSE_OTHER);
|
||||
pin_set_purpose(3, PIN_PURPOSE_OTHER);
|
||||
pin_set_remap(2, PIN_REMAP_SECOND);
|
||||
pin_set_remap(3, PIN_REMAP_SECOND);
|
||||
*/
|
||||
#endif
|
||||
#ifdef RT_USING_I2C1
|
||||
pin_set_purpose(2, PIN_PURPOSE_OTHER);
|
||||
pin_set_purpose(3, PIN_PURPOSE_OTHER);
|
||||
pin_set_remap(2, PIN_REMAP_SECOND);
|
||||
pin_set_remap(3, PIN_REMAP_SECOND);
|
||||
#endif
|
||||
#ifdef RT_USING_I2C2
|
||||
pin_set_purpose(51, PIN_PURPOSE_OTHER);
|
||||
pin_set_purpose(50, PIN_PURPOSE_OTHER);
|
||||
pin_set_remap(51, PIN_REMAP_FOURTH);
|
||||
pin_set_remap(50, PIN_REMAP_FOURTH);
|
||||
#endif
|
||||
|
||||
|
||||
#ifdef RT_USING_I2C0
|
||||
ls1c_i2c = &ls1c_i2c_bus_0;
|
||||
ls1c_i2c->parent.ops = &ls1c_i2c_ops;
|
||||
rt_i2c_bus_device_register(&ls1c_i2c->parent, "i2c0");
|
||||
rt_kprintf("i2c0_init!\n");
|
||||
#endif
|
||||
#ifdef RT_USING_I2C1
|
||||
ls1c_i2c = &ls1c_i2c_bus_1;
|
||||
ls1c_i2c->parent.ops = &ls1c_i2c_ops;
|
||||
rt_i2c_bus_device_register(&ls1c_i2c->parent, "i2c1");
|
||||
rt_kprintf("i2c1_init!\n");
|
||||
#endif
|
||||
|
||||
#ifdef RT_USING_I2C2
|
||||
ls1c_i2c = &ls1c_i2c_bus_2;
|
||||
ls1c_i2c->parent.ops = &ls1c_i2c_ops;
|
||||
rt_i2c_bus_device_register(&ls1c_i2c->parent, "i2c2");
|
||||
rt_kprintf("i2c2_init!\n");
|
||||
#endif
|
||||
|
||||
return RT_EOK;
|
||||
}
|
||||
|
||||
INIT_BOARD_EXPORT(ls1c_hw_i2c_init);
|
||||
|
||||
#endif
|
|
@ -0,0 +1,32 @@
|
|||
/*
|
||||
* File : hw_i2c.h
|
||||
* This file is part of RT-Thread RTOS
|
||||
* COPYRIGHT (C) 2006 - 2017, RT-Thread Development Team
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 2 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License along
|
||||
* with this program; if not, write to the Free Software Foundation, Inc.,
|
||||
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*
|
||||
* Change Logs:
|
||||
* Date Author Notes
|
||||
* 2018-01-04 Sundm75 the first version
|
||||
*/
|
||||
|
||||
#ifndef LS1C_I2C_H
|
||||
#define LS1C_I2C_H
|
||||
|
||||
#include <rtthread.h>
|
||||
|
||||
int rt_i2c_init(void);
|
||||
|
||||
#endif
|
|
@ -0,0 +1,611 @@
|
|||
/*
|
||||
* File : touch.c
|
||||
* This file is part of RT-Thread RTOS
|
||||
* COPYRIGHT (C) 2006 - 2012, RT-Thread Development Team
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 2 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License along
|
||||
* with this program; if not, write to the Free Software Foundation, Inc.,
|
||||
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*
|
||||
* Change Logs:
|
||||
* Date Author Notes
|
||||
* 2017-12-30 Sundm75 first version
|
||||
*/
|
||||
|
||||
#include <rtthread.h>
|
||||
#include <rtdevice.h>
|
||||
#include <stdbool.h>
|
||||
#include <drivers/spi.h>
|
||||
#include "ls1c.h"
|
||||
#include "ls1c_gpio.h"
|
||||
#include "ls1c_spi.h"
|
||||
#include "drv_spi.h"
|
||||
#include "touch.h"
|
||||
|
||||
#ifdef RT_USING_RTGUI
|
||||
|
||||
#include <rtgui/calibration.h>
|
||||
#include <rtgui/event.h>
|
||||
#include <rtgui/kbddef.h>
|
||||
#include <rtgui/rtgui_server.h>
|
||||
#include <rtgui/rtgui_system.h>
|
||||
|
||||
//竖屏幕 不需要 _ILI_HORIZONTAL_DIRECTION_
|
||||
//横屏幕 需要 _ILI_HORIZONTAL_DIRECTION_
|
||||
|
||||
//#define _ILI_HORIZONTAL_DIRECTION_
|
||||
|
||||
#if defined(_ILI_HORIZONTAL_DIRECTION_)
|
||||
#define X_WIDTH 272
|
||||
#define Y_WIDTH 480
|
||||
#else
|
||||
#define X_WIDTH 480
|
||||
#define Y_WIDTH 272
|
||||
#endif
|
||||
/*
|
||||
TOUCH INT: 84
|
||||
*/
|
||||
#define IS_TOUCH_UP() gpio_get(TOUCH_INT_PIN)
|
||||
|
||||
#define led_gpio 52 // led1指示
|
||||
|
||||
#define DUMMY 0x00
|
||||
|
||||
/*
|
||||
7 6 - 4 3 2 1-0
|
||||
s A2-A0 MODE SER/DFR PD1-PD0
|
||||
*/
|
||||
/* bit[1:0] power-down */
|
||||
#define POWER_MODE0 (0) /* Power-Down Between Conversions. When */
|
||||
/* each conversion is finished, the converter */
|
||||
/* enters a low-power mode. At the start of the */
|
||||
/* next conversion, the device instantly powers up */
|
||||
/* to full power. There is no need for additional */
|
||||
/* delays to ensure full operation, and the very first */
|
||||
/* conversion is valid. The Y? switch is on when in */
|
||||
/* power-down.*/
|
||||
#define POWER_MODE1 (1) /* Reference is off and ADC is on. */
|
||||
#define POWER_MODE2 (2) /* Reference is on and ADC is off. */
|
||||
#define POWER_MODE3 (3) /* Device is always powered. Reference is on and */
|
||||
/* ADC is on. */
|
||||
/* bit[2] SER/DFR */
|
||||
#define DIFFERENTIAL (0<<2)
|
||||
#define SINGLE_ENDED (1<<2)
|
||||
/* bit[3] mode */
|
||||
#define MODE_12BIT (0<<3)
|
||||
#define MODE_8BIT (1<<3)
|
||||
/* bit[6:4] differential mode */
|
||||
#define MEASURE_X (((1<<2) | (0<<1) | (1<<0))<<4)
|
||||
#define MEASURE_Y (((0<<2) | (0<<1) | (1<<0))<<4)
|
||||
#define MEASURE_Z1 (((0<<2) | (1<<1) | (1<<0))<<4)
|
||||
#define MEASURE_Z2 (((1<<2) | (0<<1) | (0<<0))<<4)
|
||||
/* bit[7] start */
|
||||
#define START (1<<7)
|
||||
|
||||
/* X Y change. */
|
||||
#define TOUCH_MSR_X (START | MEASURE_X | MODE_12BIT | DIFFERENTIAL | POWER_MODE0)
|
||||
#define TOUCH_MSR_Y (START | MEASURE_Y | MODE_12BIT | DIFFERENTIAL | POWER_MODE0)
|
||||
|
||||
|
||||
/* 以下定义XPT2046 的触摸屏位置*/
|
||||
#if defined(_ILI_HORIZONTAL_DIRECTION_)
|
||||
#define MIN_X_DEFAULT 2047
|
||||
#define MAX_X_DEFAULT 47
|
||||
#define MIN_Y_DEFAULT 102
|
||||
#define MAX_Y_DEFAULT 1939
|
||||
#else
|
||||
#define MIN_X_DEFAULT 47
|
||||
#define MAX_X_DEFAULT 2047
|
||||
#define MIN_Y_DEFAULT 1939
|
||||
#define MAX_Y_DEFAULT 102
|
||||
#endif
|
||||
|
||||
|
||||
|
||||
#define SAMP_CNT 8 //the adc array size
|
||||
#define SAMP_CNT_DIV2 4 //the middle of the adc array
|
||||
#define SH 10 // Valve value
|
||||
|
||||
|
||||
/*宏定义 */
|
||||
#define TOUCH_SPI_X SPI1
|
||||
#define TOUCH_INT_PIN 84
|
||||
#define TOUCH_CS_PIN 49
|
||||
#define TOUCH_SCK_PIN 46
|
||||
#define TOUCH_MISO_PIN 47
|
||||
#define TOUCH_MOSI_PIN 48
|
||||
|
||||
|
||||
/*创建结构体将需要用到的东西进行打包*/
|
||||
struct rtgui_touch_device
|
||||
{
|
||||
struct rt_device parent; /* 用于注册设备*/
|
||||
|
||||
rt_uint16_t x, y; /* 记录读取到的位置值 */
|
||||
|
||||
rt_bool_t calibrating; /* 触摸校准标志 */
|
||||
rt_touch_calibration_func_t calibration_func;/* 触摸函数 函数指针 */
|
||||
|
||||
rt_uint16_t min_x, max_x; /* 校准后 X 方向最小 最大值 */
|
||||
rt_uint16_t min_y, max_y; /* 校准后 Y 方向最小 最大值 */
|
||||
|
||||
struct rt_spi_device * spi_device; /* SPI 设备 用于通信 */
|
||||
struct rt_event event; /* 事件同步,用于“笔中断” */
|
||||
};
|
||||
static struct rtgui_touch_device *touch = RT_NULL;
|
||||
|
||||
static rt_err_t touch_send_then_recv(struct rt_spi_device *device,
|
||||
const void *send_buf,
|
||||
rt_size_t send_length,
|
||||
void *recv_buf,
|
||||
rt_size_t recv_length)
|
||||
{
|
||||
rt_err_t result;
|
||||
struct rt_spi_message message;
|
||||
rt_uint8_t dummy[128] ;
|
||||
|
||||
rt_memset(dummy, DUMMY, sizeof(dummy));
|
||||
|
||||
RT_ASSERT(device != RT_NULL);
|
||||
RT_ASSERT(device->bus != RT_NULL);
|
||||
|
||||
result = rt_mutex_take(&(device->bus->lock), RT_WAITING_FOREVER);
|
||||
if (result == RT_EOK)
|
||||
{
|
||||
if (device->bus->owner != device)
|
||||
{
|
||||
/* not the same owner as current, re-configure SPI bus */
|
||||
result = device->bus->ops->configure(device, &device->config);
|
||||
if (result == RT_EOK)
|
||||
{
|
||||
/* set SPI bus owner */
|
||||
device->bus->owner = device;
|
||||
}
|
||||
else
|
||||
{
|
||||
/* configure SPI bus failed */
|
||||
result = -RT_EIO;
|
||||
goto __exit;
|
||||
}
|
||||
}
|
||||
|
||||
/* send data */
|
||||
message.send_buf = send_buf;
|
||||
message.recv_buf = RT_NULL;
|
||||
message.length = send_length;
|
||||
message.cs_take = 1;
|
||||
message.cs_release = 0;
|
||||
message.next = RT_NULL;
|
||||
|
||||
result = device->bus->ops->xfer(device, &message);
|
||||
if (result == 0)
|
||||
{
|
||||
result = -RT_EIO;
|
||||
goto __exit;
|
||||
}
|
||||
|
||||
/* recv data */
|
||||
message.send_buf = dummy;
|
||||
message.recv_buf = recv_buf;
|
||||
message.length = recv_length;
|
||||
message.cs_take = 0;
|
||||
message.cs_release = 1;
|
||||
message.next = RT_NULL;
|
||||
|
||||
result = device->bus->ops->xfer(device, &message);
|
||||
if (result == 0)
|
||||
{
|
||||
result = -RT_EIO;
|
||||
goto __exit;
|
||||
}
|
||||
|
||||
result = RT_EOK;
|
||||
}
|
||||
else
|
||||
{
|
||||
return -RT_EIO;
|
||||
}
|
||||
|
||||
__exit:
|
||||
rt_mutex_release(&(device->bus->lock));
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
static void rtgui_touch_calculate(void)
|
||||
{
|
||||
if (touch != RT_NULL)
|
||||
{
|
||||
/* read touch */
|
||||
{
|
||||
rt_uint8_t i, j, k, min;
|
||||
rt_uint16_t temp;
|
||||
rt_uint16_t tmpxy[2][SAMP_CNT];
|
||||
rt_uint8_t send_buffer[1];
|
||||
rt_uint8_t recv_buffer[2];
|
||||
for(i=0; i<SAMP_CNT; i++)
|
||||
{
|
||||
send_buffer[0] = TOUCH_MSR_X;
|
||||
touch_send_then_recv(touch->spi_device, send_buffer, 1, recv_buffer, 2);
|
||||
rt_kprintf("touch x: %d ",(recv_buffer[0]*256|recv_buffer[1])>>4);
|
||||
#if defined(_ILI_HORIZONTAL_DIRECTION_)
|
||||
tmpxy[1][i] = (recv_buffer[0]<<8)|recv_buffer[1] ;
|
||||
tmpxy[1][i] >>= 4;
|
||||
#else
|
||||
tmpxy[0][i] = (recv_buffer[0]<<8)|recv_buffer[1] ;
|
||||
tmpxy[0][i] >>=4;
|
||||
|
||||
#endif
|
||||
send_buffer[0] = TOUCH_MSR_Y;
|
||||
touch_send_then_recv(touch->spi_device, send_buffer, 1, recv_buffer, 2);
|
||||
rt_kprintf("touch y: %d \n",(recv_buffer[0]*256|recv_buffer[1])>>4);
|
||||
|
||||
#if defined(_ILI_HORIZONTAL_DIRECTION_)
|
||||
tmpxy[0][i] = (recv_buffer[0]<<8)|recv_buffer[1] ;
|
||||
tmpxy[0][i] >>= 4;
|
||||
#else
|
||||
tmpxy[1][i] = (recv_buffer[0]<<8)|recv_buffer[1] ;
|
||||
tmpxy[1][i] >>= 4;
|
||||
#endif
|
||||
}
|
||||
/*再次打开触摸中断*/
|
||||
send_buffer[0] = 1 << 7;
|
||||
touch_send_then_recv(touch->spi_device, send_buffer, 1, recv_buffer, 2);
|
||||
touch_send_then_recv(touch->spi_device, send_buffer, 1, recv_buffer, 2);
|
||||
/* calculate average */
|
||||
{
|
||||
rt_uint32_t total_x = 0;
|
||||
rt_uint32_t total_y = 0;
|
||||
for(k=0; k<2; k++)
|
||||
{
|
||||
// sorting the ADC value
|
||||
for(i=0; i<SAMP_CNT-1; i++)
|
||||
{
|
||||
min=i;
|
||||
for (j=i+1; j<SAMP_CNT; j++)
|
||||
{
|
||||
if (tmpxy[k][min] > tmpxy[k][j])
|
||||
min=j;
|
||||
}
|
||||
temp = tmpxy[k][i];
|
||||
tmpxy[k][i] = tmpxy[k][min];
|
||||
tmpxy[k][min] = temp;
|
||||
}
|
||||
//check value for Valve value
|
||||
if((tmpxy[k][SAMP_CNT_DIV2+1]-tmpxy[k][SAMP_CNT_DIV2-2]) > SH)
|
||||
{
|
||||
return;
|
||||
}
|
||||
}
|
||||
total_x=tmpxy[0][SAMP_CNT_DIV2-2]+tmpxy[0][SAMP_CNT_DIV2-1]+tmpxy[0][SAMP_CNT_DIV2]+tmpxy[0][SAMP_CNT_DIV2+1];
|
||||
total_y=tmpxy[1][SAMP_CNT_DIV2-2]+tmpxy[1][SAMP_CNT_DIV2-1]+tmpxy[1][SAMP_CNT_DIV2]+tmpxy[1][SAMP_CNT_DIV2+1];
|
||||
//calculate average value
|
||||
touch->x=total_x>>2;
|
||||
touch->y=total_y>>2;
|
||||
rt_kprintf("touch->x:%d touch->y:%d\r\n", touch->x, touch->y);
|
||||
} /* calculate average */
|
||||
} /* read touch */
|
||||
|
||||
/* if it's not in calibration status */
|
||||
/*触摸值缩放*/
|
||||
if (touch->calibrating != RT_TRUE)
|
||||
{
|
||||
if (touch->max_x > touch->min_x)
|
||||
{
|
||||
touch->x = (touch->x - touch->min_x) * X_WIDTH/(touch->max_x - touch->min_x);
|
||||
}
|
||||
else
|
||||
{
|
||||
touch->x = (touch->min_x - touch->x) * X_WIDTH/(touch->min_x - touch->max_x);
|
||||
}
|
||||
|
||||
if (touch->max_y > touch->min_y)
|
||||
{
|
||||
touch->y = (touch->y - touch->min_y) * Y_WIDTH /(touch->max_y - touch->min_y);
|
||||
}
|
||||
else
|
||||
{
|
||||
touch->y = (touch->min_y - touch->y) * Y_WIDTH /(touch->min_y - touch->max_y);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
#include "ls1c_regs.h"
|
||||
#define TOUCH_INT_EN __REG32(LS1C_INT4_EN)
|
||||
rt_inline void touch_int_cmd(rt_bool_t NewState)
|
||||
{
|
||||
if(NewState == RT_TRUE)
|
||||
{
|
||||
//TOUCH_INT_EN |= (1<<(TOUCH_INT_PIN-64));
|
||||
reg_set_one_bit(LS1C_INT4_EN, 1<<(TOUCH_INT_PIN-64));
|
||||
}
|
||||
else
|
||||
{
|
||||
//TOUCH_INT_EN &=(~ (1<<(TOUCH_INT_PIN-64)));
|
||||
reg_clr_one_bit(LS1C_INT4_EN, 1<<(TOUCH_INT_PIN-64));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
void ls1c_touch_irqhandler(void) /* TouchScreen */
|
||||
{
|
||||
if(gpio_get(TOUCH_INT_PIN)==0)
|
||||
{
|
||||
/* 触摸屏按下后操作 */
|
||||
if (gpio_level_low == gpio_get(led_gpio))
|
||||
gpio_set(led_gpio, gpio_level_high);
|
||||
else
|
||||
gpio_set(led_gpio, gpio_level_low);
|
||||
touch_int_cmd(RT_FALSE);
|
||||
rt_event_send(&touch->event, 1);
|
||||
}
|
||||
}
|
||||
|
||||
/*管脚初始化,配置中断打开SPI1 CS0 设备*/
|
||||
rt_inline void touch_init(void)
|
||||
{
|
||||
unsigned int touch_int_gpio = TOUCH_INT_PIN; // 触摸屏中断
|
||||
int touch_irq = LS1C_GPIO_TO_IRQ(touch_int_gpio);
|
||||
|
||||
// 初始化按键中断
|
||||
gpio_set_irq_type(touch_int_gpio, IRQ_TYPE_EDGE_FALLING);
|
||||
rt_hw_interrupt_install(touch_irq, ls1c_touch_irqhandler, RT_NULL, "touch");
|
||||
rt_hw_interrupt_umask(touch_irq);
|
||||
gpio_init(touch_int_gpio, gpio_mode_input);
|
||||
|
||||
// 初始化led
|
||||
gpio_init(led_gpio, gpio_mode_output);
|
||||
gpio_set(led_gpio, gpio_level_high);
|
||||
}
|
||||
|
||||
|
||||
/* RT-Thread Device Interface */
|
||||
static rt_err_t rtgui_touch_init (rt_device_t dev)
|
||||
{
|
||||
rt_uint8_t send;
|
||||
rt_uint8_t recv_buffer[2];
|
||||
struct rtgui_touch_device * touch_device = (struct rtgui_touch_device *)dev;
|
||||
|
||||
touch_init();
|
||||
rt_kprintf("touch_init ...\n");
|
||||
send = START | DIFFERENTIAL | POWER_MODE0;
|
||||
touch_send_then_recv(touch->spi_device, &send, 1, recv_buffer, 2);
|
||||
|
||||
return RT_EOK;
|
||||
}
|
||||
|
||||
static rt_err_t rtgui_touch_control (rt_device_t dev, int cmd, void *args)
|
||||
{
|
||||
switch (cmd)
|
||||
{
|
||||
case RT_TOUCH_CALIBRATION:
|
||||
touch->calibrating = RT_TRUE;
|
||||
touch->calibration_func = (rt_touch_calibration_func_t)args;
|
||||
break;
|
||||
|
||||
case RT_TOUCH_NORMAL:
|
||||
touch->calibrating = RT_FALSE;
|
||||
break;
|
||||
|
||||
case RT_TOUCH_CALIBRATION_DATA:
|
||||
{
|
||||
struct calibration_data* data;
|
||||
data = (struct calibration_data*) args;
|
||||
|
||||
//update
|
||||
touch->min_x = data->min_x;
|
||||
touch->max_x = data->max_x;
|
||||
touch->min_y = data->min_y;
|
||||
touch->max_y = data->max_y;
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
return RT_EOK;
|
||||
}
|
||||
|
||||
void _set_mouse_position(rt_uint32_t X, rt_uint32_t Y)
|
||||
{}
|
||||
static void touch_thread_entry(void *parameter)
|
||||
{
|
||||
rt_bool_t touch_down = RT_FALSE;
|
||||
rt_uint32_t event_value;
|
||||
struct rtgui_event_mouse emouse;
|
||||
static struct _touch_previous
|
||||
{
|
||||
rt_uint32_t x;
|
||||
rt_uint32_t y;
|
||||
} touch_previous;
|
||||
|
||||
RTGUI_EVENT_MOUSE_BUTTON_INIT(&emouse);
|
||||
emouse.wid = RT_NULL;
|
||||
|
||||
while(1)
|
||||
{
|
||||
/* 接收到触摸中断事件 */
|
||||
if(rt_event_recv(&touch->event,
|
||||
1,
|
||||
RT_EVENT_FLAG_OR | RT_EVENT_FLAG_CLEAR,
|
||||
100,
|
||||
&event_value)
|
||||
== RT_EOK)
|
||||
{
|
||||
while(1)
|
||||
{
|
||||
if (IS_TOUCH_UP())
|
||||
{
|
||||
/* 触摸笔抬起 */
|
||||
/* touch up */
|
||||
emouse.button = (RTGUI_MOUSE_BUTTON_LEFT |RTGUI_MOUSE_BUTTON_UP);
|
||||
|
||||
/* use old value */
|
||||
emouse.x = touch->x;
|
||||
emouse.y = touch->y;
|
||||
|
||||
if(touch_down != RT_TRUE)
|
||||
{
|
||||
touch_int_cmd(RT_TRUE);
|
||||
break;
|
||||
}
|
||||
|
||||
if ((touch->calibrating == RT_TRUE) && (touch->calibration_func != RT_NULL))
|
||||
{
|
||||
/* 触摸校准处理 */
|
||||
/* callback function */
|
||||
touch->calibration_func(emouse.x, emouse.y);
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
/* 向ui发送触摸坐标 */
|
||||
rtgui_server_post_event(&emouse.parent, sizeof(struct rtgui_event_mouse));
|
||||
}
|
||||
rt_kprintf("touch up: (%d, %d)\n", emouse.x, emouse.y);
|
||||
|
||||
/* clean */
|
||||
touch_previous.x = touch_previous.y = 0;
|
||||
touch_down = RT_FALSE;
|
||||
|
||||
touch_int_cmd(RT_TRUE);
|
||||
break;
|
||||
} /* touch up */
|
||||
else /* touch down or move */
|
||||
{
|
||||
if(touch_down == RT_FALSE)
|
||||
{
|
||||
rt_thread_delay(RT_TICK_PER_SECOND / 10);
|
||||
}
|
||||
else
|
||||
{
|
||||
rt_thread_delay(5);
|
||||
}
|
||||
|
||||
if(IS_TOUCH_UP()) continue;
|
||||
|
||||
/* calculation */
|
||||
rtgui_touch_calculate();
|
||||
|
||||
/* send mouse event */
|
||||
emouse.parent.type = RTGUI_EVENT_MOUSE_BUTTON;
|
||||
emouse.parent.sender = RT_NULL;
|
||||
|
||||
emouse.x = touch->x;
|
||||
emouse.y = touch->y;
|
||||
_set_mouse_position(emouse.x, emouse.y);
|
||||
/* 光标跟随 */
|
||||
/* init mouse button */
|
||||
emouse.button = (RTGUI_MOUSE_BUTTON_LEFT |RTGUI_MOUSE_BUTTON_DOWN);
|
||||
|
||||
/* send event to server */
|
||||
if (touch->calibrating != RT_TRUE)
|
||||
{
|
||||
#define previous_keep 8
|
||||
/* filter. */
|
||||
if((touch_previous.x > touch->x + previous_keep)
|
||||
|| (touch_previous.x < touch->x - previous_keep)
|
||||
|| (touch_previous.y > touch->y + previous_keep)
|
||||
|| (touch_previous.y < touch->y - previous_keep))
|
||||
{
|
||||
touch_previous.x = touch->x;
|
||||
touch_previous.y = touch->y;
|
||||
/* 向ui发送触摸坐标 */
|
||||
rtgui_server_post_event(&emouse.parent, sizeof(struct rtgui_event_mouse));
|
||||
if(touch_down == RT_FALSE)
|
||||
{
|
||||
touch_down = RT_TRUE;
|
||||
rt_kprintf("touch down: (%d, %d)\n", emouse.x, emouse.y);
|
||||
}
|
||||
else
|
||||
{
|
||||
rt_kprintf("touch motion: (%d, %d)\n", emouse.x, emouse.y);
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
touch_down = RT_TRUE;
|
||||
}
|
||||
} /* touch down or move */
|
||||
} /* read touch */
|
||||
} /* event recv */
|
||||
} /* thread while(1) */
|
||||
}
|
||||
|
||||
|
||||
rt_err_t rtgui_touch_hw_init(const char * spi_device_name)
|
||||
{
|
||||
rt_uint32_t arg[2];
|
||||
struct rt_device * spi_device;
|
||||
struct rt_thread * touch_thread;
|
||||
rt_err_t err;
|
||||
|
||||
rt_kprintf("spi1 cs0 start...\n");
|
||||
spi_device = rt_device_find("spi10");
|
||||
if(spi_device == RT_NULL)
|
||||
{
|
||||
rt_kprintf("Did not find spi1, exit thread....\n");
|
||||
return;
|
||||
}
|
||||
err = rt_device_open(spi_device, RT_DEVICE_OFLAG_RDWR);
|
||||
if(err != RT_EOK)
|
||||
{
|
||||
rt_kprintf("Open spi1 failed %08X, exit thread....\n", err);
|
||||
return;
|
||||
}
|
||||
|
||||
/* config spi */
|
||||
{
|
||||
struct rt_spi_configuration cfg;
|
||||
cfg.data_width = 8;
|
||||
cfg.mode = RT_SPI_MODE_0;
|
||||
cfg.max_hz = 200 * 1000; /* 200K */
|
||||
rt_spi_configure((struct rt_spi_device *)spi_device, &cfg);
|
||||
}
|
||||
|
||||
touch = (struct rtgui_touch_device*)rt_malloc (sizeof(struct rtgui_touch_device));
|
||||
if (touch == RT_NULL) return RT_ENOMEM; /* no memory yet */
|
||||
|
||||
/* clear device structure */
|
||||
rt_memset(&(touch->parent), 0, sizeof(struct rt_device));
|
||||
|
||||
rt_event_init(&touch->event, "touch", RT_IPC_FLAG_FIFO);
|
||||
|
||||
touch->spi_device = (struct rt_spi_device *)spi_device;
|
||||
touch->calibrating = false;
|
||||
|
||||
touch->min_x = MIN_X_DEFAULT;
|
||||
touch->max_x = MAX_X_DEFAULT;
|
||||
touch->min_y = MIN_Y_DEFAULT;
|
||||
touch->max_y = MAX_Y_DEFAULT;
|
||||
|
||||
/* init device structure */
|
||||
touch->parent.type = RT_Device_Class_Miscellaneous;
|
||||
touch->parent.init = rtgui_touch_init;
|
||||
touch->parent.control = rtgui_touch_control;
|
||||
touch->parent.user_data = RT_NULL;
|
||||
|
||||
/* register touch device to RT-Thread */
|
||||
rt_device_register(&(touch->parent), "touch", RT_DEVICE_FLAG_RDWR);
|
||||
|
||||
|
||||
touch_thread = rt_thread_create("touch_thread",
|
||||
touch_thread_entry, RT_NULL,
|
||||
4096, RTGUI_SVR_THREAD_PRIORITY-1, 1);
|
||||
if (touch_thread != RT_NULL) rt_thread_startup(touch_thread);
|
||||
|
||||
rt_device_init((rt_device_t)touch);
|
||||
return RT_EOK;
|
||||
}
|
||||
|
||||
#endif
|
|
@ -0,0 +1,43 @@
|
|||
/*
|
||||
* File : touch.h
|
||||
* This file is part of RT-Thread RTOS
|
||||
* COPYRIGHT (C) 2006 - 2012, RT-Thread Development Team
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 2 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License along
|
||||
* with this program; if not, write to the Free Software Foundation, Inc.,
|
||||
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*
|
||||
* Change Logs:
|
||||
* Date Author Notes
|
||||
* 2017-12-30 Sundm75 first version
|
||||
*/
|
||||
#ifndef __TOUCH_H__
|
||||
#define __TOUCH_H__
|
||||
|
||||
#define RT_TOUCH_NORMAL 0
|
||||
#define RT_TOUCH_CALIBRATION_DATA 1
|
||||
#define RT_TOUCH_CALIBRATION 2
|
||||
|
||||
//#define SAVE_CALIBRATION
|
||||
|
||||
|
||||
rt_uint16_t touch_read_x(void);
|
||||
rt_uint16_t touch_read_y(void);
|
||||
void touch_config(void);
|
||||
|
||||
|
||||
rt_err_t rtgui_touch_hw_init(const char * spi_device_name);
|
||||
|
||||
#endif
|
||||
|
||||
|
|
@ -24,7 +24,7 @@
|
|||
|
||||
/*@{*/
|
||||
|
||||
#if defined(RT_USING_UART) && defined(RT_USING_DEVICE)
|
||||
#if defined(RT_USING_SERIAL) && defined(RT_USING_DEVICE)
|
||||
|
||||
struct rt_uart_ls1c
|
||||
{
|
||||
|
|
|
@ -0,0 +1,79 @@
|
|||
mainmenu "RT-Thread Configuration"
|
||||
|
||||
|
||||
config $BSP_DIR
|
||||
string
|
||||
option env="BSP_ROOT"
|
||||
default "."
|
||||
|
||||
config $RTT_DIR
|
||||
string
|
||||
option env="RTT_ROOT"
|
||||
default "../.."
|
||||
|
||||
config $PKGS_DIR
|
||||
string
|
||||
option env="PKGS_ROOT"
|
||||
default "packages"
|
||||
|
||||
source "$RTT_DIR/KConfig"
|
||||
source "$PKGS_DIR/KConfig"
|
||||
|
||||
if RT_USING_SERIAL
|
||||
config RT_USING_UART2
|
||||
bool "Using RT_USING_UART2"
|
||||
default y
|
||||
|
||||
config RT_UART_RX_BUFFER_SIZE
|
||||
int "The rx buffer size"
|
||||
default 64 if RT_USING_SERIAL
|
||||
default 64
|
||||
endif
|
||||
|
||||
config RT_USING_GMAC_INT_MODE
|
||||
bool "Using RT_USING_GMAC_INT_MODE"
|
||||
default y
|
||||
|
||||
config RT_USING_FPU
|
||||
bool "Using RT_USING_FPU"
|
||||
default y
|
||||
|
||||
config RT_USING_SPI0
|
||||
bool "Enable SPI0"
|
||||
select RT_USING_SPI
|
||||
default y
|
||||
|
||||
config RT_USING_SPI1
|
||||
bool "Enable SPI1"
|
||||
select RT_USING_SPI
|
||||
default y
|
||||
|
||||
if RT_USING_I2C
|
||||
config RT_USING_I2C1
|
||||
bool "Enable I2C1"
|
||||
default y
|
||||
|
||||
config RT_USING_I2C2
|
||||
bool "Enable I2C2"
|
||||
default y
|
||||
endif
|
||||
|
||||
|
||||
config USING_BXCAN0
|
||||
bool "Enable CAN0"
|
||||
select RT_USING_CAN
|
||||
default y
|
||||
|
||||
config USING_BXCAN1
|
||||
bool "Enable CAN1"
|
||||
select RT_USING_CAN
|
||||
default y
|
||||
|
||||
if RT_USING_CAN
|
||||
config RT_CAN_USING_HDR
|
||||
bool "Using RT_CAN_USING_HDR"
|
||||
select RT_USING_CAN
|
||||
default y
|
||||
endif
|
||||
|
||||
|
|
@ -0,0 +1,460 @@
|
|||
/*
|
||||
* File : ls1c_can.c
|
||||
* This file is part of RT-Thread RTOS
|
||||
* COPYRIGHT (C) 2006 - 2018, RT-Thread Development Team
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 2 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License along
|
||||
* with this program; if not, write to the Free Software Foundation, Inc.,
|
||||
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*
|
||||
* Change Logs:
|
||||
* Date Author Notes
|
||||
* 2018-01-06 sundm75 first version
|
||||
*/
|
||||
|
||||
#include "ls1c.h"
|
||||
#include "ls1c_public.h"
|
||||
#include "ls1c_can.h"
|
||||
|
||||
unsigned char set_reset_mode(CAN_TypeDef* CANx)
|
||||
{
|
||||
unsigned char status;
|
||||
int i;
|
||||
|
||||
/*检查复位标志*/
|
||||
status = CANx->MOD;
|
||||
|
||||
/* 关闭中断 */
|
||||
CANx->IER = 0x00;
|
||||
|
||||
for (i = 0; i < 100; i++)
|
||||
{
|
||||
if((status & CAN_Mode_RM) == CAN_Mode_RM)
|
||||
return 1;
|
||||
|
||||
/* 设置复位*/
|
||||
CANx->MOD |= ((unsigned char)CAN_Mode_RM);
|
||||
|
||||
/*延时*/
|
||||
delay_us(10);
|
||||
|
||||
/*检查复位标志*/
|
||||
status = CANx->MOD;
|
||||
}
|
||||
rt_kprintf("\r\nSetting SJA1000 into reset mode failed!\r\n");
|
||||
return 0;
|
||||
}
|
||||
|
||||
static unsigned char set_normal_mode(CAN_TypeDef* CANx)
|
||||
{
|
||||
unsigned char status;
|
||||
int i;
|
||||
|
||||
/*检查复位标志*/
|
||||
status = CANx->MOD;
|
||||
|
||||
for (i = 0; i < 100; i++)
|
||||
{
|
||||
if((status & CAN_Mode_RM) != CAN_Mode_RM)
|
||||
{
|
||||
/*开所有中断 (总线错误中断不开)*/
|
||||
CANx->IER |= (~(unsigned char)CAN_IR_BEI);
|
||||
return 1;
|
||||
}
|
||||
/* 设置正常工作模式*/
|
||||
CANx->MOD &= (~(unsigned char) CAN_Mode_RM);
|
||||
/*延时*/
|
||||
delay_us(10);
|
||||
status = CANx->MOD;
|
||||
}
|
||||
rt_kprintf("\r\nSetting SJA1000 into normal mode failed!\r\n");
|
||||
return 0;
|
||||
}
|
||||
|
||||
unsigned char set_start(CAN_TypeDef* CANx)
|
||||
{
|
||||
/*复位TX错误计数器*/
|
||||
CANx->TXERR = 0;
|
||||
/*复位RX错误计数器*/
|
||||
CANx->RXERR = 0;
|
||||
/*时钟分频寄存器: PeliCAN模式; CBP=1,中止输入比较器, RX0激活*/
|
||||
CANx->CDR = 0xC0;
|
||||
|
||||
return set_normal_mode(CANx);
|
||||
}
|
||||
|
||||
unsigned char CAN_Init(CAN_TypeDef* CANx, CAN_InitTypeDef* CAN_InitStruct)
|
||||
{
|
||||
unsigned char InitStatus = CAN_InitStatus_Failed;
|
||||
unsigned long wait_ack = 0x00000000;
|
||||
unsigned char status;
|
||||
|
||||
status = CANx->MOD;
|
||||
if( status == 0xFF)
|
||||
{
|
||||
rt_kprintf("\n Probe can0 failed \r\n");
|
||||
return CAN_InitStatus_Failed;
|
||||
}
|
||||
|
||||
/* 进入复位模式 */
|
||||
InitStatus = set_reset_mode(CANx);
|
||||
|
||||
if((CAN_InitStruct->CAN_Mode & CAN_Mode_SM) == CAN_Mode_SM)
|
||||
{
|
||||
/* 睡眠模式 1: 睡眠 0: 唤醒*/
|
||||
CANx->MOD|= (unsigned char)CAN_Mode_SM;
|
||||
}
|
||||
else
|
||||
{
|
||||
CANx->MOD&=~ (unsigned char)CAN_Mode_SM;
|
||||
}
|
||||
|
||||
if((CAN_InitStruct->CAN_Mode & CAN_Mode_LOM) == CAN_Mode_LOM)
|
||||
{
|
||||
/*只听模式 1:只听 0:正常 */
|
||||
CANx->MOD|= (unsigned char)CAN_Mode_LOM;
|
||||
}
|
||||
else
|
||||
{
|
||||
CANx->MOD&=~ (unsigned char)CAN_Mode_LOM;
|
||||
}
|
||||
|
||||
if((CAN_InitStruct->CAN_Mode & CAN_Mode_AFM) == CAN_Mode_AFM)
|
||||
{
|
||||
/*单滤波模式 1:单 0: 双*/
|
||||
CANx->MOD |= (unsigned char)CAN_Mode_AFM;
|
||||
}
|
||||
else
|
||||
{
|
||||
CANx->MOD&=~ (unsigned char)CAN_Mode_AFM;
|
||||
}
|
||||
|
||||
if((CAN_InitStruct->CAN_Mode & CAN_Mode_STM) == CAN_Mode_STM)
|
||||
{
|
||||
/*自检测模式 1:自检测 0:正常 */
|
||||
CANx->MOD |= (unsigned char)CAN_Mode_STM;
|
||||
}
|
||||
else
|
||||
{
|
||||
CANx->MOD&=~ (unsigned char)CAN_Mode_STM;
|
||||
}
|
||||
|
||||
/* 配置时钟频率 */
|
||||
CANx->BTR0 = (( unsigned char )( unsigned char )CAN_InitStruct->CAN_Prescaler -1) | \
|
||||
(unsigned char)CAN_InitStruct->CAN_SJW << 6;
|
||||
|
||||
CANx->BTR1 = ((unsigned char)CAN_InitStruct->CAN_BS1) | \
|
||||
((unsigned char)CAN_InitStruct->CAN_BS2 << 4) | \
|
||||
((unsigned char)CAN_InitStruct->CAN_SJW<<7);
|
||||
|
||||
/* 进入工作模式 */
|
||||
set_start(CANx);
|
||||
|
||||
/* 返回初始化结果 */
|
||||
return InitStatus;
|
||||
}
|
||||
|
||||
void CAN_FilterInit(CAN_TypeDef* CANx, CAN_FilterInitTypeDef * CAN_FilterInitStruct)
|
||||
{
|
||||
unsigned long rtr;
|
||||
unsigned long fcase;
|
||||
unsigned long ide;
|
||||
unsigned long thisid, thisid1, thisid2;
|
||||
unsigned long thismask, thismask1, thismask2;
|
||||
unsigned long firstdata;
|
||||
unsigned long datamask;
|
||||
unsigned char CAN_FilterId0, CAN_FilterId1, CAN_FilterId2, CAN_FilterId3 ;
|
||||
unsigned char CAN_FilterMaskId0, CAN_FilterMaskId1, CAN_FilterMaskId2, CAN_FilterMaskId3;
|
||||
|
||||
thisid = CAN_FilterInitStruct->ID;
|
||||
thismask = CAN_FilterInitStruct->IDMASK;
|
||||
thisid1 = (CAN_FilterInitStruct->ID & 0xFFFF0000 )>>16;
|
||||
thismask1 = (CAN_FilterInitStruct->IDMASK & 0xFFFF0000 )>>16;
|
||||
thisid2 = (CAN_FilterInitStruct->ID & 0x0000FFFF );
|
||||
thismask2 = ( CAN_FilterInitStruct->IDMASK& 0x0000FFFF );
|
||||
rtr = CAN_FilterInitStruct->RTR;
|
||||
ide = CAN_FilterInitStruct->IDE;
|
||||
firstdata = CAN_FilterInitStruct->First_Data;
|
||||
datamask = CAN_FilterInitStruct->Data_Mask;
|
||||
fcase = CAN_FilterInitStruct->MODE;
|
||||
|
||||
if(ide == 0)//标准帧
|
||||
{
|
||||
if(fcase == 0)// 0- 双滤波器模式
|
||||
{
|
||||
CAN_FilterId0 = thisid1>>3;
|
||||
CAN_FilterMaskId0 = thismask1>>3;
|
||||
CAN_FilterId1 = thisid1<<5 | firstdata>>4| rtr<<4;
|
||||
CAN_FilterMaskId1 = thismask1<<4 | datamask>>4 ;
|
||||
CAN_FilterId2 = thisid2 >> 3;
|
||||
CAN_FilterMaskId2 = thismask2 >>3;
|
||||
CAN_FilterId3 = firstdata & 0x0F | thisid2 <<5 | rtr<<4;
|
||||
CAN_FilterMaskId3 = datamask <<4 ;
|
||||
}
|
||||
else if(fcase == 1)// 1-单滤波器模式
|
||||
{
|
||||
CAN_FilterId0 = thisid>>3;
|
||||
CAN_FilterMaskId0 = thismask>>3;
|
||||
CAN_FilterId1 = thisid<<5 | rtr<<4;
|
||||
CAN_FilterMaskId1 = thismask<<5 ;
|
||||
CAN_FilterMaskId1 |= 0x0F ;
|
||||
CAN_FilterId2 = 0x00;
|
||||
CAN_FilterMaskId2 = 0xFF;
|
||||
CAN_FilterId3 = 0x00;
|
||||
CAN_FilterMaskId3 = 0xFF ;
|
||||
}
|
||||
}
|
||||
else if(ide == 1)//扩展帧
|
||||
{
|
||||
if(fcase == 0)// 0- 双滤波器模式
|
||||
{
|
||||
CAN_FilterId0 = thisid1>>8;
|
||||
CAN_FilterMaskId0 = thismask1>>8;
|
||||
CAN_FilterId1 = thisid1 ;
|
||||
CAN_FilterMaskId1 = thismask1 ;
|
||||
CAN_FilterId2 = thisid2>>8;
|
||||
CAN_FilterMaskId2 = thismask2>>8;
|
||||
CAN_FilterId3 = thisid2 ;
|
||||
CAN_FilterMaskId3 = thismask2 ;
|
||||
}
|
||||
else if(fcase == 1)// 1-单滤波器模式
|
||||
{
|
||||
CAN_FilterId0 = thisid>>21;
|
||||
CAN_FilterMaskId0 = thismask>>21;
|
||||
CAN_FilterId1 = thisid>>13 ;
|
||||
CAN_FilterMaskId1 = thismask>>13 ;
|
||||
CAN_FilterId2 = thisid>>5;
|
||||
CAN_FilterMaskId2 = thismask>>5;
|
||||
CAN_FilterId3 = thisid<<3 | rtr<<2;
|
||||
CAN_FilterMaskId3 = thismask<<3;
|
||||
CAN_FilterMaskId3 |= 0x03;
|
||||
}
|
||||
}
|
||||
|
||||
/* 进入复位模式 */
|
||||
set_reset_mode(CANx);
|
||||
|
||||
if(fcase == 1)// 1-单滤波器模式
|
||||
{
|
||||
/*单滤波模式 */
|
||||
CANx->MOD |= (unsigned char)CAN_Mode_AFM;
|
||||
}
|
||||
else if(fcase == 1)// 0- 双滤波器模式
|
||||
{
|
||||
/*双滤波模式 */
|
||||
CANx->MOD &=(~ (unsigned char) CAN_Mode_AFM);
|
||||
}
|
||||
|
||||
CANx->IDE_RTR_DLC = CAN_FilterId0;
|
||||
CANx->ID[0] = CAN_FilterId1;
|
||||
CANx->ID[1] = CAN_FilterId2;
|
||||
CANx->ID[2] = CAN_FilterId3;
|
||||
CANx->ID[3] = CAN_FilterMaskId0;
|
||||
CANx->BUF[0] = CAN_FilterMaskId1;
|
||||
CANx->BUF[1] = CAN_FilterMaskId2;
|
||||
CANx->BUF[2] = CAN_FilterMaskId3;
|
||||
/* 进入工作模式 */
|
||||
set_start(CANx);
|
||||
}
|
||||
|
||||
unsigned char CAN_SetBps(CAN_TypeDef* CANx, Ls1c_CanBPS_t Bps)
|
||||
{
|
||||
unsigned char InitStatus = CAN_InitStatus_Failed;
|
||||
unsigned char CAN_Prescaler, CAN_BS1, CAN_BS2, CAN_SJW;
|
||||
CAN_SJW = CAN_SJW_1tq;
|
||||
/* 进入复位模式 */
|
||||
InitStatus = set_reset_mode(CANx);
|
||||
if( InitStatus == CAN_InitStatus_Failed)
|
||||
return CAN_InitStatus_Failed;
|
||||
|
||||
/* BaudRate= f(APB)/((1+BS1+BS2)(SJW*2*Prescaler))=126000000/[(1+7+2)*1*2*63]=100000=100K*/
|
||||
/* BPS PRE BS1 BS2 最低40K
|
||||
1M 9 4 2
|
||||
800K 8 7 2
|
||||
500K 9 11 2
|
||||
250K 36 4 2
|
||||
125K 36 11 2
|
||||
100K 63 7 2
|
||||
50K 63 16 3`
|
||||
40K 63 16 8
|
||||
*/
|
||||
switch (Bps)
|
||||
{
|
||||
case LS1C_CAN1MBaud:
|
||||
CAN_Prescaler = 9;
|
||||
CAN_BS1 = CAN_BS1_4tq;
|
||||
CAN_BS2 = CAN_BS2_2tq;
|
||||
break;
|
||||
case LS1C_CAN800kBaud:
|
||||
CAN_Prescaler = 8;
|
||||
CAN_BS1 = CAN_BS1_7tq;
|
||||
CAN_BS2 = CAN_BS2_2tq;
|
||||
break;
|
||||
case LS1C_CAN500kBaud:
|
||||
CAN_Prescaler = 9;
|
||||
CAN_BS1 = CAN_BS1_11tq;
|
||||
CAN_BS2 = CAN_BS2_2tq;
|
||||
break;
|
||||
case LS1C_CAN250kBaud:
|
||||
CAN_Prescaler = 36;
|
||||
CAN_BS1 = CAN_BS1_4tq;
|
||||
CAN_BS2 = CAN_BS2_2tq;
|
||||
break;
|
||||
case LS1C_CAN125kBaud:
|
||||
CAN_Prescaler = 36;
|
||||
CAN_BS1 = CAN_BS1_11tq;
|
||||
CAN_BS2 = CAN_BS2_2tq;
|
||||
break;
|
||||
case LS1C_CAN100kBaud:
|
||||
CAN_Prescaler = 63;
|
||||
CAN_BS1 = CAN_BS1_7tq;
|
||||
CAN_BS2 = CAN_BS2_2tq;
|
||||
break;
|
||||
case LS1C_CAN50kBaud:
|
||||
CAN_Prescaler = 63;
|
||||
CAN_BS1 = CAN_BS1_16tq;
|
||||
CAN_BS2 = CAN_BS2_3tq;
|
||||
break;
|
||||
case LS1C_CAN40kBaud:
|
||||
CAN_Prescaler = 63;
|
||||
CAN_BS1 = CAN_BS1_16tq;
|
||||
CAN_BS2 = CAN_BS2_8tq;
|
||||
break;
|
||||
default: //100K
|
||||
CAN_Prescaler = 63;
|
||||
CAN_BS1 = CAN_BS1_7tq;
|
||||
CAN_BS2 = CAN_BS2_2tq;
|
||||
break;
|
||||
}
|
||||
/* 配置时钟频率 */
|
||||
CANx->BTR0 = (( unsigned char )CAN_Prescaler -1) | \
|
||||
(unsigned char)CAN_SJW << 6;
|
||||
|
||||
CANx->BTR1 = ((unsigned char)CAN_BS1) | \
|
||||
((unsigned char)CAN_BS2 << 4) | \
|
||||
((unsigned char)CAN_SJW<<7);
|
||||
|
||||
/* 进入工作模式 */
|
||||
set_start(CANx);
|
||||
/* 返回初始化结果 */
|
||||
return CAN_InitStatus_Failed;
|
||||
}
|
||||
|
||||
|
||||
unsigned char CAN_SetMode(CAN_TypeDef* CANx, unsigned char mode)
|
||||
{
|
||||
unsigned char InitStatus = CAN_InitStatus_Failed;
|
||||
unsigned long wait_ack = 0x00000000;
|
||||
CAN_InitTypeDef CAN_InitStructure;
|
||||
|
||||
/* 进入复位模式 */
|
||||
InitStatus = set_reset_mode(CANx);
|
||||
if( InitStatus == CAN_InitStatus_Failed)
|
||||
return CAN_InitStatus_Failed;
|
||||
|
||||
switch( mode )
|
||||
{
|
||||
case 0://正常
|
||||
CANx->MOD &= ~(unsigned char)CAN_Mode_STM;
|
||||
CANx->MOD &= ~(unsigned char)CAN_Mode_LOM;
|
||||
break;
|
||||
case 1://只听
|
||||
CANx->MOD &= ~(unsigned char)CAN_Mode_STM;
|
||||
CANx->MOD |= (unsigned char)CAN_Mode_LOM;
|
||||
break;
|
||||
case 2://回环
|
||||
CANx->MOD |= (unsigned char)CAN_Mode_STM;
|
||||
CANx->MOD &= ~(unsigned char)CAN_Mode_LOM;
|
||||
break;
|
||||
case 3://只听回环
|
||||
CANx->MOD |= (unsigned char)CAN_Mode_STM;
|
||||
CANx->MOD |= (unsigned char)CAN_Mode_LOM;
|
||||
break;
|
||||
}
|
||||
/* 进入工作模式 */
|
||||
set_start(CANx);
|
||||
|
||||
/* 返回初始化结果 */
|
||||
return CAN_InitStatus_Failed;
|
||||
}
|
||||
|
||||
unsigned char CAN_Transmit(CAN_TypeDef* CANx, CanTxMsg* TxMessage)
|
||||
{
|
||||
int i;
|
||||
if (TxMessage->IDE == CAN_Id_Extended)
|
||||
{
|
||||
CANx->ID[0]= TxMessage ->ExtId>> 21;
|
||||
CANx->ID[1]= TxMessage ->ExtId>> 13;
|
||||
CANx->ID[2]= TxMessage ->ExtId>> 5;
|
||||
CANx->ID[3]= TxMessage ->ExtId<<3;
|
||||
CANx->IDE_RTR_DLC= (TxMessage ->IDE & 0x01) << 7 |\
|
||||
(TxMessage ->RTR & 0x01) << 6 |\
|
||||
(TxMessage ->DLC & 0x0F);
|
||||
for( i=0;i<TxMessage ->DLC; i++)
|
||||
{
|
||||
CANx->BUF[i]= TxMessage->Data[i];
|
||||
}
|
||||
}
|
||||
else if (TxMessage->IDE ==CAN_Id_Standard)
|
||||
{
|
||||
CANx->ID[0]= TxMessage ->StdId>> 3;
|
||||
CANx->ID[1]= TxMessage ->StdId<< 5;
|
||||
CANx->IDE_RTR_DLC= (TxMessage ->IDE & 0x01) << 7 |\
|
||||
(TxMessage ->RTR & 0x01) << 6 |\
|
||||
(TxMessage ->DLC & 0x0F);
|
||||
CANx->ID[2]= TxMessage ->Data[0];
|
||||
CANx->ID[3]= TxMessage ->Data[1];
|
||||
for( i=0;i<TxMessage ->DLC-2; i++)
|
||||
{
|
||||
CANx->BUF[i]= TxMessage->Data[i+2];
|
||||
}
|
||||
}
|
||||
CANx->CMR = CAN_CMR_TR ;
|
||||
}
|
||||
|
||||
void CAN_Receive(CAN_TypeDef* CANx, CanRxMsg* RxMessage)
|
||||
{
|
||||
/* 获取 IDE */
|
||||
RxMessage->IDE = (CANx->IDE_RTR_DLC & 0x80)>>7;
|
||||
/* 获取 RTR */
|
||||
RxMessage->RTR = (CANx->IDE_RTR_DLC & 0x40)>>4;
|
||||
/* 获取 DLC */
|
||||
RxMessage->DLC= (CANx->IDE_RTR_DLC & 0x0F);
|
||||
if (RxMessage->IDE == CAN_Id_Standard)
|
||||
{
|
||||
RxMessage->StdId = CANx->ID[0]<<3 |CANx->ID[1]>>5 ;
|
||||
/* 获取数据 */
|
||||
RxMessage->Data[0] = (unsigned char)CANx->ID[2];
|
||||
RxMessage->Data[1] = (unsigned char)CANx->ID[3];
|
||||
RxMessage->Data[2] = (unsigned char)CANx->BUF[0];
|
||||
RxMessage->Data[3] = (unsigned char)CANx->BUF[1];
|
||||
RxMessage->Data[4] = (unsigned char)CANx->BUF[2];
|
||||
RxMessage->Data[5] = (unsigned char)CANx->BUF[3];
|
||||
RxMessage->Data[6] = (unsigned char)CANx->BUF[4];
|
||||
RxMessage->Data[7] = (unsigned char)CANx->BUF[5];
|
||||
}
|
||||
else if (RxMessage->IDE == CAN_Id_Extended)
|
||||
{
|
||||
RxMessage->ExtId= CANx->ID[0]<<21 |CANx->ID[1]<<13|CANx->ID[2]<<5|CANx->ID[3]>>3 ;
|
||||
/* 获取数据 */
|
||||
RxMessage->Data[0] = (unsigned char)CANx->BUF[0];
|
||||
RxMessage->Data[1] = (unsigned char)CANx->BUF[1];
|
||||
RxMessage->Data[2] = (unsigned char)CANx->BUF[2];
|
||||
RxMessage->Data[3] = (unsigned char)CANx->BUF[3];
|
||||
RxMessage->Data[4] = (unsigned char)CANx->BUF[4];
|
||||
RxMessage->Data[5] = (unsigned char)CANx->BUF[5];
|
||||
RxMessage->Data[6] = (unsigned char)CANx->BUF[6];
|
||||
RxMessage->Data[7] = (unsigned char)CANx->BUF[7];
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,227 @@
|
|||
|
||||
/*
|
||||
* File : ls1c_can.h
|
||||
* This file is part of RT-Thread RTOS
|
||||
* COPYRIGHT (C) 2006 - 2018, RT-Thread Development Team
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 2 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License along
|
||||
* with this program; if not, write to the Free Software Foundation, Inc.,
|
||||
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*
|
||||
* Change Logs: (Pelican Mode)
|
||||
* Date Author Notes
|
||||
* 2018-01-06 sundm75 first version
|
||||
*/
|
||||
|
||||
#ifndef __OPENLOONGSON_CAN_H
|
||||
#define __OPENLOONGSON_CAN_H
|
||||
|
||||
#define CAN0 ( (CAN_TypeDef* )LS1C_REG_BASE_CAN0)
|
||||
#define CAN1 ( (CAN_TypeDef* )LS1C_REG_BASE_CAN1)
|
||||
|
||||
#define CAN_InitStatus_Failed ((unsigned char)0x00) /*!< CAN initialization failed */
|
||||
#define CAN_InitStatus_Success ((unsigned char)0x01) /*!< CAN initialization OK */
|
||||
|
||||
#define CAN_SJW_1tq ((unsigned char)0x00) /*!< 1 time quantum */
|
||||
#define CAN_SJW_2tq ((unsigned char)0x01) /*!< 2 time quantum */
|
||||
#define CAN_SJW_3tq ((unsigned char)0x02) /*!< 3 time quantum */
|
||||
#define CAN_SJW_4tq ((unsigned char)0x03) /*!< 4 time quantum */
|
||||
|
||||
#define CAN_BS1_1tq ((unsigned char)0x00) /*!< 1 time quantum */
|
||||
#define CAN_BS1_2tq ((unsigned char)0x01) /*!< 2 time quantum */
|
||||
#define CAN_BS1_3tq ((unsigned char)0x02) /*!< 3 time quantum */
|
||||
#define CAN_BS1_4tq ((unsigned char)0x03) /*!< 4 time quantum */
|
||||
#define CAN_BS1_5tq ((unsigned char)0x04) /*!< 5 time quantum */
|
||||
#define CAN_BS1_6tq ((unsigned char)0x05) /*!< 6 time quantum */
|
||||
#define CAN_BS1_7tq ((unsigned char)0x06) /*!< 7 time quantum */
|
||||
#define CAN_BS1_8tq ((unsigned char)0x07) /*!< 8 time quantum */
|
||||
#define CAN_BS1_9tq ((unsigned char)0x08) /*!< 9 time quantum */
|
||||
#define CAN_BS1_10tq ((unsigned char)0x09) /*!< 10 time quantum */
|
||||
#define CAN_BS1_11tq ((unsigned char)0x0A) /*!< 11 time quantum */
|
||||
#define CAN_BS1_12tq ((unsigned char)0x0B) /*!< 12 time quantum */
|
||||
#define CAN_BS1_13tq ((unsigned char)0x0C) /*!< 13 time quantum */
|
||||
#define CAN_BS1_14tq ((unsigned char)0x0D) /*!< 14 time quantum */
|
||||
#define CAN_BS1_15tq ((unsigned char)0x0E) /*!< 15 time quantum */
|
||||
#define CAN_BS1_16tq ((unsigned char)0x0F) /*!< 16 time quantum */
|
||||
|
||||
#define CAN_BS2_1tq ((unsigned char)0x00) /*!< 1 time quantum */
|
||||
#define CAN_BS2_2tq ((unsigned char)0x01) /*!< 2 time quantum */
|
||||
#define CAN_BS2_3tq ((unsigned char)0x02) /*!< 3 time quantum */
|
||||
#define CAN_BS2_4tq ((unsigned char)0x03) /*!< 4 time quantum */
|
||||
#define CAN_BS2_5tq ((unsigned char)0x04) /*!< 5 time quantum */
|
||||
#define CAN_BS2_6tq ((unsigned char)0x05) /*!< 6 time quantum */
|
||||
#define CAN_BS2_7tq ((unsigned char)0x06) /*!< 7 time quantum */
|
||||
#define CAN_BS2_8tq ((unsigned char)0x07) /*!< 8 time quantum */
|
||||
|
||||
#define CAN_Id_Standard 0
|
||||
#define CAN_Id_Extended 1
|
||||
#define CAN_RTR_DATA 0
|
||||
#define CAN_RTR_Remote 1
|
||||
|
||||
#define CAN_MODE_NORMAL 0
|
||||
#define CAN_MODE_LISEN 1
|
||||
#define CAN_MODE_LOOPBACK 2
|
||||
#define CAN_MODE_LOOPBACKANLISEN 3
|
||||
|
||||
/*!< CAN 控制状态寄存器 */
|
||||
/************************** CAN_MOD 寄存器位定义*******************************/
|
||||
#define CAN_Mode_RM ((unsigned char)0x01) /*!< 复位模式 */
|
||||
#define CAN_Mode_LOM ((unsigned char)0x02) /*!< 只听模式 1:只听 0:正常 */
|
||||
#define CAN_Mode_STM ((unsigned char)0x04) /*!< 正常工作模式1:自检测 0:正常 */
|
||||
#define CAN_Mode_AFM ((unsigned char)0x08) /*!< 单/双滤波模式 1:单 0: 双*/
|
||||
#define CAN_Mode_SM ((unsigned char)0x10) /*!< 睡眠模式1: 睡眠 0: 唤醒 */
|
||||
|
||||
/************************** CAN_CMR 寄存器位定义*******************************/
|
||||
#define CAN_CMR_TR ((unsigned char)0x01) /*!< 发送请求 1: 当前信息被发送 0: 空 */
|
||||
#define CAN_CMR_AT ((unsigned char)0x02) /*!< 中止发送 1: 等待发送的信息取消 0: 空缺 */
|
||||
#define CAN_CMR_RRB ((unsigned char)0x04) /*!< 释放接收缓冲器 1:释放 0: 无动作 */
|
||||
#define CAN_CMR_CDO ((unsigned char)0x08) /*!< 清除数据溢出 1:清除 0: 无动作 */
|
||||
//#define CAN_CMR_GTS ((unsigned char)0x10) /*!< STD模式< 睡眠: 1:进入睡眠 0: 唤醒 */
|
||||
#define CAN_CMR_SRR ((unsigned char)0x10) /*!< 自接收请求 1: 0: */
|
||||
#define CAN_CMR_EFF ((unsigned char)0x80) /*!< 扩展模式 1:扩展帧 0: 标准帧 */
|
||||
|
||||
/************************** CAN_SR 寄存器位定义********************************/
|
||||
#define CAN_SR_BBS ((unsigned char)0x01) /*!< 接收缓存器状态1: 满 0: 空 */
|
||||
#define CAN_SR_DOS ((unsigned char)0x02) /*!< 数据溢出状态 1: 溢出 0: 空缺 */
|
||||
#define CAN_SR_TBS ((unsigned char)0x04) /*!< 发送缓存器状态1: 释放 0: 锁定 */
|
||||
#define CAN_SR_TCS ((unsigned char)0x08) /*!< 发送完毕状态1: 完毕 0: 未完毕 */
|
||||
#define CAN_SR_RS ((unsigned char)0x10) /*!< 接收状态1: 接收 0: 空闲 */
|
||||
#define CAN_SR_TS ((unsigned char)0x20) /*!< 发送状态1: 发送 0: 空闲*/
|
||||
#define CAN_SR_ES ((unsigned char)0x40) /*!< 出错状态1:出错 0: 正常 */
|
||||
#define CAN_SR_BS ((unsigned char)0x80) /*!< 总线状态1: 关闭 0: 开启 */
|
||||
|
||||
/************************** CAN_IR 中断寄存器位定义****************************/
|
||||
#define CAN_IR_RI ((unsigned char)0x01) /*!< 接收中断 */
|
||||
#define CAN_IR_TI ((unsigned char)0x02) /*!< 发送中断 */
|
||||
#define CAN_IR_EI ((unsigned char)0x04) /*!< 错误中断 */
|
||||
#define CAN_IR_DOI ((unsigned char)0x08) /*!< 数据溢出中断 */
|
||||
#define CAN_IR_WUI ((unsigned char)0x10) /*!< 唤醒中断 */
|
||||
#define CAN_IR_EPI ((unsigned char)0x20) /*!< 错误消极中断 */
|
||||
#define CAN_IR_ALI ((unsigned char)0x40) /*!< 仲裁丢失中断 */
|
||||
#define CAN_IR_BEI ((unsigned char)0x80) /*!< 总线错误中断 */
|
||||
|
||||
/************************* CAN_IER 中断使能寄存器位定义************************/
|
||||
#define CAN_IER_RIE ((unsigned char)0x01) /*!< 接收中断使能 */
|
||||
#define CAN_IER_TIE ((unsigned char)0x02) /*!< 发送中断使能 */
|
||||
#define CAN_IER_EIE ((unsigned char)0x04) /*!< 错误中断使能 */
|
||||
#define CAN_IER_DOIE ((unsigned char)0x08) /*!< 数据溢出中断使能 */
|
||||
#define CAN_IER_WUIE ((unsigned char)0x10) /*!< 唤醒中断使能 */
|
||||
#define CAN_IER_EPIE ((unsigned char)0x20) /*!< 错误消极中断使能 */
|
||||
#define CAN_IER_ALIE ((unsigned char)0x40) /*!< 仲裁丢失中断使能 */
|
||||
#define CAN_IER_BEIE ((unsigned char)0x80) /*!< 总线错误中断使能 */
|
||||
|
||||
typedef enum
|
||||
{
|
||||
LS1C_CAN1MBaud=0, // 1 MBit/sec
|
||||
LS1C_CAN800kBaud, // 800 kBit/sec
|
||||
LS1C_CAN500kBaud, // 500 kBit/sec
|
||||
LS1C_CAN250kBaud, // 250 kBit/sec
|
||||
LS1C_CAN125kBaud, // 125 kBit/sec
|
||||
LS1C_CAN100kBaud, // 100 kBit/sec
|
||||
LS1C_CAN50kBaud, // 50 kBit/sec
|
||||
LS1C_CAN40kBaud, // 40 kBit/sec
|
||||
}Ls1c_CanBPS_t;
|
||||
|
||||
typedef struct
|
||||
{
|
||||
unsigned char MOD;
|
||||
unsigned char CMR;
|
||||
unsigned char SR;
|
||||
unsigned char IR;
|
||||
unsigned char IER;
|
||||
unsigned char reserved0;
|
||||
unsigned char BTR0;
|
||||
unsigned char BTR1;
|
||||
unsigned char OCR;
|
||||
unsigned char reserved[2];
|
||||
unsigned char ALC;
|
||||
unsigned char ECC ;
|
||||
unsigned char EMLR;
|
||||
unsigned char RXERR;
|
||||
unsigned char TXERR;
|
||||
unsigned char IDE_RTR_DLC;
|
||||
unsigned char ID[4];
|
||||
unsigned char BUF[8];
|
||||
unsigned char RMCR;
|
||||
unsigned char CDR;
|
||||
} CAN_TypeDef;
|
||||
|
||||
typedef struct
|
||||
{
|
||||
unsigned char CAN_Prescaler; /* 波特率分频系数1 to 31. */
|
||||
unsigned char CAN_Mode; /*0x10:睡眠0x08:单,双滤波 0x40:正常工作0x20:只听 0x01:复位*/
|
||||
unsigned char CAN_SJW; /*同步跳转宽度 */
|
||||
unsigned char CAN_BS1; /*时间段1计数值*/
|
||||
unsigned char CAN_BS2; /*时间段2计数值*/
|
||||
|
||||
} CAN_InitTypeDef;
|
||||
|
||||
typedef struct
|
||||
{
|
||||
unsigned char IDE; /*0: 使用标准标识符1: 使用扩展标识符*/
|
||||
unsigned char RTR; /*0: 数据帧 1: 远程帧*/
|
||||
unsigned char MODE; /* 0- 双滤波器模式;1-单滤波器模式*/
|
||||
unsigned long First_Data; /*双滤波器模式下信息第一个数据字节*/
|
||||
unsigned long Data_Mask; /*双滤波器模式下信息第一个数据字节屏蔽*/
|
||||
unsigned long ID; /*验收代码*/
|
||||
/*
|
||||
双滤波器- 扩展帧: 2个滤波器的前16位,分别放在ID 的前16位和 ID的后16位.
|
||||
双滤波器- 标准帧: 2个滤波器的11位,分别放在ID 的前16位和 ID的后16位,第1个滤波器同时使用First_Data和Data_Mask
|
||||
单滤波器- 扩展帧: 使用29位, 放在ID 的后29位.
|
||||
单滤波器- 标准帧: 使用11位, 放在ID 的后11位.
|
||||
*/
|
||||
unsigned long IDMASK; /*验收屏蔽*/
|
||||
} CAN_FilterInitTypeDef;
|
||||
|
||||
typedef struct
|
||||
{
|
||||
unsigned long StdId; /* 11位ID*/
|
||||
unsigned long ExtId; /*29位ID**/
|
||||
unsigned char IDE; /*IDE: 标识符选择
|
||||
该位决定发送邮箱中报文使用的标识符类型
|
||||
0: 使用标准标识符
|
||||
1: 使用扩展标识符*/
|
||||
unsigned char RTR; /*远程发送请求
|
||||
0: 数据帧
|
||||
1: 远程帧*/
|
||||
unsigned char DLC; /*数据帧长度*/
|
||||
unsigned char Data[8]; /*8字节数据*/
|
||||
} CanRxMsg;
|
||||
|
||||
typedef struct
|
||||
{
|
||||
unsigned long StdId; /* 11位ID*/
|
||||
unsigned long ExtId; /*29位ID**/
|
||||
unsigned char IDE; /*IDE: 标识符选择
|
||||
该位决定发送邮箱中报文使用的标识符类型
|
||||
0: 使用标准标识符
|
||||
1: 使用扩展标识符*/
|
||||
unsigned char RTR; /*远程发送请求
|
||||
0: 数据帧
|
||||
1: 远程帧*/
|
||||
unsigned char DLC; /*数据帧长度*/
|
||||
unsigned char Data[8]; /*8字节数据*/
|
||||
} CanTxMsg;
|
||||
|
||||
unsigned char CAN_Init(CAN_TypeDef* CANx, CAN_InitTypeDef* CAN_InitStruct);
|
||||
unsigned char CAN_SetBps(CAN_TypeDef* CANx, Ls1c_CanBPS_t Bps);
|
||||
unsigned char CAN_SetMode(CAN_TypeDef* CANx, unsigned char mode);
|
||||
void CAN_FilterInit(CAN_TypeDef* CANx, CAN_FilterInitTypeDef* CAN_FilterInitStruct);
|
||||
unsigned char CAN_Transmit(CAN_TypeDef* CANx, CanTxMsg* TxMessage);
|
||||
void CAN_Receive(CAN_TypeDef* CANx, CanRxMsg* RxMessage);
|
||||
|
||||
unsigned char set_reset_mode(CAN_TypeDef* CANx);
|
||||
unsigned char set_start(CAN_TypeDef* CANx);
|
||||
|
||||
#endif
|
||||
|
|
@ -42,6 +42,15 @@ void pin_set_remap(unsigned int gpio, pin_remap_t remap)
|
|||
volatile unsigned int *reg = NULL; // 复用寄存器
|
||||
unsigned int port = GPIO_GET_PORT(gpio);
|
||||
unsigned int pin = GPIO_GET_PIN(gpio);
|
||||
int i;
|
||||
|
||||
/*指定全部pin复用为0*/
|
||||
for(i =0; i <=4; i++)
|
||||
{
|
||||
reg = (volatile unsigned int *)((LS1C_CBUS_FIRST0)+((port)*0x04)+((i)*0x10));
|
||||
// 置0
|
||||
reg_clr_one_bit(reg, pin);
|
||||
}
|
||||
|
||||
switch (port)
|
||||
{
|
||||
|
|
|
@ -20,6 +20,7 @@ typedef enum
|
|||
PIN_REMAP_THIRD, // 第三复用
|
||||
PIN_REMAP_FOURTH, // 第四复用
|
||||
PIN_REMAP_FIFTH, // 第五复用
|
||||
PIN_REMAP_DEFAULT, //缺省复用
|
||||
}pin_remap_t;
|
||||
|
||||
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
// 龙芯1c外设寄存器
|
||||
// 龙芯1c外设寄存器
|
||||
|
||||
|
||||
#ifndef __OPENLOONGSON_LS1C_REGS_H
|
||||
|
@ -7,12 +7,12 @@
|
|||
|
||||
|
||||
|
||||
// 时钟相关寄存器地址
|
||||
// 时钟相关寄存器地址
|
||||
#define LS1C_START_FREQ (0xbfe78030)
|
||||
#define LS1C_CLK_DIV_PARAM (0xbfe78034)
|
||||
|
||||
|
||||
// gpio相关寄存器地址
|
||||
// gpio相关寄存器地址
|
||||
#define LS1C_GPIO_CFG0 (0xbfd010c0)
|
||||
#define LS1C_GPIO_EN0 (0xbfd010d0)
|
||||
#define LS1C_GPIO_IN0 (0xbfd010e0)
|
||||
|
@ -35,7 +35,7 @@
|
|||
|
||||
|
||||
|
||||
// 复用相关寄存器
|
||||
// 复用相关寄存器
|
||||
#define LS1C_CBUS_FIRST0 (0xbfd011c0)
|
||||
#define LS1C_CBUS_SECOND0 (0xbfd011d0)
|
||||
#define LS1C_CBUS_THIRD0 (0xbfd011e0)
|
||||
|
@ -61,20 +61,22 @@
|
|||
#define LS1C_CBUS_FIFTH3 (0xbfd0120c)
|
||||
|
||||
|
||||
// PWM寄存器偏移
|
||||
// PWM寄存器偏移
|
||||
#define LS1C_PWM_CNTR (0x0)
|
||||
#define LS1C_PWM_HRC (0x4)
|
||||
#define LS1C_PWM_LRC (0x8)
|
||||
#define LS1C_PWM_CTRL (0xC)
|
||||
// PWM基地址
|
||||
// PWM基地址
|
||||
#define LS1C_REG_BASE_PWM0 (0xbfe5c000)
|
||||
#define LS1C_REG_BASE_PWM1 (0xbfe5c010)
|
||||
#define LS1C_REG_BASE_PWM2 (0xbfe5c020)
|
||||
#define LS1C_REG_BASE_PWM3 (0xbfe5c030)
|
||||
|
||||
//CAN基地址
|
||||
#define LS1C_REG_BASE_CAN0 (0xbfe50000)
|
||||
#define LS1C_REG_BASE_CAN1 (0xbfe54000)
|
||||
|
||||
|
||||
// 中断配置寄存器
|
||||
// 中断配置寄存器
|
||||
#define LS1C_INT0_SR (0xbfd01040)
|
||||
#define LS1C_INT0_EN (0xbfd01044)
|
||||
#define LS1C_INT0_SET (0xbfd01048)
|
||||
|
@ -111,18 +113,18 @@
|
|||
#define LS1C_INT4_EDGE (0xbfd010b4)
|
||||
|
||||
|
||||
// I2C寄存器
|
||||
// I2C寄存器
|
||||
#define LS1C_I2C0_BASE (0xbfe58000)
|
||||
#define LS1C_I2C1_BASE (0xbfe68000)
|
||||
#define LS1C_I2C2_BASE (0xbfe70000)
|
||||
|
||||
|
||||
// SPI寄存器
|
||||
// SPI寄存器
|
||||
#define LS1C_SPI0_BASE (0xbfe80000)
|
||||
#define LS1C_SPI1_BASE (0xbfec0000)
|
||||
|
||||
|
||||
// 串口寄存器
|
||||
// 串口寄存器
|
||||
#define LS1C_UART0_BASE (0xbfe40000)
|
||||
#define LS1C_UART1_BASE (0xbfe44000)
|
||||
#define LS1C_UART2_BASE (0xbfe48000)
|
||||
|
|
|
@ -19,10 +19,10 @@
|
|||
*
|
||||
* Change Logs:
|
||||
* Date Author Notes
|
||||
* 2017-10-23 勤为本 first version
|
||||
* 2017-10-23 勤为本 first version
|
||||
*/
|
||||
|
||||
// 硬件spi接口源文件
|
||||
// 硬件spi接口源文件
|
||||
|
||||
|
||||
#include <string.h>
|
||||
|
@ -35,8 +35,8 @@
|
|||
|
||||
|
||||
/*
|
||||
* 获取指定SPI模块的基地址
|
||||
* @SPIx SPI模块的编号
|
||||
* 获取指定SPI模块的基地址
|
||||
* @SPIx SPI模块的编号
|
||||
*/
|
||||
inline void *ls1c_spi_get_base(unsigned char SPIx)
|
||||
{
|
||||
|
@ -62,8 +62,8 @@ inline void *ls1c_spi_get_base(unsigned char SPIx)
|
|||
|
||||
|
||||
/*
|
||||
* 打印指定SPI模块的所有寄存器的值
|
||||
* @spi_base 基地址
|
||||
* 打印指定SPI模块的所有寄存器的值
|
||||
* @spi_base 基地址
|
||||
*/
|
||||
void ls1c_spi_print_all_regs_info(void *spi_base)
|
||||
{
|
||||
|
@ -81,9 +81,9 @@ void ls1c_spi_print_all_regs_info(void *spi_base)
|
|||
|
||||
|
||||
/*
|
||||
* 根据SPI时钟频率计算分频系数
|
||||
* @max_speed_hz SPI最大通信速度
|
||||
* @ret 分频系数
|
||||
* 根据SPI时钟频率计算分频系数
|
||||
* @max_speed_hz SPI最大通信速度
|
||||
* @ret 分频系数
|
||||
*/
|
||||
unsigned int ls1c_spi_get_div(unsigned int max_speed_hz)
|
||||
{
|
||||
|
@ -145,28 +145,28 @@ unsigned int ls1c_spi_get_div(unsigned int max_speed_hz)
|
|||
|
||||
|
||||
/*
|
||||
* 设置时钟
|
||||
* @spi_base 基地址
|
||||
* @max_hz 最大频率,单位hz
|
||||
* 设置时钟
|
||||
* @spi_base 基地址
|
||||
* @max_hz 最大频率,单位hz
|
||||
*/
|
||||
void ls1c_spi_set_clock(void *spi_base, unsigned long max_hz)
|
||||
{
|
||||
unsigned int div = 0;
|
||||
unsigned char val = 0;
|
||||
|
||||
// 获取分频系数
|
||||
// 获取分频系数
|
||||
div = ls1c_spi_get_div(max_hz);
|
||||
|
||||
// 设置spr
|
||||
// 设置spr
|
||||
val = reg_read_8(spi_base + LS1C_SPI_SPCR_OFFSET);
|
||||
val &= (~LS1C_SPI_SPCR_SPR_MASK); // spr清零
|
||||
val |= (div & LS1C_SPI_SPCR_SPR_MASK); // 设置新的spr
|
||||
val &= (~LS1C_SPI_SPCR_SPR_MASK); // spr清零
|
||||
val |= (div & LS1C_SPI_SPCR_SPR_MASK); // 设置新的spr
|
||||
reg_write_8(val, spi_base + LS1C_SPI_SPCR_OFFSET);
|
||||
|
||||
// 设置spre
|
||||
// 设置spre
|
||||
val = reg_read_8(spi_base + LS1C_SPI_SPER_OFFSET);
|
||||
val &= (~LS1C_SPI_SPER_SPRE_MASK); // spre清零
|
||||
val |= ((div >> 2) & LS1C_SPI_SPER_SPRE_MASK); // 设置新的spre
|
||||
val &= (~LS1C_SPI_SPER_SPRE_MASK); // spre清零
|
||||
val |= ((div >> 2) & LS1C_SPI_SPER_SPRE_MASK); // 设置新的spre
|
||||
reg_write_8(val, spi_base + LS1C_SPI_SPER_OFFSET);
|
||||
|
||||
return ;
|
||||
|
@ -174,10 +174,10 @@ void ls1c_spi_set_clock(void *spi_base, unsigned long max_hz)
|
|||
|
||||
|
||||
/*
|
||||
* 设置通信模式(时钟极性和相位)
|
||||
* @spi_base 基地址
|
||||
* @cpol 时钟极性
|
||||
* @cpha 时钟相位
|
||||
* 设置通信模式(时钟极性和相位)
|
||||
* @spi_base 基地址
|
||||
* @cpol 时钟极性
|
||||
* @cpha 时钟相位
|
||||
*/
|
||||
void ls1c_spi_set_mode(void *spi_base, unsigned char cpol, unsigned char cpha)
|
||||
{
|
||||
|
@ -185,13 +185,13 @@ void ls1c_spi_set_mode(void *spi_base, unsigned char cpol, unsigned char cpha)
|
|||
|
||||
val = reg_read_8(spi_base + LS1C_SPI_SPCR_OFFSET);
|
||||
|
||||
// 设置时钟极性--cpol
|
||||
val &= (~LS1C_SPI_SPCR_CPOL_MASK); // cpol清0
|
||||
val |= (cpol << LS1C_SPI_SPCR_CPOL_BIT); // 写入新的cpol
|
||||
// 设置时钟极性--cpol
|
||||
val &= (~LS1C_SPI_SPCR_CPOL_MASK); // cpol清0
|
||||
val |= (cpol << LS1C_SPI_SPCR_CPOL_BIT); // 写入新的cpol
|
||||
|
||||
// 设置时钟相位--cpha
|
||||
val &= (~LS1C_SPI_SPCR_CPHA_MASK); // cpha清0
|
||||
val |= (cpha << LS1C_SPI_SPCR_CPHA_BIT); // 写入新的cpha
|
||||
// 设置时钟相位--cpha
|
||||
val &= (~LS1C_SPI_SPCR_CPHA_MASK); // cpha清0
|
||||
val |= (cpha << LS1C_SPI_SPCR_CPHA_BIT); // 写入新的cpha
|
||||
|
||||
reg_write_8(val, spi_base + LS1C_SPI_SPCR_OFFSET);
|
||||
|
||||
|
@ -200,23 +200,24 @@ void ls1c_spi_set_mode(void *spi_base, unsigned char cpol, unsigned char cpha)
|
|||
|
||||
|
||||
/*
|
||||
* 设置指定片选为指定状态
|
||||
* @spi_base 基地址
|
||||
* @cs 片选
|
||||
* @new_status 片选引脚的新状态,取值为0或1,即高电平或低电平
|
||||
* 设置指定片选为指定状态
|
||||
* @spi_base 基地址
|
||||
* @cs 片选
|
||||
* @new_status 片选引脚的新状态,取值为0或1,即高电平或低电平
|
||||
*/
|
||||
void ls1c_spi_set_cs(void *spi_base, unsigned char cs, int new_status)
|
||||
{
|
||||
unsigned char val = 0;
|
||||
|
||||
val = 0xf0 | (0x01 << cs); // 全部csn=1,指定的csen=1
|
||||
val = reg_read_8(spi_base + LS1C_SPI_SFC_SOFTCS_OFFSET);
|
||||
val |= 0x01 << cs ; //对应的csen=1
|
||||
if (new_status) // cs = 1
|
||||
{
|
||||
val |= (0x10 << cs); // 指定csn=1
|
||||
val |= (0x10 << cs); // 指定csn=1
|
||||
}
|
||||
else // cs = 0
|
||||
{
|
||||
val &= ~(0x10 << cs); // 指定csn=0
|
||||
val &= ~(0x10 << cs); // 指定csn=0
|
||||
}
|
||||
reg_write_8(val, spi_base + LS1C_SPI_SFC_SOFTCS_OFFSET);
|
||||
|
||||
|
@ -225,8 +226,8 @@ void ls1c_spi_set_cs(void *spi_base, unsigned char cs, int new_status)
|
|||
|
||||
|
||||
/*
|
||||
* 等待收发完成
|
||||
* @spi_base 基地址
|
||||
* 等待收发完成
|
||||
* @spi_base 基地址
|
||||
*/
|
||||
inline void ls1c_spi_wait_txrx_done(void *spi_base)
|
||||
{
|
||||
|
@ -243,25 +244,25 @@ inline void ls1c_spi_wait_txrx_done(void *spi_base)
|
|||
|
||||
|
||||
/*
|
||||
* 清中断和标志位
|
||||
* @spi_base 基地址
|
||||
* 清中断和标志位
|
||||
* @spi_base 基地址
|
||||
*/
|
||||
inline void ls1c_spi_clear(void *spi_base)
|
||||
{
|
||||
unsigned char val = 0;
|
||||
|
||||
// 清中断
|
||||
// 清中断
|
||||
val = reg_read_8(spi_base + LS1C_SPI_SPSR_OFFSET);
|
||||
val |= LS1C_SPI_SPSR_SPIF_MASK;
|
||||
reg_write_8(val, spi_base + LS1C_SPI_SPSR_OFFSET);
|
||||
|
||||
// 清溢出标志位(Write-Collision Clear)
|
||||
// 清溢出标志位(Write-Collision Clear)
|
||||
val = reg_read_8(spi_base + LS1C_SPI_SPSR_OFFSET);
|
||||
if (LS1C_SPI_SPSR_WCOL_MASK & val)
|
||||
{
|
||||
rt_kprintf("[%s] clear register SPSR's wcol!\r\n"); // 手册和linux源码中不一样,加个打印看看
|
||||
reg_write_8(val & ~LS1C_SPI_SPSR_WCOL_MASK, spi_base + LS1C_SPI_SPSR_OFFSET); // 写0,linux源码中是写0
|
||||
// reg_write_8(val | LS1C_SPI_SPSR_WCOL_MASK, spi_base + LS1C_SPI_SPSR_OFFSET); // 写1,按照1c手册,应该写1
|
||||
rt_kprintf("[%s] clear register SPSR's wcol!\r\n"); // 手册和linux源码中不一样,加个打印看看
|
||||
reg_write_8(val & ~LS1C_SPI_SPSR_WCOL_MASK, spi_base + LS1C_SPI_SPSR_OFFSET); // 写0,linux源码中是写0
|
||||
// reg_write_8(val | LS1C_SPI_SPSR_WCOL_MASK, spi_base + LS1C_SPI_SPSR_OFFSET); // 写1,按照1c手册,应该写1
|
||||
}
|
||||
|
||||
return ;
|
||||
|
@ -270,23 +271,23 @@ inline void ls1c_spi_clear(void *spi_base)
|
|||
|
||||
|
||||
/*
|
||||
* 通过指定SPI发送接收一个字节
|
||||
* 注意,在多任务的系统中,此函数需要互斥。
|
||||
* 即保证在和某个从设备收发某个字节的过程中,不能被切换到其它任务同时与另外的在同一个SPI总线上的从设备通信
|
||||
* 因为龙芯1c的每路SPI上可能接有不同的从设备,通信频率、模式等可能不同
|
||||
* @spi_base 基地址
|
||||
* @tx_ch 待发送的数据
|
||||
* @ret 收到的数据
|
||||
* 通过指定SPI发送接收一个字节
|
||||
* 注意,在多任务的系统中,此函数需要互斥。
|
||||
* 即保证在和某个从设备收发某个字节的过程中,不能被切换到其它任务同时与另外的在同一个SPI总线上的从设备通信
|
||||
* 因为龙芯1c的每路SPI上可能接有不同的从设备,通信频率、模式等可能不同
|
||||
* @spi_base 基地址
|
||||
* @tx_ch 待发送的数据
|
||||
* @ret 收到的数据
|
||||
*/
|
||||
unsigned char ls1c_spi_txrx_byte(void *spi_base, unsigned char tx_ch)
|
||||
{
|
||||
unsigned char rx_ch = 0;
|
||||
|
||||
// 收发数据
|
||||
reg_write_8(tx_ch, spi_base + LS1C_SPI_TxFIFO_OFFSET); // 开始发送
|
||||
ls1c_spi_wait_txrx_done(spi_base); // 等待收发完成
|
||||
rx_ch = reg_read_8(spi_base + LS1C_SPI_RxFIFO_OFFSET); // 读取收到的数据
|
||||
ls1c_spi_clear(spi_base); // 清中断和标志位
|
||||
// 收发数据
|
||||
reg_write_8(tx_ch, spi_base + LS1C_SPI_TxFIFO_OFFSET); // 开始发送
|
||||
ls1c_spi_wait_txrx_done(spi_base); // 等待收发完成
|
||||
rx_ch = reg_read_8(spi_base + LS1C_SPI_RxFIFO_OFFSET); // 读取收到的数据
|
||||
ls1c_spi_clear(spi_base); // 清中断和标志位
|
||||
|
||||
return rx_ch;
|
||||
}
|
||||
|
|
|
@ -1,243 +1,260 @@
|
|||
#ifndef __RTTHREAD_CFG_H__
|
||||
#define __RTTHREAD_CFG_H__
|
||||
#ifndef RT_CONFIG_H__
|
||||
#define RT_CONFIG_H__
|
||||
|
||||
// <RDTConfigurator URL="http://www.rt-thread.com/eclipse">
|
||||
/* Automatically generated file; DO NOT EDIT. */
|
||||
/* RT-Thread Configuration */
|
||||
|
||||
// <integer name="RT_NAME_MAX" description="Maximal size of kernel object name length" default="6" />
|
||||
#define RT_NAME_MAX 10
|
||||
// <integer name="RT_ALIGN_SIZE" description="Alignment size for CPU architecture data access" default="4" />
|
||||
#define RT_ALIGN_SIZE 8
|
||||
// <integer name="RT_THREAD_PRIORITY_MAX" description="Maximal level of thread priority" default="32">
|
||||
// <item description="8">8</item>
|
||||
// <item description="32">32</item>
|
||||
// <item description="256">256</item>
|
||||
// </integer>
|
||||
#define RT_THREAD_PRIORITY_MAX 32
|
||||
// <integer name="RT_TICK_PER_SECOND" description="OS tick per second" default="100" />
|
||||
#define RT_TICK_PER_SECOND 1000
|
||||
// <section name="RT_DEBUG" description="Kernel Debug Configuration" default="true" >
|
||||
/* RT-Thread Kernel */
|
||||
|
||||
#define RT_NAME_MAX 10
|
||||
#define RT_ALIGN_SIZE 8
|
||||
/* RT_THREAD_PRIORITY_8 is not set */
|
||||
#define RT_THREAD_PRIORITY_32
|
||||
/* RT_THREAD_PRIORITY_256 is not set */
|
||||
#define RT_THREAD_PRIORITY_MAX 32
|
||||
#define RT_TICK_PER_SECOND 1000
|
||||
#define RT_DEBUG
|
||||
// <bool name="RT_THREAD_DEBUG" description="Thread debug enable" default="false" />
|
||||
// #define RT_THREAD_DEBUG
|
||||
// <bool name="RT_USING_OVERFLOW_CHECK" description="Thread stack over flow detect" default="true" />
|
||||
#define RT_USING_OVERFLOW_CHECK
|
||||
// <bool name="RT_USING_INTERRUPT_INFO" description="Show more interrupt description" default="true" />
|
||||
#define RT_USING_INTERRUPT_INFO
|
||||
// <integer name="IDLE_THREAD_STACK_SIZE" description="The stack size of idle thread" default="1024" />
|
||||
#define IDLE_THREAD_STACK_SIZE 1024
|
||||
// </section>
|
||||
|
||||
// <bool name="RT_USING_HOOK" description="Using hook functions" default="true" />
|
||||
#define RT_DEBUG_INIT 0
|
||||
#define RT_DEBUG_THREAD 0
|
||||
#define RT_USING_HOOK
|
||||
// <section name="RT_USING_TIMER_SOFT" description="Using software timer which will start a thread to handle soft-timer" default="true" >
|
||||
// #define RT_USING_TIMER_SOFT
|
||||
// <integer name="RT_TIMER_THREAD_PRIO" description="The priority level of timer thread" default="4" />
|
||||
#define RT_TIMER_THREAD_PRIO 4
|
||||
// <integer name="RT_TIMER_THREAD_STACK_SIZE" description="The stack size of timer thread" default="512" />
|
||||
#define RT_TIMER_THREAD_STACK_SIZE 512
|
||||
// <integer name="RT_TIMER_TICK_PER_SECOND" description="The soft-timer tick per second" default="10" />
|
||||
#define RT_TIMER_TICK_PER_SECOND 10
|
||||
// </section>
|
||||
#define IDLE_THREAD_STACK_SIZE 1024
|
||||
/* RT_USING_TIMER_SOFT is not set */
|
||||
|
||||
/* Inter-Thread communication */
|
||||
|
||||
// <section name="IPC" description="Inter-Thread communication" default="always" >
|
||||
// <bool name="RT_USING_SEMAPHORE" description="Using semaphore in the system" default="true" />
|
||||
#define RT_USING_SEMAPHORE
|
||||
// <bool name="RT_USING_MUTEX" description="Using mutex in the system" default="true" />
|
||||
#define RT_USING_MUTEX
|
||||
// <bool name="RT_USING_EVENT" description="Using event group in the system" default="true" />
|
||||
#define RT_USING_EVENT
|
||||
// <bool name="RT_USING_MAILBOX" description="Using mailbox in the system" default="true" />
|
||||
#define RT_USING_MAILBOX
|
||||
// <bool name="RT_USING_MESSAGEQUEUE" description="Using message queue in the system" default="true" />
|
||||
#define RT_USING_MESSAGEQUEUE
|
||||
// </section>
|
||||
/* RT_USING_SIGNALS is not set */
|
||||
|
||||
/* Memory Management */
|
||||
|
||||
// <section name="MM" description="Memory Management" default="always" >
|
||||
// <bool name="RT_USING_MEMPOOL" description="Using Memory Pool Management in the system" default="true" />
|
||||
#define RT_USING_MEMPOOL
|
||||
// <bool name="RT_USING_MEMHEAP" description="Using Memory Heap Object in the system" default="true" />
|
||||
#define RT_USING_MEMHEAP
|
||||
// <bool name="RT_USING_HEAP" description="Using Dynamic Heap Management in the system" default="true" />
|
||||
#define RT_USING_HEAP
|
||||
// <bool name="RT_USING_SMALL_MEM" description="Optimizing for small memory" default="false" />
|
||||
/* RT_USING_NOHEAP is not set */
|
||||
#define RT_USING_SMALL_MEM
|
||||
// <bool name="RT_USING_SLAB" description="Using SLAB memory management for large memory" default="false" />
|
||||
// #define RT_USING_SLAB
|
||||
// </section>
|
||||
/* RT_USING_SLAB is not set */
|
||||
/* RT_USING_MEMHEAP_AS_HEAP is not set */
|
||||
/* RT_USING_MEMTRACE is not set */
|
||||
#define RT_USING_HEAP
|
||||
|
||||
/* Kernel Device Object */
|
||||
|
||||
// <section name="RT_USING_DEVICE" description="Using Device Driver Framework" default="true" >
|
||||
#define RT_USING_DEVICE
|
||||
// <bool name="RT_USING_UART" description="Using UART" default="true" />
|
||||
#define RT_USING_UART
|
||||
// <bool name="RT_USING_UART2" description="Using UART0" default="true" />
|
||||
#define RT_USING_UART2
|
||||
// <integer name="RT_UART_RX_BUFFER_SIZE" description="The buffer size for UART reception" default="64" />
|
||||
#define RT_UART_RX_BUFFER_SIZE 64
|
||||
// </section>
|
||||
|
||||
#define RT_USING_FPU
|
||||
|
||||
// <section name="RT_USING_CONSOLE" description="Using console" default="true" >
|
||||
#define RT_USING_INTERRUPT_INFO
|
||||
#define RT_USING_CONSOLE
|
||||
// <integer name="RT_CONSOLEBUF_SIZE" description="The buffer size for console output" default="128" />
|
||||
#define RT_CONSOLEBUF_SIZE 128
|
||||
// <string name="RT_CONSOLE_DEVICE_NAME" description="The device name for console" default="uart" />
|
||||
#define RT_CONSOLE_DEVICE_NAME "uart2"
|
||||
// </section>
|
||||
#define RT_CONSOLEBUF_SIZE 128
|
||||
#define RT_CONSOLE_DEVICE_NAME "uart2"
|
||||
/* RT_USING_MODULE is not set */
|
||||
|
||||
/* RT-Thread Components */
|
||||
|
||||
// <bool name="RT_USING_COMPONENTS_INIT" description="Using RT-Thread components initialization" default="true" />
|
||||
#define RT_USING_COMPONENTS_INIT
|
||||
// <section name="RT_USING_FINSH" description="Using finsh as shell, which is a C-Express shell" default="true" >
|
||||
/* RT_USING_USER_MAIN is not set */
|
||||
|
||||
/* C++ features */
|
||||
|
||||
/* RT_USING_CPLUSPLUS is not set */
|
||||
|
||||
/* Command shell */
|
||||
|
||||
#define RT_USING_FINSH
|
||||
// <bool name="FINSH_USING_SYMTAB" description="Using symbol table in finsh shell" default="true" />
|
||||
#define FINSH_THREAD_NAME "tshell"
|
||||
#define FINSH_USING_HISTORY
|
||||
#define FINSH_HISTORY_LINES 5
|
||||
#define FINSH_USING_SYMTAB
|
||||
// <bool name="FINSH_USING_DESCRIPTION" description="Keeping description in symbol table" default="true" />
|
||||
#define FINSH_USING_DESCRIPTION
|
||||
// <integer name="FINSH_THREAD_STACK_SIZE" description="The stack size for finsh thread" default="4096" />
|
||||
#define FINSH_THREAD_STACK_SIZE 4096
|
||||
// <bool name="FINSH_USING_MSH" description="Using module shell" default="true" />
|
||||
#define FINSH_THREAD_PRIORITY 20
|
||||
#define FINSH_THREAD_STACK_SIZE 4096
|
||||
#define FINSH_CMD_SIZE 80
|
||||
/* FINSH_USING_AUTH is not set */
|
||||
#define FINSH_USING_MSH
|
||||
// <bool name="FINSH_USING_MSH_DEFAULT" description="Using module shell as the default shell" default="true" />
|
||||
#define FINSH_USING_MSH_DEFAULT
|
||||
// </section>
|
||||
/* FINSH_USING_MSH_ONLY is not set */
|
||||
|
||||
// <section name="LIBC" description="C Runtime library setting" default="always" >
|
||||
#define RT_USING_LIBC
|
||||
// <bool name="RT_USING_PTHREADS" description="Using POSIX threads library" default="true" />
|
||||
#define RT_USING_PTHREADS
|
||||
// </section>
|
||||
/* Device virtual file system */
|
||||
|
||||
// <section name="RT_USING_DFS" description="Device file system" default="true" >
|
||||
// #define RT_USING_DFS
|
||||
// <bool name="DFS_USING_WORKDIR" description="Using working directory" default="true" />
|
||||
// #define DFS_USING_WORKDIR
|
||||
// <integer name="DFS_FILESYSTEMS_MAX" description="The maximal number of mounted file system" default="4" />
|
||||
#define DFS_FILESYSTEMS_MAX 2
|
||||
// <integer name="DFS_FD_MAX" description="The maximal number of opened files" default="4" />
|
||||
#define DFS_FD_MAX 4
|
||||
// <bool name="RT_USING_DFS_ELMFAT" description="Using ELM FatFs" default="true" />
|
||||
#define RT_USING_DFS
|
||||
#define DFS_USING_WORKDIR
|
||||
#define DFS_FILESYSTEMS_MAX 2
|
||||
#define DFS_FILESYSTEM_TYPES_MAX 2
|
||||
#define DFS_FD_MAX 4
|
||||
#define RT_USING_DFS_ELMFAT
|
||||
// <integer name="RT_DFS_ELM_USE_LFN" description="Support long file name" default="0">
|
||||
// <item description="LFN1">1</item>
|
||||
// <item description="LFN1">2</item>
|
||||
// </integer>
|
||||
#define RT_DFS_ELM_USE_LFN 1
|
||||
// <integer name="RT_DFS_ELM_MAX_LFN" description="Maximal size of file name length" default="255" />
|
||||
#define RT_DFS_ELM_MAX_LFN 64
|
||||
// <bool name="RT_USING_DFS_YAFFS2" description="Using YAFFS2" default="false" />
|
||||
// #define RT_USING_DFS_YAFFS2
|
||||
// <bool name="RT_USING_DFS_UFFS" description="Using UFFS" default="false" />
|
||||
// #define RT_USING_DFS_UFFS
|
||||
// <bool name="RT_USING_DFS_DEVFS" description="Using devfs for device objects" default="true" />
|
||||
// #define RT_USING_DFS_DEVFS
|
||||
// <bool name="RT_USING_DFS_NFS" description="Using NFS v3 client file system" default="false" />
|
||||
// #define RT_USING_DFS_NFS
|
||||
// <string name="RT_NFS_HOST_EXPORT" description="NFSv3 host export" default="192.168.1.5:/" />
|
||||
#define RT_NFS_HOST_EXPORT "192.168.1.254:/"
|
||||
// </section>
|
||||
|
||||
// <section name="RT_USING_LWIP" description="lwip, a lightweight TCP/IP protocol stack" default="true" >
|
||||
#define RT_USING_LWIP
|
||||
#define RT_USING_GMAC_INT_MODE
|
||||
#define RT_USING_LWIP141
|
||||
//#define RT_LWIP_DEBUG
|
||||
/* elm-chan's FatFs, Generic FAT Filesystem Module */
|
||||
|
||||
// <bool name="RT_LWIP_ICMP" description="Enable ICMP protocol" default="true" />
|
||||
#define RT_LWIP_ICMP
|
||||
// <bool name="RT_LWIP_IGMP" description="Enable IGMP protocol" default="false" />
|
||||
#define RT_LWIP_IGMP
|
||||
// <bool name="RT_LWIP_UDP" description="Enable UDP protocol" default="true" />
|
||||
#define RT_LWIP_UDP
|
||||
// <bool name="RT_LWIP_TCP" description="Enable TCP protocol" default="true" />
|
||||
#define RT_LWIP_TCP
|
||||
// <bool name="RT_LWIP_DNS" description="Enable DNS protocol" default="true" />
|
||||
#define RT_LWIP_DNS
|
||||
// <integer name="RT_LWIP_PBUF_NUM" description="Maximal number of buffers in the pbuf pool" default="4" />
|
||||
#define RT_LWIP_PBUF_NUM 4
|
||||
#define RT_LWIP_PBUF_POOL_BUFSIZE 2048
|
||||
// <integer name="RT_LWIP_TCP_PCB_NUM" description="Maximal number of simultaneously active TCP connections" default="5" />
|
||||
#define RT_LWIP_TCP_PCB_NUM 3
|
||||
// <integer name="RT_LWIP_TCP_SND_BUF" description="TCP sender buffer size" default="8192" />
|
||||
#define RT_LWIP_TCP_SND_BUF 4096
|
||||
// <integer name="RT_LWIP_TCP_WND" description="TCP receive window" default="8192" />
|
||||
#define RT_LWIP_TCP_WND 2048
|
||||
// <bool name="RT_LWIP_SNMP" description="Enable SNMP protocol" default="false" />
|
||||
// #define RT_LWIP_SNMP
|
||||
// <bool name="RT_LWIP_DHCP" description="Enable DHCP client to get IP address" default="false" />
|
||||
// #define RT_LWIP_DHCP
|
||||
// <integer name="RT_LWIP_TCP_SEG_NUM" description="the number of simultaneously queued TCP" default="4" />
|
||||
#define RT_LWIP_TCP_SEG_NUM 40
|
||||
// <integer name="RT_LWIP_TCPTHREAD_PRIORITY" description="the thread priority of TCP thread" default="128" />
|
||||
#define RT_LWIP_TCPTHREAD_PRIORITY 12
|
||||
// <integer name="RT_LWIP_TCPTHREAD_MBOX_SIZE" description="the mail box size of TCP thread to wait for" default="32" />
|
||||
#define RT_LWIP_TCPTHREAD_MBOX_SIZE 8
|
||||
// <integer name="RT_LWIP_TCPTHREAD_STACKSIZE" description="the thread stack size of TCP thread" default="4096" />
|
||||
#define RT_LWIP_TCPTHREAD_STACKSIZE 4096
|
||||
// <integer name="RT_LWIP_ETHTHREAD_PRIORITY" description="the thread priority of ethnetif thread" default="144" />
|
||||
#define RT_LWIP_ETHTHREAD_PRIORITY 14
|
||||
// <integer name="RT_LWIP_ETHTHREAD_MBOX_SIZE" description="the mail box size of ethnetif thread to wait for" default="8" />
|
||||
#define RT_LWIP_ETHTHREAD_MBOX_SIZE 8
|
||||
// <integer name="RT_LWIP_ETHTHREAD_STACKSIZE" description="the stack size of ethnetif thread" default="512" />
|
||||
#define RT_LWIP_ETHTHREAD_STACKSIZE 512
|
||||
#define RT_DFS_ELM_CODE_PAGE 936
|
||||
#define RT_DFS_ELM_WORD_ACCESS
|
||||
#define RT_DFS_ELM_USE_LFN_0
|
||||
/* RT_DFS_ELM_USE_LFN_1 is not set */
|
||||
/* RT_DFS_ELM_USE_LFN_2 is not set */
|
||||
/* RT_DFS_ELM_USE_LFN_3 is not set */
|
||||
#define RT_DFS_ELM_USE_LFN 0
|
||||
#define RT_DFS_ELM_MAX_LFN 64
|
||||
#define RT_DFS_ELM_DRIVES 2
|
||||
#define RT_DFS_ELM_MAX_SECTOR_SIZE 512
|
||||
/* RT_DFS_ELM_USE_ERASE is not set */
|
||||
#define RT_DFS_ELM_REENTRANT
|
||||
/* RT_USING_DFS_DEVFS is not set */
|
||||
/* RT_USING_DFS_NET is not set */
|
||||
/* RT_USING_DFS_ROMFS is not set */
|
||||
/* RT_USING_DFS_RAMFS is not set */
|
||||
/* RT_USING_DFS_UFFS is not set */
|
||||
/* RT_USING_DFS_JFFS2 is not set */
|
||||
/* RT_USING_DFS_NFS is not set */
|
||||
|
||||
/* ip address of target */
|
||||
#define RT_LWIP_IPADDR "192.168.1.254"
|
||||
|
||||
/* gateway address of target */
|
||||
#define RT_LWIP_GWADDR "192.168.1.1"
|
||||
|
||||
/* mask address of target */
|
||||
#define RT_LWIP_MSKADDR "255.255.255.0"
|
||||
|
||||
// </section>
|
||||
|
||||
// <section name="RT_USING_MODULE" description="Application module" default="true" >
|
||||
// #define RT_USING_MODULE
|
||||
// <bool name="RT_USING_LIBDL" description="Using dynamic library" default="true" />
|
||||
// #define RT_USING_LIBDL
|
||||
// </section>
|
||||
|
||||
// <section name="RT_USING_RTGUI" description="RTGUI, a graphic user interface" default="true" >
|
||||
// #define RT_USING_RTGUI
|
||||
// <integer name="RTGUI_NAME_MAX" description="Maximal size of RTGUI object name length" default="16" />
|
||||
#define RTGUI_NAME_MAX 16
|
||||
// <bool name="RTGUI_USING_FONT16" description="Support 16 weight font" default="true" />
|
||||
#define RTGUI_USING_FONT16
|
||||
// <bool name="RTGUI_USING_FONT12" description="Support 12 weight font" default="true" />
|
||||
#define RTGUI_USING_FONT12
|
||||
// <bool name="RTGUI_USING_FONTHZ" description="Support Chinese font" default="true" />
|
||||
#define RTGUI_USING_FONTHZ
|
||||
// <bool name="RTGUI_USING_DFS_FILERW" description="Using DFS as file interface " default="true" />
|
||||
#define RTGUI_USING_DFS_FILERW
|
||||
// <bool name="RTGUI_USING_HZ_FILE" description="Using font file as Chinese font" default="false" />
|
||||
// #define RTGUI_USING_HZ_FILE
|
||||
// <bool name="RTGUI_USING_HZ_BMP" description="Using Chinese bitmap font" default="true" />
|
||||
#define RTGUI_USING_HZ_BMP
|
||||
// <bool name="RTGUI_USING_SMALL_SIZE" description="Using small size in RTGUI" default="false" />
|
||||
#define RTGUI_USING_SMALL_SIZE
|
||||
// <bool name="RTGUI_USING_MOUSE_CURSOR" description="Using mouse cursor in RTGUI" default="false" />
|
||||
// #define RTGUI_USING_MOUSE_CURSOR
|
||||
// <bool name="RTGUI_IMAGE_XPM" description="Using xpm image in RTGUI" default="true" />
|
||||
#define RTGUI_IMAGE_XPM
|
||||
// <bool name="RTGUI_IMAGE_JPEG" description="Using jpeg image in RTGUI" default="true" />
|
||||
// #define RTGUI_IMAGE_JPEG
|
||||
// <bool name="RTGUI_IMAGE_PNG" description="Using png image in RTGUI" default="true" />
|
||||
// #define RTGUI_IMAGE_PNG
|
||||
// <bool name="RTGUI_IMAGE_BMP" description="Using bmp image in RTGUI" default="true" />
|
||||
#define RTGUI_IMAGE_BMP
|
||||
// </section>
|
||||
|
||||
#define RT_USING_SPI
|
||||
#define RT_USING_SPI0
|
||||
#define RT_USING_SPI1
|
||||
/* Device Drivers */
|
||||
|
||||
#define RT_USING_DEVICE_IPC
|
||||
#define RT_USING_SERIAL
|
||||
#define RT_USING_CAN
|
||||
#define RT_CAN_USING_HDR
|
||||
/* RT_USING_HWTIMER is not set */
|
||||
/* RT_USING_CPUTIME is not set */
|
||||
#define RT_USING_I2C
|
||||
#define RT_USING_I2C_BITOPS
|
||||
|
||||
|
||||
#define RT_USING_PIN
|
||||
/* RT_USING_MTD_NOR is not set */
|
||||
/* RT_USING_MTD_NAND is not set */
|
||||
/* RT_USING_RTC is not set */
|
||||
/* RT_USING_SDIO is not set */
|
||||
#define RT_USING_SPI
|
||||
#define RT_USING_SPI_MSD
|
||||
/* RT_USING_SFUD is not set */
|
||||
/* RT_USING_W25QXX is not set */
|
||||
/* RT_USING_GD is not set */
|
||||
/* RT_USING_ENC28J60 is not set */
|
||||
/* RT_USING_SPI_WIFI is not set */
|
||||
/* RT_USING_WDT is not set */
|
||||
/* RT_USING_WIFI is not set */
|
||||
|
||||
/* Using USB */
|
||||
|
||||
// </RDTConfigurator>
|
||||
/* RT_USING_USB_HOST is not set */
|
||||
/* RT_USING_USB_DEVICE is not set */
|
||||
|
||||
/* POSIX layer and C standard library */
|
||||
|
||||
#define RT_USING_LIBC
|
||||
#define RT_USING_PTHREADS
|
||||
/* RT_USING_POSIX is not set */
|
||||
/* HAVE_SYS_SIGNALS is not set */
|
||||
|
||||
/* Network stack */
|
||||
|
||||
/* light weight TCP/IP stack */
|
||||
|
||||
#define RT_USING_LWIP
|
||||
#define RT_USING_LWIP141
|
||||
/* RT_USING_LWIP202 is not set */
|
||||
#define RT_LWIP_IGMP
|
||||
#define RT_LWIP_ICMP
|
||||
/* RT_LWIP_SNMP is not set */
|
||||
#define RT_LWIP_DNS
|
||||
/* RT_LWIP_DHCP is not set */
|
||||
|
||||
/* Static IPv4 Address */
|
||||
|
||||
#define RT_LWIP_IPADDR "192.168.1.254"
|
||||
#define RT_LWIP_GWADDR "192.168.1.1"
|
||||
#define RT_LWIP_MSKADDR "255.255.255.0"
|
||||
#define RT_LWIP_UDP
|
||||
#define RT_LWIP_TCP
|
||||
/* RT_LWIP_RAW is not set */
|
||||
/* RT_LWIP_PPP is not set */
|
||||
#define RT_MEMP_NUM_NETCONN 8
|
||||
#define RT_LWIP_PBUF_NUM 4
|
||||
#define RT_LWIP_RAW_PCB_NUM 4
|
||||
#define RT_LWIP_UDP_PCB_NUM 4
|
||||
#define RT_LWIP_TCP_PCB_NUM 3
|
||||
#define RT_LWIP_TCP_SEG_NUM 40
|
||||
#define RT_LWIP_TCP_SND_BUF 4096
|
||||
#define RT_LWIP_TCP_WND 2048
|
||||
#define RT_LWIP_TCPTHREAD_PRIORITY 12
|
||||
#define RT_LWIP_TCPTHREAD_MBOX_SIZE 8
|
||||
#define RT_LWIP_TCPTHREAD_STACKSIZE 4096
|
||||
#define RT_LWIP_ETHTHREAD_PRIORITY 14
|
||||
#define RT_LWIP_ETHTHREAD_STACKSIZE 512
|
||||
#define RT_LWIP_ETHTHREAD_MBOX_SIZE 8
|
||||
/* RT_LWIP_REASSEMBLY_FRAG is not set */
|
||||
#define LWIP_NETIF_STATUS_CALLBACK 1
|
||||
#define SO_REUSE 1
|
||||
#define LWIP_SO_RCVTIMEO 1
|
||||
#define LWIP_SO_SNDTIMEO 1
|
||||
#define LWIP_SO_RCVBUF 1
|
||||
/* RT_LWIP_NETIF_LOOPBACK is not set */
|
||||
#define LWIP_NETIF_LOOPBACK 0
|
||||
|
||||
/* Modbus master and slave stack */
|
||||
|
||||
/* RT_USING_MODBUS is not set */
|
||||
/* LWIP_USING_DHCPD is not set */
|
||||
|
||||
/* VBUS(Virtual Software BUS) */
|
||||
|
||||
/* RT_USING_VBUS is not set */
|
||||
|
||||
/* Utilities */
|
||||
|
||||
/* RT_USING_LOGTRACE is not set */
|
||||
/* RT_USING_RYM is not set */
|
||||
|
||||
/* RT-Thread online packages */
|
||||
|
||||
/* system packages */
|
||||
|
||||
/* PKG_USING_PARTITION is not set */
|
||||
/* PKG_USING_SQLITE is not set */
|
||||
/* PKG_USING_RTI is not set */
|
||||
|
||||
/* IoT - internet of things */
|
||||
|
||||
/* PKG_USING_PAHOMQTT is not set */
|
||||
/* PKG_USING_WEBCLIENT is not set */
|
||||
/* PKG_USING_MONGOOSE is not set */
|
||||
/* PKG_USING_WEBTERMINAL is not set */
|
||||
/* PKG_USING_CJSON is not set */
|
||||
/* PKG_USING_EZXML is not set */
|
||||
/* PKG_USING_NANOPB is not set */
|
||||
|
||||
/* security packages */
|
||||
|
||||
/* PKG_USING_MBEDTLS is not set */
|
||||
/* PKG_USING_libsodium is not set */
|
||||
|
||||
/* language packages */
|
||||
|
||||
/* PKG_USING_JERRYSCRIPT is not set */
|
||||
/* PKG_USING_MICROPYTHON is not set */
|
||||
|
||||
/* multimedia packages */
|
||||
|
||||
/* tools packages */
|
||||
|
||||
/* PKG_USING_CMBACKTRACE is not set */
|
||||
/* PKG_USING_EASYLOGGER is not set */
|
||||
/* PKG_USING_SYSTEMVIEW is not set */
|
||||
|
||||
/* miscellaneous packages */
|
||||
|
||||
/* PKG_USING_FASTLZ is not set */
|
||||
/* PKG_USING_MINILZO is not set */
|
||||
|
||||
/* example package: hello */
|
||||
|
||||
/* PKG_USING_HELLO is not set */
|
||||
#define RT_USING_UART2
|
||||
#define RT_UART_RX_BUFFER_SIZE 64
|
||||
#define RT_USING_GMAC_INT_MODE
|
||||
#define RT_USING_FPU
|
||||
#define RT_USING_SPI0
|
||||
#define RT_USING_SPI1
|
||||
#define RT_USING_I2C1
|
||||
#define RT_USING_I2C2
|
||||
#define USING_BXCAN0
|
||||
#define USING_BXCAN1
|
||||
|
||||
#endif
|
||||
|
|
|
@ -76,6 +76,7 @@ CONFIG_FINSH_USING_HISTORY=y
|
|||
CONFIG_FINSH_HISTORY_LINES=5
|
||||
CONFIG_FINSH_USING_SYMTAB=y
|
||||
CONFIG_FINSH_USING_DESCRIPTION=y
|
||||
# CONFIG_FINSH_ECHO_DISABLE_DEFAULT is not set
|
||||
CONFIG_FINSH_THREAD_PRIORITY=20
|
||||
CONFIG_FINSH_THREAD_STACK_SIZE=4096
|
||||
CONFIG_FINSH_CMD_SIZE=80
|
||||
|
@ -98,7 +99,7 @@ CONFIG_RT_USING_SERIAL=y
|
|||
# CONFIG_RT_USING_HWTIMER is not set
|
||||
# CONFIG_RT_USING_CPUTIME is not set
|
||||
# CONFIG_RT_USING_I2C is not set
|
||||
# CONFIG_RT_USING_PIN is not set
|
||||
CONFIG_RT_USING_PIN=y
|
||||
# CONFIG_RT_USING_MTD_NOR is not set
|
||||
# CONFIG_RT_USING_MTD_NAND is not set
|
||||
# CONFIG_RT_USING_RTC is not set
|
||||
|
@ -118,6 +119,7 @@ CONFIG_RT_USING_SERIAL=y
|
|||
#
|
||||
CONFIG_RT_USING_LIBC=y
|
||||
# CONFIG_RT_USING_PTHREADS is not set
|
||||
# CONFIG_HAVE_SYS_SIGNALS is not set
|
||||
|
||||
#
|
||||
# Network stack
|
||||
|
@ -133,11 +135,6 @@ CONFIG_RT_USING_LIBC=y
|
|||
#
|
||||
# CONFIG_RT_USING_MODBUS is not set
|
||||
|
||||
#
|
||||
# RT-Thread UI Engine
|
||||
#
|
||||
# CONFIG_PKG_USING_GUIENGINE is not set
|
||||
|
||||
#
|
||||
# VBUS(Virtual Software BUS)
|
||||
#
|
||||
|
@ -162,8 +159,14 @@ CONFIG_RT_USING_LIBC=y
|
|||
#
|
||||
# system packages
|
||||
#
|
||||
# CONFIG_PKG_USING_PARTITION is not set
|
||||
|
||||
#
|
||||
# RT-Thread GUI Engine
|
||||
#
|
||||
# CONFIG_PKG_USING_GUIENGINE is not set
|
||||
# CONFIG_PKG_USING_PERSIMMON is not set
|
||||
# CONFIG_PKG_USING_LWEXT4 is not set
|
||||
# CONFIG_PKG_USING_PARTITION is not set
|
||||
# CONFIG_PKG_USING_SQLITE is not set
|
||||
# CONFIG_PKG_USING_RTI is not set
|
||||
|
||||
|
@ -194,6 +197,8 @@ CONFIG_RT_USING_LIBC=y
|
|||
#
|
||||
# CONFIG_PKG_USING_WLAN_WICED is not set
|
||||
# CONFIG_PKG_USING_COAP is not set
|
||||
# CONFIG_PKG_USING_NOPOLL is not set
|
||||
# CONFIG_PKG_USING_NETUTILS is not set
|
||||
|
||||
#
|
||||
# security packages
|
||||
|
@ -206,7 +211,43 @@ CONFIG_RT_USING_LIBC=y
|
|||
# language packages
|
||||
#
|
||||
# CONFIG_PKG_USING_JERRYSCRIPT is not set
|
||||
# CONFIG_PKG_USING_MICROPYTHON is not set
|
||||
CONFIG_PKG_USING_MICROPYTHON=y
|
||||
CONFIG_PKG_MICROPYTHON_PATH="/packages/language/micropython"
|
||||
|
||||
#
|
||||
# System Module
|
||||
#
|
||||
# CONFIG_MICROPYTHON_USING_UOS is not set
|
||||
# CONFIG_MICROPYTHON_USING_USELECT is not set
|
||||
# CONFIG_MICROPYTHON_USING_UCTYPES is not set
|
||||
# CONFIG_MICROPYTHON_USING_UERRNO is not set
|
||||
|
||||
#
|
||||
# Tools Module
|
||||
#
|
||||
# CONFIG_MICROPYTHON_USING_CMATH is not set
|
||||
# CONFIG_MICROPYTHON_USING_UBINASCII is not set
|
||||
# CONFIG_MICROPYTHON_USING_UHASHLIB is not set
|
||||
# CONFIG_MICROPYTHON_USING_UHEAPQ is not set
|
||||
# CONFIG_MICROPYTHON_USING_UJSON is not set
|
||||
# CONFIG_MICROPYTHON_USING_URE is not set
|
||||
# CONFIG_MICROPYTHON_USING_UZLIB is not set
|
||||
# CONFIG_MICROPYTHON_USING_URANDOM is not set
|
||||
|
||||
#
|
||||
# Network Module
|
||||
#
|
||||
# CONFIG_MICROPYTHON_USING_USOCKET is not set
|
||||
|
||||
#
|
||||
# Hardware Module
|
||||
#
|
||||
# CONFIG_MICROPYTHON_USING_MACHINE_I2C is not set
|
||||
# CONFIG_MICROPYTHON_USING_MACHINE_SPI is not set
|
||||
CONFIG_PKG_MICROPYTHON_HEAP_SIZE=8192
|
||||
CONFIG_PKG_USING_MICROPYTHON_LATEST_VERSION=y
|
||||
# CONFIG_PKG_USING_MICROPYTHON_V10903 is not set
|
||||
CONFIG_PKG_MICROPYTHON_VER="latest"
|
||||
|
||||
#
|
||||
# multimedia packages
|
||||
|
@ -217,6 +258,7 @@ CONFIG_RT_USING_LIBC=y
|
|||
# tools packages
|
||||
#
|
||||
# CONFIG_PKG_USING_CMBACKTRACE is not set
|
||||
# CONFIG_PKG_USING_EASYFLASH is not set
|
||||
# CONFIG_PKG_USING_EASYLOGGER is not set
|
||||
# CONFIG_PKG_USING_SYSTEMVIEW is not set
|
||||
# CONFIG_PKG_USING_IPERF is not set
|
||||
|
@ -226,6 +268,8 @@ CONFIG_RT_USING_LIBC=y
|
|||
#
|
||||
# CONFIG_PKG_USING_FASTLZ is not set
|
||||
# CONFIG_PKG_USING_MINILZO is not set
|
||||
# CONFIG_PKG_USING_QUICKLZ is not set
|
||||
# CONFIG_PKG_USING_MULTIBUTTON is not set
|
||||
|
||||
#
|
||||
# example package: hello
|
||||
|
@ -243,10 +287,6 @@ CONFIG_RT_USING_LIBC=y
|
|||
# Network Utilities
|
||||
#
|
||||
# CONFIG_PKG_USING_WLAN_WICED_SRC is not set
|
||||
|
||||
#
|
||||
# Cloudsdk: RT_thread IOT Cloudsdk
|
||||
#
|
||||
# CONFIG_PKG_USING_CLOUDSDK is not set
|
||||
|
||||
#
|
||||
|
@ -255,6 +295,7 @@ CONFIG_RT_USING_LIBC=y
|
|||
# CONFIG_PKG_USING_WEBNET is not set
|
||||
# CONFIG_PKG_USING_COREMARK is not set
|
||||
# CONFIG_PKG_USING_POWER_MANAGER is not set
|
||||
# CONFIG_PKG_USING_RT_OTA is not set
|
||||
CONFIG_SOC_V2M_MPS2=y
|
||||
CONFIG_RT_USING_UART=y
|
||||
CONFIG_RT_USING_UART0=y
|
||||
|
|
|
@ -11,6 +11,9 @@ drv_uart.c
|
|||
CPPPATH = [cwd]
|
||||
CPPDEFINES = []
|
||||
|
||||
if GetDepend('RT_USING_PIN'):
|
||||
src += ['drv_pin.c']
|
||||
|
||||
group = DefineGroup('Drivers', src, depend = [''], CPPPATH = CPPPATH, CPPDEFINES=CPPDEFINES)
|
||||
|
||||
Return('group')
|
||||
|
|
|
@ -0,0 +1,89 @@
|
|||
/*
|
||||
* File : drv_pin.c
|
||||
* This file is part of RT-Thread RTOS
|
||||
* COPYRIGHT (C) 2006-2013, RT-Thread Development Team
|
||||
*
|
||||
* The license and distribution terms for this file may be
|
||||
* found in the file LICENSE in this distribution or at
|
||||
* http://www.rt-thread.org/license/LICENSE
|
||||
*
|
||||
* Change Logs:
|
||||
* Date Author Notes
|
||||
* 2018-03-25 Tanek the first version.
|
||||
*/
|
||||
#include <rtthread.h>
|
||||
#include <rthw.h>
|
||||
#include <drivers/pin.h>
|
||||
#include <SMM_MPS2.h>
|
||||
|
||||
#ifdef RT_USING_PIN
|
||||
|
||||
// pin 0 ~ 7 : switch 0 ~ 7
|
||||
// pin 8 ~ 15 : user led 0 ~ 7
|
||||
|
||||
static void v2m_pin_mode(rt_device_t dev, rt_base_t pin, rt_base_t mode)
|
||||
{
|
||||
return ;
|
||||
}
|
||||
|
||||
static int v2m_pin_read(rt_device_t dev, rt_base_t pin)
|
||||
{
|
||||
RT_ASSERT(dev != RT_NULL);
|
||||
|
||||
if (0 <= pin && pin <= 7)
|
||||
{
|
||||
return !!(MPS2_SCC->CFG_REG3 & (0x01 << pin)); // switchs
|
||||
}
|
||||
else if (8 <= pin && pin <= 15)
|
||||
{
|
||||
return !!(MPS2_SCC->CFG_REG1 & (0x01 << (pin - 8))); // leds
|
||||
}
|
||||
else
|
||||
{
|
||||
RT_ASSERT(RT_NULL);
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
static void v2m_pin_write(rt_device_t dev, rt_base_t pin, rt_base_t value)
|
||||
{
|
||||
RT_ASSERT(dev != RT_NULL);
|
||||
|
||||
if (8 <= pin && pin <= 15)
|
||||
{
|
||||
rt_uint32_t reg = MPS2_SCC->CFG_REG1;
|
||||
|
||||
if (value)
|
||||
reg |= 1 << (pin - 8);
|
||||
else
|
||||
reg &= ~(1 << (pin - 8));
|
||||
|
||||
MPS2_SCC->CFG_REG1 = reg;
|
||||
}
|
||||
else
|
||||
{
|
||||
RT_ASSERT(RT_NULL);
|
||||
}
|
||||
}
|
||||
|
||||
int rt_hw_pin_init(void)
|
||||
{
|
||||
int ret = RT_EOK;
|
||||
|
||||
static const struct rt_pin_ops v2m_pin_ops =
|
||||
{
|
||||
v2m_pin_mode,
|
||||
v2m_pin_write,
|
||||
v2m_pin_read,
|
||||
RT_NULL,
|
||||
RT_NULL,
|
||||
RT_NULL
|
||||
};
|
||||
|
||||
ret = rt_device_pin_register("pin", &v2m_pin_ops, RT_NULL);
|
||||
|
||||
return ret;
|
||||
}
|
||||
INIT_BOARD_EXPORT(rt_hw_pin_init);
|
||||
|
||||
#endif /*RT_USING_PIN */
|
File diff suppressed because it is too large
Load Diff
|
@ -336,7 +336,7 @@
|
|||
<MiscControls>--library_interface=armcc --library_type=standardlib --diag_suppress=66,1296,186</MiscControls>
|
||||
<Define>RT_USING_ARM_LIBC</Define>
|
||||
<Undefine></Undefine>
|
||||
<IncludePath>applications;.;drivers;..\..\include;..\..\libcpu\arm\cortex-m7;..\..\libcpu\arm\common;..\..\components\drivers\include;..\..\components\drivers\include;..\..\components\finsh;..\..\components\libc\compilers\armlibc</IncludePath>
|
||||
<IncludePath>applications;.;drivers;packages\micropython;packages\micropython\port;packages\micropython\lib\netutils;..\..\include;..\..\libcpu\arm\cortex-m7;..\..\libcpu\arm\common;..\..\components\drivers\include;..\..\components\drivers\include;..\..\components\drivers\include;..\..\components\finsh;..\..\components\libc\compilers\armlibc</IncludePath>
|
||||
</VariousControls>
|
||||
</Cads>
|
||||
<Aads>
|
||||
|
@ -400,6 +400,879 @@
|
|||
<FileType>1</FileType>
|
||||
<FilePath>drivers\drv_uart.c</FilePath>
|
||||
</File>
|
||||
<File>
|
||||
<FileName>drv_pin.c</FileName>
|
||||
<FileType>1</FileType>
|
||||
<FilePath>drivers\drv_pin.c</FilePath>
|
||||
</File>
|
||||
</Files>
|
||||
</Group>
|
||||
<Group>
|
||||
<GroupName>MicroPython</GroupName>
|
||||
<GroupOption>
|
||||
<CommonProperty>
|
||||
<UseCPPCompiler>0</UseCPPCompiler>
|
||||
<RVCTCodeConst>0</RVCTCodeConst>
|
||||
<RVCTZI>0</RVCTZI>
|
||||
<RVCTOtherData>0</RVCTOtherData>
|
||||
<ModuleSelection>0</ModuleSelection>
|
||||
<IncludeInBuild>1</IncludeInBuild>
|
||||
<AlwaysBuild>0</AlwaysBuild>
|
||||
<GenerateAssemblyFile>0</GenerateAssemblyFile>
|
||||
<AssembleAssemblyFile>0</AssembleAssemblyFile>
|
||||
<PublicsOnly>0</PublicsOnly>
|
||||
<StopOnExitCode>3</StopOnExitCode>
|
||||
<CustomArgument></CustomArgument>
|
||||
<IncludeLibraryModules></IncludeLibraryModules>
|
||||
<ComprImg>0</ComprImg>
|
||||
</CommonProperty>
|
||||
<GroupArmAds>
|
||||
<Cads>
|
||||
<interw>2</interw>
|
||||
<Optim>0</Optim>
|
||||
<oTime>2</oTime>
|
||||
<SplitLS>2</SplitLS>
|
||||
<OneElfS>2</OneElfS>
|
||||
<Strict>2</Strict>
|
||||
<EnumInt>2</EnumInt>
|
||||
<PlainCh>2</PlainCh>
|
||||
<Ropi>2</Ropi>
|
||||
<Rwpi>2</Rwpi>
|
||||
<wLevel>0</wLevel>
|
||||
<uThumb>2</uThumb>
|
||||
<uSurpInc>2</uSurpInc>
|
||||
<uC99>2</uC99>
|
||||
<useXO>2</useXO>
|
||||
<v6Lang>0</v6Lang>
|
||||
<v6LangP>0</v6LangP>
|
||||
<vShortEn>2</vShortEn>
|
||||
<vShortWch>2</vShortWch>
|
||||
<v6Lto>2</v6Lto>
|
||||
<v6WtE>2</v6WtE>
|
||||
<v6Rtti>2</v6Rtti>
|
||||
<VariousControls>
|
||||
<MiscControls> --c99 --gnu</MiscControls>
|
||||
<Define> </Define>
|
||||
<Undefine> </Undefine>
|
||||
<IncludePath></IncludePath>
|
||||
</VariousControls>
|
||||
</Cads>
|
||||
<Aads>
|
||||
<interw>2</interw>
|
||||
<Ropi>2</Ropi>
|
||||
<Rwpi>2</Rwpi>
|
||||
<thumb>2</thumb>
|
||||
<SplitLS>2</SplitLS>
|
||||
<SwStkChk>2</SwStkChk>
|
||||
<NoWarn>2</NoWarn>
|
||||
<uSurpInc>2</uSurpInc>
|
||||
<useXO>2</useXO>
|
||||
<uClangAs>2</uClangAs>
|
||||
<VariousControls>
|
||||
<MiscControls></MiscControls>
|
||||
<Define></Define>
|
||||
<Undefine></Undefine>
|
||||
<IncludePath></IncludePath>
|
||||
</VariousControls>
|
||||
</Aads>
|
||||
</GroupArmAds>
|
||||
</GroupOption>
|
||||
<Files>
|
||||
<File>
|
||||
<FileName>argcheck.c</FileName>
|
||||
<FileType>1</FileType>
|
||||
<FilePath>packages\micropython\py\argcheck.c</FilePath>
|
||||
</File>
|
||||
<File>
|
||||
<FileName>asmarm.c</FileName>
|
||||
<FileType>1</FileType>
|
||||
<FilePath>packages\micropython\py\asmarm.c</FilePath>
|
||||
</File>
|
||||
<File>
|
||||
<FileName>asmbase.c</FileName>
|
||||
<FileType>1</FileType>
|
||||
<FilePath>packages\micropython\py\asmbase.c</FilePath>
|
||||
</File>
|
||||
<File>
|
||||
<FileName>asmthumb.c</FileName>
|
||||
<FileType>1</FileType>
|
||||
<FilePath>packages\micropython\py\asmthumb.c</FilePath>
|
||||
</File>
|
||||
<File>
|
||||
<FileName>asmx64.c</FileName>
|
||||
<FileType>1</FileType>
|
||||
<FilePath>packages\micropython\py\asmx64.c</FilePath>
|
||||
</File>
|
||||
<File>
|
||||
<FileName>asmx86.c</FileName>
|
||||
<FileType>1</FileType>
|
||||
<FilePath>packages\micropython\py\asmx86.c</FilePath>
|
||||
</File>
|
||||
<File>
|
||||
<FileName>asmxtensa.c</FileName>
|
||||
<FileType>1</FileType>
|
||||
<FilePath>packages\micropython\py\asmxtensa.c</FilePath>
|
||||
</File>
|
||||
<File>
|
||||
<FileName>bc.c</FileName>
|
||||
<FileType>1</FileType>
|
||||
<FilePath>packages\micropython\py\bc.c</FilePath>
|
||||
</File>
|
||||
<File>
|
||||
<FileName>binary.c</FileName>
|
||||
<FileType>1</FileType>
|
||||
<FilePath>packages\micropython\py\binary.c</FilePath>
|
||||
</File>
|
||||
<File>
|
||||
<FileName>builtinevex.c</FileName>
|
||||
<FileType>1</FileType>
|
||||
<FilePath>packages\micropython\py\builtinevex.c</FilePath>
|
||||
</File>
|
||||
<File>
|
||||
<FileName>builtinhelp.c</FileName>
|
||||
<FileType>1</FileType>
|
||||
<FilePath>packages\micropython\py\builtinhelp.c</FilePath>
|
||||
</File>
|
||||
<File>
|
||||
<FileName>builtinimport.c</FileName>
|
||||
<FileType>1</FileType>
|
||||
<FilePath>packages\micropython\py\builtinimport.c</FilePath>
|
||||
</File>
|
||||
<File>
|
||||
<FileName>compile.c</FileName>
|
||||
<FileType>1</FileType>
|
||||
<FilePath>packages\micropython\py\compile.c</FilePath>
|
||||
</File>
|
||||
<File>
|
||||
<FileName>emitbc.c</FileName>
|
||||
<FileType>1</FileType>
|
||||
<FilePath>packages\micropython\py\emitbc.c</FilePath>
|
||||
</File>
|
||||
<File>
|
||||
<FileName>emitcommon.c</FileName>
|
||||
<FileType>1</FileType>
|
||||
<FilePath>packages\micropython\py\emitcommon.c</FilePath>
|
||||
</File>
|
||||
<File>
|
||||
<FileName>emitglue.c</FileName>
|
||||
<FileType>1</FileType>
|
||||
<FilePath>packages\micropython\py\emitglue.c</FilePath>
|
||||
</File>
|
||||
<File>
|
||||
<FileName>emitinlinethumb.c</FileName>
|
||||
<FileType>1</FileType>
|
||||
<FilePath>packages\micropython\py\emitinlinethumb.c</FilePath>
|
||||
</File>
|
||||
<File>
|
||||
<FileName>emitinlinextensa.c</FileName>
|
||||
<FileType>1</FileType>
|
||||
<FilePath>packages\micropython\py\emitinlinextensa.c</FilePath>
|
||||
</File>
|
||||
<File>
|
||||
<FileName>emitnative.c</FileName>
|
||||
<FileType>1</FileType>
|
||||
<FilePath>packages\micropython\py\emitnative.c</FilePath>
|
||||
</File>
|
||||
<File>
|
||||
<FileName>formatfloat.c</FileName>
|
||||
<FileType>1</FileType>
|
||||
<FilePath>packages\micropython\py\formatfloat.c</FilePath>
|
||||
</File>
|
||||
<File>
|
||||
<FileName>frozenmod.c</FileName>
|
||||
<FileType>1</FileType>
|
||||
<FilePath>packages\micropython\py\frozenmod.c</FilePath>
|
||||
</File>
|
||||
<File>
|
||||
<FileName>gc.c</FileName>
|
||||
<FileType>1</FileType>
|
||||
<FilePath>packages\micropython\py\gc.c</FilePath>
|
||||
</File>
|
||||
<File>
|
||||
<FileName>lexer.c</FileName>
|
||||
<FileType>1</FileType>
|
||||
<FilePath>packages\micropython\py\lexer.c</FilePath>
|
||||
</File>
|
||||
<File>
|
||||
<FileName>malloc.c</FileName>
|
||||
<FileType>1</FileType>
|
||||
<FilePath>packages\micropython\py\malloc.c</FilePath>
|
||||
</File>
|
||||
<File>
|
||||
<FileName>map.c</FileName>
|
||||
<FileType>1</FileType>
|
||||
<FilePath>packages\micropython\py\map.c</FilePath>
|
||||
</File>
|
||||
<File>
|
||||
<FileName>modarray.c</FileName>
|
||||
<FileType>1</FileType>
|
||||
<FilePath>packages\micropython\py\modarray.c</FilePath>
|
||||
</File>
|
||||
<File>
|
||||
<FileName>modbuiltins.c</FileName>
|
||||
<FileType>1</FileType>
|
||||
<FilePath>packages\micropython\py\modbuiltins.c</FilePath>
|
||||
</File>
|
||||
<File>
|
||||
<FileName>modcmath.c</FileName>
|
||||
<FileType>1</FileType>
|
||||
<FilePath>packages\micropython\py\modcmath.c</FilePath>
|
||||
</File>
|
||||
<File>
|
||||
<FileName>modcollections.c</FileName>
|
||||
<FileType>1</FileType>
|
||||
<FilePath>packages\micropython\py\modcollections.c</FilePath>
|
||||
</File>
|
||||
<File>
|
||||
<FileName>modgc.c</FileName>
|
||||
<FileType>1</FileType>
|
||||
<FilePath>packages\micropython\py\modgc.c</FilePath>
|
||||
</File>
|
||||
<File>
|
||||
<FileName>modio.c</FileName>
|
||||
<FileType>1</FileType>
|
||||
<FilePath>packages\micropython\py\modio.c</FilePath>
|
||||
</File>
|
||||
<File>
|
||||
<FileName>modmath.c</FileName>
|
||||
<FileType>1</FileType>
|
||||
<FilePath>packages\micropython\py\modmath.c</FilePath>
|
||||
</File>
|
||||
<File>
|
||||
<FileName>modmicropython.c</FileName>
|
||||
<FileType>1</FileType>
|
||||
<FilePath>packages\micropython\py\modmicropython.c</FilePath>
|
||||
</File>
|
||||
<File>
|
||||
<FileName>modstruct.c</FileName>
|
||||
<FileType>1</FileType>
|
||||
<FilePath>packages\micropython\py\modstruct.c</FilePath>
|
||||
</File>
|
||||
<File>
|
||||
<FileName>modsys.c</FileName>
|
||||
<FileType>1</FileType>
|
||||
<FilePath>packages\micropython\py\modsys.c</FilePath>
|
||||
</File>
|
||||
<File>
|
||||
<FileName>modthread.c</FileName>
|
||||
<FileType>1</FileType>
|
||||
<FilePath>packages\micropython\py\modthread.c</FilePath>
|
||||
</File>
|
||||
<File>
|
||||
<FileName>moduerrno.c</FileName>
|
||||
<FileType>1</FileType>
|
||||
<FilePath>packages\micropython\py\moduerrno.c</FilePath>
|
||||
</File>
|
||||
<File>
|
||||
<FileName>mpprint.c</FileName>
|
||||
<FileType>1</FileType>
|
||||
<FilePath>packages\micropython\py\mpprint.c</FilePath>
|
||||
</File>
|
||||
<File>
|
||||
<FileName>mpstate.c</FileName>
|
||||
<FileType>1</FileType>
|
||||
<FilePath>packages\micropython\py\mpstate.c</FilePath>
|
||||
</File>
|
||||
<File>
|
||||
<FileName>mpy_scheduler.c</FileName>
|
||||
<FileType>1</FileType>
|
||||
<FilePath>packages\micropython\py\mpy_scheduler.c</FilePath>
|
||||
</File>
|
||||
<File>
|
||||
<FileName>mpz.c</FileName>
|
||||
<FileType>1</FileType>
|
||||
<FilePath>packages\micropython\py\mpz.c</FilePath>
|
||||
</File>
|
||||
<File>
|
||||
<FileName>nativeglue.c</FileName>
|
||||
<FileType>1</FileType>
|
||||
<FilePath>packages\micropython\py\nativeglue.c</FilePath>
|
||||
</File>
|
||||
<File>
|
||||
<FileName>nlr.c</FileName>
|
||||
<FileType>1</FileType>
|
||||
<FilePath>packages\micropython\py\nlr.c</FilePath>
|
||||
</File>
|
||||
<File>
|
||||
<FileName>nlrsetjmp.c</FileName>
|
||||
<FileType>1</FileType>
|
||||
<FilePath>packages\micropython\py\nlrsetjmp.c</FilePath>
|
||||
</File>
|
||||
<File>
|
||||
<FileName>nlrthumb.c</FileName>
|
||||
<FileType>1</FileType>
|
||||
<FilePath>packages\micropython\py\nlrthumb.c</FilePath>
|
||||
</File>
|
||||
<File>
|
||||
<FileName>nlrx64.c</FileName>
|
||||
<FileType>1</FileType>
|
||||
<FilePath>packages\micropython\py\nlrx64.c</FilePath>
|
||||
</File>
|
||||
<File>
|
||||
<FileName>nlrx86.c</FileName>
|
||||
<FileType>1</FileType>
|
||||
<FilePath>packages\micropython\py\nlrx86.c</FilePath>
|
||||
</File>
|
||||
<File>
|
||||
<FileName>nlrxtensa.c</FileName>
|
||||
<FileType>1</FileType>
|
||||
<FilePath>packages\micropython\py\nlrxtensa.c</FilePath>
|
||||
</File>
|
||||
<File>
|
||||
<FileName>obj.c</FileName>
|
||||
<FileType>1</FileType>
|
||||
<FilePath>packages\micropython\py\obj.c</FilePath>
|
||||
</File>
|
||||
<File>
|
||||
<FileName>objarray.c</FileName>
|
||||
<FileType>1</FileType>
|
||||
<FilePath>packages\micropython\py\objarray.c</FilePath>
|
||||
</File>
|
||||
<File>
|
||||
<FileName>objattrtuple.c</FileName>
|
||||
<FileType>1</FileType>
|
||||
<FilePath>packages\micropython\py\objattrtuple.c</FilePath>
|
||||
</File>
|
||||
<File>
|
||||
<FileName>objbool.c</FileName>
|
||||
<FileType>1</FileType>
|
||||
<FilePath>packages\micropython\py\objbool.c</FilePath>
|
||||
</File>
|
||||
<File>
|
||||
<FileName>objboundmeth.c</FileName>
|
||||
<FileType>1</FileType>
|
||||
<FilePath>packages\micropython\py\objboundmeth.c</FilePath>
|
||||
</File>
|
||||
<File>
|
||||
<FileName>objcell.c</FileName>
|
||||
<FileType>1</FileType>
|
||||
<FilePath>packages\micropython\py\objcell.c</FilePath>
|
||||
</File>
|
||||
<File>
|
||||
<FileName>objclosure.c</FileName>
|
||||
<FileType>1</FileType>
|
||||
<FilePath>packages\micropython\py\objclosure.c</FilePath>
|
||||
</File>
|
||||
<File>
|
||||
<FileName>objcomplex.c</FileName>
|
||||
<FileType>1</FileType>
|
||||
<FilePath>packages\micropython\py\objcomplex.c</FilePath>
|
||||
</File>
|
||||
<File>
|
||||
<FileName>objdeque.c</FileName>
|
||||
<FileType>1</FileType>
|
||||
<FilePath>packages\micropython\py\objdeque.c</FilePath>
|
||||
</File>
|
||||
<File>
|
||||
<FileName>objdict.c</FileName>
|
||||
<FileType>1</FileType>
|
||||
<FilePath>packages\micropython\py\objdict.c</FilePath>
|
||||
</File>
|
||||
<File>
|
||||
<FileName>objenumerate.c</FileName>
|
||||
<FileType>1</FileType>
|
||||
<FilePath>packages\micropython\py\objenumerate.c</FilePath>
|
||||
</File>
|
||||
<File>
|
||||
<FileName>objexcept.c</FileName>
|
||||
<FileType>1</FileType>
|
||||
<FilePath>packages\micropython\py\objexcept.c</FilePath>
|
||||
</File>
|
||||
<File>
|
||||
<FileName>objfilter.c</FileName>
|
||||
<FileType>1</FileType>
|
||||
<FilePath>packages\micropython\py\objfilter.c</FilePath>
|
||||
</File>
|
||||
<File>
|
||||
<FileName>objfloat.c</FileName>
|
||||
<FileType>1</FileType>
|
||||
<FilePath>packages\micropython\py\objfloat.c</FilePath>
|
||||
</File>
|
||||
<File>
|
||||
<FileName>objfun.c</FileName>
|
||||
<FileType>1</FileType>
|
||||
<FilePath>packages\micropython\py\objfun.c</FilePath>
|
||||
</File>
|
||||
<File>
|
||||
<FileName>objgenerator.c</FileName>
|
||||
<FileType>1</FileType>
|
||||
<FilePath>packages\micropython\py\objgenerator.c</FilePath>
|
||||
</File>
|
||||
<File>
|
||||
<FileName>objgetitemiter.c</FileName>
|
||||
<FileType>1</FileType>
|
||||
<FilePath>packages\micropython\py\objgetitemiter.c</FilePath>
|
||||
</File>
|
||||
<File>
|
||||
<FileName>objint.c</FileName>
|
||||
<FileType>1</FileType>
|
||||
<FilePath>packages\micropython\py\objint.c</FilePath>
|
||||
</File>
|
||||
<File>
|
||||
<FileName>objint_longlong.c</FileName>
|
||||
<FileType>1</FileType>
|
||||
<FilePath>packages\micropython\py\objint_longlong.c</FilePath>
|
||||
</File>
|
||||
<File>
|
||||
<FileName>objint_mpz.c</FileName>
|
||||
<FileType>1</FileType>
|
||||
<FilePath>packages\micropython\py\objint_mpz.c</FilePath>
|
||||
</File>
|
||||
<File>
|
||||
<FileName>objlist.c</FileName>
|
||||
<FileType>1</FileType>
|
||||
<FilePath>packages\micropython\py\objlist.c</FilePath>
|
||||
</File>
|
||||
<File>
|
||||
<FileName>objmap.c</FileName>
|
||||
<FileType>1</FileType>
|
||||
<FilePath>packages\micropython\py\objmap.c</FilePath>
|
||||
</File>
|
||||
<File>
|
||||
<FileName>objmodule.c</FileName>
|
||||
<FileType>1</FileType>
|
||||
<FilePath>packages\micropython\py\objmodule.c</FilePath>
|
||||
</File>
|
||||
<File>
|
||||
<FileName>objnamedtuple.c</FileName>
|
||||
<FileType>1</FileType>
|
||||
<FilePath>packages\micropython\py\objnamedtuple.c</FilePath>
|
||||
</File>
|
||||
<File>
|
||||
<FileName>objnone.c</FileName>
|
||||
<FileType>1</FileType>
|
||||
<FilePath>packages\micropython\py\objnone.c</FilePath>
|
||||
</File>
|
||||
<File>
|
||||
<FileName>objobject.c</FileName>
|
||||
<FileType>1</FileType>
|
||||
<FilePath>packages\micropython\py\objobject.c</FilePath>
|
||||
</File>
|
||||
<File>
|
||||
<FileName>objpolyiter.c</FileName>
|
||||
<FileType>1</FileType>
|
||||
<FilePath>packages\micropython\py\objpolyiter.c</FilePath>
|
||||
</File>
|
||||
<File>
|
||||
<FileName>objproperty.c</FileName>
|
||||
<FileType>1</FileType>
|
||||
<FilePath>packages\micropython\py\objproperty.c</FilePath>
|
||||
</File>
|
||||
<File>
|
||||
<FileName>objrange.c</FileName>
|
||||
<FileType>1</FileType>
|
||||
<FilePath>packages\micropython\py\objrange.c</FilePath>
|
||||
</File>
|
||||
<File>
|
||||
<FileName>objreversed.c</FileName>
|
||||
<FileType>1</FileType>
|
||||
<FilePath>packages\micropython\py\objreversed.c</FilePath>
|
||||
</File>
|
||||
<File>
|
||||
<FileName>objset.c</FileName>
|
||||
<FileType>1</FileType>
|
||||
<FilePath>packages\micropython\py\objset.c</FilePath>
|
||||
</File>
|
||||
<File>
|
||||
<FileName>objsingleton.c</FileName>
|
||||
<FileType>1</FileType>
|
||||
<FilePath>packages\micropython\py\objsingleton.c</FilePath>
|
||||
</File>
|
||||
<File>
|
||||
<FileName>objslice.c</FileName>
|
||||
<FileType>1</FileType>
|
||||
<FilePath>packages\micropython\py\objslice.c</FilePath>
|
||||
</File>
|
||||
<File>
|
||||
<FileName>objstr.c</FileName>
|
||||
<FileType>1</FileType>
|
||||
<FilePath>packages\micropython\py\objstr.c</FilePath>
|
||||
</File>
|
||||
<File>
|
||||
<FileName>objstringio.c</FileName>
|
||||
<FileType>1</FileType>
|
||||
<FilePath>packages\micropython\py\objstringio.c</FilePath>
|
||||
</File>
|
||||
<File>
|
||||
<FileName>objstrunicode.c</FileName>
|
||||
<FileType>1</FileType>
|
||||
<FilePath>packages\micropython\py\objstrunicode.c</FilePath>
|
||||
</File>
|
||||
<File>
|
||||
<FileName>objtuple.c</FileName>
|
||||
<FileType>1</FileType>
|
||||
<FilePath>packages\micropython\py\objtuple.c</FilePath>
|
||||
</File>
|
||||
<File>
|
||||
<FileName>objtype.c</FileName>
|
||||
<FileType>1</FileType>
|
||||
<FilePath>packages\micropython\py\objtype.c</FilePath>
|
||||
</File>
|
||||
<File>
|
||||
<FileName>objzip.c</FileName>
|
||||
<FileType>1</FileType>
|
||||
<FilePath>packages\micropython\py\objzip.c</FilePath>
|
||||
</File>
|
||||
<File>
|
||||
<FileName>opmethods.c</FileName>
|
||||
<FileType>1</FileType>
|
||||
<FilePath>packages\micropython\py\opmethods.c</FilePath>
|
||||
</File>
|
||||
<File>
|
||||
<FileName>parse.c</FileName>
|
||||
<FileType>1</FileType>
|
||||
<FilePath>packages\micropython\py\parse.c</FilePath>
|
||||
</File>
|
||||
<File>
|
||||
<FileName>parsenum.c</FileName>
|
||||
<FileType>1</FileType>
|
||||
<FilePath>packages\micropython\py\parsenum.c</FilePath>
|
||||
</File>
|
||||
<File>
|
||||
<FileName>parsenumbase.c</FileName>
|
||||
<FileType>1</FileType>
|
||||
<FilePath>packages\micropython\py\parsenumbase.c</FilePath>
|
||||
</File>
|
||||
<File>
|
||||
<FileName>persistentcode.c</FileName>
|
||||
<FileType>1</FileType>
|
||||
<FilePath>packages\micropython\py\persistentcode.c</FilePath>
|
||||
</File>
|
||||
<File>
|
||||
<FileName>pystack.c</FileName>
|
||||
<FileType>1</FileType>
|
||||
<FilePath>packages\micropython\py\pystack.c</FilePath>
|
||||
</File>
|
||||
<File>
|
||||
<FileName>qstr.c</FileName>
|
||||
<FileType>1</FileType>
|
||||
<FilePath>packages\micropython\py\qstr.c</FilePath>
|
||||
</File>
|
||||
<File>
|
||||
<FileName>reader.c</FileName>
|
||||
<FileType>1</FileType>
|
||||
<FilePath>packages\micropython\py\reader.c</FilePath>
|
||||
</File>
|
||||
<File>
|
||||
<FileName>repl.c</FileName>
|
||||
<FileType>1</FileType>
|
||||
<FilePath>packages\micropython\py\repl.c</FilePath>
|
||||
</File>
|
||||
<File>
|
||||
<FileName>runtime.c</FileName>
|
||||
<FileType>1</FileType>
|
||||
<FilePath>packages\micropython\py\runtime.c</FilePath>
|
||||
</File>
|
||||
<File>
|
||||
<FileName>runtime_utils.c</FileName>
|
||||
<FileType>1</FileType>
|
||||
<FilePath>packages\micropython\py\runtime_utils.c</FilePath>
|
||||
</File>
|
||||
<File>
|
||||
<FileName>scope.c</FileName>
|
||||
<FileType>1</FileType>
|
||||
<FilePath>packages\micropython\py\scope.c</FilePath>
|
||||
</File>
|
||||
<File>
|
||||
<FileName>sequence.c</FileName>
|
||||
<FileType>1</FileType>
|
||||
<FilePath>packages\micropython\py\sequence.c</FilePath>
|
||||
</File>
|
||||
<File>
|
||||
<FileName>showbc.c</FileName>
|
||||
<FileType>1</FileType>
|
||||
<FilePath>packages\micropython\py\showbc.c</FilePath>
|
||||
</File>
|
||||
<File>
|
||||
<FileName>smallint.c</FileName>
|
||||
<FileType>1</FileType>
|
||||
<FilePath>packages\micropython\py\smallint.c</FilePath>
|
||||
</File>
|
||||
<File>
|
||||
<FileName>stackctrl.c</FileName>
|
||||
<FileType>1</FileType>
|
||||
<FilePath>packages\micropython\py\stackctrl.c</FilePath>
|
||||
</File>
|
||||
<File>
|
||||
<FileName>stream.c</FileName>
|
||||
<FileType>1</FileType>
|
||||
<FilePath>packages\micropython\py\stream.c</FilePath>
|
||||
</File>
|
||||
<File>
|
||||
<FileName>unicode.c</FileName>
|
||||
<FileType>1</FileType>
|
||||
<FilePath>packages\micropython\py\unicode.c</FilePath>
|
||||
</File>
|
||||
<File>
|
||||
<FileName>vm.c</FileName>
|
||||
<FileType>1</FileType>
|
||||
<FilePath>packages\micropython\py\vm.c</FilePath>
|
||||
</File>
|
||||
<File>
|
||||
<FileName>vstr.c</FileName>
|
||||
<FileType>1</FileType>
|
||||
<FilePath>packages\micropython\py\vstr.c</FilePath>
|
||||
</File>
|
||||
<File>
|
||||
<FileName>warning.c</FileName>
|
||||
<FileType>1</FileType>
|
||||
<FilePath>packages\micropython\py\warning.c</FilePath>
|
||||
</File>
|
||||
<File>
|
||||
<FileName>readline.c</FileName>
|
||||
<FileType>1</FileType>
|
||||
<FilePath>packages\micropython\lib\mp-readline\readline.c</FilePath>
|
||||
</File>
|
||||
<File>
|
||||
<FileName>interrupt_char.c</FileName>
|
||||
<FileType>1</FileType>
|
||||
<FilePath>packages\micropython\lib\utils\interrupt_char.c</FilePath>
|
||||
</File>
|
||||
<File>
|
||||
<FileName>printf.c</FileName>
|
||||
<FileType>1</FileType>
|
||||
<FilePath>packages\micropython\lib\utils\printf.c</FilePath>
|
||||
</File>
|
||||
<File>
|
||||
<FileName>pyexec.c</FileName>
|
||||
<FileType>1</FileType>
|
||||
<FilePath>packages\micropython\lib\utils\pyexec.c</FilePath>
|
||||
</File>
|
||||
<File>
|
||||
<FileName>stdout_helpers.c</FileName>
|
||||
<FileType>1</FileType>
|
||||
<FilePath>packages\micropython\lib\utils\stdout_helpers.c</FilePath>
|
||||
</File>
|
||||
<File>
|
||||
<FileName>machine_i2c.c</FileName>
|
||||
<FileType>1</FileType>
|
||||
<FilePath>packages\micropython\extmod\machine_i2c.c</FilePath>
|
||||
</File>
|
||||
<File>
|
||||
<FileName>machine_mem.c</FileName>
|
||||
<FileType>1</FileType>
|
||||
<FilePath>packages\micropython\extmod\machine_mem.c</FilePath>
|
||||
</File>
|
||||
<File>
|
||||
<FileName>machine_pinbase.c</FileName>
|
||||
<FileType>1</FileType>
|
||||
<FilePath>packages\micropython\extmod\machine_pinbase.c</FilePath>
|
||||
</File>
|
||||
<File>
|
||||
<FileName>machine_pulse.c</FileName>
|
||||
<FileType>1</FileType>
|
||||
<FilePath>packages\micropython\extmod\machine_pulse.c</FilePath>
|
||||
</File>
|
||||
<File>
|
||||
<FileName>machine_signal.c</FileName>
|
||||
<FileType>1</FileType>
|
||||
<FilePath>packages\micropython\extmod\machine_signal.c</FilePath>
|
||||
</File>
|
||||
<File>
|
||||
<FileName>machine_spi.c</FileName>
|
||||
<FileType>1</FileType>
|
||||
<FilePath>packages\micropython\extmod\machine_spi.c</FilePath>
|
||||
</File>
|
||||
<File>
|
||||
<FileName>modbtree.c</FileName>
|
||||
<FileType>1</FileType>
|
||||
<FilePath>packages\micropython\extmod\modbtree.c</FilePath>
|
||||
</File>
|
||||
<File>
|
||||
<FileName>modframebuf.c</FileName>
|
||||
<FileType>1</FileType>
|
||||
<FilePath>packages\micropython\extmod\modframebuf.c</FilePath>
|
||||
</File>
|
||||
<File>
|
||||
<FileName>modubinascii.c</FileName>
|
||||
<FileType>1</FileType>
|
||||
<FilePath>packages\micropython\extmod\modubinascii.c</FilePath>
|
||||
</File>
|
||||
<File>
|
||||
<FileName>moductypes.c</FileName>
|
||||
<FileType>1</FileType>
|
||||
<FilePath>packages\micropython\extmod\moductypes.c</FilePath>
|
||||
</File>
|
||||
<File>
|
||||
<FileName>moduhashlib.c</FileName>
|
||||
<FileType>1</FileType>
|
||||
<FilePath>packages\micropython\extmod\moduhashlib.c</FilePath>
|
||||
</File>
|
||||
<File>
|
||||
<FileName>moduheapq.c</FileName>
|
||||
<FileType>1</FileType>
|
||||
<FilePath>packages\micropython\extmod\moduheapq.c</FilePath>
|
||||
</File>
|
||||
<File>
|
||||
<FileName>modujson.c</FileName>
|
||||
<FileType>1</FileType>
|
||||
<FilePath>packages\micropython\extmod\modujson.c</FilePath>
|
||||
</File>
|
||||
<File>
|
||||
<FileName>modurandom.c</FileName>
|
||||
<FileType>1</FileType>
|
||||
<FilePath>packages\micropython\extmod\modurandom.c</FilePath>
|
||||
</File>
|
||||
<File>
|
||||
<FileName>modure.c</FileName>
|
||||
<FileType>1</FileType>
|
||||
<FilePath>packages\micropython\extmod\modure.c</FilePath>
|
||||
</File>
|
||||
<File>
|
||||
<FileName>moduselect.c</FileName>
|
||||
<FileType>1</FileType>
|
||||
<FilePath>packages\micropython\extmod\moduselect.c</FilePath>
|
||||
</File>
|
||||
<File>
|
||||
<FileName>modussl_axtls.c</FileName>
|
||||
<FileType>1</FileType>
|
||||
<FilePath>packages\micropython\extmod\modussl_axtls.c</FilePath>
|
||||
</File>
|
||||
<File>
|
||||
<FileName>modussl_mbedtls.c</FileName>
|
||||
<FileType>1</FileType>
|
||||
<FilePath>packages\micropython\extmod\modussl_mbedtls.c</FilePath>
|
||||
</File>
|
||||
<File>
|
||||
<FileName>modutimeq.c</FileName>
|
||||
<FileType>1</FileType>
|
||||
<FilePath>packages\micropython\extmod\modutimeq.c</FilePath>
|
||||
</File>
|
||||
<File>
|
||||
<FileName>moduzlib.c</FileName>
|
||||
<FileType>1</FileType>
|
||||
<FilePath>packages\micropython\extmod\moduzlib.c</FilePath>
|
||||
</File>
|
||||
<File>
|
||||
<FileName>modwebrepl.c</FileName>
|
||||
<FileType>1</FileType>
|
||||
<FilePath>packages\micropython\extmod\modwebrepl.c</FilePath>
|
||||
</File>
|
||||
<File>
|
||||
<FileName>modwebsocket.c</FileName>
|
||||
<FileType>1</FileType>
|
||||
<FilePath>packages\micropython\extmod\modwebsocket.c</FilePath>
|
||||
</File>
|
||||
<File>
|
||||
<FileName>uos_dupterm.c</FileName>
|
||||
<FileType>1</FileType>
|
||||
<FilePath>packages\micropython\extmod\uos_dupterm.c</FilePath>
|
||||
</File>
|
||||
<File>
|
||||
<FileName>utime_mphal.c</FileName>
|
||||
<FileType>1</FileType>
|
||||
<FilePath>packages\micropython\extmod\utime_mphal.c</FilePath>
|
||||
</File>
|
||||
<File>
|
||||
<FileName>vfs.c</FileName>
|
||||
<FileType>1</FileType>
|
||||
<FilePath>packages\micropython\extmod\vfs.c</FilePath>
|
||||
</File>
|
||||
<File>
|
||||
<FileName>vfs_fat.c</FileName>
|
||||
<FileType>1</FileType>
|
||||
<FilePath>packages\micropython\extmod\vfs_fat.c</FilePath>
|
||||
</File>
|
||||
<File>
|
||||
<FileName>vfs_fat_diskio.c</FileName>
|
||||
<FileType>1</FileType>
|
||||
<FilePath>packages\micropython\extmod\vfs_fat_diskio.c</FilePath>
|
||||
</File>
|
||||
<File>
|
||||
<FileName>vfs_fat_file.c</FileName>
|
||||
<FileType>1</FileType>
|
||||
<FilePath>packages\micropython\extmod\vfs_fat_file.c</FilePath>
|
||||
</File>
|
||||
<File>
|
||||
<FileName>vfs_reader.c</FileName>
|
||||
<FileType>1</FileType>
|
||||
<FilePath>packages\micropython\extmod\vfs_reader.c</FilePath>
|
||||
</File>
|
||||
<File>
|
||||
<FileName>virtpin.c</FileName>
|
||||
<FileType>1</FileType>
|
||||
<FilePath>packages\micropython\extmod\virtpin.c</FilePath>
|
||||
</File>
|
||||
<File>
|
||||
<FileName>_frozen_mpy.c</FileName>
|
||||
<FileType>1</FileType>
|
||||
<FilePath>packages\micropython\port\_frozen_mpy.c</FilePath>
|
||||
</File>
|
||||
<File>
|
||||
<FileName>file.c</FileName>
|
||||
<FileType>1</FileType>
|
||||
<FilePath>packages\micropython\port\file.c</FilePath>
|
||||
</File>
|
||||
<File>
|
||||
<FileName>help.c</FileName>
|
||||
<FileType>1</FileType>
|
||||
<FilePath>packages\micropython\port\help.c</FilePath>
|
||||
</File>
|
||||
<File>
|
||||
<FileName>machine_pin.c</FileName>
|
||||
<FileType>1</FileType>
|
||||
<FilePath>packages\micropython\port\machine_pin.c</FilePath>
|
||||
</File>
|
||||
<File>
|
||||
<FileName>modmachine.c</FileName>
|
||||
<FileType>1</FileType>
|
||||
<FilePath>packages\micropython\port\modmachine.c</FilePath>
|
||||
</File>
|
||||
<File>
|
||||
<FileName>modnetwork.c</FileName>
|
||||
<FileType>1</FileType>
|
||||
<FilePath>packages\micropython\port\modnetwork.c</FilePath>
|
||||
</File>
|
||||
<File>
|
||||
<FileName>modpyb.c</FileName>
|
||||
<FileType>1</FileType>
|
||||
<FilePath>packages\micropython\port\modpyb.c</FilePath>
|
||||
</File>
|
||||
<File>
|
||||
<FileName>modrtthread.c</FileName>
|
||||
<FileType>1</FileType>
|
||||
<FilePath>packages\micropython\port\modrtthread.c</FilePath>
|
||||
</File>
|
||||
<File>
|
||||
<FileName>moduos.c</FileName>
|
||||
<FileType>1</FileType>
|
||||
<FilePath>packages\micropython\port\moduos.c</FilePath>
|
||||
</File>
|
||||
<File>
|
||||
<FileName>moduos_file.c</FileName>
|
||||
<FileType>1</FileType>
|
||||
<FilePath>packages\micropython\port\moduos_file.c</FilePath>
|
||||
</File>
|
||||
<File>
|
||||
<FileName>modusocket.c</FileName>
|
||||
<FileType>1</FileType>
|
||||
<FilePath>packages\micropython\port\modusocket.c</FilePath>
|
||||
</File>
|
||||
<File>
|
||||
<FileName>modutime.c</FileName>
|
||||
<FileType>1</FileType>
|
||||
<FilePath>packages\micropython\port\modutime.c</FilePath>
|
||||
</File>
|
||||
<File>
|
||||
<FileName>mpy_main.c</FileName>
|
||||
<FileType>1</FileType>
|
||||
<FilePath>packages\micropython\port\mpy_main.c</FilePath>
|
||||
</File>
|
||||
<File>
|
||||
<FileName>rtt_getchar.c</FileName>
|
||||
<FileType>1</FileType>
|
||||
<FilePath>packages\micropython\port\rtt_getchar.c</FilePath>
|
||||
</File>
|
||||
<File>
|
||||
<FileName>uart_core.c</FileName>
|
||||
<FileType>1</FileType>
|
||||
<FilePath>packages\micropython\port\uart_core.c</FilePath>
|
||||
</File>
|
||||
<File>
|
||||
<FileName>netutils.c</FileName>
|
||||
<FileType>1</FileType>
|
||||
<FilePath>packages\micropython\lib\netutils\netutils.c</FilePath>
|
||||
</File>
|
||||
</Files>
|
||||
</Group>
|
||||
<Group>
|
||||
|
@ -505,6 +1378,11 @@
|
|||
<Group>
|
||||
<GroupName>DeviceDrivers</GroupName>
|
||||
<Files>
|
||||
<File>
|
||||
<FileName>pin.c</FileName>
|
||||
<FileType>1</FileType>
|
||||
<FilePath>..\..\components\drivers\misc\pin.c</FilePath>
|
||||
</File>
|
||||
<File>
|
||||
<FileName>serial.c</FileName>
|
||||
<FileType>1</FileType>
|
||||
|
|
|
@ -8,9 +8,7 @@
|
|||
|
||||
#define RT_NAME_MAX 8
|
||||
#define RT_ALIGN_SIZE 4
|
||||
/* RT_THREAD_PRIORITY_8 is not set */
|
||||
#define RT_THREAD_PRIORITY_32
|
||||
/* RT_THREAD_PRIORITY_256 is not set */
|
||||
#define RT_THREAD_PRIORITY_MAX 32
|
||||
#define RT_TICK_PER_SECOND 100
|
||||
#define RT_DEBUG
|
||||
|
@ -19,7 +17,6 @@
|
|||
#define RT_DEBUG_THREAD 0
|
||||
#define RT_USING_HOOK
|
||||
#define IDLE_THREAD_STACK_SIZE 256
|
||||
/* RT_USING_TIMER_SOFT is not set */
|
||||
|
||||
/* Inter-Thread communication */
|
||||
|
||||
|
@ -28,26 +25,19 @@
|
|||
#define RT_USING_EVENT
|
||||
#define RT_USING_MAILBOX
|
||||
#define RT_USING_MESSAGEQUEUE
|
||||
/* RT_USING_SIGNALS is not set */
|
||||
|
||||
/* Memory Management */
|
||||
|
||||
/* RT_USING_MEMPOOL is not set */
|
||||
#define RT_USING_MEMHEAP
|
||||
/* RT_USING_NOHEAP is not set */
|
||||
/* RT_USING_SMALL_MEM is not set */
|
||||
/* RT_USING_SLAB is not set */
|
||||
#define RT_USING_MEMHEAP_AS_HEAP
|
||||
#define RT_USING_HEAP
|
||||
|
||||
/* Kernel Device Object */
|
||||
|
||||
#define RT_USING_DEVICE
|
||||
/* RT_USING_INTERRUPT_INFO is not set */
|
||||
#define RT_USING_CONSOLE
|
||||
#define RT_CONSOLEBUF_SIZE 128
|
||||
#define RT_CONSOLE_DEVICE_NAME "uart0"
|
||||
/* RT_USING_MODULE is not set */
|
||||
#define ARCH_ARM
|
||||
#define ARCH_ARM_CORTEX_M
|
||||
#define ARCH_ARM_CORTEX_M7
|
||||
|
@ -60,7 +50,6 @@
|
|||
|
||||
/* C++ features */
|
||||
|
||||
/* RT_USING_CPLUSPLUS is not set */
|
||||
|
||||
/* Command shell */
|
||||
|
||||
|
@ -73,152 +62,100 @@
|
|||
#define FINSH_THREAD_PRIORITY 20
|
||||
#define FINSH_THREAD_STACK_SIZE 4096
|
||||
#define FINSH_CMD_SIZE 80
|
||||
/* FINSH_USING_AUTH is not set */
|
||||
#define FINSH_USING_MSH
|
||||
/* FINSH_USING_MSH_DEFAULT is not set */
|
||||
/* FINSH_USING_MSH_ONLY is not set */
|
||||
|
||||
/* Device virtual file system */
|
||||
|
||||
/* RT_USING_DFS is not set */
|
||||
|
||||
/* Device Drivers */
|
||||
|
||||
#define RT_USING_DEVICE_IPC
|
||||
#define RT_USING_SERIAL
|
||||
/* RT_USING_CAN is not set */
|
||||
/* RT_USING_HWTIMER is not set */
|
||||
/* RT_USING_CPUTIME is not set */
|
||||
/* RT_USING_I2C is not set */
|
||||
/* RT_USING_PIN is not set */
|
||||
/* RT_USING_MTD_NOR is not set */
|
||||
/* RT_USING_MTD_NAND is not set */
|
||||
/* RT_USING_RTC is not set */
|
||||
/* RT_USING_SDIO is not set */
|
||||
/* RT_USING_SPI is not set */
|
||||
/* RT_USING_WDT is not set */
|
||||
/* RT_USING_WIFI is not set */
|
||||
#define RT_USING_PIN
|
||||
|
||||
/* Using USB */
|
||||
|
||||
/* RT_USING_USB_HOST is not set */
|
||||
/* RT_USING_USB_DEVICE is not set */
|
||||
|
||||
/* POSIX layer and C standard library */
|
||||
|
||||
#define RT_USING_LIBC
|
||||
/* RT_USING_PTHREADS is not set */
|
||||
|
||||
/* Network stack */
|
||||
|
||||
/* light weight TCP/IP stack */
|
||||
|
||||
/* RT_USING_LWIP is not set */
|
||||
|
||||
/* Modbus master and slave stack */
|
||||
|
||||
/* RT_USING_MODBUS is not set */
|
||||
|
||||
/* RT-Thread UI Engine */
|
||||
|
||||
/* PKG_USING_GUIENGINE is not set */
|
||||
|
||||
/* VBUS(Virtual Software BUS) */
|
||||
|
||||
/* RT_USING_VBUS is not set */
|
||||
|
||||
/* Utilities */
|
||||
|
||||
/* RT_USING_LOGTRACE is not set */
|
||||
/* RT_USING_RYM is not set */
|
||||
|
||||
/* ARM CMSIS */
|
||||
|
||||
/* RT_USING_CMSIS_OS is not set */
|
||||
/* RT_USING_RTT_CMSIS is not set */
|
||||
|
||||
/* RT-Thread online packages */
|
||||
|
||||
/* system packages */
|
||||
|
||||
/* PKG_USING_PARTITION is not set */
|
||||
/* PKG_USING_PERSIMMON is not set */
|
||||
/* PKG_USING_SQLITE is not set */
|
||||
/* PKG_USING_RTI is not set */
|
||||
/* RT-Thread GUI Engine */
|
||||
|
||||
|
||||
/* IoT - internet of things */
|
||||
|
||||
/* PKG_USING_PAHOMQTT is not set */
|
||||
/* PKG_USING_WEBCLIENT is not set */
|
||||
/* PKG_USING_MONGOOSE is not set */
|
||||
/* PKG_USING_WEBTERMINAL is not set */
|
||||
/* PKG_USING_CJSON is not set */
|
||||
/* PKG_USING_LJSON is not set */
|
||||
/* PKG_USING_EZXML is not set */
|
||||
/* PKG_USING_NANOPB is not set */
|
||||
/* PKG_USING_GAGENT_CLOUD is not set */
|
||||
|
||||
/* Wi-Fi */
|
||||
|
||||
/* Marvell WiFi */
|
||||
|
||||
/* PKG_USING_WLANMARVELL is not set */
|
||||
|
||||
/* Wiced WiFi */
|
||||
|
||||
/* PKG_USING_WLAN_WICED is not set */
|
||||
/* PKG_USING_COAP is not set */
|
||||
|
||||
/* security packages */
|
||||
|
||||
/* PKG_USING_MBEDTLS is not set */
|
||||
/* PKG_USING_libsodium is not set */
|
||||
/* PKG_USING_TINYCRYPT is not set */
|
||||
|
||||
/* language packages */
|
||||
|
||||
/* PKG_USING_JERRYSCRIPT is not set */
|
||||
/* PKG_USING_MICROPYTHON is not set */
|
||||
#define PKG_USING_MICROPYTHON
|
||||
|
||||
/* System Module */
|
||||
|
||||
|
||||
/* Tools Module */
|
||||
|
||||
|
||||
/* Network Module */
|
||||
|
||||
|
||||
/* Hardware Module */
|
||||
|
||||
#define PKG_MICROPYTHON_HEAP_SIZE 8192
|
||||
#define PKG_USING_MICROPYTHON_LATEST_VERSION
|
||||
|
||||
/* multimedia packages */
|
||||
|
||||
/* PKG_USING_OPENMV is not set */
|
||||
|
||||
/* tools packages */
|
||||
|
||||
/* PKG_USING_CMBACKTRACE is not set */
|
||||
/* PKG_USING_EASYLOGGER is not set */
|
||||
/* PKG_USING_SYSTEMVIEW is not set */
|
||||
/* PKG_USING_IPERF is not set */
|
||||
|
||||
/* miscellaneous packages */
|
||||
|
||||
/* PKG_USING_FASTLZ is not set */
|
||||
/* PKG_USING_MINILZO is not set */
|
||||
|
||||
/* example package: hello */
|
||||
|
||||
/* PKG_USING_HELLO is not set */
|
||||
|
||||
/* Privated Packages of RealThread */
|
||||
|
||||
/* PKG_USING_CODEC is not set */
|
||||
/* PKG_USING_PLAYER is not set */
|
||||
/* PKG_USING_PERSIMMON_SRC is not set */
|
||||
|
||||
/* Network Utilities */
|
||||
|
||||
/* PKG_USING_WLAN_WICED_SRC is not set */
|
||||
|
||||
/* Cloudsdk: RT_thread IOT Cloudsdk */
|
||||
|
||||
/* PKG_USING_CLOUDSDK is not set */
|
||||
|
||||
/* Webnet: A web server package for rt-thread */
|
||||
|
||||
/* PKG_USING_WEBNET is not set */
|
||||
/* PKG_USING_COREMARK is not set */
|
||||
/* PKG_USING_POWER_MANAGER is not set */
|
||||
#define SOC_V2M_MPS2
|
||||
#define RT_USING_UART
|
||||
#define RT_USING_UART0
|
||||
|
|
|
@ -294,6 +294,10 @@ static rt_size_t _audio_dev_write(struct rt_device *dev, rt_off_t pos, const voi
|
|||
|
||||
_audio_send_replay_frame(audio);
|
||||
}
|
||||
else
|
||||
{
|
||||
rt_hw_interrupt_enable(level);
|
||||
}
|
||||
|
||||
return size;
|
||||
}
|
||||
|
|
|
@ -119,8 +119,11 @@ rt_size_t rt_ringbuffer_put_force(struct rt_ringbuffer *rb,
|
|||
|
||||
space_length = rt_ringbuffer_space_len(rb);
|
||||
|
||||
if (length > space_length)
|
||||
if (length > rb->buffer_size)
|
||||
{
|
||||
ptr = &ptr[length - rb->buffer_size];
|
||||
length = rb->buffer_size;
|
||||
}
|
||||
|
||||
if (rb->buffer_size - rb->write_index > length)
|
||||
{
|
||||
|
|
|
@ -26,6 +26,10 @@ config FINSH_USING_DESCRIPTION
|
|||
bool "Keeping description in symbol table"
|
||||
default y
|
||||
|
||||
config FINSH_ECHO_DISABLE_DEFAULT
|
||||
bool "Disable the echo mode in default"
|
||||
default n
|
||||
|
||||
config FINSH_THREAD_PRIORITY
|
||||
int "The priority level value of finsh thread"
|
||||
default 20
|
||||
|
|
|
@ -414,7 +414,11 @@ void finsh_thread_entry(void *parameter)
|
|||
char ch;
|
||||
|
||||
/* normal is echo mode */
|
||||
#ifndef FINSH_ECHO_DISABLE_DEFAULT
|
||||
shell->echo_mode = 1;
|
||||
#else
|
||||
shell->echo_mode = 0;
|
||||
#endif
|
||||
|
||||
#ifndef FINSH_USING_MSH_ONLY
|
||||
finsh_init(&shell->parser);
|
||||
|
|
Loading…
Reference in New Issue