Skip to content

Commit a00cc57

Browse files
committed
Prepare RT-Thread 1.2.3 release.
1 parent c7ee7f9 commit a00cc57

File tree

24 files changed

+152
-173
lines changed

24 files changed

+152
-173
lines changed

bsp/lpc176x/drivers/sd.c

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -397,7 +397,19 @@ static rt_size_t rt_sdcard_write (rt_device_t dev, rt_off_t pos, const void* buf
397397

398398
static rt_err_t rt_sdcard_control(rt_device_t dev, rt_uint8_t cmd, void *args)
399399
{
400-
return RT_EOK;
400+
if (cmd == RT_DEVICE_CTRL_BLK_GETGEOME)
401+
{
402+
struct rt_device_blk_geometry *geometry;
403+
404+
geometry = (struct rt_device_blk_geometry *)args;
405+
if (geometry == RT_NULL) return -RT_ERROR;
406+
407+
geometry->bytes_per_sector = SDCfg.sectorsize;
408+
geometry->block_size = SDCfg.blocksize;
409+
geometry->sector_count = SDCfg.sectorcnt;
410+
}
411+
412+
return RT_EOK;
401413
}
402414

403415
void rt_hw_sdcard_init()

bsp/lpc408x/Libraries/Device/NXP/LPC407x_8x_177x_8x/Source/Templates/GCC/startup_LPC407x_8x_177x_8x.s

Lines changed: 22 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -102,18 +102,18 @@ __cs3_interrupt_vector_cortex_m:
102102
.long DMA_IRQHandler /* 42: General Purpose DMA */
103103
.long I2S_IRQHandler /* 43: I2S */
104104
.long ENET_IRQHandler /* 44: Ethernet */
105-
.long MCI_IRQHandler /* 45: SD/MMC Card */
105+
.long MCI_IRQHandler /* 45: SD/MMC Card */
106106
.long MCPWM_IRQHandler /* 46: Motor Control PWM */
107107
.long QEI_IRQHandler /* 47: Quadrature Encoder Interface */
108108
.long PLL1_IRQHandler /* 48: PLL1 Lock (USB PLL) */
109-
.long USBActivity_IRQHandler /* 49: USB Activity */
110-
.long CANActivity_IRQHandler /* 50: CAN Activity */
111-
.long UART4_IRQHandler /* 51: UART4 */
112-
.long SSP2_IRQHandler /* 52: SSP2 */
113-
.long LCD_IRQHandler /* 53: LCD */
114-
.long GPIO_IRQHandler /* 54: GPIO */
115-
.long PWM0_IRQHandler /* 55: PWM0 */
116-
.long EEPROM_IRQHandler /* 56: EEPROM */
109+
.long USBActivity_IRQHandler /* 49: USB Activity */
110+
.long CANActivity_IRQHandler /* 50: CAN Activity */
111+
.long UART4_IRQHandler /* 51: UART4 */
112+
.long SSP2_IRQHandler /* 52: SSP2 */
113+
.long LCD_IRQHandler /* 53: LCD */
114+
.long GPIO_IRQHandler /* 54: GPIO */
115+
.long PWM0_IRQHandler /* 55: PWM0 */
116+
.long EEPROM_IRQHandler /* 56: EEPROM */
117117

118118
.size __cs3_interrupt_vector_cortex_m, . - __cs3_interrupt_vector_cortex_m
119119

@@ -130,22 +130,24 @@ CRP_Value:
130130
.section .cs3.reset,"x",%progbits
131131
.thumb_func
132132
.globl __cs3_reset_cortex_m
133+
.globl Reset_Handler
133134
.type __cs3_reset_cortex_m, %function
134135
__cs3_reset_cortex_m:
136+
Reset_Handler:
135137
.fnstart
136138
.ifdef RAM_MODE
137139
/* Clear .bss section (Zero init) */
138-
MOV R0, #0
139-
LDR R1, =__bss_start__
140-
LDR R2, =__bss_end__
141-
CMP R1,R2
142-
BEQ BSSIsEmpty
140+
MOV R0, #0
141+
LDR R1, =__bss_start__
142+
LDR R2, =__bss_end__
143+
CMP R1,R2
144+
BEQ BSSIsEmpty
143145
LoopZI:
144-
CMP R1, R2
145-
BHS BSSIsEmpty
146-
STR R0, [R1]
147-
ADD R1, #4
148-
BLO LoopZI
146+
CMP R1, R2
147+
BHS BSSIsEmpty
148+
STR R0, [R1]
149+
ADD R1, #4
150+
BLO LoopZI
149151
BSSIsEmpty:
150152
LDR R0, =SystemInit
151153
BLX R0
@@ -154,7 +156,7 @@ BSSIsEmpty:
154156
.else
155157
LDR R0, =SystemInit
156158
BLX R0
157-
LDR R0,=_start
159+
LDR R0,=main
158160
BX R0
159161
.endif
160162
.pool

components/dfs/filesystems/nfs/dfs_nfs.c

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -750,11 +750,12 @@ int nfs_open(struct dfs_fd *file)
750750
if (file->flags & DFS_O_CREAT)
751751
{
752752
if (nfs_mkdir(nfs, file->path, 0755) < 0)
753-
return -1;
753+
return -DFS_STATUS_EAGAIN;
754754
}
755755

756756
/* open directory */
757757
dir = nfs_opendir(nfs, file->path);
758+
if (dir == RT_NULL) return -DFS_STATUS_ENOENT;
758759
file->data = dir;
759760
}
760761
else
@@ -766,20 +767,20 @@ int nfs_open(struct dfs_fd *file)
766767
if (file->flags & DFS_O_CREAT)
767768
{
768769
if (nfs_create(nfs, file->path, 0664) < 0)
769-
return -1;
770+
return -DFS_STATUS_EAGAIN;
770771
}
771772

772773
/* open file (get file handle ) */
773774
fp = rt_malloc(sizeof(nfs_file));
774775
if (fp == RT_NULL)
775-
return -1;
776+
return -DFS_STATUS_ENOMEM;
776777

777778
handle = get_handle(nfs, file->path);
778779
if (handle == RT_NULL)
779780
{
780781
rt_free(fp);
781782

782-
return -1;
783+
return -DFS_STATUS_ENOENT;
783784
}
784785

785786
/* get size of file */
@@ -798,7 +799,7 @@ int nfs_open(struct dfs_fd *file)
798799

799800
/* set private file */
800801
file->data = fp;
801-
file->size = fp->size;
802+
file->size = fp->size;
802803
}
803804

804805
return 0;

components/dfs/src/dfs_file.c

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -335,6 +335,9 @@ int dfs_file_lseek(struct dfs_fd *fd, rt_off_t offset)
335335

336336
if (fd == RT_NULL)
337337
return -DFS_STATUS_EINVAL;
338+
fs = fd->fs;
339+
if (fs == RT_NULL)
340+
return -DFS_STATUS_EINVAL;
338341
if (fs->ops->lseek == RT_NULL)
339342
return -DFS_STATUS_ENOSYS;
340343

@@ -555,7 +558,7 @@ void ls(const char *pathname)
555558
if (pathname == RT_NULL)
556559
rt_free(path);
557560
}
558-
FINSH_FUNCTION_EXPORT(ls, list directory contents)
561+
FINSH_FUNCTION_EXPORT(ls, list directory contents);
559562

560563
void rm(const char *filename)
561564
{
@@ -564,7 +567,7 @@ void rm(const char *filename)
564567
rt_kprintf("Delete %s failed\n", filename);
565568
}
566569
}
567-
FINSH_FUNCTION_EXPORT(rm, remove files or directories)
570+
FINSH_FUNCTION_EXPORT(rm, remove files or directories);
568571

569572
void cat(const char* filename)
570573
{
@@ -590,7 +593,7 @@ void cat(const char* filename)
590593

591594
dfs_file_close(&fd);
592595
}
593-
FINSH_FUNCTION_EXPORT(cat, print file)
596+
FINSH_FUNCTION_EXPORT(cat, print file);
594597

595598
#define BUF_SZ 4096
596599
static void copyfile(const char *src, const char *dst)

components/dfs/src/dfs_fs.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -85,6 +85,8 @@ struct dfs_filesystem *dfs_filesystem_lookup(const char *path)
8585

8686
prefixlen = 0;
8787

88+
RT_ASSERT(path);
89+
8890
/* lock filesystem */
8991
dfs_lock();
9092

components/dfs/src/dfs_posix.c

Lines changed: 16 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -33,11 +33,11 @@
3333

3434
/**
3535
* this function is a POSIX compliant version, which will open a file and
36-
* return a file descriptor.
36+
* return a file descriptor according specified flags.
3737
*
3838
* @param file the path name of file.
3939
* @param flags the file open flags.
40-
* @param mode
40+
* @param mode ignored parameter
4141
*
4242
* @return the non-negative integer on successful open, others for failed.
4343
*/
@@ -120,7 +120,8 @@ RTM_EXPORT(close);
120120
* @param buf the buffer to save the read data.
121121
* @param len the maximal length of data buffer
122122
*
123-
* @return the actual read data buffer length
123+
* @return the actual read data buffer length. If the returned value is 0, it
124+
* may be reach the end of file, please check errno.
124125
*/
125126
int read(int fd, void *buf, size_t len)
126127
{
@@ -200,7 +201,7 @@ RTM_EXPORT(write);
200201
* @param offset the offset to be seeked.
201202
* @param whence the directory of seek.
202203
*
203-
* @return the current file position, or -1 on failed.
204+
* @return the current read/write position in the file, or -1 on failed.
204205
*/
205206
off_t lseek(int fd, off_t offset, int whence)
206207
{
@@ -336,6 +337,8 @@ RTM_EXPORT(stat);
336337
*
337338
* @param fildes the file description
338339
* @param buf the data buffer to save stat description.
340+
*
341+
* @return 0 on successful, -1 on failed.
339342
*/
340343
int fstat(int fildes, struct stat *buf)
341344
{
@@ -470,7 +473,7 @@ RTM_EXPORT(rmdir);
470473
*
471474
* @param name the path name to be open.
472475
*
473-
* @return the DIR pointer of directory, NULL on open failed.
476+
* @return the DIR pointer of directory, NULL on open directory failed.
474477
*/
475478
DIR *opendir(const char *name)
476479
{
@@ -537,12 +540,17 @@ struct dirent *readdir(DIR *d)
537540
if (fd == RT_NULL)
538541
{
539542
rt_set_errno(-DFS_STATUS_EBADF);
540-
541543
return RT_NULL;
542544
}
543545

544-
if (!d->num ||
545-
(d->cur += ((struct dirent *)(d->buf + d->cur))->d_reclen) >= d->num)
546+
if (d->num)
547+
{
548+
struct dirent* dirent_ptr;
549+
dirent_ptr = (struct dirent*)&d->buf[d->cur];
550+
d->cur += dirent_ptr->d_reclen;
551+
}
552+
553+
if (!d->num || d->cur >= d->num)
546554
{
547555
/* get a new entry */
548556
result = dfs_file_getdents(fd,

components/drivers/i2c/i2c-bit-ops.c

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -451,9 +451,6 @@ static const struct rt_i2c_bus_device_ops i2c_bit_bus_ops =
451451
rt_err_t rt_i2c_bit_add_bus(struct rt_i2c_bus_device *bus,
452452
const char *bus_name)
453453
{
454-
struct rt_i2c_bit_ops *bit_ops = bus->priv;
455-
RT_ASSERT(bit_ops != RT_NULL);
456-
457454
bus->ops = &i2c_bit_bus_ops;
458455

459456
return rt_i2c_bus_device_register(bus, bus_name);

components/drivers/i2c/i2c_core.c

Lines changed: 2 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -24,26 +24,19 @@
2424

2525
#include <rtdevice.h>
2626

27-
static struct rt_mutex i2c_core_lock;
28-
2927
rt_err_t rt_i2c_bus_device_register(struct rt_i2c_bus_device *bus,
3028
const char *bus_name)
3129
{
3230
rt_err_t res = RT_EOK;
3331

3432
rt_mutex_init(&bus->lock, "i2c_bus_lock", RT_IPC_FLAG_FIFO);
3533

36-
rt_mutex_take(&i2c_core_lock, RT_WAITING_FOREVER);
37-
38-
if (bus->timeout == 0)
39-
bus->timeout = RT_TICK_PER_SECOND;
34+
if (bus->timeout == 0) bus->timeout = RT_TICK_PER_SECOND;
4035

4136
res = rt_i2c_bus_device_device_init(bus, bus_name);
4237

4338
i2c_dbg("I2C bus [%s] registered\n", bus_name);
4439

45-
rt_mutex_release(&i2c_core_lock);
46-
4740
return res;
4841
}
4942

@@ -136,6 +129,6 @@ rt_size_t rt_i2c_master_recv(struct rt_i2c_bus_device *bus,
136129

137130
int rt_i2c_core_init(void)
138131
{
139-
return rt_mutex_init(&i2c_core_lock, "i2c_core_lock", RT_IPC_FLAG_FIFO);
132+
return 0;
140133
}
141134
INIT_COMPONENT_EXPORT(rt_i2c_core_init);

components/drivers/i2c/i2c_dev.c

Lines changed: 2 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -20,18 +20,11 @@
2020
* Change Logs:
2121
* Date Author Notes
2222
* 2012-04-25 weety first version
23+
* 2014-08-03 bernard fix some compiling warning
2324
*/
2425

2526
#include <rtdevice.h>
2627

27-
static rt_err_t i2c_bus_device_init(rt_device_t dev)
28-
{
29-
struct rt_i2c_bus_device *bus = (struct rt_i2c_bus_device *)dev->user_data;
30-
RT_ASSERT(bus != RT_NULL);
31-
32-
return RT_EOK;
33-
}
34-
3528
static rt_size_t i2c_bus_device_read(rt_device_t dev,
3629
rt_off_t pos,
3730
void *buffer,
@@ -122,7 +115,7 @@ rt_err_t rt_i2c_bus_device_device_init(struct rt_i2c_bus_device *bus,
122115
/* set device type */
123116
device->type = RT_Device_Class_I2CBUS;
124117
/* initialize device interface */
125-
device->init = i2c_bus_device_init;
118+
device->init = RT_NULL;
126119
device->open = RT_NULL;
127120
device->close = RT_NULL;
128121
device->read = i2c_bus_device_read;

components/drivers/include/drivers/serial.h

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,9 +30,15 @@
3030

3131
#include <rtthread.h>
3232

33+
#define BAUD_RATE_2400 2400
3334
#define BAUD_RATE_4800 4800
3435
#define BAUD_RATE_9600 9600
36+
#define BAUD_RATE_38400 38400
37+
#define BAUD_RATE_57600 57600
3538
#define BAUD_RATE_115200 115200
39+
#define BAUD_RATE_230400 230400
40+
#define BAUD_RATE_460800 460800
41+
#define BAUD_RATE_921600 921600
3642

3743
#define DATA_BITS_5 5
3844
#define DATA_BITS_6 6

0 commit comments

Comments
 (0)