Merge branch 'RT-Thread:master' into master

This commit is contained in:
chen zx 2021-08-06 17:05:50 +08:00 committed by GitHub
commit b104bbc4f9
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
82 changed files with 1501 additions and 948 deletions

View File

@ -131,6 +131,7 @@ jobs:
- {RTT_BSP: "at32/at32f407-start", RTT_TOOL_CHAIN: "sourcery-arm"}
- {RTT_BSP: "smartfusion2", RTT_TOOL_CHAIN: "sourcery-arm"}
- {RTT_BSP: "raspberry-pico", RTT_TOOL_CHAIN: "sourcery-arm"}
- {RTT_BSP: "raspberry-pi/raspi4-32", RTT_TOOL_CHAIN: "sourcery-arm"}
steps:
- uses: actions/checkout@v2
- name: Set up Python

View File

@ -128,49 +128,6 @@ void rt_hw_rtc_isr(rt_device_t device)
RTC->IFC = _RTC_IFC_MASK;
}
/***************************************************************************//**
* @brief
* Register RTC device
*
* @details
*
* @note
*
* @param[in] device
* Pointer to device descriptor
*
* @param[in] name
* Device name
*
* @param[in] flag
* Configuration flags
*
* @return
* Error code
******************************************************************************/
rt_err_t rt_hw_rtc_register(
rt_device_t device,
const char *name,
rt_uint32_t flag)
{
RT_ASSERT(device != RT_NULL);
device->type = RT_Device_Class_RTC;
device->rx_indicate = RT_NULL;
device->tx_complete = RT_NULL;
device->init = RT_NULL;
device->open = rt_rtc_open;
device->close = RT_NULL;
device->read = rt_rtc_read;
device->write = RT_NULL;
device->control = rt_rtc_control;
device->user_data = RT_NULL; /* no private */
/* register a character device */
return rt_device_register(device, name, RT_DEVICE_FLAG_RDWR | flag);
}
/***************************************************************************//**
* @brief
* Initialize all RTC module related hardware and register RTC device to kernel
@ -224,7 +181,18 @@ void rt_hw_rtc_init(void)
}
/* register rtc device */
rt_hw_rtc_register(&rtc, RT_RTC_NAME, EFM32_NO_DATA);
rtc.type = RT_Device_Class_RTC;
rtc.rx_indicate = RT_NULL;
rtc.tx_complete = RT_NULL;
rtc.init = RT_NULL;
rtc.open = rt_rtc_open;
rtc.close = RT_NULL;
rtc.read = rt_rtc_read;
rtc.write = RT_NULL;
rtc.control = rt_rtc_control;
rtc.user_data = RT_NULL; /* no private */
rt_device_register(&rtc, RT_RTC_NAME, RT_DEVICE_FLAG_RDWR | EFM32_NO_DATA);
}
#endif

View File

@ -7,6 +7,7 @@
# RT-Thread Kernel
#
CONFIG_RT_NAME_MAX=8
# CONFIG_RT_USING_ARCH_DATA_TYPE is not set
# CONFIG_RT_USING_SMP is not set
CONFIG_RT_ALIGN_SIZE=4
# CONFIG_RT_THREAD_PRIORITY_8 is not set
@ -20,6 +21,12 @@ CONFIG_RT_USING_IDLE_HOOK=y
CONFIG_RT_IDLE_HOOK_LIST_SIZE=4
CONFIG_IDLE_THREAD_STACK_SIZE=256
# CONFIG_RT_USING_TIMER_SOFT is not set
#
# kservice optimization
#
# CONFIG_RT_KSERVICE_USING_STDLIB is not set
# CONFIG_RT_KSERVICE_USING_TINY_SIZE is not set
CONFIG_RT_DEBUG=y
CONFIG_RT_DEBUG_COLOR=y
# CONFIG_RT_DEBUG_INIT_CONFIG is not set
@ -52,6 +59,8 @@ CONFIG_RT_USING_MEMHEAP=y
# CONFIG_RT_USING_SMALL_MEM is not set
# CONFIG_RT_USING_SLAB is not set
CONFIG_RT_USING_MEMHEAP_AS_HEAP=y
# CONFIG_RT_USING_USERHEAP is not set
# CONFIG_RT_USING_MEMTRACE is not set
CONFIG_RT_USING_HEAP=y
#
@ -63,7 +72,8 @@ CONFIG_RT_USING_DEVICE=y
CONFIG_RT_USING_CONSOLE=y
CONFIG_RT_CONSOLEBUF_SIZE=128
CONFIG_RT_CONSOLE_DEVICE_NAME="uart1"
CONFIG_RT_VER_NUM=0x40001
CONFIG_RT_VER_NUM=0x40004
# CONFIG_RT_USING_CPU_FFS is not set
# CONFIG_ARCH_CPU_STACK_GROWS_UPWARD is not set
#
@ -108,19 +118,23 @@ CONFIG_FINSH_ARG_MAX=10
#
CONFIG_RT_USING_DEVICE_IPC=y
CONFIG_RT_PIPE_BUFSZ=512
# CONFIG_RT_USING_SYSTEM_WORKQUEUE is not set
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=64
# CONFIG_RT_USING_CAN is not set
# CONFIG_RT_USING_HWTIMER is not set
CONFIG_RT_USING_CPUTIME=y
# CONFIG_RT_USING_I2C is not set
# CONFIG_RT_USING_PHY is not set
CONFIG_RT_USING_PIN=y
# CONFIG_RT_USING_ADC is not set
# CONFIG_RT_USING_DAC is not set
# CONFIG_RT_USING_PWM is not set
# CONFIG_RT_USING_MTD_NOR is not set
# CONFIG_RT_USING_MTD_NAND is not set
# CONFIG_RT_USING_MTD is not set
# CONFIG_RT_USING_PM is not set
# CONFIG_RT_USING_RTC is not set
# CONFIG_RT_USING_SDIO is not set
@ -128,10 +142,10 @@ CONFIG_RT_USING_PIN=y
# CONFIG_RT_USING_WDT is not set
# CONFIG_RT_USING_AUDIO is not set
# CONFIG_RT_USING_SENSOR is not set
#
# Using WiFi
#
# CONFIG_RT_USING_TOUCH is not set
# CONFIG_RT_USING_HWCRYPTO is not set
# CONFIG_RT_USING_PULSE_ENCODER is not set
# CONFIG_RT_USING_INPUT_CAPTURE is not set
# CONFIG_RT_USING_WIFI is not set
#
@ -145,6 +159,8 @@ CONFIG_RT_USING_PIN=y
#
CONFIG_RT_USING_LIBC=y
# CONFIG_RT_USING_PTHREADS is not set
# CONFIG_RT_USING_MODULE is not set
CONFIG_RT_LIBC_FIXED_TIMEZONE=8
#
# Network
@ -155,16 +171,16 @@ CONFIG_RT_USING_LIBC=y
#
# CONFIG_RT_USING_SAL is not set
#
# Network interface device
#
# CONFIG_RT_USING_NETDEV is not set
#
# light weight TCP/IP stack
#
# CONFIG_RT_USING_LWIP is not set
#
# Modbus master and slave stack
#
# CONFIG_RT_USING_MODBUS is not set
#
# AT commands
#
@ -178,10 +194,15 @@ CONFIG_RT_USING_LIBC=y
#
# Utilities
#
# CONFIG_RT_USING_LOGTRACE is not set
# CONFIG_RT_USING_RYM is not set
# CONFIG_RT_USING_ULOG is not set
# CONFIG_RT_USING_UTEST is not set
# CONFIG_RT_USING_RT_LINK is not set
#
# RT-Thread Utestcases
#
# CONFIG_RT_USING_UTESTCASES is not set
#
# RT-Thread online packages
@ -190,14 +211,20 @@ CONFIG_RT_USING_LIBC=y
#
# IoT - internet of things
#
# CONFIG_PKG_USING_LORAWAN_DRIVER is not set
# CONFIG_PKG_USING_PAHOMQTT is not set
# CONFIG_PKG_USING_UMQTT is not set
# CONFIG_PKG_USING_WEBCLIENT is not set
# CONFIG_PKG_USING_WEBNET is not set
# CONFIG_PKG_USING_MONGOOSE is not set
# CONFIG_PKG_USING_MYMQTT is not set
# CONFIG_PKG_USING_KAWAII_MQTT is not set
# CONFIG_PKG_USING_BC28_MQTT is not set
# CONFIG_PKG_USING_WEBTERMINAL is not set
# CONFIG_PKG_USING_CJSON is not set
# CONFIG_PKG_USING_JSMN is not set
# CONFIG_PKG_USING_LIBMODBUS is not set
# CONFIG_PKG_USING_FREEMODBUS is not set
# CONFIG_PKG_USING_LJSON is not set
# CONFIG_PKG_USING_EZXML is not set
# CONFIG_PKG_USING_NANOPB is not set
@ -219,6 +246,8 @@ CONFIG_RT_USING_LIBC=y
# CONFIG_PKG_USING_COAP is not set
# CONFIG_PKG_USING_NOPOLL is not set
# CONFIG_PKG_USING_NETUTILS is not set
# CONFIG_PKG_USING_CMUX is not set
# CONFIG_PKG_USING_PPP_DEVICE is not set
# CONFIG_PKG_USING_AT_DEVICE is not set
# CONFIG_PKG_USING_ATSRV_SOCKET is not set
# CONFIG_PKG_USING_WIZNET is not set
@ -230,12 +259,38 @@ CONFIG_RT_USING_LIBC=y
# CONFIG_PKG_USING_GAGENT_CLOUD is not set
# CONFIG_PKG_USING_ALI_IOTKIT is not set
# CONFIG_PKG_USING_AZURE is not set
# CONFIG_PKG_USING_TENCENT_IOTKIT is not set
# CONFIG_PKG_USING_TENCENT_IOT_EXPLORER is not set
# CONFIG_PKG_USING_JIOT-C-SDK is not set
# CONFIG_PKG_USING_UCLOUD_IOT_SDK is not set
# CONFIG_PKG_USING_JOYLINK is not set
# CONFIG_PKG_USING_NIMBLE is not set
# CONFIG_PKG_USING_OTA_DOWNLOADER is not set
# CONFIG_PKG_USING_IPMSG is not set
# CONFIG_PKG_USING_LSSDP is not set
# CONFIG_PKG_USING_AIRKISS_OPEN is not set
# CONFIG_PKG_USING_LIBRWS is not set
# CONFIG_PKG_USING_TCPSERVER is not set
# CONFIG_PKG_USING_PROTOBUF_C is not set
# CONFIG_PKG_USING_DLT645 is not set
# CONFIG_PKG_USING_QXWZ is not set
# CONFIG_PKG_USING_SMTP_CLIENT is not set
# CONFIG_PKG_USING_ABUP_FOTA is not set
# CONFIG_PKG_USING_LIBCURL2RTT is not set
# CONFIG_PKG_USING_CAPNP is not set
# CONFIG_PKG_USING_RT_CJSON_TOOLS is not set
# CONFIG_PKG_USING_AGILE_TELNET is not set
# CONFIG_PKG_USING_NMEALIB is not set
# CONFIG_PKG_USING_AGILE_JSMN is not set
# CONFIG_PKG_USING_PDULIB is not set
# CONFIG_PKG_USING_BTSTACK is not set
# CONFIG_PKG_USING_LORAWAN_ED_STACK is not set
# CONFIG_PKG_USING_WAYZ_IOTKIT is not set
# CONFIG_PKG_USING_MAVLINK is not set
# CONFIG_PKG_USING_RAPIDJSON is not set
# CONFIG_PKG_USING_BSAL is not set
# CONFIG_PKG_USING_AGILE_MODBUS is not set
# CONFIG_PKG_USING_AGILE_FTP is not set
# CONFIG_PKG_USING_EMBEDDEDPROTO is not set
#
# security packages
@ -243,6 +298,8 @@ CONFIG_RT_USING_LIBC=y
# CONFIG_PKG_USING_MBEDTLS is not set
# CONFIG_PKG_USING_libsodium is not set
# CONFIG_PKG_USING_TINYCRYPT is not set
# CONFIG_PKG_USING_TFM is not set
# CONFIG_PKG_USING_YD_CRYPTO is not set
#
# language packages
@ -257,6 +314,15 @@ CONFIG_RT_USING_LIBC=y
# CONFIG_PKG_USING_OPENMV is not set
# CONFIG_PKG_USING_MUPDF is not set
# CONFIG_PKG_USING_STEMWIN is not set
# CONFIG_PKG_USING_WAVPLAYER is not set
# CONFIG_PKG_USING_TJPGD is not set
# CONFIG_PKG_USING_PDFGEN is not set
# CONFIG_PKG_USING_HELIX is not set
# CONFIG_PKG_USING_AZUREGUIX is not set
# CONFIG_PKG_USING_TOUCHGFX2RTT is not set
# CONFIG_PKG_USING_NUEMWIN is not set
# CONFIG_PKG_USING_MP3PLAYER is not set
# CONFIG_PKG_USING_TINYJPEG is not set
#
# tools packages
@ -265,27 +331,103 @@ CONFIG_RT_USING_LIBC=y
# CONFIG_PKG_USING_EASYFLASH is not set
# CONFIG_PKG_USING_EASYLOGGER is not set
# CONFIG_PKG_USING_SYSTEMVIEW is not set
# CONFIG_PKG_USING_SEGGER_RTT is not set
# CONFIG_PKG_USING_RDB is not set
# CONFIG_PKG_USING_QRCODE is not set
# CONFIG_PKG_USING_ULOG_EASYFLASH is not set
# CONFIG_PKG_USING_ULOG_FILE is not set
# CONFIG_PKG_USING_LOGMGR is not set
# CONFIG_PKG_USING_ADBD is not set
# CONFIG_PKG_USING_COREMARK is not set
# CONFIG_PKG_USING_DHRYSTONE is not set
# CONFIG_PKG_USING_MEMORYPERF is not set
# CONFIG_PKG_USING_NR_MICRO_SHELL is not set
# CONFIG_PKG_USING_CHINESE_FONT_LIBRARY is not set
# CONFIG_PKG_USING_LUNAR_CALENDAR is not set
# 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 is not set
# CONFIG_PKG_USING_SOLAR_TERMS is not set
# CONFIG_PKG_USING_GAN_ZHI is not set
#
# system packages
#
#
# acceleration: Assembly language or algorithmic acceleration packages
#
# CONFIG_PKG_USING_RT_MEMCPY_CM is not set
# CONFIG_PKG_USING_QFPLIB_M0_FULL is not set
# CONFIG_PKG_USING_QFPLIB_M0_TINY is not set
# CONFIG_PKG_USING_QFPLIB_M3 is not set
#
# Micrium: Micrium software products porting for RT-Thread
#
# CONFIG_PKG_USING_UCOSIII_WRAPPER is not set
# CONFIG_PKG_USING_UCOSII_WRAPPER is not set
# CONFIG_PKG_USING_UC_CRC is not set
# CONFIG_PKG_USING_UC_CLK is not set
# CONFIG_PKG_USING_UC_COMMON is not set
# CONFIG_PKG_USING_UC_MODBUS is not set
# CONFIG_PKG_USING_GUIENGINE is not set
# CONFIG_PKG_USING_CAIRO is not set
# CONFIG_PKG_USING_PIXMAN is not set
# CONFIG_PKG_USING_LWEXT4 is not set
# CONFIG_PKG_USING_PARTITION is not set
# CONFIG_PKG_USING_FAL is not set
# CONFIG_PKG_USING_FLASHDB is not set
# CONFIG_PKG_USING_SQLITE is not set
# CONFIG_PKG_USING_RTI is not set
# CONFIG_PKG_USING_LITTLEVGL2RTT is not set
# CONFIG_PKG_USING_LITTLEVGL2RTT_V001 is not set
# CONFIG_PKG_USING_LITTLEVGL2RTT_LATEST_VERSION is not set
# CONFIG_LV_MEM_STATIC is not set
# CONFIG_LV_MEM_DYNAMIC is not set
# CONFIG_LV_COLOR_DEPTH_1 is not set
# CONFIG_LV_COLOR_DEPTH_8 is not set
# CONFIG_LV_COLOR_DEPTH_16 is not set
# CONFIG_LV_COLOR_DEPTH_24 is not set
# CONFIG_LV_COLOR_DEPTH_32 is not set
# CONFIG_LV_GC_DISABLE is not set
# CONFIG_LV_GC_ENABLE 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
# CONFIG_PKG_USING_DFS_UFFS is not set
# CONFIG_PKG_USING_LWEXT4 is not set
# CONFIG_PKG_USING_THREAD_POOL is not set
# CONFIG_PKG_USING_ROBOTS is not set
# CONFIG_PKG_USING_EV is not set
# CONFIG_PKG_USING_SYSWATCH is not set
# CONFIG_PKG_USING_SYS_LOAD_MONITOR is not set
# CONFIG_PKG_USING_PLCCORE is not set
# CONFIG_PKG_USING_RAMDISK is not set
# CONFIG_PKG_USING_MININI is not set
# 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_KPRINTF_THREADSAFE is not set
# CONFIG_PKG_USING_LPM is not set
# CONFIG_PKG_USING_TLSF is not set
# CONFIG_PKG_USING_EVENT_RECORDER is not set
#
# peripheral libraries and drivers
@ -293,7 +435,8 @@ CONFIG_RT_USING_LIBC=y
# CONFIG_PKG_USING_SENSORS_DRIVERS is not set
# CONFIG_PKG_USING_REALTEK_AMEBA is not set
# CONFIG_PKG_USING_SHT2X is not set
# CONFIG_PKG_USING_AP3216C is not set
# CONFIG_PKG_USING_SHT3X is not set
# CONFIG_PKG_USING_AS7341 is not set
# CONFIG_PKG_USING_STM32_SDIO is not set
# CONFIG_PKG_USING_ICM20608 is not set
# CONFIG_PKG_USING_U8G2 is not set
@ -302,14 +445,72 @@ CONFIG_RT_USING_LIBC=y
# CONFIG_PKG_USING_SX12XX is not set
# CONFIG_PKG_USING_SIGNAL_LED is not set
# CONFIG_PKG_USING_LEDBLINK is not set
# CONFIG_PKG_USING_LITTLED is not set
# CONFIG_PKG_USING_LKDGUI is not set
# CONFIG_PKG_USING_NRF5X_SDK is not set
# CONFIG_PKG_USING_NRFX is not set
# CONFIG_PKG_USING_WM_LIBRARIES is not set
# CONFIG_PKG_USING_KENDRYTE_SDK is not set
# CONFIG_PKG_USING_INFRARED is not set
# CONFIG_PKG_USING_ROSSERIAL is not set
# CONFIG_PKG_USING_AGILE_BUTTON is not set
# CONFIG_PKG_USING_AGILE_LED is not set
# CONFIG_PKG_USING_AT24CXX is not set
# CONFIG_PKG_USING_MOTIONDRIVER2RTT is not set
# CONFIG_PKG_USING_AD7746 is not set
# CONFIG_PKG_USING_PCA9685 is not set
# CONFIG_PKG_USING_I2C_TOOLS is not set
# CONFIG_PKG_USING_NRF24L01 is not set
# CONFIG_PKG_USING_TOUCH_DRIVERS is not set
# CONFIG_PKG_USING_MAX17048 is not set
# CONFIG_PKG_USING_RPLIDAR is not set
# CONFIG_PKG_USING_AS608 is not set
# CONFIG_PKG_USING_RC522 is not set
# CONFIG_PKG_USING_WS2812B is not set
# CONFIG_PKG_USING_EMBARC_BSP is not set
# CONFIG_PKG_USING_EXTERN_RTC_DRIVERS is not set
# CONFIG_PKG_USING_MULTI_RTIMER is not set
# CONFIG_PKG_USING_MAX7219 is not set
# CONFIG_PKG_USING_BEEP is not set
# CONFIG_PKG_USING_EASYBLINK is not set
# CONFIG_PKG_USING_PMS_SERIES is not set
# CONFIG_PKG_USING_CAN_YMODEM is not set
# CONFIG_PKG_USING_LORA_RADIO_DRIVER is not set
# CONFIG_PKG_USING_QLED is not set
# CONFIG_PKG_USING_PAJ7620 is not set
# CONFIG_PKG_USING_AGILE_CONSOLE is not set
# CONFIG_PKG_USING_LD3320 is not set
# CONFIG_PKG_USING_WK2124 is not set
# CONFIG_PKG_USING_LY68L6400 is not set
# CONFIG_PKG_USING_DM9051 is not set
# CONFIG_PKG_USING_SSD1306 is not set
# CONFIG_PKG_USING_QKEY is not set
# CONFIG_PKG_USING_RS485 is not set
# CONFIG_PKG_USING_NES is not set
# CONFIG_PKG_USING_VIRTUAL_SENSOR is not set
# CONFIG_PKG_USING_VDEVICE is not set
# CONFIG_PKG_USING_SGM706 is not set
# CONFIG_PKG_USING_STM32WB55_SDK is not set
# CONFIG_PKG_USING_RDA58XX is not set
# CONFIG_PKG_USING_LIBNFC is not set
# CONFIG_PKG_USING_MFOC is not set
# CONFIG_PKG_USING_TMC51XX is not set
# CONFIG_PKG_USING_TCA9534 is not set
# CONFIG_PKG_USING_KOBUKI is not set
# CONFIG_PKG_USING_ROSSERIAL is not set
# CONFIG_PKG_USING_MICRO_ROS is not set
#
# AI packages
#
# CONFIG_PKG_USING_LIBANN is not set
# CONFIG_PKG_USING_NNOM is not set
# CONFIG_PKG_USING_ONNX_BACKEND is not set
# CONFIG_PKG_USING_ONNX_PARSER is not set
# CONFIG_PKG_USING_TENSORFLOWLITEMICRO is not set
# CONFIG_PKG_USING_ELAPACK is not set
# CONFIG_PKG_USING_ULAPACK is not set
# CONFIG_PKG_USING_QUEST is not set
# CONFIG_PKG_USING_NAXOS is not set
#
# miscellaneous packages
@ -319,13 +520,18 @@ CONFIG_RT_USING_LIBC=y
# CONFIG_PKG_USING_FASTLZ is not set
# CONFIG_PKG_USING_MINILZO is not set
# CONFIG_PKG_USING_QUICKLZ is not set
# CONFIG_PKG_USING_LZMA is not set
# CONFIG_PKG_USING_MULTIBUTTON is not set
# CONFIG_PKG_USING_FLEXIBLE_BUTTON is not set
# CONFIG_PKG_USING_CANFESTIVAL is not set
# CONFIG_PKG_USING_ZLIB is not set
# CONFIG_PKG_USING_MINIZIP is not set
# CONFIG_PKG_USING_DSTR is not set
# CONFIG_PKG_USING_TINYFRAME is not set
# CONFIG_PKG_USING_KENDRYTE_DEMO is not set
# CONFIG_PKG_USING_DIGITALCTRL is not set
# CONFIG_PKG_USING_UPACKER is not set
# CONFIG_PKG_USING_UPARAM is not set
#
# samples: kernel and components samples
@ -336,7 +542,25 @@ CONFIG_RT_USING_LIBC=y
# CONFIG_PKG_USING_PERIPHERAL_SAMPLES is not set
# CONFIG_PKG_USING_HELLO is not set
# CONFIG_PKG_USING_VI is not set
# CONFIG_PKG_USING_NNOM 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
# CONFIG_PKG_USING_UKAL is not set
# CONFIG_PKG_USING_CRCLIB is not set
#
# entertainment: terminal games and other interesting software packages
#
# CONFIG_PKG_USING_THREES is not set
# CONFIG_PKG_USING_2048 is not set
# CONFIG_PKG_USING_SNAKE is not set
# CONFIG_PKG_USING_TETRIS is not set
# CONFIG_PKG_USING_DONUT is not set
# CONFIG_PKG_USING_ACLOCK is not set
# CONFIG_PKG_USING_LWGPS is not set
# CONFIG_PKG_USING_STATE_MACHINE is not set
# CONFIG_PKG_USING_MCURSES is not set
# CONFIG_PKG_USING_COWSAY is not set
#
# Hardware Drivers Config
@ -351,10 +575,21 @@ CONFIG_SOC_MIMXRT1064DVL6A=y
CONFIG_BSP_USING_GPIO=y
CONFIG_BSP_USING_LPUART=y
CONFIG_BSP_USING_LPUART1=y
# CONFIG_BSP_USING_LPUART2 is not set
# CONFIG_BSP_USING_LPUART3 is not set
# CONFIG_BSP_USING_LPUART4 is not set
# CONFIG_BSP_USING_LPUART5 is not set
# CONFIG_BSP_USING_LPUART6 is not set
# CONFIG_BSP_USING_LPUART7 is not set
# CONFIG_BSP_USING_LPUART8 is not set
# CONFIG_BSP_USING_I2C is not set
# CONFIG_BSP_USING_LCD is not set
#
# Onboard Peripheral Drivers
#
# CONFIG_BSP_USING_SDRAM is not set
# CONFIG_BSP_USING_ETH is not set
#
# Board extended module Drivers

View File

@ -413,7 +413,7 @@ static void imxrt_lcd_pins_init(void)
0U); /* Software Input On Field: Input Path is determined by functionality */
IOMUXC_SetPinMux(
IOMUXC_GPIO_B1_03_LCD_DATA15, /* GPIO_B1_03 is configured as LCD_DATA15 */
0U); /* Software Input On Field: Input Path is determined by functionality */x
0U); /* Software Input On Field: Input Path is determined by functionality */
IOMUXC_SetPinConfig(
IOMUXC_GPIO_AD_B0_02_GPIO1_IO02, /* GPIO_AD_B0_02 PAD functional properties : */
0x10B0u); /* Slew Rate Field: Slow Slew Rate

View File

@ -10,12 +10,15 @@
#define RT_ALIGN_SIZE 4
#define RT_THREAD_PRIORITY_32
#define RT_THREAD_PRIORITY_MAX 32
#define RT_TICK_PER_SECOND 100
#define RT_TICK_PER_SECOND 1000
#define RT_USING_OVERFLOW_CHECK
#define RT_USING_HOOK
#define RT_USING_IDLE_HOOK
#define RT_IDLE_HOOK_LIST_SIZE 4
#define IDLE_THREAD_STACK_SIZE 256
/* kservice optimization */
#define RT_DEBUG
#define RT_DEBUG_COLOR
@ -40,7 +43,7 @@
#define RT_USING_CONSOLE
#define RT_CONSOLEBUF_SIZE 128
#define RT_CONSOLE_DEVICE_NAME "uart1"
#define RT_VER_NUM 0x40001
#define RT_VER_NUM 0x40004
/* RT-Thread Components */
@ -76,31 +79,30 @@
#define RT_USING_DEVICE_IPC
#define RT_PIPE_BUFSZ 512
#define RT_USING_SERIAL
#define RT_USING_SERIAL_V1
#define RT_SERIAL_RB_BUFSZ 64
#define RT_USING_CPUTIME
#define RT_USING_PIN
/* Using WiFi */
/* Using USB */
/* POSIX layer and C standard library */
#define RT_USING_LIBC
#define RT_LIBC_FIXED_TIMEZONE 8
/* Network */
/* Socket abstraction layer */
/* Network interface device */
/* light weight TCP/IP stack */
/* Modbus master and slave stack */
/* AT commands */
@ -110,6 +112,9 @@
/* Utilities */
/* RT-Thread Utestcases */
/* RT-Thread online packages */
/* IoT - internet of things */
@ -140,16 +145,27 @@
/* system packages */
/* acceleration: Assembly language or algorithmic acceleration packages */
/* Micrium: Micrium software products porting for RT-Thread */
/* peripheral libraries and drivers */
/* AI packages */
/* miscellaneous packages */
/* samples: kernel and components samples */
/* entertainment: terminal games and other interesting software packages */
/* Hardware Drivers Config */
#define BSP_USING_4MFLASH
@ -163,6 +179,7 @@
/* Onboard Peripheral Drivers */
/* Board extended module Drivers */

View File

@ -63,6 +63,9 @@ if GetDepend(['RT_USING_AUDIO']):
if GetDepend(['BSP_USING_LTDC']):
src += ['MIMXRT1064/drivers/']
if GetDepend(["BSP_USING_LCD"]):
src += ['MIMXRT1064/drivers/fsl_elcdif.c']
if GetDepend(['BSP_USING_DMA']):
src += ['MIMXRT1064/drivers/fsl_dmamux.c']

View File

@ -42,7 +42,7 @@ struct imxrt_lcd
};
static struct imxrt_lcd lcd;
ALIGN(64) static uint16_t frame_buffer[LCD_HEIGHT][LCD_WIDTH] RT_SECTION("NonCacheable");
AT_NONCACHEABLE_SECTION_ALIGN(static uint16_t frame_buffer[LCD_HEIGHT][LCD_WIDTH], 64);
static rt_err_t imxrt_lcd_init(rt_device_t device)
{

View File

@ -23,6 +23,12 @@ CONFIG_IDLE_THREAD_STACK_SIZE=2048
CONFIG_RT_USING_TIMER_SOFT=y
CONFIG_RT_TIMER_THREAD_PRIO=4
CONFIG_RT_TIMER_THREAD_STACK_SIZE=2048
#
# kservice optimization
#
# CONFIG_RT_KSERVICE_USING_STDLIB is not set
# CONFIG_RT_KSERVICE_USING_TINY_SIZE is not set
CONFIG_RT_DEBUG=y
# CONFIG_RT_DEBUG_COLOR is not set
# CONFIG_RT_DEBUG_INIT_CONFIG is not set
@ -67,8 +73,10 @@ CONFIG_RT_USING_DEVICE=y
CONFIG_RT_USING_CONSOLE=y
CONFIG_RT_CONSOLEBUF_SIZE=128
CONFIG_RT_CONSOLE_DEVICE_NAME="uart1"
CONFIG_RT_VER_NUM=0x40003
# CONFIG_RT_PRINTF_LONGLONG is not set
CONFIG_RT_VER_NUM=0x40004
# CONFIG_RT_USING_CPU_FFS is not set
CONFIG_RT_USING_GIC_V2=y
CONFIG_ARCH_ARMV8=y
# CONFIG_ARCH_CPU_STACK_GROWS_UPWARD is not set
@ -125,6 +133,11 @@ CONFIG_RT_DFS_ELM_WORD_ACCESS=y
# CONFIG_RT_DFS_ELM_USE_LFN_2 is not set
CONFIG_RT_DFS_ELM_USE_LFN_3=y
CONFIG_RT_DFS_ELM_USE_LFN=3
CONFIG_RT_DFS_ELM_LFN_UNICODE_0=y
# 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
CONFIG_RT_DFS_ELM_LFN_UNICODE=0
CONFIG_RT_DFS_ELM_MAX_LFN=255
CONFIG_RT_DFS_ELM_DRIVES=2
CONFIG_RT_DFS_ELM_MAX_SECTOR_SIZE=512
@ -133,8 +146,6 @@ CONFIG_RT_DFS_ELM_REENTRANT=y
CONFIG_RT_USING_DFS_DEVFS=y
# CONFIG_RT_USING_DFS_ROMFS is not set
# CONFIG_RT_USING_DFS_RAMFS is not set
# CONFIG_RT_USING_DFS_UFFS is not set
# CONFIG_RT_USING_DFS_JFFS2 is not set
# CONFIG_RT_USING_DFS_NFS is not set
#
@ -146,6 +157,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=y
CONFIG_RT_SERIAL_RB_BUFSZ=512
# CONFIG_RT_USING_CAN is not set
@ -181,6 +194,7 @@ CONFIG_RT_USING_WDT=y
# CONFIG_RT_USING_AUDIO is not set
# CONFIG_RT_USING_SENSOR is not set
CONFIG_RT_USING_TOUCH=y
# CONFIG_RT_TOUCH_PIN_IRQ is not set
# CONFIG_RT_USING_HWCRYPTO is not set
# CONFIG_RT_USING_PULSE_ENCODER is not set
# CONFIG_RT_USING_INPUT_CAPTURE is not set
@ -203,6 +217,7 @@ CONFIG_RT_USING_POSIX=y
# 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_DEFAULT_TIMEZONE=8
#
# Network
@ -212,6 +227,7 @@ CONFIG_RT_USING_POSIX=y
# Socket abstraction layer
#
CONFIG_RT_USING_SAL=y
CONFIG_SAL_INTERNET_CHECK=y
#
# protocol stack implement
@ -238,6 +254,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
@ -252,8 +269,8 @@ CONFIG_IP_SOF_BROADCAST_RECV=1
#
# Static IPv4 Address
#
CONFIG_RT_LWIP_IPADDR="192.168.1.30"
CONFIG_RT_LWIP_GWADDR="192.168.1.1"
CONFIG_RT_LWIP_IPADDR="192.168.111.172"
CONFIG_RT_LWIP_GWADDR="192.168.111.1"
CONFIG_RT_LWIP_MSKADDR="255.255.255.0"
CONFIG_RT_LWIP_UDP=y
CONFIG_RT_LWIP_TCP=y
@ -307,6 +324,12 @@ CONFIG_RT_LWIP_USING_PING=y
# CONFIG_RT_USING_RYM is not set
# CONFIG_RT_USING_ULOG is not set
# CONFIG_RT_USING_UTEST is not set
# CONFIG_RT_USING_RT_LINK is not set
#
# RT-Thread Utestcases
#
# CONFIG_RT_USING_UTESTCASES is not set
#
# RT-Thread online packages
@ -375,8 +398,6 @@ CONFIG_RT_LWIP_USING_PING=y
# CONFIG_PKG_USING_LIBRWS is not set
# CONFIG_PKG_USING_TCPSERVER is not set
# CONFIG_PKG_USING_PROTOBUF_C is not set
# CONFIG_PKG_USING_ONNX_PARSER is not set
# CONFIG_PKG_USING_ONNX_BACKEND is not set
# CONFIG_PKG_USING_DLT645 is not set
# CONFIG_PKG_USING_QXWZ is not set
# CONFIG_PKG_USING_SMTP_CLIENT is not set
@ -390,6 +411,13 @@ CONFIG_RT_LWIP_USING_PING=y
# CONFIG_PKG_USING_PDULIB is not set
# CONFIG_PKG_USING_BTSTACK is not set
# CONFIG_PKG_USING_LORAWAN_ED_STACK is not set
# CONFIG_PKG_USING_WAYZ_IOTKIT is not set
# CONFIG_PKG_USING_MAVLINK is not set
# CONFIG_PKG_USING_RAPIDJSON is not set
# CONFIG_PKG_USING_BSAL is not set
# CONFIG_PKG_USING_AGILE_MODBUS is not set
# CONFIG_PKG_USING_AGILE_FTP is not set
# CONFIG_PKG_USING_EMBEDDEDPROTO is not set
#
# security packages
@ -415,6 +443,7 @@ CONFIG_RT_LWIP_USING_PING=y
# CONFIG_PKG_USING_STEMWIN is not set
# CONFIG_PKG_USING_WAVPLAYER is not set
# CONFIG_PKG_USING_TJPGD is not set
# CONFIG_PKG_USING_PDFGEN is not set
# CONFIG_PKG_USING_HELIX is not set
# CONFIG_PKG_USING_AZUREGUIX is not set
# CONFIG_PKG_USING_TOUCHGFX2RTT is not set
@ -429,6 +458,8 @@ CONFIG_RT_LWIP_USING_PING=y
# CONFIG_PKG_USING_RDB is not set
# CONFIG_PKG_USING_QRCODE is not set
# CONFIG_PKG_USING_ULOG_EASYFLASH is not set
# CONFIG_PKG_USING_ULOG_FILE is not set
# CONFIG_PKG_USING_LOGMGR is not set
# CONFIG_PKG_USING_ADBD is not set
# CONFIG_PKG_USING_COREMARK is not set
# CONFIG_PKG_USING_DHRYSTONE is not set
@ -441,6 +472,20 @@ CONFIG_RT_LWIP_USING_PING=y
# 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 is not set
#
# system packages
@ -448,7 +493,6 @@ CONFIG_RT_LWIP_USING_PING=y
# CONFIG_PKG_USING_GUIENGINE is not set
# CONFIG_PKG_USING_CAIRO is not set
# CONFIG_PKG_USING_PIXMAN is not set
# CONFIG_PKG_USING_LWEXT4 is not set
# CONFIG_PKG_USING_PARTITION is not set
# CONFIG_PKG_USING_FAL is not set
# CONFIG_PKG_USING_FLASHDB is not set
@ -458,6 +502,9 @@ CONFIG_RT_LWIP_USING_PING=y
# 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
# CONFIG_PKG_USING_DFS_UFFS is not set
# CONFIG_PKG_USING_LWEXT4 is not set
# CONFIG_PKG_USING_THREAD_POOL is not set
# CONFIG_PKG_USING_ROBOTS is not set
# CONFIG_PKG_USING_EV is not set
@ -478,6 +525,15 @@ CONFIG_RT_LWIP_USING_PING=y
# CONFIG_PKG_USING_UC_COMMON is not set
# CONFIG_PKG_USING_UC_MODBUS is not set
# CONFIG_PKG_USING_PPOOL is not set
# CONFIG_PKG_USING_OPENAMP is not set
# CONFIG_PKG_USING_RT_KPRINTF_THREADSAFE is not set
# CONFIG_PKG_USING_RT_MEMCPY_CM is not set
# CONFIG_PKG_USING_QFPLIB_M0_FULL is not set
# CONFIG_PKG_USING_QFPLIB_M0_TINY is not set
# CONFIG_PKG_USING_QFPLIB_M3 is not set
# CONFIG_PKG_USING_LPM is not set
# CONFIG_PKG_USING_TLSF is not set
# CONFIG_PKG_USING_EVENT_RECORDER is not set
#
# peripheral libraries and drivers
@ -486,6 +542,7 @@ CONFIG_RT_LWIP_USING_PING=y
# CONFIG_PKG_USING_REALTEK_AMEBA is not set
# CONFIG_PKG_USING_SHT2X is not set
# CONFIG_PKG_USING_SHT3X is not set
# CONFIG_PKG_USING_AS7341 is not set
# CONFIG_PKG_USING_STM32_SDIO is not set
# CONFIG_PKG_USING_ICM20608 is not set
# CONFIG_PKG_USING_U8G2 is not set
@ -534,6 +591,29 @@ CONFIG_RT_LWIP_USING_PING=y
# CONFIG_PKG_USING_DM9051 is not set
# CONFIG_PKG_USING_SSD1306 is not set
# CONFIG_PKG_USING_QKEY is not set
# CONFIG_PKG_USING_RS485 is not set
# CONFIG_PKG_USING_NES is not set
# CONFIG_PKG_USING_VIRTUAL_SENSOR is not set
# CONFIG_PKG_USING_VDEVICE is not set
# CONFIG_PKG_USING_SGM706 is not set
# CONFIG_PKG_USING_STM32WB55_SDK is not set
# CONFIG_PKG_USING_RDA58XX is not set
# CONFIG_PKG_USING_LIBNFC is not set
# CONFIG_PKG_USING_MFOC is not set
# CONFIG_PKG_USING_TMC51XX is not set
#
# AI packages
#
# CONFIG_PKG_USING_LIBANN is not set
# CONFIG_PKG_USING_NNOM is not set
# CONFIG_PKG_USING_ONNX_BACKEND is not set
# CONFIG_PKG_USING_ONNX_PARSER is not set
# CONFIG_PKG_USING_TENSORFLOWLITEMICRO is not set
# CONFIG_PKG_USING_ELAPACK is not set
# CONFIG_PKG_USING_ULAPACK is not set
# CONFIG_PKG_USING_QUEST is not set
# CONFIG_PKG_USING_NAXOS is not set
#
# miscellaneous packages
@ -543,6 +623,7 @@ CONFIG_RT_LWIP_USING_PING=y
# CONFIG_PKG_USING_FASTLZ is not set
# CONFIG_PKG_USING_MINILZO is not set
# CONFIG_PKG_USING_QUICKLZ is not set
# CONFIG_PKG_USING_LZMA is not set
# CONFIG_PKG_USING_MULTIBUTTON is not set
# CONFIG_PKG_USING_FLEXIBLE_BUTTON is not set
# CONFIG_PKG_USING_CANFESTIVAL is not set
@ -564,64 +645,24 @@ CONFIG_RT_LWIP_USING_PING=y
# CONFIG_PKG_USING_HELLO is not set
# CONFIG_PKG_USING_VI is not set
# CONFIG_PKG_USING_KI is not set
# CONFIG_PKG_USING_NNOM is not set
# CONFIG_PKG_USING_LIBANN is not set
# CONFIG_PKG_USING_ELAPACK is not set
# CONFIG_PKG_USING_ARMv7M_DWT is not set
# CONFIG_PKG_USING_VT100 is not set
# CONFIG_PKG_USING_ULAPACK is not set
# CONFIG_PKG_USING_UKAL is not set
# CONFIG_PKG_USING_CRCLIB is not set
#
# games: games run on RT-Thread console
# entertainment: terminal games and other interesting software packages
#
# CONFIG_PKG_USING_THREES is not set
# CONFIG_PKG_USING_2048 is not set
# CONFIG_PKG_USING_SNAKE is not set
# CONFIG_PKG_USING_TETRIS is not set
# CONFIG_PKG_USING_DONUT is not set
# CONFIG_PKG_USING_ACLOCK is not set
# CONFIG_PKG_USING_LWGPS is not set
# CONFIG_PKG_USING_TENSORFLOWLITEMICRO is not set
#
# Privated Packages of RealThread
#
# CONFIG_PKG_USING_CODEC is not set
# CONFIG_PKG_USING_PLAYER is not set
# CONFIG_PKG_USING_MPLAYER is not set
# CONFIG_PKG_USING_PERSIMMON_SRC is not set
# CONFIG_PKG_USING_JS_PERSIMMON is not set
# CONFIG_PKG_USING_JERRYSCRIPT_WIN32 is not set
#
# Network Utilities
#
# CONFIG_PKG_USING_MDNS is not set
# CONFIG_PKG_USING_UPNP is not set
# CONFIG_PKG_USING_WICED is not set
# CONFIG_PKG_USING_CLOUDSDK is not set
# CONFIG_PKG_USING_POWER_MANAGER is not set
# CONFIG_PKG_USING_RT_OTA is not set
# CONFIG_PKG_USING_RDBD_SRC is not set
# CONFIG_PKG_USING_RTINSIGHT is not set
# CONFIG_PKG_USING_SMARTCONFIG is not set
# CONFIG_PKG_USING_RTX is not set
# CONFIG_RT_USING_TESTCASE is not set
# CONFIG_PKG_USING_NGHTTP2 is not set
# CONFIG_PKG_USING_AVS is not set
# CONFIG_PKG_USING_ALI_LINKKIT is not set
# CONFIG_PKG_USING_STS is not set
# CONFIG_PKG_USING_DLMS is not set
# CONFIG_PKG_USING_AUDIO_FRAMEWORK is not set
# CONFIG_PKG_USING_ZBAR is not set
# CONFIG_PKG_USING_MCF is not set
# CONFIG_PKG_USING_URPC is not set
# CONFIG_PKG_USING_BSAL is not set
# CONFIG_PKG_USING_DCM is not set
# CONFIG_PKG_USING_EMQ is not set
# CONFIG_PKG_USING_CFGM is not set
# CONFIG_PKG_USING_RT_CMSIS_DAP is not set
# CONFIG_PKG_USING_VIRTUAL_DEVICE is not set
# CONFIG_PKG_USING_SMODULE is not set
# CONFIG_PKG_USING_STATE_MACHINE is not set
# CONFIG_PKG_USING_MCURSES is not set
# CONFIG_PKG_USING_COWSAY is not set
CONFIG_BCM2711_SOC=y
# CONFIG_BSP_SUPPORT_FPU is not set

View File

@ -23,6 +23,7 @@ config BCM2711_SOC
select ARCH_ARMV8
select RT_USING_COMPONENTS_INIT
select RT_USING_USER_MAIN
select RT_USING_GIC_V2
default y
source "driver/Kconfig"

View File

@ -19,6 +19,7 @@
#include "raspi4.h"
#include "drv_eth.h"
#define DBG_LEVEL DBG_LOG
#include <rtdbg.h>
#define LOG_TAG "drv.eth"
@ -26,12 +27,14 @@
static int link_speed = 0;
static int link_flag = 0;
#define RECV_CACHE_BUF (2048)
#define SEND_CACHE_BUF (2048)
#define DMA_DISC_ADDR_SIZE (2 * 1024 *1024)
#define RECV_CACHE_BUF (1024)
#define SEND_CACHE_BUF (1024)
#define SEND_DATA_NO_CACHE (0x08200000)
#define RECV_DATA_NO_CACHE (0x08400000)
#define DMA_DISC_ADDR_SIZE (4 * 1024 *1024)
#define RX_DESC_BASE (mac_reg_base_addr + GENET_RX_OFF)
#define TX_DESC_BASE (mac_reg_base_addr + GENET_TX_OFF)
#define RX_DESC_BASE (MAC_REG + GENET_RX_OFF)
#define TX_DESC_BASE (MAC_REG + GENET_TX_OFF)
#define MAX_ADDR_LEN (6)
@ -45,11 +48,11 @@ static rt_thread_t link_thread_tid = RT_NULL;
#define LINK_THREAD_PRIORITY (20)
#define LINK_THREAD_TIMESLICE (10)
static rt_uint32_t tx_index = 0;
static rt_uint32_t rx_index = 0;
static rt_uint32_t index_flag = 0;
static rt_uint32_t send_cache_pbuf[RECV_CACHE_BUF];
struct rt_eth_dev
{
@ -60,12 +63,11 @@ struct rt_eth_dev
int state;
int index;
struct rt_timer link_timer;
struct rt_timer rx_poll_timer;
void *priv;
};
static struct rt_eth_dev eth_dev;
static struct rt_semaphore send_finsh_sem_lock;
static struct rt_semaphore sem_lock;
static struct rt_semaphore link_ack;
static inline rt_uint32_t read32(void *addr)
@ -78,18 +80,12 @@ static inline void write32(void *addr, rt_uint32_t value)
(*((volatile unsigned int*)(addr))) = value;
}
static void eth_rx_irq(int irq, void *param)
{
rt_uint32_t val = 0;
val = read32(mac_reg_base_addr + GENET_INTRL2_CPU_STAT);
val &= ~read32(mac_reg_base_addr + GENET_INTRL2_CPU_STAT_MASK);
write32(mac_reg_base_addr + GENET_INTRL2_CPU_CLEAR, val);
val = read32(MAC_REG + GENET_INTRL2_CPU_STAT);
val &= ~read32(MAC_REG + GENET_INTRL2_CPU_STAT_MASK);
write32(MAC_REG + GENET_INTRL2_CPU_CLEAR, val);
if (val & GENET_IRQ_RXDMA_DONE)
{
eth_device_ready(&eth_dev.parent);
@ -97,7 +93,7 @@ static void eth_rx_irq(int irq, void *param)
if (val & GENET_IRQ_TXDMA_DONE)
{
rt_sem_release(&send_finsh_sem_lock);
rt_sem_release(&sem_lock);
}
}
@ -109,11 +105,10 @@ static int bcmgenet_interface_set(void)
{
case PHY_INTERFACE_MODE_RGMII:
case PHY_INTERFACE_MODE_RGMII_RXID:
write32(mac_reg_base_addr + SYS_PORT_CTRL, PORT_MODE_EXT_GPHY);
write32(MAC_REG + SYS_PORT_CTRL, PORT_MODE_EXT_GPHY);
break;
default:
rt_kprintf("unknown phy mode: %d\n", mac_reg_base_addr);
rt_kprintf("unknown phy mode: %d\n", MAC_REG);
return -1;
}
return 0;
@ -122,48 +117,44 @@ static int bcmgenet_interface_set(void)
static void bcmgenet_umac_reset(void)
{
rt_uint32_t reg;
reg = read32(mac_reg_base_addr + SYS_RBUF_FLUSH_CTRL);
reg = read32(MAC_REG + SYS_RBUF_FLUSH_CTRL);
reg |= BIT(1);
write32((mac_reg_base_addr + SYS_RBUF_FLUSH_CTRL), reg);
write32((MAC_REG + SYS_RBUF_FLUSH_CTRL), reg);
reg &= ~BIT(1);
write32((mac_reg_base_addr + SYS_RBUF_FLUSH_CTRL), reg);
write32((MAC_REG + SYS_RBUF_FLUSH_CTRL), reg);
DELAY_MICROS(10);
write32((mac_reg_base_addr + SYS_RBUF_FLUSH_CTRL), 0);
write32((MAC_REG + SYS_RBUF_FLUSH_CTRL), 0);
DELAY_MICROS(10);
write32(mac_reg_base_addr + UMAC_CMD, 0);
write32(mac_reg_base_addr + UMAC_CMD, (CMD_SW_RESET | CMD_LCL_LOOP_EN));
write32(MAC_REG + UMAC_CMD, 0);
write32(MAC_REG + UMAC_CMD, (CMD_SW_RESET | CMD_LCL_LOOP_EN));
DELAY_MICROS(2);
write32(mac_reg_base_addr + UMAC_CMD, 0);
write32(MAC_REG + UMAC_CMD, 0);
/* clear tx/rx counter */
write32(mac_reg_base_addr + UMAC_MIB_CTRL, MIB_RESET_RX | MIB_RESET_TX | MIB_RESET_RUNT);
write32(mac_reg_base_addr + UMAC_MIB_CTRL, 0);
write32(mac_reg_base_addr + UMAC_MAX_FRAME_LEN, ENET_MAX_MTU_SIZE);
write32(MAC_REG + UMAC_MIB_CTRL, MIB_RESET_RX | MIB_RESET_TX | MIB_RESET_RUNT);
write32(MAC_REG + UMAC_MIB_CTRL, 0);
write32(MAC_REG + UMAC_MAX_FRAME_LEN, ENET_MAX_MTU_SIZE);
/* init rx registers, enable ip header optimization */
reg = read32(mac_reg_base_addr + RBUF_CTRL);
reg = read32(MAC_REG + RBUF_CTRL);
reg |= RBUF_ALIGN_2B;
write32(mac_reg_base_addr + RBUF_CTRL, reg);
write32(mac_reg_base_addr + RBUF_TBUF_SIZE_CTRL, 1);
write32(MAC_REG + RBUF_CTRL, reg);
write32(MAC_REG + RBUF_TBUF_SIZE_CTRL, 1);
}
static void bcmgenet_disable_dma(void)
{
rt_uint32_t tdma_reg = 0, rdma_reg = 0;
tdma_reg = read32(mac_reg_base_addr + TDMA_REG_BASE + DMA_CTRL);
tdma_reg = read32(MAC_REG + TDMA_REG_BASE + DMA_CTRL);
tdma_reg &= ~(1UL << DMA_EN);
write32(mac_reg_base_addr + TDMA_REG_BASE + DMA_CTRL, tdma_reg);
rdma_reg = read32(mac_reg_base_addr + RDMA_REG_BASE + DMA_CTRL);
write32(MAC_REG + TDMA_REG_BASE + DMA_CTRL, tdma_reg);
rdma_reg = read32(MAC_REG + RDMA_REG_BASE + DMA_CTRL);
rdma_reg &= ~(1UL << DMA_EN);
write32(mac_reg_base_addr + RDMA_REG_BASE + DMA_CTRL, rdma_reg);
write32(mac_reg_base_addr + UMAC_TX_FLUSH, 1);
write32(MAC_REG + RDMA_REG_BASE + DMA_CTRL, rdma_reg);
write32(MAC_REG + UMAC_TX_FLUSH, 1);
DELAY_MICROS(100);
write32(mac_reg_base_addr + UMAC_TX_FLUSH, 0);
write32(MAC_REG + UMAC_TX_FLUSH, 0);
}
static void bcmgenet_enable_dma(void)
@ -172,10 +163,10 @@ static void bcmgenet_enable_dma(void)
rt_uint32_t dma_ctrl = 0;
dma_ctrl = (1 << (DEFAULT_Q + DMA_RING_BUF_EN_SHIFT)) | DMA_EN;
write32(mac_reg_base_addr + TDMA_REG_BASE + DMA_CTRL, dma_ctrl);
write32(MAC_REG + TDMA_REG_BASE + DMA_CTRL, dma_ctrl);
reg = read32(mac_reg_base_addr + RDMA_REG_BASE + DMA_CTRL);
write32(mac_reg_base_addr + RDMA_REG_BASE + DMA_CTRL, dma_ctrl | reg);
reg = read32(MAC_REG + RDMA_REG_BASE + DMA_CTRL);
write32(MAC_REG + RDMA_REG_BASE + DMA_CTRL, dma_ctrl | reg);
}
static int bcmgenet_mdio_write(rt_uint32_t addr, rt_uint32_t reg, rt_uint32_t value)
@ -183,16 +174,16 @@ static int bcmgenet_mdio_write(rt_uint32_t addr, rt_uint32_t reg, rt_uint32_t va
int count = 10000;
rt_uint32_t val;
val = MDIO_WR | (addr << MDIO_PMD_SHIFT) | (reg << MDIO_REG_SHIFT) | (0xffff & value);
write32(mac_reg_base_addr + MDIO_CMD, val);
write32(MAC_REG + MDIO_CMD, val);
rt_uint32_t reg_val = read32(mac_reg_base_addr + MDIO_CMD);
rt_uint32_t reg_val = read32(MAC_REG + MDIO_CMD);
reg_val = reg_val | MDIO_START_BUSY;
write32(mac_reg_base_addr + MDIO_CMD, reg_val);
write32(MAC_REG + MDIO_CMD, reg_val);
while ((read32(mac_reg_base_addr + MDIO_CMD) & MDIO_START_BUSY) && (--count))
while ((read32(MAC_REG + MDIO_CMD) & MDIO_START_BUSY) && (--count))
DELAY_MICROS(1);
reg_val = read32(mac_reg_base_addr + MDIO_CMD);
reg_val = read32(MAC_REG + MDIO_CMD);
return reg_val & 0xffff;
}
@ -204,31 +195,32 @@ static int bcmgenet_mdio_read(rt_uint32_t addr, rt_uint32_t reg)
rt_uint32_t reg_val = 0;
val = MDIO_RD | (addr << MDIO_PMD_SHIFT) | (reg << MDIO_REG_SHIFT);
write32(mac_reg_base_addr + MDIO_CMD, val);
write32(MAC_REG + MDIO_CMD, val);
reg_val = read32(mac_reg_base_addr + MDIO_CMD);
reg_val = read32(MAC_REG + MDIO_CMD);
reg_val = reg_val | MDIO_START_BUSY;
write32(mac_reg_base_addr + MDIO_CMD, reg_val);
write32(MAC_REG + MDIO_CMD, reg_val);
while ((read32(mac_reg_base_addr + MDIO_CMD) & MDIO_START_BUSY) && (--count))
while ((read32(MAC_REG + MDIO_CMD) & MDIO_START_BUSY) && (--count))
DELAY_MICROS(1);
reg_val = read32(mac_reg_base_addr + MDIO_CMD);
reg_val = read32(MAC_REG + MDIO_CMD);
return reg_val & 0xffff;
}
static int bcmgenet_gmac_write_hwaddr(void)
{
//{0xdc,0xa6,0x32,0x28,0x22,0x50};
rt_uint8_t addr[6];
rt_uint32_t reg;
bcm271x_mbox_hardware_get_mac_address(&addr[0]);
reg = addr[0] << 24 | addr[1] << 16 | addr[2] << 8 | addr[3];
write32(mac_reg_base_addr + UMAC_MAC0, reg);
write32(MAC_REG + UMAC_MAC0, reg);
reg = addr[4] << 8 | addr[5];
write32(mac_reg_base_addr + UMAC_MAC1, reg);
write32(MAC_REG + UMAC_MAC1, reg);
return 0;
}
@ -254,8 +246,10 @@ static void bcmgenet_mdio_init(void)
rt_uint32_t ret = 0;
/*get ethernet uid*/
ret = get_ethernet_uid();
if (ret == 0) return;
if (ret == 0)
{
return;
}
/* reset phy */
bcmgenet_mdio_write(1, BCM54213PE_MII_CONTROL, MII_CONTROL_PHY_RESET);
/* read control reg */
@ -282,34 +276,34 @@ static void bcmgenet_mdio_init(void)
static void rx_ring_init(void)
{
write32(mac_reg_base_addr + RDMA_REG_BASE + DMA_SCB_BURST_SIZE, DMA_MAX_BURST_LENGTH);
write32(mac_reg_base_addr + RDMA_RING_REG_BASE + DMA_START_ADDR, 0x0);
write32(mac_reg_base_addr + RDMA_READ_PTR, 0x0);
write32(mac_reg_base_addr + RDMA_WRITE_PTR, 0x0);
write32(mac_reg_base_addr + RDMA_RING_REG_BASE + DMA_END_ADDR, RX_DESCS * DMA_DESC_SIZE / 4 - 1);
write32(MAC_REG + RDMA_REG_BASE + DMA_SCB_BURST_SIZE, DMA_MAX_BURST_LENGTH);
write32(MAC_REG + RDMA_RING_REG_BASE + DMA_START_ADDR, 0x0);
write32(MAC_REG + RDMA_READ_PTR, 0x0);
write32(MAC_REG + RDMA_WRITE_PTR, 0x0);
write32(MAC_REG + RDMA_RING_REG_BASE + DMA_END_ADDR, RX_DESCS * DMA_DESC_SIZE / 4 - 1);
write32(mac_reg_base_addr + RDMA_PROD_INDEX, 0x0);
write32(mac_reg_base_addr + RDMA_CONS_INDEX, 0x0);
write32(mac_reg_base_addr + RDMA_RING_REG_BASE + DMA_RING_BUF_SIZE, (RX_DESCS << DMA_RING_SIZE_SHIFT) | RX_BUF_LENGTH);
write32(mac_reg_base_addr + RDMA_XON_XOFF_THRESH, DMA_FC_THRESH_VALUE);
write32(mac_reg_base_addr + RDMA_REG_BASE + DMA_RING_CFG, 1 << DEFAULT_Q);
write32(MAC_REG + RDMA_PROD_INDEX, 0x0);
write32(MAC_REG + RDMA_CONS_INDEX, 0x0);
write32(MAC_REG + RDMA_RING_REG_BASE + DMA_RING_BUF_SIZE, (RX_DESCS << DMA_RING_SIZE_SHIFT) | RX_BUF_LENGTH);
write32(MAC_REG + RDMA_XON_XOFF_THRESH, DMA_FC_THRESH_VALUE);
write32(MAC_REG + RDMA_REG_BASE + DMA_RING_CFG, 1 << DEFAULT_Q);
}
static void tx_ring_init(void)
{
write32(mac_reg_base_addr + TDMA_REG_BASE + DMA_SCB_BURST_SIZE, DMA_MAX_BURST_LENGTH);
write32(mac_reg_base_addr + TDMA_RING_REG_BASE + DMA_START_ADDR, 0x0);
write32(mac_reg_base_addr + TDMA_READ_PTR, 0x0);
write32(mac_reg_base_addr + TDMA_READ_PTR, 0x0);
write32(mac_reg_base_addr + TDMA_READ_PTR, 0x0);
write32(mac_reg_base_addr + TDMA_WRITE_PTR, 0x0);
write32(mac_reg_base_addr + TDMA_RING_REG_BASE + DMA_END_ADDR, TX_DESCS * DMA_DESC_SIZE / 4 - 1);
write32(mac_reg_base_addr + TDMA_PROD_INDEX, 0x0);
write32(mac_reg_base_addr + TDMA_CONS_INDEX, 0x0);
write32(mac_reg_base_addr + TDMA_RING_REG_BASE + DMA_MBUF_DONE_THRESH, 0x1);
write32(mac_reg_base_addr + TDMA_FLOW_PERIOD, 0x0);
write32(mac_reg_base_addr + TDMA_RING_REG_BASE + DMA_RING_BUF_SIZE, (TX_DESCS << DMA_RING_SIZE_SHIFT) | RX_BUF_LENGTH);
write32(mac_reg_base_addr + TDMA_REG_BASE + DMA_RING_CFG, 1 << DEFAULT_Q);
write32(MAC_REG + TDMA_REG_BASE + DMA_SCB_BURST_SIZE, DMA_MAX_BURST_LENGTH);
write32(MAC_REG + TDMA_RING_REG_BASE + DMA_START_ADDR, 0x0);
write32(MAC_REG + TDMA_READ_PTR, 0x0);
write32(MAC_REG + TDMA_READ_PTR, 0x0);
write32(MAC_REG + TDMA_READ_PTR, 0x0);
write32(MAC_REG + TDMA_WRITE_PTR, 0x0);
write32(MAC_REG + TDMA_RING_REG_BASE + DMA_END_ADDR, TX_DESCS * DMA_DESC_SIZE / 4 - 1);
write32(MAC_REG + TDMA_PROD_INDEX, 0x0);
write32(MAC_REG + TDMA_CONS_INDEX, 0x0);
write32(MAC_REG + TDMA_RING_REG_BASE + DMA_MBUF_DONE_THRESH, 0x1);
write32(MAC_REG + TDMA_FLOW_PERIOD, 0x0);
write32(MAC_REG + TDMA_RING_REG_BASE + DMA_RING_BUF_SIZE, (TX_DESCS << DMA_RING_SIZE_SHIFT) | RX_BUF_LENGTH);
write32(MAC_REG + TDMA_REG_BASE + DMA_RING_CFG, 1 << DEFAULT_Q);
}
static void rx_descs_init(void)
@ -348,14 +342,14 @@ static int bcmgenet_adjust_link(void)
return -1;
}
rt_uint32_t reg1 = read32(mac_reg_base_addr + EXT_RGMII_OOB_CTRL);
rt_uint32_t reg1 = read32(MAC_REG + EXT_RGMII_OOB_CTRL);
//reg1 &= ~(1UL << OOB_DISABLE);
//rt_kprintf("OOB_DISABLE is %d\n", OOB_DISABLE);
reg1 |= (RGMII_LINK | RGMII_MODE_EN | ID_MODE_DIS);
write32(mac_reg_base_addr + EXT_RGMII_OOB_CTRL, reg1);
write32(MAC_REG + EXT_RGMII_OOB_CTRL, reg1);
DELAY_MICROS(1000);
write32(mac_reg_base_addr + UMAC_CMD, speed << CMD_SPEED_SHIFT);
write32(MAC_REG + UMAC_CMD, speed << CMD_SPEED_SHIFT);
return 0;
}
@ -393,28 +387,28 @@ static int bcmgenet_gmac_eth_start(void)
}
/* wait tx index clear */
while ((read32(mac_reg_base_addr + TDMA_CONS_INDEX) != 0) && (--count))
while ((read32(MAC_REG + TDMA_CONS_INDEX) != 0) && (--count))
DELAY_MICROS(1);
tx_index = read32(mac_reg_base_addr + TDMA_CONS_INDEX);
write32(mac_reg_base_addr + TDMA_PROD_INDEX, tx_index);
tx_index = read32(MAC_REG + TDMA_CONS_INDEX);
write32(MAC_REG + TDMA_PROD_INDEX, tx_index);
index_flag = read32(mac_reg_base_addr + RDMA_PROD_INDEX);
index_flag = read32(MAC_REG + RDMA_PROD_INDEX);
rx_index = index_flag % RX_DESCS;
write32(mac_reg_base_addr + RDMA_CONS_INDEX, index_flag);
write32(mac_reg_base_addr + RDMA_PROD_INDEX, index_flag);
write32(MAC_REG + RDMA_CONS_INDEX, index_flag);
write32(MAC_REG + RDMA_PROD_INDEX, index_flag);
/* Enable Rx/Tx */
rt_uint32_t rx_tx_en;
rx_tx_en = read32(mac_reg_base_addr + UMAC_CMD);
rx_tx_en = read32(MAC_REG + UMAC_CMD);
rx_tx_en |= (CMD_TX_EN | CMD_RX_EN);
write32(mac_reg_base_addr + UMAC_CMD, rx_tx_en);
// eanble IRQ for TxDMA done and RxDMA done
write32(mac_reg_base_addr + GENET_INTRL2_CPU_CLEAR_MASK, GENET_IRQ_TXDMA_DONE | GENET_IRQ_RXDMA_DONE);
write32(MAC_REG + UMAC_CMD, rx_tx_en);
//IRQ
write32(MAC_REG + GENET_INTRL2_CPU_CLEAR_MASK, GENET_IRQ_TXDMA_DONE | GENET_IRQ_RXDMA_DONE);
return 0;
}
@ -424,16 +418,17 @@ static rt_uint32_t bcmgenet_gmac_eth_recv(rt_uint8_t **packetp)
{
void* desc_base;
rt_uint32_t length = 0, addr = 0;
rt_uint32_t prod_index = read32(mac_reg_base_addr + RDMA_PROD_INDEX);
if(prod_index == index_flag) //no buff
rt_uint32_t prod_index = read32(MAC_REG + RDMA_PROD_INDEX);
if(prod_index == index_flag)
{
cur_recv_cnt = index_flag;
index_flag = 0x7fffffff;
/* no buff */
return 0;
}
else
{
if(prev_recv_cnt == (prod_index & 0xffff)) //no new buff
if(prev_recv_cnt == prod_index & 0xffff)
{
return 0;
}
@ -446,11 +441,7 @@ static rt_uint32_t bcmgenet_gmac_eth_recv(rt_uint8_t **packetp)
* This would actually not be needed if we don't program
* RBUF_ALIGN_2B
*/
//Convert to memory address
addr = addr + eth_recv_no_cache - RECV_DATA_NO_CACHE;
rt_hw_cpu_dcache_invalidate(addr,length);
rt_hw_cpu_dcache_invalidate(addr,length);
*packetp = (rt_uint8_t *)(addr + RX_BUF_OFFSET);
rx_index = rx_index + 1;
@ -458,8 +449,7 @@ static rt_uint32_t bcmgenet_gmac_eth_recv(rt_uint8_t **packetp)
{
rx_index = 0;
}
write32(mac_reg_base_addr + RDMA_CONS_INDEX, cur_recv_cnt);
write32(MAC_REG + RDMA_CONS_INDEX, cur_recv_cnt);
cur_recv_cnt = cur_recv_cnt + 1;
@ -469,43 +459,45 @@ static rt_uint32_t bcmgenet_gmac_eth_recv(rt_uint8_t **packetp)
}
prev_recv_cnt = cur_recv_cnt;
return length - RX_BUF_OFFSET;
return length;
}
}
static int bcmgenet_gmac_eth_send(rt_uint32_t packet, int length,struct pbuf *p)
static int bcmgenet_gmac_eth_send(void *packet, int length)
{
rt_ubase_t level;
void *desc_base = (TX_DESC_BASE + tx_index * DMA_DESC_SIZE);
pbuf_copy_partial(p, (void*)(packet + tx_index * SEND_CACHE_BUF), p->tot_len, 0);
rt_uint32_t len_stat = length << DMA_BUFLENGTH_SHIFT;
rt_uint32_t prod_index, cons;
rt_uint32_t tries = 100;
prod_index = read32(MAC_REG + TDMA_PROD_INDEX);
len_stat |= 0x3F << DMA_TX_QTAG_SHIFT;
len_stat |= DMA_TX_APPEND_CRC | DMA_SOP | DMA_EOP;
rt_hw_cpu_dcache_clean((void*)(packet + tx_index * SEND_CACHE_BUF),length);
rt_uint32_t prod_index;
prod_index = read32(mac_reg_base_addr + TDMA_PROD_INDEX);
write32((desc_base + DMA_DESC_ADDRESS_LO), SEND_DATA_NO_CACHE + tx_index * SEND_CACHE_BUF);
rt_hw_cpu_dcache_clean((void*)packet, length);
write32((desc_base + DMA_DESC_ADDRESS_LO), packet);
write32((desc_base + DMA_DESC_ADDRESS_HI), 0);
write32((desc_base + DMA_DESC_LENGTH_STATUS), len_stat);
tx_index ++;
if(tx_index >= TX_DESCS)
{
tx_index = 0;
}
tx_index = tx_index + 1;
prod_index = prod_index + 1;
if (prod_index > 0xffff)
if (prod_index == 0xe000)
{
write32(MAC_REG + TDMA_PROD_INDEX, 0);
prod_index = 0;
}
if (tx_index >= TX_DESCS)
{
tx_index = 0;
}
/* Start Transmisson */
write32(mac_reg_base_addr + TDMA_PROD_INDEX, prod_index);
write32(MAC_REG + TDMA_PROD_INDEX, prod_index);
rt_sem_take(&sem_lock, RT_WAITING_FOREVER);
return 0;
}
@ -514,10 +506,8 @@ static void link_task_entry(void *param)
struct eth_device *eth_device = (struct eth_device *)param;
RT_ASSERT(eth_device != RT_NULL);
struct rt_eth_dev *dev = &eth_dev;
//start mdio
bcmgenet_mdio_init();
//start timer link
rt_timer_init(&dev->link_timer, "link_timer",
link_irq,
@ -532,7 +522,7 @@ static void link_task_entry(void *param)
rt_timer_stop(&dev->link_timer);
//set mac
// bcmgenet_gmac_write_hwaddr();
bcmgenet_gmac_write_hwaddr();
bcmgenet_gmac_write_hwaddr();
//check link speed
@ -552,13 +542,9 @@ static void link_task_entry(void *param)
rt_kprintf("Support link mode Speed 10M\n");
}
//Convert to memory address
bcmgenet_gmac_eth_start();
rt_hw_interrupt_install(ETH_IRQ, eth_rx_irq, NULL, "eth_irq");
rt_hw_interrupt_umask(ETH_IRQ);
link_flag = 1;
}
@ -569,7 +555,7 @@ static rt_err_t bcmgenet_eth_init(rt_device_t device)
/* Read GENET HW version */
rt_uint8_t major = 0;
hw_reg = read32(mac_reg_base_addr + SYS_REV_CTRL);
hw_reg = read32(MAC_REG + SYS_REV_CTRL);
major = (hw_reg >> 24) & 0x0f;
if (major != 6)
{
@ -589,12 +575,12 @@ static rt_err_t bcmgenet_eth_init(rt_device_t device)
}
/* rbuf clear */
write32(mac_reg_base_addr + SYS_RBUF_FLUSH_CTRL, 0);
write32(MAC_REG + SYS_RBUF_FLUSH_CTRL, 0);
/* disable MAC while updating its registers */
write32(mac_reg_base_addr + UMAC_CMD, 0);
write32(MAC_REG + UMAC_CMD, 0);
/* issue soft reset with (rg)mii loopback to ensure a stable rxclk */
write32(mac_reg_base_addr + UMAC_CMD, CMD_SW_RESET | CMD_LCL_LOOP_EN);
write32(MAC_REG + UMAC_CMD, CMD_SW_RESET | CMD_LCL_LOOP_EN);
link_thread_tid = rt_thread_create("link", link_task_entry, (void *)device,
LINK_THREAD_STACK_SIZE,
@ -623,28 +609,32 @@ static rt_err_t bcmgenet_eth_control(rt_device_t dev, int cmd, void *args)
rt_err_t rt_eth_tx(rt_device_t device, struct pbuf *p)
{
rt_uint32_t sendbuf = (rt_uint32_t)SEND_DATA_NO_CACHE + (rt_uint32_t)(tx_index * SEND_CACHE_BUF);
/* lock eth device */
if (link_flag == 1)
{
bcmgenet_gmac_eth_send((rt_uint32_t)eth_send_no_cache, p->tot_len,p);
rt_sem_take(&send_finsh_sem_lock,RT_WAITING_FOREVER);
pbuf_copy_partial(p, (void *)&send_cache_pbuf[0], p->tot_len, 0);
rt_memcpy((void *)sendbuf, send_cache_pbuf, p->tot_len);
bcmgenet_gmac_eth_send((void *)sendbuf, p->tot_len);
}
return RT_EOK;
}
struct pbuf *rt_eth_rx(rt_device_t device)
{
int recv_len = 0;
rt_uint8_t* addr_point = RT_NULL;
rt_uint8_t *addr_point = RT_NULL;
struct pbuf *pbuf = RT_NULL;
if (link_flag == 1)
{
recv_len = bcmgenet_gmac_eth_recv(&addr_point);
recv_len = bcmgenet_gmac_eth_recv((rt_uint8_t **)&addr_point);
if (recv_len > 0)
{
pbuf = pbuf_alloc(PBUF_LINK, recv_len, PBUF_RAM);
if(pbuf)
rt_memcpy(pbuf->payload, addr_point, recv_len);
if(pbuf)
{
rt_memcpy(pbuf->payload, addr_point, recv_len);
}
}
}
return pbuf;
@ -653,14 +643,15 @@ struct pbuf *rt_eth_rx(rt_device_t device)
int rt_hw_eth_init(void)
{
rt_uint8_t mac_addr[6];
rt_sem_init(&send_finsh_sem_lock,"send_finsh_sem_lock",TX_DESCS,RT_IPC_FLAG_FIFO);
rt_sem_init(&sem_lock, "eth_send_lock", TX_DESCS, RT_IPC_FLAG_FIFO);
rt_sem_init(&link_ack, "link_ack", 0, RT_IPC_FLAG_FIFO);
memset(&eth_dev, 0, sizeof(eth_dev));
memset((void *)eth_send_no_cache, 0, DMA_DISC_ADDR_SIZE);
memset((void *)eth_recv_no_cache, 0, DMA_DISC_ADDR_SIZE);
memset((void *)SEND_DATA_NO_CACHE, 0, DMA_DISC_ADDR_SIZE);
memset((void *)RECV_DATA_NO_CACHE, 0, DMA_DISC_ADDR_SIZE);
bcm271x_mbox_hardware_get_mac_address(&mac_addr[0]);
eth_dev.iobase = mac_reg_base_addr;
eth_dev.iobase = MAC_REG;
eth_dev.name = "e0";
eth_dev.dev_addr[0] = mac_addr[0];
eth_dev.dev_addr[1] = mac_addr[1];

View File

@ -11,7 +11,7 @@
SECTIONS
{
. = 0x8000;
. = 0x200000;
. = ALIGN(4096);
.text :
{

View File

@ -19,6 +19,9 @@
#define RT_USING_TIMER_SOFT
#define RT_TIMER_THREAD_PRIO 4
#define RT_TIMER_THREAD_STACK_SIZE 2048
/* kservice optimization */
#define RT_DEBUG
/* Inter-Thread communication */
@ -41,7 +44,8 @@
#define RT_USING_CONSOLE
#define RT_CONSOLEBUF_SIZE 128
#define RT_CONSOLE_DEVICE_NAME "uart1"
#define RT_VER_NUM 0x40003
#define RT_VER_NUM 0x40004
#define RT_USING_GIC_V2
#define ARCH_ARMV8
/* RT-Thread Components */
@ -84,6 +88,8 @@
#define RT_DFS_ELM_WORD_ACCESS
#define RT_DFS_ELM_USE_LFN_3
#define RT_DFS_ELM_USE_LFN 3
#define RT_DFS_ELM_LFN_UNICODE_0
#define RT_DFS_ELM_LFN_UNICODE 0
#define RT_DFS_ELM_MAX_LFN 255
#define RT_DFS_ELM_DRIVES 2
#define RT_DFS_ELM_MAX_SECTOR_SIZE 512
@ -98,6 +104,7 @@
#define RT_SYSTEM_WORKQUEUE_STACKSIZE 2048
#define RT_SYSTEM_WORKQUEUE_PRIORITY 23
#define RT_USING_SERIAL
#define RT_USING_SERIAL_V1
#define RT_SERIAL_USING_DMA
#define RT_SERIAL_RB_BUFSZ 512
#define RT_USING_I2C
@ -120,12 +127,14 @@
#define RT_USING_LIBC
#define RT_USING_POSIX
#define RT_LIBC_DEFAULT_TIMEZONE 8
/* Network */
/* Socket abstraction layer */
#define RT_USING_SAL
#define SAL_INTERNET_CHECK
/* protocol stack implement */
@ -156,8 +165,8 @@
/* Static IPv4 Address */
#define RT_LWIP_IPADDR "192.168.1.30"
#define RT_LWIP_GWADDR "192.168.1.1"
#define RT_LWIP_IPADDR "192.168.111.172"
#define RT_LWIP_GWADDR "192.168.111.1"
#define RT_LWIP_MSKADDR "255.255.255.0"
#define RT_LWIP_UDP
#define RT_LWIP_TCP
@ -195,6 +204,9 @@
/* Utilities */
/* RT-Thread Utestcases */
/* RT-Thread online packages */
/* IoT - internet of things */
@ -232,19 +244,16 @@
/* peripheral libraries and drivers */
/* AI packages */
/* miscellaneous packages */
/* samples: kernel and components samples */
/* games: games run on RT-Thread console */
/* Privated Packages of RealThread */
/* Network Utilities */
/* entertainment: terminal games and other interesting software packages */
#define BCM2711_SOC

View File

@ -37,7 +37,7 @@ if PLATFORM == 'gcc':
DEVICE = ' -march=armv8-a -mtune=cortex-a72'
CFLAGS = DEVICE + ' -Wall'
AFLAGS = ' -c' + ' -x assembler-with-cpp -D__ASSEMBLY__'
AFLAGS = ' -c' + DEVICE + ' -x assembler-with-cpp -D__ASSEMBLY__'
LFLAGS = DEVICE + ' -nostartfiles -Wl,--gc-sections,-Map=rtthread.map,-cref,-u,system_vectors -T link.lds'
CPATH = ''
LPATH = ''

View File

@ -41,9 +41,9 @@ struct rt_stm32_eth
/* interface address info, hw address */
rt_uint8_t dev_addr[MAX_ADDR_LEN];
/* ETH_Speed */
uint32_t ETH_Speed;
rt_uint32_t ETH_Speed;
/* ETH_Duplex_Mode */
uint32_t ETH_Mode;
rt_uint32_t ETH_Mode;
};
static ETH_DMADescTypeDef *DMARxDscrTab, *DMATxDscrTab;
@ -167,8 +167,14 @@ static rt_err_t rt_stm32_eth_control(rt_device_t dev, int cmd, void *args)
{
case NIOCTL_GADDR:
/* get mac address */
if (args) rt_memcpy(args, stm32_eth_device.dev_addr, 6);
else return -RT_ERROR;
if (args)
{
SMEMCPY(args, stm32_eth_device.dev_addr, 6);
}
else
{
return -RT_ERROR;
}
break;
default :
@ -214,7 +220,7 @@ rt_err_t rt_stm32_eth_tx(rt_device_t dev, struct pbuf *p)
while ((byteslefttocopy + bufferoffset) > ETH_TX_BUF_SIZE)
{
/* Copy data to Tx buffer*/
memcpy((uint8_t *)((uint8_t *)buffer + bufferoffset), (uint8_t *)((uint8_t *)q->payload + payloadoffset), (ETH_TX_BUF_SIZE - bufferoffset));
SMEMCPY((uint8_t *)((uint8_t *)buffer + bufferoffset), (uint8_t *)((uint8_t *)q->payload + payloadoffset), (ETH_TX_BUF_SIZE - bufferoffset));
/* Point to next descriptor */
DmaTxDesc = (ETH_DMADescTypeDef *)(DmaTxDesc->Buffer2NextDescAddr);
@ -236,7 +242,7 @@ rt_err_t rt_stm32_eth_tx(rt_device_t dev, struct pbuf *p)
}
/* Copy the remaining bytes */
memcpy((uint8_t *)((uint8_t *)buffer + bufferoffset), (uint8_t *)((uint8_t *)q->payload + payloadoffset), byteslefttocopy);
SMEMCPY((uint8_t *)((uint8_t *)buffer + bufferoffset), (uint8_t *)((uint8_t *)q->payload + payloadoffset), byteslefttocopy);
bufferoffset = bufferoffset + byteslefttocopy;
framelength = framelength + byteslefttocopy;
}
@ -327,7 +333,7 @@ struct pbuf *rt_stm32_eth_rx(rt_device_t dev)
while ((byteslefttocopy + bufferoffset) > ETH_RX_BUF_SIZE)
{
/* Copy data to pbuf */
memcpy((uint8_t *)((uint8_t *)q->payload + payloadoffset), (uint8_t *)((uint8_t *)buffer + bufferoffset), (ETH_RX_BUF_SIZE - bufferoffset));
SMEMCPY((uint8_t *)((uint8_t *)q->payload + payloadoffset), (uint8_t *)((uint8_t *)buffer + bufferoffset), (ETH_RX_BUF_SIZE - bufferoffset));
/* Point to next descriptor */
dmarxdesc = (ETH_DMADescTypeDef *)(dmarxdesc->Buffer2NextDescAddr);
@ -338,7 +344,7 @@ struct pbuf *rt_stm32_eth_rx(rt_device_t dev)
bufferoffset = 0;
}
/* Copy remaining data in pbuf */
memcpy((uint8_t *)((uint8_t *)q->payload + payloadoffset), (uint8_t *)((uint8_t *)buffer + bufferoffset), byteslefttocopy);
SMEMCPY((uint8_t *)((uint8_t *)q->payload + payloadoffset), (uint8_t *)((uint8_t *)buffer + bufferoffset), byteslefttocopy);
bufferoffset = bufferoffset + byteslefttocopy;
}
}
@ -385,7 +391,9 @@ void HAL_ETH_RxCpltCallback(ETH_HandleTypeDef *heth)
rt_err_t result;
result = eth_device_ready(&(stm32_eth_device.parent));
if (result != RT_EOK)
{
LOG_I("RxCpltCallback err = %d", result);
}
}
void HAL_ETH_ErrorCallback(ETH_HandleTypeDef *heth)

View File

@ -28,13 +28,12 @@
/* The PHY ID one register */
#define PHY_ID1_REG 0x02U
/* The PHY ID two register */
#define PHY_ID2_REG 0x03U
/* The PHY auto-negotiate advertise register */
#define PHY_AUTONEG_ADVERTISE_REG 0x04U
#ifdef PHY_USING_LAN8720A
/* The PHY interrupt source flag register. */
#define PHY_INTERRUPT_FLAG_REG 0x1DU
@ -51,9 +50,8 @@
#define PHY_Status_SPEED_10M(sr) ((sr) & PHY_10M_MASK)
#define PHY_Status_SPEED_100M(sr) ((sr) & PHY_100M_MASK)
#define PHY_Status_FULL_DUPLEX(sr) ((sr) & PHY_FULL_DUPLEX_MASK)
#endif /* PHY_USING_LAN8720A */
#ifdef PHY_USING_DM9161CEP
#elif defined(PHY_USING_DM9161CEP)
#define PHY_Status_REG 0x11U
#define PHY_10M_MASK ((1<<12) || (1<<13))
#define PHY_100M_MASK ((1<<14) || (1<<15))
@ -69,9 +67,7 @@
#define PHY_LINK_CHANGE_MASK (1<<9)
#define PHY_INT_MASK 0
#endif /* PHY_USING_DM9161CEP */
#ifdef PHY_USING_DP83848C
#elif defined(PHY_USING_DP83848C)
#define PHY_Status_REG 0x10U
#define PHY_10M_MASK (1<<1)
#define PHY_FULL_DUPLEX_MASK (1<<2)
@ -87,6 +83,6 @@
/* The PHY interrupt mask register. */
#define PHY_INTERRUPT_MASK_REG 0x12U
#define PHY_INT_MASK (1<<5)
#endif /* PHY_USING_DP83848C */
#endif
#endif /* __DRV_ETH_H__ */

View File

@ -265,8 +265,8 @@ static rt_err_t stm32_rtc_set_secs(void *args)
static const struct rt_rtc_ops stm32_rtc_ops =
{
stm32_rtc_init,
stm32_rtc_get_secs, /* get_secs */
stm32_rtc_set_secs, /* set secs */
stm32_rtc_get_secs,
stm32_rtc_set_secs,
RT_NULL,
RT_NULL,
RT_NULL,
@ -280,7 +280,7 @@ static int rt_hw_rtc_init(void)
rt_err_t result;
stm32_rtc_dev.ops = &stm32_rtc_ops;
result = rt_rtc_dev_register(&stm32_rtc_dev, "rtc", RT_DEVICE_FLAG_RDWR, RT_NULL);
result = rt_hw_rtc_register(&stm32_rtc_dev, "rtc", RT_DEVICE_FLAG_RDWR, RT_NULL);
if (result != RT_EOK)
{
LOG_E("rtc register err code: %d", result);

View File

@ -21,6 +21,12 @@ CONFIG_RT_USING_IDLE_HOOK=y
CONFIG_RT_IDLE_HOOK_LIST_SIZE=4
CONFIG_IDLE_THREAD_STACK_SIZE=1024
# CONFIG_RT_USING_TIMER_SOFT is not set
#
# kservice optimization
#
# CONFIG_RT_KSERVICE_USING_STDLIB is not set
# CONFIG_RT_KSERVICE_USING_TINY_SIZE is not set
CONFIG_RT_DEBUG=y
CONFIG_RT_DEBUG_COLOR=y
# CONFIG_RT_DEBUG_INIT_CONFIG is not set
@ -52,6 +58,7 @@ CONFIG_RT_USING_MEMPOOL=y
# CONFIG_RT_USING_NOHEAP is not set
CONFIG_RT_USING_SMALL_MEM=y
# CONFIG_RT_USING_SLAB is not set
# CONFIG_RT_USING_USERHEAP is not set
# CONFIG_RT_USING_MEMTRACE is not set
CONFIG_RT_USING_HEAP=y
@ -64,7 +71,8 @@ CONFIG_RT_USING_DEVICE=y
CONFIG_RT_USING_CONSOLE=y
CONFIG_RT_CONSOLEBUF_SIZE=128
CONFIG_RT_CONSOLE_DEVICE_NAME="uart1"
CONFIG_RT_VER_NUM=0x40002
# CONFIG_RT_PRINTF_LONGLONG is not set
CONFIG_RT_VER_NUM=0x40004
CONFIG_ARCH_ARM=y
CONFIG_RT_USING_CPU_FFS=y
CONFIG_ARCH_ARM_CORTEX_M=y
@ -115,18 +123,21 @@ CONFIG_RT_USING_DEVICE_IPC=y
CONFIG_RT_PIPE_BUFSZ=512
# CONFIG_RT_USING_SYSTEM_WORKQUEUE is not set
CONFIG_RT_USING_SERIAL=y
CONFIG_RT_USING_SERIAL_V1=y
# CONFIG_RT_USING_SERIAL_V2 is not set
CONFIG_RT_SERIAL_USING_DMA=y
CONFIG_RT_SERIAL_RB_BUFSZ=64
# CONFIG_RT_USING_CAN is not set
# CONFIG_RT_USING_HWTIMER is not set
# CONFIG_RT_USING_CPUTIME is not set
# CONFIG_RT_USING_I2C is not set
# CONFIG_RT_USING_PHY is not set
CONFIG_RT_USING_PIN=y
# CONFIG_RT_USING_ADC is not set
# CONFIG_RT_USING_DAC is not set
# CONFIG_RT_USING_PWM is not set
# CONFIG_RT_USING_MTD_NOR is not set
# CONFIG_RT_USING_MTD_NAND is not set
# CONFIG_RT_USING_MTD is not set
# CONFIG_RT_USING_PM is not set
# CONFIG_RT_USING_RTC is not set
# CONFIG_RT_USING_SDIO is not set
@ -134,15 +145,10 @@ CONFIG_RT_USING_PIN=y
# CONFIG_RT_USING_WDT is not set
# CONFIG_RT_USING_AUDIO is not set
# CONFIG_RT_USING_SENSOR is not set
#
# Using Hardware Crypto drivers
#
# CONFIG_RT_USING_TOUCH is not set
# CONFIG_RT_USING_HWCRYPTO is not set
#
# Using WiFi
#
# CONFIG_RT_USING_PULSE_ENCODER is not set
# CONFIG_RT_USING_INPUT_CAPTURE is not set
# CONFIG_RT_USING_WIFI is not set
#
@ -156,6 +162,8 @@ CONFIG_RT_USING_PIN=y
#
# CONFIG_RT_USING_LIBC is not set
# CONFIG_RT_USING_PTHREADS is not set
CONFIG_RT_LIBC_USING_TIME=y
CONFIG_RT_LIBC_DEFAULT_TIMEZONE=8
#
# Network
@ -176,11 +184,6 @@ CONFIG_RT_USING_PIN=y
#
# CONFIG_RT_USING_LWIP is not set
#
# Modbus master and slave stack
#
# CONFIG_RT_USING_MODBUS is not set
#
# AT commands
#
@ -197,8 +200,14 @@ CONFIG_RT_USING_PIN=y
# CONFIG_RT_USING_RYM is not set
# CONFIG_RT_USING_ULOG is not set
# CONFIG_RT_USING_UTEST 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
#
@ -206,14 +215,20 @@ CONFIG_RT_USING_PIN=y
#
# IoT - internet of things
#
# CONFIG_PKG_USING_LORAWAN_DRIVER is not set
# CONFIG_PKG_USING_PAHOMQTT is not set
# CONFIG_PKG_USING_UMQTT is not set
# CONFIG_PKG_USING_WEBCLIENT is not set
# CONFIG_PKG_USING_WEBNET is not set
# CONFIG_PKG_USING_MONGOOSE is not set
# CONFIG_PKG_USING_MYMQTT is not set
# CONFIG_PKG_USING_KAWAII_MQTT is not set
# CONFIG_PKG_USING_BC28_MQTT is not set
# CONFIG_PKG_USING_WEBTERMINAL is not set
# CONFIG_PKG_USING_CJSON is not set
# CONFIG_PKG_USING_JSMN is not set
# CONFIG_PKG_USING_LIBMODBUS is not set
# CONFIG_PKG_USING_FREEMODBUS is not set
# CONFIG_PKG_USING_LJSON is not set
# CONFIG_PKG_USING_EZXML is not set
# CONFIG_PKG_USING_NANOPB is not set
@ -235,6 +250,8 @@ CONFIG_RT_USING_PIN=y
# CONFIG_PKG_USING_COAP is not set
# CONFIG_PKG_USING_NOPOLL is not set
# CONFIG_PKG_USING_NETUTILS is not set
# CONFIG_PKG_USING_CMUX is not set
# CONFIG_PKG_USING_PPP_DEVICE is not set
# CONFIG_PKG_USING_AT_DEVICE is not set
# CONFIG_PKG_USING_ATSRV_SOCKET is not set
# CONFIG_PKG_USING_WIZNET is not set
@ -246,12 +263,38 @@ CONFIG_RT_USING_PIN=y
# CONFIG_PKG_USING_GAGENT_CLOUD is not set
# CONFIG_PKG_USING_ALI_IOTKIT is not set
# CONFIG_PKG_USING_AZURE is not set
# CONFIG_PKG_USING_TENCENT_IOTKIT is not set
# CONFIG_PKG_USING_TENCENT_IOT_EXPLORER is not set
# CONFIG_PKG_USING_JIOT-C-SDK is not set
# CONFIG_PKG_USING_UCLOUD_IOT_SDK is not set
# CONFIG_PKG_USING_JOYLINK is not set
# CONFIG_PKG_USING_NIMBLE is not set
# CONFIG_PKG_USING_OTA_DOWNLOADER is not set
# CONFIG_PKG_USING_IPMSG is not set
# CONFIG_PKG_USING_LSSDP is not set
# CONFIG_PKG_USING_AIRKISS_OPEN is not set
# CONFIG_PKG_USING_LIBRWS is not set
# CONFIG_PKG_USING_TCPSERVER is not set
# CONFIG_PKG_USING_PROTOBUF_C is not set
# CONFIG_PKG_USING_DLT645 is not set
# CONFIG_PKG_USING_QXWZ is not set
# CONFIG_PKG_USING_SMTP_CLIENT is not set
# CONFIG_PKG_USING_ABUP_FOTA is not set
# CONFIG_PKG_USING_LIBCURL2RTT is not set
# CONFIG_PKG_USING_CAPNP is not set
# CONFIG_PKG_USING_RT_CJSON_TOOLS is not set
# CONFIG_PKG_USING_AGILE_TELNET is not set
# CONFIG_PKG_USING_NMEALIB is not set
# CONFIG_PKG_USING_AGILE_JSMN is not set
# CONFIG_PKG_USING_PDULIB is not set
# CONFIG_PKG_USING_BTSTACK is not set
# CONFIG_PKG_USING_LORAWAN_ED_STACK is not set
# CONFIG_PKG_USING_WAYZ_IOTKIT is not set
# CONFIG_PKG_USING_MAVLINK is not set
# CONFIG_PKG_USING_RAPIDJSON is not set
# CONFIG_PKG_USING_BSAL is not set
# CONFIG_PKG_USING_AGILE_MODBUS is not set
# CONFIG_PKG_USING_AGILE_FTP is not set
# CONFIG_PKG_USING_EMBEDDEDPROTO is not set
#
# security packages
@ -259,6 +302,8 @@ CONFIG_RT_USING_PIN=y
# CONFIG_PKG_USING_MBEDTLS is not set
# CONFIG_PKG_USING_libsodium is not set
# CONFIG_PKG_USING_TINYCRYPT is not set
# CONFIG_PKG_USING_TFM is not set
# CONFIG_PKG_USING_YD_CRYPTO is not set
#
# language packages
@ -273,6 +318,13 @@ CONFIG_RT_USING_PIN=y
# CONFIG_PKG_USING_OPENMV is not set
# CONFIG_PKG_USING_MUPDF is not set
# CONFIG_PKG_USING_STEMWIN is not set
# CONFIG_PKG_USING_WAVPLAYER is not set
# CONFIG_PKG_USING_TJPGD is not set
# CONFIG_PKG_USING_PDFGEN is not set
# CONFIG_PKG_USING_HELIX is not set
# CONFIG_PKG_USING_AZUREGUIX is not set
# CONFIG_PKG_USING_TOUCHGFX2RTT is not set
# CONFIG_PKG_USING_NUEMWIN is not set
#
# tools packages
@ -284,7 +336,36 @@ CONFIG_RT_USING_PIN=y
# CONFIG_PKG_USING_RDB is not set
# CONFIG_PKG_USING_QRCODE is not set
# CONFIG_PKG_USING_ULOG_EASYFLASH is not set
# CONFIG_PKG_USING_ULOG_FILE is not set
# CONFIG_PKG_USING_LOGMGR is not set
# CONFIG_PKG_USING_ADBD is not set
# CONFIG_PKG_USING_COREMARK is not set
# CONFIG_PKG_USING_DHRYSTONE is not set
# CONFIG_PKG_USING_MEMORYPERF is not set
# CONFIG_PKG_USING_NR_MICRO_SHELL is not set
# CONFIG_PKG_USING_CHINESE_FONT_LIBRARY is not set
# CONFIG_PKG_USING_LUNAR_CALENDAR is not set
# 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 is not set
# CONFIG_PKG_USING_SOLAR_TERMS is not set
# CONFIG_PKG_USING_GAN_ZHI is not set
#
# system packages
@ -293,16 +374,47 @@ CONFIG_RT_USING_PIN=y
# CONFIG_PKG_USING_PERSIMMON is not set
# CONFIG_PKG_USING_CAIRO is not set
# CONFIG_PKG_USING_PIXMAN is not set
# CONFIG_PKG_USING_LWEXT4 is not set
# CONFIG_PKG_USING_PARTITION is not set
# CONFIG_PKG_USING_FAL is not set
# CONFIG_PKG_USING_FLASHDB is not set
# CONFIG_PKG_USING_SQLITE is not set
# CONFIG_PKG_USING_RTI is not set
# CONFIG_PKG_USING_LITTLEVGL2RTT 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
# CONFIG_PKG_USING_DFS_UFFS is not set
# CONFIG_PKG_USING_LWEXT4 is not set
# CONFIG_PKG_USING_THREAD_POOL is not set
# CONFIG_PKG_USING_ROBOTS is not set
# CONFIG_PKG_USING_EV is not set
# CONFIG_PKG_USING_SYSWATCH is not set
# CONFIG_PKG_USING_SYS_LOAD_MONITOR is not set
# CONFIG_PKG_USING_PLCCORE is not set
# CONFIG_PKG_USING_RAMDISK is not set
# CONFIG_PKG_USING_MININI is not set
# CONFIG_PKG_USING_QBOOT is not set
#
# Micrium: Micrium software products porting for RT-Thread
#
# CONFIG_PKG_USING_UCOSIII_WRAPPER is not set
# CONFIG_PKG_USING_UCOSII_WRAPPER is not set
# CONFIG_PKG_USING_UC_CRC is not set
# CONFIG_PKG_USING_UC_CLK is not set
# CONFIG_PKG_USING_UC_COMMON is not set
# CONFIG_PKG_USING_UC_MODBUS is not set
# CONFIG_PKG_USING_PPOOL is not set
# CONFIG_PKG_USING_OPENAMP is not set
# CONFIG_PKG_USING_RT_KPRINTF_THREADSAFE is not set
# CONFIG_PKG_USING_RT_MEMCPY_CM is not set
# CONFIG_PKG_USING_QFPLIB_M0_FULL is not set
# CONFIG_PKG_USING_QFPLIB_M0_TINY is not set
# CONFIG_PKG_USING_QFPLIB_M3 is not set
# CONFIG_PKG_USING_LPM is not set
# CONFIG_PKG_USING_TLSF is not set
# CONFIG_PKG_USING_EVENT_RECORDER is not set
#
# peripheral libraries and drivers
@ -310,7 +422,8 @@ CONFIG_RT_USING_PIN=y
# CONFIG_PKG_USING_SENSORS_DRIVERS is not set
# CONFIG_PKG_USING_REALTEK_AMEBA is not set
# CONFIG_PKG_USING_SHT2X is not set
# CONFIG_PKG_USING_AP3216C is not set
# CONFIG_PKG_USING_SHT3X is not set
# CONFIG_PKG_USING_AS7341 is not set
# CONFIG_PKG_USING_STM32_SDIO is not set
# CONFIG_PKG_USING_ICM20608 is not set
# CONFIG_PKG_USING_U8G2 is not set
@ -319,15 +432,70 @@ CONFIG_RT_USING_PIN=y
# CONFIG_PKG_USING_SX12XX is not set
# CONFIG_PKG_USING_SIGNAL_LED is not set
# CONFIG_PKG_USING_LEDBLINK is not set
# CONFIG_PKG_USING_LITTLED is not set
# CONFIG_PKG_USING_LKDGUI is not set
# CONFIG_PKG_USING_NRF5X_SDK is not set
# CONFIG_PKG_USING_NRFX is not set
# CONFIG_PKG_USING_WM_LIBRARIES is not set
# CONFIG_PKG_USING_KENDRYTE_SDK is not set
# CONFIG_PKG_USING_INFRARED is not set
# CONFIG_PKG_USING_ROSSERIAL is not set
# CONFIG_PKG_USING_AGILE_BUTTON is not set
# CONFIG_PKG_USING_AGILE_LED is not set
# CONFIG_PKG_USING_AT24CXX is not set
# CONFIG_PKG_USING_MOTIONDRIVER2RTT is not set
# CONFIG_PKG_USING_AD7746 is not set
# CONFIG_PKG_USING_PCA9685 is not set
# CONFIG_PKG_USING_I2C_TOOLS is not set
# CONFIG_PKG_USING_NRF24L01 is not set
# CONFIG_PKG_USING_TOUCH_DRIVERS is not set
# CONFIG_PKG_USING_MAX17048 is not set
# CONFIG_PKG_USING_RPLIDAR is not set
# CONFIG_PKG_USING_AS608 is not set
# CONFIG_PKG_USING_RC522 is not set
# CONFIG_PKG_USING_WS2812B is not set
# CONFIG_PKG_USING_EMBARC_BSP is not set
# CONFIG_PKG_USING_EXTERN_RTC_DRIVERS is not set
# CONFIG_PKG_USING_MULTI_RTIMER is not set
# CONFIG_PKG_USING_MAX7219 is not set
# CONFIG_PKG_USING_BEEP is not set
# CONFIG_PKG_USING_EASYBLINK is not set
# CONFIG_PKG_USING_PMS_SERIES is not set
# CONFIG_PKG_USING_CAN_YMODEM is not set
# CONFIG_PKG_USING_LORA_RADIO_DRIVER is not set
# CONFIG_PKG_USING_QLED is not set
# CONFIG_PKG_USING_PAJ7620 is not set
# CONFIG_PKG_USING_AGILE_CONSOLE is not set
# CONFIG_PKG_USING_LD3320 is not set
# CONFIG_PKG_USING_WK2124 is not set
# CONFIG_PKG_USING_LY68L6400 is not set
# CONFIG_PKG_USING_DM9051 is not set
# CONFIG_PKG_USING_SSD1306 is not set
# CONFIG_PKG_USING_QKEY is not set
# CONFIG_PKG_USING_RS485 is not set
# CONFIG_PKG_USING_NES is not set
# CONFIG_PKG_USING_VIRTUAL_SENSOR is not set
# CONFIG_PKG_USING_VDEVICE is not set
# CONFIG_PKG_USING_SGM706 is not set
# CONFIG_PKG_USING_STM32WB55_SDK is not set
# CONFIG_PKG_USING_RDA58XX is not set
# CONFIG_PKG_USING_LIBNFC is not set
# CONFIG_PKG_USING_MFOC is not set
# CONFIG_PKG_USING_TMC51XX is not set
# CONFIG_PKG_USING_TCA9534 is not set
#
# AI packages
#
# CONFIG_PKG_USING_LIBANN is not set
# CONFIG_PKG_USING_NNOM is not set
# CONFIG_PKG_USING_ONNX_BACKEND is not set
# CONFIG_PKG_USING_ONNX_PARSER is not set
# CONFIG_PKG_USING_TENSORFLOWLITEMICRO is not set
# CONFIG_PKG_USING_ELAPACK is not set
# CONFIG_PKG_USING_ULAPACK is not set
# CONFIG_PKG_USING_QUEST is not set
# CONFIG_PKG_USING_NAXOS is not set
#
# miscellaneous packages
@ -337,13 +505,18 @@ CONFIG_RT_USING_PIN=y
# CONFIG_PKG_USING_FASTLZ is not set
# CONFIG_PKG_USING_MINILZO is not set
# CONFIG_PKG_USING_QUICKLZ is not set
# CONFIG_PKG_USING_LZMA is not set
# CONFIG_PKG_USING_MULTIBUTTON is not set
# CONFIG_PKG_USING_FLEXIBLE_BUTTON is not set
# CONFIG_PKG_USING_CANFESTIVAL is not set
# CONFIG_PKG_USING_ZLIB is not set
# CONFIG_PKG_USING_MINIZIP is not set
# CONFIG_PKG_USING_DSTR is not set
# CONFIG_PKG_USING_TINYFRAME is not set
# CONFIG_PKG_USING_KENDRYTE_DEMO is not set
# CONFIG_PKG_USING_DIGITALCTRL is not set
# CONFIG_PKG_USING_UPACKER is not set
# CONFIG_PKG_USING_UPARAM is not set
#
# samples: kernel and components samples
@ -354,7 +527,25 @@ CONFIG_RT_USING_PIN=y
# CONFIG_PKG_USING_PERIPHERAL_SAMPLES is not set
# CONFIG_PKG_USING_HELLO is not set
# CONFIG_PKG_USING_VI is not set
# CONFIG_PKG_USING_NNOM 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
# CONFIG_PKG_USING_UKAL is not set
# CONFIG_PKG_USING_CRCLIB is not set
#
# entertainment: terminal games and other interesting software packages
#
# CONFIG_PKG_USING_THREES is not set
# CONFIG_PKG_USING_2048 is not set
# CONFIG_PKG_USING_SNAKE is not set
# CONFIG_PKG_USING_TETRIS is not set
# CONFIG_PKG_USING_DONUT is not set
# CONFIG_PKG_USING_ACLOCK is not set
# CONFIG_PKG_USING_LWGPS is not set
# CONFIG_PKG_USING_STATE_MACHINE is not set
# CONFIG_PKG_USING_MCURSES is not set
# CONFIG_PKG_USING_COWSAY is not set
CONFIG_SOC_FAMILY_STM32=y
CONFIG_SOC_SERIES_STM32F4=y
@ -369,11 +560,12 @@ CONFIG_SOC_STM32F407ZG=y
CONFIG_BSP_USING_USB_TO_USART=y
# CONFIG_BSP_USING_COM2 is not set
# CONFIG_BSP_USING_COM3 is not set
# CONFIG_BSP_USING_SRAM is not set
# CONFIG_BSP_USING_SPI_FLASH is not set
# CONFIG_BSP_USING_EEPROM is not set
# CONFIG_BSP_USING_ETH is not set
# CONFIG_BSP_USING_MPU6050 is not set
# CONFIG_BSP_USING_SDCARD is not set
# CONFIG_BSP_USING_FS is not set
#
# On-chip Peripheral Drivers
@ -394,9 +586,17 @@ CONFIG_BSP_USING_UART1=y
# CONFIG_BSP_USING_SPI is not set
# CONFIG_BSP_USING_ADC is not set
# CONFIG_BSP_USING_I2C1 is not set
# CONFIG_BSP_USING_DAC is not set
# CONFIG_BSP_USING_ONCHIP_RTC is not set
# CONFIG_BSP_USING_WDT is not set
# CONFIG_BSP_USING_SDIO is not set
# CONFIG_BSP_USING_USBD is not set
# CONFIG_BSP_USING_USBH is not set
# CONFIG_BSP_USING_PULSE_ENCODER is not set
# CONFIG_BSP_USING_EXT_FMC_IO is not set
# CONFIG_BSP_USING_FMC is not set
# CONFIG_BSP_USING_RNG is not set
# CONFIG_BSP_USING_UDID is not set
#
# Board extended module Drivers

View File

@ -71,18 +71,27 @@ menu "Onboard Peripheral Drivers"
select BSP_USING_I2C1
select PKG_USING_MPU6XXX
config BSP_USING_SDCARD
bool "Enable SDCARD (sdio)"
select BSP_USING_SDIO
select RT_USING_DFS
select RT_USING_DFS_ELMFAT
default n
menu "Enable File System"
config BSP_USING_FS
bool
default n
config SDIO_MAX_FREQ
int "sdio max freq"
range 0 24000000
depends on BSP_USING_SDCARD
default 1000000
config BSP_USING_SDCARD
bool "Enable SDCARD (FATFS)"
select BSP_USING_SDIO
select RT_USING_DFS
select RT_USING_DFS_ELMFAT
select RT_USING_DFS_ROMFS
select BSP_USING_FS
select RT_USING_SYSTEM_WORKQUEUE
default n
config SDIO_MAX_FREQ
int "sdio max freq"
range 0 24000000
depends on BSP_USING_SDCARD
default 1000000
endmenu
endmenu

View File

@ -18,8 +18,8 @@ if GetDepend(['BSP_USING_ETH']):
if GetDepend(['BSP_USING_SPI_FLASH']):
src += Glob('ports/spi_flash_init.c')
if GetDepend(['BSP_USING_SDCARD']):
src += Glob('ports/drv_sdcard.c')
if GetDepend(['BSP_USING_FS']):
src += Glob('ports/drv_filesystem.c')
if GetDepend(['BSP_USING_SRAM']):
src += Glob('ports/drv_sram.c')

View File

@ -0,0 +1,105 @@
/*
* Copyright (c) 2006-2021, RT-Thread Development Team
*
* SPDX-License-Identifier: Apache-2.0
*
* Change Logs:
* Date Author Notes
* 2018-12-13 balanceTWK add sdcard port file
* 2021-05-10 Meco Man fix a bug that cannot use fatfs in the main thread at starting up
* 2021-07-28 Meco Man implement romfs as the root filesystem
*/
#include <rtthread.h>
#ifdef BSP_USING_FS
#include <dfs_romfs.h>
#include <dfs_fs.h>
#include <dfs_posix.h>
#if DFS_FILESYSTEMS_MAX < 4
#error "Please define DFS_FILESYSTEMS_MAX more than 4"
#endif
#if DFS_FILESYSTEM_TYPES_MAX < 4
#error "Please define DFS_FILESYSTEM_TYPES_MAX more than 4"
#endif
#define DBG_TAG "app.filesystem"
#define DBG_LVL DBG_INFO
#include <rtdbg.h>
#ifdef BSP_USING_SDCARD
static void sd_mount(void *parameter)
{
while (1)
{
rt_thread_mdelay(500);
if(rt_device_find("sd0") != RT_NULL)
{
if (dfs_mount("sd0", "/sdcard", "elm", 0, 0) == RT_EOK)
{
LOG_I("sd card mount to '/sdcard'");
break;
}
else
{
LOG_W("sd card mount to '/sdcard' failed!");
}
}
}
}
static int onboard_sdcard_mount(void)
{
rt_thread_t tid;
if (dfs_mount("sd0", "/sdcard", "elm", 0, 0) == RT_EOK)
{
LOG_I("sd card mount to '/sdcard'");
}
else
{
tid = rt_thread_create("sd_mount", sd_mount, RT_NULL,
1024, RT_THREAD_PRIORITY_MAX - 2, 20);
if (tid != RT_NULL)
{
rt_thread_startup(tid);
}
else
{
LOG_E("create sd_mount thread err!");
}
}
return RT_EOK;
}
#endif
static const struct romfs_dirent _romfs_root[] =
{
#ifdef BSP_USING_SDCARD
{ROMFS_DIRENT_DIR, "sdcard", RT_NULL, 0},
#endif
// {ROMFS_DIRENT_DIR, "flash", RT_NULL, 0},
};
const struct romfs_dirent romfs_root =
{
ROMFS_DIRENT_DIR, "/", (rt_uint8_t *)_romfs_root, sizeof(_romfs_root) / sizeof(_romfs_root[0])
};
static int filesystem_mount(void)
{
if (dfs_mount(RT_NULL, "/", "rom", 0, &(romfs_root)) != 0)
{
LOG_E("rom mount to '/' failed!");
}
#ifdef BSP_USING_SDCARD
onboard_sdcard_mount();
#endif
return RT_EOK;
}
INIT_APP_EXPORT(filesystem_mount);
#endif /* BSP_USING_FS */

View File

@ -1,70 +0,0 @@
/*
* Copyright (c) 2006-2021, RT-Thread Development Team
*
* SPDX-License-Identifier: Apache-2.0
*
* Change Logs:
* Date Author Notes
* 2018-12-13 balanceTWK add sdcard port file
* 2021-05-10 Meco Man fix a bug that cannot use fatfs in the main thread at starting up
*/
#include <rtthread.h>
#ifdef BSP_USING_SDCARD
#include <dfs_elm.h>
#include <dfs_fs.h>
#include <dfs_posix.h>
#define DBG_TAG "app.card"
#define DBG_LVL DBG_INFO
#include <rtdbg.h>
static void sd_mount(void *parameter)
{
while (1)
{
rt_thread_mdelay(500);
if(rt_device_find("sd0") != RT_NULL)
{
if (dfs_mount("sd0", "/", "elm", 0, 0) == RT_EOK)
{
LOG_I("sd card mount to '/'");
break;
}
else
{
LOG_W("sd card mount to '/' failed!");
}
}
}
}
static int onboard_sdcard_mount(void)
{
rt_thread_t tid;
if (dfs_mount("sd0", "/", "elm", 0, 0) == RT_EOK)
{
LOG_I("sd card mount to '/'");
}
else
{
tid = rt_thread_create("sd_mount", sd_mount, RT_NULL,
1024, RT_THREAD_PRIORITY_MAX - 2, 20);
if (tid != RT_NULL)
{
rt_thread_startup(tid);
}
else
{
LOG_E("create sd_mount thread err!");
}
}
return RT_EOK;
}
INIT_APP_EXPORT(onboard_sdcard_mount);
#endif /* BSP_USING_SDCARD */

View File

@ -16,6 +16,9 @@
#define RT_USING_IDLE_HOOK
#define RT_IDLE_HOOK_LIST_SIZE 4
#define IDLE_THREAD_STACK_SIZE 1024
/* kservice optimization */
#define RT_DEBUG
#define RT_DEBUG_COLOR
@ -39,7 +42,7 @@
#define RT_USING_CONSOLE
#define RT_CONSOLEBUF_SIZE 128
#define RT_CONSOLE_DEVICE_NAME "uart1"
#define RT_VER_NUM 0x40002
#define RT_VER_NUM 0x40004
#define ARCH_ARM
#define RT_USING_CPU_FFS
#define ARCH_ARM_CORTEX_M
@ -79,21 +82,18 @@
#define RT_USING_DEVICE_IPC
#define RT_PIPE_BUFSZ 512
#define RT_USING_SERIAL
#define RT_USING_SERIAL_V1
#define RT_SERIAL_USING_DMA
#define RT_SERIAL_RB_BUFSZ 64
#define RT_USING_PIN
/* Using Hardware Crypto drivers */
/* Using WiFi */
/* Using USB */
/* POSIX layer and C standard library */
#define RT_LIBC_USING_TIME
#define RT_LIBC_DEFAULT_TIMEZONE 8
/* Network */
@ -106,9 +106,6 @@
/* light weight TCP/IP stack */
/* Modbus master and slave stack */
/* AT commands */
@ -118,6 +115,9 @@
/* Utilities */
/* RT-Thread Utestcases */
/* RT-Thread online packages */
/* IoT - internet of things */
@ -149,14 +149,23 @@
/* system packages */
/* Micrium: Micrium software products porting for RT-Thread */
/* peripheral libraries and drivers */
/* AI packages */
/* miscellaneous packages */
/* samples: kernel and components samples */
/* entertainment: terminal games and other interesting software packages */
#define SOC_FAMILY_STM32
#define SOC_SERIES_STM32F4

View File

@ -10,7 +10,7 @@
#ifndef DFS_SELECT_H__
#define DFS_SELECT_H__
#include <libc/libc_fdset.h>
#include <sys/select.h>
#ifdef __cplusplus
extern "C" {

View File

@ -234,7 +234,6 @@ struct rt_mmcsd_host *mmcsd_alloc_host(void);
void mmcsd_free_host(struct rt_mmcsd_host *host);
int rt_mmcsd_core_init(void);
int rt_mmcsd_blk_init(void);
rt_int32_t rt_mmcsd_blk_probe(struct rt_mmcsd_card *card);
void rt_mmcsd_blk_remove(struct rt_mmcsd_card *card);

View File

@ -6,13 +6,43 @@
* Change Logs:
* Date Author Notes
* 2012-10-10 aozima first version.
* 2021-06-11 iysheng implement RTC framework V2.0
* 2021-07-30 Meco Man move rtc_core.h to rtc.h
*/
#ifndef __RTC_H__
#define __RTC_H__
#include <rtconfig.h>
#include <drivers/rtc_core.h>
#include <rtdef.h>
#define RT_DEVICE_CTRL_RTC_GET_TIME 0x10 /**< get second time */
#define RT_DEVICE_CTRL_RTC_SET_TIME 0x11 /**< set second time */
#define RT_DEVICE_CTRL_RTC_GET_TIME_US 0x12 /**< get microsecond time */
#define RT_DEVICE_CTRL_RTC_SET_TIME_US 0x13 /**< set microsecond time */
#define RT_DEVICE_CTRL_RTC_GET_ALARM 0x14 /**< get alarm */
#define RT_DEVICE_CTRL_RTC_SET_ALARM 0x15 /**< set alarm */
struct rt_rtc_ops
{
rt_err_t (*init)(void);
rt_err_t (*get_secs)(void *arg);
rt_err_t (*set_secs)(void *arg);
rt_err_t (*get_alarm)(void *arg);
rt_err_t (*set_alarm)(void *arg);
rt_err_t (*get_usecs)(void *arg);
rt_err_t (*set_usecs)(void *arg);
};
typedef struct rt_rtc_device
{
struct rt_device parent;
const struct rt_rtc_ops *ops;
} rt_rtc_dev_t;
rt_err_t rt_hw_rtc_register(rt_rtc_dev_t *rtc,
const char *name,
rt_uint32_t flag,
void *data);
rt_err_t set_date(rt_uint32_t year, rt_uint32_t month, rt_uint32_t day);
rt_err_t set_time(rt_uint32_t hour, rt_uint32_t minute, rt_uint32_t second);

View File

@ -1,45 +0,0 @@
/*
* Copyright (c) 2006-2021, RT-Thread Development Team
*
* SPDX-License-Identifier: Apache-2.0
*
* Change Logs:
* Date Author Notes
* 2021-06-11 iysheng first version.
*/
#ifndef __RTC_CORE_H__
#define __RTC_CORE_H__
#include <rtthread.h>
#define RT_DEVICE_CTRL_RTC_GET_TIME 0x10 /**< get second time */
#define RT_DEVICE_CTRL_RTC_SET_TIME 0x11 /**< set second time */
#define RT_DEVICE_CTRL_RTC_GET_TIME_US 0x12 /**< get microsecond time */
#define RT_DEVICE_CTRL_RTC_SET_TIME_US 0x13 /**< set microsecond time */
#define RT_DEVICE_CTRL_RTC_GET_ALARM 0x14 /**< get alarm */
#define RT_DEVICE_CTRL_RTC_SET_ALARM 0x15 /**< set alarm */
struct rt_rtc_ops
{
rt_err_t (*init)(void);
rt_err_t (*get_secs)(void *arg);
rt_err_t (*set_secs)(void *arg);
rt_err_t (*get_alarm)(void *arg);
rt_err_t (*set_alarm)(void *arg);
rt_err_t (*get_usecs)(void *arg);
rt_err_t (*set_usecs)(void *arg);
};
typedef struct rt_rtc_device
{
struct rt_device parent;
const struct rt_rtc_ops *ops;
} rt_rtc_dev_t;
rt_err_t rt_rtc_dev_register(rt_rtc_dev_t *rtc,
const char *name,
rt_uint32_t flag,
void *data);
#endif /* __RTC_CORE_H__ */

View File

@ -69,7 +69,7 @@ rt_err_t rt_workqueue_critical_work(struct rt_workqueue *queue, struct rt_work *
#ifdef RT_USING_SYSTEM_WORKQUEUE
rt_err_t rt_work_submit(struct rt_work *work, rt_tick_t time);
rt_err_t rt_work_cancel(struct rt_work *work);
#endif
#endif /* RT_USING_SYSTEM_WORKQUEUE */
rt_inline void rt_work_init(struct rt_work *work, void (*work_func)(struct rt_work *work, void *work_data),
void *work_data)
@ -85,7 +85,6 @@ rt_inline void rt_work_init(struct rt_work *work, void (*work_func)(struct rt_wo
void rt_delayed_work_init(struct rt_delayed_work *work, void (*work_func)(struct rt_work *work,
void *work_data), void *work_data);
int rt_work_sys_workqueue_init(void);
#endif
#endif /* RT_USING_HEAP */
#endif

View File

@ -7,7 +7,7 @@ CPPPATH = [cwd + '/../include']
group = []
if GetDepend(['RT_USING_RTC']):
src = src + ['rtc.c', 'rtc_core.c']
src = src + ['rtc.c']
if GetDepend(['RT_USING_ALARM']):
src = src + ['alarm.c']
if GetDepend(['RT_USING_SOFT_RTC']):

View File

@ -10,6 +10,8 @@
* 2012-04-16 aozima add scheduler lock for set_date and set_time.
* 2018-02-16 armink add auto sync time by NTP
* 2021-05-09 Meco Man remove NTP
* 2021-06-11 iysheng implement RTC framework V2.0
* 2021-07-30 Meco Man move rtc_core.c to rtc.c
*/
#include <time.h>
@ -20,7 +22,117 @@
#ifdef RT_USING_RTC
/*
* This function initializes rtc_core
*/
static rt_err_t rt_rtc_init(struct rt_device *dev)
{
rt_rtc_dev_t *rtc_core;
RT_ASSERT(dev != RT_NULL);
rtc_core = (rt_rtc_dev_t *)dev;
if (rtc_core->ops->init)
{
return (rtc_core->ops->init());
}
return -RT_ENOSYS;
}
static rt_err_t rt_rtc_open(struct rt_device *dev, rt_uint16_t oflag)
{
return RT_EOK;
}
static rt_err_t rt_rtc_close(struct rt_device *dev)
{
/* Add close member function in rt_rtc_ops when need,
* then call that function here.
* */
return RT_EOK;
}
static rt_err_t rt_rtc_control(struct rt_device *dev, int cmd, void *args)
{
#define TRY_DO_RTC_FUNC(rt_rtc_dev, func_name, args) \
rt_rtc_dev->ops->func_name ? rt_rtc_dev->ops->func_name(args) : -RT_EINVAL;
rt_rtc_dev_t *rtc_device;
rt_err_t ret = -RT_EINVAL;
RT_ASSERT(dev != RT_NULL);
rtc_device = (rt_rtc_dev_t *)dev;
switch (cmd)
{
case RT_DEVICE_CTRL_RTC_GET_TIME:
ret = TRY_DO_RTC_FUNC(rtc_device, get_secs, args);
break;
case RT_DEVICE_CTRL_RTC_SET_TIME:
ret = TRY_DO_RTC_FUNC(rtc_device, set_secs, args);
break;
case RT_DEVICE_CTRL_RTC_GET_TIME_US:
ret = TRY_DO_RTC_FUNC(rtc_device, get_usecs, args);
break;
case RT_DEVICE_CTRL_RTC_SET_TIME_US:
ret = TRY_DO_RTC_FUNC(rtc_device, set_usecs, args);
break;
case RT_DEVICE_CTRL_RTC_GET_ALARM:
ret = TRY_DO_RTC_FUNC(rtc_device, get_alarm, args);
break;
case RT_DEVICE_CTRL_RTC_SET_ALARM:
ret = TRY_DO_RTC_FUNC(rtc_device, set_alarm, args);
break;
default:
break;
}
return ret;
#undef TRY_DO_RTC_FUNC
}
#ifdef RT_USING_DEVICE_OPS
const static struct rt_device_ops rtc_core_ops =
{
rt_rtc_init,
rt_rtc_open,
rt_rtc_close,
RT_NULL,
RT_NULL,
rt_rtc_control,
};
#endif /* RT_USING_DEVICE_OPS */
rt_err_t rt_hw_rtc_register(rt_rtc_dev_t *rtc,
const char *name,
rt_uint32_t flag,
void *data)
{
struct rt_device *device;
RT_ASSERT(rtc != RT_NULL);
device = &(rtc->parent);
device->type = RT_Device_Class_RTC;
device->rx_indicate = RT_NULL;
device->tx_complete = RT_NULL;
#ifdef RT_USING_DEVICE_OPS
device->ops = &rtc_core_ops;
#else
device->init = rt_rtc_init;
device->open = rt_rtc_open;
device->close = rt_rtc_close;
device->read = RT_NULL;
device->write = RT_NULL;
device->control = rt_rtc_control;
#endif /* RT_USING_DEVICE_OPS */
device->user_data = data;
/* register a character device */
return rt_device_register(device, name, flag);
}
/**
* Set system date(time not modify, local timezone).
@ -30,12 +142,10 @@
* @param rt_uint32_t day e.g: 31.
*
* @return rt_err_t if set success, return RT_EOK.
*
*/
rt_err_t set_date(rt_uint32_t year, rt_uint32_t month, rt_uint32_t day)
{
time_t now;
struct tm *p_tm;
struct tm tm_new;
rt_device_t device;
rt_err_t ret = -RT_ERROR;
@ -43,14 +153,8 @@ rt_err_t set_date(rt_uint32_t year, rt_uint32_t month, rt_uint32_t day)
/* get current time */
now = time(RT_NULL);
/* lock scheduler. */
rt_enter_critical();
/* converts calendar time into local time. */
p_tm = localtime(&now);
/* copy the statically located variable */
rt_memcpy(&tm_new, p_tm, sizeof(struct tm));
/* unlock scheduler. */
rt_exit_critical();
localtime_r(&now, &tm_new);
/* update date. */
tm_new.tm_year = year - 1900;
@ -80,12 +184,10 @@ rt_err_t set_date(rt_uint32_t year, rt_uint32_t month, rt_uint32_t day)
* @param rt_uint32_t second e.g: 0~59.
*
* @return rt_err_t if set success, return RT_EOK.
*
*/
rt_err_t set_time(rt_uint32_t hour, rt_uint32_t minute, rt_uint32_t second)
{
time_t now;
struct tm *p_tm;
struct tm tm_new;
rt_device_t device;
rt_err_t ret = -RT_ERROR;
@ -93,14 +195,8 @@ rt_err_t set_time(rt_uint32_t hour, rt_uint32_t minute, rt_uint32_t second)
/* get current time */
now = time(RT_NULL);
/* lock scheduler. */
rt_enter_critical();
/* converts calendar time into local time. */
p_tm = localtime(&now);
/* copy the statically located variable */
rt_memcpy(&tm_new, p_tm, sizeof(struct tm));
/* unlock scheduler. */
rt_exit_critical();
localtime_r(&now, &tm_new);
/* update time. */
tm_new.tm_hour = hour;

View File

@ -1,123 +0,0 @@
/*
* COPYRIGHT (C) 2011-2021, Real-Thread Information Technology Ltd
*
* SPDX-License-Identifier: Apache-2.0
*
* Change Logs:
* Date Author Notes
* 2021-06-11 iysheng first version.
*/
#include <drivers/rtc_core.h>
#define TRY_DO_RTC_FUNC(rt_rtc_dev, func_name, args) \
rt_rtc_dev->ops->func_name ? rt_rtc_dev->ops->func_name(args) : -RT_EINVAL;
/*
* This function initializes rtc_core
*/
static rt_err_t rt_rtc_core_init(struct rt_device *dev)
{
rt_rtc_dev_t *rtc_core;
RT_ASSERT(dev != RT_NULL);
rtc_core = (rt_rtc_dev_t *)dev;
if (rtc_core->ops->init)
{
return (rtc_core->ops->init());
}
return (-RT_ENOSYS);
}
static rt_err_t rt_rtc_core_open(struct rt_device *dev, rt_uint16_t oflag)
{
return (RT_EOK);
}
static rt_err_t rt_rtc_core_close(struct rt_device *dev)
{
/* Add close member function in rt_rtc_ops when need,
* then call that function here.
* */
return (RT_EOK);
}
static rt_err_t rt_rtc_core_control(struct rt_device *dev,
int cmd,
void *args)
{
rt_rtc_dev_t *rtc_core;
rt_err_t ret = -RT_EINVAL;
RT_ASSERT(dev != RT_NULL);
rtc_core = (rt_rtc_dev_t *)dev;
switch (cmd)
{
case RT_DEVICE_CTRL_RTC_GET_TIME:
ret = TRY_DO_RTC_FUNC(rtc_core, get_secs, args);
break;
case RT_DEVICE_CTRL_RTC_SET_TIME:
ret = TRY_DO_RTC_FUNC(rtc_core, set_secs, args);
break;
case RT_DEVICE_CTRL_RTC_GET_TIME_US:
ret = TRY_DO_RTC_FUNC(rtc_core, get_usecs, args);
break;
case RT_DEVICE_CTRL_RTC_SET_TIME_US:
ret = TRY_DO_RTC_FUNC(rtc_core, set_usecs, args);
break;
case RT_DEVICE_CTRL_RTC_GET_ALARM:
ret = TRY_DO_RTC_FUNC(rtc_core, get_alarm, args);
break;
case RT_DEVICE_CTRL_RTC_SET_ALARM:
ret = TRY_DO_RTC_FUNC(rtc_core, set_alarm, args);
break;
default:
break;
}
return ret;
}
#ifdef RT_USING_DEVICE_OPS
const static struct rt_device_ops rtc_core_ops =
{
rt_rtc_core_init,
rt_rtc_core_open,
rt_rtc_core_close,
RT_NULL,
RT_NULL,
rt_rtc_core_control,
};
#endif
rt_err_t rt_rtc_dev_register(rt_rtc_dev_t *rtc,
const char *name,
rt_uint32_t flag,
void *data)
{
struct rt_device *device;
RT_ASSERT(rtc != RT_NULL);
device = &(rtc->parent);
device->type = RT_Device_Class_RTC;
device->rx_indicate = RT_NULL;
device->tx_complete = RT_NULL;
#ifdef RT_USING_DEVICE_OPS
device->ops = &rtc_core_ops;
#else
device->init = rt_rtc_core_init;
device->open = rt_rtc_core_open;
device->close = rt_rtc_core_close;
device->read = RT_NULL;
device->write = RT_NULL;
device->control = rt_rtc_core_control;
#endif
device->user_data = data;
/* register a character device */
return rt_device_register(device, name, flag);
}

View File

@ -515,15 +515,3 @@ void rt_mmcsd_blk_remove(struct rt_mmcsd_card *card)
}
}
}
/*
* This function will initialize block device on the mmc/sd.
*
* @deprecated since 2.1.0, this function does not need to be invoked
* in the system initialization.
*/
int rt_mmcsd_blk_init(void)
{
/* nothing */
return 0;
}

View File

@ -8,6 +8,7 @@
* 2012-09-30 Bernard first version.
* 2013-05-08 Grissiom reimplement
* 2016-08-18 heyuanjie add interface
* 2021-07-20 arminker fix write_index bug in function rt_ringbuffer_put_force
*/
#include <rtthread.h>
@ -138,7 +139,8 @@ rt_size_t rt_ringbuffer_put_force(struct rt_ringbuffer *rb,
if (length > space_length)
{
rb->read_mirror = ~rb->read_mirror;
if (rb->write_index <= rb->read_index)
rb->read_mirror = ~rb->read_mirror;
rb->read_index = rb->write_index;
}

View File

@ -358,7 +358,7 @@ rt_err_t rt_work_cancel(struct rt_work *work)
return rt_workqueue_cancel_work(sys_workq, work);
}
int rt_work_sys_workqueue_init(void)
static int rt_work_sys_workqueue_init(void)
{
if (sys_workq != RT_NULL)
return RT_EOK;
@ -370,5 +370,5 @@ int rt_work_sys_workqueue_init(void)
return RT_EOK;
}
INIT_PREV_EXPORT(rt_work_sys_workqueue_init);
#endif
#endif
#endif /* RT_USING_SYSTEM_WORKQUEUE */
#endif /* RT_USING_HEAP */

View File

@ -59,9 +59,9 @@ if RT_USING_LIBC != y
default y
endif
config RT_LIBC_FIXED_TIMEZONE
config RT_LIBC_DEFAULT_TIMEZONE
depends on (RT_LIBC_USING_TIME || RT_USING_LIBC)
int "Manually set a fixed time zone (UTC+)"
int "Set the default time zone (UTC+)"
range -12 12
default 8

View File

@ -9,14 +9,8 @@
*/
#include <stdint.h>
#include <stdio.h>
#include <rthw.h>
#include <rtdevice.h>
#include <rtthread.h>
#include <dfs_posix.h>
#include "posix_aio.h"
struct rt_workqueue* aio_queue = NULL;

View File

@ -11,6 +11,10 @@
#ifndef POSIX_AIO_H__
#define POSIX_AIO_H__
#include <stdio.h>
#include <sys/signal.h>
#include <rtdevice.h>
struct aiocb
{
int aio_fildes; /* File descriptor. */

View File

@ -7,8 +7,8 @@
* Date Author Notes
* 2021-05-22 Meco Man The first version.
*/
#ifndef _SYS_ERRNO_H
#define _SYS_ERRNO_H
#ifndef __SYS_ERRNO_H__
#define __SYS_ERRNO_H__
#if defined(__ARMCC_VERSION)
/*

View File

@ -6,3 +6,8 @@
* Change Logs:
* Date Author Notes
*/
#ifndef __SYS_STAT_H__
#define __SYS_STAT_H__
#endif

View File

@ -8,8 +8,8 @@
* 2020-09-05 Meco Man fix bugs
* 2020-12-16 Meco Man add useconds_t
*/
#ifndef __TYPES_H__
#define __TYPES_H__
#ifndef __SYS_TYPES_H__
#define __SYS_TYPES_H__
#include <stdint.h>

View File

@ -7,8 +7,8 @@
* Date Author Notes
* 2020-12-16 Meco Man add usleep
*/
#ifndef _SYS_UNISTD_H
#define _SYS_UNISTD_H
#ifndef __SYS_UNISTD_H__
#define __SYS_UNISTD_H__
#include <rtconfig.h>
#include "types.h"

View File

@ -0,0 +1,49 @@
/*
* Copyright (c) 2006-2021, RT-Thread Development Team
*
* SPDX-License-Identifier: Apache-2.0
*
* Change Logs:
* Date Author Notes
* 2021-07-21 Meco Man The first version
*/
#ifndef __SYS_SELECT_H__
#define __SYS_SELECT_H__
#include <rtconfig.h>
#include <sys/types.h>
#ifndef FD_SETSIZE
#define FD_SETSIZE 32
#endif
#ifdef SAL_USING_POSIX
#ifdef FD_SETSIZE
#undef FD_SETSIZE
#endif
#define FD_SETSIZE DFS_FD_MAX
#endif /* SAL_USING_POSIX */
#define NBBY 8 /* number of bits in a byte */
typedef long fd_mask;
#define NFDBITS (sizeof (fd_mask) * NBBY) /* bits per mask */
#ifndef howmany
#define howmany(x,y) (((x)+((y)-1))/(y))
#endif
#ifndef _SYS_TYPES_FD_SET /* MIPS */
typedef struct _types_fd_set {
fd_mask fds_bits[howmany(FD_SETSIZE, NFDBITS)];
} _types_fd_set;
#define fd_set _types_fd_set
#define FD_SET(n, p) ((p)->fds_bits[(n)/NFDBITS] |= (1L << ((n) % NFDBITS)))
#define FD_CLR(n, p) ((p)->fds_bits[(n)/NFDBITS] &= ~(1L << ((n) % NFDBITS)))
#define FD_ISSET(n, p) ((p)->fds_bits[(n)/NFDBITS] & (1L << ((n) % NFDBITS)))
#define FD_ZERO(p) memset((void*)(p), 0, sizeof(*(p)))
#endif /* _SYS_TYPES_FD_SET */
#endif /* __SYS_SELECT_H__ */

View File

@ -6,33 +6,27 @@
* Change Logs:
* Date Author Notes
* 2017-09-12 Bernard The first version
* 2021-07-21 Meco Man move to libc/common
*/
#ifndef LIBC_SIGNAL_H__
#define LIBC_SIGNAL_H__
#ifndef __SYS_SIGNAL_H__
#define __SYS_SIGNAL_H__
#ifdef __cplusplus
extern "C" {
#endif
#include <stdint.h>
#ifdef HAVE_CCONFIG_H
#include <cconfig.h>
#endif
#ifndef HAVE_SIGVAL
/* Signal Generation and Delivery, P1003.1b-1993, p. 63
NOTE: P1003.1c/D10, p. 34 adds sigev_notify_function and
sigev_notify_attributes to the sigevent structure. */
union sigval
{
int sival_int; /* Integer signal value */
void *sival_ptr; /* Pointer signal value */
};
#endif
#ifndef HAVE_SIGEVENT
struct sigevent
{
int sigev_notify; /* Notification type */
@ -42,9 +36,7 @@ struct sigevent
/* Notification function */
void *sigev_notify_attributes; /* Notification Attributes, really pthread_attr_t */
};
#endif
#ifndef HAVE_SIGINFO
struct siginfo
{
uint16_t si_signo;
@ -53,26 +45,37 @@ struct siginfo
union sigval si_value;
};
typedef struct siginfo siginfo_t;
#endif
#define SI_USER 0x01 /* Signal sent by kill(). */
#define SI_QUEUE 0x02 /* Signal sent by sigqueue(). */
#define SI_TIMER 0x03 /* Signal generated by expiration of a
timer set by timer_settime(). */
#define SI_ASYNCIO 0x04 /* Signal generated by completion of an
asynchronous I/O request. */
#define SI_MESGQ 0x05 /* Signal generated by arrival of a
message on an empty message queue. */
#define SI_TIMER 0x03 /* Signal generated by expiration of a timer set by timer_settime(). */
#define SI_ASYNCIO 0x04 /* Signal generated by completion of an asynchronous I/O request. */
#define SI_MESGQ 0x05 /* Signal generated by arrival of a message on an empty message queue. */
#if !defined(RT_USING_NEWLIB)
typedef void (*_sig_func_ptr)(int);
typedef unsigned long sigset_t;
#endif
#include <signal.h>
struct sigaction
{
_sig_func_ptr sa_handler;
sigset_t sa_mask;
int sa_flags;
};
#define SIG_SETMASK 0 /* set mask with sigprocmask() */
#define SIG_BLOCK 1 /* set of signals to block */
#define SIG_UNBLOCK 2 /* set of signals to, well, unblock */
#define sigaddset(what,sig) (*(what) |= (1<<(sig)), 0)
#define sigdelset(what,sig) (*(what) &= ~(1<<(sig)), 0)
#define sigemptyset(what) (*(what) = 0, 0)
#define sigfillset(what) (*(what) = ~(0), 0)
#define sigismember(what,sig) (((*(what)) & (1<<(sig))) != 0)
int sigprocmask (int how, const sigset_t *set, sigset_t *oset);
int sigaction(int signum, const struct sigaction *act, struct sigaction *oldact);
#ifdef __ARMCC_VERSION
#define SIGHUP 1
/* #define SIGINT 2 */
#define SIGQUIT 3
@ -103,28 +106,9 @@ typedef unsigned long sigset_t;
#define SIGRTMAX 31
#define NSIG 32
#define SIG_SETMASK 0 /* set mask with sigprocmask() */
#define SIG_BLOCK 1 /* set of signals to block */
#define SIG_UNBLOCK 2 /* set of signals to, well, unblock */
struct sigaction
{
_sig_func_ptr sa_handler;
sigset_t sa_mask;
int sa_flags;
};
#define sigaddset(what,sig) (*(what) |= (1<<(sig)), 0)
#define sigdelset(what,sig) (*(what) &= ~(1<<(sig)), 0)
#define sigemptyset(what) (*(what) = 0, 0)
#define sigfillset(what) (*(what) = ~(0), 0)
#define sigismember(what,sig) (((*(what)) & (1<<(sig))) != 0)
int sigprocmask (int how, const sigset_t *set, sigset_t *oset);
int sigaction(int signum, const struct sigaction *act, struct sigaction *oldact);
#include <signal.h>
#elif defined(__IAR_SYSTEMS_ICC__)
#define SIGHUP 1
#define SIGINT 2
#define SIGQUIT 3
@ -155,25 +139,51 @@ int sigaction(int signum, const struct sigaction *act, struct sigaction *oldact)
#define SIGRTMAX 31
#define NSIG 32
#define SIG_SETMASK 0 /* set mask with sigprocmask() */
#define SIG_BLOCK 1 /* set of signals to block */
#define SIG_UNBLOCK 2 /* set of signals to, well, unblock */
#include <signal.h>
struct sigaction
{
_sig_func_ptr sa_handler;
sigset_t sa_mask;
int sa_flags;
};
#elif defined(__GNUC__)
#define SIGHUP 1 /* hangup */
#define SIGINT 2 /* interrupt */
#define SIGQUIT 3 /* quit */
#define SIGILL 4 /* illegal instruction (not reset when caught) */
#define SIGTRAP 5 /* trace trap (not reset when caught) */
#define SIGIOT 6 /* IOT instruction */
#define SIGABRT 6 /* used by abort, replace SIGIOT in the future */
#define SIGEMT 7 /* EMT instruction */
#define SIGFPE 8 /* floating point exception */
#define SIGKILL 9 /* kill (cannot be caught or ignored) */
#define SIGBUS 10 /* bus error */
#define SIGSEGV 11 /* segmentation violation */
#define SIGSYS 12 /* bad argument to system call */
#define SIGPIPE 13 /* write on a pipe with no one to read it */
#define SIGALRM 14 /* alarm clock */
#define SIGTERM 15 /* software termination signal from kill */
#define SIGURG 16 /* urgent condition on IO channel */
#define SIGSTOP 17 /* sendable stop signal not from tty */
#define SIGTSTP 18 /* stop signal from tty */
#define SIGCONT 19 /* continue a stopped process */
#define SIGCHLD 20 /* to parent on child stop or exit */
#define SIGCLD 20 /* System V name for SIGCHLD */
#define SIGTTIN 21 /* to readers pgrp upon background tty read */
#define SIGTTOU 22 /* like TTIN for output if (tp->t_local&LTOSTOP) */
#define SIGIO 23 /* input/output possible signal */
#define SIGPOLL SIGIO /* System V name for SIGIO */
#define SIGXCPU 24 /* exceeded CPU time limit */
#define SIGXFSZ 25 /* exceeded file size limit */
#define SIGVTALRM 26 /* virtual time alarm */
#define SIGPROF 27 /* profiling time alarm */
#define SIGWINCH 28 /* window changed */
#define SIGLOST 29 /* resource lost (eg, record-lock lost) */
#define SIGUSR1 30 /* user defined signal 1 */
#define SIGUSR2 31 /* user defined signal 2 */
#define NSIG 32 /* signal 0 implied */
#define sigaddset(what,sig) (*(what) |= (1<<(sig)), 0)
#define sigdelset(what,sig) (*(what) &= ~(1<<(sig)), 0)
#define sigemptyset(what) (*(what) = 0, 0)
#define sigfillset(what) (*(what) = ~(0), 0)
#define sigismember(what,sig) (((*(what)) & (1<<(sig))) != 0)
#ifndef _SIGNAL_H_
/* Some applications take advantage of the fact that <sys/signal.h>
* and <signal.h> are equivalent in glibc. Allow for that here. */
#include <signal.h>
#endif
int sigprocmask (int how, const sigset_t *set, sigset_t *oset);
int sigaction(int signum, const struct sigaction *act, struct sigaction *oldact);
#endif
#ifdef __cplusplus

View File

@ -12,12 +12,14 @@
#define _SYS_TIME_H_
#include <rtconfig.h>
#include <rtdef.h>
#include <time.h>
#ifdef __cplusplus
extern "C" {
#endif
/* timezone */
#define DST_NONE 0 /* not on dst */
#define DST_USA 1 /* USA style dst */
#define DST_AUST 2 /* Australian style dst */
@ -30,12 +32,21 @@ extern "C" {
#define DST_TUR 9 /* Turkey */
#define DST_AUSTALT 10 /* Australian style with shift in 1986 */
#ifndef _TIMEVAL_DEFINED
#define _TIMEVAL_DEFINED
struct timezone {
int tz_minuteswest; /* minutes west of Greenwich */
int tz_dsttime; /* type of dst correction */
};
void rt_tz_set(rt_int8_t tz);
rt_int8_t rt_tz_get(void);
rt_int8_t rt_tz_is_dst(void);
/*
* Structure returned by gettimeofday(2) system call,
* and used in other calls.
*/
#ifndef _TIMEVAL_DEFINED
#define _TIMEVAL_DEFINED
#if !(defined(_WIN32))
struct timeval {
long tv_sec; /* seconds */
@ -44,18 +55,6 @@ struct timeval {
#endif
#endif /* _TIMEVAL_DEFINED */
#if !(defined(__GNUC__) && !defined(__ARMCC_VERSION)/*GCC*/) && !(defined(__ICCARM__) && (__VER__ >= 8010001)) && !defined(_WIN32)
struct timespec {
time_t tv_sec; /* seconds */
long tv_nsec; /* and nanoseconds */
};
#endif
struct timezone {
int tz_minuteswest; /* minutes west of Greenwich */
int tz_dsttime; /* type of dst correction */
};
int stime(const time_t *t);
time_t timegm(struct tm * const t);
int gettimeofday(struct timeval *tv, struct timezone *tz);
@ -66,6 +65,14 @@ struct tm *gmtime_r(const time_t *timep, struct tm *r);
#ifdef RT_USING_POSIX
#include <sys/types.h>
#if !(defined(__GNUC__) && !defined(__ARMCC_VERSION)/*GCC*/) && !(defined(__ICCARM__) && (__VER__ >= 8010001)) && !defined(_WIN32)
struct timespec {
time_t tv_sec; /* seconds */
long tv_nsec; /* and nanoseconds */
};
#endif
/* posix clock and timer */
#define MILLISECOND_PER_SECOND 1000UL
#define MICROSECOND_PER_SECOND 1000000UL
@ -95,7 +102,7 @@ struct tm *gmtime_r(const time_t *timep, struct tm *r);
int clock_getres (clockid_t clockid, struct timespec *res);
int clock_gettime (clockid_t clockid, struct timespec *tp);
int clock_settime (clockid_t clockid, const struct timespec *tp);
int clock_time_to_tick(const struct timespec *time);
int rt_timespec_to_tick(const struct timespec *time);
#endif /* RT_USING_POSIX */
#ifdef __cplusplus

View File

@ -18,12 +18,13 @@
* 2021-02-12 Meco Man move all of the functions located in <clock_time.c> to this file
* 2021-03-15 Meco Man fixed a bug of leaking memory in asctime()
* 2021-05-01 Meco Man support fixed timezone
* 2021-07-21 Meco Man implement that change/set timezone APIs
*/
#include "sys/time.h"
#include <sys/errno.h>
#include <rtthread.h>
#include <rthw.h>
#ifdef RT_USING_DEVICE
#include <rtdevice.h>
#endif
@ -32,10 +33,6 @@
#define DBG_LVL DBG_INFO
#include <rtdbg.h>
#ifndef RT_LIBC_FIXED_TIMEZONE
#define RT_LIBC_FIXED_TIMEZONE 8 /* UTC+8 */
#endif
/* seconds per day */
#define SPD 24*60*60
@ -202,7 +199,7 @@ struct tm *gmtime_r(const time_t *timep, struct tm *r)
r->tm_mon = i;
r->tm_mday += work - __spm[i];
r->tm_isdst = 0;
r->tm_isdst = rt_tz_is_dst();
return r;
}
RTM_EXPORT(gmtime_r);
@ -218,7 +215,7 @@ struct tm* localtime_r(const time_t* t, struct tm* r)
{
time_t local_tz;
local_tz = *t + RT_LIBC_FIXED_TIMEZONE * 3600;
local_tz = *t + rt_tz_get() * 3600;
return gmtime_r(&local_tz, r);
}
RTM_EXPORT(localtime_r);
@ -235,7 +232,7 @@ time_t mktime(struct tm * const t)
time_t timestamp;
timestamp = timegm(t);
timestamp = timestamp - 3600 * RT_LIBC_FIXED_TIMEZONE;
timestamp = timestamp - 3600 * rt_tz_get();
return timestamp;
}
RTM_EXPORT(mktime);
@ -426,7 +423,7 @@ int gettimeofday(struct timeval *tv, struct timezone *tz)
if(tz != RT_NULL)
{
tz->tz_dsttime = DST_NONE;
tz->tz_minuteswest = -(RT_LIBC_FIXED_TIMEZONE * 60);
tz->tz_minuteswest = -(rt_tz_get() * 60);
}
if (tv != RT_NULL && get_timeval(tv) == RT_EOK)
@ -468,38 +465,47 @@ RTM_EXPORT(difftime);
RTM_EXPORT(strftime);
#ifdef RT_USING_POSIX
static struct timeval _timevalue;
static int clock_time_system_init()
#ifdef RT_USING_RTC
static volatile struct timeval _timevalue;
static int _rt_clock_time_system_init()
{
time_t time;
register rt_base_t level;
time_t time = 0;
rt_tick_t tick;
rt_device_t device;
time = 0;
#ifdef RT_USING_RTC
device = rt_device_find("rtc");
if (device != RT_NULL)
{
/* get realtime seconds */
rt_device_control(device, RT_DEVICE_CTRL_RTC_GET_TIME, &time);
if(rt_device_control(device, RT_DEVICE_CTRL_RTC_GET_TIME, &time) == RT_EOK)
{
level = rt_hw_interrupt_disable();
tick = rt_tick_get(); /* get tick */
_timevalue.tv_usec = (tick%RT_TICK_PER_SECOND) * MICROSECOND_PER_TICK;
_timevalue.tv_sec = time - tick/RT_TICK_PER_SECOND - 1;
rt_hw_interrupt_enable(level);
return 0;
}
}
#else
LOG_W("Cannot find a RTC device to provide time!");
#endif
/* get tick */
tick = rt_tick_get();
level = rt_hw_interrupt_disable();
_timevalue.tv_usec = 0;
_timevalue.tv_sec = 0;
rt_hw_interrupt_enable(level);
_timevalue.tv_usec = (tick%RT_TICK_PER_SECOND) * MICROSECOND_PER_TICK;
_timevalue.tv_sec = time - tick/RT_TICK_PER_SECOND - 1;
return 0;
return -1;
}
INIT_COMPONENT_EXPORT(clock_time_system_init);
INIT_COMPONENT_EXPORT(_rt_clock_time_system_init);
#endif /* RT_USING_RTC */
int clock_getres(clockid_t clockid, struct timespec *res)
{
#ifndef RT_USING_RTC
LOG_W("Cannot find a RTC device to save time!");
return -1;
#else
int ret = 0;
if (res == RT_NULL)
@ -529,11 +535,16 @@ int clock_getres(clockid_t clockid, struct timespec *res)
}
return ret;
#endif /* RT_USING_RTC */
}
RTM_EXPORT(clock_getres);
int clock_gettime(clockid_t clockid, struct timespec *tp)
{
#ifndef RT_USING_RTC
LOG_W("Cannot find a RTC device to save time!");
return -1;
#else
int ret = 0;
if (tp == RT_NULL)
@ -546,11 +557,14 @@ int clock_gettime(clockid_t clockid, struct timespec *tp)
{
case CLOCK_REALTIME:
{
/* get tick */
int tick = rt_tick_get();
int tick;
register rt_base_t level;
level = rt_hw_interrupt_disable();
tick = rt_tick_get(); /* get tick */
tp->tv_sec = _timevalue.tv_sec + tick / RT_TICK_PER_SECOND;
tp->tv_nsec = (_timevalue.tv_usec + (tick % RT_TICK_PER_SECOND) * MICROSECOND_PER_TICK) * 1000;
rt_hw_interrupt_enable(level);
}
break;
@ -574,11 +588,17 @@ int clock_gettime(clockid_t clockid, struct timespec *tp)
}
return ret;
#endif /* RT_USING_RTC */
}
RTM_EXPORT(clock_gettime);
int clock_settime(clockid_t clockid, const struct timespec *tp)
{
#ifndef RT_USING_RTC
LOG_W("Cannot find a RTC device to save time!");
return -1;
#else
register rt_base_t level;
int second;
rt_tick_t tick;
rt_device_t device;
@ -586,38 +606,36 @@ int clock_settime(clockid_t clockid, const struct timespec *tp)
if ((clockid != CLOCK_REALTIME) || (tp == RT_NULL))
{
rt_set_errno(EINVAL);
return -1;
}
/* get second */
second = tp->tv_sec;
/* get tick */
tick = rt_tick_get();
level = rt_hw_interrupt_disable();
tick = rt_tick_get(); /* get tick */
/* update timevalue */
_timevalue.tv_usec = MICROSECOND_PER_SECOND - (tick % RT_TICK_PER_SECOND) * MICROSECOND_PER_TICK;
_timevalue.tv_sec = second - tick/RT_TICK_PER_SECOND - 1;
rt_hw_interrupt_enable(level);
#ifdef RT_USING_RTC
/* update for RTC device */
device = rt_device_find("rtc");
if (device != RT_NULL)
{
/* set realtime seconds */
rt_device_control(device, RT_DEVICE_CTRL_RTC_SET_TIME, &second);
if(rt_device_control(device, RT_DEVICE_CTRL_RTC_SET_TIME, &second) == RT_EOK)
{
return 0;
}
}
else
#else
LOG_W("Cannot find a RTC device to save time!");
#endif
return -1;
return 0;
return -1;
#endif /* RT_USING_RTC */
}
RTM_EXPORT(clock_settime);
int clock_time_to_tick(const struct timespec *time)
int rt_timespec_to_tick(const struct timespec *time)
{
int tick;
int nsecond, second;
@ -648,6 +666,32 @@ int clock_time_to_tick(const struct timespec *time)
return tick;
}
RTM_EXPORT(clock_time_to_tick);
RTM_EXPORT(rt_timespec_to_tick);
#endif /* RT_USING_POSIX */
/* timezone */
#ifndef RT_LIBC_DEFAULT_TIMEZONE
#define RT_LIBC_DEFAULT_TIMEZONE 8
#endif
static volatile rt_int8_t rt_current_timezone = RT_LIBC_DEFAULT_TIMEZONE;
void rt_tz_set(rt_int8_t tz)
{
register rt_base_t level;
level = rt_hw_interrupt_disable();
rt_current_timezone = tz;
rt_hw_interrupt_enable(level);
}
rt_int8_t rt_tz_get(void)
{
return rt_current_timezone;
}
rt_int8_t rt_tz_is_dst(void)
{
return 0;
}

View File

@ -8,6 +8,7 @@
*/
#include <string.h>
#include <sys/signal.h>
#include "mqueue.h"
#include "pthread_internal.h"
@ -243,7 +244,7 @@ ssize_t mq_timedreceive(mqd_t mqdes,
return -1;
}
tick = clock_time_to_tick(abs_timeout);
tick = rt_timespec_to_tick(abs_timeout);
result = rt_mq_recv(mqdes->mq, msg_ptr, msg_len, tick);
if (result == RT_EOK)

View File

@ -222,7 +222,7 @@ int pthread_cond_timedwait(pthread_cond_t *cond,
int timeout;
rt_err_t result;
timeout = clock_time_to_tick(abstime);
timeout = rt_timespec_to_tick(abstime);
result = _pthread_cond_timedwait(cond, mutex, timeout);
if (result == RT_EOK)
return 0;

View File

@ -319,7 +319,7 @@ int sem_timedwait(sem_t *sem, const struct timespec *abs_timeout)
return EINVAL;
/* calculate os tick */
tick = clock_time_to_tick(abs_timeout);
tick = rt_timespec_to_tick(abs_timeout);
result = rt_sem_take(sem->sem, tick);
if (result == -RT_ETIMEOUT)

View File

@ -7,6 +7,7 @@
* Date Author Notes
* 2017/10/1 Bernard The first version
*/
#include <rthw.h>
#include <rtthread.h>
@ -14,6 +15,7 @@
#include <sys/errno.h>
#include "posix_signal.h"
#define sig_valid(sig_no) (sig_no >= 0 && sig_no < RT_SIG_MAX)
void (*signal(int sig, void (*func)(int))) (int)
@ -79,13 +81,10 @@ int sigtimedwait(const sigset_t *set, siginfo_t *info,
int ret = 0;
int tick = RT_WAITING_FOREVER;
#ifdef RT_USING_PTHREADS
if (timeout)
{
extern int clock_time_to_tick(const struct timespec *time);
tick = clock_time_to_tick(timeout);
tick = rt_timespec_to_tick(timeout);
}
#endif
ret = rt_signal_wait(set, info, tick);
if (ret == 0) return 0;

View File

@ -15,7 +15,6 @@
extern "C" {
#endif
#include <rtthread.h>
#include <sys/signal.h>
enum rt_signal_value{

View File

@ -13,6 +13,7 @@
#include <string.h>
#include <ctype.h>
#include <sys/time.h>
#include <sys/errno.h>
#include <at_socket.h>
#include <at_device.h>
@ -78,7 +79,7 @@ struct at_socket *at_get_socket(int socket)
}
/* get a block to the AT socket receive list*/
static size_t at_recvpkt_put(rt_slist_t *rlist, const char *ptr, size_t length)
static rt_err_t at_recvpkt_put(rt_slist_t *rlist, const char *ptr, size_t length)
{
at_recv_pkt_t pkt = RT_NULL;
@ -86,7 +87,7 @@ static size_t at_recvpkt_put(rt_slist_t *rlist, const char *ptr, size_t length)
if (pkt == RT_NULL)
{
LOG_E("No memory for receive packet table!");
return 0;
return -RT_ENOMEM;
}
pkt->bfsz_totle = length;
@ -95,7 +96,7 @@ static size_t at_recvpkt_put(rt_slist_t *rlist, const char *ptr, size_t length)
rt_slist_append(rlist, &pkt->list);
return length;
return RT_EOK;
}
/* delete and free all receive buffer list */
@ -651,14 +652,20 @@ static void at_recv_notice_cb(struct at_socket *sock, at_socket_evt_t event, con
RT_ASSERT(event == AT_SOCKET_EVT_RECV);
/* check the socket object status */
if (sock->magic != AT_SOCKET_MAGIC)
if (sock->magic != AT_SOCKET_MAGIC || sock->state == AT_SOCKET_CLOSED)
{
rt_free((void *)buff);
return;
}
/* put receive buffer to receiver packet list */
rt_mutex_take(sock->recv_lock, RT_WAITING_FOREVER);
at_recvpkt_put(&(sock->recvpkt_list), buff, bfsz);
if (at_recvpkt_put(&(sock->recvpkt_list), buff, bfsz) != RT_EOK)
{
rt_free((void *)buff);
rt_mutex_release(sock->recv_lock);
return;
}
rt_mutex_release(sock->recv_lock);
rt_sem_release(sock->recv_notice);

View File

@ -9,6 +9,7 @@
* 2018-04-12 chenyong add client implement
* 2018-08-17 chenyong multiple client support
* 2021-03-17 Meco Man fix a buf of leaking memory
* 2021-07-14 Sszl fix a buf of leaking memory
*/
#include <at.h>
@ -571,30 +572,19 @@ int at_obj_set_urc_table(at_client_t client, const struct at_urc *urc_table, rt_
}
else
{
struct at_urc_table *old_urc_table = RT_NULL;
size_t old_table_size = client->urc_table_size * sizeof(struct at_urc_table);
old_urc_table = (struct at_urc_table *) rt_malloc(old_table_size);
if (old_urc_table == RT_NULL)
{
return -RT_ENOMEM;
}
rt_memcpy(old_urc_table, client->urc_table, old_table_size);
struct at_urc_table *new_urc_table = RT_NULL;
/* realloc urc table space */
client->urc_table = (struct at_urc_table *) rt_realloc(client->urc_table,
old_table_size + sizeof(struct at_urc_table));
if (client->urc_table == RT_NULL)
new_urc_table = (struct at_urc_table *) rt_realloc(client->urc_table,client->urc_table_size * sizeof(struct at_urc_table) + sizeof(struct at_urc_table));
if (new_urc_table == RT_NULL)
{
rt_free(old_urc_table);
return -RT_ENOMEM;
}
rt_memcpy(client->urc_table, old_urc_table, old_table_size);
client->urc_table = new_urc_table;
client->urc_table[client->urc_table_size].urc = urc_table;
client->urc_table[client->urc_table_size].urc_size = table_sz;
client->urc_table_size++;
rt_free(old_urc_table);
}
return RT_EOK;

View File

@ -222,6 +222,13 @@
#define LWIP_DBG_TYPES_ON (LWIP_DBG_ON|LWIP_DBG_TRACE|LWIP_DBG_STATE|LWIP_DBG_FRESH|LWIP_DBG_HALT)
/* ---------- Memory options ---------- */
#ifdef RT_USING_ASM_MEMCPY
#define MEMCPY(dst,src,len) rt_memcpy(dst,src,len)
#else
#define MEMCPY(dst,src,len) memcpy(dst,src,len)
#endif /* RT_USING_ASM_MEMCPY */
#define SMEMCPY(dst,src,len) MEMCPY(dst,src,len)
#define MEM_ALIGNMENT 4
#define MEM_LIBC_MALLOC 1

View File

@ -201,14 +201,14 @@ int lwip_netdev_ping(struct netdev *netif, const char *host, size_t data_len,
{
return -RT_ERROR;
}
rt_memcpy(&h, &res->ai_addr, sizeof(struct sockaddr_in *));
rt_memcpy(&ina, &h->sin_addr, sizeof(ina));
SMEMCPY(&h, &res->ai_addr, sizeof(struct sockaddr_in *));
SMEMCPY(&ina, &h->sin_addr, sizeof(ina));
lwip_freeaddrinfo(res);
if (inet_aton(inet_ntoa(ina), &target_addr) == 0)
{
return -RT_ERROR;
}
rt_memcpy(&(ping_resp->ip_addr), &target_addr, sizeof(ip_addr_t));
SMEMCPY(&(ping_resp->ip_addr), &target_addr, sizeof(ip_addr_t));
/* new a socket */
if ((s = lwip_socket(AF_INET, SOCK_RAW, IP_PROTO_ICMP)) < 0)
@ -331,7 +331,7 @@ static int netdev_add(struct netif *lwip_netif)
netdev->mtu = lwip_netif->mtu;
netdev->ops = &lwip_netdev_ops;
netdev->hwaddr_len = lwip_netif->hwaddr_len;
rt_memcpy(netdev->hwaddr, lwip_netif->hwaddr, lwip_netif->hwaddr_len);
SMEMCPY(netdev->hwaddr, lwip_netif->hwaddr, lwip_netif->hwaddr_len);
netdev->ip_addr = lwip_netif->ip_addr;
netdev->gw = lwip_netif->gw;
netdev->netmask = lwip_netif->netmask;

View File

@ -230,14 +230,21 @@
#define LWIP_DBG_TYPES_ON (LWIP_DBG_ON|LWIP_DBG_TRACE|LWIP_DBG_STATE|LWIP_DBG_FRESH|LWIP_DBG_HALT)
/* ---------- Memory options ---------- */
#ifdef RT_USING_ASM_MEMCPY
#define MEMCPY(dst,src,len) rt_memcpy(dst,src,len)
#else
#define MEMCPY(dst,src,len) memcpy(dst,src,len)
#endif /* RT_USING_ASM_MEMCPY */
#define SMEMCPY(dst,src,len) MEMCPY(dst,src,len)
#ifdef RT_LWIP_MEM_ALIGNMENT
#define MEM_ALIGNMENT RT_LWIP_MEM_ALIGNMENT
#else
#define MEM_ALIGNMENT 4
#endif
#define MEMP_OVERFLOW_CHECK 1 ////
#define LWIP_ALLOW_MEM_FREE_FROM_OTHER_CONTEXT 1 ////
#define MEMP_OVERFLOW_CHECK 1
#define LWIP_ALLOW_MEM_FREE_FROM_OTHER_CONTEXT 1
//#define MEM_LIBC_MALLOC 1
//#define MEM_USE_POOLS 1
//#define MEMP_USE_CUSTOM_POOLS 1

View File

@ -210,14 +210,14 @@ int lwip_netdev_ping(struct netdev *netif, const char *host, size_t data_len,
{
return -RT_ERROR;
}
rt_memcpy(&h, &res->ai_addr, sizeof(struct sockaddr_in *));
rt_memcpy(&ina, &h->sin_addr, sizeof(ina));
SMEMCPY(&h, &res->ai_addr, sizeof(struct sockaddr_in *));
SMEMCPY(&ina, &h->sin_addr, sizeof(ina));
lwip_freeaddrinfo(res);
if (inet_aton(inet_ntoa(ina), &target_addr) == 0)
{
return -RT_ERROR;
}
rt_memcpy(&(ping_resp->ip_addr), &target_addr, sizeof(ip_addr_t));
SMEMCPY(&(ping_resp->ip_addr), &target_addr, sizeof(ip_addr_t));
/* new a socket */
if ((s = lwip_socket(AF_INET, SOCK_RAW, IP_PROTO_ICMP)) < 0)
@ -340,7 +340,7 @@ static int netdev_add(struct netif *lwip_netif)
netdev->mtu = lwip_netif->mtu;
netdev->ops = &lwip_netdev_ops;
netdev->hwaddr_len = lwip_netif->hwaddr_len;
rt_memcpy(netdev->hwaddr, lwip_netif->hwaddr, lwip_netif->hwaddr_len);
SMEMCPY(netdev->hwaddr, lwip_netif->hwaddr, lwip_netif->hwaddr_len);
netdev->ip_addr = lwip_netif->ip_addr;
netdev->gw = lwip_netif->gw;
netdev->netmask = lwip_netif->netmask;

View File

@ -230,14 +230,21 @@
#define LWIP_DBG_TYPES_ON (LWIP_DBG_ON|LWIP_DBG_TRACE|LWIP_DBG_STATE|LWIP_DBG_FRESH|LWIP_DBG_HALT)
/* ---------- Memory options ---------- */
#ifdef RT_USING_ASM_MEMCPY
#define MEMCPY(dst,src,len) rt_memcpy(dst,src,len)
#else
#define MEMCPY(dst,src,len) memcpy(dst,src,len)
#endif /* RT_USING_ASM_MEMCPY */
#define SMEMCPY(dst,src,len) MEMCPY(dst,src,len)
#ifdef RT_LWIP_MEM_ALIGNMENT
#define MEM_ALIGNMENT RT_LWIP_MEM_ALIGNMENT
#else
#define MEM_ALIGNMENT 4
#endif
#define MEMP_OVERFLOW_CHECK 1 ////
#define LWIP_ALLOW_MEM_FREE_FROM_OTHER_CONTEXT 1 ////
#define MEMP_OVERFLOW_CHECK 1
#define LWIP_ALLOW_MEM_FREE_FROM_OTHER_CONTEXT 1
//#define MEM_LIBC_MALLOC 1
//#define MEM_USE_POOLS 1
//#define MEMP_USE_CUSTOM_POOLS 1

View File

@ -210,14 +210,14 @@ int lwip_netdev_ping(struct netdev *netif, const char *host, size_t data_len,
{
return -RT_ERROR;
}
rt_memcpy(&h, &res->ai_addr, sizeof(struct sockaddr_in *));
rt_memcpy(&ina, &h->sin_addr, sizeof(ina));
SMEMCPY(&h, &res->ai_addr, sizeof(struct sockaddr_in *));
SMEMCPY(&ina, &h->sin_addr, sizeof(ina));
lwip_freeaddrinfo(res);
if (inet_aton(inet_ntoa(ina), &target_addr) == 0)
{
return -RT_ERROR;
}
rt_memcpy(&(ping_resp->ip_addr), &target_addr, sizeof(ip_addr_t));
SMEMCPY(&(ping_resp->ip_addr), &target_addr, sizeof(ip_addr_t));
/* new a socket */
if ((s = lwip_socket(AF_INET, SOCK_RAW, IP_PROTO_ICMP)) < 0)
@ -340,7 +340,7 @@ static int netdev_add(struct netif *lwip_netif)
netdev->mtu = lwip_netif->mtu;
netdev->ops = &lwip_netdev_ops;
netdev->hwaddr_len = lwip_netif->hwaddr_len;
rt_memcpy(netdev->hwaddr, lwip_netif->hwaddr, lwip_netif->hwaddr_len);
SMEMCPY(netdev->hwaddr, lwip_netif->hwaddr, lwip_netif->hwaddr_len);
netdev->ip_addr = lwip_netif->ip_addr;
netdev->gw = lwip_netif->gw;
netdev->netmask = lwip_netif->netmask;

View File

@ -242,9 +242,16 @@
#endif
/* ---------- Memory options ---------- */
#ifdef RT_USING_ASM_MEMCPY
#define MEMCPY(dst,src,len) rt_memcpy(dst,src,len)
#else
#define MEMCPY(dst,src,len) memcpy(dst,src,len)
#endif /* RT_USING_ASM_MEMCPY */
#define SMEMCPY(dst,src,len) MEMCPY(dst,src,len)
#define MEM_ALIGNMENT 4
#define MEMP_OVERFLOW_CHECK 1 ////
#define LWIP_ALLOW_MEM_FREE_FROM_OTHER_CONTEXT 1 ////
#define MEMP_OVERFLOW_CHECK 1
#define LWIP_ALLOW_MEM_FREE_FROM_OTHER_CONTEXT 1
//#define MEM_LIBC_MALLOC 1
//#define MEM_USE_POOLS 1
//#define MEMP_USE_CUSTOM_POOLS 1

View File

@ -208,14 +208,14 @@ int lwip_netdev_ping(struct netdev *netif, const char *host, size_t data_len,
{
return -RT_ERROR;
}
rt_memcpy(&h, &res->ai_addr, sizeof(struct sockaddr_in *));
rt_memcpy(&ina, &h->sin_addr, sizeof(ina));
SMEMCPY(&h, &res->ai_addr, sizeof(struct sockaddr_in *));
SMEMCPY(&ina, &h->sin_addr, sizeof(ina));
lwip_freeaddrinfo(res);
if (inet_aton(inet_ntoa(ina), &target_addr) == 0)
{
return -RT_ERROR;
}
rt_memcpy(&(ping_resp->ip_addr), &target_addr, sizeof(ip_addr_t));
SMEMCPY(&(ping_resp->ip_addr), &target_addr, sizeof(ip_addr_t));
/* new a socket */
if ((s = lwip_socket(AF_INET, SOCK_RAW, IP_PROTO_ICMP)) < 0)
@ -338,7 +338,7 @@ static int netdev_add(struct netif *lwip_netif)
netdev->mtu = lwip_netif->mtu;
netdev->ops = &lwip_netdev_ops;
netdev->hwaddr_len = lwip_netif->hwaddr_len;
rt_memcpy(netdev->hwaddr, lwip_netif->hwaddr, lwip_netif->hwaddr_len);
SMEMCPY(netdev->hwaddr, lwip_netif->hwaddr, lwip_netif->hwaddr_len);
netdev->ip_addr = lwip_netif->ip_addr;
netdev->gw = lwip_netif->gw;
netdev->netmask = lwip_netif->netmask;

View File

@ -6,7 +6,7 @@
* Change Logs:
* Date Author Notes
* 2015-02-17 Bernard First version
* 2108-05-24 ChenYong Add socket abstraction layer
* 2018-05-24 ChenYong Add socket abstraction layer
*/
#ifndef NETDB_H__

View File

@ -83,7 +83,7 @@ static void thread3_entry(void *param)
int event_simple_init()
{
/* 初始化事件对象 */
rt_event_init(&event, "event", RT_IPC_FLAG_FIFO);
rt_event_init(&event, "event", RT_IPC_FLAG_PRIO);
/* 创建线程1 */
tid1 = rt_thread_create("t1",

View File

@ -82,7 +82,7 @@ int mbox_send_wait_init()
"mbt", /* 名称是mbt */
&mb_pool[0], /* 邮箱用到的内存池是mb_pool */
sizeof(mb_pool)/4, /* 大小是mb_pool大小除以4因为一封邮件的大小是4字节 */
RT_IPC_FLAG_FIFO); /* 采用FIFO方式进行线程等待 */
RT_IPC_FLAG_PRIO); /* 采用PRIO方式进行线程等待 */
/* 创建线程1 */
tid1 = rt_thread_create("t1",

View File

@ -80,7 +80,7 @@ int mbox_simple_init()
"mbt", /* 名称是mbt */
&mb_pool[0], /* 邮箱用到的内存池是mb_pool */
sizeof(mb_pool)/4, /* 大小是mb_pool大小除以4因为一封邮件的大小是4字节 */
RT_IPC_FLAG_FIFO); /* 采用FIFO方式进行线程等待 */
RT_IPC_FLAG_PRIO); /* 采用PRIO方式进行线程等待 */
/* 创建线程1 */
tid1 = rt_thread_create("t1",

View File

@ -98,7 +98,7 @@ int messageq_simple_init()
&msg_pool[0], /* 内存池指向msg_pool */
128 - sizeof(void*), /* 每个消息的大小是 128 - void* */
sizeof(msg_pool), /* 内存池的大小是msg_pool的大小 */
RT_IPC_FLAG_FIFO); /* 如果有多个线程等待,按照先来先得到的方法分配消息 */
RT_IPC_FLAG_PRIO); /* 如果有多个线程等待,按照优先级由高到低的方法分配消息 */
/* 创建线程1 */
tid1 = rt_thread_create("t1",

View File

@ -281,7 +281,7 @@ static void thread29_entry(void* parameter)
static int mutex_simple_init()
{
/* 创建互斥锁 */
mutex = rt_mutex_create("mutex", RT_IPC_FLAG_FIFO);
mutex = rt_mutex_create("mutex", RT_IPC_FLAG_PRIO);
if (mutex == RT_NULL)
{
tc_stat(TC_STAT_END | TC_STAT_FAILED);

View File

@ -87,7 +87,7 @@ static void thread3_entry(void* parameter)
int mutex_simple_init()
{
/* 创建互斥锁 */
mutex = rt_mutex_create("mutex", RT_IPC_FLAG_FIFO);
mutex = rt_mutex_create("mutex", RT_IPC_FLAG_PRIO);
if (mutex == RT_NULL)
{
tc_stat(TC_STAT_END | TC_STAT_FAILED);

View File

@ -209,7 +209,7 @@ int semaphore_buffer_worker_init()
rb_init(&working_rb, working_buffer, BUFFER_SIZE);
/* 创建信号量 */
sem = rt_sem_create("sem", 1, RT_IPC_FLAG_FIFO);
sem = rt_sem_create("sem", 1, RT_IPC_FLAG_PRIO);
if (sem == RT_NULL)
{
tc_stat(TC_STAT_END | TC_STAT_FAILED);

View File

@ -78,7 +78,7 @@ static void thread_entry(void* parameter)
int semaphore_dynamic_init()
{
/* 创建一个信号量初始值是0 */
sem = rt_sem_create("sem", 0, RT_IPC_FLAG_FIFO);
sem = rt_sem_create("sem", 0, RT_IPC_FLAG_PRIO);
if (sem == RT_NULL)
{
tc_stat(TC_STAT_END | TC_STAT_FAILED);

View File

@ -98,9 +98,9 @@ void consumer_thread_entry(void* parameter)
int semaphore_producer_consumer_init()
{
/* 初始化3个信号量 */
rt_sem_init(&sem_lock , "lock", 1, RT_IPC_FLAG_FIFO);
rt_sem_init(&sem_empty, "empty", MAXSEM, RT_IPC_FLAG_FIFO);
rt_sem_init(&sem_full , "full", 0, RT_IPC_FLAG_FIFO);
rt_sem_init(&sem_lock , "lock", 1, RT_IPC_FLAG_PRIO);
rt_sem_init(&sem_empty, "empty", MAXSEM, RT_IPC_FLAG_PRIO);
rt_sem_init(&sem_full , "full", 0, RT_IPC_FLAG_PRIO);
/* 创建线程1 */
producer_tid = rt_thread_create("producer",

View File

@ -81,7 +81,7 @@ int semaphore_static_init(void)
rt_err_t result;
/* 初始化信号量初始值是0 */
result = rt_sem_init(&sem, "sem", 0, RT_IPC_FLAG_FIFO);
result = rt_sem_init(&sem, "sem", 0, RT_IPC_FLAG_PRIO);
if (result != RT_EOK)
{
tc_stat(TC_STAT_END | TC_STAT_FAILED);

View File

@ -35,7 +35,7 @@ void tc_thread_entry(void* parameter)
struct finsh_syscall* index;
/* create tc semaphore */
rt_sem_init(&_tc_sem, "tc", 0, RT_IPC_FLAG_FIFO);
rt_sem_init(&_tc_sem, "tc", 0, RT_IPC_FLAG_PRIO);
do {
for (index = _syscall_table_begin; index < _syscall_table_end; FINSH_NEXT_SYSCALL(index))

View File

@ -73,7 +73,7 @@ int timer_timeout_init()
&msg_pool[0], /* 内存池指向msg_pool */
128 - sizeof(void*), /* 每个消息的大小是 128 - void* */
sizeof(msg_pool), /* 内存池的大小是msg_pool的大小 */
RT_IPC_FLAG_FIFO); /* 如果有多个线程等待,按照先来先得到的方法分配消息 */
RT_IPC_FLAG_PRIO); /* 如果有多个线程等待,按照优先级由高到低的方法分配消息 */
/* 创建线程 */
tid = rt_thread_create("t",

View File

@ -61,7 +61,7 @@ static int wakeup_app(void)
{
rt_thread_t tid;
wakeup_event = rt_event_create("wakup", RT_IPC_FLAG_FIFO);
wakeup_event = rt_event_create("wakup", RT_IPC_FLAG_PRIO);
RT_ASSERT(wakeup_event != RT_NULL);
tid = rt_thread_create("wakeup_app", wakeup_app_entry, RT_NULL,

View File

@ -1,60 +0,0 @@
/*
* Copyright (c) 2006-2021, RT-Thread Development Team
*
* SPDX-License-Identifier: Apache-2.0
*
* Change Logs:
* Date Author Notes
* 2017-10-30 Bernard The first version
*/
#ifndef LIBC_FDSET_H__
#define LIBC_FDSET_H__
#include <rtconfig.h>
#if defined(RT_USING_NEWLIB) || defined(_WIN32) || (defined( __GNUC__ ) && !defined(__ARMCC_VERSION))
#include <sys/types.h>
#if defined(HAVE_SYS_SELECT_H)
#include <sys/select.h>
#endif
#else
#ifdef SAL_USING_POSIX
#ifdef FD_SETSIZE
#undef FD_SETSIZE
#endif
#define FD_SETSIZE DFS_FD_MAX
#endif
# ifndef FD_SETSIZE
# define FD_SETSIZE 32
# endif
# define NBBY 8 /* number of bits in a byte */
typedef long fd_mask;
# define NFDBITS (sizeof (fd_mask) * NBBY) /* bits per mask */
# ifndef howmany
# define howmany(x,y) (((x)+((y)-1))/(y))
# endif
/* We use a macro for fd_set so that including Sockets.h afterwards
can work. */
typedef struct _types_fd_set {
fd_mask fds_bits[howmany(FD_SETSIZE, NFDBITS)];
} _types_fd_set;
#define fd_set _types_fd_set
# define FD_SET(n, p) ((p)->fds_bits[(n)/NFDBITS] |= (1L << ((n) % NFDBITS)))
# define FD_CLR(n, p) ((p)->fds_bits[(n)/NFDBITS] &= ~(1L << ((n) % NFDBITS)))
# define FD_ISSET(n, p) ((p)->fds_bits[(n)/NFDBITS] & (1L << ((n) % NFDBITS)))
# define FD_ZERO(p) memset((void*)(p), 0, sizeof(*(p)))
#endif
#endif

View File

@ -510,7 +510,7 @@ typedef struct rt_timer *rt_timer_t;
* @addtogroup Signal
*/
#ifdef RT_USING_SIGNALS
#include <libc/libc_signal.h>
#include <sys/signal.h>
typedef unsigned long rt_sigset_t;
typedef void (*rt_sighandler_t)(int signo);
typedef siginfo_t rt_siginfo_t;

View File

@ -13,11 +13,8 @@
/* definitions for libc if toolchain has no these definitions */
#include "libc/libc_stat.h"
#include "libc/libc_fcntl.h"
#include "libc/libc_dirent.h"
#include "libc/libc_signal.h"
#include "libc/libc_fdset.h"
#ifndef RT_USING_LIBC
#if defined(__ARMCC_VERSION) || defined(__IAR_SYSTEMS_ICC__)

View File

@ -131,6 +131,10 @@ config RT_KSERVICE_USING_TINY_SIZE
bool "Enable kservice to use tiny size"
default n
config RT_USING_ASM_MEMCPY
bool
default n
endmenu
menuconfig RT_DEBUG
@ -352,6 +356,10 @@ menu "Kernel Device Object"
config RT_CONSOLE_DEVICE_NAME
string "the device name for console"
default "uart"
config RT_PRINTF_LONGLONG
bool "rt_kprintf support long long"
default n
endif
endmenu

View File

@ -139,7 +139,7 @@ rt_err_t rt_thread_idle_delhook(void (*hook)(void))
#ifdef RT_USING_MODULE
/* Return whether there is defunctional thread to be deleted. */
rt_inline int _has_defunct_thread(void)
rt_inline int _idle_has_defunct_thread(void)
{
/* The rt_list_isempty has prototype of "int rt_list_isempty(const rt_list_t *l)".
* So the compiler has a good reason that the _rt_thread_defunct list does
@ -207,7 +207,7 @@ static void rt_defunct_execute(void)
#ifdef RT_USING_MODULE
/* check whether list is empty */
if (!_has_defunct_thread())
if (!_idle_has_defunct_thread())
{
rt_hw_interrupt_enable(lock);
break;

102
src/ipc.c
View File

@ -68,7 +68,7 @@ extern void (*rt_object_put_hook)(struct rt_object *object);
*
* @warning This function can be called from all IPC initialization and creation.
*/
rt_inline rt_err_t rt_ipc_object_init(struct rt_ipc_object *ipc)
rt_inline rt_err_t _ipc_object_init(struct rt_ipc_object *ipc)
{
/* initialize ipc object */
rt_list_init(&(ipc->suspend_thread));
@ -106,9 +106,9 @@ rt_inline rt_err_t rt_ipc_object_init(struct rt_ipc_object *ipc)
* rt_sem_take(), rt_mutex_take(), rt_event_recv(), rt_mb_send_wait(),
* rt_mb_recv(), rt_mq_recv(), rt_mq_send_wait()
*/
rt_inline rt_err_t rt_ipc_list_suspend(rt_list_t *list,
struct rt_thread *thread,
rt_uint8_t flag)
rt_inline rt_err_t _ipc_list_suspend(rt_list_t *list,
struct rt_thread *thread,
rt_uint8_t flag)
{
/* suspend thread */
rt_thread_suspend(thread);
@ -175,7 +175,7 @@ rt_inline rt_err_t rt_ipc_list_suspend(rt_list_t *list,
* rt_sem_release(), rt_mutex_release(), rt_mb_send_wait(), rt_mq_send_wait(),
* rt_mb_urgent(), rt_mb_recv(), rt_mq_urgent(), rt_mq_recv(),
*/
rt_inline rt_err_t rt_ipc_list_resume(rt_list_t *list)
rt_inline rt_err_t _ipc_list_resume(rt_list_t *list)
{
struct rt_thread *thread;
@ -204,7 +204,7 @@ rt_inline rt_err_t rt_ipc_list_resume(rt_list_t *list)
* When the return value is any other values, it means this operation failed.
*
*/
rt_inline rt_err_t rt_ipc_list_resume_all(rt_list_t *list)
rt_inline rt_err_t _ipc_list_resume_all(rt_list_t *list)
{
struct rt_thread *thread;
register rt_ubase_t temp;
@ -292,7 +292,7 @@ rt_err_t rt_sem_init(rt_sem_t sem,
rt_object_init(&(sem->parent.parent), RT_Object_Class_Semaphore, name);
/* initialize ipc object */
rt_ipc_object_init(&(sem->parent));
_ipc_object_init(&(sem->parent));
/* set initial value */
sem->value = (rt_uint16_t)value;
@ -331,7 +331,7 @@ rt_err_t rt_sem_detach(rt_sem_t sem)
RT_ASSERT(rt_object_is_systemobject(&sem->parent.parent));
/* wakeup all suspended threads */
rt_ipc_list_resume_all(&(sem->parent.suspend_thread));
_ipc_list_resume_all(&(sem->parent.suspend_thread));
/* detach semaphore object */
rt_object_detach(&(sem->parent.parent));
@ -386,7 +386,7 @@ rt_sem_t rt_sem_create(const char *name, rt_uint32_t value, rt_uint8_t flag)
return sem;
/* initialize ipc object */
rt_ipc_object_init(&(sem->parent));
_ipc_object_init(&(sem->parent));
/* set initial value */
sem->value = value;
@ -427,7 +427,7 @@ rt_err_t rt_sem_delete(rt_sem_t sem)
RT_ASSERT(rt_object_is_systemobject(&sem->parent.parent) == RT_FALSE);
/* wakeup all suspended threads */
rt_ipc_list_resume_all(&(sem->parent.suspend_thread));
_ipc_list_resume_all(&(sem->parent.suspend_thread));
/* delete semaphore object */
rt_object_delete(&(sem->parent.parent));
@ -513,7 +513,7 @@ rt_err_t rt_sem_take(rt_sem_t sem, rt_int32_t time)
thread->name));
/* suspend thread */
rt_ipc_list_suspend(&(sem->parent.suspend_thread),
_ipc_list_suspend(&(sem->parent.suspend_thread),
thread,
sem->parent.parent.flag);
@ -607,7 +607,7 @@ rt_err_t rt_sem_release(rt_sem_t sem)
if (!rt_list_isempty(&sem->parent.suspend_thread))
{
/* resume the suspended thread */
rt_ipc_list_resume(&(sem->parent.suspend_thread));
_ipc_list_resume(&(sem->parent.suspend_thread));
need_schedule = RT_TRUE;
}
else
@ -667,7 +667,7 @@ rt_err_t rt_sem_control(rt_sem_t sem, int cmd, void *arg)
level = rt_hw_interrupt_disable();
/* resume all waiting thread */
rt_ipc_list_resume_all(&sem->parent.suspend_thread);
_ipc_list_resume_all(&sem->parent.suspend_thread);
/* set new value */
sem->value = (rt_uint16_t)value;
@ -730,7 +730,7 @@ rt_err_t rt_mutex_init(rt_mutex_t mutex, const char *name, rt_uint8_t flag)
rt_object_init(&(mutex->parent.parent), RT_Object_Class_Mutex, name);
/* initialize ipc object */
rt_ipc_object_init(&(mutex->parent));
_ipc_object_init(&(mutex->parent));
mutex->value = 1;
mutex->owner = RT_NULL;
@ -771,7 +771,7 @@ rt_err_t rt_mutex_detach(rt_mutex_t mutex)
RT_ASSERT(rt_object_is_systemobject(&mutex->parent.parent));
/* wakeup all suspended threads */
rt_ipc_list_resume_all(&(mutex->parent.suspend_thread));
_ipc_list_resume_all(&(mutex->parent.suspend_thread));
/* detach mutex object */
rt_object_detach(&(mutex->parent.parent));
@ -813,7 +813,7 @@ rt_mutex_t rt_mutex_create(const char *name, rt_uint8_t flag)
return mutex;
/* initialize ipc object */
rt_ipc_object_init(&(mutex->parent));
_ipc_object_init(&(mutex->parent));
mutex->value = 1;
mutex->owner = RT_NULL;
@ -856,7 +856,7 @@ rt_err_t rt_mutex_delete(rt_mutex_t mutex)
RT_ASSERT(rt_object_is_systemobject(&mutex->parent.parent) == RT_FALSE);
/* wakeup all suspended threads */
rt_ipc_list_resume_all(&(mutex->parent.suspend_thread));
_ipc_list_resume_all(&(mutex->parent.suspend_thread));
/* delete mutex object */
rt_object_delete(&(mutex->parent.parent));
@ -985,7 +985,7 @@ __again:
}
/* suspend current thread */
rt_ipc_list_suspend(&(mutex->parent.suspend_thread),
_ipc_list_suspend(&(mutex->parent.suspend_thread),
thread,
mutex->parent.parent.flag);
@ -1150,7 +1150,7 @@ rt_err_t rt_mutex_release(rt_mutex_t mutex)
}
/* resume thread */
rt_ipc_list_resume(&(mutex->parent.suspend_thread));
_ipc_list_resume(&(mutex->parent.suspend_thread));
need_schedule = RT_TRUE;
}
@ -1269,7 +1269,7 @@ rt_err_t rt_event_init(rt_event_t event, const char *name, rt_uint8_t flag)
event->parent.parent.flag = flag;
/* initialize ipc object */
rt_ipc_object_init(&(event->parent));
_ipc_object_init(&(event->parent));
/* initialize event */
event->set = 0;
@ -1305,7 +1305,7 @@ rt_err_t rt_event_detach(rt_event_t event)
RT_ASSERT(rt_object_is_systemobject(&event->parent.parent));
/* resume all suspended thread */
rt_ipc_list_resume_all(&(event->parent.suspend_thread));
_ipc_list_resume_all(&(event->parent.suspend_thread));
/* detach event object */
rt_object_detach(&(event->parent.parent));
@ -1358,7 +1358,7 @@ rt_event_t rt_event_create(const char *name, rt_uint8_t flag)
event->parent.parent.flag = flag;
/* initialize ipc object */
rt_ipc_object_init(&(event->parent));
_ipc_object_init(&(event->parent));
/* initialize event */
event->set = 0;
@ -1396,7 +1396,7 @@ rt_err_t rt_event_delete(rt_event_t event)
RT_DEBUG_NOT_IN_INTERRUPT;
/* resume all suspended thread */
rt_ipc_list_resume_all(&(event->parent.suspend_thread));
_ipc_list_resume_all(&(event->parent.suspend_thread));
/* delete event object */
rt_object_delete(&(event->parent.parent));
@ -1628,7 +1628,7 @@ rt_err_t rt_event_recv(rt_event_t event,
thread->event_info = option;
/* put thread to suspended thread list */
rt_ipc_list_suspend(&(event->parent.suspend_thread),
_ipc_list_suspend(&(event->parent.suspend_thread),
thread,
event->parent.parent.flag);
@ -1700,7 +1700,7 @@ rt_err_t rt_event_control(rt_event_t event, int cmd, void *arg)
level = rt_hw_interrupt_disable();
/* resume all waiting thread */
rt_ipc_list_resume_all(&event->parent.suspend_thread);
_ipc_list_resume_all(&event->parent.suspend_thread);
/* initialize event set */
event->set = 0;
@ -1781,7 +1781,7 @@ rt_err_t rt_mb_init(rt_mailbox_t mb,
mb->parent.parent.flag = flag;
/* initialize ipc object */
rt_ipc_object_init(&(mb->parent));
_ipc_object_init(&(mb->parent));
/* initialize mailbox */
mb->msg_pool = (rt_ubase_t *)msgpool;
@ -1824,9 +1824,9 @@ rt_err_t rt_mb_detach(rt_mailbox_t mb)
RT_ASSERT(rt_object_is_systemobject(&mb->parent.parent));
/* resume all suspended thread */
rt_ipc_list_resume_all(&(mb->parent.suspend_thread));
_ipc_list_resume_all(&(mb->parent.suspend_thread));
/* also resume all mailbox private suspended thread */
rt_ipc_list_resume_all(&(mb->suspend_sender_thread));
_ipc_list_resume_all(&(mb->suspend_sender_thread));
/* detach mailbox object */
rt_object_detach(&(mb->parent.parent));
@ -1882,7 +1882,7 @@ rt_mailbox_t rt_mb_create(const char *name, rt_size_t size, rt_uint8_t flag)
mb->parent.parent.flag = flag;
/* initialize ipc object */
rt_ipc_object_init(&(mb->parent));
_ipc_object_init(&(mb->parent));
/* initialize mailbox */
mb->size = size;
@ -1934,10 +1934,10 @@ rt_err_t rt_mb_delete(rt_mailbox_t mb)
RT_ASSERT(rt_object_is_systemobject(&mb->parent.parent) == RT_FALSE);
/* resume all suspended thread */
rt_ipc_list_resume_all(&(mb->parent.suspend_thread));
_ipc_list_resume_all(&(mb->parent.suspend_thread));
/* also resume all mailbox private suspended thread */
rt_ipc_list_resume_all(&(mb->suspend_sender_thread));
_ipc_list_resume_all(&(mb->suspend_sender_thread));
/* free mailbox pool */
RT_KERNEL_FREE(mb->msg_pool);
@ -2020,7 +2020,7 @@ rt_err_t rt_mb_send_wait(rt_mailbox_t mb,
RT_DEBUG_IN_THREAD_CONTEXT;
/* suspend current thread */
rt_ipc_list_suspend(&(mb->suspend_sender_thread),
_ipc_list_suspend(&(mb->suspend_sender_thread),
thread,
mb->parent.parent.flag);
@ -2087,7 +2087,7 @@ rt_err_t rt_mb_send_wait(rt_mailbox_t mb,
/* resume suspended thread */
if (!rt_list_isempty(&mb->parent.suspend_thread))
{
rt_ipc_list_resume(&(mb->parent.suspend_thread));
_ipc_list_resume(&(mb->parent.suspend_thread));
/* enable interrupt */
rt_hw_interrupt_enable(temp);
@ -2183,7 +2183,7 @@ rt_err_t rt_mb_urgent(rt_mailbox_t mb, rt_ubase_t value)
/* resume suspended thread */
if (!rt_list_isempty(&mb->parent.suspend_thread))
{
rt_ipc_list_resume(&(mb->parent.suspend_thread));
_ipc_list_resume(&(mb->parent.suspend_thread));
/* enable interrupt */
rt_hw_interrupt_enable(temp);
@ -2266,7 +2266,7 @@ rt_err_t rt_mb_recv(rt_mailbox_t mb, rt_ubase_t *value, rt_int32_t timeout)
RT_DEBUG_IN_THREAD_CONTEXT;
/* suspend current thread */
rt_ipc_list_suspend(&(mb->parent.suspend_thread),
_ipc_list_suspend(&(mb->parent.suspend_thread),
thread,
mb->parent.parent.flag);
@ -2329,7 +2329,7 @@ rt_err_t rt_mb_recv(rt_mailbox_t mb, rt_ubase_t *value, rt_int32_t timeout)
/* resume suspended thread */
if (!rt_list_isempty(&(mb->suspend_sender_thread)))
{
rt_ipc_list_resume(&(mb->suspend_sender_thread));
_ipc_list_resume(&(mb->suspend_sender_thread));
/* enable interrupt */
rt_hw_interrupt_enable(temp);
@ -2379,9 +2379,9 @@ rt_err_t rt_mb_control(rt_mailbox_t mb, int cmd, void *arg)
level = rt_hw_interrupt_disable();
/* resume all waiting thread */
rt_ipc_list_resume_all(&(mb->parent.suspend_thread));
_ipc_list_resume_all(&(mb->parent.suspend_thread));
/* also resume all mailbox private suspended thread */
rt_ipc_list_resume_all(&(mb->suspend_sender_thread));
_ipc_list_resume_all(&(mb->suspend_sender_thread));
/* re-init mailbox */
mb->entry = 0;
@ -2478,7 +2478,7 @@ rt_err_t rt_mq_init(rt_mq_t mq,
mq->parent.parent.flag = flag;
/* initialize ipc object */
rt_ipc_object_init(&(mq->parent));
_ipc_object_init(&(mq->parent));
/* set message pool */
mq->msg_pool = msgpool;
@ -2538,9 +2538,9 @@ rt_err_t rt_mq_detach(rt_mq_t mq)
RT_ASSERT(rt_object_is_systemobject(&mq->parent.parent));
/* resume all suspended thread */
rt_ipc_list_resume_all(&mq->parent.suspend_thread);
_ipc_list_resume_all(&mq->parent.suspend_thread);
/* also resume all message queue private suspended thread */
rt_ipc_list_resume_all(&(mq->suspend_sender_thread));
_ipc_list_resume_all(&(mq->suspend_sender_thread));
/* detach message queue object */
rt_object_detach(&(mq->parent.parent));
@ -2602,7 +2602,7 @@ rt_mq_t rt_mq_create(const char *name,
mq->parent.parent.flag = flag;
/* initialize ipc object */
rt_ipc_object_init(&(mq->parent));
_ipc_object_init(&(mq->parent));
/* initialize message queue */
@ -2673,9 +2673,9 @@ rt_err_t rt_mq_delete(rt_mq_t mq)
RT_ASSERT(rt_object_is_systemobject(&mq->parent.parent) == RT_FALSE);
/* resume all suspended thread */
rt_ipc_list_resume_all(&(mq->parent.suspend_thread));
_ipc_list_resume_all(&(mq->parent.suspend_thread));
/* also resume all message queue private suspended thread */
rt_ipc_list_resume_all(&(mq->suspend_sender_thread));
_ipc_list_resume_all(&(mq->suspend_sender_thread));
/* free message queue pool */
RT_KERNEL_FREE(mq->msg_pool);
@ -2776,7 +2776,7 @@ rt_err_t rt_mq_send_wait(rt_mq_t mq,
RT_DEBUG_IN_THREAD_CONTEXT;
/* suspend current thread */
rt_ipc_list_suspend(&(mq->suspend_sender_thread),
_ipc_list_suspend(&(mq->suspend_sender_thread),
thread,
mq->parent.parent.flag);
@ -2862,7 +2862,7 @@ rt_err_t rt_mq_send_wait(rt_mq_t mq,
/* resume suspended thread */
if (!rt_list_isempty(&mq->parent.suspend_thread))
{
rt_ipc_list_resume(&(mq->parent.suspend_thread));
_ipc_list_resume(&(mq->parent.suspend_thread));
/* enable interrupt */
rt_hw_interrupt_enable(temp);
@ -2991,7 +2991,7 @@ rt_err_t rt_mq_urgent(rt_mq_t mq, const void *buffer, rt_size_t size)
/* resume suspended thread */
if (!rt_list_isempty(&mq->parent.suspend_thread))
{
rt_ipc_list_resume(&(mq->parent.suspend_thread));
_ipc_list_resume(&(mq->parent.suspend_thread));
/* enable interrupt */
rt_hw_interrupt_enable(temp);
@ -3081,7 +3081,7 @@ rt_err_t rt_mq_recv(rt_mq_t mq,
}
/* suspend current thread */
rt_ipc_list_suspend(&(mq->parent.suspend_thread),
_ipc_list_suspend(&(mq->parent.suspend_thread),
thread,
mq->parent.parent.flag);
@ -3157,7 +3157,7 @@ rt_err_t rt_mq_recv(rt_mq_t mq,
/* resume suspended thread */
if (!rt_list_isempty(&(mq->suspend_sender_thread)))
{
rt_ipc_list_resume(&(mq->suspend_sender_thread));
_ipc_list_resume(&(mq->suspend_sender_thread));
/* enable interrupt */
rt_hw_interrupt_enable(temp);
@ -3208,9 +3208,9 @@ rt_err_t rt_mq_control(rt_mq_t mq, int cmd, void *arg)
level = rt_hw_interrupt_disable();
/* resume all waiting thread */
rt_ipc_list_resume_all(&mq->parent.suspend_thread);
_ipc_list_resume_all(&mq->parent.suspend_thread);
/* also resume all message queue private suspended thread */
rt_ipc_list_resume_all(&(mq->suspend_sender_thread));
_ipc_list_resume_all(&(mq->suspend_sender_thread));
/* release all message in the queue */
while (mq->msg_queue_head != RT_NULL)

View File

@ -198,6 +198,7 @@ RT_WEAK void *rt_memset(void *s, int c, rt_ubase_t count)
}
RTM_EXPORT(rt_memset);
#ifndef RT_USING_ASM_MEMCPY
/**
* This function will copy memory content from source address to destination
* address.
@ -208,7 +209,7 @@ RTM_EXPORT(rt_memset);
*
* @return the address of destination memory
*/
RT_WEAK void *rt_memcpy(void *dst, const void *src, rt_ubase_t count)
void *rt_memcpy(void *dst, const void *src, rt_ubase_t count)
{
#ifdef RT_KSERVICE_USING_TINY_SIZE
char *tmp = (char *)dst, *s = (char *)src;
@ -280,6 +281,7 @@ RT_WEAK void *rt_memcpy(void *dst, const void *src, rt_ubase_t count)
#endif /* RT_KSERVICE_USING_TINY_SIZE */
}
RTM_EXPORT(rt_memcpy);
#endif /* RT_USING_ASM_MEMCPY */
#ifndef RT_KSERVICE_USING_STDLIB

View File

@ -23,7 +23,7 @@
* 2013-12-21 Grissiom add rt_critical_level
* 2018-11-22 Jesven remove the current task from ready queue
* add per cpu ready queue
* add _get_highest_priority_thread to find highest priority task
* add _scheduler_get_highest_priority_thread to find highest priority task
* rt_schedule_insert_thread won't insert current task to ready queue
* in smp version, rt_hw_context_switch_interrupt maybe switch to
* new task directly
@ -119,7 +119,7 @@ static void _rt_scheduler_stack_check(struct rt_thread *thread)
* get the highest priority thread in ready queue
*/
#ifdef RT_USING_SMP
static struct rt_thread* _get_highest_priority_thread(rt_ubase_t *highest_prio)
static struct rt_thread* _scheduler_get_highest_priority_thread(rt_ubase_t *highest_prio)
{
register struct rt_thread *highest_priority_thread;
register rt_ubase_t highest_ready_priority, local_highest_ready_priority;
@ -155,7 +155,7 @@ static struct rt_thread* _get_highest_priority_thread(rt_ubase_t *highest_prio)
return highest_priority_thread;
}
#else
static struct rt_thread* _get_highest_priority_thread(rt_ubase_t *highest_prio)
static struct rt_thread* _scheduler_get_highest_priority_thread(rt_ubase_t *highest_prio)
{
register struct rt_thread *highest_priority_thread;
register rt_ubase_t highest_ready_priority;
@ -241,7 +241,7 @@ void rt_system_scheduler_start(void)
register struct rt_thread *to_thread;
rt_ubase_t highest_ready_priority;
to_thread = _get_highest_priority_thread(&highest_ready_priority);
to_thread = _scheduler_get_highest_priority_thread(&highest_ready_priority);
#ifdef RT_USING_SMP
to_thread->oncpu = rt_hw_cpu_id();
@ -329,7 +329,7 @@ void rt_schedule(void)
if (rt_thread_ready_priority_group != 0 || pcpu->priority_group != 0)
{
to_thread = _get_highest_priority_thread(&highest_ready_priority);
to_thread = _scheduler_get_highest_priority_thread(&highest_ready_priority);
current_thread->oncpu = RT_CPU_DETACHED;
if ((current_thread->stat & RT_THREAD_STAT_MASK) == RT_THREAD_RUNNING)
{
@ -429,7 +429,7 @@ void rt_schedule(void)
/* need_insert_from_thread: need to insert from_thread to ready queue */
int need_insert_from_thread = 0;
to_thread = _get_highest_priority_thread(&highest_ready_priority);
to_thread = _scheduler_get_highest_priority_thread(&highest_ready_priority);
if ((rt_current_thread->stat & RT_THREAD_STAT_MASK) == RT_THREAD_RUNNING)
{
@ -582,7 +582,7 @@ void rt_scheduler_do_irq_switch(void *context)
if (rt_thread_ready_priority_group != 0 || pcpu->priority_group != 0)
{
to_thread = _get_highest_priority_thread(&highest_ready_priority);
to_thread = _scheduler_get_highest_priority_thread(&highest_ready_priority);
current_thread->oncpu = RT_CPU_DETACHED;
if ((current_thread->stat & RT_THREAD_STAT_MASK) == RT_THREAD_RUNNING)
{