Skip to content

Commit 372038a

Browse files
committed
[finsh/msh] Add user commands support
1 parent 3fb070c commit 372038a

File tree

13 files changed

+54
-43
lines changed

13 files changed

+54
-43
lines changed

library.properties

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
name=RT-Thread
2-
version=0.9.0
2+
version=0.9.1
33
author=onelife <[email protected]>, Bernard Xiong <[email protected]>
44
maintainer=onelife <[email protected]>
55
sentence=Real Time Operating System porting for Arduino SAM and SAMD boards

src/components/arduino/drv_button.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ typedef void (*rx_indicator)(void);
4141
#else /* RT_USING_ULOG */
4242
# define LOG_E(format, args...) rt_kprintf(format "\n", ##args)
4343
# define LOG_W LOG_E
44-
# ifdef BSP_SPI_DEBUG
44+
# ifdef BSP_BUTTON_DEBUG
4545
# define LOG_D(format, args...) rt_kprintf(format "\n", ##args)
4646
# else
4747
# define LOG_D(format, args...)

src/components/arduino/drv_iic.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ extern "C" {
3636
#else /* RT_USING_ULOG */
3737
# define LOG_E(format, args...) rt_kprintf(format "\n", ##args)
3838
# define LOG_W LOG_E
39-
# ifdef BSP_SPI_DEBUG
39+
# ifdef BSP_IIC_DEBUG
4040
# define LOG_I(format, args...) rt_kprintf(format "\n", ##args)
4141
# else
4242
# define LOG_I(format, args...)

src/components/arduino/drv_iic_ft6206.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ typedef void (*rx_indicator)(void);
4343
#else /* RT_USING_ULOG */
4444
# define LOG_E(format, args...) rt_kprintf(format "\n", ##args)
4545
# define LOG_W LOG_E
46-
# ifdef BSP_SPI_DEBUG
46+
# ifdef BSP_FT6206_DEBUG
4747
# define LOG_D(format, args...) rt_kprintf(format "\n", ##args)
4848
# else
4949
# define LOG_D(format, args...)

src/components/arduino/drv_rtc.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ extern "C" {
4040
#else /* RT_USING_ULOG */
4141
# define LOG_E(format, args...) rt_kprintf(format "\n", ##args)
4242
# define LOG_W LOG_E
43-
# ifdef BSP_SPI_DEBUG
43+
# ifdef BSP_RTC_DEBUG
4444
# define LOG_I(format, args...) rt_kprintf(format "\n", ##args)
4545
# else
4646
# define LOG_I(format, args...)

src/components/arduino/drv_spi_ssd1306.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ extern "C" {
3131
/* Private typedef -----------------------------------------------------------*/
3232
/* Private define ------------------------------------------------------------*/
3333
#ifdef RT_USING_ULOG
34-
# ifdef BSP_SSD_DEBUG
34+
# ifdef BSP_SSD1306_DEBUG
3535
# define LOG_LVL LOG_LVL_DBG
3636
# else
3737
# define LOG_LVL LOG_LVL_INFO
@@ -41,7 +41,7 @@ extern "C" {
4141
#else /* RT_USING_ULOG */
4242
# define LOG_E(format, args...) rt_kprintf(format "\n", ##args)
4343
# define LOG_W LOG_E
44-
# ifdef BSP_SPI_DEBUG
44+
# ifdef BSP_SSD_DEBUG
4545
# define LOG_D(format, args...) rt_kprintf(format "\n", ##args)
4646
# else
4747
# define LOG_D(format, args...)

src/components/arduino/drv_spi_ssd1331.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ extern "C" {
3131
/* Private typedef -----------------------------------------------------------*/
3232
/* Private define ------------------------------------------------------------*/
3333
#ifdef RT_USING_ULOG
34-
# ifdef BSP_SSD_DEBUG
34+
# ifdef BSP_SSD1331_DEBUG
3535
# define LOG_LVL LOG_LVL_DBG
3636
# else
3737
# define LOG_LVL LOG_LVL_INFO
@@ -41,7 +41,7 @@ extern "C" {
4141
#else /* RT_USING_ULOG */
4242
# define LOG_E(format, args...) rt_kprintf(format "\n", ##args)
4343
# define LOG_W LOG_E
44-
# ifdef BSP_SPI_DEBUG
44+
# ifdef BSP_SSD_DEBUG
4545
# define LOG_D(format, args...) rt_kprintf(format "\n", ##args)
4646
# else
4747
# define LOG_D(format, args...)

src/components/arduino/drv_spi_st7735.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ extern "C" {
4040
#else /* RT_USING_ULOG */
4141
# define LOG_E(format, args...) rt_kprintf(format "\n", ##args)
4242
# define LOG_W LOG_E
43-
# ifdef BSP_SPI_DEBUG
43+
# ifdef BSP_ST7735_DEBUG
4444
# define LOG_D(format, args...) rt_kprintf(format "\n", ##args)
4545
# else
4646
# define LOG_D(format, args...)

src/components/arduino/drv_spiili.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ extern "C" {
4141
#else /* RT_USING_ULOG */
4242
# define LOG_E(format, args...) rt_kprintf(format "\n", ##args)
4343
# define LOG_W LOG_E
44-
# ifdef BSP_SPI_DEBUG
44+
# ifdef BSP_ILI_DEBUG
4545
# define LOG_D(format, args...) rt_kprintf(format "\n", ##args)
4646
# else
4747
# define LOG_D(format, args...)

src/include/rtlibc.h

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,13 +13,14 @@
1313

1414
/* definitions for libc if toolchain has no these definitions */
1515
#include "libc/libc_stat.h"
16-
#if defined(CONFIG_ARDUINO) && defined(ARDUINO_ARCH_STM32)
16+
#if defined(CONFIG_ARDUINO) && defined(CONFIG_NO_ERRNO)
1717
# include "errno.h"
1818
#else
1919
# include "libc/libc_errno.h"
2020
#endif
21-
22-
#include "libc/libc_fcntl.h"
21+
#if !(defined(CONFIG_ARDUINO) && defined(CONFIG_NO_FCNTL))
22+
# include "libc/libc_fcntl.h"
23+
#endif
2324
#include "libc/libc_ioctl.h"
2425
#include "libc/libc_dirent.h"
2526
#include "libc/libc_signal.h"

src/rtconfig.h

Lines changed: 33 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -121,6 +121,12 @@
121121
# define CONFIG_GUI_HIGH (64)
122122
#endif /* CONFIG_USING_SSD1306_SPI4 */
123123

124+
/* STM32duino */
125+
#ifdef ARDUINO_ARCH_STM32
126+
# define CONFIG_NO_ERRNO
127+
# define RT_TICK_PER_SECOND (1000)
128+
#endif /* ARDUINO_ARCH_STM32 */
129+
124130

125131
/* Arduino Config */
126132

@@ -131,10 +137,24 @@
131137
# ifndef CONFIG_PRIORITY_MAX
132138
# define CONFIG_PRIORITY_MAX (3) /* NVIC */
133139
# endif
134-
#ifndef CONFIG_KERNEL_PRIORITY
135-
# define CONFIG_KERNEL_PRIORITY (2) /* Platform */
140+
# ifndef CONFIG_KERNEL_PRIORITY
141+
# define CONFIG_KERNEL_PRIORITY (2) /* Platform */
142+
# endif
143+
#endif /* defined(ARDUINO_ARCH_SAM) || defined(ARDUINO_ARCH_SAMD) || defined(ARDUINO_ARCH_STM32) */
144+
145+
#if defined(ARDUINO_ARCH_SAM)
146+
# define SERIAL_IRQn (UART_IRQn)
147+
#elif defined(ARDUINO_ARCH_SAMD)
148+
# define SERIAL_IRQn (USB_IRQn)
149+
#elif defined(ARDUINO_ARCH_STM32)
150+
# if defined(ARDUINO_NUCLEO_F767ZI)
151+
# define SERIAL_IRQn (USART3_IRQn)
152+
# endif
153+
#elif defined(ARDUINO_ARCH_RISCV)
154+
/* none */
155+
#else
156+
# warning "Unsupported architecture!"
136157
#endif
137-
#endif /* defined(ARDUINO_ARCH_SAM) || defined(ARDUINO_ARCH_SAMD) */
138158

139159
#ifndef CONFIG_HEAP_SIZE
140160
# ifdef ARDUINO_ARCH_SAM
@@ -353,19 +373,21 @@
353373
#define RT_NAME_MAX (16)
354374
#define RT_ALIGN_SIZE (4)
355375
#define RT_THREAD_PRIORITY_MAX (32)
356-
#define RT_TICK_PER_SECOND (100)
376+
#ifndef RT_TICK_PER_SECOND
377+
# define RT_TICK_PER_SECOND (100)
378+
#endif
357379

358380

359381
/* Arduino Thread Config */
360382

361383
#ifndef CONFIG_ARDUINO_STACK_SIZE
362-
# define CONFIG_ARDUINO_STACK_SIZE (3 * 512)
384+
# define CONFIG_ARDUINO_STACK_SIZE (4 * 512)
363385
#endif
364386
#ifndef CONFIG_ARDUINO_PRIORITY
365387
# define CONFIG_ARDUINO_PRIORITY (RT_THREAD_PRIORITY_MAX >> 1)
366388
#endif
367389
#ifndef CONFIG_ARDUINO_TICK
368-
# define CONFIG_ARDUINO_TICK (15)
390+
# define CONFIG_ARDUINO_TICK (RT_TICK_PER_SECOND / 10)
369391
#endif
370392

371393

@@ -379,19 +401,19 @@
379401
/* Utility Config */
380402

381403
#define RT_USING_DEVICE /* Required by IPC, DRV */
382-
#define RT_USING_MUTEX /* Required by DFS, DRV */
383-
#define RT_USING_SEMAPHORE /* Required by FINSH */
404+
#define RT_USING_MUTEX /* Required by DFS, DRV, CMSIS-OS */
405+
#define RT_USING_SEMAPHORE /* Required by FINSH, CMSIS-OS */
384406
#define RT_USING_MAILBOX /* Required by GUI */
385-
// #define RT_USING_MESSAGEQUEUE /* Required by ? */
386-
// #define RT_USING_EVENT /* Required by ? */
407+
// #define RT_USING_MESSAGEQUEUE /* Required by CMSIS-OS */
408+
// #define RT_USING_EVENT /* Required by CMSIS-OS */
387409
// #define RT_USING_SIGNALS /* Required by ? */
388410
// #define RT_USING_HOOK
389411
// #define RT_USING_IDLE_HOOK
390412

391413

392414
/* Memory Management Config */
393415

394-
#define RT_USING_MEMPOOL /* Required by SIG, GUI */
416+
#define RT_USING_MEMPOOL /* Required by SIG, GUI, CMSIS-OS */
395417
// #define RT_USING_MEMHEAP
396418
#define RT_USING_HEAP
397419
#define RT_USING_SMALL_MEM

src/rtt.cpp

Lines changed: 2 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -34,12 +34,6 @@
3434
# define CONSOLE_DEVICE CONFIG_SERIAL_DEVICE
3535
# endif
3636

37-
#if defined(ARDUINO_ARCH_STM32)
38-
# if defined(ARDUINO_NUCLEO_F767ZI)
39-
# define SERIAL_IRQn (USART3_IRQn)
40-
# endif
41-
#endif
42-
4337

4438
# if CONFIG_USING_CONSOLE
4539
/* === Map Arduino "Serial" to RT-Thread Device === */
@@ -392,7 +386,7 @@ void arduino_thread_entry(void *param) {
392386
#if !CONFIG_USING_DRIVER_SERIAL
393387
if (serialEventRun) serialEventRun();
394388
#endif
395-
rt_thread_sleep(1);
389+
rt_thread_sleep(RT_TICK_PER_SECOND / 100);
396390
}
397391
}
398392

@@ -431,20 +425,10 @@ void loop(void) { rt_thread_sleep(RT_TICK_PER_SECOND); }
431425
/* === RT-Thread Class === */
432426

433427
void RT_Thread::begin(void) {
434-
#if defined(ARDUINO_ARCH_SAM)
435-
NVIC_SetPriority(UART_IRQn, CONFIG_PRIORITY_MAX);
436-
#elif defined(ARDUINO_ARCH_SAMD)
437-
NVIC_SetPriority(USB_IRQn, CONFIG_PRIORITY_MAX);
438-
#elif defined(ARDUINO_ARCH_STM32)
439-
NVIC_SetPriority(SERIAL_IRQn, CONFIG_PRIORITY_MAX);
440-
#elif defined(ARDUINO_ARCH_RISCV)
441-
/* none */
442-
#else
443-
#warning "Unsupported architecture!"
444-
#endif
445428
#if defined(ARDUINO_ARCH_SAM) || defined(ARDUINO_ARCH_SAMD) || defined(ARDUINO_ARCH_STM32)
446429
NVIC_SetPriority(SysTick_IRQn, CONFIG_KERNEL_PRIORITY);
447430
NVIC_SetPriority(PendSV_IRQn, CONFIG_KERNEL_PRIORITY);
431+
NVIC_SetPriority(SERIAL_IRQn, CONFIG_PRIORITY_MAX);
448432
#endif
449433

450434
/* disable interrupt*/

src/shell_cmd.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -109,6 +109,10 @@ ADD_MSH_CMD(prtscn, capture screen, prtscn, int, int argc, char **argv)
109109
# endif
110110
#endif
111111

112+
#if __has_include("user_cmd.h")
113+
# include "user_cmd.h"
114+
#endif
115+
112116

113117
/* Please add your commands with the following format:
114118

0 commit comments

Comments
 (0)