diff options
| author | thread-liu <[email protected]> | 2020-12-03 09:09:00 +0800 |
|---|---|---|
| committer | GitHub <[email protected]> | 2020-12-03 09:09:00 +0800 |
| commit | d97530e0ffc6e28a7a68f66dfcf775f02fc007e5 (patch) | |
| tree | 523fdc8c8b15b4c68501ec7f09b29c26954a51db /components | |
| parent | 73391c60fb7b26c5c05188b065196eea75d63145 (diff) | |
| parent | df3d4b7bc9cab6dcc0aaf87cd32bd67bb1531036 (diff) | |
Merge branch 'master' into step4
Diffstat (limited to 'components')
| -rw-r--r-- | components/dfs/filesystems/devfs/devfs.c | 2 | ||||
| -rw-r--r-- | components/drivers/audio/audio.c | 2 | ||||
| -rw-r--r-- | components/drivers/include/ipc/ringbuffer.h | 1 | ||||
| -rw-r--r-- | components/drivers/pm/pm.c | 12 | ||||
| -rw-r--r-- | components/drivers/rtc/alarm.c | 7 | ||||
| -rw-r--r-- | components/drivers/sdio/sdio.c | 6 | ||||
| -rw-r--r-- | components/drivers/serial/serial.c | 5 | ||||
| -rw-r--r-- | components/drivers/src/ringbuffer.c | 34 | ||||
| -rw-r--r-- | components/drivers/src/workqueue.c | 2 | ||||
| -rw-r--r-- | components/libc/compilers/common/termios.h | 2 | ||||
| -rw-r--r-- | components/libc/pthreads/semaphore.c | 2 |
11 files changed, 61 insertions, 14 deletions
diff --git a/components/dfs/filesystems/devfs/devfs.c b/components/dfs/filesystems/devfs/devfs.c index 7637074dbb..e457f18727 100644 --- a/components/dfs/filesystems/devfs/devfs.c +++ b/components/dfs/filesystems/devfs/devfs.c @@ -326,7 +326,7 @@ static const struct dfs_filesystem_ops _device_fs = int devfs_init(void) { - /* register rom file system */ + /* register device file system */ dfs_register(&_device_fs); return 0; 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 diff --git a/components/libc/compilers/common/termios.h b/components/libc/compilers/common/termios.h index ee2b4d5718..414d0c0cb3 100644 --- a/components/libc/compilers/common/termios.h +++ b/components/libc/compilers/common/termios.h @@ -9,6 +9,8 @@ #ifndef _TERMIOS_H__ #define _TERMIOS_H__ +#include <rtconfig.h> + #ifdef RT_USING_POSIX_TERMIOS #include <sys/types.h> #include <posix_termios.h> 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) { |
