summaryrefslogtreecommitdiff
path: root/components
diff options
context:
space:
mode:
authorWang-Huachen <[email protected]>2020-11-30 12:48:23 +0800
committerWang-Huachen <[email protected]>2020-11-30 12:48:23 +0800
commitf7b553b193deb179e23843d759d20d83da4b85d3 (patch)
treeff949a536a962896aec25ff73e0abd874c84a6af /components
parent9756c77f0447f9ce4f00a37600298a1f1fd90cda (diff)
parentaf95348bf1dd06ed2147cf9caee8a78513c31a72 (diff)
Merge branch 'master' of https://github.com/RT-Thread/rt-thread
Diffstat (limited to 'components')
-rwxr-xr-xcomponents/drivers/Kconfig4
-rw-r--r--components/drivers/audio/audio.c2
-rw-r--r--components/drivers/include/drivers/phy.h87
-rw-r--r--components/drivers/include/drivers/phy_mdio.h43
-rw-r--r--components/drivers/include/ipc/dataqueue.h11
-rw-r--r--components/drivers/include/rtdevice.h5
-rw-r--r--components/drivers/phy/SConscript8
-rw-r--r--components/drivers/phy/phy.c78
-rw-r--r--components/drivers/pm/pm.c12
-rw-r--r--components/drivers/rtc/alarm.c7
-rw-r--r--components/drivers/sdio/sdio.c6
-rw-r--r--components/drivers/src/dataqueue.c115
-rw-r--r--components/drivers/touch/touch.h3
-rw-r--r--components/finsh/cmd.c1
-rw-r--r--components/libc/compilers/armlibc/README.md9
-rw-r--r--components/libc/compilers/common/readme.md2
-rw-r--r--components/libc/compilers/dlib/README.md7
-rw-r--r--components/libc/compilers/newlib/README.md9
-rw-r--r--components/libc/pthreads/semaphore.c2
19 files changed, 364 insertions, 47 deletions
diff --git a/components/drivers/Kconfig b/components/drivers/Kconfig
index 457b8751fe..db4455160e 100755
--- a/components/drivers/Kconfig
+++ b/components/drivers/Kconfig
@@ -103,6 +103,10 @@ if RT_USING_I2C
endif
endif
+config RT_USING_PHY
+ bool "Using ethernet phy device drivers"
+ default n
+
config RT_USING_PIN
bool "Using generic GPIO device drivers"
default y
diff --git a/components/drivers/audio/audio.c b/components/drivers/audio/audio.c
index 4cec8a4a9c..846dad07cf 100644
--- a/components/drivers/audio/audio.c
+++ b/components/drivers/audio/audio.c
@@ -19,7 +19,9 @@
#define DBG_LVL DBG_INFO
#include <rtdbg.h>
+#ifndef MIN
#define MIN(a, b) ((a) < (b) ? (a) : (b))
+#endif
enum
{
diff --git a/components/drivers/include/drivers/phy.h b/components/drivers/include/drivers/phy.h
new file mode 100644
index 0000000000..2d1ad9f91f
--- /dev/null
+++ b/components/drivers/include/drivers/phy.h
@@ -0,0 +1,87 @@
+/*
+ * Copyright (c) 2006-2020, RT-Thread Development Team
+ *
+ * SPDX-License-Identifier: Apache-2.0
+ *
+ * Change Logs:
+ * Date Author Notes
+ * 2020-10-14 wangqiang the first version
+ */
+
+#ifndef __PHY_H__
+#define __PHY_H__
+
+#include <rtthread.h>
+
+#ifdef __cplusplus
+extern "C"
+{
+#endif
+
+/* Defines the PHY link speed. This is align with the speed for MAC. */
+enum phy_speed
+{
+ PHY_SPEED_10M = 0U, /* PHY 10M speed. */
+ PHY_SPEED_100M /* PHY 100M speed. */
+};
+
+/* Defines the PHY link duplex. */
+enum phy_duplex
+{
+ PHY_HALF_DUPLEX = 0U, /* PHY half duplex. */
+ PHY_FULL_DUPLEX /* PHY full duplex. */
+};
+
+/*! @brief Defines the PHY loopback mode. */
+enum phy_loop
+{
+ PHY_LOCAL_LOOP = 0U, /* PHY local loopback. */
+ PHY_REMOTE_LOOP /* PHY remote loopback. */
+};
+
+
+struct rt_phy_msg
+{
+ rt_uint32_t reg;
+ rt_uint32_t value;
+};
+
+typedef struct rt_phy_msg rt_phy_msg_t;
+
+
+struct rt_phy_device
+{
+ struct rt_device parent;
+ struct rt_mdio_bus *bus;
+ rt_uint32_t addr;
+ struct rt_phy_ops *ops;
+};
+
+typedef struct rt_phy_device rt_phy_t;
+
+
+enum {
+ PHY_STATUS_OK = 0,
+ PHY_STATUS_FAIL,
+ PHY_STATUS_TIMEOUT,
+};
+
+typedef rt_int32_t rt_phy_status;
+
+struct rt_phy_ops
+{
+ rt_phy_status (*init)(void *object, rt_uint32_t phy_addr, rt_uint32_t src_clock_hz);
+ rt_phy_status (*read)(rt_uint32_t reg, rt_uint32_t *data);
+ rt_phy_status (*write)(rt_uint32_t reg, rt_uint32_t data);
+ rt_phy_status (*loopback)(rt_uint32_t mode, rt_uint32_t speed, rt_bool_t enable);
+ rt_phy_status (*get_link_status)(rt_bool_t *status);
+ rt_phy_status (*get_link_speed_duplex)(rt_uint32_t *speed, rt_uint32_t *duplex);
+};
+
+rt_err_t rt_hw_phy_register(struct rt_phy_device *phy, const char *name);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* __PHY_H__*/
diff --git a/components/drivers/include/drivers/phy_mdio.h b/components/drivers/include/drivers/phy_mdio.h
new file mode 100644
index 0000000000..d978ec2984
--- /dev/null
+++ b/components/drivers/include/drivers/phy_mdio.h
@@ -0,0 +1,43 @@
+/*
+ * Copyright (c) 2006-2020, RT-Thread Development Team
+ *
+ * SPDX-License-Identifier: Apache-2.0
+ *
+ * Change Logs:
+ * Date Author Notes
+ * 2020-10-14 wangqiang the first version
+ */
+
+#ifndef __MDIO_H__
+#define __MDIO_H__
+
+#include <rtthread.h>
+
+#ifdef __cplusplus
+extern "C"
+{
+#endif
+
+
+struct rt_mdio_bus_ops
+{
+ rt_bool_t (*init)(void *bus, rt_uint32_t src_clock_hz);
+ rt_size_t (*read)(void *bus, rt_uint32_t addr, rt_uint32_t reg, void *data, rt_uint32_t size);
+ rt_size_t (*write)(void *bus, rt_uint32_t addr, rt_uint32_t reg, void *data, rt_uint32_t size);
+ rt_bool_t (*uninit)(void *bus);
+};
+
+struct rt_mdio_bus
+{
+ void *hw_obj;
+ char *name;
+ struct rt_mdio_bus_ops *ops;
+};
+
+typedef struct rt_mdio_bus rt_mdio_t;
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif
diff --git a/components/drivers/include/ipc/dataqueue.h b/components/drivers/include/ipc/dataqueue.h
index d90be76ffb..0262f4702b 100644
--- a/components/drivers/include/ipc/dataqueue.h
+++ b/components/drivers/include/ipc/dataqueue.h
@@ -17,8 +17,7 @@
#define RT_DATAQUEUE_EVENT_LWM 0x03
struct rt_data_item;
-#define RT_DATAQUEUE_SIZE(dq) ((dq)->put_index - (dq)->get_index)
-#define RT_DATAQUEUE_EMPTY(dq) ((dq)->size - RT_DATAQUEUE_SIZE(dq))
+
/* data queue implementation */
struct rt_data_queue
{
@@ -26,10 +25,11 @@ struct rt_data_queue
rt_uint16_t size;
rt_uint16_t lwm;
- rt_bool_t waiting_lwm;
- rt_uint16_t get_index;
- rt_uint16_t put_index;
+ rt_uint16_t get_index : 15;
+ rt_uint16_t is_empty : 1;
+ rt_uint16_t put_index : 15;
+ rt_uint16_t is_full : 1;
struct rt_data_item *queue;
@@ -60,5 +60,6 @@ rt_err_t rt_data_queue_peak(struct rt_data_queue *queue,
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);
+rt_uint16_t rt_data_queue_len(struct rt_data_queue *queue);
#endif
diff --git a/components/drivers/include/rtdevice.h b/components/drivers/include/rtdevice.h
index f54290097c..f0fa2f5b4a 100644
--- a/components/drivers/include/rtdevice.h
+++ b/components/drivers/include/rtdevice.h
@@ -69,6 +69,11 @@ extern "C" {
#endif /* RT_USING_I2C_BITOPS */
#endif /* RT_USING_I2C */
+#ifdef RT_USING_PHY
+#include "drivers/phy.h"
+#include "drivers/phy_mdio.h"
+#endif /* RT_USING_PHY */
+
#ifdef RT_USING_SDIO
#include "drivers/mmcsd_core.h"
#include "drivers/sd.h"
diff --git a/components/drivers/phy/SConscript b/components/drivers/phy/SConscript
new file mode 100644
index 0000000000..ec12ed24c2
--- /dev/null
+++ b/components/drivers/phy/SConscript
@@ -0,0 +1,8 @@
+from building import *
+
+cwd = GetCurrentDir()
+src = Glob('*.c')
+CPPPATH = [cwd + '/../include']
+group = DefineGroup('DeviceDrivers', src, depend = ['RT_USING_PHY'], CPPPATH = CPPPATH)
+
+Return('group')
diff --git a/components/drivers/phy/phy.c b/components/drivers/phy/phy.c
new file mode 100644
index 0000000000..3ed4a1a265
--- /dev/null
+++ b/components/drivers/phy/phy.c
@@ -0,0 +1,78 @@
+
+/*
+ * Copyright (c) 2006-2020, RT-Thread Development Team
+ *
+ * SPDX-License-Identifier: Apache-2.0
+ *
+ * Change Logs:
+ * Date Author Notes
+ * 2020-09-27 wangqiang first version
+ */
+
+#include <rthw.h>
+#include <rtthread.h>
+#include <rtdevice.h>
+
+#define DBG_TAG "PHY"
+#define DBG_LVL DBG_INFO
+#include <rtdbg.h>
+
+
+static rt_size_t phy_device_read(rt_device_t dev, rt_off_t pos, void *buffer, rt_size_t count)
+{
+ struct rt_phy_device *phy = (struct rt_phy_device *)dev->user_data;
+ struct rt_phy_msg *msg = (struct rt_phy_msg *)buffer;
+ return phy->bus->ops->read(phy->bus, phy->addr, msg->reg, &(msg->value), 4);
+}
+static rt_size_t phy_device_write(rt_device_t dev, rt_off_t pos, const void *buffer, rt_size_t count)
+{
+ struct rt_phy_device *phy = (struct rt_phy_device *)dev->user_data;
+ struct rt_phy_msg *msg = (struct rt_phy_msg *)buffer;
+ return phy->bus->ops->write(phy->bus, phy->addr, msg->reg, &(msg->value), 4);
+}
+
+
+
+#ifdef RT_USING_DEVICE_OPS
+const static struct rt_device_ops phy_ops =
+{
+ RT_NULL,
+ RT_NULL,
+ RT_NULL,
+ phy_device_read,
+ phy_device_write,
+ RT_NULL,
+};
+#endif
+
+/*
+* phy device register
+*/
+rt_err_t rt_hw_phy_register(struct rt_phy_device *phy, const char *name)
+{
+ rt_err_t ret;
+ struct rt_device *device;
+
+ device = &(phy->parent);
+
+ device->type = RT_Device_Class_PHY;
+ device->rx_indicate = RT_NULL;
+ device->tx_complete = RT_NULL;
+
+#ifdef RT_USING_DEVICE_OPS
+ device->ops = phy_ops;
+#else
+ device->init = NULL;
+ device->open = NULL;
+ device->close = NULL;
+ device->read = phy_device_read;
+ device->write = phy_device_write;
+ device->control = NULL;
+#endif
+ device->user_data = phy;
+
+ /* register a character device */
+ ret = rt_device_register(device, name, RT_DEVICE_FLAG_RDWR);
+
+ return ret;
+}
diff --git a/components/drivers/pm/pm.c b/components/drivers/pm/pm.c
index dd7cc2ae63..f9190ae9ef 100644
--- a/components/drivers/pm/pm.c
+++ b/components/drivers/pm/pm.c
@@ -8,6 +8,7 @@
* 2012-06-02 Bernard the first version
* 2018-08-02 Tanek split run and sleep modes, support custom mode
* 2019-04-28 Zero-Free improve PM mode and device ops interface
+ * 2020-11-23 zhangsz update pm mode select
*/
#include <rthw.h>
@@ -214,8 +215,6 @@ static void _pm_change_sleep_mode(struct rt_pm *pm, rt_uint8_t mode)
*/
void rt_system_power_manager(void)
{
- rt_uint8_t mode;
-
if (_pm_init_flag == 0)
return;
@@ -223,8 +222,7 @@ void rt_system_power_manager(void)
_pm_frequency_scaling(&_pm);
/* Low Power Mode Processing */
- mode = _pm_select_sleep_mode(&_pm);
- _pm_change_sleep_mode(&_pm, mode);
+ _pm_change_sleep_mode(&_pm, _pm.sleep_mode);
}
/**
@@ -248,6 +246,7 @@ void rt_pm_request(rt_uint8_t mode)
pm = &_pm;
if (pm->modes[mode] < 255)
pm->modes[mode] ++;
+ _pm_select_sleep_mode(pm);
rt_hw_interrupt_enable(level);
}
@@ -273,6 +272,7 @@ void rt_pm_release(rt_uint8_t mode)
pm = &_pm;
if (pm->modes[mode] > 0)
pm->modes[mode] --;
+ _pm_select_sleep_mode(pm);
rt_hw_interrupt_enable(level);
}
@@ -516,6 +516,10 @@ void rt_system_pm_init(const struct rt_pm_ops *ops,
pm->device_pm = RT_NULL;
pm->device_pm_number = 0;
+#if IDLE_THREAD_STACK_SIZE <= 256
+ #error "[pm.c ERR] IDLE Stack Size Too Small!"
+#endif
+
_pm_init_flag = 1;
}
diff --git a/components/drivers/rtc/alarm.c b/components/drivers/rtc/alarm.c
index 71b6e7236a..53cb538321 100644
--- a/components/drivers/rtc/alarm.c
+++ b/components/drivers/rtc/alarm.c
@@ -8,6 +8,7 @@
* 2012-10-27 heyuanjie87 first version.
* 2013-05-17 aozima initial alarm event & mutex in system init.
* 2020-10-15 zhangsz add alarm flags hour minute second.
+ * 2020-11-09 zhangsz fix alarm set when modify rtc time.
*/
#include <rtthread.h>
@@ -102,7 +103,7 @@ static void alarm_wakeup(struct rt_alarm *alarm, struct tm *now)
{
alarm->wktime.tm_hour = now->tm_hour;
alarm->wktime.tm_min = now->tm_min;
- alarm->wktime.tm_sec = alarm->wktime.tm_sec + 1;
+ alarm->wktime.tm_sec = now->tm_sec + 1;
if (alarm->wktime.tm_sec > 59)
{
alarm->wktime.tm_sec = 0;
@@ -125,7 +126,7 @@ static void alarm_wakeup(struct rt_alarm *alarm, struct tm *now)
alarm->wktime.tm_hour = now->tm_hour;
if (alarm->wktime.tm_sec == now->tm_sec)
{
- alarm->wktime.tm_min = alarm->wktime.tm_min + 1;
+ alarm->wktime.tm_min = now->tm_min + 1;
if (alarm->wktime.tm_min > 59)
{
alarm->wktime.tm_min = 0;
@@ -144,7 +145,7 @@ static void alarm_wakeup(struct rt_alarm *alarm, struct tm *now)
if ((alarm->wktime.tm_min == now->tm_min) &&
(alarm->wktime.tm_sec == now->tm_sec))
{
- alarm->wktime.tm_hour = alarm->wktime.tm_hour + 1;
+ alarm->wktime.tm_hour = now->tm_hour + 1;
if (alarm->wktime.tm_hour > 23)
{
alarm->wktime.tm_hour = 0;
diff --git a/components/drivers/sdio/sdio.c b/components/drivers/sdio/sdio.c
index 65bf87b895..f5d97cdd08 100644
--- a/components/drivers/sdio/sdio.c
+++ b/components/drivers/sdio/sdio.c
@@ -892,9 +892,9 @@ static rt_int32_t sdio_init_card(struct rt_mmcsd_host *host, rt_uint32_t ocr)
if (card->flags & CARD_FLAG_HIGHSPEED)
{
- mmcsd_set_clock(host, 50000000);
- }
- else
+ mmcsd_set_clock(host, card->host->freq_max > 50000000 ? 50000000 : card->host->freq_max);
+ }
+ else
{
mmcsd_set_clock(host, card->cis.max_tran_speed);
}
diff --git a/components/drivers/src/dataqueue.c b/components/drivers/src/dataqueue.c
index ba4a921da0..bfe8e12573 100644
--- a/components/drivers/src/dataqueue.c
+++ b/components/drivers/src/dataqueue.c
@@ -28,7 +28,7 @@ rt_data_queue_init(struct rt_data_queue *queue,
void (*evt_notify)(struct rt_data_queue *queue, rt_uint32_t event))
{
RT_ASSERT(queue != RT_NULL);
- RT_ASSERT((0x10000 % size) == 0);
+ RT_ASSERT(size > 0);
queue->evt_notify = evt_notify;
@@ -38,6 +38,8 @@ rt_data_queue_init(struct rt_data_queue *queue,
queue->get_index = 0;
queue->put_index = 0;
+ queue->is_empty = 1;
+ queue->is_full = 0;
rt_list_init(&(queue->suspended_push_list));
rt_list_init(&(queue->suspended_pop_list));
@@ -61,14 +63,14 @@ 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);
+ RT_ASSERT(queue->magic == DATAQUEUE_MAGIC);
result = RT_EOK;
thread = rt_thread_self();
level = rt_hw_interrupt_disable();
- while (queue->put_index - queue->get_index == queue->size)
+ while (queue->is_full)
{
/* queue is full */
if (timeout == 0)
@@ -109,9 +111,18 @@ rt_err_t rt_data_queue_push(struct rt_data_queue *queue,
if (result != RT_EOK) goto __exit;
}
- queue->queue[queue->put_index % queue->size].data_ptr = data_ptr;
- queue->queue[queue->put_index % queue->size].data_size = data_size;
+ queue->queue[queue->put_index].data_ptr = data_ptr;
+ queue->queue[queue->put_index].data_size = data_size;
queue->put_index += 1;
+ if (queue->put_index == queue->size)
+ {
+ queue->put_index = 0;
+ }
+ queue->is_empty = 0;
+ if (queue->put_index == queue->get_index)
+ {
+ queue->is_full = 1;
+ }
/* there is at least one thread in suspended list */
if (!rt_list_isempty(&(queue->suspended_pop_list)))
@@ -151,8 +162,8 @@ rt_err_t rt_data_queue_pop(struct rt_data_queue *queue,
rt_thread_t thread;
rt_err_t result;
- RT_ASSERT(queue->magic == DATAQUEUE_MAGIC);
RT_ASSERT(queue != RT_NULL);
+ RT_ASSERT(queue->magic == DATAQUEUE_MAGIC);
RT_ASSERT(data_ptr != RT_NULL);
RT_ASSERT(size != RT_NULL);
@@ -160,7 +171,7 @@ rt_err_t rt_data_queue_pop(struct rt_data_queue *queue,
thread = rt_thread_self();
level = rt_hw_interrupt_disable();
- while (queue->get_index == queue->put_index)
+ while (queue->is_empty)
{
/* queue is empty */
if (timeout == 0)
@@ -201,12 +212,20 @@ rt_err_t rt_data_queue_pop(struct rt_data_queue *queue,
goto __exit;
}
- *data_ptr = queue->queue[queue->get_index % queue->size].data_ptr;
- *size = queue->queue[queue->get_index % queue->size].data_size;
-
+ *data_ptr = queue->queue[queue->get_index].data_ptr;
+ *size = queue->queue[queue->get_index].data_size;
queue->get_index += 1;
+ if (queue->get_index == queue->size)
+ {
+ queue->get_index = 0;
+ }
+ queue->is_full = 0;
+ if (queue->put_index == queue->get_index)
+ {
+ queue->is_empty = 1;
+ }
- if ((queue->put_index - queue->get_index) <= queue->lwm)
+ if (rt_data_queue_len(queue) <= queue->lwm)
{
/* there is at least one thread in suspended list */
if (!rt_list_isempty(&(queue->suspended_push_list)))
@@ -251,20 +270,18 @@ rt_err_t rt_data_queue_peak(struct rt_data_queue *queue,
{
rt_ubase_t level;
- RT_ASSERT(queue->magic == DATAQUEUE_MAGIC);
RT_ASSERT(queue != RT_NULL);
+ RT_ASSERT(queue->magic == DATAQUEUE_MAGIC);
- level = rt_hw_interrupt_disable();
-
- if (queue->get_index == queue->put_index)
+ if (queue->is_empty)
{
- rt_hw_interrupt_enable(level);
-
return -RT_EEMPTY;
}
- *data_ptr = queue->queue[queue->get_index % queue->size].data_ptr;
- *size = queue->queue[queue->get_index % queue->size].data_size;
+ level = rt_hw_interrupt_disable();
+
+ *data_ptr = queue->queue[queue->get_index].data_ptr;
+ *size = queue->queue[queue->get_index].data_size;
rt_hw_interrupt_enable(level);
@@ -274,10 +291,20 @@ RTM_EXPORT(rt_data_queue_peak);
void rt_data_queue_reset(struct rt_data_queue *queue)
{
+ rt_ubase_t level;
struct rt_thread *thread;
- register rt_ubase_t temp;
+ RT_ASSERT(queue != RT_NULL);
RT_ASSERT(queue->magic == DATAQUEUE_MAGIC);
+
+ level = rt_hw_interrupt_disable();
+
+ queue->get_index = 0;
+ queue->put_index = 0;
+ queue->is_empty = 1;
+ queue->is_full = 0;
+
+ rt_hw_interrupt_enable(level);
rt_enter_critical();
/* wakeup all suspend threads */
@@ -286,7 +313,7 @@ void rt_data_queue_reset(struct rt_data_queue *queue)
while (!rt_list_isempty(&(queue->suspended_pop_list)))
{
/* disable interrupt */
- temp = rt_hw_interrupt_disable();
+ level = rt_hw_interrupt_disable();
/* get next suspend thread */
thread = rt_list_entry(queue->suspended_pop_list.next,
@@ -303,14 +330,14 @@ void rt_data_queue_reset(struct rt_data_queue *queue)
rt_thread_resume(thread);
/* enable interrupt */
- rt_hw_interrupt_enable(temp);
+ rt_hw_interrupt_enable(level);
}
/* resume on push list */
while (!rt_list_isempty(&(queue->suspended_push_list)))
{
/* disable interrupt */
- temp = rt_hw_interrupt_disable();
+ level = rt_hw_interrupt_disable();
/* get next suspend thread */
thread = rt_list_entry(queue->suspended_push_list.next,
@@ -327,7 +354,7 @@ void rt_data_queue_reset(struct rt_data_queue *queue)
rt_thread_resume(thread);
/* enable interrupt */
- rt_hw_interrupt_enable(temp);
+ rt_hw_interrupt_enable(level);
}
rt_exit_critical();
@@ -339,19 +366,49 @@ 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();
+ RT_ASSERT(queue->magic == DATAQUEUE_MAGIC);
/* wakeup all suspend threads */
rt_data_queue_reset(queue);
+ level = rt_hw_interrupt_disable();
queue->magic = 0;
- rt_free(queue->queue);
-
rt_hw_interrupt_enable(level);
+
+ rt_free(queue->queue);
return RT_EOK;
}
RTM_EXPORT(rt_data_queue_deinit);
+
+rt_uint16_t rt_data_queue_len(struct rt_data_queue *queue)
+{
+ rt_ubase_t level;
+ rt_int16_t len;
+
+ RT_ASSERT(queue != RT_NULL);
+ RT_ASSERT(queue->magic == DATAQUEUE_MAGIC);
+
+ if (queue->is_empty)
+ {
+ return 0;
+ }
+
+ level = rt_hw_interrupt_disable();
+
+ if (queue->put_index > queue->get_index)
+ {
+ len = queue->put_index - queue->get_index;
+ }
+ else
+ {
+ len = queue->size + queue->put_index - queue->get_index;
+ }
+
+ rt_hw_interrupt_enable(level);
+
+ return len;
+}
+RTM_EXPORT(rt_data_queue_len);
+
diff --git a/components/drivers/touch/touch.h b/components/drivers/touch/touch.h
index 6b7288a5a0..c33fe17520 100644
--- a/components/drivers/touch/touch.h
+++ b/components/drivers/touch/touch.h
@@ -45,6 +45,9 @@ extern "C" {
#define RT_TOUCH_CTRL_SET_X_TO_Y (5) /* Set X Y coordinate exchange */
#define RT_TOUCH_CTRL_DISABLE_INT (6) /* Disable interrupt */
#define RT_TOUCH_CTRL_ENABLE_INT (7) /* Enable interrupt */
+#define RT_TOUCH_CTRL_POWER_ON (8) /* Touch Power On */
+#define RT_TOUCH_CTRL_POWER_OFF (9) /* Touch Power Off */
+#define RT_TOUCH_CTRL_GET_STATUS (10) /* Get Touch Power Status */
/* Touch event */
#define RT_TOUCH_EVENT_NONE (0) /* Touch none */
diff --git a/components/finsh/cmd.c b/components/finsh/cmd.c
index d764ea4231..afbda59e90 100644
--- a/components/finsh/cmd.c
+++ b/components/finsh/cmd.c
@@ -821,6 +821,7 @@ static char *const device_type_str[] =
"Miscellaneous Device",
"Sensor Device",
"Touch Device",
+ "Phy Device",
"Unknown"
};
diff --git a/components/libc/compilers/armlibc/README.md b/components/libc/compilers/armlibc/README.md
new file mode 100644
index 0000000000..4d2a73b6be
--- /dev/null
+++ b/components/libc/compilers/armlibc/README.md
@@ -0,0 +1,9 @@
+# ARMLIB (Keil-MDK) porting for RT-Thread
+
+Please define RT_USING_LIBC and compile RT-Thread with Keil-MDK compiler.
+
+
+
+## More Information
+
+https://www.keil.com/support/man/docs/armlib/ \ No newline at end of file
diff --git a/components/libc/compilers/common/readme.md b/components/libc/compilers/common/readme.md
index 0cd56272ff..99797d933c 100644
--- a/components/libc/compilers/common/readme.md
+++ b/components/libc/compilers/common/readme.md
@@ -1,4 +1,4 @@
-# Attention :
+## Attentions
1. This folder is "common" for armlibc newlibc and dlib. It's not "common" for minilibc.
diff --git a/components/libc/compilers/dlib/README.md b/components/libc/compilers/dlib/README.md
index 846eb3f5c0..acd08f9074 100644
--- a/components/libc/compilers/dlib/README.md
+++ b/components/libc/compilers/dlib/README.md
@@ -1,4 +1,9 @@
-Dlib(IAR) porting for RT-Thread.
+# DLIB (IAR) porting for RT-Thread
Please define RT_USING_LIBC and compile RT-Thread with IAR compiler.
+
+
+## More Information
+
+http://www.iarsys.co.jp/download/LMS2/arm/7502/ewarm7502doc/arm/doc/EWARM_DevelopmentGuide.ENU.pdf P.130 \ No newline at end of file
diff --git a/components/libc/compilers/newlib/README.md b/components/libc/compilers/newlib/README.md
new file mode 100644
index 0000000000..385f329a4f
--- /dev/null
+++ b/components/libc/compilers/newlib/README.md
@@ -0,0 +1,9 @@
+# NEWLIB (GCC) porting for RT-Thread
+
+Please define RT_USING_LIBC and compile RT-Thread with GCC compiler.
+
+
+
+## More Information
+
+https://sourceware.org/newlib/libc.html#Reentrancy \ No newline at end of file
diff --git a/components/libc/pthreads/semaphore.c b/components/libc/pthreads/semaphore.c
index 2bef10022e..2ed93e99b6 100644
--- a/components/libc/pthreads/semaphore.c
+++ b/components/libc/pthreads/semaphore.c
@@ -64,7 +64,7 @@ static sem_t *posix_sem_find(const char* name)
for (iter = posix_sem_list; iter != RT_NULL; iter = iter->next)
{
- object = (rt_object_t)&(iter->sem);
+ object = (rt_object_t)iter->sem;
if (strncmp(object->name, name, RT_NAME_MAX) == 0)
{