mirror of
https://github.com/RT-Thread/rt-thread.git
synced 2026-11-17 07:05:31 +08:00
94 files changed
+2945
-1866
No files matched your search
@@ -23,7 +23,7 @@ CONFIG_RT_IDLE_HOOK_LIST_SIZE=4
|
||||
CONFIG_IDLE_THREAD_STACK_SIZE=512
|
||||
CONFIG_RT_USING_TIMER_SOFT=y
|
||||
CONFIG_RT_TIMER_THREAD_PRIO=4
|
||||
CONFIG_RT_TIMER_THREAD_STACK_SIZE=256
|
||||
CONFIG_RT_TIMER_THREAD_STACK_SIZE=1024
|
||||
|
||||
#
|
||||
# kservice optimization
|
||||
@@ -31,6 +31,9 @@ CONFIG_RT_TIMER_THREAD_STACK_SIZE=256
|
||||
# CONFIG_RT_KSERVICE_USING_STDLIB is not set
|
||||
# CONFIG_RT_KSERVICE_USING_TINY_SIZE is not set
|
||||
# CONFIG_RT_USING_ASM_MEMCPY is not set
|
||||
# CONFIG_RT_USING_ASM_MEMSET is not set
|
||||
# CONFIG_RT_USING_TINY_FFS is not set
|
||||
# CONFIG_RT_PRINTF_LONGLONG is not set
|
||||
CONFIG_RT_DEBUG=y
|
||||
# CONFIG_RT_DEBUG_COLOR is not set
|
||||
# CONFIG_RT_DEBUG_INIT_CONFIG is not set
|
||||
@@ -76,8 +79,7 @@ CONFIG_RT_USING_DEVICE_OPS=y
|
||||
CONFIG_RT_USING_CONSOLE=y
|
||||
CONFIG_RT_CONSOLEBUF_SIZE=128
|
||||
CONFIG_RT_CONSOLE_DEVICE_NAME="uart0"
|
||||
# CONFIG_RT_PRINTF_LONGLONG is not set
|
||||
CONFIG_RT_VER_NUM=0x40004
|
||||
CONFIG_RT_VER_NUM=0x40100
|
||||
# CONFIG_RT_USING_CPU_FFS is not set
|
||||
# CONFIG_ARCH_CPU_STACK_GROWS_UPWARD is not set
|
||||
|
||||
@@ -88,6 +90,7 @@ CONFIG_RT_USING_COMPONENTS_INIT=y
|
||||
CONFIG_RT_USING_USER_MAIN=y
|
||||
CONFIG_RT_MAIN_THREAD_STACK_SIZE=1024
|
||||
CONFIG_RT_MAIN_THREAD_PRIORITY=10
|
||||
# CONFIG_RT_USING_LEGACY is not set
|
||||
|
||||
#
|
||||
# C++ features
|
||||
@@ -117,6 +120,14 @@ CONFIG_FINSH_ARG_MAX=10
|
||||
# Device virtual file system
|
||||
#
|
||||
# CONFIG_RT_USING_DFS is not set
|
||||
# CONFIG_RT_DFS_ELM_USE_LFN_0 is not set
|
||||
# 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_LFN_UNICODE_0 is not set
|
||||
# CONFIG_RT_DFS_ELM_LFN_UNICODE_1 is not set
|
||||
# CONFIG_RT_DFS_ELM_LFN_UNICODE_2 is not set
|
||||
# CONFIG_RT_DFS_ELM_LFN_UNICODE_3 is not set
|
||||
|
||||
#
|
||||
# Device Drivers
|
||||
@@ -163,10 +174,13 @@ CONFIG_RT_USING_PIN=y
|
||||
#
|
||||
# POSIX layer and C standard library
|
||||
#
|
||||
# CONFIG_RT_USING_LIBC is not set
|
||||
# CONFIG_RT_USING_PTHREADS is not set
|
||||
CONFIG_RT_USING_LIBC=y
|
||||
CONFIG_RT_LIBC_USING_TIME=y
|
||||
# CONFIG_RT_LIBC_USING_FILEIO is not set
|
||||
# CONFIG_RT_USING_MODULE is not set
|
||||
CONFIG_RT_LIBC_DEFAULT_TIMEZONE=8
|
||||
# CONFIG_RT_USING_POSIX is not set
|
||||
# CONFIG_RT_USING_PTHREADS is not set
|
||||
|
||||
#
|
||||
# Network
|
||||
@@ -304,6 +318,7 @@ CONFIG_RT_LIBC_DEFAULT_TIMEZONE=8
|
||||
# CONFIG_PKG_USING_LORA_GW_DRIVER_LIB is not set
|
||||
# CONFIG_PKG_USING_LORA_PKT_SNIFFER is not set
|
||||
# CONFIG_PKG_USING_HM is not set
|
||||
# CONFIG_PKG_USING_SMALL_MODBUS is not set
|
||||
|
||||
#
|
||||
# security packages
|
||||
@@ -351,6 +366,12 @@ CONFIG_RT_LIBC_DEFAULT_TIMEZONE=8
|
||||
# CONFIG_PKG_USING_U8G2_OFFICIAL is not set
|
||||
# CONFIG_PKG_USING_U8G2 is not set
|
||||
|
||||
#
|
||||
# PainterEngine: A cross-platform graphics application framework written in C language
|
||||
#
|
||||
# CONFIG_PKG_USING_PAINTERENGINE is not set
|
||||
# CONFIG_PKG_USING_PAINTERENGINE_AUX is not set
|
||||
|
||||
#
|
||||
# tools packages
|
||||
#
|
||||
@@ -392,6 +413,7 @@ CONFIG_RT_LIBC_DEFAULT_TIMEZONE=8
|
||||
# CONFIG_PKG_USING_MEM_SANDBOX is not set
|
||||
# CONFIG_PKG_USING_SOLAR_TERMS is not set
|
||||
# CONFIG_PKG_USING_GAN_ZHI is not set
|
||||
# CONFIG_PKG_USING_FDT is not set
|
||||
|
||||
#
|
||||
# system packages
|
||||
@@ -405,6 +427,13 @@ CONFIG_RT_LIBC_DEFAULT_TIMEZONE=8
|
||||
# CONFIG_PKG_USING_QFPLIB_M0_TINY is not set
|
||||
# CONFIG_PKG_USING_QFPLIB_M3 is not set
|
||||
|
||||
#
|
||||
# CMSIS: ARM Cortex-M Microcontroller Software Interface Standard
|
||||
#
|
||||
# CONFIG_PKG_USING_CMSIS_5 is not set
|
||||
# CONFIG_PKG_USING_CMSIS_5_AUX is not set
|
||||
# CONFIG_PKG_USING_CMSIS_RTOS2 is not set
|
||||
|
||||
#
|
||||
# Micrium: Micrium software products porting for RT-Thread
|
||||
#
|
||||
@@ -422,7 +451,6 @@ CONFIG_RT_LIBC_DEFAULT_TIMEZONE=8
|
||||
# CONFIG_PKG_USING_FLASHDB is not set
|
||||
# CONFIG_PKG_USING_SQLITE is not set
|
||||
# CONFIG_PKG_USING_RTI is not set
|
||||
# CONFIG_PKG_USING_CMSIS is not set
|
||||
# CONFIG_PKG_USING_DFS_YAFFS is not set
|
||||
# CONFIG_PKG_USING_LITTLEFS is not set
|
||||
# CONFIG_PKG_USING_DFS_JFFS2 is not set
|
||||
@@ -439,6 +467,7 @@ CONFIG_RT_LIBC_DEFAULT_TIMEZONE=8
|
||||
# CONFIG_PKG_USING_QBOOT is not set
|
||||
# CONFIG_PKG_USING_PPOOL is not set
|
||||
# CONFIG_PKG_USING_OPENAMP is not set
|
||||
# CONFIG_PKG_USING_RT_VSNPRINTF_FULL is not set
|
||||
# CONFIG_PKG_USING_RT_KPRINTF_THREADSAFE is not set
|
||||
# CONFIG_PKG_USING_LPM is not set
|
||||
# CONFIG_PKG_USING_TLSF is not set
|
||||
@@ -599,12 +628,14 @@ CONFIG_PKG_BLUETRUM_SDK_VER="latest"
|
||||
# Hardware Drivers Config
|
||||
#
|
||||
CONFIG_SOC_AB32VG1=y
|
||||
# CONFIG_PKG_USING_BLUETRUM_NIMBLE is not set
|
||||
|
||||
#
|
||||
# Onboard Peripheral Drivers
|
||||
#
|
||||
# CONFIG_BSP_USING_AUDIO is not set
|
||||
# CONFIG_BSP_USING_SDCARD is not set
|
||||
# CONFIG_BSP_USING_NIMBLE is not set
|
||||
|
||||
#
|
||||
# On-chip Peripheral Drivers
|
||||
@@ -622,8 +653,5 @@ CONFIG_BSP_UART0_FIFO_SIZE=10
|
||||
# CONFIG_BSP_USING_ONCHIP_RTC is not set
|
||||
# CONFIG_BSP_USING_ADC is not set
|
||||
# CONFIG_BSP_USING_IRRX is not set
|
||||
|
||||
#
|
||||
# Board extended module Drivers
|
||||
#
|
||||
# CONFIG_BSP_USING_ON_CHIP_FLASH is not set
|
||||
CONFIG_BOARD_BLUETRUM_EVB=y
|
||||
Binary file not shown.
@@ -5,7 +5,7 @@
|
||||
<provider copy-of="extension" id="org.eclipse.cdt.ui.UserLanguageSettingsProvider"/>
|
||||
<provider-reference id="org.eclipse.cdt.core.ReferencedProjectsLanguageSettingsProvider" ref="shared-provider"/>
|
||||
<provider-reference id="org.eclipse.cdt.managedbuilder.core.MBSLanguageSettingsProvider" ref="shared-provider"/>
|
||||
<provider class="org.eclipse.cdt.managedbuilder.language.settings.providers.GCCBuiltinSpecsDetector" console="false" env-hash="-309903127852947962" id="ilg.gnumcueclipse.managedbuild.cross.riscv.GCCBuiltinSpecsDetector" keep-relative-paths="false" name="CDT RISC-V Cross GCC Built-in Compiler Settings" parameter="${COMMAND} ${FLAGS} ${cross_toolchain_flags} -E -P -v -dD "${INPUTS}"" prefer-non-shared="true">
|
||||
<provider class="org.eclipse.cdt.managedbuilder.language.settings.providers.GCCBuiltinSpecsDetector" console="false" env-hash="530397848961880773" id="ilg.gnumcueclipse.managedbuild.cross.riscv.GCCBuiltinSpecsDetector" keep-relative-paths="false" name="CDT RISC-V Cross GCC Built-in Compiler Settings" parameter="${COMMAND} ${FLAGS} ${cross_toolchain_flags} -E -P -v -dD "${INPUTS}"" prefer-non-shared="true">
|
||||
<language-scope id="org.eclipse.cdt.core.gcc"/>
|
||||
<language-scope id="org.eclipse.cdt.core.g++"/>
|
||||
</provider>
|
||||
|
||||
@@ -1,19 +1,19 @@
|
||||
#RT-Thread Studio Project Configuration
|
||||
#Wed Dec 16 14:30:21 CST 2020
|
||||
#Wed Nov 24 11:34:07 CST 2021
|
||||
cfg_version=v3.0
|
||||
board_name=AB32VG1-AB-PROUGEN
|
||||
example_name=
|
||||
hardware_adapter=DAP-LINK
|
||||
project_type=rt-thread
|
||||
hardware_adapter=ST-LINK
|
||||
board_base_nano_proj=False
|
||||
project_type=rt-thread
|
||||
chip_name=AB32VG1
|
||||
selected_rtt_version=latest
|
||||
bsp_version=1.0.0
|
||||
bsp_version=1.1.0
|
||||
os_branch=full
|
||||
output_project_path=D\:/Softwares/RT-ThreadStudio/workspace
|
||||
output_project_path=D\:\\code\\rt_thread\\studio\\ab32vg1
|
||||
is_base_example_project=False
|
||||
is_use_scons_build=True
|
||||
project_base_bsp=true
|
||||
project_name=ab32vg1
|
||||
os_version=latest
|
||||
bsp_path=repo/Local/Board_Support_Packages/Bluetrum/AB32VG1-AB-PROUGEN/1.0.0
|
||||
bsp_path=repo/Extract/Board_Support_Packages/Bluetrum/AB32VG1-AB-PROUGEN/1.1.0
|
||||
@@ -70,12 +70,12 @@ ab32vg1-prougen 是 中科蓝讯(Bluetrum) 推出的一款基于 RISC-V 内核
|
||||
| GPIO | 支持 | PA PB PE PF |
|
||||
| UART | 支持 | UART0/1/2 |
|
||||
| SDIO | 支持 | |
|
||||
| ADC | 支持 | 10bit ADC |
|
||||
| SPI | 即将支持 | 软件 SPI |
|
||||
| ADC | 支持 | 10bit SRADC 16bit SDADC |
|
||||
| SPI | 即将支持 | |
|
||||
| I2C | 支持 | 软件 I2C |
|
||||
| RTC | 支持 | |
|
||||
| WDT | 支持 | |
|
||||
| FLASH | 即将支持 | 对接 FAL |
|
||||
| FLASH | 支持 | 对接 FAL |
|
||||
| TIMER | 支持 | |
|
||||
| PWM | 支持 | LPWM 的 G1 G2 G3 之间是互斥的,只能三选一 |
|
||||
| FM receive | 支持 | |
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2006-2021, Bluetrum Development Team
|
||||
* Copyright (c) 2021-2021, Bluetrum Development Team
|
||||
*
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*
|
||||
@@ -64,7 +64,8 @@ static int blehr_sample(void)
|
||||
15,
|
||||
1);
|
||||
|
||||
if (tid != RT_NULL) {
|
||||
if (tid != RT_NULL)
|
||||
{
|
||||
rt_thread_startup(tid);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -26,7 +26,7 @@ void sd_mount(void *parameter)
|
||||
while (1)
|
||||
{
|
||||
rt_thread_mdelay(500);
|
||||
if(rt_device_find("sd0") != RT_NULL)
|
||||
if (rt_device_find("sd0") != RT_NULL)
|
||||
{
|
||||
if (dfs_mount("sd0", "/", "elm", 0, 0) == RT_EOK)
|
||||
{
|
||||
|
||||
@@ -1,12 +1,12 @@
|
||||
menu "Hardware Drivers Config"
|
||||
|
||||
config SOC_AB32VG1
|
||||
bool
|
||||
menuconfig SOC_AB32VG1
|
||||
bool "SOC_AB32VG1"
|
||||
select PKG_USING_BLUETRUM_SDK
|
||||
default y
|
||||
|
||||
config PKG_USING_BLUETRUM_NIMBLE
|
||||
bool
|
||||
menuconfig PKG_USING_BLUETRUM_NIMBLE
|
||||
bool "PKG_USING_BLUETRUM_NIMBLE"
|
||||
default n
|
||||
|
||||
menu "Onboard Peripheral Drivers"
|
||||
@@ -34,6 +34,11 @@ menu "Onboard Peripheral Drivers"
|
||||
default 24000000
|
||||
endif
|
||||
|
||||
config BSP_USING_NIMBLE
|
||||
bool "use nimble stack(iot)"
|
||||
select PKG_USING_BLUETRUM_NIMBLE
|
||||
default n
|
||||
|
||||
endmenu
|
||||
|
||||
menu "On-chip Peripheral Drivers"
|
||||
@@ -233,20 +238,10 @@ menu "On-chip Peripheral Drivers"
|
||||
default n
|
||||
endif
|
||||
|
||||
config BSP_USING_ON_CHIP_FLASH
|
||||
bool "Enable on-chip FLASH"
|
||||
default n
|
||||
endmenu
|
||||
|
||||
choice
|
||||
prompt "BLE STACK"
|
||||
default BLE_STACK_USING_NULL
|
||||
help
|
||||
Select the ble stack
|
||||
|
||||
config BLE_STACK_USING_NULL
|
||||
bool "not use the ble stack"
|
||||
|
||||
config BSP_USING_NIMBLE
|
||||
bool "use nimble stack(iot)"
|
||||
select PKG_USING_BLUETRUM_NIMBLE
|
||||
endchoice
|
||||
|
||||
endmenu
|
||||
@@ -8,10 +8,14 @@ board.c
|
||||
ab32vg1_hal_msp.c
|
||||
''')
|
||||
CPPPATH = [cwd]
|
||||
CPPPATH += [cwd + '/ports']
|
||||
|
||||
if GetDepend(['RT_USING_AUDIO']):
|
||||
src += Glob('ports/audio/drv_sound.c')
|
||||
|
||||
if GetDepend(['BSP_USING_ON_CHIP_FLASH']):
|
||||
src += Glob('ports/on_chip_flash_init.c')
|
||||
|
||||
group = DefineGroup('Board', src, depend = [''], CPPPATH = CPPPATH)
|
||||
|
||||
objs = [group]
|
||||
|
||||
@@ -68,6 +68,28 @@ void hal_printf(const char *fmt, ...)
|
||||
}
|
||||
#endif
|
||||
|
||||
RT_SECTION(".irq")
|
||||
void os_interrupt_enter(void)
|
||||
{
|
||||
rt_interrupt_enter();
|
||||
}
|
||||
|
||||
RT_SECTION(".irq")
|
||||
void os_interrupt_leave(void)
|
||||
{
|
||||
rt_interrupt_leave();
|
||||
}
|
||||
|
||||
typedef void (*isr_t)(void);
|
||||
RT_SECTION(".irq")
|
||||
isr_t register_isr(int vector, isr_t isr)
|
||||
{
|
||||
char buf[8] = {0};
|
||||
rt_snprintf(buf, sizeof(buf), "sys%d", vector);
|
||||
rt_isr_handler_t handle = (rt_isr_handler_t)isr;
|
||||
rt_hw_interrupt_install(vector, handle, RT_NULL, buf);
|
||||
}
|
||||
|
||||
RT_SECTION(".irq.timer")
|
||||
void timer0_isr(int vector, void *param)
|
||||
{
|
||||
@@ -94,9 +116,55 @@ void timer0_cfg(uint32_t ticks)
|
||||
TMR0CON |= BIT(0); // EN
|
||||
}
|
||||
|
||||
void hal_mdelay(uint32_t ms)
|
||||
uint32_t hal_get_ticks(void)
|
||||
{
|
||||
rt_thread_mdelay(ms);
|
||||
return rt_tick_get();
|
||||
}
|
||||
|
||||
void hal_mdelay(uint32_t nms)
|
||||
{
|
||||
rt_thread_mdelay(nms);
|
||||
}
|
||||
|
||||
void hal_udelay(uint32_t nus)
|
||||
{
|
||||
rt_hw_us_delay(nus);
|
||||
}
|
||||
|
||||
/**
|
||||
* The time delay function.
|
||||
*
|
||||
* @param us microseconds.
|
||||
*/
|
||||
RT_SECTION(".com_text")
|
||||
void rt_hw_us_delay(rt_uint32_t us)
|
||||
{
|
||||
rt_uint32_t ticks;
|
||||
rt_uint32_t told, tnow, tcnt = 0;
|
||||
rt_uint32_t reload = TMR0PR;
|
||||
|
||||
ticks = us * reload / (1000 / RT_TICK_PER_SECOND);
|
||||
told = TMR0CNT;
|
||||
while (1)
|
||||
{
|
||||
tnow = TMR0CNT;
|
||||
if (tnow != told)
|
||||
{
|
||||
if (tnow < told)
|
||||
{
|
||||
tcnt += told - tnow;
|
||||
}
|
||||
else
|
||||
{
|
||||
tcnt += reload - tnow + told;
|
||||
}
|
||||
told = tnow;
|
||||
if (tcnt >= ticks)
|
||||
{
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void rt_hw_systick_init(void)
|
||||
@@ -114,7 +182,7 @@ void rt_hw_systick_init(void)
|
||||
|
||||
timer0_init();
|
||||
hal_set_tick_hook(timer0_cfg);
|
||||
hal_set_ticks(get_sysclk_nhz()/RT_TICK_PER_SECOND);
|
||||
hal_set_ticks(get_sysclk_nhz() / RT_TICK_PER_SECOND);
|
||||
|
||||
PICCON |= 0x10002;
|
||||
}
|
||||
@@ -156,7 +224,8 @@ void cache_init(void)
|
||||
RT_SECTION(".irq.cache")
|
||||
void os_spiflash_lock(void)
|
||||
{
|
||||
if ((rt_thread_self() != RT_NULL) && (rt_interrupt_nest == 0)) {
|
||||
if ((rt_thread_self() != RT_NULL) && (rt_interrupt_nest == 0))
|
||||
{
|
||||
rt_mutex_take(&mutex_spiflash, RT_WAITING_FOREVER);
|
||||
}
|
||||
}
|
||||
@@ -164,7 +233,8 @@ void os_spiflash_lock(void)
|
||||
RT_SECTION(".irq.cache")
|
||||
void os_spiflash_unlock(void)
|
||||
{
|
||||
if ((rt_thread_self() != RT_NULL) && (rt_interrupt_nest == 0)) {
|
||||
if ((rt_thread_self() != RT_NULL) && (rt_interrupt_nest == 0))
|
||||
{
|
||||
rt_mutex_release(&mutex_spiflash);
|
||||
}
|
||||
}
|
||||
@@ -172,7 +242,8 @@ void os_spiflash_unlock(void)
|
||||
RT_SECTION(".irq.cache")
|
||||
void os_cache_lock(void)
|
||||
{
|
||||
if ((rt_thread_self() != RT_NULL) && (rt_interrupt_nest == 0)) {
|
||||
if ((rt_thread_self() != RT_NULL) && (rt_interrupt_nest == 0))
|
||||
{
|
||||
rt_mutex_take(&mutex_cache, RT_WAITING_FOREVER);
|
||||
}
|
||||
}
|
||||
@@ -180,7 +251,8 @@ void os_cache_lock(void)
|
||||
RT_SECTION(".irq.cache")
|
||||
void os_cache_unlock(void)
|
||||
{
|
||||
if ((rt_thread_self() != RT_NULL) && (rt_interrupt_nest == 0)) {
|
||||
if ((rt_thread_self() != RT_NULL) && (rt_interrupt_nest == 0))
|
||||
{
|
||||
rt_mutex_release(&mutex_cache);
|
||||
}
|
||||
}
|
||||
@@ -212,5 +284,5 @@ void exception_isr(void)
|
||||
rt_kprintf(stack_info, rt_thread_self()->sp, rt_thread_self()->name);
|
||||
#endif
|
||||
|
||||
while(1);
|
||||
while (1);
|
||||
}
|
||||
@@ -0,0 +1,43 @@
|
||||
/*
|
||||
* Copyright (c) 2006-2021, Bluetrum Development Team
|
||||
*
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*
|
||||
* Change Logs:
|
||||
* Date Author Notes
|
||||
* 2021-11-16 greedyhao first version
|
||||
*/
|
||||
|
||||
#ifndef __FAL_CFG_H__
|
||||
#define __FAL_CFG_H__
|
||||
|
||||
#include <rtthread.h>
|
||||
|
||||
#if defined(BSP_USING_ON_CHIP_FLASH)
|
||||
extern const struct fal_flash_dev ab32_onchip_flash;
|
||||
|
||||
/* flash device table */
|
||||
#define FAL_FLASH_DEV_TABLE \
|
||||
{ \
|
||||
&ab32_onchip_flash, \
|
||||
}
|
||||
/* ====================== Partition Configuration ========================== */
|
||||
#ifdef FAL_PART_HAS_TABLE_CFG
|
||||
|
||||
/* partition table */
|
||||
#define FAL_PART_TABLE \
|
||||
{ \
|
||||
{FAL_PART_MAGIC_WROD, "boot", "onchip_flash", 0, 8 * 1024, 0}, \
|
||||
{FAL_PART_MAGIC_WROD, "app", "onchip_flash", 8 * 1024, 996 * 1024, 0}, \
|
||||
{FAL_PART_MAGIC_WROD, "param", "onchip_flash", 1004 * 1024, 20 * 1024, 0}, \
|
||||
}
|
||||
#endif /* FAL_PART_HAS_TABLE_CFG */
|
||||
|
||||
#else
|
||||
|
||||
#define FAL_FLASH_DEV_TABLE { 0 }
|
||||
#define FAL_PART_TABLE { 0 }
|
||||
|
||||
#endif
|
||||
|
||||
#endif /* __FAL_CFG_H__ */
|
||||
@@ -0,0 +1,21 @@
|
||||
/*
|
||||
* Copyright (c) 2006-2021, Bluetrum Development Team
|
||||
*
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*
|
||||
* Change Logs:
|
||||
* Date Author Notes
|
||||
* 2021-11-16 greedyhao first version
|
||||
*/
|
||||
|
||||
#include <rtthread.h>
|
||||
#include "fal.h"
|
||||
|
||||
#if defined(BSP_USING_ON_CHIP_FLASH)
|
||||
static int rt_hw_on_chip_flash_init(void)
|
||||
{
|
||||
fal_init();
|
||||
return RT_EOK;
|
||||
}
|
||||
INIT_COMPONENT_EXPORT(rt_hw_on_chip_flash_init);
|
||||
#endif
|
||||
@@ -18,7 +18,7 @@
|
||||
#define IDLE_THREAD_STACK_SIZE 512
|
||||
#define RT_USING_TIMER_SOFT
|
||||
#define RT_TIMER_THREAD_PRIO 4
|
||||
#define RT_TIMER_THREAD_STACK_SIZE 256
|
||||
#define RT_TIMER_THREAD_STACK_SIZE 1024
|
||||
|
||||
/* kservice optimization */
|
||||
|
||||
@@ -46,7 +46,7 @@
|
||||
#define RT_USING_CONSOLE
|
||||
#define RT_CONSOLEBUF_SIZE 128
|
||||
#define RT_CONSOLE_DEVICE_NAME "uart0"
|
||||
#define RT_VER_NUM 0x40004
|
||||
#define RT_VER_NUM 0x40100
|
||||
|
||||
/* RT-Thread Components */
|
||||
|
||||
@@ -91,6 +91,7 @@
|
||||
|
||||
/* POSIX layer and C standard library */
|
||||
|
||||
#define RT_USING_LIBC
|
||||
#define RT_LIBC_USING_TIME
|
||||
#define RT_LIBC_DEFAULT_TIMEZONE 8
|
||||
|
||||
@@ -147,6 +148,9 @@
|
||||
/* u8g2: a monochrome graphic library */
|
||||
|
||||
|
||||
/* PainterEngine: A cross-platform graphics application framework written in C language */
|
||||
|
||||
|
||||
/* tools packages */
|
||||
|
||||
|
||||
@@ -155,6 +159,9 @@
|
||||
/* acceleration: Assembly language or algorithmic acceleration packages */
|
||||
|
||||
|
||||
/* CMSIS: ARM Cortex-M Microcontroller Software Interface Standard */
|
||||
|
||||
|
||||
/* Micrium: Micrium software products porting for RT-Thread */
|
||||
|
||||
|
||||
@@ -186,9 +193,6 @@
|
||||
#define BSP_USING_UART
|
||||
#define BSP_USING_UART0
|
||||
#define BSP_UART0_FIFO_SIZE 10
|
||||
|
||||
/* Board extended module Drivers */
|
||||
|
||||
#define BOARD_BLUETRUM_EVB
|
||||
|
||||
#endif
|
||||
@@ -40,7 +40,7 @@ if PLATFORM == 'gcc':
|
||||
OBJDUMP = PREFIX + 'objdump'
|
||||
OBJCPY = PREFIX + 'objcopy'
|
||||
|
||||
DEVICE = ' -mcmodel=medany -march=rv32imc -mabi=ilp32 -msave-restore'
|
||||
DEVICE = ' -mcmodel=medany -march=rv32imc -mabi=ilp32 -msave-restore -ffunction-sections'
|
||||
CFLAGS = DEVICE + ' -D_USE_LONG_TIME_T'
|
||||
AFLAGS = ' -c' + DEVICE + ' -x assembler-with-cpp'
|
||||
LFLAGS = DEVICE + ' -nostartfiles -Wl,--gc-sections,-Map=rtthread.map,-cref,-u,_start -T link.lds'
|
||||
|
||||
@@ -38,6 +38,9 @@ if GetDepend('RT_USING_ADC'):
|
||||
if GetDepend('BSP_USING_IRRX'):
|
||||
src += ['drv_irrx.c']
|
||||
|
||||
if GetDepend('BSP_USING_ON_CHIP_FLASH'):
|
||||
src += ['drv_flash.c']
|
||||
|
||||
group = DefineGroup('Drivers', src, depend = [''], CPPPATH = path)
|
||||
|
||||
objs = [group]
|
||||
|
||||
@@ -0,0 +1,140 @@
|
||||
/*
|
||||
* Copyright (c) 2006-2021, Bluetrum Development Team
|
||||
*
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*
|
||||
* Change Logs:
|
||||
* Date Author Notes
|
||||
* 2021-11-16 greedyhao first version
|
||||
*/
|
||||
|
||||
#include "board.h"
|
||||
#include "drv_flash.h"
|
||||
|
||||
#ifdef BSP_USING_ON_CHIP_FLASH
|
||||
|
||||
#if defined(PKG_USING_FAL)
|
||||
#include "fal.h"
|
||||
#endif
|
||||
|
||||
//#define DRV_DEBUG
|
||||
#define LOG_TAG "drv.flash"
|
||||
#include <drv_log.h>
|
||||
|
||||
#if defined(PKG_USING_FAL)
|
||||
|
||||
#define AB32_FLASH_START_ADDRESS 0x00000000
|
||||
#define AB32_FLASH_SIZE (1024 * 1024)
|
||||
#define AB32_FLASH_PAGE_SIZE (0x1000)
|
||||
|
||||
static int fal_flash_read(long offset, rt_uint8_t *buf, size_t size);
|
||||
static int fal_flash_write(long offset, const rt_uint8_t *buf, size_t size);
|
||||
static int fal_flash_erase(long offset, size_t size);
|
||||
|
||||
const struct fal_flash_dev ab32_onchip_flash =
|
||||
{
|
||||
"onchip_flash",
|
||||
AB32_FLASH_START_ADDRESS,
|
||||
AB32_FLASH_SIZE,
|
||||
AB32_FLASH_PAGE_SIZE,
|
||||
{NULL, fal_flash_read, fal_flash_write, fal_flash_erase},
|
||||
256 * 8
|
||||
};
|
||||
|
||||
static int fal_flash_read(long offset, rt_uint8_t *buf, size_t size)
|
||||
{
|
||||
return os_spiflash_read(buf, offset, size);
|
||||
}
|
||||
|
||||
static int fal_flash_write(long offset, const rt_uint8_t *buf, size_t size)
|
||||
{
|
||||
if (size % 256)
|
||||
{
|
||||
rt_kprintf("Flash write requires 256 byte alignment\n");
|
||||
return -1;
|
||||
}
|
||||
os_spiflash_program(buf, offset, size);
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int fal_flash_erase(long offset, size_t size)
|
||||
{
|
||||
if (size % 4096)
|
||||
{
|
||||
rt_kprintf("Flash erase requires 4096 byte alignment\n");
|
||||
return -1;
|
||||
}
|
||||
while (size > 0)
|
||||
{
|
||||
os_spiflash_erase(offset);
|
||||
offset += 4096;
|
||||
size -= 4096;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
int fal_ops_test(void)
|
||||
{
|
||||
int result;
|
||||
const struct fal_partition *part_dev = fal_partition_find("param");
|
||||
uint8_t *data = rt_malloc(256);
|
||||
int i;
|
||||
int size = 256;
|
||||
int addr = 0;
|
||||
|
||||
for (int i = 0; i < 256; i++)
|
||||
{
|
||||
data[i] = i;
|
||||
}
|
||||
|
||||
result = fal_partition_write(part_dev, 0, data, 256);
|
||||
if (result >= 0)
|
||||
{
|
||||
rt_kprintf("Write data success. Start from 0x%08X, size is %ld.\n", addr, size);
|
||||
rt_kprintf("Write data: ");
|
||||
for (i = 0; i < size; i++)
|
||||
{
|
||||
rt_kprintf("%d ", data[i]);
|
||||
}
|
||||
rt_kprintf(".\n");
|
||||
}
|
||||
|
||||
rt_memset(data, 0, 256);
|
||||
result = fal_partition_read(part_dev, 0, data, 256);
|
||||
if (result >= 0)
|
||||
{
|
||||
rt_kprintf("Read data success. Start from 0x%08X, size is %ld.\n", addr, size);
|
||||
rt_kprintf("Read data: ");
|
||||
for (i = 0; i < size; i++)
|
||||
{
|
||||
rt_kprintf("%d ", data[i]);
|
||||
}
|
||||
rt_kprintf(".\n");
|
||||
}
|
||||
|
||||
result = fal_partition_erase(part_dev, 0, 4096);
|
||||
if (result >= 0)
|
||||
{
|
||||
rt_kprintf("Erase data success.\n");
|
||||
}
|
||||
|
||||
rt_memset(data, 0, 256);
|
||||
result = fal_partition_read(part_dev, 0, data, 256);
|
||||
if (result >= 0)
|
||||
{
|
||||
rt_kprintf("Read data success. Start from 0x%08X, size is %ld.\n", addr, size);
|
||||
rt_kprintf("Read data: ");
|
||||
for (i = 0; i < size; i++)
|
||||
{
|
||||
rt_kprintf("%d ", data[i]);
|
||||
}
|
||||
rt_kprintf(".\n");
|
||||
}
|
||||
rt_free(data);
|
||||
|
||||
return 0;
|
||||
}
|
||||
MSH_CMD_EXPORT(fal_ops_test, "fal_ops_test");
|
||||
|
||||
#endif
|
||||
#endif
|
||||
@@ -0,0 +1,42 @@
|
||||
/*
|
||||
* Copyright (c) 2006-2021, Bluetrum Development Team
|
||||
*
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*
|
||||
* Change Logs:
|
||||
* Date Author Notes
|
||||
* 2021-11-16 greedyhao first version
|
||||
*/
|
||||
|
||||
#ifndef __DRV_FLASH_H__
|
||||
#define __DRV_FLASH_H__
|
||||
|
||||
#include <stdint.h>
|
||||
|
||||
/**
|
||||
* @brief Read a block of data
|
||||
*
|
||||
* @param buf output data
|
||||
* @param addr
|
||||
* @param len less than 512
|
||||
* @return uint16_t
|
||||
*/
|
||||
uint16_t os_spiflash_read(void *buf, uint32_t addr, uint16_t len);
|
||||
|
||||
/**
|
||||
* @brief Write a block of data
|
||||
*
|
||||
* @param buf input data
|
||||
* @param addr 256 alignment
|
||||
* @param len 256 alignment
|
||||
*/
|
||||
void os_spiflash_program(const void *buf, uint32_t addr, uint16_t len);
|
||||
|
||||
/**
|
||||
* @brief Erases a block of data
|
||||
*
|
||||
* @param addr 4k alignment
|
||||
*/
|
||||
void os_spiflash_erase(uint32_t addr);
|
||||
|
||||
#endif /* __DRV_FLASH_H__ */
|
||||
@@ -27,9 +27,9 @@ struct port_info
|
||||
static const struct port_info port_table[] =
|
||||
{
|
||||
{0, 8, 0}, /* PA0-PA7 */
|
||||
{0, 5, 8}, /* PB0-PB5 */
|
||||
{0, 5, 8}, /* PB0-PB4 */
|
||||
{0, 8, 13}, /* PE0-PE7 */
|
||||
{0, 6, 21}, /* PF0-PF6 */
|
||||
{0, 6, 21}, /* PF0-PF5 */
|
||||
};
|
||||
|
||||
static const hal_sfr_t port_sfr[] =
|
||||
@@ -56,8 +56,6 @@ static rt_uint8_t _pin_port(rt_uint32_t pin)
|
||||
#define PORT_SFR(port) (port_sfr[(port)])
|
||||
#define PIN_NO(pin) (rt_uint8_t)((pin) & 0xFu)
|
||||
|
||||
// #define PIN_ABPIN(pin) (rt_uint8_t)(port_table[PIN_PORT(pin)].total_pin + PIN_NO(pin))
|
||||
|
||||
static rt_base_t ab32_pin_get(const char *name)
|
||||
{
|
||||
rt_base_t pin = 0;
|
||||
|
||||
@@ -11,7 +11,6 @@
|
||||
*/
|
||||
|
||||
#include "board.h"
|
||||
#include <time.h>
|
||||
#include <sys/time.h>
|
||||
|
||||
#ifdef BSP_USING_ONCHIP_RTC
|
||||
|
||||
@@ -142,41 +142,6 @@ static rt_int32_t ab32_get_scl(void *data)
|
||||
return rt_pin_read(cfg->scl);
|
||||
}
|
||||
|
||||
/**
|
||||
* The time delay function.
|
||||
*
|
||||
* @param us microseconds.
|
||||
*/
|
||||
static void ab32_udelay(rt_uint32_t us)
|
||||
{
|
||||
rt_uint32_t ticks;
|
||||
rt_uint32_t told, tnow, tcnt = 0;
|
||||
rt_uint32_t reload = TMR0PR;
|
||||
|
||||
ticks = us * reload / (1000 / RT_TICK_PER_SECOND);
|
||||
told = TMR0CNT;
|
||||
while (1)
|
||||
{
|
||||
tnow = TMR0CNT;
|
||||
if (tnow != told)
|
||||
{
|
||||
if (tnow < told)
|
||||
{
|
||||
tcnt += told - tnow;
|
||||
}
|
||||
else
|
||||
{
|
||||
tcnt += reload - tnow + told;
|
||||
}
|
||||
told = tnow;
|
||||
if (tcnt >= ticks)
|
||||
{
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
static const struct rt_i2c_bit_ops ab32_bit_ops_default =
|
||||
{
|
||||
.data = RT_NULL,
|
||||
@@ -184,7 +149,7 @@ static const struct rt_i2c_bit_ops ab32_bit_ops_default =
|
||||
.set_scl = ab32_set_scl,
|
||||
.get_sda = ab32_get_sda,
|
||||
.get_scl = ab32_get_scl,
|
||||
.udelay = ab32_udelay,
|
||||
.udelay = rt_hw_us_delay,
|
||||
.delay_us = 1,
|
||||
.timeout = 100
|
||||
};
|
||||
@@ -205,9 +170,9 @@ static rt_err_t ab32_i2c_bus_unlock(const struct ab32_soft_i2c_config *cfg)
|
||||
while (i++ < 9)
|
||||
{
|
||||
rt_pin_write(cfg->scl, PIN_HIGH);
|
||||
ab32_udelay(100);
|
||||
rt_hw_us_delay(100);
|
||||
rt_pin_write(cfg->scl, PIN_LOW);
|
||||
ab32_udelay(100);
|
||||
rt_hw_us_delay(100);
|
||||
}
|
||||
}
|
||||
if (PIN_LOW == rt_pin_read(cfg->sda))
|
||||
|
||||
@@ -11,8 +11,9 @@
|
||||
|
||||
void hal_set_tick_hook(void (*hook)(uint32_t ticks));
|
||||
void hal_set_ticks(uint32_t ticks);
|
||||
uint32_t hal_get_ticks(void);
|
||||
void hal_mdelay(uint32_t nms);
|
||||
void hal_udelay(uint16_t nus);
|
||||
void hal_udelay(uint32_t nus);
|
||||
void hal_printf(const char *fmt, ...);
|
||||
|
||||
#endif
|
||||
Binary file not shown.
@@ -11,26 +11,24 @@ void hal_set_tick_hook(void (*hook)(uint32_t ticks))
|
||||
|
||||
void hal_set_ticks(uint32_t ticks)
|
||||
{
|
||||
if (ticks != hw_ticks) {
|
||||
if (ticks != hw_ticks)
|
||||
{
|
||||
hw_ticks = ticks;
|
||||
}
|
||||
if (tick_cfg_hook != HAL_NULL) {
|
||||
if (tick_cfg_hook != HAL_NULL)
|
||||
{
|
||||
tick_cfg_hook(hw_ticks);
|
||||
}
|
||||
}
|
||||
|
||||
WEAK void hal_mdelay(uint32_t nms)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
void hal_udelay(uint16_t nus)
|
||||
WEAK void hal_udelay(uint32_t nus)
|
||||
{
|
||||
int i;
|
||||
for (i = 0; i < nus*10; i++) {
|
||||
asm("nop");
|
||||
}
|
||||
}
|
||||
|
||||
WEAK void hal_printf(const char *fmt, ...)
|
||||
{}
|
||||
{
|
||||
}
|
||||
@@ -6,7 +6,6 @@
|
||||
|
||||
#include "ab32vg1.h"
|
||||
|
||||
.set _memcpy, 0x84044
|
||||
.global _start
|
||||
.section .reset, "ax"
|
||||
_start:
|
||||
@@ -111,3 +110,5 @@ cpu_irq_comm:
|
||||
|
||||
.global _tp
|
||||
.set _tp, 0x84800
|
||||
|
||||
.set _memcpy, 0x84044
|
||||
@@ -29,7 +29,7 @@ extern "C" {
|
||||
|
||||
#include <stdint.h>
|
||||
#include <drv_common.h>
|
||||
#include <time.h>
|
||||
#include <sys/time.h>
|
||||
|
||||
/// definition for rtc handle.
|
||||
typedef void *rtc_handle_t;
|
||||
|
||||
@@ -12,7 +12,7 @@
|
||||
* ----- ------ -------- --------------------------------------
|
||||
*/
|
||||
|
||||
#include <time.h>
|
||||
#include <sys/time.h>
|
||||
#include <string.h>
|
||||
#include "ft_i2c_hw.h"
|
||||
#include "ft_i2c.h"
|
||||
|
||||
@@ -20,7 +20,7 @@
|
||||
|
||||
#include "drv_rtc.h"
|
||||
#include "fsl_snvs_hp.h"
|
||||
#include <time.h>
|
||||
#include <sys/time.h>
|
||||
|
||||
#if defined(FSL_SDK_DISABLE_DRIVER_CLOCK_CONTROL) && FSL_SDK_DISABLE_DRIVER_CLOCK_CONTROL
|
||||
#error "Please don't define 'FSL_SDK_DISABLE_DRIVER_CLOCK_CONTROL'!"
|
||||
|
||||
@@ -36,7 +36,7 @@
|
||||
|
||||
#include "chip.h"
|
||||
#include <stdlib.h>
|
||||
#include <time.h>
|
||||
#include <sys/time.h>
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
|
||||
@@ -6,6 +6,7 @@
|
||||
* Change Logs:
|
||||
* Date Author Notes
|
||||
* 2020-11-15 xckhmf First Verison
|
||||
* 2021-11-27 chenyingchun fix _master_xfer bug
|
||||
*
|
||||
*/
|
||||
|
||||
@@ -56,36 +57,54 @@ static int twi_master_init(struct rt_i2c_bus_device *bus)
|
||||
nrfx_twi_twim_bus_recover(config.scl,config.sda);
|
||||
|
||||
rtn = nrfx_twim_init(p_instance,&config,NULL,NULL);
|
||||
if (rtn != NRFX_SUCCESS)
|
||||
{
|
||||
return rtn;
|
||||
}
|
||||
nrfx_twim_enable(p_instance);
|
||||
return 0;
|
||||
}
|
||||
|
||||
static rt_size_t _master_xfer(struct rt_i2c_bus_device *bus,
|
||||
struct rt_i2c_msg msgs[],
|
||||
rt_uint32_t num)
|
||||
struct rt_i2c_msg msgs[],
|
||||
rt_uint32_t num)
|
||||
{
|
||||
nrfx_twim_t const * p_instance = &((drv_i2c_cfg_t *)bus->priv)->twi_instance;
|
||||
struct rt_i2c_msg *msg;
|
||||
nrfx_twim_t const *p_instance = &((drv_i2c_cfg_t *)bus->priv)->twi_instance;
|
||||
nrfx_err_t ret = NRFX_ERROR_INTERNAL;
|
||||
uint32_t no_stop_flag = 0;
|
||||
rt_int32_t i = 0;
|
||||
|
||||
nrfx_twim_xfer_desc_t xfer = NRFX_TWIM_XFER_DESC_TX(msgs->addr,msgs->buf, msgs->len);
|
||||
if((msgs->flags & 0x01) == RT_I2C_WR)
|
||||
for (i = 0; i < num; i++)
|
||||
{
|
||||
xfer.type = NRFX_TWIM_XFER_TX;
|
||||
if((msgs->flags & 0x40) == RT_I2C_NO_READ_ACK)
|
||||
msg = &msgs[i];
|
||||
nrfx_twim_xfer_desc_t xfer = NRFX_TWIM_XFER_DESC_TX(msg->addr, msg->buf, msg->len);
|
||||
|
||||
if (msg->flags & RT_I2C_RD)
|
||||
{
|
||||
no_stop_flag = NRFX_TWIM_FLAG_TX_NO_STOP;
|
||||
xfer.type = NRFX_TWIM_XFER_RX;
|
||||
}
|
||||
else
|
||||
{
|
||||
xfer.type = NRFX_TWIM_XFER_TX;
|
||||
if (msg->flags & RT_I2C_NO_READ_ACK)
|
||||
{
|
||||
no_stop_flag = NRFX_TWIM_FLAG_TX_NO_STOP;
|
||||
}
|
||||
}
|
||||
|
||||
ret = nrfx_twim_xfer(p_instance, &xfer, no_stop_flag);
|
||||
if (ret != NRFX_SUCCESS)
|
||||
{
|
||||
goto out;
|
||||
}
|
||||
}
|
||||
else if((msgs->flags & 0x01) == RT_I2C_RD)
|
||||
{
|
||||
xfer.type = NRFX_TWIM_XFER_RX;
|
||||
}
|
||||
ret = nrfx_twim_xfer(p_instance,&xfer,no_stop_flag);
|
||||
return (ret == NRFX_SUCCESS) ? msgs->len : 0;
|
||||
|
||||
out:
|
||||
return i;
|
||||
}
|
||||
|
||||
|
||||
static const struct rt_i2c_bus_device_ops _i2c_ops =
|
||||
{
|
||||
_master_xfer,
|
||||
|
||||
@@ -405,6 +405,64 @@ menu "On-chip Peripheral Drivers"
|
||||
hex "MCU FLASH PAGE SIZE, please not change,nrfx default is 0x1000"
|
||||
default 0x1000
|
||||
endmenu
|
||||
|
||||
config BSP_USING_TIM
|
||||
bool "Enable TIMER"
|
||||
select RT_USING_HWTIMER
|
||||
default n
|
||||
if BSP_USING_TIM
|
||||
config NRFX_TIMER_ENABLED
|
||||
int
|
||||
default 1
|
||||
config BSP_USING_TIM0
|
||||
bool "Enable TIMER0"
|
||||
default n
|
||||
if BSP_USING_TIM0
|
||||
config NRFX_TIMER0_ENABLED
|
||||
int
|
||||
default 1
|
||||
endif
|
||||
config BSP_USING_TIM1
|
||||
bool "Enable TIMER1"
|
||||
default n
|
||||
if BSP_USING_TIM1
|
||||
config NRFX_TIMER1_ENABLED
|
||||
int
|
||||
default 1
|
||||
endif
|
||||
config BSP_USING_TIM2
|
||||
bool "Enable TIMER2"
|
||||
default n
|
||||
if BSP_USING_TIM2
|
||||
config NRFX_TIMER2_ENABLED
|
||||
int
|
||||
default 1
|
||||
endif
|
||||
config BSP_USING_TIM3
|
||||
bool "Enable TIMER3"
|
||||
default n
|
||||
if BSP_USING_TIM3
|
||||
config NRFX_TIMER3_ENABLED
|
||||
int
|
||||
default 1
|
||||
endif
|
||||
|
||||
config BSP_USING_TIM4
|
||||
bool "Enable TIMER4"
|
||||
default n
|
||||
if BSP_USING_TIM4
|
||||
config NRFX_TIMER4_ENABLED
|
||||
int
|
||||
default 1
|
||||
endif
|
||||
endif
|
||||
|
||||
|
||||
if PKG_USING_TINYUSB
|
||||
config NRFX_POWER_ENABLED
|
||||
int
|
||||
default 1
|
||||
endif
|
||||
|
||||
endmenu
|
||||
|
||||
|
||||
@@ -72,20 +72,32 @@ static nu_i2c_bus_t nu_i2c1 =
|
||||
static rt_size_t nu_i2c_mst_xfer(struct rt_i2c_bus_device *bus,
|
||||
struct rt_i2c_msg msgs[],
|
||||
rt_uint32_t num);
|
||||
static rt_err_t nu_i2c_bus_control(struct rt_i2c_bus_device *bus,
|
||||
rt_uint32_t u32Cmd,
|
||||
rt_uint32_t u32Value);
|
||||
|
||||
static const struct rt_i2c_bus_device_ops nu_i2c_ops =
|
||||
{
|
||||
.master_xfer = nu_i2c_mst_xfer,
|
||||
.slave_xfer = NULL,
|
||||
.i2c_bus_control = NULL,
|
||||
.i2c_bus_control = nu_i2c_bus_control
|
||||
};
|
||||
|
||||
static rt_err_t nu_i2c_configure(nu_i2c_bus_t *bus)
|
||||
static rt_err_t nu_i2c_bus_control(struct rt_i2c_bus_device *bus, rt_uint32_t u32Cmd, rt_uint32_t u32Value)
|
||||
{
|
||||
RT_ASSERT(bus != RT_NULL);
|
||||
nu_i2c_bus_t *nu_i2c;
|
||||
|
||||
bus->parent.ops = &nu_i2c_ops;
|
||||
I2C_Open(bus->I2C, 100000);
|
||||
RT_ASSERT(bus != RT_NULL);
|
||||
nu_i2c = (nu_i2c_bus_t *) bus;
|
||||
|
||||
switch (RT_I2C_DEV_CTRL_CLK)
|
||||
{
|
||||
case RT_I2C_DEV_CTRL_CLK:
|
||||
I2C_SetBusClockFreq(nu_i2c->I2C, u32Value);
|
||||
break;
|
||||
default:
|
||||
return -RT_EIO;
|
||||
}
|
||||
|
||||
return RT_EOK;
|
||||
}
|
||||
@@ -290,24 +302,28 @@ static rt_size_t nu_i2c_mst_xfer(struct rt_i2c_bus_device *bus,
|
||||
int rt_hw_i2c_init(void)
|
||||
{
|
||||
rt_err_t ret = RT_ERROR;
|
||||
#if defined(BSP_USING_I2C0)
|
||||
|
||||
SYS_UnlockReg();
|
||||
SYS_ResetModule(I2C0_RST);
|
||||
SYS_LockReg();
|
||||
nu_i2c_configure(&nu_i2c0);
|
||||
|
||||
#if defined(BSP_USING_I2C0)
|
||||
I2C_Close(nu_i2c0.I2C);
|
||||
I2C_Open(nu_i2c0.I2C, 100000);
|
||||
nu_i2c0.parent.ops = &nu_i2c_ops;
|
||||
|
||||
ret = rt_i2c_bus_device_register(&nu_i2c0.parent, nu_i2c0.device_name);
|
||||
RT_ASSERT(RT_EOK == ret);
|
||||
#endif /* BSP_USING_I2C0 */
|
||||
|
||||
#if defined(BSP_USING_I2C1)
|
||||
SYS_UnlockReg();
|
||||
SYS_ResetModule(I2C1_RST);
|
||||
SYS_LockReg();
|
||||
nu_i2c_configure(&nu_i2c1);
|
||||
I2C_Close(nu_i2c1.I2C);
|
||||
I2C_Open(nu_i2c1.I2C, 100000);
|
||||
nu_i2c1.parent.ops = &nu_i2c_ops;
|
||||
|
||||
ret = rt_i2c_bus_device_register(&nu_i2c1.parent, nu_i2c1.device_name);
|
||||
RT_ASSERT(RT_EOK == ret);
|
||||
#endif /* BSP_USING_I2C1 */
|
||||
|
||||
SYS_LockReg();
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
||||
@@ -1144,6 +1144,9 @@ void USBH_IRQHandler(void)
|
||||
TD_T *td, *td_prev, *td_next;
|
||||
uint32_t int_sts;
|
||||
|
||||
/* enter interrupt */
|
||||
rt_interrupt_enter();
|
||||
|
||||
int_sts = _ohci->HcInterruptStatus;
|
||||
|
||||
//USB_debug("ohci int_sts = 0x%x\n", int_sts);
|
||||
@@ -1199,6 +1202,10 @@ void USBH_IRQHandler(void)
|
||||
}
|
||||
|
||||
_ohci->HcInterruptStatus = int_sts;
|
||||
|
||||
/* leave interrupt */
|
||||
rt_interrupt_leave();
|
||||
|
||||
}
|
||||
|
||||
#ifdef ENABLE_DEBUG_MSG
|
||||
|
||||
@@ -81,20 +81,32 @@ static nu_i2c_bus_t nu_i2c2 =
|
||||
static rt_size_t nu_i2c_mst_xfer(struct rt_i2c_bus_device *bus,
|
||||
struct rt_i2c_msg msgs[],
|
||||
rt_uint32_t num);
|
||||
static rt_err_t nu_i2c_bus_control(struct rt_i2c_bus_device *bus,
|
||||
rt_uint32_t u32Cmd,
|
||||
rt_uint32_t u32Value);
|
||||
|
||||
static const struct rt_i2c_bus_device_ops nu_i2c_ops =
|
||||
{
|
||||
.master_xfer = nu_i2c_mst_xfer,
|
||||
.slave_xfer = NULL,
|
||||
.i2c_bus_control = NULL,
|
||||
.i2c_bus_control = nu_i2c_bus_control
|
||||
};
|
||||
|
||||
static rt_err_t nu_i2c_configure(nu_i2c_bus_t *bus)
|
||||
static rt_err_t nu_i2c_bus_control(struct rt_i2c_bus_device *bus, rt_uint32_t u32Cmd, rt_uint32_t u32Value)
|
||||
{
|
||||
RT_ASSERT(bus != RT_NULL);
|
||||
nu_i2c_bus_t *nu_i2c;
|
||||
|
||||
bus->parent.ops = &nu_i2c_ops;
|
||||
I2C_Open(bus->I2C, 100000);
|
||||
RT_ASSERT(bus != RT_NULL);
|
||||
nu_i2c = (nu_i2c_bus_t *) bus;
|
||||
|
||||
switch (RT_I2C_DEV_CTRL_CLK)
|
||||
{
|
||||
case RT_I2C_DEV_CTRL_CLK:
|
||||
I2C_SetBusClockFreq(nu_i2c->I2C, u32Value);
|
||||
break;
|
||||
default:
|
||||
return -RT_EIO;
|
||||
}
|
||||
|
||||
return RT_EOK;
|
||||
}
|
||||
@@ -354,33 +366,38 @@ static rt_size_t nu_i2c_mst_xfer(struct rt_i2c_bus_device *bus,
|
||||
int rt_hw_i2c_init(void)
|
||||
{
|
||||
rt_err_t ret = RT_ERROR;
|
||||
#if defined(BSP_USING_I2C0)
|
||||
|
||||
SYS_UnlockReg();
|
||||
SYS_ResetModule(I2C0_RST);
|
||||
SYS_LockReg();
|
||||
nu_i2c_configure(&nu_i2c0);
|
||||
|
||||
#if defined(BSP_USING_I2C0)
|
||||
I2C_Close(nu_i2c0.I2C);
|
||||
I2C_Open(nu_i2c0.I2C, 100000);
|
||||
nu_i2c0.parent.ops = &nu_i2c_ops;
|
||||
|
||||
ret = rt_i2c_bus_device_register(&nu_i2c0.parent, nu_i2c0.device_name);
|
||||
RT_ASSERT(RT_EOK == ret);
|
||||
#endif /* BSP_USING_I2C0 */
|
||||
|
||||
#if defined(BSP_USING_I2C1)
|
||||
SYS_UnlockReg();
|
||||
SYS_ResetModule(I2C1_RST);
|
||||
SYS_LockReg();
|
||||
nu_i2c_configure(&nu_i2c1);
|
||||
I2C_Close(nu_i2c1.I2C);
|
||||
I2C_Open(nu_i2c1.I2C, 100000);
|
||||
nu_i2c1.parent.ops = &nu_i2c_ops;
|
||||
|
||||
ret = rt_i2c_bus_device_register(&nu_i2c1.parent, nu_i2c1.device_name);
|
||||
RT_ASSERT(RT_EOK == ret);
|
||||
#endif /* BSP_USING_I2C1 */
|
||||
|
||||
#if defined(BSP_USING_I2C2)
|
||||
SYS_UnlockReg();
|
||||
SYS_ResetModule(I2C2_RST);
|
||||
SYS_LockReg();
|
||||
nu_i2c_configure(&nu_i2c2);
|
||||
I2C_Close(nu_i2c2.I2C);
|
||||
I2C_Open(nu_i2c2.I2C, 100000);
|
||||
nu_i2c2.parent.ops = &nu_i2c_ops;
|
||||
|
||||
ret = rt_i2c_bus_device_register(&nu_i2c2.parent, nu_i2c2.device_name);
|
||||
RT_ASSERT(RT_EOK == ret);
|
||||
#endif /* BSP_USING_I2C2 */
|
||||
|
||||
SYS_LockReg();
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
||||
File diff suppressed because it is too large.
Load diff
@@ -1113,6 +1113,9 @@ void EHCI_IRQHandler(void)
|
||||
{
|
||||
uint32_t intsts;
|
||||
|
||||
/* enter interrupt */
|
||||
rt_interrupt_enter();
|
||||
|
||||
intsts = _ehci->USTSR;
|
||||
_ehci->USTSR = intsts; /* clear interrupt status */
|
||||
|
||||
@@ -1136,6 +1139,9 @@ void EHCI_IRQHandler(void)
|
||||
{
|
||||
iaad_remove_qh();
|
||||
}
|
||||
|
||||
/* leave interrupt */
|
||||
rt_interrupt_leave();
|
||||
}
|
||||
|
||||
static UDEV_T *ehci_find_device_by_port(int port)
|
||||
|
||||
@@ -1154,6 +1154,9 @@ void OHCI_IRQHandler(void)
|
||||
TD_T *td, *td_prev, *td_next;
|
||||
uint32_t int_sts;
|
||||
|
||||
/* enter interrupt */
|
||||
rt_interrupt_enter();
|
||||
|
||||
int_sts = _ohci->HcInterruptStatus;
|
||||
|
||||
//USB_debug("ohci int_sts = 0x%x\n", int_sts);
|
||||
@@ -1209,6 +1212,9 @@ void OHCI_IRQHandler(void)
|
||||
}
|
||||
|
||||
_ohci->HcInterruptStatus = int_sts;
|
||||
|
||||
/* leave interrupt */
|
||||
rt_interrupt_leave();
|
||||
}
|
||||
|
||||
#ifdef ENABLE_DEBUG_MSG
|
||||
|
||||
@@ -81,20 +81,32 @@ static nu_i2c_bus_t nu_i2c2 =
|
||||
static rt_size_t nu_i2c_mst_xfer(struct rt_i2c_bus_device *bus,
|
||||
struct rt_i2c_msg msgs[],
|
||||
rt_uint32_t num);
|
||||
static rt_err_t nu_i2c_bus_control(struct rt_i2c_bus_device *bus,
|
||||
rt_uint32_t u32Cmd,
|
||||
rt_uint32_t u32Value);
|
||||
|
||||
static const struct rt_i2c_bus_device_ops nu_i2c_ops =
|
||||
{
|
||||
.master_xfer = nu_i2c_mst_xfer,
|
||||
.slave_xfer = NULL,
|
||||
.i2c_bus_control = NULL,
|
||||
.i2c_bus_control = nu_i2c_bus_control
|
||||
};
|
||||
|
||||
static rt_err_t nu_i2c_configure(nu_i2c_bus_t *bus)
|
||||
static rt_err_t nu_i2c_bus_control(struct rt_i2c_bus_device *bus, rt_uint32_t u32Cmd, rt_uint32_t u32Value)
|
||||
{
|
||||
RT_ASSERT(bus != RT_NULL);
|
||||
nu_i2c_bus_t *nu_i2c;
|
||||
|
||||
bus->parent.ops = &nu_i2c_ops;
|
||||
I2C_Open(bus->I2C, 100000);
|
||||
RT_ASSERT(bus != RT_NULL);
|
||||
nu_i2c = (nu_i2c_bus_t *) bus;
|
||||
|
||||
switch (RT_I2C_DEV_CTRL_CLK)
|
||||
{
|
||||
case RT_I2C_DEV_CTRL_CLK:
|
||||
I2C_SetBusClockFreq(nu_i2c->I2C, u32Value);
|
||||
break;
|
||||
default:
|
||||
return -RT_EIO;
|
||||
}
|
||||
|
||||
return RT_EOK;
|
||||
}
|
||||
@@ -354,36 +366,38 @@ static rt_size_t nu_i2c_mst_xfer(struct rt_i2c_bus_device *bus,
|
||||
int rt_hw_i2c_init(void)
|
||||
{
|
||||
rt_err_t ret = RT_ERROR;
|
||||
#if defined(BSP_USING_I2C0)
|
||||
|
||||
SYS_UnlockReg();
|
||||
/* Enable I2C0 clock */
|
||||
SYS_ResetModule(I2C0_RST);
|
||||
SYS_LockReg();
|
||||
nu_i2c_configure(&nu_i2c0);
|
||||
|
||||
#if defined(BSP_USING_I2C0)
|
||||
I2C_Close(nu_i2c0.I2C);
|
||||
I2C_Open(nu_i2c0.I2C, 100000);
|
||||
nu_i2c0.parent.ops = &nu_i2c_ops;
|
||||
|
||||
ret = rt_i2c_bus_device_register(&nu_i2c0.parent, nu_i2c0.device_name);
|
||||
RT_ASSERT(RT_EOK == ret);
|
||||
#endif /* BSP_USING_I2C0 */
|
||||
|
||||
#if defined(BSP_USING_I2C1)
|
||||
SYS_UnlockReg();
|
||||
/* Enable I2C1 clock */
|
||||
SYS_ResetModule(I2C1_RST);
|
||||
SYS_LockReg();
|
||||
nu_i2c_configure(&nu_i2c1);
|
||||
I2C_Close(nu_i2c1.I2C);
|
||||
I2C_Open(nu_i2c1.I2C, 100000);
|
||||
nu_i2c1.parent.ops = &nu_i2c_ops;
|
||||
|
||||
ret = rt_i2c_bus_device_register(&nu_i2c1.parent, nu_i2c1.device_name);
|
||||
RT_ASSERT(RT_EOK == ret);
|
||||
#endif /* BSP_USING_I2C1 */
|
||||
|
||||
#if defined(BSP_USING_I2C2)
|
||||
SYS_UnlockReg();
|
||||
/* Enable I2C2 clock */
|
||||
SYS_ResetModule(I2C2_RST);
|
||||
SYS_LockReg();
|
||||
nu_i2c_configure(&nu_i2c2);
|
||||
I2C_Close(nu_i2c2.I2C);
|
||||
I2C_Open(nu_i2c2.I2C, 100000);
|
||||
nu_i2c2.parent.ops = &nu_i2c_ops;
|
||||
|
||||
ret = rt_i2c_bus_device_register(&nu_i2c2.parent, nu_i2c2.device_name);
|
||||
RT_ASSERT(RT_EOK == ret);
|
||||
#endif /* BSP_USING_I2C2 */
|
||||
|
||||
SYS_LockReg();
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
||||
File diff suppressed because it is too large.
Load diff
@@ -376,6 +376,7 @@ typedef struct
|
||||
__IO uint32_t BLEN; /*!< [0x0838] SD Block Length Register */
|
||||
__IO uint32_t TOUT; /*!< [0x083c] SD Response/Data-in Time-out Register */
|
||||
|
||||
__IO uint32_t ECTL; /*!< [0x0840] SD Host Extend Control Register */
|
||||
} SDH_T;
|
||||
|
||||
|
||||
@@ -450,8 +451,8 @@ typedef struct
|
||||
#define SDH_CTL_CLK8OEN_Pos (6) /*!< SDH_T::CTL: CLK8OEN Position */
|
||||
#define SDH_CTL_CLK8OEN_Msk (0x1ul << SDH_CTL_CLK8OEN_Pos) /*!< SDH_T::CTL: CLK8OEN Mask */
|
||||
|
||||
#define SDH_CTL_CLKKEEP_Pos (7) /*!< SDH_T::CTL: CLKKEEP Position */
|
||||
#define SDH_CTL_CLKKEEP_Msk (0x1ul << SDH_CTL_CLKKEEP_Pos) /*!< SDH_T::CTL: CLKKEEP Mask */
|
||||
#define SDH_CTL_CLKKEEP0_Pos (7) /*!< SDH_T::CTL: CLKKEEP Position */
|
||||
#define SDH_CTL_CLKKEEP0_Msk (0x1ul << SDH_CTL_CLKKEEP0_Pos) /*!< SDH_T::CTL: CLKKEEP Mask */
|
||||
|
||||
#define SDH_CTL_CMDCODE_Pos (8) /*!< SDH_T::CTL: CMDCODE Position */
|
||||
#define SDH_CTL_CMDCODE_Msk (0x3ful << SDH_CTL_CMDCODE_Pos) /*!< SDH_T::CTL: CMDCODE Mask */
|
||||
@@ -567,6 +568,12 @@ typedef struct
|
||||
#define SDH_TOUT_TOUT_Pos (0) /*!< SDH_T::TOUT: TOUT Position */
|
||||
#define SDH_TOUT_TOUT_Msk (0xfffffful << SDH_TOUT_TOUT_Pos) /*!< SDH_T::TOUT: TOUT Mask */
|
||||
|
||||
#define SDH_ECTL_POWEROFF0_Pos (0) /*!< SDH_T::ECTL: POWEROFF0 Position */
|
||||
#define SDH_ECTL_POWEROFF0_Msk (0x1ul << SDH_ECTL_POWEROFF0_Pos) /*!< SDH_T::ECTL: POWEROFF0 Mask */
|
||||
|
||||
#define SDH_ECTL_POWEROFF1_Pos (1) /*!< SDH_T::ECTL: POWEROFF1 Position */
|
||||
#define SDH_ECTL_POWEROFF1_Msk (0x1ul << SDH_ECTL_POWEROFF1_Pos) /*!< SDH_T::ECTL: POWEROFF1 Mask */
|
||||
|
||||
/**@}*/ /* SDH_CONST */
|
||||
/**@}*/ /* end of SDH register group */
|
||||
/**@}*/ /* end of REGISTER group */
|
||||
@@ -645,7 +652,6 @@ typedef struct SDH_info_t
|
||||
/*@}*/ /* end of group N9H30_SDH_EXPORTED_TYPEDEF */
|
||||
|
||||
/// @cond HIDDEN_SYMBOLS
|
||||
extern SDH_INFO_T SD0, SD1;
|
||||
|
||||
/// @endcond HIDDEN_SYMBOLS
|
||||
|
||||
@@ -724,7 +730,7 @@ extern SDH_INFO_T SD0, SD1;
|
||||
* 0: Card removed.
|
||||
* \hideinitializer
|
||||
*/
|
||||
#define SDH_IS_CARD_PRESENT(sdh) (((sdh) == SDH0)? SD0.IsCardInsert : SD1.IsCardInsert)
|
||||
//#define SDH_IS_CARD_PRESENT(sdh) (((sdh) == SDH0)? SD0.IsCardInsert : SD1.IsCardInsert)
|
||||
|
||||
/**
|
||||
* @brief Get SD Card capacity.
|
||||
@@ -734,17 +740,18 @@ extern SDH_INFO_T SD0, SD1;
|
||||
* @return SD Card capacity. (unit: KByte)
|
||||
* \hideinitializer
|
||||
*/
|
||||
#define SDH_GET_CARD_CAPACITY(sdh) (((sdh) == SDH0)? SD0.diskSize : SD1.diskSize)
|
||||
//#define SDH_GET_CARD_CAPACITY(sdh) (((sdh) == SDH0)? SD0.diskSize : SD1.diskSize)
|
||||
|
||||
|
||||
void SDH_Open(SDH_T *sdh, uint32_t u32CardDetSrc);
|
||||
uint32_t SDH_Probe(SDH_T *sdh);
|
||||
uint32_t SDH_Read(SDH_T *sdh, uint8_t *pu8BufAddr, uint32_t u32StartSec, uint32_t u32SecCount);
|
||||
uint32_t SDH_Write(SDH_T *sdh, uint8_t *pu8BufAddr, uint32_t u32StartSec, uint32_t u32SecCount);
|
||||
|
||||
uint32_t SDH_CardDetection(SDH_T *sdh);
|
||||
void SDH_Open_Disk(SDH_T *sdh, uint32_t u32CardDetSrc);
|
||||
void SDH_Close_Disk(SDH_T *sdh);
|
||||
void SDH_Open(SDH_T *sdh, SDH_INFO_T *pSD, uint32_t u32CardDetSrc);
|
||||
uint32_t SDH_Probe(SDH_T *sdh, SDH_INFO_T *pSD, uint32_t card_num);
|
||||
uint32_t SDH_Read(SDH_T *sdh, SDH_INFO_T *pSD, uint8_t *pu8BufAddr, uint32_t u32StartSec, uint32_t u32SecCount);
|
||||
uint32_t SDH_Write(SDH_T *sdh, SDH_INFO_T *pSD, uint8_t *pu8BufAddr, uint32_t u32StartSec, uint32_t u32SecCount);
|
||||
void SDH_CardSelect(SDH_T *sdh, SDH_INFO_T *pSD, uint32_t u32CardSrc);
|
||||
uint32_t SDH_CardDetection(SDH_T *sdh, SDH_INFO_T *pSD, uint32_t card_num);
|
||||
void SDH_Open_Disk(SDH_T *sdh, SDH_INFO_T *pSD, uint32_t u32CardDetSrc);
|
||||
void SDH_Close_Disk(SDH_T *sdh, SDH_INFO_T *pSD);
|
||||
uint32_t SDH_WhichCardIsSelected(SDH_T *sdh);
|
||||
|
||||
|
||||
/*@}*/ /* end of group N9H30_SDH_EXPORTED_FUNCTIONS */
|
||||
|
||||
File diff suppressed because it is too large.
Load diff
@@ -297,6 +297,8 @@ static int ehci_init(void)
|
||||
_ehci->UCFGR = 0x1; /* enable port routing to EHCI */
|
||||
_ehci->UIENR = HSUSBH_UIENR_USBIEN_Msk | HSUSBH_UIENR_UERRIEN_Msk | HSUSBH_UIENR_HSERREN_Msk | HSUSBH_UIENR_IAAEN_Msk;
|
||||
|
||||
_ehci->UASSTR = 0xfff;
|
||||
|
||||
usbh_delay_ms(1); /* delay 1 ms */
|
||||
|
||||
_ehci->UPSCR[0] = HSUSBH_UPSCR_PP_Msk; /* enable port 1 port power */
|
||||
@@ -905,7 +907,7 @@ static int visit_qtd(qTD_T *qtd)
|
||||
return 0;
|
||||
}
|
||||
|
||||
static void scan_asynchronous_list()
|
||||
void scan_asynchronous_list()
|
||||
{
|
||||
QH_T *qh, *qh_tmp;
|
||||
qTD_T *q_pre, *qtd, *qtd_tmp;
|
||||
@@ -1094,9 +1096,8 @@ void iaad_remove_qh()
|
||||
//void EHCI_IRQHandler(void)
|
||||
void nu_ehci_isr(int vector, void *param)
|
||||
{
|
||||
uint32_t intsts;
|
||||
volatile uint32_t intsts = _ehci->USTSR;
|
||||
|
||||
intsts = _ehci->USTSR;
|
||||
_ehci->USTSR = intsts; /* clear interrupt status */
|
||||
|
||||
//USB_debug("ehci int_sts = 0x%x\n", intsts);
|
||||
|
||||
File diff suppressed because it is too large.
Load diff
@@ -67,7 +67,7 @@ void usbh_core_init()
|
||||
#ifdef ENABLE_OHCI
|
||||
//sysInstallISR(IRQ_LEVEL_1, IRQ_OHCI, (PVOID)OHCI_IRQHandler);
|
||||
rt_hw_interrupt_install(IRQ_OHCI, nu_ohci_isr, NULL, "ohci");
|
||||
rt_hw_interrupt_set_priority(IRQ_OHCI, IRQ_LEVEL_1);
|
||||
//rt_hw_interrupt_set_priority(IRQ_OHCI, IRQ_LEVEL_1);
|
||||
|
||||
ohci_driver.init();
|
||||
ENABLE_OHCI_IRQ();
|
||||
@@ -76,7 +76,7 @@ void usbh_core_init()
|
||||
#ifdef ENABLE_EHCI
|
||||
//sysInstallISR(IRQ_LEVEL_1, IRQ_EHCI, (PVOID)EHCI_IRQHandler);
|
||||
rt_hw_interrupt_install(IRQ_EHCI, nu_ehci_isr, NULL, "ehci");
|
||||
rt_hw_interrupt_set_priority(IRQ_EHCI, IRQ_LEVEL_1);
|
||||
//rt_hw_interrupt_set_priority(IRQ_EHCI, IRQ_LEVEL_1);
|
||||
|
||||
ehci_driver.init();
|
||||
ENABLE_EHCI_IRQ();
|
||||
|
||||
@@ -275,11 +275,15 @@ config SOC_SERIES_N9H30
|
||||
select RT_USING_DFS
|
||||
|
||||
if BSP_USING_SDH
|
||||
|
||||
config BSP_USING_EMMC
|
||||
bool "Enable FMI_EMMC"
|
||||
|
||||
config BSP_USING_SDH0
|
||||
bool "Enable SDH0"
|
||||
bool "Enable SDH_PORT0"
|
||||
|
||||
config BSP_USING_SDH1
|
||||
bool "Enable SDH1"
|
||||
bool "Enable SDH_PORT1"
|
||||
|
||||
config NU_SDH_HOTPLUG
|
||||
bool "Using HOTPLUG"
|
||||
|
||||
@@ -12,7 +12,7 @@
|
||||
#include <drv_sys.h>
|
||||
|
||||
//#define DEBUG
|
||||
//#define DEF_COND_WAIT 1
|
||||
#define DEF_COND_WAIT 1
|
||||
|
||||
static unsigned int GFX_BPP;
|
||||
static unsigned int GFX_WIDTH;
|
||||
|
||||
@@ -244,6 +244,11 @@ static rt_err_t nu_i2s_dai_setup(nu_i2s_t psNuI2s, struct rt_audio_configure *pc
|
||||
i2sIoctl(I2S_SET_I2S_FORMAT, I2S_FORMAT_I2S, 0);
|
||||
|
||||
if (psNuI2s->AcodecOps->role == NU_ACODEC_ROLE_MASTER)
|
||||
{
|
||||
// Set as slave, source clock is XIN (12MHz)
|
||||
i2sIoctl(I2S_SET_MODE, I2S_MODE_SLAVE, 0);
|
||||
}
|
||||
else
|
||||
{
|
||||
if (pconfig->samplerate % 11025)
|
||||
{
|
||||
@@ -284,11 +289,6 @@ static rt_err_t nu_i2s_dai_setup(nu_i2s_t psNuI2s, struct rt_audio_configure *pc
|
||||
// Set as master
|
||||
i2sIoctl(I2S_SET_MODE, I2S_MODE_MASTER, 0);
|
||||
}
|
||||
else
|
||||
{
|
||||
// Set as slave, source clock is XIN (12MHz)
|
||||
i2sIoctl(I2S_SET_MODE, I2S_MODE_SLAVE, 0);
|
||||
}
|
||||
|
||||
LOG_I("Open I2S.");
|
||||
|
||||
|
||||
File diff suppressed because it is too large.
Load diff
@@ -48,19 +48,23 @@ void rt_interrupt_dispatch(rt_uint32_t fiq_irq)
|
||||
/* Get irq number */
|
||||
_mIPER = (inpw(REG_AIC_IPER) >> 2) & 0x3f;
|
||||
_mISNR = inpw(REG_AIC_ISNR) & 0x3f;
|
||||
if ((_mIPER != _mISNR) || _mISNR == 0)
|
||||
return;
|
||||
|
||||
/* Get interrupt service routine */
|
||||
isr_func = irq_desc[_mISNR].handler;
|
||||
param = irq_desc[_mISNR].param;
|
||||
if (_mISNR != 0)
|
||||
{
|
||||
if (_mIPER == _mISNR)
|
||||
{
|
||||
/* Get interrupt service routine */
|
||||
isr_func = irq_desc[_mISNR].handler;
|
||||
param = irq_desc[_mISNR].param;
|
||||
|
||||
#ifdef RT_USING_INTERRUPT_INFO
|
||||
irq_desc[_mISNR].counter ++;
|
||||
irq_desc[_mISNR].counter ++;
|
||||
#endif
|
||||
|
||||
/* Turn to interrupt service routine */
|
||||
isr_func(_mISNR, param);
|
||||
/* Turn to interrupt service routine */
|
||||
isr_func(_mISNR, param);
|
||||
}
|
||||
}
|
||||
|
||||
/* Handled the ISR. */
|
||||
outpw(REG_AIC_EOSCR, 1);
|
||||
|
||||
File diff suppressed because it is too large.
Load diff
@@ -40,7 +40,7 @@ static rt_err_t nau8822_mixer_query(rt_uint32_t ui32Units, rt_uint32_t *ui32Valu
|
||||
nu_acodec_ops nu_acodec_ops_nau8822 =
|
||||
{
|
||||
.name = "NAU8822",
|
||||
.role = NU_ACODEC_ROLE_SLAVE,
|
||||
.role = NU_ACODEC_ROLE_MASTER,
|
||||
.config = { // Default settings.
|
||||
.samplerate = 16000,
|
||||
.channels = 2,
|
||||
@@ -117,6 +117,20 @@ static int I2C_WriteNAU8822(uint8_t u8addr, uint16_t u16data)
|
||||
return RT_EOK;
|
||||
}
|
||||
|
||||
static void nau8822_phonejack_set(S_NU_NAU8822_CONFIG *psCodecConfig, int bEnable)
|
||||
{
|
||||
rt_pin_mode(psCodecConfig->pin_phonejack_en, PIN_MODE_OUTPUT);
|
||||
|
||||
if (bEnable)
|
||||
{
|
||||
rt_pin_write(psCodecConfig->pin_phonejack_en, PIN_LOW);
|
||||
}
|
||||
else
|
||||
{
|
||||
rt_pin_write(psCodecConfig->pin_phonejack_en, PIN_HIGH);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
static rt_err_t nau8822_probe(void)
|
||||
{
|
||||
@@ -180,8 +194,6 @@ static rt_err_t nau8822_dsp_config(rt_uint32_t ui32SamplRate, rt_uint8_t u8ChNum
|
||||
}
|
||||
u16AudIf = (u16AudIf & 0x19F) | (u8WLEN << 5);
|
||||
|
||||
I2C_WriteNAU8822(4, u16AudIf);
|
||||
|
||||
if (ui32SamplRate % 11025)
|
||||
{
|
||||
I2C_WriteNAU8822(36, 0x008); //12.288Mhz
|
||||
@@ -189,6 +201,10 @@ static rt_err_t nau8822_dsp_config(rt_uint32_t ui32SamplRate, rt_uint8_t u8ChNum
|
||||
I2C_WriteNAU8822(38, 0x093);
|
||||
I2C_WriteNAU8822(39, 0x0E9);
|
||||
|
||||
/* FIXME */
|
||||
if (ui32SamplRate > 48000)
|
||||
ui32SamplRate = 8000;
|
||||
|
||||
mClkDiv = (48000 * 256 * u8ChNum) / (ui32SamplRate * 256);
|
||||
bClkDiv = (ui32SamplRate * 256) / (ui32SamplRate * u8ChNum * u8SamplBit);
|
||||
}
|
||||
@@ -199,6 +215,10 @@ static rt_err_t nau8822_dsp_config(rt_uint32_t ui32SamplRate, rt_uint8_t u8ChNum
|
||||
I2C_WriteNAU8822(38, 0x161);
|
||||
I2C_WriteNAU8822(39, 0x026);
|
||||
|
||||
/* FIXME */
|
||||
if (ui32SamplRate > 44100)
|
||||
ui32SamplRate = 11025;
|
||||
|
||||
mClkDiv = (44100 * 256 * u8ChNum) / (ui32SamplRate * 256);
|
||||
bClkDiv = (ui32SamplRate * 256) / (ui32SamplRate * u8ChNum * u8SamplBit);
|
||||
}
|
||||
@@ -258,11 +278,16 @@ static rt_err_t nau8822_dsp_config(rt_uint32_t ui32SamplRate, rt_uint8_t u8ChNum
|
||||
return -RT_ERROR;
|
||||
}
|
||||
|
||||
u16ClkCtrl = (1 << 8) | (1 << 0); //Use internal PLL, FS/BCLK
|
||||
if (nu_acodec_ops_nau8822.role == NU_ACODEC_ROLE_MASTER)
|
||||
{
|
||||
u16ClkCtrl = (1 << 8) | (1 << 0); //Use internal PLL, FS/BCLK
|
||||
}
|
||||
|
||||
u16ClkCtrl = (u16ClkCtrl & 0x11F) | (mClkDiv << 5);
|
||||
u16ClkCtrl = (u16ClkCtrl & 0x1E3) | (bClkDiv << 2);
|
||||
|
||||
I2C_WriteNAU8822(4, u16AudIf);
|
||||
|
||||
I2C_WriteNAU8822(6, u16ClkCtrl);
|
||||
|
||||
return RT_EOK;
|
||||
@@ -271,28 +296,36 @@ static rt_err_t nau8822_dsp_config(rt_uint32_t ui32SamplRate, rt_uint8_t u8ChNum
|
||||
static rt_err_t nau8822_init(void)
|
||||
{
|
||||
//input source is MIC
|
||||
I2C_WriteNAU8822(1, 0x03F);
|
||||
if (nu_acodec_ops_nau8822.role == NU_ACODEC_ROLE_MASTER)
|
||||
{
|
||||
I2C_WriteNAU8822(1, 0x03F); /* PLLEN, MICBIASEN, ABIASEN, IOBUFEN, REFIMP(3kohm) */
|
||||
}
|
||||
else
|
||||
{
|
||||
I2C_WriteNAU8822(1, 0x01F); /* MICBIASEN, ABIASEN, IOBUFEN, REFIMP(3kohm) */
|
||||
}
|
||||
|
||||
I2C_WriteNAU8822(2, 0x1BF); /* Enable L/R Headphone, ADC Mix/Boost, ADC */
|
||||
I2C_WriteNAU8822(3, 0x07F); /* Enable L/R main mixer, DAC */
|
||||
I2C_WriteNAU8822(4, 0x010); /* 16-bit word length, I2S format, Stereo */
|
||||
I2C_WriteNAU8822(5, 0x000); /* Companding control and loop back mode (all disable) */
|
||||
nau8822_delay_ms(30);
|
||||
|
||||
if (nu_acodec_ops_nau8822.role == NU_ACODEC_ROLE_SLAVE)
|
||||
{
|
||||
I2C_WriteNAU8822(6, 0x1AD); /* Divide by 6, 16K */
|
||||
I2C_WriteNAU8822(7, 0x006); /* 16K for internal filter coefficients */
|
||||
}
|
||||
|
||||
I2C_WriteNAU8822(6, 0x1AD); /* Divide by 6, 16K */
|
||||
I2C_WriteNAU8822(7, 0x006); /* 16K for internal filter coefficients */
|
||||
I2C_WriteNAU8822(10, 0x008); /* DAC soft mute is disabled, DAC oversampling rate is 128x */
|
||||
I2C_WriteNAU8822(14, 0x108); /* ADC HP filter is disabled, ADC oversampling rate is 128x */
|
||||
I2C_WriteNAU8822(15, 0x1EF); /* ADC left digital volume control */
|
||||
I2C_WriteNAU8822(16, 0x1EF); /* ADC right digital volume control */
|
||||
I2C_WriteNAU8822(44, 0x033); /* LMICN/LMICP is connected to PGA */
|
||||
I2C_WriteNAU8822(49, 0x042);
|
||||
I2C_WriteNAU8822(47, 0x100); /* Gain value */
|
||||
I2C_WriteNAU8822(48, 0x100); /* Gain value */
|
||||
I2C_WriteNAU8822(50, 0x001); /* Left DAC connected to LMIX */
|
||||
I2C_WriteNAU8822(51, 0x001); /* Right DAC connected to RMIX */
|
||||
|
||||
I2C_WriteNAU8822(0x34, 0x13F);
|
||||
I2C_WriteNAU8822(0x35, 0x13F);
|
||||
|
||||
nu_acodec_ops_nau8822.config.samplerate = 16000;
|
||||
nu_acodec_ops_nau8822.config.channels = 2;
|
||||
nu_acodec_ops_nau8822.config.samplebits = 16;
|
||||
@@ -326,10 +359,12 @@ static rt_err_t nau8822_mixer_control(rt_uint32_t ui32Units, rt_uint32_t ui32Val
|
||||
if (ui32Value)
|
||||
{
|
||||
I2C_WriteNAU8822(10, u16Data | (1 << 6));
|
||||
nau8822_phonejack_set(g_psCodecConfig, 0);
|
||||
}
|
||||
else
|
||||
{
|
||||
I2C_WriteNAU8822(10, u16Data & ~(1 << 6));
|
||||
nau8822_phonejack_set(g_psCodecConfig, 1);
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
||||
@@ -14,6 +14,7 @@
|
||||
|
||||
#if defined(NU_PKG_USING_BMX055)
|
||||
|
||||
#include <sys/time.h>
|
||||
#include <string.h>
|
||||
#include "sensor_bmx055.h"
|
||||
|
||||
|
||||
@@ -29,6 +29,11 @@ menu "Nuvoton Packages Config"
|
||||
select BSP_USING_I2C
|
||||
default n
|
||||
|
||||
config NU_PKG_USING_DA9062
|
||||
bool "DA9062 PMIC."
|
||||
select BSP_USING_I2C
|
||||
default n
|
||||
|
||||
config NU_PKG_USING_ILI9341
|
||||
bool "ILI9341 LCD Panel"
|
||||
select BSP_USING_GPIO
|
||||
|
||||
@@ -14,6 +14,7 @@
|
||||
|
||||
#if defined(NU_PKG_USING_MAX31875)
|
||||
|
||||
#include <sys/time.h>
|
||||
#include "sensor.h"
|
||||
#include "max31875_c.h"
|
||||
|
||||
|
||||
@@ -498,7 +498,8 @@ rt_err_t rt_hw_mtd_spinand_init(void)
|
||||
RT_ASSERT(result == RT_EOK);
|
||||
|
||||
result = spinand_flash_init(SPINAND_FLASH_QSPI);
|
||||
RT_ASSERT(result == RT_EOK);
|
||||
if (result != RT_EOK)
|
||||
return -RT_ERROR;
|
||||
|
||||
for (i = 0; i < MTD_SPINAND_PARTITION_NUM; i++)
|
||||
{
|
||||
|
||||
@@ -26,7 +26,48 @@
|
||||
const struct nu_spinand_info g_spinandflash_list[] =
|
||||
{
|
||||
/* Winbond */
|
||||
{ 0xEFAA21, 2048, 64, 0x6b, 0xff, 0xff, 0xff, 0x1, 1024, 64, 0, "Winbond 128MB: 2048+64@64@1024" }, /* Only tested */
|
||||
/* Only tested */
|
||||
{
|
||||
0xEFAA21, 2048, 64, 0x6b, 0xff, 0xff, 0xff, 0x1, 1024, 64, 0, "Winbond 128MB: 2048+64@64@1024",
|
||||
#if defined(RT_USING_DFS_UFFS)
|
||||
{
|
||||
/* For storing Seal-byte at 0x37. Need 15-Bytes */
|
||||
0x04, 0x04, 0x14, 0x04, 0x24, 0x04, 0x34, 0x03, 0xFF, 0x00
|
||||
},
|
||||
{
|
||||
/* For storing Seal-byte at 0x37 and not report latest ECC part in Spare-3 */
|
||||
0x08, 0x08, 0x18, 0x08, 0x28, 0x08, /*0x38, 0x08,*/ 0xFF, 0x00
|
||||
}
|
||||
#else
|
||||
{
|
||||
0x04, 0x04, 0x14, 0x04, 0x24, 0x04, 0x34, 0x04, 0xFF, 0x00
|
||||
},
|
||||
{
|
||||
0x08, 0x08, 0x18, 0x08, 0x28, 0x08, 0x38, 0x08, 0xFF, 0x00
|
||||
}
|
||||
#endif
|
||||
},
|
||||
|
||||
{
|
||||
0xEFBF22, 2048, 64, 0x6b, 0xff, 0xff, 0xff, 0x1, 2048, 64, 0, "Winbond 256MB: 2048+64@64@2048",
|
||||
#if defined(RT_USING_DFS_UFFS)
|
||||
{
|
||||
/* For storing Seal-byte at 0x39. Need 15-Bytes */
|
||||
0x08, 0x04, 0x18, 0x04, 0x28, 0x04, 0x38, 0x03, 0xFF, 0x00
|
||||
},
|
||||
{
|
||||
/* For storing Seal-byte at 0x39 and not report latest ECC part in Spare-3 */
|
||||
0x0C, 0x04, 0x1C, 0x04, 0x2C, 0x04, /*0x3C, 0x04,*/ 0xFF, 0x00
|
||||
}
|
||||
#else
|
||||
{
|
||||
0x08, 0x04, 0x18, 0x04, 0x28, 0x04, 0x38, 0x04, 0xFF, 0x00
|
||||
},
|
||||
{
|
||||
0x0C, 0x04, 0x1C, 0x04, 0x2C, 0x04, 0x3C, 0x04, 0xFF, 0x00
|
||||
}
|
||||
#endif
|
||||
},
|
||||
|
||||
#if 0
|
||||
{ 0xEFAA22, 2048, 64, 0x6b, 0xff, 0xff, 0xff, 0x1, 2048, 64, 0, "Winbond 256MB: 2048+64@64@1024" },
|
||||
@@ -61,6 +102,7 @@ const struct nu_spinand_info g_spinandflash_list[] =
|
||||
|
||||
|
||||
/*
|
||||
========================================================
|
||||
For 0xEFAA21 description:
|
||||
|
||||
Data Area(2048-Byte)
|
||||
@@ -112,27 +154,66 @@ ECC Spare: ECC for spare 4-D.
|
||||
| 0 1 2 3 | 4 5 6 7 | 8 9 A B C D | E F |
|
||||
-----------------------------------------------
|
||||
| NO ECC | ECC PROTECTED | ECC 34-3D |
|
||||
|
||||
========================================================
|
||||
|
||||
========================================================
|
||||
For 0xEFBF22 description:
|
||||
|
||||
Data Area(2048-Byte)
|
||||
-----------------------------
|
||||
|Sect-0|Sect-1|Sect-2|Sect-3|
|
||||
|(512B)|(512B)|(512B)|(512B)|
|
||||
-----------------------------
|
||||
|
||||
Spare Area(64-Byte)
|
||||
---------------------------------
|
||||
|Spare-0|Spare-1|Spare-2|Spare-3|
|
||||
| (16B) | (16B) | (16B) | (16B) |
|
||||
---------------------------------
|
||||
|
||||
----------------- Spare-0 -------------------
|
||||
/ \
|
||||
-----------------------------------------
|
||||
| BBM | UD2 | UD1 | ECC UD1 |
|
||||
| 0 1 | 2 3 4 5 6 7 | 8 9 A B | C D E F |
|
||||
-----------------------------------------
|
||||
| NO ECC | ECC PROTECTED |
|
||||
|
||||
BBM: Bad block marker.
|
||||
UD1: User Data 1.
|
||||
UD2: User Data 2.
|
||||
ECC UD1: ECC for UD1.
|
||||
|
||||
---------------- Spare-1 -------------------
|
||||
/ \
|
||||
---------------------------------------
|
||||
| UD2 | UD1 | ECC UD1 |
|
||||
| 0 1 2 3 4 5 6 7 | 8 9 A B | C D E F |
|
||||
---------------------------------------
|
||||
| NO ECC | ECC PROTECTED |
|
||||
|
||||
---------------- Spare-2 -------------------
|
||||
/ \
|
||||
---------------------------------------
|
||||
| UD2 | UD1 | ECC UD1 |
|
||||
| 0 1 2 3 4 5 6 7 | 8 9 A B | C D E F |
|
||||
---------------------------------------
|
||||
| NO ECC | ECC PROTECTED |
|
||||
|
||||
---------------- Spare-3 -------------------
|
||||
/ \
|
||||
---------------------------------------
|
||||
| UD2 | UD1 | ECC UD1 |
|
||||
| 0 1 2 3 4 5 6 7 | 8 9 A B | C D E F |
|
||||
---------------------------------------
|
||||
| NO ECC | ECC PROTECTED |
|
||||
|
||||
========================================================
|
||||
*/
|
||||
|
||||
rt_uint8_t spinand_flash_data_layout[SPINAND_SPARE_LAYOUT_SIZE] =
|
||||
{
|
||||
#if defined(RT_USING_DFS_UFFS)
|
||||
/* For storing Seal-byte at 0x37. */
|
||||
0x04, 0x04, 0x14, 0x04, 0x24, 0x04, 0x34, 0x03, 0xFF, 0x00
|
||||
#else
|
||||
0x04, 0x04, 0x14, 0x04, 0x24, 0x04, 0x34, 0x04, 0xFF, 0x00
|
||||
#endif
|
||||
};
|
||||
|
||||
rt_uint8_t spinand_flash_ecc_layout[SPINAND_SPARE_LAYOUT_SIZE] =
|
||||
{
|
||||
#if defined(RT_USING_DFS_UFFS)
|
||||
/* For storing Seal-byte at 0x37 and not report latest ECC part in Spare-3 */
|
||||
0x08, 0x08, 0x18, 0x08, 0x28, 0x08, /*0x38, 0x08,*/ 0xFF, 0x00
|
||||
#else
|
||||
0x08, 0x08, 0x18, 0x08, 0x28, 0x08, 0x38, 0x08, 0xFF, 0x00
|
||||
#endif
|
||||
};
|
||||
rt_uint8_t spinand_flash_data_layout[SPINAND_SPARE_LAYOUT_SIZE];
|
||||
rt_uint8_t spinand_flash_ecc_layout[SPINAND_SPARE_LAYOUT_SIZE];
|
||||
|
||||
static rt_err_t spinand_info_read(struct rt_qspi_device *qspi);
|
||||
|
||||
@@ -186,7 +267,6 @@ static rt_err_t spinand_program_dataload(
|
||||
uint8_t *pu8SpareBuff,
|
||||
uint32_t u32SpareCount)
|
||||
{
|
||||
uint32_t volatile i = 0;
|
||||
uint8_t u8WECmd = 0x06;
|
||||
rt_err_t result = RT_EOK;
|
||||
|
||||
@@ -667,6 +747,9 @@ static rt_err_t spinand_info_read(struct rt_qspi_device *qspi)
|
||||
{
|
||||
if (u32JedecId == g_spinandflash_list[i].u32JEDECID) /* Match JEDECID? */
|
||||
{
|
||||
rt_memcpy((void *)&spinand_flash_data_layout[0], (void *)&g_spinandflash_list[i].au8DataLayout[0], SPINAND_SPARE_LAYOUT_SIZE);
|
||||
rt_memcpy((void *)&spinand_flash_ecc_layout[0], (void *)&g_spinandflash_list[i].au8EccLayout[0], SPINAND_SPARE_LAYOUT_SIZE);
|
||||
|
||||
rt_memcpy(SPINAND_FLASH_INFO, &g_spinandflash_list[i], sizeof(struct nu_spinand_info));
|
||||
LOG_I("Found: [%08X] %s.", u32JedecId, SPINAND_FLASH_DESCRIPTION);
|
||||
|
||||
|
||||
@@ -19,24 +19,6 @@
|
||||
#include "drv_spi.h"
|
||||
#include <board.h>
|
||||
|
||||
/* SPI NAND flash information */
|
||||
struct nu_spinand_info
|
||||
{
|
||||
uint32_t u32JEDECID;
|
||||
uint16_t u16PageSize;
|
||||
uint16_t u16OOBSize;
|
||||
uint8_t u8QuadReadCmdId;
|
||||
uint8_t u8ReadStatusCmdId;
|
||||
uint8_t u8WriteStatusCmdid;
|
||||
uint8_t u8StatusValue;
|
||||
uint8_t u8DummyByte;
|
||||
uint32_t u32BlockPerFlash;
|
||||
uint32_t u32PagePerBlock;
|
||||
uint8_t u8IsDieSelect;
|
||||
const char *szDescription;
|
||||
};
|
||||
typedef struct nu_spinand_info *nu_spinand_info_t;
|
||||
|
||||
struct spinand_ops
|
||||
{
|
||||
rt_err_t (*block_erase)(struct rt_qspi_device *qspi, uint8_t u8Addr2, uint8_t u8Addr1, uint8_t u8Addr0);
|
||||
@@ -53,15 +35,6 @@ struct spinand_ops
|
||||
};
|
||||
typedef struct spinand_ops *nu_spinand_ops_t;
|
||||
|
||||
struct nu_spinand
|
||||
{
|
||||
struct nu_spinand_info info;
|
||||
struct rt_qspi_device *qspi_device;
|
||||
nu_spinand_ops_t ops;
|
||||
struct rt_mutex lock;
|
||||
};
|
||||
typedef struct nu_spinand *nu_spinand_t;
|
||||
|
||||
#define SPINAND_FLASH_JEDECID g_spinandflash_dev.info.u32JEDECID
|
||||
#define SPINAND_FLASH_PAGE_SIZE g_spinandflash_dev.info.u16PageSize
|
||||
#define SPINAND_FLASH_OOB_SIZE g_spinandflash_dev.info.u16OOBSize
|
||||
@@ -82,6 +55,36 @@ typedef struct nu_spinand *nu_spinand_t;
|
||||
|
||||
#define SPINAND_SPARE_LAYOUT_SIZE 16
|
||||
|
||||
/* SPI NAND flash information */
|
||||
struct nu_spinand_info
|
||||
{
|
||||
uint32_t u32JEDECID;
|
||||
uint16_t u16PageSize;
|
||||
uint16_t u16OOBSize;
|
||||
uint8_t u8QuadReadCmdId;
|
||||
uint8_t u8ReadStatusCmdId;
|
||||
uint8_t u8WriteStatusCmdid;
|
||||
uint8_t u8StatusValue;
|
||||
uint8_t u8DummyByte;
|
||||
uint32_t u32BlockPerFlash;
|
||||
uint32_t u32PagePerBlock;
|
||||
uint8_t u8IsDieSelect;
|
||||
const char *szDescription;
|
||||
|
||||
uint8_t au8DataLayout[SPINAND_SPARE_LAYOUT_SIZE];
|
||||
uint8_t au8EccLayout[SPINAND_SPARE_LAYOUT_SIZE];
|
||||
};
|
||||
typedef struct nu_spinand_info *nu_spinand_info_t;
|
||||
|
||||
struct nu_spinand
|
||||
{
|
||||
struct nu_spinand_info info;
|
||||
struct rt_qspi_device *qspi_device;
|
||||
nu_spinand_ops_t ops;
|
||||
struct rt_mutex lock;
|
||||
};
|
||||
typedef struct nu_spinand *nu_spinand_t;
|
||||
|
||||
rt_err_t rt_hw_mtd_spinand_register(const char *device_name);
|
||||
rt_size_t nu_qspi_transfer_message(struct rt_qspi_device *device, struct rt_qspi_message *message);
|
||||
rt_err_t nu_qspi_send_then_recv(struct rt_qspi_device *device, const void *send_buf, rt_size_t send_length, void *recv_buf, rt_size_t recv_length);
|
||||
|
||||
@@ -30,8 +30,8 @@ extern "C"
|
||||
*/
|
||||
|
||||
#define EMAC_PHY_ADDR 1UL /*!< PHY address, this address is board dependent \hideinitializer */
|
||||
#define EMAC_RX_DESC_SIZE 64UL /*!< Number of Rx Descriptors, should be 2 at least \hideinitializer */
|
||||
#define EMAC_TX_DESC_SIZE 32UL /*!< Number of Tx Descriptors, should be 2 at least \hideinitializer */
|
||||
#define EMAC_RX_DESC_SIZE 128UL /*!< Number of Rx Descriptors, should be 2 at least \hideinitializer */
|
||||
#define EMAC_TX_DESC_SIZE 64UL /*!< Number of Tx Descriptors, should be 2 at least \hideinitializer */
|
||||
#define EMAC_CAMENTRY_NB 16UL /*!< Number of CAM \hideinitializer */
|
||||
#define EMAC_MAX_PKT_SIZE 1536UL /*!< Number of HDR + EXTRA + VLAN_TAG + PAYLOAD + CRC \hideinitializer */
|
||||
|
||||
@@ -53,6 +53,8 @@ typedef struct
|
||||
uint32_t u32Next; /*!< Pointer to next descriptor */
|
||||
uint32_t u32Backup1; /*!< For backup descriptor fields over written by time stamp */
|
||||
uint32_t u32Backup2; /*!< For backup descriptor fields over written by time stamp */
|
||||
uint32_t u32Reserved1; /*!< For Reserved */
|
||||
uint32_t u32Reserved2; /*!< For Reserved */
|
||||
} EMAC_DESCRIPTOR_T;
|
||||
|
||||
/** Tx/Rx buffer structure */
|
||||
@@ -379,7 +381,8 @@ int32_t EMAC_FillCamEntry(EMAC_T *EMAC, uint8_t pu8MacAddr[]);
|
||||
uint8_t *EMAC_ClaimFreeTXBuf(EMAC_MEMMGR_T *psMemMgr);
|
||||
uint32_t EMAC_GetAvailRXBufSize(EMAC_MEMMGR_T *psMemMgr, uint8_t **ppuDataBuf);
|
||||
uint32_t EMAC_SendPktWoCopy(EMAC_MEMMGR_T *psMemMgr, uint32_t u32Size);
|
||||
void EMAC_RecvPktDoneWoRxTrigger(EMAC_MEMMGR_T *psMemMgr);
|
||||
EMAC_DESCRIPTOR_T * EMAC_RecvPktDoneWoRxTrigger(EMAC_MEMMGR_T *psMemMgr);
|
||||
void EMAC_RxTrigger(EMAC_MEMMGR_T *psMemMgr, EMAC_DESCRIPTOR_T * rx_desc);
|
||||
|
||||
/*@}*/ /* end of group EMAC_EXPORTED_FUNCTIONS */
|
||||
|
||||
|
||||
@@ -298,7 +298,7 @@ static void EMAC_RxDescInit(EMAC_MEMMGR_T *psMemMgr)
|
||||
for (i = 0UL; i < psMemMgr->u32RxDescSize; i++)
|
||||
{
|
||||
psMemMgr->psRXDescs[i].u32Status1 = EMAC_DESC_OWN_EMAC;
|
||||
psMemMgr->psRXDescs[i].u32Data = (uint32_t)&psMemMgr->psRXFrames[i] | BIT31;
|
||||
psMemMgr->psRXDescs[i].u32Data = (uint32_t)&psMemMgr->psRXFrames[i];
|
||||
psMemMgr->psRXDescs[i].u32Status2 = 0UL;
|
||||
psMemMgr->psRXDescs[i].u32Next = (uint32_t)(&psMemMgr->psRXDescs[(i + 1UL) % EMAC_RX_DESC_SIZE]) | BIT31;
|
||||
psMemMgr->psRXDescs[i].u32Backup1 = psMemMgr->psRXDescs[i].u32Data;
|
||||
@@ -1129,25 +1129,37 @@ uint32_t EMAC_GetAvailRXBufSize(EMAC_MEMMGR_T *psMemMgr, uint8_t **ppuDataBuf)
|
||||
* @note Application can only call this function once every time \ref EMAC_RecvPkt or \ref EMAC_RecvPktTS returns 1
|
||||
* @note This function is without doing EMAC_TRIGGER_RX.
|
||||
*/
|
||||
void EMAC_RecvPktDoneWoRxTrigger(EMAC_MEMMGR_T *psMemMgr)
|
||||
EMAC_DESCRIPTOR_T * EMAC_RecvPktDoneWoRxTrigger(EMAC_MEMMGR_T *psMemMgr)
|
||||
{
|
||||
/* Get Rx Frame Descriptor */
|
||||
EMAC_DESCRIPTOR_T *desc = (EMAC_DESCRIPTOR_T *)psMemMgr->psCurrentRxDesc;
|
||||
EMAC_DESCRIPTOR_T *ret = desc;
|
||||
|
||||
/* Restore descriptor link list and data pointer they will be overwrite if time stamp enabled */
|
||||
desc->u32Data = desc->u32Backup1;
|
||||
desc->u32Next = desc->u32Backup2;
|
||||
|
||||
/* Change ownership to DMA for next use */
|
||||
desc->u32Status1 |= EMAC_DESC_OWN_EMAC;
|
||||
// desc->u32Status1 |= EMAC_DESC_OWN_EMAC;
|
||||
|
||||
/* Get Next Frame Descriptor pointer to process */
|
||||
desc = (EMAC_DESCRIPTOR_T *)desc->u32Next;
|
||||
|
||||
/* Save last processed Rx descriptor */
|
||||
psMemMgr->psCurrentRxDesc = desc;
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
void EMAC_RxTrigger(EMAC_MEMMGR_T *psMemMgr, EMAC_DESCRIPTOR_T * rx_desc)
|
||||
{
|
||||
EMAC_T *EMAC = psMemMgr->psEmac;
|
||||
|
||||
rx_desc->u32Status1 |= EMAC_DESC_OWN_EMAC;
|
||||
|
||||
/* Trigger EMAC to send the packet */
|
||||
EMAC_TRIGGER_RX(EMAC);
|
||||
}
|
||||
|
||||
/*@}*/ /* end of group EMAC_EXPORTED_FUNCTIONS */
|
||||
|
||||
|
||||
@@ -8,9 +8,6 @@
|
||||
#include "nuc980.h"
|
||||
#include "nu_pdma.h"
|
||||
|
||||
|
||||
static uint8_t u32ChSelect[PDMA_CH_MAX];
|
||||
|
||||
/** @addtogroup Standard_Driver Standard Driver
|
||||
@{
|
||||
*/
|
||||
@@ -44,7 +41,6 @@ void PDMA_Open(PDMA_T *pdma, uint32_t u32Mask)
|
||||
if ((1 << i) & u32Mask)
|
||||
{
|
||||
pdma->DSCT[i].CTL = 0UL;
|
||||
u32ChSelect[i] = PDMA_MEM;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -188,54 +184,27 @@ void PDMA_SetTransferAddr(PDMA_T *pdma, uint32_t u32Ch, uint32_t u32SrcAddr, uin
|
||||
*/
|
||||
void PDMA_SetTransferMode(PDMA_T *pdma, uint32_t u32Ch, uint32_t u32Peripheral, uint32_t u32ScatterEn, uint32_t u32DescAddr)
|
||||
{
|
||||
u32ChSelect[u32Ch] = u32Peripheral;
|
||||
switch (u32Ch)
|
||||
if (u32Ch < PDMA_CH_MAX)
|
||||
{
|
||||
case 0ul:
|
||||
pdma->REQSEL0_3 = (pdma->REQSEL0_3 & ~PDMA_REQSEL0_3_REQSRC0_Msk) | u32Peripheral;
|
||||
break;
|
||||
case 1ul:
|
||||
pdma->REQSEL0_3 = (pdma->REQSEL0_3 & ~PDMA_REQSEL0_3_REQSRC1_Msk) | (u32Peripheral << PDMA_REQSEL0_3_REQSRC1_Pos);
|
||||
break;
|
||||
case 2ul:
|
||||
pdma->REQSEL0_3 = (pdma->REQSEL0_3 & ~PDMA_REQSEL0_3_REQSRC2_Msk) | (u32Peripheral << PDMA_REQSEL0_3_REQSRC2_Pos);
|
||||
break;
|
||||
case 3ul:
|
||||
pdma->REQSEL0_3 = (pdma->REQSEL0_3 & ~PDMA_REQSEL0_3_REQSRC3_Msk) | (u32Peripheral << PDMA_REQSEL0_3_REQSRC3_Pos);
|
||||
break;
|
||||
case 4ul:
|
||||
pdma->REQSEL4_7 = (pdma->REQSEL4_7 & ~PDMA_REQSEL4_7_REQSRC4_Msk) | u32Peripheral;
|
||||
break;
|
||||
case 5ul:
|
||||
pdma->REQSEL4_7 = (pdma->REQSEL4_7 & ~PDMA_REQSEL4_7_REQSRC5_Msk) | (u32Peripheral << PDMA_REQSEL4_7_REQSRC5_Pos);
|
||||
break;
|
||||
case 6ul:
|
||||
pdma->REQSEL4_7 = (pdma->REQSEL4_7 & ~PDMA_REQSEL4_7_REQSRC6_Msk) | (u32Peripheral << PDMA_REQSEL4_7_REQSRC6_Pos);
|
||||
break;
|
||||
case 7ul:
|
||||
pdma->REQSEL4_7 = (pdma->REQSEL4_7 & ~PDMA_REQSEL4_7_REQSRC7_Msk) | (u32Peripheral << PDMA_REQSEL4_7_REQSRC7_Pos);
|
||||
break;
|
||||
case 8ul:
|
||||
pdma->REQSEL8_11 = (pdma->REQSEL8_11 & ~PDMA_REQSEL8_11_REQSRC8_Msk) | u32Peripheral;
|
||||
break;
|
||||
case 9ul:
|
||||
pdma->REQSEL8_11 = (pdma->REQSEL8_11 & ~PDMA_REQSEL8_11_REQSRC9_Msk) | (u32Peripheral << PDMA_REQSEL8_11_REQSRC9_Pos);
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
__IO uint32_t *pau32REQSEL = (__IO uint32_t *)&pdma->REQSEL0_3;
|
||||
uint32_t u32REQSEL_Pos, u32REQSEL_Msk;
|
||||
|
||||
if (u32ScatterEn)
|
||||
{
|
||||
pdma->DSCT[u32Ch].CTL = (pdma->DSCT[u32Ch].CTL & ~PDMA_DSCT_CTL_OPMODE_Msk) | PDMA_OP_SCATTER;
|
||||
pdma->DSCT[u32Ch].NEXT = u32DescAddr - (pdma->SCATBA);
|
||||
}
|
||||
else
|
||||
{
|
||||
pdma->DSCT[u32Ch].CTL = (pdma->DSCT[u32Ch].CTL & ~PDMA_DSCT_CTL_OPMODE_Msk) | PDMA_OP_BASIC;
|
||||
u32REQSEL_Pos = (u32Ch % 4) * 8 ;
|
||||
u32REQSEL_Msk = PDMA_REQSEL0_3_REQSRC0_Msk << u32REQSEL_Pos;
|
||||
pau32REQSEL[u32Ch / 4] = (pau32REQSEL[u32Ch / 4] & ~u32REQSEL_Msk) | (u32Peripheral << u32REQSEL_Pos);
|
||||
|
||||
if (u32ScatterEn)
|
||||
{
|
||||
pdma->DSCT[u32Ch].CTL = (pdma->DSCT[u32Ch].CTL & ~PDMA_DSCT_CTL_OPMODE_Msk) | PDMA_OP_SCATTER;
|
||||
pdma->DSCT[u32Ch].NEXT = u32DescAddr - (pdma->SCATBA);
|
||||
}
|
||||
else
|
||||
{
|
||||
pdma->DSCT[u32Ch].CTL = (pdma->DSCT[u32Ch].CTL & ~PDMA_DSCT_CTL_OPMODE_Msk) | PDMA_OP_BASIC;
|
||||
}
|
||||
}
|
||||
else {}
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Set PDMA Burst Type and Size
|
||||
*
|
||||
@@ -310,45 +279,21 @@ void PDMA_DisableTimeout(PDMA_T *pdma, uint32_t u32Mask)
|
||||
*/
|
||||
void PDMA_SetTimeOut(PDMA_T *pdma, uint32_t u32Ch, uint32_t u32OnOff, uint32_t u32TimeOutCnt)
|
||||
{
|
||||
switch (u32Ch)
|
||||
if (u32Ch < PDMA_CH_MAX)
|
||||
{
|
||||
case 0ul:
|
||||
pdma->TOC0_1 = (pdma->TOC0_1 & ~PDMA_TOC0_1_TOC0_Msk) | u32TimeOutCnt;
|
||||
break;
|
||||
case 1ul:
|
||||
pdma->TOC0_1 = (pdma->TOC0_1 & ~PDMA_TOC0_1_TOC1_Msk) | (u32TimeOutCnt << PDMA_TOC0_1_TOC1_Pos);
|
||||
break;
|
||||
case 2ul:
|
||||
pdma->TOC2_3 = (pdma->TOC2_3 & ~PDMA_TOC2_3_TOC2_Msk) | u32TimeOutCnt;
|
||||
break;
|
||||
case 3ul:
|
||||
pdma->TOC2_3 = (pdma->TOC2_3 & ~PDMA_TOC2_3_TOC3_Msk) | (u32TimeOutCnt << PDMA_TOC0_1_TOC1_Pos);
|
||||
break;
|
||||
case 4ul:
|
||||
pdma->TOC4_5 = (pdma->TOC4_5 & ~PDMA_TOC4_5_TOC4_Msk) | u32TimeOutCnt;
|
||||
break;
|
||||
case 5ul:
|
||||
pdma->TOC4_5 = (pdma->TOC4_5 & ~PDMA_TOC4_5_TOC5_Msk) | (u32TimeOutCnt << PDMA_TOC4_5_TOC5_Pos);
|
||||
break;
|
||||
case 6ul:
|
||||
pdma->TOC6_7 = (pdma->TOC6_7 & ~PDMA_TOC6_7_TOC6_Msk) | u32TimeOutCnt;
|
||||
break;
|
||||
case 7ul:
|
||||
pdma->TOC6_7 = (pdma->TOC6_7 & ~PDMA_TOC6_7_TOC7_Msk) | (u32TimeOutCnt << PDMA_TOC6_7_TOC7_Pos);
|
||||
break;
|
||||
case 8ul:
|
||||
pdma->TOC8_9 = (pdma->TOC8_9 & ~PDMA_TOC8_9_TOC8_Msk) | u32TimeOutCnt;
|
||||
break;
|
||||
case 9ul:
|
||||
pdma->TOC8_9 = (pdma->TOC8_9 & ~PDMA_TOC8_9_TOC9_Msk) | (u32TimeOutCnt << PDMA_TOC8_9_TOC9_Pos);
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
__IO uint32_t *pau32TOC = (__IO uint32_t *)&pdma->TOC0_1;
|
||||
uint32_t u32TOC_Pos, u32TOC_Msk;
|
||||
|
||||
u32TOC_Pos = (u32Ch % 2) * 16 ;
|
||||
u32TOC_Msk = PDMA_TOC0_1_TOC0_Msk << u32TOC_Pos;
|
||||
pau32TOC[u32Ch / 2] = (pau32TOC[u32Ch / 2] & ~u32TOC_Msk) | (u32TimeOutCnt << u32TOC_Pos);
|
||||
|
||||
if (u32OnOff)
|
||||
pdma->TOUTEN |= (1 << u32Ch);
|
||||
else
|
||||
pdma->TOUTEN &= ~(1 << u32Ch);
|
||||
}
|
||||
if (u32OnOff)
|
||||
pdma->TOUTEN |= (1 << u32Ch);
|
||||
else
|
||||
pdma->TOUTEN &= ~(1 << u32Ch);
|
||||
else {}
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -363,7 +308,15 @@ void PDMA_SetTimeOut(PDMA_T *pdma, uint32_t u32Ch, uint32_t u32OnOff, uint32_t u
|
||||
*/
|
||||
void PDMA_Trigger(PDMA_T *pdma, uint32_t u32Ch)
|
||||
{
|
||||
if (u32ChSelect[u32Ch] == PDMA_MEM)
|
||||
__IO uint32_t *pau32REQSEL = (__IO uint32_t *)&pdma->REQSEL0_3;
|
||||
uint32_t u32REQSEL_Pos, u32REQSEL_Msk, u32ChReq;
|
||||
|
||||
u32REQSEL_Pos = (u32Ch % 4) * 8 ;
|
||||
u32REQSEL_Msk = PDMA_REQSEL0_3_REQSRC0_Msk << u32REQSEL_Pos;
|
||||
|
||||
u32ChReq = (pau32REQSEL[u32Ch / 4] & u32REQSEL_Msk) >> u32REQSEL_Pos;
|
||||
|
||||
if (u32ChReq == PDMA_MEM)
|
||||
{
|
||||
pdma->SWREQ = (1ul << u32Ch);
|
||||
}
|
||||
|
||||
@@ -33,7 +33,7 @@
|
||||
#define DISABLE_EHCI_IRQ() rt_hw_interrupt_mask(IRQ_EHCI)
|
||||
#define IS_EHCI_IRQ_ENABLED() ((inpw(REG_AIC_INTMSK0)>>IRQ_EHCI) & 0x1)
|
||||
|
||||
//#define ENABLE_OHCI /* Enable OHCI host controller */
|
||||
#define ENABLE_OHCI /* Enable OHCI host controller */
|
||||
#define ENABLE_EHCI /* Enable EHCI host controller */
|
||||
|
||||
#define EHCI_PORT_CNT 2 /* Number of EHCI roothub ports */
|
||||
@@ -50,7 +50,7 @@
|
||||
unconditionally reclaim iTD/isTD scheduled
|
||||
in just elapsed EHCI_ISO_RCLM_RANGE ms. */
|
||||
|
||||
#define MAX_DESC_BUFF_SIZE 1024 /* To hold the configuration descriptor, USB
|
||||
#define MAX_DESC_BUFF_SIZE 4096 /* To hold the configuration descriptor, USB
|
||||
core will allocate a buffer with this size
|
||||
for each connected device. USB core does
|
||||
not release it until device disconnected. */
|
||||
|
||||
@@ -297,6 +297,8 @@ static int ehci_init(void)
|
||||
_ehci->UCFGR = 0x1; /* enable port routing to EHCI */
|
||||
_ehci->UIENR = HSUSBH_UIENR_USBIEN_Msk | HSUSBH_UIENR_UERRIEN_Msk | HSUSBH_UIENR_HSERREN_Msk | HSUSBH_UIENR_IAAEN_Msk;
|
||||
|
||||
_ehci->UASSTR = 0xfff;
|
||||
|
||||
usbh_delay_ms(1); /* delay 1 ms */
|
||||
|
||||
_ehci->UPSCR[0] = HSUSBH_UPSCR_PP_Msk; /* enable port 1 port power */
|
||||
@@ -905,7 +907,7 @@ static int visit_qtd(qTD_T *qtd)
|
||||
return 0;
|
||||
}
|
||||
|
||||
static void scan_asynchronous_list()
|
||||
void scan_asynchronous_list()
|
||||
{
|
||||
QH_T *qh, *qh_tmp;
|
||||
qTD_T *q_pre, *qtd, *qtd_tmp;
|
||||
@@ -1094,9 +1096,8 @@ void iaad_remove_qh()
|
||||
//void EHCI_IRQHandler(void)
|
||||
void nu_ehci_isr(int vector, void *param)
|
||||
{
|
||||
uint32_t intsts;
|
||||
volatile uint32_t intsts = _ehci->USTSR;
|
||||
|
||||
intsts = _ehci->USTSR;
|
||||
_ehci->USTSR = intsts; /* clear interrupt status */
|
||||
|
||||
//USB_debug("ehci int_sts = 0x%x\n", intsts);
|
||||
|
||||
File diff suppressed because it is too large.
Load diff
File diff suppressed because it is too large.
Load diff
@@ -100,20 +100,32 @@ static nu_i2c_bus_t nu_i2c_arr [ ] =
|
||||
static rt_size_t nu_i2c_mst_xfer(struct rt_i2c_bus_device *bus,
|
||||
struct rt_i2c_msg msgs[],
|
||||
rt_uint32_t num);
|
||||
static rt_err_t nu_i2c_bus_control(struct rt_i2c_bus_device *bus,
|
||||
rt_uint32_t u32Cmd,
|
||||
rt_uint32_t u32Value);
|
||||
|
||||
static const struct rt_i2c_bus_device_ops nu_i2c_ops =
|
||||
{
|
||||
.master_xfer = nu_i2c_mst_xfer,
|
||||
.slave_xfer = NULL,
|
||||
.i2c_bus_control = NULL,
|
||||
.i2c_bus_control = nu_i2c_bus_control
|
||||
};
|
||||
|
||||
static rt_err_t nu_i2c_configure(nu_i2c_bus_t *bus)
|
||||
static rt_err_t nu_i2c_bus_control(struct rt_i2c_bus_device *bus, rt_uint32_t u32Cmd, rt_uint32_t u32Value)
|
||||
{
|
||||
RT_ASSERT(bus != RT_NULL);
|
||||
nu_i2c_bus_t *nu_i2c;
|
||||
|
||||
bus->parent.ops = &nu_i2c_ops;
|
||||
I2C_Open(bus->I2C, 100000);
|
||||
RT_ASSERT(bus != RT_NULL);
|
||||
nu_i2c = (nu_i2c_bus_t *) bus;
|
||||
|
||||
switch (RT_I2C_DEV_CTRL_CLK)
|
||||
{
|
||||
case RT_I2C_DEV_CTRL_CLK:
|
||||
I2C_SetBusClockFreq(nu_i2c->I2C, u32Value);
|
||||
break;
|
||||
default:
|
||||
return -RT_EIO;
|
||||
}
|
||||
|
||||
return RT_EOK;
|
||||
}
|
||||
@@ -376,11 +388,14 @@ int rt_hw_i2c_init(void)
|
||||
|
||||
for (i = (I2C_START + 1); i < I2C_CNT; i++)
|
||||
{
|
||||
|
||||
nu_sys_ipclk_enable(nu_i2c_arr[i].clkidx);
|
||||
nu_sys_ip_reset(nu_i2c_arr[i].rstidx);
|
||||
|
||||
nu_i2c_configure(&nu_i2c_arr[i]);
|
||||
/* Reset and initial IP engine. */
|
||||
I2C_Close(nu_i2c_arr[i].I2C);
|
||||
I2C_Open(nu_i2c_arr[i].I2C, 100000);
|
||||
nu_i2c_arr[i].parent.ops = &nu_i2c_ops;
|
||||
|
||||
ret = rt_i2c_bus_device_register(&nu_i2c_arr[i].parent, nu_i2c_arr[i].device_name);
|
||||
RT_ASSERT(RT_EOK == ret);
|
||||
}
|
||||
|
||||
@@ -244,6 +244,11 @@ static rt_err_t nu_i2s_dai_setup(nu_i2s_t psNuI2s, struct rt_audio_configure *pc
|
||||
i2sIoctl(I2S_SET_I2S_FORMAT, I2S_FORMAT_I2S, 0);
|
||||
|
||||
if (psNuI2s->AcodecOps->role == NU_ACODEC_ROLE_MASTER)
|
||||
{
|
||||
// Set as slave, source clock is XIN (12MHz)
|
||||
i2sIoctl(I2S_SET_MODE, I2S_MODE_SLAVE, 0);
|
||||
}
|
||||
else
|
||||
{
|
||||
if (pconfig->samplerate % 11025)
|
||||
{
|
||||
@@ -284,11 +289,6 @@ static rt_err_t nu_i2s_dai_setup(nu_i2s_t psNuI2s, struct rt_audio_configure *pc
|
||||
// Set as master
|
||||
i2sIoctl(I2S_SET_MODE, I2S_MODE_MASTER, 0);
|
||||
}
|
||||
else
|
||||
{
|
||||
// Set as slave, source clock is XIN (12MHz)
|
||||
i2sIoctl(I2S_SET_MODE, I2S_MODE_SLAVE, 0);
|
||||
}
|
||||
|
||||
LOG_I("Open I2S.");
|
||||
|
||||
|
||||
@@ -302,7 +302,6 @@ E_SYS_USB0_ID nu_sys_usb0_role(void)
|
||||
#ifdef RT_USING_FINSH
|
||||
|
||||
#include <finsh.h>
|
||||
FINSH_FUNCTION_EXPORT_ALIAS(rt_hw_cpu_reset, reset, restart the system);
|
||||
|
||||
#ifdef FINSH_USING_MSH
|
||||
int cmd_reset(int argc, char **argv)
|
||||
|
||||
File diff suppressed because it is too large.
Load diff
File diff suppressed because it is too large.
Load diff
@@ -17,8 +17,10 @@ static void nu_pin_uart_init(void)
|
||||
/* UART0: GPF11, GPF12 */
|
||||
outpw(REG_SYS_GPF_MFPH, (inpw(REG_SYS_GPF_MFPH) & 0xfff00fff) | 0x11000);
|
||||
|
||||
#if !defined(BOARD_USING_LCD_ILI9341)
|
||||
/* UART1: GPF9, GPF10 */
|
||||
outpw(REG_SYS_GPF_MFPH, (inpw(REG_SYS_GPF_MFPH) & 0xfffff00f) | 0x00220);
|
||||
#endif
|
||||
}
|
||||
|
||||
static void nu_pin_emac_init(void)
|
||||
|
||||
@@ -7,6 +7,7 @@
|
||||
# RT-Thread Kernel
|
||||
#
|
||||
CONFIG_RT_NAME_MAX=16
|
||||
# CONFIG_RT_USING_BIG_ENDIAN is not set
|
||||
# CONFIG_RT_USING_ARCH_DATA_TYPE is not set
|
||||
# CONFIG_RT_USING_SMP is not set
|
||||
CONFIG_RT_ALIGN_SIZE=4
|
||||
@@ -27,6 +28,7 @@ CONFIG_IDLE_THREAD_STACK_SIZE=2048
|
||||
#
|
||||
# CONFIG_RT_KSERVICE_USING_STDLIB is not set
|
||||
# CONFIG_RT_KSERVICE_USING_TINY_SIZE is not set
|
||||
# CONFIG_RT_USING_ASM_MEMCPY is not set
|
||||
CONFIG_RT_DEBUG=y
|
||||
CONFIG_RT_DEBUG_COLOR=y
|
||||
# CONFIG_RT_DEBUG_INIT_CONFIG is not set
|
||||
@@ -72,7 +74,8 @@ CONFIG_RT_USING_INTERRUPT_INFO=y
|
||||
CONFIG_RT_USING_CONSOLE=y
|
||||
CONFIG_RT_CONSOLEBUF_SIZE=256
|
||||
CONFIG_RT_CONSOLE_DEVICE_NAME="uart0"
|
||||
CONFIG_RT_VER_NUM=0x40003
|
||||
# CONFIG_RT_PRINTF_LONGLONG is not set
|
||||
CONFIG_RT_VER_NUM=0x40004
|
||||
CONFIG_ARCH_ARM=y
|
||||
# CONFIG_RT_USING_CPU_FFS is not set
|
||||
CONFIG_ARCH_ARM_ARM9=y
|
||||
@@ -95,19 +98,19 @@ CONFIG_RT_MAIN_THREAD_PRIORITY=10
|
||||
# Command shell
|
||||
#
|
||||
CONFIG_RT_USING_FINSH=y
|
||||
CONFIG_RT_USING_MSH=y
|
||||
CONFIG_FINSH_USING_MSH=y
|
||||
CONFIG_FINSH_THREAD_NAME="tshell"
|
||||
CONFIG_FINSH_THREAD_PRIORITY=20
|
||||
CONFIG_FINSH_THREAD_STACK_SIZE=4096
|
||||
CONFIG_FINSH_USING_HISTORY=y
|
||||
CONFIG_FINSH_HISTORY_LINES=5
|
||||
CONFIG_FINSH_USING_SYMTAB=y
|
||||
CONFIG_FINSH_CMD_SIZE=80
|
||||
CONFIG_MSH_USING_BUILT_IN_COMMANDS=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
|
||||
# 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
|
||||
CONFIG_FINSH_ARG_MAX=10
|
||||
|
||||
#
|
||||
@@ -141,6 +144,7 @@ CONFIG_RT_DFS_ELM_DRIVES=8
|
||||
CONFIG_RT_DFS_ELM_MAX_SECTOR_SIZE=4096
|
||||
# CONFIG_RT_DFS_ELM_USE_ERASE is not set
|
||||
CONFIG_RT_DFS_ELM_REENTRANT=y
|
||||
CONFIG_RT_DFS_ELM_MUTEX_TIMEOUT=3000
|
||||
CONFIG_RT_USING_DFS_DEVFS=y
|
||||
# CONFIG_RT_USING_DFS_ROMFS is not set
|
||||
# CONFIG_RT_USING_DFS_RAMFS is not set
|
||||
@@ -155,6 +159,8 @@ CONFIG_RT_USING_SYSTEM_WORKQUEUE=y
|
||||
CONFIG_RT_SYSTEM_WORKQUEUE_STACKSIZE=2048
|
||||
CONFIG_RT_SYSTEM_WORKQUEUE_PRIORITY=23
|
||||
CONFIG_RT_USING_SERIAL=y
|
||||
CONFIG_RT_USING_SERIAL_V1=y
|
||||
# CONFIG_RT_USING_SERIAL_V2 is not set
|
||||
# CONFIG_RT_SERIAL_USING_DMA is not set
|
||||
CONFIG_RT_SERIAL_RB_BUFSZ=2048
|
||||
CONFIG_RT_USING_CAN=y
|
||||
@@ -205,6 +211,7 @@ CONFIG_RT_INPUT_CAPTURE_RB_SIZE=100
|
||||
#
|
||||
# Using USB
|
||||
#
|
||||
CONFIG_RT_USING_USB=y
|
||||
CONFIG_RT_USING_USB_HOST=y
|
||||
CONFIG_RT_USBH_MSTORAGE=y
|
||||
CONFIG_UDISK_MOUNTPOINT="/mnt/udisk"
|
||||
@@ -234,14 +241,16 @@ CONFIG_RT_USB_MSTORAGE_DISK_NAME="ramdisk1"
|
||||
# POSIX layer and C standard library
|
||||
#
|
||||
CONFIG_RT_USING_LIBC=y
|
||||
CONFIG_RT_LIBC_USING_TIME=y
|
||||
# CONFIG_RT_LIBC_USING_FILEIO is not set
|
||||
# CONFIG_RT_USING_MODULE is not set
|
||||
CONFIG_RT_LIBC_DEFAULT_TIMEZONE=8
|
||||
# CONFIG_RT_USING_PTHREADS is not set
|
||||
CONFIG_RT_USING_POSIX=y
|
||||
# CONFIG_RT_USING_POSIX_MMAP is not set
|
||||
# CONFIG_RT_USING_POSIX_TERMIOS is not set
|
||||
# CONFIG_RT_USING_POSIX_GETLINE is not set
|
||||
# CONFIG_RT_USING_POSIX_AIO is not set
|
||||
# CONFIG_RT_USING_MODULE is not set
|
||||
CONFIG_RT_LIBC_FIXED_TIMEZONE=8
|
||||
|
||||
#
|
||||
# Network
|
||||
@@ -278,6 +287,7 @@ CONFIG_NETDEV_IPV6=0
|
||||
CONFIG_RT_USING_LWIP=y
|
||||
# CONFIG_RT_USING_LWIP141 is not set
|
||||
CONFIG_RT_USING_LWIP202=y
|
||||
# CONFIG_RT_USING_LWIP203 is not set
|
||||
# CONFIG_RT_USING_LWIP212 is not set
|
||||
# CONFIG_RT_USING_LWIP_IPV6 is not set
|
||||
CONFIG_RT_LWIP_MEM_ALIGNMENT=4
|
||||
@@ -349,8 +359,15 @@ CONFIG_RT_LWIP_USING_PING=y
|
||||
CONFIG_RT_USING_UTEST=y
|
||||
CONFIG_UTEST_THR_STACK_SIZE=4096
|
||||
CONFIG_UTEST_THR_PRIORITY=20
|
||||
# CONFIG_RT_USING_VAR_EXPORT is not set
|
||||
# CONFIG_RT_USING_RT_LINK is not set
|
||||
# CONFIG_RT_USING_LWP is not set
|
||||
|
||||
#
|
||||
# RT-Thread Utestcases
|
||||
#
|
||||
# CONFIG_RT_USING_UTESTCASES is not set
|
||||
|
||||
#
|
||||
# RT-Thread online packages
|
||||
#
|
||||
@@ -507,27 +524,6 @@ CONFIG_PKG_NUEMWIN_VER_NUM=0x99999
|
||||
# CONFIG_PKG_USING_BS8116A is not set
|
||||
# CONFIG_PKG_USING_GPS_RMC is not set
|
||||
# CONFIG_PKG_USING_URLENCODE is not set
|
||||
# CONFIG_PKG_USING_UMCN is not set
|
||||
# CONFIG_PKG_USING_LWRB2RTT is not set
|
||||
# CONFIG_PKG_USING_CPU_USAGE is not set
|
||||
# CONFIG_PKG_USING_GBK2UTF8 is not set
|
||||
# CONFIG_PKG_USING_VCONSOLE is not set
|
||||
# CONFIG_PKG_USING_KDB is not set
|
||||
# CONFIG_PKG_USING_WAMR is not set
|
||||
# CONFIG_PKG_USING_MICRO_XRCE_DDS_CLIENT is not set
|
||||
# CONFIG_PKG_USING_LWLOG is not set
|
||||
# CONFIG_PKG_USING_ANV_TRACE is not set
|
||||
# CONFIG_PKG_USING_ANV_MEMLEAK is not set
|
||||
# CONFIG_PKG_USING_ANV_TESTSUIT is not set
|
||||
# CONFIG_PKG_USING_ANV_BENCH is not set
|
||||
# CONFIG_PKG_USING_DEVMEM is not set
|
||||
# CONFIG_PKG_USING_REGEX is not set
|
||||
CONFIG_PKG_USING_MEM_SANDBOX=y
|
||||
CONFIG_PKG_MEM_SANDBOX_PATH="/packages/tools/mem_sandbox"
|
||||
CONFIG_PKG_USING_MEM_SANDBOX_LATEST_VERSION=y
|
||||
CONFIG_PKG_MEM_SANDBOX_VER="latest"
|
||||
# CONFIG_PKG_USING_SOLAR_TERMS is not set
|
||||
# CONFIG_PKG_USING_GAN_ZHI is not set
|
||||
|
||||
#
|
||||
# system packages
|
||||
@@ -733,27 +729,8 @@ CONFIG_PKG_OPTPARSE_VER="latest"
|
||||
# CONFIG_PKG_USING_NETWORK_SAMPLES is not set
|
||||
# CONFIG_PKG_USING_PERIPHERAL_SAMPLES is not set
|
||||
# CONFIG_PKG_USING_HELLO is not set
|
||||
CONFIG_PKG_USING_VI=y
|
||||
CONFIG_PKG_VI_PATH="/packages/misc/vi"
|
||||
CONFIG_VI_SANDBOX_SIZE_KB=20
|
||||
CONFIG_VI_MAX_LEN=4096
|
||||
# CONFIG_VI_ENABLE_8BIT is not set
|
||||
CONFIG_VI_ENABLE_COLON=y
|
||||
CONFIG_VI_ENABLE_COLON_EXPAND=y
|
||||
CONFIG_VI_ENABLE_YANKMARK=y
|
||||
CONFIG_VI_ENABLE_SEARCH=y
|
||||
CONFIG_VI_ENABLE_DOT_CMD=y
|
||||
CONFIG_VI_ENABLE_READONLY=y
|
||||
CONFIG_VI_ENABLE_SETOPTS=y
|
||||
CONFIG_VI_ENABLE_SET=y
|
||||
# CONFIG_VI_ENABLE_WIN_RESIZE is not set
|
||||
CONFIG_VI_ENABLE_VI_ASK_TERMINAL=y
|
||||
CONFIG_VI_ENABLE_UNDO=y
|
||||
CONFIG_VI_ENABLE_UNDO_QUEUE=y
|
||||
CONFIG_VI_UNDO_QUEUE_MAX=256
|
||||
CONFIG_VI_ENABLE_VERBOSE_STATUS=y
|
||||
CONFIG_PKG_USING_VI_LATEST_VERSION=y
|
||||
CONFIG_PKG_VI_VER="latest"
|
||||
# CONFIG_PKG_USING_VI is not set
|
||||
# CONFIG_PKG_USING_VI_LATEST_VERSION is not set
|
||||
# CONFIG_PKG_USING_KI is not set
|
||||
# CONFIG_PKG_USING_ARMv7M_DWT is not set
|
||||
# CONFIG_PKG_USING_VT100 is not set
|
||||
@@ -783,6 +760,7 @@ CONFIG_NU_PKG_USING_UTILS=y
|
||||
# CONFIG_NU_PKG_USING_MAX31875 is not set
|
||||
# CONFIG_NU_PKG_USING_NAU88L25 is not set
|
||||
CONFIG_NU_PKG_USING_NAU8822=y
|
||||
# CONFIG_NU_PKG_USING_DA9062 is not set
|
||||
# CONFIG_NU_PKG_USING_ILI9341 is not set
|
||||
# CONFIG_NU_PKG_USING_SPINAND is not set
|
||||
|
||||
|
||||
@@ -28,9 +28,9 @@ menu "Hardware Drivers Config"
|
||||
default n
|
||||
|
||||
config BOARD_USING_STORAGE_SDCARD
|
||||
bool "SDCARD supporting(over sdh1)"
|
||||
bool "SDCARD supporting(over sdh_p0)"
|
||||
select BSP_USING_SDH
|
||||
select BSP_USING_SDH1
|
||||
select BSP_USING_SDH0
|
||||
default y
|
||||
|
||||
config BOARD_USING_STORAGE_SPIFLASH
|
||||
|
||||
File diff suppressed because it is too large.
Load diff
@@ -148,4 +148,4 @@ SECTIONS
|
||||
.debug_varnames 0 : { *(.debug_varnames) }
|
||||
}
|
||||
|
||||
__bss_size = (__bss_end - __bss_start)>>3;
|
||||
__bss_size = SIZEOF(.bss);
|
||||
@@ -13,7 +13,7 @@
|
||||
|
||||
#include <rtthread.h>
|
||||
#include <rtdevice.h>
|
||||
#include <time.h>
|
||||
#include <sys/time.h>
|
||||
#include "bcm283x.h"
|
||||
|
||||
struct rt_rtc_device
|
||||
|
||||
@@ -137,4 +137,4 @@ SECTIONS
|
||||
.debug_varnames 0 : { *(.debug_varnames) }
|
||||
}
|
||||
|
||||
__bss_size = (__bss_end - __bss_start)>>3;
|
||||
__bss_size = SIZEOF(.bss);
|
||||
@@ -137,4 +137,4 @@ SECTIONS
|
||||
.debug_varnames 0 : { *(.debug_varnames) }
|
||||
}
|
||||
|
||||
__bss_size = (__bss_end - __bss_start)>>3;
|
||||
__bss_size = SIZEOF(.bss);
|
||||
@@ -56,6 +56,44 @@ menu "On-chip Peripheral Drivers"
|
||||
depends on BSP_USING_LPUART1 && RT_SERIAL_USING_DMA
|
||||
default n
|
||||
endif
|
||||
|
||||
menuconfig BSP_USING_I2C
|
||||
bool "Enable I2C BUS"
|
||||
default n
|
||||
select RT_USING_I2C
|
||||
select RT_USING_I2C_BITOPS
|
||||
select RT_USING_PIN
|
||||
if BSP_USING_I2C
|
||||
menuconfig BSP_USING_I2C3
|
||||
bool "Enable I2C3 BUS"
|
||||
default y
|
||||
if BSP_USING_I2C3
|
||||
comment "Notice: PC0 --> 32; PC1 --> 33"
|
||||
config BSP_I2C3_SCL_PIN
|
||||
int "i2c3 scl pin number"
|
||||
range 1 176
|
||||
default 32
|
||||
config BSP_I2C3_SDA_PIN
|
||||
int "I2C3 sda pin number"
|
||||
range 1 176
|
||||
default 33
|
||||
endif
|
||||
|
||||
menuconfig BSP_USING_I2C4
|
||||
bool "Enable I2C4 BUS"
|
||||
default n
|
||||
if BSP_USING_I2C4
|
||||
comment "Notice: PC1 --> 33; PD6 --> 54"
|
||||
config BSP_I2C4_SCL_PIN
|
||||
int "i2c4 scl pin number"
|
||||
range 1 176
|
||||
default 54
|
||||
config BSP_I2C4_SDA_PIN
|
||||
int "I2C4 sda pin number"
|
||||
range 1 176
|
||||
default 33
|
||||
endif
|
||||
endif
|
||||
|
||||
config BSP_USING_ON_CHIP_FLASH
|
||||
bool "Enable on-chip FLASH"
|
||||
|
||||
@@ -169,7 +169,7 @@ MSH_CMD_EXPORT(pwm_sample, pwm sample);
|
||||
#endif
|
||||
|
||||
#ifdef RT_USING_RTC
|
||||
#include <time.h>
|
||||
#include <sys/time.h>
|
||||
static int rtc_sample(int argc, char *argv[])
|
||||
{
|
||||
rt_err_t ret = RT_EOK;
|
||||
|
||||
@@ -169,7 +169,7 @@ MSH_CMD_EXPORT(pwm_sample, pwm sample);
|
||||
#endif
|
||||
|
||||
#ifdef RT_USING_RTC
|
||||
#include <time.h>
|
||||
#include <sys/time.h>
|
||||
static int rtc_sample(int argc, char *argv[])
|
||||
{
|
||||
rt_err_t ret = RT_EOK;
|
||||
|
||||
@@ -13,7 +13,8 @@
|
||||
#ifndef __ALARM_H__
|
||||
#define __ALARM_H__
|
||||
|
||||
#include <time.h>
|
||||
#include <sys/time.h>
|
||||
#include <rtdef.h>
|
||||
|
||||
#define RT_ALARM_TM_NOW -1 /* set the alarm tm_day,tm_mon,tm_sec,etc.
|
||||
to now.we also call it "don't care" value */
|
||||
|
||||
@@ -14,7 +14,7 @@
|
||||
* 2021-07-30 Meco Man move rtc_core.c to rtc.c
|
||||
*/
|
||||
|
||||
#include <time.h>
|
||||
#include <sys/time.h>
|
||||
#include <string.h>
|
||||
#include <stdlib.h>
|
||||
#include <rtthread.h>
|
||||
|
||||
@@ -21,6 +21,23 @@ struct rt_data_item
|
||||
rt_size_t data_size;
|
||||
};
|
||||
|
||||
/**
|
||||
* @brief This function will initialize the data queue. Calling this function will
|
||||
* initialize the data queue control block and set the notification callback function.
|
||||
*
|
||||
* @param queue is a pointer to the data queue object.
|
||||
*
|
||||
* @param size is the maximum number of data in the data queue.
|
||||
*
|
||||
* @param lwm is low water mark.
|
||||
* When the number of data in the data queue is less than this value, this function will
|
||||
* wake up the thread waiting for write data.
|
||||
*
|
||||
* @param evt_notify is the notification callback function.
|
||||
*
|
||||
* @return Return the operation status. When the return value is RT_EOK, the initialization is successful.
|
||||
* When the return value is RT_ENOMEM, it means insufficient memory allocation failed.
|
||||
*/
|
||||
rt_err_t
|
||||
rt_data_queue_init(struct rt_data_queue *queue,
|
||||
rt_uint16_t size,
|
||||
@@ -54,6 +71,21 @@ rt_data_queue_init(struct rt_data_queue *queue,
|
||||
}
|
||||
RTM_EXPORT(rt_data_queue_init);
|
||||
|
||||
/**
|
||||
* @brief This function will write data to the data queue. If the data queue is full,
|
||||
* the thread will suspend for the specified amount of time.
|
||||
*
|
||||
* @param queue is a pointer to the data queue object.
|
||||
* .
|
||||
* @param data_ptr is the buffer pointer of the data to be written.
|
||||
*
|
||||
* @param size is the size in bytes of the data to be written.
|
||||
*
|
||||
* @param timeout is the waiting time.
|
||||
*
|
||||
* @return Return the operation status. When the return value is RT_EOK, the operation is successful.
|
||||
* When the return value is RT_ETIMEOUT, it means the specified time out.
|
||||
*/
|
||||
rt_err_t rt_data_queue_push(struct rt_data_queue *queue,
|
||||
const void *data_ptr,
|
||||
rt_size_t data_size,
|
||||
@@ -153,6 +185,24 @@ __exit:
|
||||
}
|
||||
RTM_EXPORT(rt_data_queue_push);
|
||||
|
||||
/**
|
||||
* @brief This function will pop data from the data queue. If the data queue is empty,the thread
|
||||
* will suspend for the specified amount of time.
|
||||
*
|
||||
* @note When the number of data in the data queue is less than lwm(low water mark), will
|
||||
* wake up the thread waiting for write data.
|
||||
*
|
||||
* @param queue is a pointer to the data queue object.
|
||||
*
|
||||
* @param data_ptr is the buffer pointer of the data to be fetched.
|
||||
*
|
||||
* @param size is the size in bytes of the data to be fetched.
|
||||
*
|
||||
* @param timeout is the waiting time.
|
||||
*
|
||||
* @return Return the operation status. When the return value is RT_EOK, the operation is successful.
|
||||
* When the return value is RT_ETIMEOUT, it means the specified time out.
|
||||
*/
|
||||
rt_err_t rt_data_queue_pop(struct rt_data_queue *queue,
|
||||
const void** data_ptr,
|
||||
rt_size_t *size,
|
||||
@@ -264,6 +314,18 @@ __exit:
|
||||
}
|
||||
RTM_EXPORT(rt_data_queue_pop);
|
||||
|
||||
/**
|
||||
* @brief This function will fetch but retaining data in the data queue.
|
||||
*
|
||||
* @param queue is a pointer to the data queue object.
|
||||
*
|
||||
* @param data_ptr is the buffer pointer of the data to be fetched.
|
||||
*
|
||||
* @param size is the size in bytes of the data to be fetched.
|
||||
*
|
||||
* @return Return the operation status. When the return value is RT_EOK, the operation is successful.
|
||||
* When the return value is -RT_EEMPTY, it means the data queue is empty.
|
||||
*/
|
||||
rt_err_t rt_data_queue_peek(struct rt_data_queue *queue,
|
||||
const void** data_ptr,
|
||||
rt_size_t *size)
|
||||
@@ -289,6 +351,14 @@ rt_err_t rt_data_queue_peek(struct rt_data_queue *queue,
|
||||
}
|
||||
RTM_EXPORT(rt_data_queue_peek);
|
||||
|
||||
/**
|
||||
* @brief This function will reset the data queue.
|
||||
*
|
||||
* @note Calling this function will wake up all threads on the data queue
|
||||
* that are hanging and waiting.
|
||||
*
|
||||
* @param queue is a pointer to the data queue object.
|
||||
*/
|
||||
void rt_data_queue_reset(struct rt_data_queue *queue)
|
||||
{
|
||||
rt_ubase_t level;
|
||||
@@ -362,6 +432,13 @@ void rt_data_queue_reset(struct rt_data_queue *queue)
|
||||
}
|
||||
RTM_EXPORT(rt_data_queue_reset);
|
||||
|
||||
/**
|
||||
* @brief This function will deinit the data queue.
|
||||
*
|
||||
* @param queue is a pointer to the data queue object.
|
||||
*
|
||||
* @return Return the operation status. When the return value is RT_EOK, the operation is successful.
|
||||
*/
|
||||
rt_err_t rt_data_queue_deinit(struct rt_data_queue *queue)
|
||||
{
|
||||
rt_ubase_t level;
|
||||
@@ -382,6 +459,13 @@ rt_err_t rt_data_queue_deinit(struct rt_data_queue *queue)
|
||||
}
|
||||
RTM_EXPORT(rt_data_queue_deinit);
|
||||
|
||||
/**
|
||||
* @brief This function will get the number of data in the data queue.
|
||||
*
|
||||
* @param queue is a pointer to the data queue object.
|
||||
*
|
||||
* @return Return the number of data in the data queue.
|
||||
*/
|
||||
rt_uint16_t rt_data_queue_len(struct rt_data_queue *queue)
|
||||
{
|
||||
rt_ubase_t level;
|
||||
|
||||
@@ -751,9 +751,9 @@ long list_timer(void)
|
||||
|
||||
maxlen = RT_NAME_MAX;
|
||||
|
||||
rt_kprintf("%-*.s periodic timeout flag\n", maxlen, item_title);
|
||||
rt_kprintf("%-*.s periodic timeout activated mode\n", maxlen, item_title);
|
||||
object_split(maxlen);
|
||||
rt_kprintf(" ---------- ---------- -----------\n");
|
||||
rt_kprintf(" ---------- ---------- ----------- ---------\n");
|
||||
do
|
||||
{
|
||||
next = list_get_next(next, &find_arg);
|
||||
@@ -781,9 +781,13 @@ long list_timer(void)
|
||||
timer->init_tick,
|
||||
timer->timeout_tick);
|
||||
if (timer->parent.flag & RT_TIMER_FLAG_ACTIVATED)
|
||||
rt_kprintf("activated\n");
|
||||
rt_kprintf("activated ");
|
||||
else
|
||||
rt_kprintf("deactivated\n");
|
||||
rt_kprintf("deactivated ");
|
||||
if (timer->parent.flag & RT_TIMER_FLAG_PERIODIC)
|
||||
rt_kprintf("periodic\n");
|
||||
else
|
||||
rt_kprintf("one shot\n");
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1107,7 +1107,7 @@ static uint32_t ipstr_to_u32(char *ipstr)
|
||||
struct hostent *at_gethostbyname(const char *name)
|
||||
{
|
||||
struct at_device *device = RT_NULL;
|
||||
ip_addr_t addr;
|
||||
ip_addr_t addr = {0};
|
||||
char ipstr[16] = { 0 };
|
||||
/* buffer variables for at_gethostbyname() */
|
||||
static struct hostent s_hostent;
|
||||
|
||||
@@ -15,7 +15,7 @@
|
||||
* 一个线程定时发送事件 (事件5)
|
||||
*/
|
||||
#include <rtthread.h>
|
||||
#include <time.h>
|
||||
#include <sys/time.h>
|
||||
#include "tc_comm.h"
|
||||
|
||||
/* 指向线程控制块的指针 */
|
||||
|
||||
@@ -5,10 +5,11 @@
|
||||
*
|
||||
* Change Logs:
|
||||
* Date Author Notes
|
||||
* 2018-10-06 ZhaoXiaowei the first version
|
||||
* 2018-10-06 ZhaoXiaowei the first version
|
||||
* 2021-11-04 GuEe-GUI set sp with SP_ELx
|
||||
*/
|
||||
|
||||
/*
|
||||
/*
|
||||
*enable gtimer
|
||||
*/
|
||||
.globl rt_hw_gtimer_enable
|
||||
@@ -17,6 +18,14 @@ rt_hw_gtimer_enable:
|
||||
MSR CNTP_CTL_EL0,X0
|
||||
RET
|
||||
|
||||
/*
|
||||
*disable gtimer
|
||||
*/
|
||||
.globl rt_hw_gtimer_disable
|
||||
rt_hw_gtimer_disable:
|
||||
MSR CNTP_CTL_EL0,XZR
|
||||
RET
|
||||
|
||||
/*
|
||||
*set gtimer CNTP_TVAL_EL0 value
|
||||
*/
|
||||
@@ -48,10 +57,6 @@ rt_hw_get_gtimer_frq:
|
||||
RET
|
||||
|
||||
.macro SAVE_CONTEXT
|
||||
|
||||
/* Switch to use the EL0 stack pointer. */
|
||||
MSR SPSEL, #0
|
||||
|
||||
/* Save the entire context. */
|
||||
STP X0, X1, [SP, #-0x10]!
|
||||
STP X2, X3, [SP, #-0x10]!
|
||||
@@ -98,16 +103,9 @@ rt_hw_get_gtimer_frq:
|
||||
|
||||
MOV X0, SP /* Move SP into X0 for saving. */
|
||||
|
||||
/* Switch to use the ELx stack pointer. */
|
||||
MSR SPSEL, #1
|
||||
|
||||
.endm
|
||||
|
||||
.macro SAVE_CONTEXT_T
|
||||
|
||||
/* Switch to use the EL0 stack pointer. */
|
||||
MSR SPSEL, #0
|
||||
|
||||
/* Save the entire context. */
|
||||
STP X0, X1, [SP, #-0x10]!
|
||||
STP X2, X3, [SP, #-0x10]!
|
||||
@@ -135,15 +133,15 @@ rt_hw_get_gtimer_frq:
|
||||
B.EQ 1f
|
||||
B .
|
||||
3:
|
||||
MRS X3, SPSR_EL3
|
||||
MOV X3, 0x0d
|
||||
MOV X2, X30
|
||||
B 0f
|
||||
2:
|
||||
MRS X3, SPSR_EL2
|
||||
MOV X3, 0x09
|
||||
MOV X2, X30
|
||||
B 0f
|
||||
1:
|
||||
MRS X3, SPSR_EL1
|
||||
MOV X3, 0x05
|
||||
MOV X2, X30
|
||||
B 0f
|
||||
0:
|
||||
@@ -152,16 +150,10 @@ rt_hw_get_gtimer_frq:
|
||||
|
||||
MOV X0, SP /* Move SP into X0 for saving. */
|
||||
|
||||
/* Switch to use the ELx stack pointer. */
|
||||
MSR SPSEL, #1
|
||||
|
||||
.endm
|
||||
|
||||
.macro RESTORE_CONTEXT
|
||||
|
||||
/* Switch to use the EL0 stack pointer. */
|
||||
MSR SPSEL, #0
|
||||
|
||||
/* Set the SP to point to the stack of the task being restored. */
|
||||
MOV SP, X0
|
||||
|
||||
@@ -206,9 +198,6 @@ rt_hw_get_gtimer_frq:
|
||||
LDP X2, X3, [SP], #0x10
|
||||
LDP X0, X1, [SP], #0x10
|
||||
|
||||
/* Switch to use the ELx stack pointer. _RB_ Might not be required. */
|
||||
MSR SPSEL, #1
|
||||
|
||||
ERET
|
||||
|
||||
.endm
|
||||
|
||||
@@ -7,15 +7,16 @@
|
||||
* Date Author Notes
|
||||
* 2011-09-23 Bernard the first version
|
||||
* 2011-10-05 Bernard add thumb mode
|
||||
* 2021-11-04 GuEe-GUI set sp with SP_ELx
|
||||
*/
|
||||
#include <rtthread.h>
|
||||
#include <board.h>
|
||||
|
||||
#include <armv8.h>
|
||||
|
||||
#define INITIAL_SPSR_EL3 (PSTATE_EL3 | SP_EL0)
|
||||
#define INITIAL_SPSR_EL2 (PSTATE_EL2 | SP_EL0)
|
||||
#define INITIAL_SPSR_EL1 (PSTATE_EL1 | SP_EL0)
|
||||
#define INITIAL_SPSR_EL3 (PSTATE_EL3 | SP_ELx)
|
||||
#define INITIAL_SPSR_EL2 (PSTATE_EL2 | SP_ELx)
|
||||
#define INITIAL_SPSR_EL1 (PSTATE_EL1 | SP_ELx)
|
||||
|
||||
/**
|
||||
* This function will initialize thread stack
|
||||
|
||||
@@ -18,7 +18,7 @@ system_vectors:
|
||||
.align 11
|
||||
.set VBAR, system_vectors
|
||||
.org VBAR
|
||||
// Exception from CurrentEL (EL1) with SP_EL0 (SPSEL=1)
|
||||
// Exception from CurrentEL (EL1) with SP_EL0 (SPSEL=0)
|
||||
.org (VBAR + 0x00 + 0)
|
||||
B vector_error // Synchronous
|
||||
.org (VBAR + 0x80 + 0)
|
||||
|
||||
@@ -6,6 +6,7 @@
|
||||
* Date Author Notes
|
||||
* 2020-01-15 bigmagic the first version
|
||||
* 2020-08-10 SummerGift support clang compiler
|
||||
* 2021-11-04 GuEe-GUI set sp with SP_ELx
|
||||
*/
|
||||
|
||||
.section ".text.entrypoint","ax"
|
||||
@@ -32,14 +33,15 @@ cpu_setup:
|
||||
bne cpu_not_in_el3
|
||||
|
||||
/* Should never be executed, just for completeness. (EL3) */
|
||||
mov x0, #(1 << 0) /* EL0 and EL1 are in Non-Secure state */
|
||||
orr x0, x0, #(1 << 4) /* RES1 */
|
||||
orr x0, x0, #(1 << 5) /* RES1 */
|
||||
orr x0, x0, #(1 << 7) /* SMC instructions are undefined at EL1 and above */
|
||||
orr x0, x0, #(1 << 8) /* HVC instructions are enabled at EL1 and above */
|
||||
orr x0, x0, #(1 << 10) /* The next lower level is AArch64 */
|
||||
mov x2, #(1 << 0) /* EL0 and EL1 are in Non-Secure state */
|
||||
orr x2, x2, #(1 << 4) /* RES1 */
|
||||
orr x2, x2, #(1 << 5) /* RES1 */
|
||||
orr x2, x2, #(1 << 7) /* SMC instructions are undefined at EL1 and above */
|
||||
orr x2, x2, #(1 << 8) /* HVC instructions are enabled at EL1 and above */
|
||||
orr x2, x2, #(1 << 10) /* The next lower level is AArch64 */
|
||||
msr scr_el3, x2
|
||||
|
||||
/* Change execution level to EL2 */
|
||||
mov x2, #0x3c9
|
||||
msr spsr_el3, x2 /* 0b1111001001 */
|
||||
adr x2, cpu_not_in_el3
|
||||
@@ -51,8 +53,6 @@ cpu_not_in_el3: /* Running at EL2 or EL1 */
|
||||
beq cpu_in_el1 /* Halt this core if running in El1 */
|
||||
|
||||
cpu_in_el2:
|
||||
msr sp_el1, x1
|
||||
|
||||
/* Enable CNTP for EL1 */
|
||||
mrs x0, cnthctl_el2 /* Counter-timer Hypervisor Control register */
|
||||
orr x0, x0, #3
|
||||
@@ -71,6 +71,7 @@ cpu_in_el2:
|
||||
eret
|
||||
|
||||
cpu_in_el1:
|
||||
msr spsel, #1
|
||||
mov sp, x1 /* Set sp in el1 */
|
||||
|
||||
/* Avoid trap from SIMD or float point instruction */
|
||||
@@ -89,7 +90,7 @@ cpu_in_el1:
|
||||
clean_bss_loop:
|
||||
cbz w2, jump_to_entry
|
||||
str xzr, [x1], #8
|
||||
sub w2, w2, #1
|
||||
sub w2, w2, #8
|
||||
cbnz w2, clean_bss_loop
|
||||
|
||||
jump_to_entry:
|
||||
|
||||
+111
-111
File diff suppressed because it is too large.
Load diff
+22
-40
@@ -593,7 +593,6 @@ RTM_EXPORT(rt_show_version);
|
||||
/* private function */
|
||||
#define _ISDIGIT(c) ((unsigned)((c) - '0') < 10)
|
||||
|
||||
#ifdef RT_PRINTF_LONGLONG
|
||||
/**
|
||||
* This function will duplicate a string.
|
||||
*
|
||||
@@ -603,44 +602,38 @@ RTM_EXPORT(rt_show_version);
|
||||
*
|
||||
* @return the duplicated string pointer.
|
||||
*/
|
||||
#ifdef RT_PRINTF_LONGLONG
|
||||
rt_inline int divide(long long *n, int base)
|
||||
{
|
||||
int res;
|
||||
|
||||
/* optimized for processor which does not support divide instructions. */
|
||||
if (base == 10)
|
||||
{
|
||||
res = (int)(((unsigned long long)*n) % 10U);
|
||||
*n = (long long)(((unsigned long long)*n) / 10U);
|
||||
}
|
||||
else
|
||||
{
|
||||
res = (int)(((unsigned long long)*n) % 16U);
|
||||
*n = (long long)(((unsigned long long)*n) / 16U);
|
||||
}
|
||||
|
||||
return res;
|
||||
}
|
||||
#else
|
||||
rt_inline int divide(long *n, int base)
|
||||
#endif /* RT_PRINTF_LONGLONG */
|
||||
{
|
||||
int res;
|
||||
|
||||
/* optimized for processor which does not support divide instructions. */
|
||||
if (base == 10)
|
||||
{
|
||||
#ifdef RT_PRINTF_LONGLONG
|
||||
res = (int)(((unsigned long long)*n) % 10U);
|
||||
*n = (long long)(((unsigned long long)*n) / 10U);
|
||||
#else
|
||||
res = (int)(((unsigned long)*n) % 10U);
|
||||
*n = (long)(((unsigned long)*n) / 10U);
|
||||
#endif
|
||||
}
|
||||
else
|
||||
{
|
||||
#ifdef RT_PRINTF_LONGLONG
|
||||
res = (int)(((unsigned long long)*n) % 16U);
|
||||
*n = (long long)(((unsigned long long)*n) / 16U);
|
||||
#else
|
||||
res = (int)(((unsigned long)*n) % 16U);
|
||||
*n = (long)(((unsigned long)*n) / 16U);
|
||||
#endif
|
||||
}
|
||||
|
||||
return res;
|
||||
}
|
||||
#endif /* RT_PRINTF_LONGLONG */
|
||||
|
||||
rt_inline int skip_atoi(const char **s)
|
||||
{
|
||||
@@ -659,30 +652,19 @@ rt_inline int skip_atoi(const char **s)
|
||||
#define SPECIAL (1 << 5) /* 0x */
|
||||
#define LARGE (1 << 6) /* use 'ABCDEF' instead of 'abcdef' */
|
||||
|
||||
static char *print_number(char *buf,
|
||||
char *end,
|
||||
#ifdef RT_PRINTF_LONGLONG
|
||||
long long num,
|
||||
#else
|
||||
long num,
|
||||
#endif /* RT_PRINTF_LONGLONG */
|
||||
int base,
|
||||
int s,
|
||||
#ifdef RT_PRINTF_PRECISION
|
||||
static char *print_number(char *buf,
|
||||
char *end,
|
||||
#ifdef RT_PRINTF_LONGLONG
|
||||
long long num,
|
||||
#else
|
||||
long num,
|
||||
#endif /* RT_PRINTF_LONGLONG */
|
||||
int base,
|
||||
int s,
|
||||
int precision,
|
||||
int type)
|
||||
#else
|
||||
static char *print_number(char *buf,
|
||||
char *end,
|
||||
#ifdef RT_PRINTF_LONGLONG
|
||||
long long num,
|
||||
#else
|
||||
long num,
|
||||
#endif /* RT_PRINTF_LONGLONG */
|
||||
int base,
|
||||
int s,
|
||||
int type)
|
||||
#endif /* RT_PRINTF_PRECISION */
|
||||
int type)
|
||||
{
|
||||
char c, sign;
|
||||
#ifdef RT_PRINTF_LONGLONG
|
||||
|
||||
@@ -31,6 +31,7 @@
|
||||
|
||||
#include <rthw.h>
|
||||
#include <rtthread.h>
|
||||
#include <stddef.h>
|
||||
|
||||
#ifdef RT_USING_HOOK
|
||||
static void (*rt_thread_suspend_hook)(rt_thread_t thread);
|
||||
|
||||
+2
-2
@@ -560,12 +560,12 @@ rt_err_t rt_timer_control(rt_timer_t timer, int cmd, void *arg)
|
||||
if(timer->parent.flag & RT_TIMER_FLAG_ACTIVATED)
|
||||
{
|
||||
/*timer is start and run*/
|
||||
*(rt_tick_t *)arg = RT_TIMER_FLAG_ACTIVATED;
|
||||
*(rt_uint32_t *)arg = RT_TIMER_FLAG_ACTIVATED;
|
||||
}
|
||||
else
|
||||
{
|
||||
/*timer is stop*/
|
||||
*(rt_tick_t *)arg = RT_TIMER_FLAG_DEACTIVATED;
|
||||
*(rt_uint32_t *)arg = RT_TIMER_FLAG_DEACTIVATED;
|
||||
}
|
||||
break;
|
||||
|
||||
|
||||
+36
-11
@@ -616,6 +616,17 @@ def MergeGroup(src_group, group):
|
||||
else:
|
||||
src_group['LOCAL_ASFLAGS'] = group['LOCAL_ASFLAGS']
|
||||
|
||||
def _PretreatListParameters(target_list):
|
||||
while '' in target_list: # remove null strings
|
||||
target_list.remove('')
|
||||
while ' ' in target_list: # remove ' '
|
||||
target_list.remove(' ')
|
||||
|
||||
if(len(target_list) == 0):
|
||||
return False # ignore this list, don't add this list to the parameter
|
||||
|
||||
return True # permit to add this list to the parameter
|
||||
|
||||
def DefineGroup(name, src, depend, **parameters):
|
||||
global Env
|
||||
if not GetDepend(depend):
|
||||
@@ -640,19 +651,29 @@ def DefineGroup(name, src, depend, **parameters):
|
||||
group['src'] = src
|
||||
|
||||
if 'CCFLAGS' in group:
|
||||
Env.AppendUnique(CCFLAGS = group['CCFLAGS'])
|
||||
target = group['CCFLAGS']
|
||||
if len(target) > 0:
|
||||
Env.AppendUnique(CCFLAGS = target)
|
||||
if 'CPPPATH' in group:
|
||||
paths = []
|
||||
for item in group['CPPPATH']:
|
||||
paths.append(os.path.abspath(item))
|
||||
group['CPPPATH'] = paths
|
||||
Env.AppendUnique(CPPPATH = group['CPPPATH'])
|
||||
target = group['CPPPATH']
|
||||
if _PretreatListParameters(target) == True:
|
||||
paths = []
|
||||
for item in target:
|
||||
paths.append(os.path.abspath(item))
|
||||
target = paths
|
||||
Env.AppendUnique(CPPPATH = target)
|
||||
if 'CPPDEFINES' in group:
|
||||
Env.AppendUnique(CPPDEFINES = group['CPPDEFINES'])
|
||||
target = group['CPPDEFINES']
|
||||
if _PretreatListParameters(target) == True:
|
||||
Env.AppendUnique(CPPDEFINES = target)
|
||||
if 'LINKFLAGS' in group:
|
||||
Env.AppendUnique(LINKFLAGS = group['LINKFLAGS'])
|
||||
target = group['LINKFLAGS']
|
||||
if len(target) > 0:
|
||||
Env.AppendUnique(LINKFLAGS = target)
|
||||
if 'ASFLAGS' in group:
|
||||
Env.AppendUnique(ASFLAGS = group['ASFLAGS'])
|
||||
target = group['ASFLAGS']
|
||||
if len(target) > 0:
|
||||
Env.AppendUnique(ASFLAGS = target)
|
||||
if 'LOCAL_CPPPATH' in group:
|
||||
paths = []
|
||||
for item in group['LOCAL_CPPPATH']:
|
||||
@@ -675,9 +696,13 @@ def DefineGroup(name, src, depend, **parameters):
|
||||
os.unlink(fn)
|
||||
|
||||
if 'LIBS' in group:
|
||||
Env.AppendUnique(LIBS = group['LIBS'])
|
||||
target = group['LIBS']
|
||||
if _PretreatListParameters(target) == True:
|
||||
Env.AppendUnique(LIBS = target)
|
||||
if 'LIBPATH' in group:
|
||||
Env.AppendUnique(LIBPATH = group['LIBPATH'])
|
||||
target = group['LIBPATH']
|
||||
if _PretreatListParameters(target) == True:
|
||||
Env.AppendUnique(LIBPATH = target)
|
||||
|
||||
# check whether to build group library
|
||||
if 'LIBRARY' in group:
|
||||
|
||||
Reference in new issue
Block a user