summaryrefslogtreecommitdiff
path: root/components
diff options
context:
space:
mode:
authorliuxianliang <[email protected]>2021-04-06 10:42:58 +0800
committerliuxianliang <[email protected]>2021-04-06 10:42:58 +0800
commit233e1cd8bc7cbdc38006dfc18adde8bc2595620f (patch)
treecec4669f56b09734b7dcc2682d854fef325722b8 /components
parent4431c4796fb3e26fb66c012feb8bf47f3292b473 (diff)
parentc5a0df2254bd6fadc941a33d9066ce6b972c4274 (diff)
Merge branch 'master' of https://github.com/RT-Thread/rt-thread into develop_one
Diffstat (limited to 'components')
-rw-r--r--components/drivers/include/drivers/sensor.h3
-rw-r--r--components/drivers/sensors/sensor.c3
-rw-r--r--components/drivers/serial/serial.c2
-rw-r--r--components/drivers/spi/SConscript5
-rw-r--r--components/drivers/spi/sfud/src/sfud.c2
-rw-r--r--components/drivers/src/ringblk_buf.c42
-rw-r--r--components/libc/pthreads/pthread.c21
7 files changed, 52 insertions, 26 deletions
diff --git a/components/drivers/include/drivers/sensor.h b/components/drivers/include/drivers/sensor.h
index d071893eed..e05006f9f6 100644
--- a/components/drivers/include/drivers/sensor.h
+++ b/components/drivers/include/drivers/sensor.h
@@ -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;
};
diff --git a/components/drivers/sensors/sensor.c b/components/drivers/sensors/sensor.c
index 6d584e568e..8d43a7a905 100644
--- a/components/drivers/sensors/sensor.c
+++ b/components/drivers/sensors/sensor.c
@@ -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 */
diff --git a/components/drivers/serial/serial.c b/components/drivers/serial/serial.c
index d9a20f05a0..32161ad0cb 100644
--- a/components/drivers/serial/serial.c
+++ b/components/drivers/serial/serial.c
@@ -816,11 +816,11 @@ static rt_err_t rt_serial_close(struct rt_device *dev)
/* configure low level device */
serial->ops->control(serial, RT_DEVICE_CTRL_CLR_INT, (void *) RT_DEVICE_FLAG_DMA_TX);
}
+#endif /* RT_SERIAL_USING_DMA */
serial->ops->control(serial, RT_DEVICE_CTRL_CLOSE, RT_NULL);
dev->flag &= ~RT_DEVICE_FLAG_ACTIVATED;
-#endif /* RT_SERIAL_USING_DMA */
return RT_EOK;
}
diff --git a/components/drivers/spi/SConscript b/components/drivers/spi/SConscript
index e19f30861f..d6cb93f7f1 100644
--- a/components/drivers/spi/SConscript
+++ b/components/drivers/spi/SConscript
@@ -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
diff --git a/components/drivers/spi/sfud/src/sfud.c b/components/drivers/spi/sfud/src/sfud.c
index e5b03131ff..4078179262 100644
--- a/components/drivers/spi/sfud/src/sfud.c
+++ b/components/drivers/spi/sfud/src/sfud.c
@@ -218,7 +218,7 @@ sfud_err sfud_qspi_fast_read_enable(sfud_flash *flash, uint8_t data_line_width)
break;
case 2:
if (read_mode & DUAL_IO) {
- qspi_set_read_cmd_format(flash, SFUD_CMD_DUAL_IO_READ_DATA, 1, 2, 8, 2);
+ qspi_set_read_cmd_format(flash, SFUD_CMD_DUAL_IO_READ_DATA, 1, 2, 4, 2);
} else if (read_mode & DUAL_OUTPUT) {
qspi_set_read_cmd_format(flash, SFUD_CMD_DUAL_OUTPUT_READ_DATA, 1, 1, 8, 2);
} else {
diff --git a/components/drivers/src/ringblk_buf.c b/components/drivers/src/ringblk_buf.c
index c9631b9d4a..c6688b3d2b 100644
--- a/components/drivers/src/ringblk_buf.c
+++ b/components/drivers/src/ringblk_buf.c
@@ -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;
}
}
diff --git a/components/libc/pthreads/pthread.c b/components/libc/pthreads/pthread.c
index 8a728c4e99..79104d1fd5 100644
--- a/components/libc/pthreads/pthread.c
+++ b/components/libc/pthreads/pthread.c
@@ -209,6 +209,8 @@ int pthread_create(pthread_t *pid,
/* get pthread data */
ptd = _pthread_get_data(pth_id);
+ RT_ASSERT(ptd != RT_NULL);
+
if (attr != RT_NULL)
{
ptd->attr = *attr;
@@ -299,6 +301,12 @@ int pthread_detach(pthread_t thread)
{
int ret = 0;
_pthread_data_t *ptd = _pthread_get_data(thread);
+ if (ptd == RT_NULL)
+ {
+ /* invalid pthread id */
+ ret = EINVAL;
+ goto __exit;
+ }
rt_enter_critical();
if (ptd->attr.detachstate == PTHREAD_CREATE_DETACHED)
@@ -360,6 +368,12 @@ int pthread_join(pthread_t thread, void **value_ptr)
rt_err_t result;
ptd = _pthread_get_data(thread);
+
+ if (ptd == RT_NULL)
+ {
+ return EINVAL; /* invalid pthread id */
+ }
+
if (ptd && ptd->tid == rt_thread_self())
{
/* join self */
@@ -367,7 +381,9 @@ int pthread_join(pthread_t thread, void **value_ptr)
}
if (ptd->attr.detachstate == PTHREAD_CREATE_DETACHED)
+ {
return EINVAL; /* join on a detached pthread */
+ }
result = rt_sem_take(ptd->joinable_sem, RT_WAITING_FOREVER);
if (result == RT_EOK)
@@ -662,7 +678,10 @@ int pthread_cancel(pthread_t thread)
/* get posix thread data */
ptd = _pthread_get_data(thread);
- RT_ASSERT(ptd != RT_NULL);
+ if (ptd == RT_NULL)
+ {
+ return EINVAL;
+ }
/* cancel self */
if (ptd->tid == rt_thread_self())