mirror of
https://github.com/RT-Thread/rt-thread.git
synced 2026-06-13 04:33:18 +08:00
@@ -0,0 +1,20 @@
|
||||
name: Check File Format and License
|
||||
|
||||
on: [pull_request]
|
||||
|
||||
jobs:
|
||||
scancode_job:
|
||||
runs-on: ubuntu-latest
|
||||
name: Scan code format and license
|
||||
steps:
|
||||
- uses: actions/checkout@v2
|
||||
- name: Set up Python
|
||||
uses: actions/setup-python@master
|
||||
with:
|
||||
python-version: 3.8
|
||||
|
||||
- name: Check Format and License
|
||||
shell: bash
|
||||
run: |
|
||||
pip install click chardet
|
||||
python tools/file_check.py check 'https://github.com/RT-Thread/rt-thread' 'master'
|
||||
@@ -6,8 +6,8 @@
|
||||
* Change Logs:
|
||||
* Date Author Notes
|
||||
* 2020-10-30 CDT first version
|
||||
* 2021-01-18 CDT MOdify SRAM_SIZE
|
||||
*/
|
||||
|
||||
|
||||
#ifndef __BOARD_H__
|
||||
#define __BOARD_H__
|
||||
@@ -18,7 +18,7 @@
|
||||
|
||||
/* board configuration */
|
||||
#define SRAM_BASE 0x1FFE0000
|
||||
#define SRAM_SIZE 0x20000
|
||||
#define SRAM_SIZE 0x80000
|
||||
#define SRAM_END (SRAM_BASE + SRAM_SIZE)
|
||||
|
||||
/* High speed sram. */
|
||||
|
||||
@@ -6,9 +6,9 @@
|
||||
* Change Logs:
|
||||
* Date Author Notes
|
||||
* 2020-10-30 CDT first version
|
||||
* 2021-01-18 CDT modify i2c gpio init
|
||||
*/
|
||||
|
||||
|
||||
/*******************************************************************************
|
||||
* Include files
|
||||
******************************************************************************/
|
||||
@@ -65,10 +65,8 @@ static const struct hc32_soft_i2c_config soft_i2c_config[] =
|
||||
#endif
|
||||
};
|
||||
|
||||
|
||||
static struct hc32_i2c i2c_obj[sizeof(soft_i2c_config) / sizeof(soft_i2c_config[0])];
|
||||
|
||||
|
||||
/*******************************************************************************
|
||||
* Function implementation - global ('extern') and local ('static')
|
||||
******************************************************************************/
|
||||
@@ -81,8 +79,8 @@ static void hc32_i2c_gpio_init(struct hc32_i2c *i2c)
|
||||
{
|
||||
struct hc32_soft_i2c_config* cfg = (struct hc32_soft_i2c_config*)i2c->ops.data;
|
||||
|
||||
rt_pin_mode(cfg->scl_pin, PIN_MODE_OUTPUT);
|
||||
rt_pin_mode(cfg->sda_pin, PIN_MODE_OUTPUT);
|
||||
rt_pin_mode(cfg->scl_pin, PIN_MODE_OUTPUT_OD);
|
||||
rt_pin_mode(cfg->sda_pin, PIN_MODE_OUTPUT_OD);
|
||||
|
||||
rt_pin_write(cfg->scl_pin, PIN_HIGH);
|
||||
rt_pin_write(cfg->sda_pin, PIN_HIGH);
|
||||
@@ -98,8 +96,6 @@ static void hc32_set_sda(void *data, rt_int32_t state)
|
||||
{
|
||||
struct hc32_soft_i2c_config* cfg = (struct hc32_soft_i2c_config*)data;
|
||||
|
||||
rt_pin_mode(cfg->sda_pin, PIN_MODE_OUTPUT);
|
||||
|
||||
if (state)
|
||||
rt_pin_write(cfg->sda_pin, PIN_HIGH);
|
||||
else
|
||||
@@ -116,8 +112,6 @@ static void hc32_set_scl(void *data, rt_int32_t state)
|
||||
{
|
||||
struct hc32_soft_i2c_config* cfg = (struct hc32_soft_i2c_config*)data;
|
||||
|
||||
rt_pin_mode(cfg->scl_pin, PIN_MODE_OUTPUT);
|
||||
|
||||
if (state)
|
||||
rt_pin_write(cfg->scl_pin, PIN_HIGH);
|
||||
else
|
||||
@@ -133,8 +127,6 @@ static rt_int32_t hc32_get_sda(void *data)
|
||||
{
|
||||
struct hc32_soft_i2c_config* cfg = (struct hc32_soft_i2c_config*)data;
|
||||
|
||||
rt_pin_mode(cfg->sda_pin, PIN_MODE_INPUT);
|
||||
|
||||
return rt_pin_read(cfg->sda_pin);
|
||||
}
|
||||
|
||||
@@ -147,8 +139,6 @@ static rt_int32_t hc32_get_scl(void *data)
|
||||
{
|
||||
struct hc32_soft_i2c_config* cfg = (struct hc32_soft_i2c_config*)data;
|
||||
|
||||
rt_pin_mode(cfg->scl_pin, PIN_MODE_INPUT);
|
||||
|
||||
return rt_pin_read(cfg->scl_pin);
|
||||
}
|
||||
|
||||
@@ -210,7 +200,6 @@ int hc32_hw_i2c_init(void)
|
||||
}
|
||||
INIT_BOARD_EXPORT(hc32_hw_i2c_init);
|
||||
|
||||
|
||||
#endif /* RT_USING_I2C */
|
||||
|
||||
/*******************************************************************************
|
||||
|
||||
+32
-12
@@ -72,8 +72,10 @@ CONFIG_RT_VER_NUM=0x40003
|
||||
#
|
||||
# RT-Thread Components
|
||||
#
|
||||
# CONFIG_RT_USING_COMPONENTS_INIT is not set
|
||||
# CONFIG_RT_USING_USER_MAIN is not set
|
||||
CONFIG_RT_USING_COMPONENTS_INIT=y
|
||||
CONFIG_RT_USING_USER_MAIN=y
|
||||
CONFIG_RT_MAIN_THREAD_STACK_SIZE=2048
|
||||
CONFIG_RT_MAIN_THREAD_PRIORITY=10
|
||||
|
||||
#
|
||||
# C++ features
|
||||
@@ -133,8 +135,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
|
||||
|
||||
#
|
||||
# Device Drivers
|
||||
@@ -285,8 +285,6 @@ CONFIG_RT_LIBC_USING_TIME=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
|
||||
@@ -301,6 +299,10 @@ CONFIG_RT_LIBC_USING_TIME=y
|
||||
# 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
|
||||
|
||||
#
|
||||
# security packages
|
||||
@@ -382,6 +384,8 @@ CONFIG_RT_LIBC_USING_TIME=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_THREAD_POOL is not set
|
||||
# CONFIG_PKG_USING_ROBOTS is not set
|
||||
# CONFIG_PKG_USING_EV is not set
|
||||
@@ -409,6 +413,7 @@ CONFIG_RT_LIBC_USING_TIME=y
|
||||
# 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
|
||||
|
||||
#
|
||||
# peripheral libraries and drivers
|
||||
@@ -471,6 +476,23 @@ CONFIG_RT_LIBC_USING_TIME=y
|
||||
# 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
|
||||
|
||||
#
|
||||
# miscellaneous packages
|
||||
@@ -502,25 +524,23 @@ CONFIG_RT_LIBC_USING_TIME=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
|
||||
# CONFIG_PKG_USING_STATE_MACHINE is not set
|
||||
# CONFIG_PKG_USING_MCURSES is not set
|
||||
# CONFIG_PKG_USING_COWSAY is not set
|
||||
CONFIG_SOC_SIMULATOR=y
|
||||
CONFIG_RT_USING_DFS_WINSHAREDIR=y
|
||||
|
||||
@@ -18,8 +18,16 @@ config PKGS_DIR
|
||||
source "$RTT_DIR/Kconfig"
|
||||
source "$PKGS_DIR/Kconfig"
|
||||
|
||||
config SOC_SIMULATOR
|
||||
bool
|
||||
select RT_USING_COMPONENTS_INIT
|
||||
select RT_USING_USER_MAIN
|
||||
default y
|
||||
|
||||
if RT_USING_DFS
|
||||
config RT_USING_DFS_WINSHAREDIR
|
||||
bool "Enable shared file system between windows"
|
||||
default n
|
||||
endif
|
||||
|
||||
|
||||
|
||||
@@ -86,6 +86,19 @@ def ObjRemove(objs, remove):
|
||||
objs.remove(item)
|
||||
return
|
||||
|
||||
def ProjectRemove(group, remove):
|
||||
global Projects
|
||||
for item in Projects:
|
||||
if item['name'] == group:
|
||||
for src in item['src']:
|
||||
if os.path.basename(str(src)) in remove:
|
||||
# print(type(src), os.path.basename(str(src)) )
|
||||
item['src'].remove(src)
|
||||
return
|
||||
|
||||
ObjRemove(objs, ['components.obj', 'components.o', 'components.c'])
|
||||
ProjectRemove('Kernel', ['components.obj', 'components.o', 'components.c'])
|
||||
|
||||
# build program -shared
|
||||
if GetDepend('RT_USING_MODULE'):
|
||||
# Remove module.c in $RTT_ROOT/src
|
||||
|
||||
@@ -11,37 +11,8 @@
|
||||
#include <stdio.h>
|
||||
#include <board.h>
|
||||
|
||||
extern int platform_init(void);
|
||||
extern int platform_post_init(void);
|
||||
extern int mnt_init(void);
|
||||
|
||||
void rt_init_thread_entry(void *parameter)
|
||||
int main(void)
|
||||
{
|
||||
rt_kprintf("Hello RT-Thread!\n");
|
||||
|
||||
platform_init();
|
||||
mnt_init();
|
||||
|
||||
platform_post_init();
|
||||
|
||||
#if defined(PKG_USING_GUIENGINE) && defined(GUIENGINE_USING_DEMO)
|
||||
{
|
||||
extern int rt_gui_demo_init(void);
|
||||
rt_gui_demo_init();
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
int rt_application_init()
|
||||
{
|
||||
rt_thread_t tid;
|
||||
|
||||
tid = rt_thread_create("init",
|
||||
rt_init_thread_entry, RT_NULL,
|
||||
2048, RT_THREAD_PRIORITY_MAX / 3, 20);
|
||||
|
||||
if (tid != RT_NULL)
|
||||
rt_thread_startup(tid);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -15,8 +15,6 @@
|
||||
|
||||
int mnt_init(void)
|
||||
{
|
||||
dfs_init();
|
||||
|
||||
#ifdef RT_USING_DFS_WINSHAREDIR
|
||||
extern int dfs_win32_init(void);
|
||||
extern rt_err_t rt_win_sharedir_init(const char *name);
|
||||
@@ -54,5 +52,5 @@ int mnt_init(void)
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
INIT_COMPONENT_EXPORT(mnt_init);
|
||||
#endif
|
||||
|
||||
@@ -13,8 +13,6 @@
|
||||
|
||||
int platform_init(void)
|
||||
{
|
||||
finsh_system_init();
|
||||
|
||||
#ifdef RT_USING_LWIP
|
||||
#ifdef RT_USING_TAPNETIF
|
||||
tap_netif_hw_init();
|
||||
@@ -39,6 +37,7 @@ int platform_init(void)
|
||||
|
||||
return 0;
|
||||
}
|
||||
INIT_COMPONENT_EXPORT(platform_init);
|
||||
|
||||
int platform_post_init(void)
|
||||
{
|
||||
@@ -51,6 +50,6 @@ int platform_post_init(void)
|
||||
rt_hw_sdl_start();
|
||||
}
|
||||
#endif
|
||||
|
||||
return 0;
|
||||
}
|
||||
INIT_COMPONENT_EXPORT(platform_post_init);
|
||||
|
||||
@@ -1,73 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) 2006-2021, RT-Thread Development Team
|
||||
*
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*
|
||||
* Change Logs:
|
||||
* Date Author Notes
|
||||
* 2012-09-03 prife first implementation
|
||||
*/
|
||||
#include <rthw.h>
|
||||
#include <rtthread.h>
|
||||
|
||||
#include "board.h"
|
||||
|
||||
/**
|
||||
* @addtogroup win32
|
||||
*/
|
||||
|
||||
/*@{*/
|
||||
|
||||
extern int rt_application_init(void);
|
||||
extern rt_uint8_t *heap;
|
||||
|
||||
/**
|
||||
* This function will startup RT-Thread RTOS.
|
||||
*/
|
||||
void rtthread_startup(void)
|
||||
{
|
||||
/* init board */
|
||||
rt_hw_board_init();
|
||||
|
||||
/* show version */
|
||||
rt_show_version();
|
||||
|
||||
/* init timer system */
|
||||
rt_system_timer_init();
|
||||
|
||||
#ifdef RT_USING_HEAP
|
||||
/* init memory system */
|
||||
rt_system_heap_init((void *)heap, (void *)&heap[RT_HEAP_SIZE - 1]);
|
||||
#endif
|
||||
|
||||
/* init scheduler system */
|
||||
rt_system_scheduler_init();
|
||||
|
||||
/* init application */
|
||||
rt_application_init();
|
||||
|
||||
/* init timer thread */
|
||||
rt_system_timer_thread_init();
|
||||
|
||||
/* init idle thread */
|
||||
rt_thread_idle_init();
|
||||
|
||||
/* start scheduler */
|
||||
rt_system_scheduler_start();
|
||||
|
||||
/* never reach here */
|
||||
return ;
|
||||
}
|
||||
|
||||
int main(void)
|
||||
{
|
||||
/* disable interrupt first */
|
||||
rt_hw_interrupt_disable();
|
||||
|
||||
/* startup RT-Thread RTOS */
|
||||
rtthread_startup();
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
/*@}*/
|
||||
@@ -18,7 +18,6 @@
|
||||
/**
|
||||
* @addtogroup simulator on win32
|
||||
*/
|
||||
rt_uint8_t *heap;
|
||||
|
||||
rt_uint8_t *rt_hw_sram_init(void)
|
||||
{
|
||||
@@ -33,6 +32,10 @@ rt_uint8_t *rt_hw_sram_init(void)
|
||||
exit(1);
|
||||
#endif
|
||||
}
|
||||
#ifdef RT_USING_HEAP
|
||||
/* init memory system */
|
||||
rt_system_heap_init((void*)heap, (void*)&heap[RT_HEAP_SIZE - 1]);
|
||||
#endif
|
||||
return heap;
|
||||
}
|
||||
|
||||
@@ -87,10 +90,10 @@ FINSH_FUNCTION_EXPORT_ALIAS(rt_hw_exit, __cmd_quit, exit rt-thread);
|
||||
/**
|
||||
* This function will initial win32
|
||||
*/
|
||||
void rt_hw_board_init()
|
||||
int rt_hw_board_init(void)
|
||||
{
|
||||
/* init system memory */
|
||||
heap = rt_hw_sram_init();
|
||||
rt_hw_sram_init();
|
||||
|
||||
uart_console_init();
|
||||
|
||||
@@ -101,5 +104,10 @@ void rt_hw_board_init()
|
||||
#if defined(RT_USING_CONSOLE)
|
||||
rt_console_set_device(RT_CONSOLE_DEVICE_NAME);
|
||||
#endif
|
||||
/* init board */
|
||||
#ifdef RT_USING_COMPONENTS_INIT
|
||||
rt_components_board_init();
|
||||
#endif
|
||||
return 0;
|
||||
}
|
||||
/*@}*/
|
||||
|
||||
@@ -9,7 +9,7 @@
|
||||
*/
|
||||
#ifndef __BOARD_H__
|
||||
#define __BOARD_H__
|
||||
void rt_hw_board_init(void);
|
||||
int rt_hw_board_init(void);
|
||||
rt_uint8_t *rt_hw_sram_init(void);
|
||||
|
||||
/* SD Card init function */
|
||||
|
||||
@@ -133,7 +133,6 @@ static rt_err_t rt_sdcard_control(rt_device_t dev, int cmd, void *args)
|
||||
return RT_EOK;
|
||||
}
|
||||
|
||||
|
||||
rt_err_t rt_hw_sdcard_init(const char *spi_device_name)
|
||||
{
|
||||
int size;
|
||||
@@ -144,6 +143,11 @@ rt_err_t rt_hw_sdcard_init(const char *spi_device_name)
|
||||
device = &(sd->parent);
|
||||
|
||||
lock = rt_mutex_create("lock", RT_IPC_FLAG_FIFO);
|
||||
if (lock == RT_NULL)
|
||||
{
|
||||
LOG_E("Create mutex in rt_hw_sdcard_init failed!");
|
||||
return -RT_ERROR;
|
||||
}
|
||||
|
||||
/* open sd card file, if not exist, then create it */
|
||||
sd->file = fopen(SDCARD_SIM, "rb+");
|
||||
|
||||
@@ -221,6 +221,10 @@ static void sdlfb_hw_init(void)
|
||||
rt_device_register(RT_DEVICE(&_device), "sdl", RT_DEVICE_FLAG_RDWR);
|
||||
|
||||
sdllock = rt_mutex_create("fb", RT_IPC_FLAG_FIFO);
|
||||
if (sdllock == RT_NULL)
|
||||
{
|
||||
LOG_E("Create mutex for sdlfb failed!");
|
||||
}
|
||||
}
|
||||
|
||||
#ifdef _WIN32
|
||||
|
||||
@@ -43,6 +43,10 @@
|
||||
|
||||
/* RT-Thread Components */
|
||||
|
||||
#define RT_USING_COMPONENTS_INIT
|
||||
#define RT_USING_USER_MAIN
|
||||
#define RT_MAIN_THREAD_STACK_SIZE 2048
|
||||
#define RT_MAIN_THREAD_PRIORITY 10
|
||||
|
||||
/* C++ features */
|
||||
|
||||
@@ -157,14 +161,18 @@
|
||||
/* peripheral libraries and drivers */
|
||||
|
||||
|
||||
/* AI packages */
|
||||
|
||||
|
||||
/* miscellaneous packages */
|
||||
|
||||
|
||||
/* samples: kernel and components samples */
|
||||
|
||||
|
||||
/* games: games run on RT-Thread console */
|
||||
/* entertainment: terminal games and other interesting software packages */
|
||||
|
||||
#define SOC_SIMULATOR
|
||||
#define RT_USING_DFS_WINSHAREDIR
|
||||
#include "rtconfig_project.h"
|
||||
|
||||
|
||||
@@ -134,7 +134,12 @@ CONFIG_RT_USING_RTC=y
|
||||
# CONFIG_RT_USING_ALARM is not set
|
||||
# CONFIG_RT_USING_SOFT_RTC is not set
|
||||
# CONFIG_RT_USING_SDIO is not set
|
||||
# CONFIG_RT_USING_SPI is not set
|
||||
CONFIG_RT_USING_SPI=y
|
||||
# CONFIG_RT_USING_QSPI is not set
|
||||
# CONFIG_RT_USING_SPI_MSD is not set
|
||||
# CONFIG_RT_USING_SFUD is not set
|
||||
# CONFIG_RT_USING_ENC28J60 is not set
|
||||
# CONFIG_RT_USING_SPI_WIFI is not set
|
||||
CONFIG_RT_USING_WDT=y
|
||||
# CONFIG_RT_USING_AUDIO is not set
|
||||
# CONFIG_RT_USING_SENSOR is not set
|
||||
@@ -316,6 +321,7 @@ CONFIG_RT_USING_LIBC=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_ADBD is not set
|
||||
# CONFIG_PKG_USING_COREMARK is not set
|
||||
# CONFIG_PKG_USING_DHRYSTONE is not set
|
||||
@@ -331,6 +337,7 @@ CONFIG_RT_USING_LIBC=y
|
||||
# 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
|
||||
|
||||
#
|
||||
# system packages
|
||||
@@ -370,6 +377,7 @@ CONFIG_RT_USING_LIBC=y
|
||||
# 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_PRINTF is not set
|
||||
|
||||
#
|
||||
# peripheral libraries and drivers
|
||||
@@ -378,6 +386,7 @@ CONFIG_RT_USING_LIBC=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
|
||||
@@ -430,6 +439,7 @@ CONFIG_RT_USING_LIBC=y
|
||||
# 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
|
||||
|
||||
#
|
||||
# miscellaneous packages
|
||||
@@ -494,6 +504,16 @@ CONFIG_BSP_USING_GPIO=y
|
||||
CONFIG_BSP_USING_UART=y
|
||||
CONFIG_BSP_USING_UART1=y
|
||||
# CONFIG_BSP_UART1_RX_USING_DMA is not set
|
||||
# CONFIG_BSP_USING_I2C is not set
|
||||
CONFIG_BSP_USING_SPI=y
|
||||
CONFIG_BSP_USING_SPI2=y
|
||||
# CONFIG_BSP_SPI2_TX_USING_DMA is not set
|
||||
# CONFIG_BSP_SPI2_RX_USING_DMA is not set
|
||||
# CONFIG_BSP_USING_CRC is not set
|
||||
# CONFIG_BSP_USING_RNG is not set
|
||||
# CONFIG_BSP_USING_UDID is not set
|
||||
|
||||
#
|
||||
# Onboard Peripheral Drivers
|
||||
#
|
||||
CONFIG_BSP_USING_SPI_LCD=y
|
||||
|
||||
File diff suppressed because one or more lines are too long
@@ -5,19 +5,22 @@ KeepUserPlacement=false
|
||||
Mcu.Family=STM32L4
|
||||
Mcu.IP0=NVIC
|
||||
Mcu.IP1=RCC
|
||||
Mcu.IP2=SYS
|
||||
Mcu.IP3=USART1
|
||||
Mcu.IPNb=4
|
||||
Mcu.IP2=SPI2
|
||||
Mcu.IP3=SYS
|
||||
Mcu.IP4=USART1
|
||||
Mcu.IPNb=5
|
||||
Mcu.Name=STM32L431R(B-C)Tx
|
||||
Mcu.Package=LQFP64
|
||||
Mcu.Pin0=PC14-OSC32_IN (PC14)
|
||||
Mcu.Pin1=PC15-OSC32_OUT (PC15)
|
||||
Mcu.Pin2=PH0-OSC_IN (PH0)
|
||||
Mcu.Pin3=PH1-OSC_OUT (PH1)
|
||||
Mcu.Pin4=PA9
|
||||
Mcu.Pin5=PA10
|
||||
Mcu.Pin6=VP_SYS_VS_Systick
|
||||
Mcu.PinsNb=7
|
||||
Mcu.Pin4=PC3
|
||||
Mcu.Pin5=PB13
|
||||
Mcu.Pin6=PA9
|
||||
Mcu.Pin7=PA10
|
||||
Mcu.Pin8=VP_SYS_VS_Systick
|
||||
Mcu.PinsNb=9
|
||||
Mcu.ThirdPartyNb=0
|
||||
Mcu.UserConstants=
|
||||
Mcu.UserName=STM32L431RCTx
|
||||
@@ -40,12 +43,18 @@ PA10.Signal=USART1_RX
|
||||
PA9.Locked=true
|
||||
PA9.Mode=Asynchronous
|
||||
PA9.Signal=USART1_TX
|
||||
PB13.Locked=true
|
||||
PB13.Mode=Simplex_Bidirectional_Master
|
||||
PB13.Signal=SPI2_SCK
|
||||
PC14-OSC32_IN\ (PC14).Locked=true
|
||||
PC14-OSC32_IN\ (PC14).Mode=LSE-External-Oscillator
|
||||
PC14-OSC32_IN\ (PC14).Signal=RCC_OSC32_IN
|
||||
PC15-OSC32_OUT\ (PC15).Locked=true
|
||||
PC15-OSC32_OUT\ (PC15).Mode=LSE-External-Oscillator
|
||||
PC15-OSC32_OUT\ (PC15).Signal=RCC_OSC32_OUT
|
||||
PC3.Locked=true
|
||||
PC3.Mode=Simplex_Bidirectional_Master
|
||||
PC3.Signal=SPI2_MOSI
|
||||
PH0-OSC_IN\ (PH0).Locked=true
|
||||
PH0-OSC_IN\ (PH0).Mode=HSE-External-Oscillator
|
||||
PH0-OSC_IN\ (PH0).Signal=RCC_OSC_IN
|
||||
@@ -121,6 +130,11 @@ RCC.USART3Freq_Value=80000000
|
||||
RCC.VCOInputFreq_Value=4000000
|
||||
RCC.VCOOutputFreq_Value=160000000
|
||||
RCC.VCOSAI1OutputFreq_Value=32000000
|
||||
SPI2.CalculateBaudRate=40.0 MBits/s
|
||||
SPI2.Direction=SPI_DIRECTION_1LINE
|
||||
SPI2.IPParameters=VirtualType,Mode,Direction,CalculateBaudRate
|
||||
SPI2.Mode=SPI_MODE_MASTER
|
||||
SPI2.VirtualType=VM_MASTER
|
||||
USART1.IPParameters=VirtualMode-Asynchronous
|
||||
USART1.VirtualMode-Asynchronous=VM_ASYNC
|
||||
VP_SYS_VS_Systick.Mode=SysTick
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
******************************************************************************
|
||||
* @attention
|
||||
*
|
||||
* <h2><center>© COPYRIGHT(c) 2020 STMicroelectronics</center></h2>
|
||||
* <h2><center>© COPYRIGHT(c) 2021 STMicroelectronics</center></h2>
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without modification,
|
||||
* are permitted provided that the following conditions are met:
|
||||
@@ -86,7 +86,7 @@
|
||||
/*#define HAL_SD_MODULE_ENABLED */
|
||||
/*#define HAL_SMBUS_MODULE_ENABLED */
|
||||
/*#define HAL_SMARTCARD_MODULE_ENABLED */
|
||||
/*#define HAL_SPI_MODULE_ENABLED */
|
||||
#define HAL_SPI_MODULE_ENABLED
|
||||
/*#define HAL_SRAM_MODULE_ENABLED */
|
||||
/*#define HAL_SWPMI_MODULE_ENABLED */
|
||||
/*#define HAL_TIM_MODULE_ENABLED */
|
||||
|
||||
@@ -41,6 +41,8 @@
|
||||
/* USER CODE END PM */
|
||||
|
||||
/* Private variables ---------------------------------------------------------*/
|
||||
SPI_HandleTypeDef hspi2;
|
||||
|
||||
UART_HandleTypeDef huart1;
|
||||
|
||||
/* USER CODE BEGIN PV */
|
||||
@@ -50,6 +52,7 @@ UART_HandleTypeDef huart1;
|
||||
/* Private function prototypes -----------------------------------------------*/
|
||||
void SystemClock_Config(void);
|
||||
static void MX_GPIO_Init(void);
|
||||
static void MX_SPI2_Init(void);
|
||||
static void MX_USART1_UART_Init(void);
|
||||
/* USER CODE BEGIN PFP */
|
||||
|
||||
@@ -88,6 +91,7 @@ int main(void)
|
||||
|
||||
/* Initialize all configured peripherals */
|
||||
MX_GPIO_Init();
|
||||
MX_SPI2_Init();
|
||||
MX_USART1_UART_Init();
|
||||
/* USER CODE BEGIN 2 */
|
||||
|
||||
@@ -166,6 +170,46 @@ void SystemClock_Config(void)
|
||||
HAL_RCCEx_EnableMSIPLLMode();
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief SPI2 Initialization Function
|
||||
* @param None
|
||||
* @retval None
|
||||
*/
|
||||
static void MX_SPI2_Init(void)
|
||||
{
|
||||
|
||||
/* USER CODE BEGIN SPI2_Init 0 */
|
||||
|
||||
/* USER CODE END SPI2_Init 0 */
|
||||
|
||||
/* USER CODE BEGIN SPI2_Init 1 */
|
||||
|
||||
/* USER CODE END SPI2_Init 1 */
|
||||
/* SPI2 parameter configuration*/
|
||||
hspi2.Instance = SPI2;
|
||||
hspi2.Init.Mode = SPI_MODE_MASTER;
|
||||
hspi2.Init.Direction = SPI_DIRECTION_1LINE;
|
||||
hspi2.Init.DataSize = SPI_DATASIZE_4BIT;
|
||||
hspi2.Init.CLKPolarity = SPI_POLARITY_LOW;
|
||||
hspi2.Init.CLKPhase = SPI_PHASE_1EDGE;
|
||||
hspi2.Init.NSS = SPI_NSS_SOFT;
|
||||
hspi2.Init.BaudRatePrescaler = SPI_BAUDRATEPRESCALER_2;
|
||||
hspi2.Init.FirstBit = SPI_FIRSTBIT_MSB;
|
||||
hspi2.Init.TIMode = SPI_TIMODE_DISABLE;
|
||||
hspi2.Init.CRCCalculation = SPI_CRCCALCULATION_DISABLE;
|
||||
hspi2.Init.CRCPolynomial = 7;
|
||||
hspi2.Init.CRCLength = SPI_CRC_LENGTH_DATASIZE;
|
||||
hspi2.Init.NSSPMode = SPI_NSS_PULSE_ENABLE;
|
||||
if (HAL_SPI_Init(&hspi2) != HAL_OK)
|
||||
{
|
||||
Error_Handler();
|
||||
}
|
||||
/* USER CODE BEGIN SPI2_Init 2 */
|
||||
|
||||
/* USER CODE END SPI2_Init 2 */
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief USART1 Initialization Function
|
||||
* @param None
|
||||
@@ -212,6 +256,7 @@ static void MX_GPIO_Init(void)
|
||||
/* GPIO Ports Clock Enable */
|
||||
__HAL_RCC_GPIOC_CLK_ENABLE();
|
||||
__HAL_RCC_GPIOH_CLK_ENABLE();
|
||||
__HAL_RCC_GPIOB_CLK_ENABLE();
|
||||
__HAL_RCC_GPIOA_CLK_ENABLE();
|
||||
|
||||
}
|
||||
|
||||
@@ -77,6 +77,81 @@ void HAL_MspInit(void)
|
||||
/* USER CODE END MspInit 1 */
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief SPI MSP Initialization
|
||||
* This function configures the hardware resources used in this example
|
||||
* @param hspi: SPI handle pointer
|
||||
* @retval None
|
||||
*/
|
||||
void HAL_SPI_MspInit(SPI_HandleTypeDef* hspi)
|
||||
{
|
||||
GPIO_InitTypeDef GPIO_InitStruct = {0};
|
||||
if(hspi->Instance==SPI2)
|
||||
{
|
||||
/* USER CODE BEGIN SPI2_MspInit 0 */
|
||||
|
||||
/* USER CODE END SPI2_MspInit 0 */
|
||||
/* Peripheral clock enable */
|
||||
__HAL_RCC_SPI2_CLK_ENABLE();
|
||||
|
||||
__HAL_RCC_GPIOC_CLK_ENABLE();
|
||||
__HAL_RCC_GPIOB_CLK_ENABLE();
|
||||
/**SPI2 GPIO Configuration
|
||||
PC3 ------> SPI2_MOSI
|
||||
PB13 ------> SPI2_SCK
|
||||
*/
|
||||
GPIO_InitStruct.Pin = GPIO_PIN_3;
|
||||
GPIO_InitStruct.Mode = GPIO_MODE_AF_PP;
|
||||
GPIO_InitStruct.Pull = GPIO_NOPULL;
|
||||
GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_VERY_HIGH;
|
||||
GPIO_InitStruct.Alternate = GPIO_AF5_SPI2;
|
||||
HAL_GPIO_Init(GPIOC, &GPIO_InitStruct);
|
||||
|
||||
GPIO_InitStruct.Pin = GPIO_PIN_13;
|
||||
GPIO_InitStruct.Mode = GPIO_MODE_AF_PP;
|
||||
GPIO_InitStruct.Pull = GPIO_NOPULL;
|
||||
GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_VERY_HIGH;
|
||||
GPIO_InitStruct.Alternate = GPIO_AF5_SPI2;
|
||||
HAL_GPIO_Init(GPIOB, &GPIO_InitStruct);
|
||||
|
||||
/* USER CODE BEGIN SPI2_MspInit 1 */
|
||||
|
||||
/* USER CODE END SPI2_MspInit 1 */
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief SPI MSP De-Initialization
|
||||
* This function freeze the hardware resources used in this example
|
||||
* @param hspi: SPI handle pointer
|
||||
* @retval None
|
||||
*/
|
||||
void HAL_SPI_MspDeInit(SPI_HandleTypeDef* hspi)
|
||||
{
|
||||
if(hspi->Instance==SPI2)
|
||||
{
|
||||
/* USER CODE BEGIN SPI2_MspDeInit 0 */
|
||||
|
||||
/* USER CODE END SPI2_MspDeInit 0 */
|
||||
/* Peripheral clock disable */
|
||||
__HAL_RCC_SPI2_CLK_DISABLE();
|
||||
|
||||
/**SPI2 GPIO Configuration
|
||||
PC3 ------> SPI2_MOSI
|
||||
PB13 ------> SPI2_SCK
|
||||
*/
|
||||
HAL_GPIO_DeInit(GPIOC, GPIO_PIN_3);
|
||||
|
||||
HAL_GPIO_DeInit(GPIOB, GPIO_PIN_13);
|
||||
|
||||
/* USER CODE BEGIN SPI2_MspDeInit 1 */
|
||||
|
||||
/* USER CODE END SPI2_MspDeInit 1 */
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief UART MSP Initialization
|
||||
* This function configures the hardware resources used in this example
|
||||
|
||||
@@ -29,8 +29,37 @@ menu "On-chip Peripheral Drivers"
|
||||
default n
|
||||
endif
|
||||
|
||||
menuconfig BSP_USING_SPI
|
||||
bool "Enable SPI BUS"
|
||||
default n
|
||||
select RT_USING_SPI
|
||||
if BSP_USING_SPI
|
||||
config BSP_USING_SPI2
|
||||
bool "Enable SPI2 BUS"
|
||||
default n
|
||||
|
||||
config BSP_SPI2_TX_USING_DMA
|
||||
bool "Enable SPI2 TX DMA"
|
||||
depends on BSP_USING_SPI2
|
||||
default n
|
||||
|
||||
config BSP_SPI2_RX_USING_DMA
|
||||
bool "Enable SPI2 RX DMA"
|
||||
depends on BSP_USING_SPI2
|
||||
select BSP_SPI2_TX_USING_DMA
|
||||
default n
|
||||
endif
|
||||
|
||||
source "../libraries/HAL_Drivers/Kconfig"
|
||||
|
||||
endmenu
|
||||
|
||||
menu "Onboard Peripheral Drivers"
|
||||
config BSP_USING_SPI_LCD
|
||||
bool "Enable LCD (spi2)"
|
||||
select BSP_USING_SPI
|
||||
select BSP_USING_SPI2
|
||||
default n
|
||||
endmenu
|
||||
|
||||
endmenu
|
||||
|
||||
@@ -12,9 +12,12 @@ board.c
|
||||
CubeMX_Config/Src/stm32l4xx_hal_msp.c
|
||||
''')
|
||||
|
||||
if GetDepend('BSP_USING_SPI_LCD'):
|
||||
src += ['ports/lcd/drv_lcd.c']
|
||||
|
||||
path = [cwd]
|
||||
path += [cwd + '/CubeMX_Config/Inc']
|
||||
|
||||
path += [cwd + '/ports/lcd']
|
||||
startup_path_prefix = SDK_LIB
|
||||
|
||||
if rtconfig.CROSS_TOOL == 'gcc':
|
||||
@@ -33,7 +36,7 @@ elif rtconfig.CROSS_TOOL == 'iar':
|
||||
# STM32L4R7xx || STM32L4R9xx || STM32L4S5xx
|
||||
# STM32L4S7xx || STM32L4S9xx
|
||||
# You can select chips from the list above
|
||||
CPPDEFINES = ['STM32L432xx']
|
||||
CPPDEFINES = ['STM32L431xx']
|
||||
group = DefineGroup('Drivers', src, depend = [''], CPPPATH = path, CPPDEFINES = CPPDEFINES)
|
||||
|
||||
Return('group')
|
||||
|
||||
@@ -0,0 +1,12 @@
|
||||
import os
|
||||
from building import *
|
||||
|
||||
objs = []
|
||||
cwd = GetCurrentDir()
|
||||
list = os.listdir(cwd)
|
||||
|
||||
for item in list:
|
||||
if os.path.isfile(os.path.join(cwd, item, 'SConscript')):
|
||||
objs = objs + SConscript(os.path.join(item, 'SConscript'))
|
||||
|
||||
Return('objs')
|
||||
@@ -0,0 +1,13 @@
|
||||
Import('RTT_ROOT')
|
||||
Import('rtconfig')
|
||||
from building import *
|
||||
|
||||
cwd = GetCurrentDir()
|
||||
|
||||
src += Glob('*.c')
|
||||
|
||||
CPPPATH = [cwd]
|
||||
|
||||
group = DefineGroup('devices', src, depend = ['BSP_USING_SPI_LCD'], CPPPATH = CPPPATH)
|
||||
|
||||
Return('group')
|
||||
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,44 @@
|
||||
#ifndef __DRV_LCD_H__
|
||||
#define __DRV_LCD_H__
|
||||
|
||||
#include <board.h>
|
||||
|
||||
#define LCD_W 240
|
||||
#define LCD_H 240
|
||||
|
||||
//POINT_COLOR
|
||||
#define WHITE 0xFFFF
|
||||
#define BLACK 0x0000
|
||||
#define BLUE 0x001F
|
||||
#define BRED 0XF81F
|
||||
#define GRED 0XFFE0
|
||||
#define GBLUE 0X07FF
|
||||
#define RED 0xF800
|
||||
#define MAGENTA 0xF81F
|
||||
#define GREEN 0x07E0
|
||||
#define CYAN 0x7FFF
|
||||
#define YELLOW 0xFFE0
|
||||
#define BROWN 0XBC40
|
||||
#define BRRED 0XFC07
|
||||
#define GRAY 0X8430
|
||||
#define GRAY175 0XAD75
|
||||
#define GRAY151 0X94B2
|
||||
#define GRAY187 0XBDD7
|
||||
#define GRAY240 0XF79E
|
||||
|
||||
void lcd_clear(rt_uint16_t color);
|
||||
void lcd_address_set(rt_uint16_t x1, rt_uint16_t y1, rt_uint16_t x2, rt_uint16_t y2);
|
||||
void lcd_set_color(rt_uint16_t back, rt_uint16_t fore);
|
||||
|
||||
void lcd_draw_point(rt_uint16_t x, rt_uint16_t y);
|
||||
void lcd_draw_point_color(rt_uint16_t x, rt_uint16_t y, rt_uint16_t color);
|
||||
void lcd_draw_circle(rt_uint16_t x0, rt_uint16_t y0, rt_uint8_t r);
|
||||
void lcd_draw_line(rt_uint16_t x1, rt_uint16_t y1, rt_uint16_t x2, rt_uint16_t y2);
|
||||
void lcd_draw_rectangle(rt_uint16_t x1, rt_uint16_t y1, rt_uint16_t x2, rt_uint16_t y2);
|
||||
void lcd_fill(rt_uint16_t x_start, rt_uint16_t y_start, rt_uint16_t x_end, rt_uint16_t y_end, rt_uint16_t color);
|
||||
|
||||
void lcd_show_num(rt_uint16_t x, rt_uint16_t y, rt_uint32_t num, rt_uint8_t len, rt_uint32_t size);
|
||||
rt_err_t lcd_show_string(rt_uint16_t x, rt_uint16_t y, rt_uint32_t size, const char *fmt, ...);
|
||||
rt_err_t lcd_show_image(rt_uint16_t x, rt_uint16_t y, rt_uint16_t length, rt_uint16_t wide, const rt_uint8_t *p);
|
||||
|
||||
#endif
|
||||
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
@@ -336,9 +336,9 @@
|
||||
<v6Rtti>0</v6Rtti>
|
||||
<VariousControls>
|
||||
<MiscControls></MiscControls>
|
||||
<Define>RT_USING_ARM_LIBC, USE_HAL_DRIVER, STM32L432xx, __RTTHREAD__</Define>
|
||||
<Define>RT_USING_ARM_LIBC, USE_HAL_DRIVER, __RTTHREAD__, STM32L431xx</Define>
|
||||
<Undefine></Undefine>
|
||||
<IncludePath>.;applications;..\..\..\libcpu\arm\common;..\..\..\libcpu\arm\cortex-m4;..\..\..\components\drivers\include;..\..\..\components\drivers\include;..\..\..\components\drivers\include;..\..\..\components\drivers\include;..\..\..\components\drivers\include;board;board\CubeMX_Config\Inc;..\libraries\HAL_Drivers;..\libraries\HAL_Drivers\config;..\..\..\components\finsh;.;..\..\..\include;..\..\..\components\libc\compilers\armlibc;..\..\..\components\libc\compilers\common;..\libraries\STM32L4xx_HAL\STM32L4xx_HAL_Driver\Inc;..\libraries\STM32L4xx_HAL\CMSIS\Device\ST\STM32L4xx\Include;..\libraries\STM32L4xx_HAL\CMSIS\Include</IncludePath>
|
||||
<IncludePath>.;applications;..\..\..\libcpu\arm\common;..\..\..\libcpu\arm\cortex-m4;..\..\..\components\drivers\include;..\..\..\components\drivers\include;..\..\..\components\drivers\include;..\..\..\components\drivers\spi;..\..\..\components\drivers\include;..\..\..\components\drivers\include;..\..\..\components\drivers\include;board;board\CubeMX_Config\Inc;board\ports\lcd;..\libraries\HAL_Drivers;..\libraries\HAL_Drivers\config;..\..\..\components\finsh;.;..\..\..\include;..\..\..\components\libc\compilers\armlibc;..\..\..\components\libc\compilers\common;..\libraries\STM32L4xx_HAL\STM32L4xx_HAL_Driver\Inc;..\libraries\STM32L4xx_HAL\CMSIS\Device\ST\STM32L4xx\Include;..\libraries\STM32L4xx_HAL\CMSIS\Include</IncludePath>
|
||||
</VariousControls>
|
||||
</Cads>
|
||||
<Aads>
|
||||
@@ -421,6 +421,75 @@
|
||||
</Group>
|
||||
<Group>
|
||||
<GroupName>DeviceDrivers</GroupName>
|
||||
<GroupOption>
|
||||
<CommonProperty>
|
||||
<UseCPPCompiler>0</UseCPPCompiler>
|
||||
<RVCTCodeConst>0</RVCTCodeConst>
|
||||
<RVCTZI>0</RVCTZI>
|
||||
<RVCTOtherData>0</RVCTOtherData>
|
||||
<ModuleSelection>0</ModuleSelection>
|
||||
<IncludeInBuild>1</IncludeInBuild>
|
||||
<AlwaysBuild>0</AlwaysBuild>
|
||||
<GenerateAssemblyFile>0</GenerateAssemblyFile>
|
||||
<AssembleAssemblyFile>0</AssembleAssemblyFile>
|
||||
<PublicsOnly>0</PublicsOnly>
|
||||
<StopOnExitCode>3</StopOnExitCode>
|
||||
<CustomArgument></CustomArgument>
|
||||
<IncludeLibraryModules></IncludeLibraryModules>
|
||||
<ComprImg>0</ComprImg>
|
||||
</CommonProperty>
|
||||
<GroupArmAds>
|
||||
<Cads>
|
||||
<interw>2</interw>
|
||||
<Optim>0</Optim>
|
||||
<oTime>2</oTime>
|
||||
<SplitLS>2</SplitLS>
|
||||
<OneElfS>2</OneElfS>
|
||||
<Strict>2</Strict>
|
||||
<EnumInt>2</EnumInt>
|
||||
<PlainCh>2</PlainCh>
|
||||
<Ropi>2</Ropi>
|
||||
<Rwpi>2</Rwpi>
|
||||
<wLevel>0</wLevel>
|
||||
<uThumb>2</uThumb>
|
||||
<uSurpInc>2</uSurpInc>
|
||||
<uC99>2</uC99>
|
||||
<uGnu>2</uGnu>
|
||||
<useXO>2</useXO>
|
||||
<v6Lang>0</v6Lang>
|
||||
<v6LangP>0</v6LangP>
|
||||
<vShortEn>2</vShortEn>
|
||||
<vShortWch>2</vShortWch>
|
||||
<v6Lto>2</v6Lto>
|
||||
<v6WtE>2</v6WtE>
|
||||
<v6Rtti>2</v6Rtti>
|
||||
<VariousControls>
|
||||
<MiscControls></MiscControls>
|
||||
<Define> </Define>
|
||||
<Undefine> </Undefine>
|
||||
<IncludePath></IncludePath>
|
||||
</VariousControls>
|
||||
</Cads>
|
||||
<Aads>
|
||||
<interw>2</interw>
|
||||
<Ropi>2</Ropi>
|
||||
<Rwpi>2</Rwpi>
|
||||
<thumb>2</thumb>
|
||||
<SplitLS>2</SplitLS>
|
||||
<SwStkChk>2</SwStkChk>
|
||||
<NoWarn>2</NoWarn>
|
||||
<uSurpInc>2</uSurpInc>
|
||||
<useXO>2</useXO>
|
||||
<uClangAs>2</uClangAs>
|
||||
<VariousControls>
|
||||
<MiscControls></MiscControls>
|
||||
<Define></Define>
|
||||
<Undefine></Undefine>
|
||||
<IncludePath></IncludePath>
|
||||
</VariousControls>
|
||||
</Aads>
|
||||
</GroupArmAds>
|
||||
</GroupOption>
|
||||
<Files>
|
||||
<File>
|
||||
<FileName>pin.c</FileName>
|
||||
@@ -437,6 +506,16 @@
|
||||
<FileType>1</FileType>
|
||||
<FilePath>..\..\..\components\drivers\serial\serial.c</FilePath>
|
||||
</File>
|
||||
<File>
|
||||
<FileName>spi_core.c</FileName>
|
||||
<FileType>1</FileType>
|
||||
<FilePath>..\..\..\components\drivers\spi\spi_core.c</FilePath>
|
||||
</File>
|
||||
<File>
|
||||
<FileName>spi_dev.c</FileName>
|
||||
<FileType>1</FileType>
|
||||
<FilePath>..\..\..\components\drivers\spi\spi_dev.c</FilePath>
|
||||
</File>
|
||||
<File>
|
||||
<FileName>completion.c</FileName>
|
||||
<FileType>1</FileType>
|
||||
@@ -492,6 +571,11 @@
|
||||
<FileType>1</FileType>
|
||||
<FilePath>board\CubeMX_Config\Src\stm32l4xx_hal_msp.c</FilePath>
|
||||
</File>
|
||||
<File>
|
||||
<FileName>drv_lcd.c</FileName>
|
||||
<FileType>1</FileType>
|
||||
<FilePath>board\ports\lcd\drv_lcd.c</FilePath>
|
||||
</File>
|
||||
<File>
|
||||
<FileName>startup_stm32l431xx.s</FileName>
|
||||
<FileType>2</FileType>
|
||||
@@ -507,6 +591,11 @@
|
||||
<FileType>1</FileType>
|
||||
<FilePath>..\libraries\HAL_Drivers\drv_usart.c</FilePath>
|
||||
</File>
|
||||
<File>
|
||||
<FileName>drv_spi.c</FileName>
|
||||
<FileType>1</FileType>
|
||||
<FilePath>..\libraries\HAL_Drivers\drv_spi.c</FilePath>
|
||||
</File>
|
||||
<File>
|
||||
<FileName>drv_common.c</FileName>
|
||||
<FileType>1</FileType>
|
||||
@@ -742,6 +831,21 @@
|
||||
<FileType>1</FileType>
|
||||
<FilePath>..\libraries\STM32L4xx_HAL\STM32L4xx_HAL_Driver\Src\stm32l4xx_hal_usart_ex.c</FilePath>
|
||||
</File>
|
||||
<File>
|
||||
<FileName>stm32l4xx_hal_spi.c</FileName>
|
||||
<FileType>1</FileType>
|
||||
<FilePath>..\libraries\STM32L4xx_HAL\STM32L4xx_HAL_Driver\Src\stm32l4xx_hal_spi.c</FilePath>
|
||||
</File>
|
||||
<File>
|
||||
<FileName>stm32l4xx_hal_spi_ex.c</FileName>
|
||||
<FileType>1</FileType>
|
||||
<FilePath>..\libraries\STM32L4xx_HAL\STM32L4xx_HAL_Driver\Src\stm32l4xx_hal_spi_ex.c</FilePath>
|
||||
</File>
|
||||
<File>
|
||||
<FileName>stm32l4xx_hal_qspi.c</FileName>
|
||||
<FileType>1</FileType>
|
||||
<FilePath>..\libraries\STM32L4xx_HAL\STM32L4xx_HAL_Driver\Src\stm32l4xx_hal_qspi.c</FilePath>
|
||||
</File>
|
||||
<File>
|
||||
<FileName>stm32l4xx_hal_rtc.c</FileName>
|
||||
<FileType>1</FileType>
|
||||
|
||||
@@ -83,6 +83,7 @@
|
||||
#define RT_SERIAL_RB_BUFSZ 64
|
||||
#define RT_USING_PIN
|
||||
#define RT_USING_RTC
|
||||
#define RT_USING_SPI
|
||||
#define RT_USING_WDT
|
||||
|
||||
/* Using USB */
|
||||
@@ -169,5 +170,11 @@
|
||||
#define BSP_USING_GPIO
|
||||
#define BSP_USING_UART
|
||||
#define BSP_USING_UART1
|
||||
#define BSP_USING_SPI
|
||||
#define BSP_USING_SPI2
|
||||
|
||||
/* Onboard Peripheral Drivers */
|
||||
|
||||
#define BSP_USING_SPI_LCD
|
||||
|
||||
#endif
|
||||
|
||||
@@ -73,7 +73,8 @@ elif PLATFORM == 'armcc':
|
||||
DEVICE = ' --cpu Cortex-M4.fp '
|
||||
CFLAGS = '-c ' + DEVICE + ' --apcs=interwork --c99'
|
||||
AFLAGS = DEVICE + ' --apcs=interwork '
|
||||
LFLAGS = DEVICE + ' --info sizes --info totals --info unused --info veneers --list rt-thread.map --strict --scatter "board\linker_scripts\link.sct"'
|
||||
LFLAGS = DEVICE + ' --info sizes --info totals --info unused --info veneers --list rt-thread.map '
|
||||
LFLAGS += r' --strict --scatter "board\linker_scripts\link.sct" '
|
||||
CFLAGS += ' -I' + EXEC_PATH + '/ARM/ARMCC/include'
|
||||
LFLAGS += ' --libpath=' + EXEC_PATH + '/ARM/ARMCC/lib'
|
||||
|
||||
@@ -94,6 +95,39 @@ elif PLATFORM == 'armcc':
|
||||
|
||||
POST_ACTION = 'fromelf --bin $TARGET --output rtthread.bin \nfromelf -z $TARGET'
|
||||
|
||||
elif PLATFORM == 'armclang':
|
||||
# toolchains
|
||||
CC = 'armclang'
|
||||
CXX = 'armclang'
|
||||
AS = 'armasm'
|
||||
AR = 'armar'
|
||||
LINK = 'armlink'
|
||||
TARGET_EXT = 'axf'
|
||||
|
||||
DEVICE = ' --cpu Cortex-M4.fp '
|
||||
CFLAGS = ' -xc -std=c99 --target=arm-arm-none-eabi -mcpu=cortex-m4 '
|
||||
CFLAGS += ' -mcpu=cortex-m4 -mfpu=fpv4-sp-d16 '
|
||||
CFLAGS += ' -mfloat-abi=hard -c -fno-rtti -funsigned-char -fshort-enums -fshort-wchar '
|
||||
CFLAGS += ' -gdwarf-3 -ffunction-sections '
|
||||
AFLAGS = DEVICE + ' --apcs=interwork '
|
||||
LFLAGS = DEVICE + ' --info sizes --info totals --info unused --info veneers '
|
||||
LFLAGS += ' --list rt-thread.map '
|
||||
LFLAGS += r' --strict --scatter "board\linker_scripts\link.sct" '
|
||||
CFLAGS += ' -I' + EXEC_PATH + '/ARM/ARMCLANG/include'
|
||||
LFLAGS += ' --libpath=' + EXEC_PATH + '/ARM/ARMCLANG/lib'
|
||||
|
||||
EXEC_PATH += '/ARM/ARMCLANG/bin/'
|
||||
|
||||
if BUILD == 'debug':
|
||||
CFLAGS += ' -g -O1' # armclang recommend
|
||||
AFLAGS += ' -g'
|
||||
else:
|
||||
CFLAGS += ' -O2'
|
||||
|
||||
CXXFLAGS = CFLAGS
|
||||
|
||||
POST_ACTION = 'fromelf --bin $TARGET --output rtthread.bin \nfromelf -z $TARGET'
|
||||
|
||||
elif PLATFORM == 'iar':
|
||||
# toolchains
|
||||
CC = 'iccarm'
|
||||
|
||||
@@ -572,6 +572,11 @@ void I2C1_INIT()
|
||||
|
||||
rt_event_init(&i2c_event, "i2c_event", RT_IPC_FLAG_FIFO );
|
||||
i2c_mux = rt_mutex_create("i2c_mux", RT_IPC_FLAG_FIFO );
|
||||
if (i2c_mux == RT_NULL)
|
||||
{
|
||||
LOG_E("Create mutex for i2c_mux failed!");
|
||||
return;
|
||||
}
|
||||
i2c1_init_flag = 1;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -49,6 +49,7 @@ extern "C" {
|
||||
#define RT_SENSOR_CLASS_ECO2 (15) /* eCO2 sensor */
|
||||
#define RT_SENSOR_CLASS_GNSS (16) /* GPS/GNSS sensor */
|
||||
#define RT_SENSOR_CLASS_TOF (17) /* TOF sensor */
|
||||
#define RT_SENSOR_CLASS_SPO2 (18) /* SpO2 sensor */
|
||||
|
||||
/* Sensor vendor types */
|
||||
|
||||
@@ -89,6 +90,7 @@ extern "C" {
|
||||
#define RT_SENSOR_UNIT_PPB (15) /* Concentration unit: ppb */
|
||||
#define RT_SENSOR_UNIT_DMS (16) /* Coordinates unit: DMS */
|
||||
#define RT_SENSOR_UNIT_DD (17) /* Coordinates unit: DD */
|
||||
#define RT_SENSOR_UNIT_PERCENT (18) /* Percentage unit: % */
|
||||
|
||||
/* Sensor communication interface types */
|
||||
|
||||
@@ -217,6 +219,7 @@ struct rt_sensor_data
|
||||
rt_int32_t force; /* Force sensor. unit: mN */
|
||||
rt_uint32_t dust; /* Dust sensor. unit: ug/m3 */
|
||||
rt_uint32_t eco2; /* eCO2 sensor. unit: ppm */
|
||||
rt_uint32_t spo2; /* SpO2 sensor. unit: % */
|
||||
} data;
|
||||
};
|
||||
|
||||
|
||||
@@ -36,7 +36,8 @@ static char *const sensor_name_str[] =
|
||||
"dust_", /* Dust sensor */
|
||||
"eco2_", /* eCO2 sensor */
|
||||
"gnss_", /* GPS/GNSS sensor */
|
||||
"tof_" /* TOF sensor */
|
||||
"tof_", /* TOF sensor */
|
||||
"spo2_" /* SpO2 sensor */
|
||||
};
|
||||
|
||||
/* Sensor interrupt correlation function */
|
||||
|
||||
@@ -28,7 +28,10 @@ if GetDepend('RT_USING_SFUD'):
|
||||
if rtconfig.CROSS_TOOL == 'gcc':
|
||||
LOCAL_CCFLAGS += ' -std=c99'
|
||||
elif rtconfig.CROSS_TOOL == 'keil':
|
||||
LOCAL_CCFLAGS += ' --c99'
|
||||
if rtconfig.PLATFORM == 'armcc':
|
||||
LOCAL_CCFLAGS += ' --c99'
|
||||
elif rtconfig.PLATFORM == 'armclang':
|
||||
LOCAL_CCFLAGS += ' -std=c99'
|
||||
|
||||
src += src_device
|
||||
|
||||
|
||||
@@ -50,26 +50,26 @@ RTM_EXPORT(rt_rbb_init);
|
||||
* @param buf_size buffer size
|
||||
* @param blk_max_num max block number
|
||||
*
|
||||
* @return != NULL: ring block buffer object
|
||||
* NULL: create failed
|
||||
* @return != RT_NULL: ring block buffer object
|
||||
* RT_NULL: create failed
|
||||
*/
|
||||
rt_rbb_t rt_rbb_create(rt_size_t buf_size, rt_size_t blk_max_num)
|
||||
{
|
||||
rt_rbb_t rbb = NULL;
|
||||
rt_rbb_t rbb = RT_NULL;
|
||||
rt_uint8_t *buf;
|
||||
rt_rbb_blk_t blk_set;
|
||||
|
||||
rbb = (rt_rbb_t)rt_malloc(sizeof(struct rt_rbb));
|
||||
if (!rbb)
|
||||
{
|
||||
return NULL;
|
||||
return RT_NULL;
|
||||
}
|
||||
|
||||
buf = (rt_uint8_t *)rt_malloc(buf_size);
|
||||
if (!buf)
|
||||
{
|
||||
rt_free(rbb);
|
||||
return NULL;
|
||||
return RT_NULL;
|
||||
}
|
||||
|
||||
blk_set = (rt_rbb_blk_t)rt_malloc(sizeof(struct rt_rbb_blk) * blk_max_num);
|
||||
@@ -77,7 +77,7 @@ rt_rbb_t rt_rbb_create(rt_size_t buf_size, rt_size_t blk_max_num)
|
||||
{
|
||||
rt_free(buf);
|
||||
rt_free(rbb);
|
||||
return NULL;
|
||||
return RT_NULL;
|
||||
}
|
||||
|
||||
rt_rbb_init(rbb, buf, buf_size, blk_set, blk_max_num);
|
||||
@@ -116,7 +116,7 @@ static rt_rbb_blk_t find_empty_blk_in_set(rt_rbb_t rbb)
|
||||
}
|
||||
}
|
||||
|
||||
return NULL;
|
||||
return RT_NULL;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -127,14 +127,14 @@ static rt_rbb_blk_t find_empty_blk_in_set(rt_rbb_t rbb)
|
||||
*
|
||||
* @note When your application need align access, please make the blk_szie is aligned.
|
||||
*
|
||||
* @return != NULL: allocated block
|
||||
* NULL: allocate failed
|
||||
* @return != RT_NULL: allocated block
|
||||
* RT_NULL: allocate failed
|
||||
*/
|
||||
rt_rbb_blk_t rt_rbb_blk_alloc(rt_rbb_t rbb, rt_size_t blk_size)
|
||||
{
|
||||
rt_base_t level;
|
||||
rt_size_t empty1 = 0, empty2 = 0;
|
||||
rt_rbb_blk_t head, tail, new_rbb = NULL;
|
||||
rt_rbb_blk_t head, tail, new_rbb = RT_NULL;
|
||||
|
||||
RT_ASSERT(rbb);
|
||||
RT_ASSERT(blk_size < (1L << 24));
|
||||
@@ -178,7 +178,7 @@ rt_rbb_blk_t rt_rbb_blk_alloc(rt_rbb_t rbb, rt_size_t blk_size)
|
||||
else
|
||||
{
|
||||
/* no space */
|
||||
new_rbb = NULL;
|
||||
new_rbb = RT_NULL;
|
||||
}
|
||||
}
|
||||
else
|
||||
@@ -202,7 +202,7 @@ rt_rbb_blk_t rt_rbb_blk_alloc(rt_rbb_t rbb, rt_size_t blk_size)
|
||||
else
|
||||
{
|
||||
/* no space */
|
||||
new_rbb = NULL;
|
||||
new_rbb = RT_NULL;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -217,7 +217,7 @@ rt_rbb_blk_t rt_rbb_blk_alloc(rt_rbb_t rbb, rt_size_t blk_size)
|
||||
}
|
||||
else
|
||||
{
|
||||
new_rbb = NULL;
|
||||
new_rbb = RT_NULL;
|
||||
}
|
||||
|
||||
rt_hw_interrupt_enable(level);
|
||||
@@ -245,13 +245,13 @@ RTM_EXPORT(rt_rbb_blk_put);
|
||||
*
|
||||
* @param rbb ring block buffer object
|
||||
*
|
||||
* @return != NULL: block
|
||||
* NULL: get failed
|
||||
* @return != RT_NULL: block
|
||||
* RT_NULL: get failed
|
||||
*/
|
||||
rt_rbb_blk_t rt_rbb_blk_get(rt_rbb_t rbb)
|
||||
{
|
||||
rt_base_t level;
|
||||
rt_rbb_blk_t block = NULL;
|
||||
rt_rbb_blk_t block = RT_NULL;
|
||||
rt_slist_t *node;
|
||||
|
||||
RT_ASSERT(rbb);
|
||||
@@ -271,7 +271,7 @@ rt_rbb_blk_t rt_rbb_blk_get(rt_rbb_t rbb)
|
||||
}
|
||||
}
|
||||
/* not found */
|
||||
block = NULL;
|
||||
block = RT_NULL;
|
||||
|
||||
__exit:
|
||||
|
||||
@@ -364,7 +364,7 @@ rt_size_t rt_rbb_blk_queue_get(rt_rbb_t rbb, rt_size_t queue_data_len, rt_rbb_bl
|
||||
rt_base_t level;
|
||||
rt_size_t data_total_size = 0;
|
||||
rt_slist_t *node;
|
||||
rt_rbb_blk_t last_block = NULL, block;
|
||||
rt_rbb_blk_t last_block = RT_NULL, block;
|
||||
|
||||
RT_ASSERT(rbb);
|
||||
RT_ASSERT(blk_queue);
|
||||
@@ -388,7 +388,7 @@ rt_size_t rt_rbb_blk_queue_get(rt_rbb_t rbb, rt_size_t queue_data_len, rt_rbb_bl
|
||||
else
|
||||
{
|
||||
/* the first block must be put status */
|
||||
last_block = NULL;
|
||||
last_block = RT_NULL;
|
||||
continue;
|
||||
}
|
||||
}
|
||||
@@ -493,7 +493,7 @@ rt_size_t rt_rbb_next_blk_queue_len(rt_rbb_t rbb)
|
||||
rt_base_t level;
|
||||
rt_size_t data_len = 0;
|
||||
rt_slist_t *node;
|
||||
rt_rbb_blk_t last_block = NULL, block;
|
||||
rt_rbb_blk_t last_block = RT_NULL, block;
|
||||
|
||||
RT_ASSERT(rbb);
|
||||
|
||||
@@ -510,7 +510,7 @@ rt_size_t rt_rbb_next_blk_queue_len(rt_rbb_t rbb)
|
||||
if (last_block->status != RT_RBB_BLK_PUT)
|
||||
{
|
||||
/* the first block must be put status */
|
||||
last_block = NULL;
|
||||
last_block = RT_NULL;
|
||||
continue;
|
||||
}
|
||||
}
|
||||
|
||||
+26
-1
@@ -210,7 +210,32 @@ typedef rt_base_t rt_off_t; /**< Type for offset */
|
||||
#ifdef RT_USING_COMPONENTS_INIT
|
||||
typedef int (*init_fn_t)(void);
|
||||
#ifdef _MSC_VER /* we do not support MS VC++ compiler */
|
||||
#define INIT_EXPORT(fn, level)
|
||||
#pragma section("rti_fn$f",read)
|
||||
#if RT_DEBUG_INIT
|
||||
struct rt_init_desc
|
||||
{
|
||||
const char* level;
|
||||
const init_fn_t fn;
|
||||
const char* fn_name;
|
||||
};
|
||||
#define INIT_EXPORT(fn, level) \
|
||||
const char __rti_level_##fn[] = level"__rt_init_"#fn; \
|
||||
const char __rti_##fn##_name[] = #fn; \
|
||||
__declspec(allocate("rti_fn$f")) \
|
||||
RT_USED const struct rt_init_desc __rt_init_msc_##fn = \
|
||||
{__rti_level_##fn, fn, __rti_##fn##_name};
|
||||
#else
|
||||
struct rt_init_desc
|
||||
{
|
||||
const char* level;
|
||||
const init_fn_t fn;
|
||||
};
|
||||
#define INIT_EXPORT(fn, level) \
|
||||
const char __rti_level_##fn[] = level"__rt_init_"#fn; \
|
||||
__declspec(allocate("rti_fn$f")) \
|
||||
RT_USED const struct rt_init_desc __rt_init_msc_##fn = \
|
||||
{__rti_level_##fn, fn };
|
||||
#endif
|
||||
#else
|
||||
#if RT_DEBUG_INIT
|
||||
struct rt_init_desc
|
||||
|
||||
+28
-13
@@ -14,6 +14,7 @@
|
||||
* 2013-06-24 Bernard add rt_kprintf re-define when not use RT_USING_CONSOLE.
|
||||
* 2016-08-09 ArdaFu add new thread and interrupt hook.
|
||||
* 2018-11-22 Jesven add all cpu's lock and ipi handler
|
||||
* 2021-02-28 Meco Man add RT_KSERVICE_USING_STDLIB
|
||||
*/
|
||||
|
||||
#ifndef __RT_THREAD_H__
|
||||
@@ -515,10 +516,12 @@ void rt_components_board_init(void);
|
||||
void rt_kprintf(const char *fmt, ...);
|
||||
void rt_kputs(const char *str);
|
||||
#endif
|
||||
|
||||
rt_int32_t rt_vsprintf(char *dest, const char *format, va_list arg_ptr);
|
||||
rt_int32_t rt_vsnprintf(char *buf, rt_size_t size, const char *fmt, va_list args);
|
||||
rt_int32_t rt_sprintf(char *buf, const char *format, ...);
|
||||
rt_int32_t rt_snprintf(char *buf, rt_size_t size, const char *format, ...);
|
||||
rt_int32_t rt_sscanf(const char *buf, const char *fmt, ...);
|
||||
|
||||
#if defined(RT_USING_DEVICE) && defined(RT_USING_CONSOLE)
|
||||
rt_device_t rt_console_set_device(const char *name);
|
||||
@@ -539,22 +542,34 @@ int __rt_ffs(int value);
|
||||
void *rt_memset(void *src, int c, rt_ubase_t n);
|
||||
void *rt_memcpy(void *dest, const void *src, rt_ubase_t n);
|
||||
|
||||
rt_int32_t rt_strncmp(const char *cs, const char *ct, rt_ubase_t count);
|
||||
rt_int32_t rt_strcmp(const char *cs, const char *ct);
|
||||
rt_size_t rt_strlen(const char *src);
|
||||
rt_size_t rt_strnlen(const char *s, rt_ubase_t maxlen);
|
||||
char *rt_strdup(const char *s);
|
||||
#if defined(__CC_ARM) || defined(__CLANG_ARM)
|
||||
/* leak strdup interface */
|
||||
char* strdup(const char* str);
|
||||
#endif
|
||||
|
||||
char *rt_strstr(const char *str1, const char *str2);
|
||||
rt_int32_t rt_sscanf(const char *buf, const char *fmt, ...);
|
||||
char *rt_strncpy(char *dest, const char *src, rt_ubase_t n);
|
||||
#ifndef RT_KSERVICE_USING_STDLIB
|
||||
void *rt_memmove(void *dest, const void *src, rt_ubase_t n);
|
||||
rt_int32_t rt_memcmp(const void *cs, const void *ct, rt_ubase_t count);
|
||||
char *rt_strstr(const char *str1, const char *str2);
|
||||
rt_int32_t rt_strcasecmp(const char *a, const char *b);
|
||||
char *rt_strncpy(char *dest, const char *src, rt_ubase_t n);
|
||||
rt_int32_t rt_strncmp(const char *cs, const char *ct, rt_ubase_t count);
|
||||
rt_int32_t rt_strcmp(const char *cs, const char *ct);
|
||||
rt_size_t rt_strnlen(const char *s, rt_ubase_t maxlen);
|
||||
rt_size_t rt_strlen(const char *src);
|
||||
#else
|
||||
#include <string.h>
|
||||
#define rt_memmove(dest, src, n) memmove(dest, src, n)
|
||||
#define rt_memcmp(cs, ct, count) memcmp(cs, ct, count)
|
||||
#define rt_strstr(str1, str2) strstr(str1, str2)
|
||||
#define rt_strcasecmp(a, b) strcasecmp(a, b)
|
||||
#define rt_strncpy(dest, src, n) strncpy(dest, src, n)
|
||||
#define rt_strncmp(cs, ct, count) strncmp(cs, ct, count)
|
||||
#define rt_strcmp(cs, ct) strcmp(cs, ct)
|
||||
#define rt_strnlen(s, maxlen) strnlen(s, maxlen)
|
||||
#define rt_strlen(src) strlen(src)
|
||||
#endif /*RT_KSERVICE_USING_STDLIB*/
|
||||
|
||||
char *rt_strdup(const char *s);
|
||||
#if defined(__CC_ARM) || defined(__CLANG_ARM)
|
||||
/* lack strdup interface */
|
||||
char* strdup(const char* str);
|
||||
#endif
|
||||
|
||||
void rt_show_version(void);
|
||||
|
||||
|
||||
@@ -11,6 +11,9 @@ CPPPATH = [cwd]
|
||||
if rtconfig.PLATFORM == 'armcc':
|
||||
src += Glob('*_rvds.S')
|
||||
|
||||
if rtconfig.PLATFORM == 'armclang':
|
||||
src += Glob('*_rvds.S')
|
||||
|
||||
if rtconfig.PLATFORM == 'gcc':
|
||||
src += Glob('*_init.S')
|
||||
src += Glob('*_gcc.S')
|
||||
|
||||
@@ -699,3 +699,14 @@ rt_uint32_t YieldInterruptHandle(void)
|
||||
|
||||
return 0;
|
||||
} /*** YieldInterruptHandle ***/
|
||||
|
||||
/* system entry */
|
||||
extern int rtthread_startup(void);
|
||||
int wmain(int argc, char* argv[])
|
||||
{
|
||||
/* disable interrupt first */
|
||||
rt_hw_interrupt_disable();
|
||||
/* startup RT-Thread RTOS */
|
||||
rtthread_startup();
|
||||
}
|
||||
#pragma comment(linker, "/subsystem:console /entry:wmainCRTStartup")
|
||||
|
||||
@@ -0,0 +1,326 @@
|
||||
/*
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*
|
||||
* Change Logs:
|
||||
* Date Author Notes
|
||||
* 2020-12-04 tyx first implementation
|
||||
*/
|
||||
|
||||
#include <rthw.h>
|
||||
#include <rtthread.h>
|
||||
|
||||
#ifdef RT_USING_USER_MAIN
|
||||
#ifndef RT_MAIN_THREAD_STACK_SIZE
|
||||
#define RT_MAIN_THREAD_STACK_SIZE 2048
|
||||
#endif
|
||||
#ifndef RT_MAIN_THREAD_PRIORITY
|
||||
#define RT_MAIN_THREAD_PRIORITY (RT_THREAD_PRIORITY_MAX / 3)
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#ifdef RT_USING_COMPONENTS_INIT
|
||||
/*
|
||||
* Components Initialization will initialize some driver and components as following
|
||||
* order:
|
||||
* rti_start --> 0
|
||||
* BOARD_EXPORT --> 1
|
||||
* rti_board_end --> 1.end
|
||||
*
|
||||
* DEVICE_EXPORT --> 2
|
||||
* COMPONENT_EXPORT --> 3
|
||||
* FS_EXPORT --> 4
|
||||
* ENV_EXPORT --> 5
|
||||
* APP_EXPORT --> 6
|
||||
*
|
||||
* rti_end --> 6.end
|
||||
*
|
||||
* These automatically initialization, the driver or component initial function must
|
||||
* be defined with:
|
||||
* INIT_BOARD_EXPORT(fn);
|
||||
* INIT_DEVICE_EXPORT(fn);
|
||||
* ...
|
||||
* INIT_APP_EXPORT(fn);
|
||||
* etc.
|
||||
*/
|
||||
|
||||
#pragma section("rti_fn$a", read)
|
||||
const char __rti_fn_begin_name[] = "__rti_fn_start";
|
||||
__declspec(allocate("rti_fn$a")) const struct rt_init_desc __rti_fn_begin =
|
||||
{
|
||||
__rti_fn_begin_name,
|
||||
NULL
|
||||
};
|
||||
|
||||
#pragma section("rti_fn$z", read)
|
||||
const char __rti_fn_end_name[] = "__rti_fn_end";
|
||||
__declspec(allocate("rti_fn$z")) const struct rt_init_desc __rti_fn_end =
|
||||
{
|
||||
__rti_fn_end_name,
|
||||
NULL
|
||||
};
|
||||
|
||||
static int rti_start(void)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
INIT_EXPORT(rti_start, "0");
|
||||
|
||||
static int rti_board_end(void)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
INIT_EXPORT(rti_board_end, "1_end");
|
||||
|
||||
static int rti_end(void)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
INIT_EXPORT(rti_end, "6_end");
|
||||
|
||||
/**
|
||||
* Find next init function
|
||||
*/
|
||||
static const struct rt_init_desc* rt_init_find_next(const char* lv,
|
||||
unsigned int* begin, unsigned int* end)
|
||||
{
|
||||
const struct rt_init_desc* ptr;
|
||||
const struct rt_init_desc* ret_ptr = RT_NULL;
|
||||
|
||||
while (begin < end)
|
||||
{
|
||||
if (*begin != 0)
|
||||
{
|
||||
ptr = (const struct rt_init_desc*)begin;
|
||||
if (ret_ptr != RT_NULL)
|
||||
{
|
||||
if (rt_strcmp(lv, ptr->level) < 0 &&
|
||||
rt_strcmp(ret_ptr->level, ptr->level) > 0)
|
||||
{
|
||||
ret_ptr = ptr;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (rt_strcmp(lv, ptr->level) < 0)
|
||||
{
|
||||
ret_ptr = ptr;
|
||||
}
|
||||
}
|
||||
begin += (sizeof(struct rt_init_desc) / sizeof(unsigned int));
|
||||
}
|
||||
else
|
||||
{
|
||||
begin++;
|
||||
}
|
||||
}
|
||||
return ret_ptr;
|
||||
}
|
||||
|
||||
/**
|
||||
* RT-Thread Components Initialization for board
|
||||
*/
|
||||
void rt_components_board_init(void)
|
||||
{
|
||||
const struct rt_init_desc* ptr;
|
||||
const char* lv_start = "0__rt_init_rti_start";
|
||||
const char* lv_end = "1_end__rt_init_rti_board_end";
|
||||
unsigned int* ptr_begin = (unsigned int*)&__rti_fn_begin;
|
||||
unsigned int* ptr_end = (unsigned int*)&__rti_fn_end;
|
||||
int result;
|
||||
|
||||
ptr_begin += (sizeof(struct rt_init_desc) / sizeof(unsigned int));
|
||||
while (*ptr_begin == 0) ptr_begin++;
|
||||
do ptr_end--; while (*ptr_end == 0);
|
||||
|
||||
while (1)
|
||||
{
|
||||
ptr = rt_init_find_next(lv_start, ptr_begin, ptr_end);
|
||||
if (ptr == RT_NULL ||
|
||||
rt_strcmp(ptr->level, lv_end) >= 0)
|
||||
{
|
||||
break;
|
||||
}
|
||||
if (ptr->fn)
|
||||
{
|
||||
#if RT_DEBUG_INIT
|
||||
rt_kprintf("initialize %s", ptr->fn_name);
|
||||
result = ptr->fn();
|
||||
rt_kprintf(":%d done\n", result);
|
||||
#else
|
||||
result = ptr->fn();
|
||||
#endif
|
||||
}
|
||||
lv_start = ptr->level;
|
||||
};
|
||||
}
|
||||
|
||||
/**
|
||||
* RT-Thread Components Initialization
|
||||
*/
|
||||
void rt_components_init(void)
|
||||
{
|
||||
const struct rt_init_desc* ptr;
|
||||
const char* lv_start = "1_end__rt_init_rti_board_end";
|
||||
const char* lv_end = "6_end__rt_init_rti_end";
|
||||
unsigned int* ptr_begin = (unsigned int*)&__rti_fn_begin;
|
||||
unsigned int* ptr_end = (unsigned int*)&__rti_fn_end;
|
||||
int result;
|
||||
|
||||
ptr_begin += (sizeof(struct rt_init_desc) / sizeof(unsigned int));
|
||||
while (*ptr_begin == 0) ptr_begin++;
|
||||
do ptr_end--; while (*ptr_end == 0);
|
||||
|
||||
while (1)
|
||||
{
|
||||
ptr = rt_init_find_next(lv_start, ptr_begin, ptr_end);
|
||||
if (ptr == RT_NULL ||
|
||||
rt_strcmp(ptr->level, lv_end) >= 0)
|
||||
{
|
||||
break;
|
||||
}
|
||||
if (ptr->fn)
|
||||
{
|
||||
#if RT_DEBUG_INIT
|
||||
rt_kprintf("initialize %s", ptr->fn_name);
|
||||
result = ptr->fn();
|
||||
rt_kprintf(":%d done\n", result);
|
||||
#else
|
||||
result = ptr->fn();
|
||||
#endif
|
||||
}
|
||||
lv_start = ptr->level;
|
||||
};
|
||||
}
|
||||
#endif /* RT_USING_COMPONENTS_INIT */
|
||||
|
||||
#ifdef RT_USING_USER_MAIN
|
||||
|
||||
void rt_application_init(void);
|
||||
void rt_hw_board_init(void);
|
||||
int rtthread_startup(void);
|
||||
|
||||
#if defined(__CC_ARM) || defined(__CLANG_ARM)
|
||||
extern int $Super$$main(void);
|
||||
/* re-define main function */
|
||||
int $Sub$$main(void)
|
||||
{
|
||||
rtthread_startup();
|
||||
return 0;
|
||||
}
|
||||
#elif defined(__ICCARM__)
|
||||
extern int main(void);
|
||||
/* __low_level_init will auto called by IAR cstartup */
|
||||
extern void __iar_data_init3(void);
|
||||
int __low_level_init(void)
|
||||
{
|
||||
// call IAR table copy function.
|
||||
__iar_data_init3();
|
||||
rtthread_startup();
|
||||
return 0;
|
||||
}
|
||||
#elif defined(__GNUC__)
|
||||
/* Add -eentry to arm-none-eabi-gcc argument */
|
||||
int entry(void)
|
||||
{
|
||||
rtthread_startup();
|
||||
return 0;
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifndef RT_USING_HEAP
|
||||
/* if there is not enable heap, we should use static thread and stack. */
|
||||
ALIGN(8)
|
||||
static rt_uint8_t main_stack[RT_MAIN_THREAD_STACK_SIZE];
|
||||
struct rt_thread main_thread;
|
||||
#endif
|
||||
|
||||
/* the system main thread */
|
||||
void main_thread_entry(void *parameter)
|
||||
{
|
||||
extern int main(void);
|
||||
|
||||
#ifdef RT_USING_COMPONENTS_INIT
|
||||
/* RT-Thread components initialization */
|
||||
rt_components_init();
|
||||
#endif
|
||||
|
||||
#ifdef RT_USING_SMP
|
||||
rt_hw_secondary_cpu_up();
|
||||
#endif
|
||||
/* invoke system main function */
|
||||
#if defined(__CC_ARM) || defined(__CLANG_ARM)
|
||||
{
|
||||
extern int $Super$$main(void);
|
||||
$Super$$main(); /* for ARMCC. */
|
||||
}
|
||||
#elif defined(__ICCARM__) || defined(__GNUC__) || defined(__TASKING__) || defined(_MSC_VER)
|
||||
main();
|
||||
#endif
|
||||
}
|
||||
|
||||
void rt_application_init(void)
|
||||
{
|
||||
rt_thread_t tid;
|
||||
|
||||
#ifdef RT_USING_HEAP
|
||||
tid = rt_thread_create("main", main_thread_entry, RT_NULL,
|
||||
RT_MAIN_THREAD_STACK_SIZE, RT_MAIN_THREAD_PRIORITY, 20);
|
||||
RT_ASSERT(tid != RT_NULL);
|
||||
#else
|
||||
rt_err_t result;
|
||||
|
||||
tid = &main_thread;
|
||||
result = rt_thread_init(tid, "main", main_thread_entry, RT_NULL,
|
||||
main_stack, sizeof(main_stack), RT_MAIN_THREAD_PRIORITY, 20);
|
||||
RT_ASSERT(result == RT_EOK);
|
||||
|
||||
/* if not define RT_USING_HEAP, using to eliminate the warning */
|
||||
(void)result;
|
||||
#endif
|
||||
|
||||
rt_thread_startup(tid);
|
||||
}
|
||||
|
||||
int rtthread_startup(void)
|
||||
{
|
||||
rt_hw_interrupt_disable();
|
||||
|
||||
/* board level initialization
|
||||
* NOTE: please initialize heap inside board initialization.
|
||||
*/
|
||||
rt_hw_board_init();
|
||||
|
||||
/* show RT-Thread version */
|
||||
rt_show_version();
|
||||
|
||||
/* timer system initialization */
|
||||
rt_system_timer_init();
|
||||
|
||||
/* scheduler system initialization */
|
||||
rt_system_scheduler_init();
|
||||
|
||||
#ifdef RT_USING_SIGNALS
|
||||
/* signal system initialization */
|
||||
rt_system_signal_init();
|
||||
#endif
|
||||
|
||||
/* create init_thread */
|
||||
rt_application_init();
|
||||
|
||||
/* timer thread initialization */
|
||||
rt_system_timer_thread_init();
|
||||
|
||||
/* idle thread initialization */
|
||||
rt_thread_idle_init();
|
||||
|
||||
#ifdef RT_USING_SMP
|
||||
rt_hw_spin_lock(&_cpus_lock);
|
||||
#endif /*RT_USING_SMP*/
|
||||
|
||||
/* start scheduler */
|
||||
rt_system_scheduler_start();
|
||||
|
||||
/* never reach here */
|
||||
return 0;
|
||||
}
|
||||
#endif
|
||||
@@ -116,6 +116,10 @@ config RT_TIMER_THREAD_STACK_SIZE
|
||||
|
||||
endif
|
||||
|
||||
config RT_KSERVICE_USING_STDLIB
|
||||
bool "Enable kservice to use standard C library"
|
||||
default n
|
||||
|
||||
menuconfig RT_DEBUG
|
||||
bool "Enable debugging features"
|
||||
default y
|
||||
|
||||
@@ -17,6 +17,7 @@
|
||||
* 2013-06-24 Bernard remove rt_kprintf if RT_USING_CONSOLE is not defined.
|
||||
* 2013-09-24 aozima make sure the device is in STREAM mode when used by rt_kprintf.
|
||||
* 2015-07-06 Bernard Add rt_assert_handler routine.
|
||||
* 2021-02-28 Meco Man add RT_KSERVICE_USING_STDLIB
|
||||
*/
|
||||
|
||||
#include <rtthread.h>
|
||||
@@ -280,6 +281,8 @@ RT_WEAK void *rt_memcpy(void *dst, const void *src, rt_ubase_t count)
|
||||
}
|
||||
RTM_EXPORT(rt_memcpy);
|
||||
|
||||
#ifndef RT_KSERVICE_USING_STDLIB
|
||||
|
||||
/**
|
||||
* This function will move memory content from source address to destination
|
||||
* address.
|
||||
@@ -506,6 +509,8 @@ rt_size_t rt_strlen(const char *s)
|
||||
}
|
||||
RTM_EXPORT(rt_strlen);
|
||||
|
||||
#endif /*RT_KSERVICE_USING_STDLIB*/
|
||||
|
||||
#ifdef RT_USING_HEAP
|
||||
/**
|
||||
* This function will duplicate a string.
|
||||
|
||||
@@ -0,0 +1,228 @@
|
||||
#
|
||||
# Copyright (c) 2006-2021, RT-Thread Development Team
|
||||
#
|
||||
# SPDX-License-Identifier: Apache-2.0
|
||||
#
|
||||
# Change Logs:
|
||||
# Date Author Notes
|
||||
# 2021-04-01 LiuKang the first version
|
||||
#
|
||||
|
||||
import os
|
||||
import re
|
||||
import sys
|
||||
import click
|
||||
import chardet
|
||||
import logging
|
||||
import datetime
|
||||
|
||||
|
||||
def init_logger():
|
||||
log_format = "[%(filename)s %(lineno)d %(levelname)s] %(message)s "
|
||||
date_format = '%Y-%m-%d %H:%M:%S %a '
|
||||
logging.basicConfig(level=logging.INFO,
|
||||
format=log_format,
|
||||
datefmt=date_format,
|
||||
)
|
||||
|
||||
class CheckOut:
|
||||
def __init__(self, rtt_repo, rtt_branch):
|
||||
self.root = os.getcwd()
|
||||
self.rtt_repo = rtt_repo
|
||||
self.rtt_branch = rtt_branch
|
||||
|
||||
def get_new_file(self):
|
||||
file_list = list()
|
||||
try:
|
||||
os.system('git remote add rtt_repo {}'.format(self.rtt_repo))
|
||||
os.system('git fetch rtt_repo')
|
||||
os.system('git reset rtt_repo/{} --soft'.format(self.rtt_branch))
|
||||
os.system('git status > git.txt')
|
||||
except Exception as e:
|
||||
logging.error(e)
|
||||
return None
|
||||
try:
|
||||
with open('git.txt', 'r') as f:
|
||||
file_lines = f.readlines()
|
||||
except Exception as e:
|
||||
logging.error(e)
|
||||
return None
|
||||
file_path = ''
|
||||
for line in file_lines:
|
||||
if 'new file' in line:
|
||||
file_path = line.split('new file:')[1].strip()
|
||||
logging.info('new file -> {}'.format(file_path))
|
||||
elif 'deleted' in line:
|
||||
logging.info('deleted file -> {}'.format(line.split('deleted:')[1].strip()))
|
||||
elif 'modified' in line:
|
||||
file_path = line.split('modified:')[1].strip()
|
||||
logging.info('modified file -> {}'.format(file_path))
|
||||
else:
|
||||
continue
|
||||
|
||||
file_list.append(file_path)
|
||||
|
||||
return file_list
|
||||
|
||||
|
||||
class FormatCheck:
|
||||
def __init__(self, file_list):
|
||||
self.file_list = file_list
|
||||
|
||||
def __check_file(self, file_lines):
|
||||
line_num = 1
|
||||
check_result = False
|
||||
for line in file_lines:
|
||||
# check line start
|
||||
line_start = line.replace(' ', '')
|
||||
# find tab
|
||||
if line_start.startswith('\t'):
|
||||
logging.error("line[{}]: please use space replace tab at the start of this line.".format(line_num))
|
||||
check_result = False
|
||||
# check line end
|
||||
lin_end = line.split('\n')[0]
|
||||
if lin_end.endswith(' ') or lin_end.endswith('\t'):
|
||||
logging.error("line[{}]: please delete extra space at the end of this line.".format(line_num))
|
||||
check_result = False
|
||||
line_num += 1
|
||||
|
||||
return check_result
|
||||
|
||||
def check(self):
|
||||
logging.info("Start to check files format.")
|
||||
if len(self.file_list) == 0:
|
||||
logging.warning("There are no files to check license.")
|
||||
return 0
|
||||
encoding_check_result = True
|
||||
format_check_result = True
|
||||
for file_path in self.file_list:
|
||||
file_lines = ''
|
||||
code = ''
|
||||
if file_path.endswith(".c") or file_path.endswith(".h"):
|
||||
try:
|
||||
with open(file_path, 'r') as f:
|
||||
file = f.read()
|
||||
file_lines = f.readlines()
|
||||
# get file encoding
|
||||
code = chardet.detect(file)['encoding']
|
||||
except Exception as e:
|
||||
logging.error(e)
|
||||
else:
|
||||
continue
|
||||
|
||||
if code != 'utf-8':
|
||||
logging.error("[{0}]: encoding not utf-8, please format it.".format(file_path))
|
||||
encoding_check_result = False
|
||||
else:
|
||||
logging.info('[{0}]: encoding check success.'.format(file_path))
|
||||
|
||||
format_check_result = self.__check_file(file_lines)
|
||||
|
||||
if not encoding_check_result or not format_check_result:
|
||||
logging.error("files format check fail.")
|
||||
return False
|
||||
|
||||
logging.info("files format check success.")
|
||||
|
||||
return True
|
||||
|
||||
|
||||
class LicenseCheck:
|
||||
def __init__(self, file_list):
|
||||
self.file_list = file_list
|
||||
|
||||
def check(self):
|
||||
current_year = datetime.date.today().year
|
||||
logging.info("current year: {}".format(current_year))
|
||||
if len(self.file_list) == 0:
|
||||
logging.warning("There are no files to check license.")
|
||||
return 0
|
||||
logging.info("Start to check files license.")
|
||||
check_result = True
|
||||
for file_path in self.file_list:
|
||||
if file_path.endswith(".c") or file_path.endswith(".h"):
|
||||
try:
|
||||
with open(file_path, 'r') as f:
|
||||
file = f.readlines()
|
||||
except Exception as e:
|
||||
logging.error(e)
|
||||
else:
|
||||
continue
|
||||
|
||||
if 'Copyright' in file[1] and 'SPDX-License-Identifier: Apache-2.0' in file[3]:
|
||||
try:
|
||||
license_year = re.search(r'2006-\d{4}', file[1]).group()
|
||||
true_year = '2006-{}'.format(current_year)
|
||||
if license_year != true_year:
|
||||
logging.warning("[{0}]: license year: {} is not true: {}, please update.".format(file_path,
|
||||
license_year,
|
||||
true_year))
|
||||
|
||||
else:
|
||||
logging.info("[{0}]: license check success.".format(file_path))
|
||||
except Exception as e:
|
||||
logging.error(e)
|
||||
|
||||
else:
|
||||
logging.error("[{0}]: license check fail.".format(file_path))
|
||||
check_result = False
|
||||
|
||||
return check_result
|
||||
|
||||
|
||||
@click.group()
|
||||
@click.pass_context
|
||||
def cli(ctx):
|
||||
pass
|
||||
|
||||
|
||||
@cli.command()
|
||||
@click.option(
|
||||
'--license',
|
||||
"check_license",
|
||||
required=False,
|
||||
type=click.BOOL,
|
||||
flag_value=True,
|
||||
help="Enable File license check.",
|
||||
)
|
||||
@click.argument(
|
||||
'repo',
|
||||
nargs=1,
|
||||
type=click.STRING,
|
||||
default='https://github.com/RT-Thread/rt-thread',
|
||||
)
|
||||
@click.argument(
|
||||
'branch',
|
||||
nargs=1,
|
||||
type=click.STRING,
|
||||
default='master',
|
||||
)
|
||||
def check(check_license, repo, branch):
|
||||
"""
|
||||
check files license and format.
|
||||
"""
|
||||
init_logger()
|
||||
# get modified files list
|
||||
checkout = CheckOut(repo, branch)
|
||||
file_list = checkout.get_new_file()
|
||||
if file_list is None:
|
||||
logging.error("checkout files fail")
|
||||
sys.exit(1)
|
||||
|
||||
# check modified files format
|
||||
format_check = FormatCheck(file_list)
|
||||
format_check_result = format_check.check()
|
||||
license_check_result = True
|
||||
if check_license:
|
||||
license_check = LicenseCheck(file_list)
|
||||
license_check_result = license_check.check()
|
||||
|
||||
if not format_check_result or not license_check_result:
|
||||
logging.error("file format check or license check fail.")
|
||||
sys.exit(1)
|
||||
logging.info("check success.")
|
||||
sys.exit(0)
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
cli()
|
||||
Reference in New Issue
Block a user