diff options
| author | Wayne Lin <[email protected]> | 2020-05-15 09:41:27 +0800 |
|---|---|---|
| committer | Wayne Lin <[email protected]> | 2020-05-15 09:41:27 +0800 |
| commit | 5d65fe074f0e0ba53673ffef6205aab6baa76d0a (patch) | |
| tree | 9847ae8364cbd3c7cec8168ba75e2c5cb15a8a41 /components | |
| parent | 39431f5a702f3dcec843cb8884064953594243ec (diff) | |
| parent | dab737f6375f5cdd86ad3bc6d166657b17364948 (diff) | |
Merge branch 'master' of https://github.com/rt-thread/rt-thread into rtt_issues
Diffstat (limited to 'components')
20 files changed, 77 insertions, 21 deletions
diff --git a/components/cplusplus/crt_init.c b/components/cplusplus/crt_init.c index fe12932457..fe12932457 100755..100644 --- a/components/cplusplus/crt_init.c +++ b/components/cplusplus/crt_init.c diff --git a/components/cplusplus/Mutex.cpp b/components/cplusplus/cxx_Mutex.cpp index 229e842446..229e842446 100644 --- a/components/cplusplus/Mutex.cpp +++ b/components/cplusplus/cxx_Mutex.cpp diff --git a/components/cplusplus/Semaphore.cpp b/components/cplusplus/cxx_Semaphore.cpp index c977a27c1a..c977a27c1a 100644 --- a/components/cplusplus/Semaphore.cpp +++ b/components/cplusplus/cxx_Semaphore.cpp diff --git a/components/cplusplus/Thread.cpp b/components/cplusplus/cxx_Thread.cpp index b21fbdce1f..b21fbdce1f 100644 --- a/components/cplusplus/Thread.cpp +++ b/components/cplusplus/cxx_Thread.cpp diff --git a/components/cplusplus/crt.cpp b/components/cplusplus/cxx_crt.cpp index d4cb84f77c..d4cb84f77c 100644 --- a/components/cplusplus/crt.cpp +++ b/components/cplusplus/cxx_crt.cpp diff --git a/components/drivers/include/ipc/dataqueue.h b/components/drivers/include/ipc/dataqueue.h index f584c267bf..d90be76ffb 100644 --- a/components/drivers/include/ipc/dataqueue.h +++ b/components/drivers/include/ipc/dataqueue.h @@ -22,6 +22,8 @@ struct rt_data_item; /* data queue implementation */ struct rt_data_queue { + rt_uint32_t magic; + rt_uint16_t size; rt_uint16_t lwm; rt_bool_t waiting_lwm; @@ -57,5 +59,6 @@ rt_err_t rt_data_queue_peak(struct rt_data_queue *queue, const void **data_ptr, rt_size_t *size); void rt_data_queue_reset(struct rt_data_queue *queue); +rt_err_t rt_data_queue_deinit(struct rt_data_queue *queue); #endif diff --git a/components/drivers/sensors/sensor.h b/components/drivers/sensors/sensor.h index a0eaaae9ea..3821ec36ca 100755 --- a/components/drivers/sensors/sensor.h +++ b/components/drivers/sensors/sensor.h @@ -61,6 +61,8 @@ extern "C" { #define RT_SENSOR_VENDOR_ASAIR (8) /* Aosong */ #define RT_SENSOR_VENDOR_SHARP (9) /* Sharp */ #define RT_SENSOR_VENDOR_SENSIRION (10) /* Sensirion */ +#define RT_SENSOR_VENDOR_TI (11) /* Texas Instruments*/ + /* Sensor unit types */ diff --git a/components/drivers/serial/serial.c b/components/drivers/serial/serial.c index 7dd2918b9b..c442b052b1 100644 --- a/components/drivers/serial/serial.c +++ b/components/drivers/serial/serial.c @@ -785,6 +785,8 @@ static rt_err_t rt_serial_close(struct rt_device *dev) tx_dma = (struct rt_serial_tx_dma*)serial->serial_tx; RT_ASSERT(tx_dma != RT_NULL); + rt_data_queue_deinit(&(tx_dma->data_queue)); + rt_free(tx_dma); serial->serial_tx = RT_NULL; dev->open_flag &= ~RT_DEVICE_FLAG_DMA_TX; diff --git a/components/drivers/src/dataqueue.c b/components/drivers/src/dataqueue.c index 7553986b9f..5a802c0711 100644 --- a/components/drivers/src/dataqueue.c +++ b/components/drivers/src/dataqueue.c @@ -13,6 +13,8 @@ #include <rtdevice.h> #include <rthw.h> +#define DATAQUEUE_MAGIC 0xbead0e0e + struct rt_data_item { const void *data_ptr; @@ -29,6 +31,7 @@ rt_data_queue_init(struct rt_data_queue *queue, queue->evt_notify = evt_notify; + queue->magic = DATAQUEUE_MAGIC; queue->size = size; queue->lwm = lwm; @@ -57,6 +60,7 @@ rt_err_t rt_data_queue_push(struct rt_data_queue *queue, rt_thread_t thread; rt_err_t result; + RT_ASSERT(queue->magic == DATAQUEUE_MAGIC); RT_ASSERT(queue != RT_NULL); result = RT_EOK; @@ -145,7 +149,8 @@ rt_err_t rt_data_queue_pop(struct rt_data_queue *queue, rt_ubase_t level; rt_thread_t thread; rt_err_t result; - + + RT_ASSERT(queue->magic == DATAQUEUE_MAGIC); RT_ASSERT(queue != RT_NULL); RT_ASSERT(data_ptr != RT_NULL); RT_ASSERT(size != RT_NULL); @@ -244,7 +249,8 @@ rt_err_t rt_data_queue_peak(struct rt_data_queue *queue, rt_size_t *size) { rt_ubase_t level; - + + RT_ASSERT(queue->magic == DATAQUEUE_MAGIC); RT_ASSERT(queue != RT_NULL); level = rt_hw_interrupt_disable(); @@ -269,7 +275,9 @@ void rt_data_queue_reset(struct rt_data_queue *queue) { struct rt_thread *thread; register rt_ubase_t temp; - + + RT_ASSERT(queue->magic == DATAQUEUE_MAGIC); + rt_enter_critical(); /* wakeup all suspend threads */ @@ -325,3 +333,24 @@ void rt_data_queue_reset(struct rt_data_queue *queue) rt_schedule(); } RTM_EXPORT(rt_data_queue_reset); + +rt_err_t rt_data_queue_deinit(struct rt_data_queue *queue) +{ + rt_ubase_t level; + + RT_ASSERT(queue->magic == DATAQUEUE_MAGIC); + RT_ASSERT(queue != RT_NULL); + + level = rt_hw_interrupt_disable(); + + /* wakeup all suspend threads */ + rt_data_queue_reset(queue); + + queue->magic = 0; + rt_free(queue->queue); + + rt_hw_interrupt_enable(level); + + return RT_EOK; +} +RTM_EXPORT(rt_data_queue_deinit); diff --git a/components/drivers/src/pipe.c b/components/drivers/src/pipe.c index ae87b6f5f2..2a7e143f6c 100644 --- a/components/drivers/src/pipe.c +++ b/components/drivers/src/pipe.c @@ -323,18 +323,29 @@ static const struct dfs_file_ops pipe_fops = rt_err_t rt_pipe_open (rt_device_t device, rt_uint16_t oflag) { rt_pipe_t *pipe = (rt_pipe_t *)device; + rt_err_t ret = RT_EOK; - if (device == RT_NULL) return -RT_EINVAL; + if (device == RT_NULL) + { + ret = -RT_EINVAL; + goto __exit; + } + rt_mutex_take(&(pipe->lock), RT_WAITING_FOREVER); if (pipe->fifo == RT_NULL) { pipe->fifo = rt_ringbuffer_create(pipe->bufsz); + if (pipe->fifo == RT_NULL) + { + ret = -RT_ENOMEM; + } } rt_mutex_release(&(pipe->lock)); - return RT_EOK; +__exit: + return ret; } rt_err_t rt_pipe_close (rt_device_t device) diff --git a/components/drivers/usb/usbdevice/class/mstorage.c b/components/drivers/usb/usbdevice/class/mstorage.c index 43fb25afe4..a681b8212f 100644 --- a/components/drivers/usb/usbdevice/class/mstorage.c +++ b/components/drivers/usb/usbdevice/class/mstorage.c @@ -426,7 +426,7 @@ static rt_size_t _read_capacity(ufunction_t func, ustorage_cbw_t cbw) data = (struct mstorage*)func->user_data; buf = data->ep_in->buffer; - sector_count = data->geometry.sector_count; + sector_count = data->geometry.sector_count - 1; /* Last Logical Block Address */ sector_size = data->geometry.bytes_per_sector; buf[0] = sector_count >> 24; diff --git a/components/drivers/usb/usbhost/class/adk.h b/components/drivers/usb/usbhost/class/adk.h index 041d47c674..c582ad7f17 100644 --- a/components/drivers/usb/usbhost/class/adk.h +++ b/components/drivers/usb/usbhost/class/adk.h @@ -8,8 +8,8 @@ * 2011-12-12 Yi Qiu first version */ -#ifndef __HID_H__ -#define __HID_H__ +#ifndef __ADK_H__ +#define __ADK_H__ #include <rtthread.h> diff --git a/components/drivers/wlan/wlan_dev.c b/components/drivers/wlan/wlan_dev.c index 4241476a2b..53b6138e99 100644 --- a/components/drivers/wlan/wlan_dev.c +++ b/components/drivers/wlan/wlan_dev.c @@ -102,7 +102,7 @@ rt_err_t rt_wlan_dev_connect(struct rt_wlan_device *device, struct rt_wlan_info if ((password_len > RT_WLAN_PASSWORD_MAX_LENGTH) || (info->ssid.len > RT_WLAN_SSID_MAX_LENGTH)) { - LOG_E("L:%d password or ssid is to long", __LINE__); + LOG_E("L:%d password or ssid is too long", __LINE__); return -RT_ERROR; } rt_memset(&sta_info, 0, sizeof(struct rt_sta_info)); @@ -150,7 +150,7 @@ rt_err_t rt_wlan_dev_ap_start(struct rt_wlan_device *device, struct rt_wlan_info if ((password_len > RT_WLAN_PASSWORD_MAX_LENGTH) || (info->ssid.len > RT_WLAN_SSID_MAX_LENGTH)) { - LOG_E("L:%d password or ssid is to long", __LINE__); + LOG_E("L:%d password or ssid is too long", __LINE__); return -RT_ERROR; } @@ -530,7 +530,7 @@ rt_err_t rt_wlan_dev_scan(struct rt_wlan_device *device, struct rt_wlan_info *in { if (info->ssid.len > RT_WLAN_SSID_MAX_LENGTH) { - LOG_E("L:%d ssid is to long", __LINE__); + LOG_E("L:%d ssid is too long", __LINE__); return -RT_EINVAL; } rt_memcpy(&scan_info.ssid, &info->ssid, sizeof(rt_wlan_ssid_t)); diff --git a/components/finsh/cmd.c b/components/finsh/cmd.c index 48a629961b..9743bfd18b 100644 --- a/components/finsh/cmd.c +++ b/components/finsh/cmd.c @@ -29,6 +29,7 @@ * 2018-11-22 Jesven list_thread add smp support * 2018-12-27 Jesven Fix the problem that disable interrupt too long in list_thread * Provide protection for the "first layer of objects" when list_* + * 2020-04-07 chenhui add clear */ #include <rthw.h> @@ -48,6 +49,15 @@ long hello(void) } FINSH_FUNCTION_EXPORT(hello, say hello world); +long clear(void) +{ + rt_kprintf("\x1b[2J\x1b[H"); + + return 0; +} +FINSH_FUNCTION_EXPORT(clear,clear the terminal screen); +MSH_CMD_EXPORT(clear,clear the terminal screen); + extern void rt_show_version(void); long version(void) { diff --git a/components/finsh/finsh.h b/components/finsh/finsh.h index eb38682c4f..7276ea7ce1 100644 --- a/components/finsh/finsh.h +++ b/components/finsh/finsh.h @@ -27,8 +27,8 @@ #define HEAP_ALIGNMENT 4 /* heap alignment */ #define FINSH_GET16(x) (*(x)) | (*((x)+1) << 8) -#define FINSH_GET32(x) (rt_uint32_t)(*(x)) | ((rt_uint32_t)*((x)+1) << 8) | \ - ((rt_uint32_t)*((x)+2) << 16) | ((rt_uint32_t)*((x)+3) << 24) +#define FINSH_GET32(x) (rt_ubase_t)(*(x)) | ((rt_ubase_t)*((x)+1) << 8) | \ + ((rt_ubase_t)*((x)+2) << 16) | ((rt_ubase_t)*((x)+3) << 24) #define FINSH_SET16(x, v) \ do \ diff --git a/components/finsh/finsh_compiler.c b/components/finsh/finsh_compiler.c index 8d33e0e567..f81409bf9a 100644 --- a/components/finsh/finsh_compiler.c +++ b/components/finsh/finsh_compiler.c @@ -191,7 +191,7 @@ static int finsh_compile(struct finsh_node* node) case FINSH_NODE_VALUE_NULL: case FINSH_NODE_VALUE_STRING: finsh_code_byte(FINSH_OP_LD_DWORD); - finsh_code_dword((uint32_t)node->value.ptr); + finsh_code_dword((rt_ubase_t)node->value.ptr); break; /* arithmetic operation */ diff --git a/components/libc/compilers/minilibc/sys/types.h b/components/libc/compilers/minilibc/sys/types.h index d3abc6bb38..746235273c 100644 --- a/components/libc/compilers/minilibc/sys/types.h +++ b/components/libc/compilers/minilibc/sys/types.h @@ -25,8 +25,6 @@ typedef unsigned short u_short; typedef unsigned int u_int; typedef unsigned long u_long; -typedef int mode_t; - typedef unsigned long clockid_t; typedef int pid_t; diff --git a/components/net/at/at_socket/at_socket.c b/components/net/at/at_socket/at_socket.c index 11be4e23c0..220bf9d620 100644 --- a/components/net/at/at_socket/at_socket.c +++ b/components/net/at/at_socket/at_socket.c @@ -744,7 +744,7 @@ int at_recvfrom(int socket, void *mem, size_t len, int flags, struct sockaddr *f goto __exit; } - /* if the socket type is UDP, nead to connect socket first */ + /* if the socket type is UDP, need to connect socket first */ if (from && sock->type == AT_SOCKET_UDP && sock->state == AT_SOCKET_OPEN) { ip_addr_t remote_addr; diff --git a/components/net/netdev/src/netdev.c b/components/net/netdev/src/netdev.c index 68e5364a9e..aa43d8d3db 100644 --- a/components/net/netdev/src/netdev.c +++ b/components/net/netdev/src/netdev.c @@ -1087,7 +1087,7 @@ int netdev_cmd_ping(char* target_name, rt_uint32_t times, rt_size_t size) } } - /* if the response time is more than NETDEV_PING_DELAY, no nead to delay */ + /* if the response time is more than NETDEV_PING_DELAY, no need to delay */ delay_tick = ((rt_tick_get() - start_tick) > NETDEV_PING_DELAY) || (index == times) ? 0 : NETDEV_PING_DELAY; rt_thread_delay(delay_tick); } diff --git a/components/net/sal_socket/src/sal_socket.c b/components/net/sal_socket/src/sal_socket.c index e5c55f8bf8..e3bea5a28e 100644 --- a/components/net/sal_socket/src/sal_socket.c +++ b/components/net/sal_socket/src/sal_socket.c @@ -679,7 +679,7 @@ int sal_shutdown(int socket, int how) /* get the socket object by socket descriptor */ SAL_SOCKET_OBJ_GET(sock, socket); - /* shutdown operation not nead to check network interface status */ + /* shutdown operation not need to check network interface status */ /* check the network interface socket opreation */ SAL_NETDEV_SOCKETOPS_VALID(sock->netdev, pf, shutdown); @@ -924,6 +924,7 @@ int sal_socket(int domain, int type, int protocol) sock = sal_get_socket(socket); if (sock == RT_NULL) { + socket_delete(socket); return -1; } @@ -956,7 +957,7 @@ int sal_socket(int domain, int type, int protocol) sock->user_data = (void *) proto_socket; return sock->socket; } - + socket_delete(socket); return -1; } @@ -969,7 +970,7 @@ int sal_closesocket(int socket) /* get the socket object by socket descriptor */ SAL_SOCKET_OBJ_GET(sock, socket); - /* clsoesocket operation not nead to vaild network interface status */ + /* clsoesocket operation not need to vaild network interface status */ /* valid the network interface socket opreation */ SAL_NETDEV_SOCKETOPS_VALID(sock->netdev, pf, socket); |
