summaryrefslogtreecommitdiff
path: root/components/drivers
diff options
context:
space:
mode:
authorthread-liu <[email protected]>2020-12-03 09:09:00 +0800
committerGitHub <[email protected]>2020-12-03 09:09:00 +0800
commitd97530e0ffc6e28a7a68f66dfcf775f02fc007e5 (patch)
tree523fdc8c8b15b4c68501ec7f09b29c26954a51db /components/drivers
parent73391c60fb7b26c5c05188b065196eea75d63145 (diff)
parentdf3d4b7bc9cab6dcc0aaf87cd32bd67bb1531036 (diff)
Merge branch 'master' into step4
Diffstat (limited to 'components/drivers')
-rw-r--r--components/drivers/audio/audio.c2
-rw-r--r--components/drivers/include/ipc/ringbuffer.h1
-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/serial/serial.c5
-rw-r--r--components/drivers/src/ringbuffer.c34
-rw-r--r--components/drivers/src/workqueue.c2
8 files changed, 57 insertions, 12 deletions
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/ipc/ringbuffer.h b/components/drivers/include/ipc/ringbuffer.h
index 4487d02c47..2afd2ca213 100644
--- a/components/drivers/include/ipc/ringbuffer.h
+++ b/components/drivers/include/ipc/ringbuffer.h
@@ -71,6 +71,7 @@ rt_size_t rt_ringbuffer_put_force(struct rt_ringbuffer *rb, const rt_uint8_t *pt
rt_size_t rt_ringbuffer_putchar(struct rt_ringbuffer *rb, const rt_uint8_t ch);
rt_size_t rt_ringbuffer_putchar_force(struct rt_ringbuffer *rb, const rt_uint8_t ch);
rt_size_t rt_ringbuffer_get(struct rt_ringbuffer *rb, rt_uint8_t *ptr, rt_uint16_t length);
+rt_size_t rt_ringbuffer_peak(struct rt_ringbuffer *rb, rt_uint8_t **ptr);
rt_size_t rt_ringbuffer_getchar(struct rt_ringbuffer *rb, rt_uint8_t *ch);
rt_size_t rt_ringbuffer_data_len(struct rt_ringbuffer *rb);
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/serial/serial.c b/components/drivers/serial/serial.c
index 2511f18102..c2cc2f615c 100644
--- a/components/drivers/serial/serial.c
+++ b/components/drivers/serial/serial.c
@@ -221,7 +221,10 @@ rt_inline int _serial_poll_rx(struct rt_serial_device *serial, rt_uint8_t *data,
*data = ch;
data ++; length --;
- if (ch == '\n') break;
+ if(serial->parent.open_flag & RT_DEVICE_FLAG_STREAM)
+ {
+ if (ch == '\n') break;
+ }
}
return size - length;
diff --git a/components/drivers/src/ringbuffer.c b/components/drivers/src/ringbuffer.c
index c6a491a7cc..88afd19506 100644
--- a/components/drivers/src/ringbuffer.c
+++ b/components/drivers/src/ringbuffer.c
@@ -194,6 +194,40 @@ rt_size_t rt_ringbuffer_get(struct rt_ringbuffer *rb,
RTM_EXPORT(rt_ringbuffer_get);
/**
+ * peak data from ring buffer
+ */
+rt_size_t rt_ringbuffer_peak(struct rt_ringbuffer *rb, rt_uint8_t **ptr)
+{
+ RT_ASSERT(rb != RT_NULL);
+
+ *ptr = RT_NULL;
+
+ /* whether has enough data */
+ rt_size_t size = rt_ringbuffer_data_len(rb);
+
+ /* no data */
+ if (size == 0)
+ return 0;
+
+ *ptr = &rb->buffer_ptr[rb->read_index];
+
+ if(rb->buffer_size - rb->read_index > size)
+ {
+ rb->read_index += size;
+ return size;
+ }
+
+ size = rb->buffer_size - rb->read_index;
+
+ /* we are going into the other side of the mirror */
+ rb->read_mirror = ~rb->read_mirror;
+ rb->read_index = 0;
+
+ return size;
+}
+RTM_EXPORT(rt_ringbuffer_peak);
+
+/**
* put a character into ring buffer
*/
rt_size_t rt_ringbuffer_putchar(struct rt_ringbuffer *rb, const rt_uint8_t ch)
diff --git a/components/drivers/src/workqueue.c b/components/drivers/src/workqueue.c
index 2e0280df3a..2b5630d8d0 100644
--- a/components/drivers/src/workqueue.c
+++ b/components/drivers/src/workqueue.c
@@ -424,6 +424,6 @@ int rt_work_sys_workqueue_init(void)
return RT_EOK;
}
-INIT_DEVICE_EXPORT(rt_work_sys_workqueue_init);
+INIT_PREV_EXPORT(rt_work_sys_workqueue_init);
#endif
#endif