Skip to content

Commit d113eb0

Browse files
authored
Merge pull request #2145 from armink/lts-v3.1.x
Lts v3.1.x
2 parents af33226 + 1805aad commit d113eb0

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

60 files changed

+2553
-468
lines changed

components/dfs/filesystems/elmfat/dfs_elm.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -265,7 +265,7 @@ int dfs_elm_mkfs(rt_device_t dev_id)
265265
/* [IN] Size of the allocation unit */
266266
/* [-] Working buffer */
267267
/* [IN] Size of working buffer */
268-
result = f_mkfs(logic_nbr, FM_ANY, 0, work, _MAX_SS);
268+
result = f_mkfs(logic_nbr, FM_ANY|FM_SFD, 0, work, _MAX_SS);
269269
rt_free(work); work = RT_NULL;
270270

271271
/* check flag status, we need clear the temp driver stored in disk[] */

components/dfs/src/dfs.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -221,7 +221,7 @@ struct dfs_fd *fd_get(int fd)
221221
d = fdt->fds[fd];
222222

223223
/* check dfs_fd valid or not */
224-
if (d->magic != DFS_FD_MAGIC)
224+
if ((d == NULL) || (d->magic != DFS_FD_MAGIC))
225225
{
226226
dfs_unlock();
227227
return NULL;

components/dfs/src/dfs_posix.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -890,9 +890,9 @@ int access(const char *path, int amode)
890890
char *getcwd(char *buf, size_t size)
891891
{
892892
#ifdef DFS_USING_WORKDIR
893-
rt_enter_critical();
893+
dfs_lock();
894894
strncpy(buf, working_directory, size);
895-
rt_exit_critical();
895+
dfs_unlock();
896896
#else
897897
rt_kprintf(NO_WORKING_DIR);
898898
#endif

components/drivers/Kconfig

Lines changed: 22 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,12 @@ config RT_USING_SERIAL
1616
select RT_USING_DEVICE
1717
default y
1818

19+
if RT_USING_SERIAL
20+
config RT_SERIAL_USING_DMA
21+
bool "Enable serial DMA mode"
22+
default y
23+
endif
24+
1925
config RT_USING_CAN
2026
bool "Using CAN device drivers"
2127
default n
@@ -72,6 +78,10 @@ config RT_USING_PIN
7278
bool "Using generic GPIO device drivers"
7379
default y
7480

81+
config RT_USING_ADC
82+
bool "Using ADC device drivers"
83+
default n
84+
7585
config RT_USING_PWM
7686
bool "Using PWM device drivers"
7787
default n
@@ -118,9 +128,8 @@ config RT_USING_RTC
118128
default n
119129
config RTC_SYNC_USING_NTP
120130
bool "Using NTP auto sync RTC time"
121-
select PKG_USING_NETUTILS
122-
select PKG_NETUTILS_NTP
123-
default n
131+
depends on PKG_NETUTILS_NTP
132+
default y
124133

125134
if RTC_SYNC_USING_NTP
126135
config RTC_NTP_FIRST_SYNC_DELAY
@@ -165,7 +174,11 @@ config RT_USING_SPI
165174
bool "Using SPI Bus/Device device drivers"
166175
default n
167176

168-
if RT_USING_SPI
177+
if RT_USING_SPI
178+
config RT_USING_QSPI
179+
bool "Enable QSPI mode"
180+
default n
181+
169182
config RT_USING_SPI_MSD
170183
bool "Using SD/TF card driver with spi"
171184
select RT_USING_DFS
@@ -182,6 +195,11 @@ config RT_USING_SPI
182195
config RT_SFUD_USING_FLASH_INFO_TABLE
183196
bool "Using defined supported flash chip information table"
184197
default y
198+
199+
config RT_SFUD_USING_QSPI
200+
bool "Using QSPI mode support"
201+
select RT_USING_QSPI
202+
default n
185203

186204
config RT_DEBUG_SFUD
187205
bool "Show more SFUD debug information"

components/drivers/audio/audio.c

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -105,8 +105,6 @@ static rt_err_t _audio_dev_init(struct rt_device *dev)
105105

106106
static rt_err_t _audio_dev_open(struct rt_device *dev, rt_uint16_t oflag)
107107
{
108-
rt_err_t result = RT_EOK;
109-
rt_base_t level;
110108
struct rt_audio_device *audio;
111109

112110
RT_ASSERT(dev != RT_NULL);
@@ -159,7 +157,6 @@ static rt_err_t _audio_dev_open(struct rt_device *dev, rt_uint16_t oflag)
159157

160158
//init pipe for record
161159
{
162-
rt_size_t size = CFG_AUDIO_RECORD_PIPE_SIZE;
163160
rt_uint8_t *buf = rt_malloc(CFG_AUDIO_RECORD_PIPE_SIZE);
164161

165162
if (buf == RT_NULL)
@@ -170,7 +167,7 @@ static rt_err_t _audio_dev_open(struct rt_device *dev, rt_uint16_t oflag)
170167
return -RT_ENOMEM;
171168
}
172169

173-
rt_audio_pipe_init(&audio_pipe, "recpipe", RT_PIPE_FLAG_FORCE_WR | RT_PIPE_FLAG_BLOCK_RD, buf,
170+
rt_audio_pipe_init(&audio_pipe, "recpipe", (rt_int32_t)(RT_PIPE_FLAG_FORCE_WR | RT_PIPE_FLAG_BLOCK_RD), buf,
174171
CFG_AUDIO_RECORD_PIPE_SIZE);
175172
}
176173

@@ -536,8 +533,6 @@ void rt_audio_tx_complete(struct rt_audio_device *audio, rt_uint8_t *pbuf)
536533

537534
void rt_audio_rx_done(struct rt_audio_device *audio, rt_uint8_t *pbuf, rt_size_t len)
538535
{
539-
rt_err_t result = RT_EOK;
540-
541536
//save data to record pipe
542537
rt_device_write(RT_DEVICE(RT_DEVICE(&audio_pipe)), 0, pbuf, len);
543538

components/drivers/audio/audio_pipe.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -188,7 +188,7 @@ static rt_err_t rt_pipe_control(rt_device_t dev, int cmd, void *args)
188188
}
189189

190190
#ifdef RT_USING_DEVICE_OPS
191-
const static struct rt_device_ops audio_pipe_ops
191+
const static struct rt_device_ops audio_pipe_ops =
192192
{
193193
RT_NULL,
194194
RT_NULL,
@@ -213,7 +213,7 @@ const static struct rt_device_ops audio_pipe_ops
213213
*/
214214
rt_err_t rt_audio_pipe_init(struct rt_audio_pipe *pipe,
215215
const char *name,
216-
enum rt_audio_pipe_flag flag,
216+
rt_int32_t flag,
217217
rt_uint8_t *buf,
218218
rt_size_t size)
219219
{
@@ -258,7 +258,7 @@ rt_err_t rt_audio_pipe_detach(struct rt_audio_pipe *pipe)
258258
}
259259

260260
#ifdef RT_USING_HEAP
261-
rt_err_t rt_audio_pipe_create(const char *name, enum rt_audio_pipe_flag flag, rt_size_t size)
261+
rt_err_t rt_audio_pipe_create(const char *name, rt_int32_t flag, rt_size_t size)
262262
{
263263
rt_uint8_t *rb_memptr = RT_NULL;
264264
struct rt_audio_pipe *pipe = RT_NULL;

components/drivers/audio/audio_pipe.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ struct rt_audio_pipe
5050
/* ring buffer in pipe device */
5151
struct rt_ringbuffer ringbuffer;
5252

53-
enum rt_audio_pipe_flag flag;
53+
rt_int32_t flag;
5454

5555
/* suspended list */
5656
rt_list_t suspended_read_list;
@@ -64,12 +64,12 @@ struct rt_audio_pipe
6464

6565
rt_err_t rt_audio_pipe_init(struct rt_audio_pipe *pipe,
6666
const char *name,
67-
enum rt_audio_pipe_flag flag,
67+
rt_int32_t flag,
6868
rt_uint8_t *buf,
6969
rt_size_t size);
7070
rt_err_t rt_audio_pipe_detach(struct rt_audio_pipe *pipe);
7171
#ifdef RT_USING_HEAP
72-
rt_err_t rt_audio_pipe_create(const char *name, enum rt_audio_pipe_flag flag, rt_size_t size);
72+
rt_err_t rt_audio_pipe_create(const char *name, rt_int32_t flag, rt_size_t size);
7373
void rt_audio_pipe_destroy(struct rt_audio_pipe *pipe);
7474
#endif
7575
#endif

components/drivers/hwtimer/README_CN.md

Lines changed: 24 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -1,30 +1,29 @@
1-
定时器设备
2-
===
3-
4-
##功能
5-
---
1+
# 定时器设备
2+
3+
## 功能
4+
65
* 时间测量
76
* 周期或单次执行回调函数
87

9-
##编译
10-
---
8+
## 编译
9+
1110
1. 在rtconfig.h添加 `#define RT_USING_HWTIMER`
12-
13-
##使用流程
14-
---
11+
12+
## 使用流程
13+
1514
1. 以读写方式打开设备
1615
2. 设置超时回调函数(如果需要)
1716
3. 根据需要设置定时模式(单次/周期)
1817
4. 设置计数频率(可选)
1918
5. 写入超时值,定时器随即启动
2019
6. 停止定时器(可选)
2120
7. 关闭设备(如果需要)
22-
21+
2322
应用参考 [hwtimer_test] (/examples/test/hwtimer\_test.c)
2423

25-
##驱动编写指南
26-
---
27-
###操作接口
24+
## 驱动编写指南
25+
26+
### 操作接口
2827

2928
```
3029
struct rt_hwtimer_ops
@@ -43,8 +42,8 @@ struct rt_hwtimer_ops
4342
* count_get - <读取计数器值>
4443
* control - <设置计数频率 >
4544

46-
###定时器特征信息
47-
45+
### 定时器特征信息
46+
4847
```
4948
struct rt_hwtimer_info
5049
{
@@ -60,7 +59,8 @@ struct rt_hwtimer_info
6059
* maxcnt <计数器最大计数值>
6160
* cntmode <递增计数/递减计数>
6261

63-
###注册设备
62+
### 注册设备
63+
6464
```
6565
static rt_hwtimer_t _timer0;
6666
int stm32_hwtimer_init(void)
@@ -73,8 +73,9 @@ int stm32_hwtimer_init(void)
7373
return 0;
7474
}
7575
```
76-
77-
###定时器中断
76+
77+
### 定时器中断
78+
7879
```
7980
void timer_irq_handler(void)
8081
{
@@ -84,15 +85,13 @@ void timer_irq_handler(void)
8485
}
8586
```
8687

87-
##注意事项
88-
---
89-
90-
<font color="#FF0000">可能出现定时误差</font>
91-
88+
## 注意事项
89+
90+
**可能出现定时误差**
9291

9392
误差原因:
9493

9594
假设计数器最大值0xFFFF,计数频率1Mhz,定时时间1秒又1微秒。
96-
95+
9796
由于定时器一次最多只能计时到65535us,对于1000001us的定时要求。
9897
可以50000us定时20次完成,此时将会出现计算误差1us。

components/drivers/hwtimer/hwtimer.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -153,7 +153,7 @@ static rt_size_t rt_hwtimer_read(struct rt_device *dev, rt_off_t pos, void *buff
153153
cnt = timer->ops->count_get(timer);
154154
if (timer->info->cntmode == HWTIMER_CNTMODE_DW)
155155
{
156-
cnt = timer->info->maxcnt - cnt;
156+
cnt = (timer->freq * timer->period_sec) - cnt;
157157
}
158158

159159
t = timer->overflow * timer->period_sec + cnt/(float)timer->freq;
Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
/*
2+
* Copyright (c) 2006-2018, RT-Thread Development Team
3+
*
4+
* SPDX-License-Identifier: Apache-2.0
5+
*
6+
* Change Logs:
7+
* Date Author Notes
8+
* 2018-05-07 aozima the first version
9+
* 2018-11-16 Ernest Chen add finsh command and update adc function
10+
*/
11+
12+
#ifndef __ADC_H__
13+
#define __ADC_H__
14+
#include <rtthread.h>
15+
16+
struct rt_adc_device;
17+
struct rt_adc_ops
18+
{
19+
rt_err_t (*enabled)(struct rt_adc_device *device, rt_uint32_t channel, rt_bool_t enabled);
20+
rt_err_t (*convert)(struct rt_adc_device *device, rt_uint32_t channel, rt_uint32_t *value);
21+
};
22+
23+
struct rt_adc_device
24+
{
25+
struct rt_device parent;
26+
const struct rt_adc_ops *ops;
27+
};
28+
typedef struct rt_adc_device *rt_adc_device_t;
29+
30+
typedef enum
31+
{
32+
RT_ADC_CMD_ENABLE,
33+
RT_ADC_CMD_DISABLE,
34+
} rt_adc_cmd_t;
35+
36+
rt_err_t rt_hw_adc_register(rt_adc_device_t adc,const char *name, const struct rt_adc_ops *ops, const void *user_data);
37+
38+
rt_uint32_t rt_adc_read(rt_adc_device_t dev, rt_uint32_t channel);
39+
rt_err_t rt_adc_enable(rt_adc_device_t dev, rt_uint32_t channel);
40+
rt_err_t rt_adc_disable(rt_adc_device_t dev, rt_uint32_t channel);
41+
42+
#endif /* __ADC_H__ */

0 commit comments

Comments
 (0)