fixed coding style in component/drivers/src

git-svn-id: https://rt-thread.googlecode.com/svn/trunk@2384 bbd45198-f89e-11dd-88c7-29a3b14d5316
This commit is contained in:
dzzxzz@gmail.com 2012-11-02 04:05:38 +00:00
parent 5d710e8862
commit 1aab195a7d
3 changed files with 319 additions and 301 deletions

View File

@ -30,7 +30,8 @@ void rt_completion_init(struct rt_completion* completion)
rt_hw_interrupt_enable(level); rt_hw_interrupt_enable(level);
} }
rt_err_t rt_completion_wait(struct rt_completion* completion, rt_int32_t timeout) rt_err_t rt_completion_wait(struct rt_completion *completion,
rt_int32_t timeout)
{ {
rt_err_t result; rt_err_t result;
rt_base_t level; rt_base_t level;
@ -96,7 +97,8 @@ void rt_completion_done(struct rt_completion* completion)
rt_base_t level; rt_base_t level;
RT_ASSERT(completion != RT_NULL); RT_ASSERT(completion != RT_NULL);
if(completion->flag == RT_COMPLETED) return; if (completion->flag == RT_COMPLETED)
return;
level = rt_hw_interrupt_disable(); level = rt_hw_interrupt_disable();
completion->flag = RT_COMPLETED; completion->flag = RT_COMPLETED;

View File

@ -11,11 +11,15 @@
* Date Author Notes * Date Author Notes
* 2012-09-30 Bernard first version. * 2012-09-30 Bernard first version.
*/ */
#include <rthw.h> #include <rthw.h>
#include <rtthread.h> #include <rtthread.h>
#include <rtdevice.h> #include <rtdevice.h>
static rt_size_t rt_pipe_read(rt_device_t dev, rt_off_t pos, void *buffer, rt_size_t size) static rt_size_t rt_pipe_read(rt_device_t dev,
rt_off_t pos,
void *buffer,
rt_size_t size)
{ {
rt_uint32_t level; rt_uint32_t level;
rt_thread_t thread; rt_thread_t thread;
@ -69,7 +73,10 @@ static rt_size_t rt_pipe_read(rt_device_t dev, rt_off_t pos, void *buffer, rt_si
} }
struct rt_pipe_device *_pipe = RT_NULL; struct rt_pipe_device *_pipe = RT_NULL;
static rt_size_t rt_pipe_write(rt_device_t dev, rt_off_t pos, const void *buffer, rt_size_t size) static rt_size_t rt_pipe_write(rt_device_t dev,
rt_off_t pos,
const void *buffer,
rt_size_t size)
{ {
rt_uint32_t level; rt_uint32_t level;
rt_thread_t thread; rt_thread_t thread;
@ -172,8 +179,10 @@ rt_err_t rt_pipe_create(const char* name, rt_size_t size)
} }
__exit: __exit:
if (pipe != RT_NULL) rt_free(pipe); if (pipe != RT_NULL)
if (rb_memptr != RT_NULL) rt_free(rb_memptr); rt_free(pipe);
if (rb_memptr != RT_NULL)
rt_free(rb_memptr);
return result; return result;
} }
@ -181,7 +190,8 @@ RTM_EXPORT(rt_pipe_create);
void rt_pipe_destroy(struct rt_pipe_device *pipe) void rt_pipe_destroy(struct rt_pipe_device *pipe)
{ {
if (pipe == RT_NULL) return; if (pipe == RT_NULL)
return;
/* un-register pipe device */ /* un-register pipe device */
rt_device_unregister(&(pipe->parent)); rt_device_unregister(&(pipe->parent));
@ -193,4 +203,3 @@ void rt_pipe_destroy(struct rt_pipe_device* pipe)
return; return;
} }
RTM_EXPORT(rt_pipe_destroy); RTM_EXPORT(rt_pipe_destroy);

View File

@ -16,7 +16,9 @@
#include <rtdevice.h> #include <rtdevice.h>
#include <string.h> #include <string.h>
void rt_ringbuffer_init(struct rt_ringbuffer* rb, rt_uint8_t *pool, rt_uint16_t size) void rt_ringbuffer_init(struct rt_ringbuffer *rb,
rt_uint8_t *pool,
rt_uint16_t size)
{ {
RT_ASSERT(rb != RT_NULL); RT_ASSERT(rb != RT_NULL);
@ -29,7 +31,9 @@ void rt_ringbuffer_init(struct rt_ringbuffer* rb, rt_uint8_t *pool, rt_uint16_t
} }
RTM_EXPORT(rt_ringbuffer_init); RTM_EXPORT(rt_ringbuffer_init);
rt_size_t rt_ringbuffer_put(struct rt_ringbuffer* rb, const rt_uint8_t *ptr, rt_uint16_t length) rt_size_t rt_ringbuffer_put(struct rt_ringbuffer *rb,
const rt_uint8_t *ptr,
rt_uint16_t length)
{ {
rt_uint16_t size; rt_uint16_t size;
rt_uint16_t mask; rt_uint16_t mask;
@ -54,7 +58,8 @@ rt_size_t rt_ringbuffer_put(struct rt_ringbuffer* rb, const rt_uint8_t *ptr, rt_
} }
else else
{ {
memcpy(&rb->buffer_ptr[write_position], ptr, rb->buffer_size - write_position); memcpy(&rb->buffer_ptr[write_position], ptr,
rb->buffer_size - write_position);
memcpy(&rb->buffer_ptr[0], &ptr[rb->buffer_size - write_position], memcpy(&rb->buffer_ptr[0], &ptr[rb->buffer_size - write_position],
length - (rb->buffer_size - write_position)); length - (rb->buffer_size - write_position));
} }
@ -89,7 +94,9 @@ RTM_EXPORT(rt_ringbuffer_putchar);
/** /**
* get data from ring buffer * get data from ring buffer
*/ */
rt_size_t rt_ringbuffer_get(struct rt_ringbuffer* rb, rt_uint8_t *ptr, rt_uint16_t length) rt_size_t rt_ringbuffer_get(struct rt_ringbuffer *rb,
rt_uint8_t *ptr,
rt_uint16_t length)
{ {
rt_size_t size; rt_size_t size;
rt_uint16_t mask; rt_uint16_t mask;
@ -114,7 +121,8 @@ rt_size_t rt_ringbuffer_get(struct rt_ringbuffer* rb, rt_uint8_t *ptr, rt_uint16
else else
{ {
/* copy first and second */ /* copy first and second */
memcpy(ptr, &rb->buffer_ptr[read_position], rb->buffer_size - read_position); memcpy(ptr, &rb->buffer_ptr[read_position],
rb->buffer_size - read_position);
memcpy(&ptr[rb->buffer_size - read_position], &rb->buffer_ptr[0], memcpy(&ptr[rb->buffer_size - read_position], &rb->buffer_ptr[0],
length - rb->buffer_size + read_position); length - rb->buffer_size + read_position);
} }
@ -145,4 +153,3 @@ rt_size_t rt_ringbuffer_getchar(struct rt_ringbuffer* rb, rt_uint8_t *ch)
return 1; return 1;
} }
RTM_EXPORT(rt_ringbuffer_getchar); RTM_EXPORT(rt_ringbuffer_getchar);