diff options
| author | Meco Man <[email protected]> | 2021-01-30 12:33:19 +0800 |
|---|---|---|
| committer | GitHub <[email protected]> | 2021-01-30 12:33:19 +0800 |
| commit | 97cc8a8f72838deb0273a3e60ae29319edd7e4f7 (patch) | |
| tree | 240ca2dbffead9d828c59719b447844ab63c5e52 /components | |
| parent | 7405618eafd9d0acd1d6da7ccd014700e9c17768 (diff) | |
| parent | 45963a16b07857fadec81ff1d7cf6d16deeaddb5 (diff) | |
Merge pull request #14 from RT-Thread/master
pr
Diffstat (limited to 'components')
| -rw-r--r-- | components/dfs/filesystems/uffs/src/inc/uffs/uffs_flash.h | 2 | ||||
| -rw-r--r-- | components/dfs/filesystems/uffs/uffs_nandif.c | 2 | ||||
| -rw-r--r-- | components/drivers/include/drivers/rt_drv_pwm.h | 8 | ||||
| -rw-r--r-- | components/drivers/misc/rt_drv_pwm.c | 74 | ||||
| -rw-r--r-- | components/drivers/sensors/sensor.c | 11 | ||||
| -rw-r--r-- | components/drivers/spi/spi_flash.h | 3 | ||||
| -rw-r--r-- | components/net/lwip_dhcpd/SConscript | 2 | ||||
| -rw-r--r-- | components/net/lwip_dhcpd/dhcp_server.c | 16 | ||||
| -rw-r--r-- | components/utilities/ulog/ulog.c | 189 | ||||
| -rw-r--r-- | components/utilities/ulog/ulog.h | 2 | ||||
| -rw-r--r-- | components/utilities/ulog/ulog_def.h | 1 |
11 files changed, 241 insertions, 69 deletions
diff --git a/components/dfs/filesystems/uffs/src/inc/uffs/uffs_flash.h b/components/dfs/filesystems/uffs/src/inc/uffs/uffs_flash.h index 1d0344ff8b..844d8ea231 100644 --- a/components/dfs/filesystems/uffs/src/inc/uffs/uffs_flash.h +++ b/components/dfs/filesystems/uffs/src/inc/uffs/uffs_flash.h @@ -62,7 +62,7 @@ extern "C"{ #define UFFS_LAYOUT_UFFS 0 //!< do layout by dev->attr information #define UFFS_LAYOUT_FLASH 1 //!< flash driver do the layout -#define UFFS_SPARE_LAYOUT_SIZE 6 //!< maximum spare layout array size, 2 segments +#define UFFS_SPARE_LAYOUT_SIZE 16 //!< maximum spare layout array size, 2 segments /** flash operation return code */ #define UFFS_FLASH_NO_ERR 0 //!< no error diff --git a/components/dfs/filesystems/uffs/uffs_nandif.c b/components/dfs/filesystems/uffs/uffs_nandif.c index 2e1a981fba..00e1bee8d5 100644 --- a/components/dfs/filesystems/uffs/uffs_nandif.c +++ b/components/dfs/filesystems/uffs/uffs_nandif.c @@ -324,7 +324,7 @@ static rt_uint8_t hw_flash_ecc_layout[UFFS_SPARE_LAYOUT_SIZE] = 0x00, 0x04, 0xFF, 0x00 }; -void uffs_setup_storage(struct uffs_StorageAttrSt *attr, +RT_WEAK void uffs_setup_storage(struct uffs_StorageAttrSt *attr, struct rt_mtd_nand_device *nand) { rt_memset(attr, 0, sizeof(struct uffs_StorageAttrSt)); diff --git a/components/drivers/include/drivers/rt_drv_pwm.h b/components/drivers/include/drivers/rt_drv_pwm.h index 16de4c6ab8..7a8e17b916 100644 --- a/components/drivers/include/drivers/rt_drv_pwm.h +++ b/components/drivers/include/drivers/rt_drv_pwm.h @@ -18,12 +18,20 @@ #define PWM_CMD_DISABLE (128 + 1) #define PWM_CMD_SET (128 + 2) #define PWM_CMD_GET (128 + 3) +#define PWMN_CMD_ENABLE (128 + 4) +#define PWMN_CMD_DISABLE (128 + 5) struct rt_pwm_configuration { rt_uint32_t channel; /* 0-n */ rt_uint32_t period; /* unit:ns 1ns~4.29s:1Ghz~0.23hz */ rt_uint32_t pulse; /* unit:ns (pulse<=period) */ + + /* + * RT_TRUE : The channel of pwm is complememtary. + * RT_FALSE : The channel of pwm is nomal. + */ + rt_bool_t complementary; }; struct rt_device_pwm; diff --git a/components/drivers/misc/rt_drv_pwm.c b/components/drivers/misc/rt_drv_pwm.c index 97d38d51b3..572580c45c 100644 --- a/components/drivers/misc/rt_drv_pwm.c +++ b/components/drivers/misc/rt_drv_pwm.c @@ -136,7 +136,8 @@ rt_err_t rt_pwm_enable(struct rt_device_pwm *device, int channel) return -RT_EIO; } - configuration.channel = channel; + configuration.channel = (channel > 0) ? (channel) : (-channel); /* Make it is positive num forever */ + configuration.complementary = (channel > 0) ? (RT_FALSE) : (RT_TRUE); /* If nagetive, it's complementary */ result = rt_device_control(&device->parent, PWM_CMD_ENABLE, &configuration); return result; @@ -152,7 +153,8 @@ rt_err_t rt_pwm_disable(struct rt_device_pwm *device, int channel) return -RT_EIO; } - configuration.channel = channel; + configuration.channel = (channel > 0) ? (channel) : (-channel); /* Make it is positive num forever */ + configuration.complementary = (channel > 0) ? (RT_FALSE) : (RT_TRUE); /* If nagetive, it's complementary */ result = rt_device_control(&device->parent, PWM_CMD_DISABLE, &configuration); return result; @@ -176,6 +178,20 @@ rt_err_t rt_pwm_set(struct rt_device_pwm *device, int channel, rt_uint32_t perio return result; } +rt_err_t rt_pwm_get(struct rt_device_pwm *device, struct rt_pwm_configuration *cfg) +{ + rt_err_t result = RT_EOK; + + if (!device) + { + return -RT_EIO; + } + + result = rt_device_control(&device->parent, PWM_CMD_GET, cfg); + + return result; +} + #ifdef RT_USING_FINSH #include <finsh.h> @@ -191,6 +207,7 @@ static int pwm_enable(int argc, char **argv) if (argc != 3) { rt_kprintf("Usage: pwm_enable pwm1 1\n"); + rt_kprintf(" pwm_enable <pwm_dev> <channel/-channel>\n"); result = -RT_ERROR; goto _exit; } @@ -202,12 +219,13 @@ static int pwm_enable(int argc, char **argv) goto _exit; } + /* If channel is complementary(1), make the channel number to nagetive */ result = rt_pwm_enable(device, atoi(argv[2])); _exit: return result; } -MSH_CMD_EXPORT(pwm_enable, pwm_enable pwm1 1); +MSH_CMD_EXPORT(pwm_enable, pwm_enable <pwm_dev> <channel/-channel>); static int pwm_disable(int argc, char **argv) { @@ -216,7 +234,8 @@ static int pwm_disable(int argc, char **argv) if (argc != 3) { - rt_kprintf("Usage: pwm_enable pwm1 1\n"); + rt_kprintf("Usage: pwm_disable pwm1 1\n"); + rt_kprintf(" pwm_disable <pwm_dev> <channel/-channel> \n"); result = -RT_ERROR; goto _exit; } @@ -228,12 +247,13 @@ static int pwm_disable(int argc, char **argv) goto _exit; } + /* If channel is complementary(1), make the channel number to nagetive */ result = rt_pwm_disable(device, atoi(argv[2])); _exit: return result; } -MSH_CMD_EXPORT(pwm_disable, pwm_disable pwm1 1); +MSH_CMD_EXPORT(pwm_disable, pwm_disable <pwm_dev> <channel/-channel>); static int pwm_set(int argc, char **argv) { @@ -243,6 +263,7 @@ static int pwm_set(int argc, char **argv) if (argc != 5) { rt_kprintf("Usage: pwm_set pwm1 1 100 50\n"); + rt_kprintf("Usage: pwm_set <pwm_dev> <channel> <period> <pulse>\n"); result = -RT_ERROR; goto _exit; } @@ -259,7 +280,48 @@ static int pwm_set(int argc, char **argv) _exit: return result; } -MSH_CMD_EXPORT(pwm_set, pwm_set pwm1 1 100 50); +MSH_CMD_EXPORT(pwm_set, pwm_set <pwm_dev> <channel> <period> <pulse>); + + +static int pwm_get(int argc, char **argv) +{ + int result = 0; + struct rt_device_pwm *device = RT_NULL; + struct rt_pwm_configuration cfg = {0}; + + if (argc != 3) + { + rt_kprintf("Usage: pwm_get pwm1 1\n"); + rt_kprintf(" pwm_get <pwm_dev> <channel>\n"); + result = -RT_ERROR; + goto _exit; + } + + device = (struct rt_device_pwm *)rt_device_find(argv[1]); + if (!device) + { + result = -RT_EIO; + goto _exit; + } + + cfg.channel = atoi(argv[2]); + result = rt_pwm_get(device, &cfg); + if (result != RT_EOK) + { + rt_kprintf("Get info of device: [%s] error.\n", argv[1]); + } + else + { + rt_kprintf("Get info of device: [%s]:\n", argv[1]); + rt_kprintf("period : %d\n", cfg.period); + rt_kprintf("pulse : %d\n", cfg.pulse); + rt_kprintf("Duty cycle : %d%%\n", (int)(((double)(cfg.pulse)/(cfg.period)) * 100)); + } + +_exit: + return result; +} +MSH_CMD_EXPORT(pwm_get, pwm_get <pwm_dev> <channel>); #endif /* FINSH_USING_MSH */ #endif /* RT_USING_FINSH */ diff --git a/components/drivers/sensors/sensor.c b/components/drivers/sensors/sensor.c index bbfcea97be..660b86f85b 100644 --- a/components/drivers/sensors/sensor.c +++ b/components/drivers/sensors/sensor.c @@ -216,12 +216,6 @@ static rt_err_t rt_sensor_close(rt_device_t dev) sensor->config.power = RT_SENSOR_POWER_DOWN; } - /* Sensor disable interrupt */ - if (sensor->config.irq_pin.pin != RT_PIN_NONE) - { - rt_pin_irq_enable(sensor->config.irq_pin.pin, RT_FALSE); - } - if (sensor->module != RT_NULL && sensor->info.fifo_max > 0 && sensor->data_buf != RT_NULL) { for (i = 0; i < sensor->module->sen_num; i ++) @@ -240,6 +234,11 @@ static rt_err_t rt_sensor_close(rt_device_t dev) } } } + /* Sensor disable interrupt */ + if (sensor->config.irq_pin.pin != RT_PIN_NONE) + { + rt_pin_irq_enable(sensor->config.irq_pin.pin, RT_FALSE); + } __exit: if (sensor->module) diff --git a/components/drivers/spi/spi_flash.h b/components/drivers/spi/spi_flash.h index 30db32474a..82b1ab2ecd 100644 --- a/components/drivers/spi/spi_flash.h +++ b/components/drivers/spi/spi_flash.h @@ -6,11 +6,14 @@ * Change Logs: * Date Author Notes * 2016/5/20 bernard the first version + * 2020/1/7 redoc add include */ #ifndef SPI_FLASH_H__ #define SPI_FLASH_H__ +#include <rtdevice.h> + struct spi_flash_device { struct rt_device flash_device; diff --git a/components/net/lwip_dhcpd/SConscript b/components/net/lwip_dhcpd/SConscript index 16c673036a..837eb043e4 100644 --- a/components/net/lwip_dhcpd/SConscript +++ b/components/net/lwip_dhcpd/SConscript @@ -2,7 +2,7 @@ from building import * cwd = GetCurrentDir() -if GetDepend('RT_USING_LWIP202') or GetDepend('RT_USING_LWIP210') : +if GetDepend('RT_USING_LWIP202') or GetDepend('RT_USING_LWIP212') : src = ['dhcp_server_raw.c'] else: src = ['dhcp_server.c'] diff --git a/components/net/lwip_dhcpd/dhcp_server.c b/components/net/lwip_dhcpd/dhcp_server.c index 93b4ad16f0..b37d038b86 100644 --- a/components/net/lwip_dhcpd/dhcp_server.c +++ b/components/net/lwip_dhcpd/dhcp_server.c @@ -80,6 +80,22 @@ #define LWIP_DHCP 1 #include <lwip/dhcp.h> +#ifndef DHCP_CLIENT_PORT +#define DHCP_CLIENT_PORT 68 +#endif + +#ifndef DHCP_SERVER_PORT +#define DHCP_SERVER_PORT 67 +#endif + +#ifndef ETHADDR32_COPY +#define ETHADDR32_COPY(dst, src) SMEMCPY(dst, src, ETH_HWADDR_LEN) +#endif + +#ifndef ETHADDR16_COPY +#define ETHADDR16_COPY(dst, src) SMEMCPY(dst, src, ETH_HWADDR_LEN) +#endif + /* buffer size for receive DHCP packet */ #define BUFSZ 1024 diff --git a/components/utilities/ulog/ulog.c b/components/utilities/ulog/ulog.c index 7610089298..5fcc40ac07 100644 --- a/components/utilities/ulog/ulog.c +++ b/components/utilities/ulog/ulog.c @@ -77,7 +77,7 @@ struct rt_ulog { rt_bool_t init_ok; - struct rt_mutex output_locker; + struct rt_semaphore output_locker; /* all backends */ rt_slist_t backend_list; /* the thread log's line buffer */ @@ -90,6 +90,7 @@ struct rt_ulog #endif /* ULOG_USING_ISR_LOG */ #ifdef ULOG_USING_ASYNC_OUTPUT + rt_bool_t async_enabled; rt_rbb_t async_rbb; rt_thread_t async_th; struct rt_semaphore async_notice; @@ -186,7 +187,7 @@ static void output_unlock(void) /* is in thread context */ if (rt_interrupt_get_nest() == 0) { - rt_mutex_release(&ulog.output_locker); + rt_sem_release(&ulog.output_locker); } else { @@ -201,7 +202,7 @@ static void output_lock(void) /* is in thread context */ if (rt_interrupt_get_nest() == 0) { - rt_mutex_take(&ulog.output_locker, RT_WAITING_FOREVER); + rt_sem_take(&ulog.output_locker, RT_WAITING_FOREVER); } else { @@ -393,6 +394,10 @@ void ulog_output_to_all_backend(rt_uint32_t level, const char *tag, rt_bool_t is for (node = rt_slist_first(&ulog.backend_list); node; node = rt_slist_next(node)) { backend = rt_slist_entry(node, struct ulog_backend, list); + if (backend->out_level < level) + { + continue; + } #if !defined(ULOG_USING_COLOR) || defined(ULOG_USING_SYSLOG) backend->output(backend, level, tag, is_raw, log, size); #else @@ -403,7 +408,11 @@ void ulog_output_to_all_backend(rt_uint32_t level, const char *tag, rt_bool_t is else { /* recalculate the log start address and log size when backend not supported color */ - rt_size_t color_info_len = rt_strlen(color_output_info[level]), output_size = size; + rt_size_t color_info_len = 0, output_size = size; + + if (color_output_info[level] != RT_NULL) + color_info_len = rt_strlen(color_output_info[level]); + if (color_info_len) { rt_size_t color_hdr_len = rt_strlen(CSI_START) + color_info_len; @@ -739,6 +748,42 @@ void ulog_hexdump(const char *tag, rt_size_t width, rt_uint8_t *buf, rt_size_t s #ifdef ULOG_USING_FILTER /** + * Set the filter's level by different backend. + * The log on this backend which level is less than it will stop output. + * + * @param be_name backend name + * @param level The filter level. When the level is LOG_FILTER_LVL_SILENT, the log enter silent mode. + * When the level is LOG_FILTER_LVL_ALL, it will remove this tag's level filer. + * Then all level log will resume output. + * + * @return 0 : success + * -10: level is out of range + */ +int ulog_be_lvl_filter_set(const char *be_name, rt_uint32_t level) +{ + rt_slist_t *node = RT_NULL; + ulog_backend_t backend; + int result = RT_EOK; + + if (level > LOG_FILTER_LVL_ALL) + return -RT_EINVAL; + + if (!ulog.init_ok) + return result; + + for (node = rt_slist_first(&ulog.backend_list); node; node = rt_slist_next(node)) + { + backend = rt_slist_entry(node, struct ulog_backend, list); + if (rt_strncmp(backend->name, be_name, RT_NAME_MAX) == 0) + { + backend->out_level = level; + } + } + + return result; +} + +/** * Set the filter's level by different tag. * The log on this tag which level is less than it will stop output. * @@ -945,6 +990,47 @@ const char *ulog_global_filter_kw_get(void) #if defined(RT_USING_FINSH) && defined(FINSH_USING_MSH) #include <finsh.h> +static void _print_lvl_info(void) +{ +#ifndef ULOG_USING_SYSLOG + rt_kprintf("Assert : 0\n"); + rt_kprintf("Error : 3\n"); + rt_kprintf("Warning : 4\n"); + rt_kprintf("Info : 6\n"); + rt_kprintf("Debug : 7\n"); +#else + rt_kprintf("EMERG : 1 (1 << 0)\n"); + rt_kprintf("ALERT : 2 (1 << 1)\n"); + rt_kprintf("CRIT : 4 (1 << 2)\n"); + rt_kprintf("ERR : 8 (1 << 3)\n"); + rt_kprintf("WARNING : 16 (1 << 4)\n"); + rt_kprintf("NOTICE : 32 (1 << 5)\n"); + rt_kprintf("INFO : 64 (1 << 6)\n"); + rt_kprintf("DEBUG : 128 (1 << 7)\n"); +#endif /* ULOG_USING_SYSLOG */ +} + +static void ulog_be_lvl(uint8_t argc, char **argv) +{ + if (argc > 2) + { + if ((atoi(argv[2]) <= LOG_FILTER_LVL_ALL) && (atoi(argv[2]) >= 0)) + { + ulog_be_lvl_filter_set(argv[1], atoi(argv[2])); + } + else + { + rt_kprintf("Please input correct level (0-%d).\n", LOG_FILTER_LVL_ALL); + } + } + else + { + rt_kprintf("Please input: ulog_be_lvl <be_name> <level>.\n"); + _print_lvl_info(); + } +} +MSH_CMD_EXPORT(ulog_be_lvl, Set ulog filter level by different backend.); + static void ulog_tag_lvl(uint8_t argc, char **argv) { if (argc > 2) @@ -961,22 +1047,7 @@ static void ulog_tag_lvl(uint8_t argc, char **argv) else { rt_kprintf("Please input: ulog_tag_lvl <tag> <level>.\n"); -#ifndef ULOG_USING_SYSLOG - rt_kprintf("Assert : 0\n"); - rt_kprintf("Error : 3\n"); - rt_kprintf("Warning : 4\n"); - rt_kprintf("Info : 6\n"); - rt_kprintf("Debug : 7\n"); -#else - rt_kprintf("EMERG : 1 (1 << 0)\n"); - rt_kprintf("ALERT : 2 (1 << 1)\n"); - rt_kprintf("CRIT : 4 (1 << 2)\n"); - rt_kprintf("ERR : 8 (1 << 3)\n"); - rt_kprintf("WARNING : 16 (1 << 4)\n"); - rt_kprintf("NOTICE : 32 (1 << 5)\n"); - rt_kprintf("INFO : 64 (1 << 6)\n"); - rt_kprintf("DEBUG : 128 (1 << 7)\n"); -#endif /* ULOG_USING_SYSLOG */ + _print_lvl_info(); } } MSH_CMD_EXPORT(ulog_tag_lvl, Set ulog filter level by different tag.); @@ -997,22 +1068,7 @@ static void ulog_lvl(uint8_t argc, char **argv) else { rt_kprintf("Please input: ulog_lvl <level>.\n"); -#ifndef ULOG_USING_SYSLOG - rt_kprintf("Assert : 0\n"); - rt_kprintf("Error : 3\n"); - rt_kprintf("Warning : 4\n"); - rt_kprintf("Info : 6\n"); - rt_kprintf("Debug : 7\n"); -#else - rt_kprintf("EMERG : 1 (1 << 0)\n"); - rt_kprintf("ALERT : 2 (1 << 1)\n"); - rt_kprintf("CRIT : 4 (1 << 2)\n"); - rt_kprintf("ERR : 8 (1 << 3)\n"); - rt_kprintf("WARNING : 16 (1 << 4)\n"); - rt_kprintf("NOTICE : 32 (1 << 5)\n"); - rt_kprintf("INFO : 64 (1 << 6)\n"); - rt_kprintf("DEBUG : 128 (1 << 7)\n"); -#endif /* ULOG_USING_SYSLOG */ + _print_lvl_info(); } } MSH_CMD_EXPORT(ulog_lvl, Set ulog global filter level.); @@ -1124,6 +1180,7 @@ rt_err_t ulog_backend_register(ulog_backend_t backend, const char *name, rt_bool } backend->support_color = support_color; + backend->out_level = LOG_FILTER_LVL_ALL; rt_memcpy(backend->name, name, RT_NAME_MAX); level = rt_hw_interrupt_disable(); @@ -1163,6 +1220,11 @@ void ulog_async_output(void) rt_rbb_blk_t log_blk; ulog_frame_t log_frame; + if (!ulog.async_enabled) + { + return; + } + while ((log_blk = rt_rbb_blk_get(ulog.async_rbb)) != NULL) { log_frame = (ulog_frame_t) log_blk->buf; @@ -1177,6 +1239,17 @@ void ulog_async_output(void) } /** + * enable or disable asynchronous output mode + * the log will be output directly when mode is disabled + * + * @param enabled RT_TRUE: enabled, RT_FALSE: disabled + */ +void ulog_async_output_enabled(rt_bool_t enabled) +{ + ulog.async_enabled = enabled; +} + +/** * waiting for get asynchronous output log * * @param time the waiting time @@ -1230,7 +1303,7 @@ int ulog_init(void) if (ulog.init_ok) return 0; - rt_mutex_init(&ulog.output_locker, "ulog lock", RT_IPC_FLAG_FIFO); + rt_sem_init(&ulog.output_locker, "ulog lock", 1, RT_IPC_FLAG_FIFO); rt_slist_init(&ulog.backend_list); #ifdef ULOG_USING_FILTER @@ -1239,29 +1312,16 @@ int ulog_init(void) #ifdef ULOG_USING_ASYNC_OUTPUT RT_ASSERT(ULOG_ASYNC_OUTPUT_STORE_LINES >= 2); + ulog.async_enabled = RT_TRUE; /* async output ring block buffer */ ulog.async_rbb = rt_rbb_create(RT_ALIGN(ULOG_ASYNC_OUTPUT_BUF_SIZE, RT_ALIGN_SIZE), ULOG_ASYNC_OUTPUT_STORE_LINES); if (ulog.async_rbb == NULL) { rt_kprintf("Error: ulog init failed! No memory for async rbb.\n"); - rt_mutex_detach(&ulog.output_locker); + rt_sem_detach(&ulog.output_locker); return -RT_ENOMEM; } - /* async output thread */ - ulog.async_th = rt_thread_create("ulog_async", async_output_thread_entry, &ulog, ULOG_ASYNC_OUTPUT_THREAD_STACK, - ULOG_ASYNC_OUTPUT_THREAD_PRIORITY, 20); - if (ulog.async_th == NULL) - { - rt_kprintf("Error: ulog init failed! No memory for async output thread.\n"); - rt_mutex_detach(&ulog.output_locker); - rt_rbb_destroy(ulog.async_rbb); - return -RT_ENOMEM; - } - rt_sem_init(&ulog.async_notice, "ulog", 0, RT_IPC_FLAG_FIFO); - /* async output thread startup */ - rt_thread_startup(ulog.async_th); - #endif /* ULOG_USING_ASYNC_OUTPUT */ #ifdef ULOG_USING_FILTER @@ -1272,7 +1332,28 @@ int ulog_init(void) return 0; } -INIT_PREV_EXPORT(ulog_init); +INIT_BOARD_EXPORT(ulog_init); + +#ifdef ULOG_USING_ASYNC_OUTPUT +int ulog_async_init(void) +{ + if (ulog.async_th == NULL) + { + /* async output thread */ + ulog.async_th = rt_thread_create("ulog_async", async_output_thread_entry, &ulog, ULOG_ASYNC_OUTPUT_THREAD_STACK, + ULOG_ASYNC_OUTPUT_THREAD_PRIORITY, 20); + if (ulog.async_th == NULL) + { + rt_kprintf("Error: ulog init failed! No memory for async output thread.\n"); + return -RT_ENOMEM; + } + /* async output thread startup */ + rt_thread_startup(ulog.async_th); + } + return 0; +} +INIT_PREV_EXPORT(ulog_async_init); +#endif /* ULOG_USING_ASYNC_OUTPUT */ void ulog_deinit(void) { @@ -1304,7 +1385,7 @@ void ulog_deinit(void) } #endif /* ULOG_USING_FILTER */ - rt_mutex_detach(&ulog.output_locker); + rt_sem_detach(&ulog.output_locker); #ifdef ULOG_USING_ASYNC_OUTPUT rt_rbb_destroy(ulog.async_rbb); diff --git a/components/utilities/ulog/ulog.h b/components/utilities/ulog/ulog.h index c78d72eda5..670644bb30 100644 --- a/components/utilities/ulog/ulog.h +++ b/components/utilities/ulog/ulog.h @@ -24,6 +24,7 @@ extern "C" { * ulog init and deint */ int ulog_init(void); +int ulog_async_init(void); void ulog_deinit(void); /* @@ -78,6 +79,7 @@ void ulog_flush(void); * asynchronous output API */ void ulog_async_output(void); +void ulog_async_output_enabled(rt_bool_t enabled); void ulog_async_waiting_log(rt_int32_t time); #endif diff --git a/components/utilities/ulog/ulog_def.h b/components/utilities/ulog/ulog_def.h index de5e82fcc5..771e76a601 100644 --- a/components/utilities/ulog/ulog_def.h +++ b/components/utilities/ulog/ulog_def.h @@ -201,6 +201,7 @@ struct ulog_backend { char name[RT_NAME_MAX]; rt_bool_t support_color; + rt_uint32_t out_level; void (*init) (struct ulog_backend *backend); void (*output)(struct ulog_backend *backend, rt_uint32_t level, const char *tag, rt_bool_t is_raw, const char *log, size_t len); void (*flush) (struct ulog_backend *backend); |
