mirror of
https://github.com/RT-Thread/rt-thread.git
synced 2025-02-21 01:07:18 +08:00
fixed the coding style in the components/drivers
git-svn-id: https://rt-thread.googlecode.com/svn/trunk@2431 bbd45198-f89e-11dd-88c7-29a3b14d5316
This commit is contained in:
parent
871951930b
commit
68b7e7c481
@ -1,7 +1,7 @@
|
||||
/*
|
||||
* File : i2c-bit-ops.c
|
||||
* This file is part of RT-Thread RTOS
|
||||
* COPYRIGHT (C) 2006, RT-Thread Development Team
|
||||
* COPYRIGHT (C) 2006 - 2012, RT-Thread Development Team
|
||||
*
|
||||
* The license and distribution terms for this file may be
|
||||
* found in the file LICENSE in this distribution or at
|
||||
@ -20,7 +20,6 @@
|
||||
#define bit_dbg(fmt, ...)
|
||||
#endif
|
||||
|
||||
|
||||
#define SET_SDA(ops, val) ops->set_sda(ops->data, val)
|
||||
#define SET_SCL(ops, val) ops->set_scl(ops->data, val)
|
||||
#define GET_SDA(ops) ops->get_sda(ops->data)
|
||||
@ -40,7 +39,7 @@ rt_inline void i2c_delay2(struct rt_i2c_bit_ops *ops)
|
||||
#define SDA_H(ops) SET_SDA(ops, 1)
|
||||
#define SCL_L(ops) SET_SCL(ops, 0)
|
||||
|
||||
/*
|
||||
/**
|
||||
* release scl line, and wait scl line to high.
|
||||
*/
|
||||
static rt_err_t SCL_H(struct rt_i2c_bit_ops *ops)
|
||||
@ -73,7 +72,6 @@ done:
|
||||
return RT_EOK;
|
||||
}
|
||||
|
||||
|
||||
static void i2c_start(struct rt_i2c_bit_ops *ops)
|
||||
{
|
||||
#ifdef RT_I2C_BIT_DEBUG
|
||||
@ -101,7 +99,6 @@ static void i2c_restart(struct rt_i2c_bit_ops *ops)
|
||||
SCL_L(ops);
|
||||
}
|
||||
|
||||
|
||||
static void i2c_stop(struct rt_i2c_bit_ops *ops)
|
||||
{
|
||||
SDA_L(ops);
|
||||
@ -122,6 +119,7 @@ rt_inline rt_bool_t i2c_waitack(struct rt_i2c_bit_ops *ops)
|
||||
if (SCL_H(ops) < 0)
|
||||
{
|
||||
bit_dbg("wait ack timeout\n");
|
||||
|
||||
return -RT_ETIMEOUT;
|
||||
}
|
||||
|
||||
@ -133,7 +131,6 @@ rt_inline rt_bool_t i2c_waitack(struct rt_i2c_bit_ops *ops)
|
||||
return ack;
|
||||
}
|
||||
|
||||
|
||||
static rt_int32_t i2c_writeb(struct rt_i2c_bus_device *bus, rt_uint8_t data)
|
||||
{
|
||||
rt_int32_t i;
|
||||
@ -152,9 +149,9 @@ static rt_int32_t i2c_writeb(struct rt_i2c_bus_device *bus, rt_uint8_t data)
|
||||
bit_dbg("i2c_writeb: 0x%02x, "
|
||||
"wait scl pin high timeout at bit %d\n",
|
||||
data, i);
|
||||
|
||||
return -RT_ETIMEOUT;
|
||||
}
|
||||
|
||||
}
|
||||
SCL_L(ops);
|
||||
i2c_delay(ops);
|
||||
@ -162,7 +159,6 @@ static rt_int32_t i2c_writeb(struct rt_i2c_bus_device *bus, rt_uint8_t data)
|
||||
return i2c_waitack(ops);
|
||||
}
|
||||
|
||||
|
||||
static rt_int32_t i2c_readb(struct rt_i2c_bus_device *bus)
|
||||
{
|
||||
rt_uint8_t i;
|
||||
@ -179,6 +175,7 @@ static rt_int32_t i2c_readb(struct rt_i2c_bus_device *bus)
|
||||
{
|
||||
bit_dbg("i2c_readb: wait scl pin high "
|
||||
"timeout at bit %d\n", 7 - i);
|
||||
|
||||
return -RT_ETIMEOUT;
|
||||
}
|
||||
|
||||
@ -191,8 +188,8 @@ static rt_int32_t i2c_readb(struct rt_i2c_bus_device *bus)
|
||||
return data;
|
||||
}
|
||||
|
||||
|
||||
static rt_size_t i2c_send_bytes(struct rt_i2c_bus_device *bus, struct rt_i2c_msg *msg)
|
||||
static rt_size_t i2c_send_bytes(struct rt_i2c_bus_device *bus,
|
||||
struct rt_i2c_msg *msg)
|
||||
{
|
||||
rt_int32_t ret;
|
||||
rt_size_t bytes = 0;
|
||||
@ -213,14 +210,17 @@ static rt_size_t i2c_send_bytes(struct rt_i2c_bus_device *bus, struct rt_i2c_msg
|
||||
else if (ret == 0)
|
||||
{
|
||||
i2c_dbg("send bytes: NACK.\n");
|
||||
|
||||
return 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
i2c_dbg("send bytes: error %d\n", ret);
|
||||
|
||||
return ret;
|
||||
}
|
||||
}
|
||||
|
||||
return bytes;
|
||||
}
|
||||
|
||||
@ -234,13 +234,16 @@ static rt_err_t i2c_send_ack_or_nack(struct rt_i2c_bus_device *bus, int ack)
|
||||
if (SCL_H(ops) < 0)
|
||||
{
|
||||
bit_dbg("ACK or NACK timeout\n");
|
||||
|
||||
return -RT_ETIMEOUT;
|
||||
}
|
||||
SCL_L(ops);
|
||||
|
||||
return RT_EOK;
|
||||
}
|
||||
|
||||
static rt_size_t i2c_recv_bytes(struct rt_i2c_bus_device *bus, struct rt_i2c_msg *msg)
|
||||
static rt_size_t i2c_recv_bytes(struct rt_i2c_bus_device *bus,
|
||||
struct rt_i2c_msg *msg)
|
||||
{
|
||||
rt_int32_t val;
|
||||
rt_int32_t bytes = 0; /* actual bytes */
|
||||
@ -275,11 +278,13 @@ static rt_size_t i2c_recv_bytes(struct rt_i2c_bus_device *bus, struct rt_i2c_msg
|
||||
return val;
|
||||
}
|
||||
}
|
||||
|
||||
return bytes;
|
||||
}
|
||||
|
||||
static rt_int32_t i2c_send_address(struct rt_i2c_bus_device *bus,
|
||||
rt_uint8_t addr, rt_int32_t retries)
|
||||
rt_uint8_t addr,
|
||||
rt_int32_t retries)
|
||||
{
|
||||
struct rt_i2c_bit_ops *ops = bus->priv;
|
||||
rt_int32_t i;
|
||||
@ -300,7 +305,8 @@ static rt_int32_t i2c_send_address(struct rt_i2c_bus_device *bus,
|
||||
return ret;
|
||||
}
|
||||
|
||||
static rt_err_t i2c_bit_send_address(struct rt_i2c_bus_device *bus, struct rt_i2c_msg *msg)
|
||||
static rt_err_t i2c_bit_send_address(struct rt_i2c_bus_device *bus,
|
||||
struct rt_i2c_msg *msg)
|
||||
{
|
||||
rt_uint16_t flags = msg->flags;
|
||||
rt_uint16_t ignore_nack = msg->flags & RT_I2C_IGNORE_NACK;
|
||||
@ -323,6 +329,7 @@ static rt_err_t i2c_bit_send_address(struct rt_i2c_bus_device *bus, struct rt_i2
|
||||
if ((ret != 1) && !ignore_nack)
|
||||
{
|
||||
bit_dbg("NACK: sending first addr\n");
|
||||
|
||||
return -RT_EIO;
|
||||
}
|
||||
|
||||
@ -330,6 +337,7 @@ static rt_err_t i2c_bit_send_address(struct rt_i2c_bus_device *bus, struct rt_i2
|
||||
if ((ret != 1) && !ignore_nack)
|
||||
{
|
||||
bit_dbg("NACK: sending second addr\n");
|
||||
|
||||
return -RT_EIO;
|
||||
}
|
||||
if (flags & RT_I2C_RD)
|
||||
@ -341,6 +349,7 @@ static rt_err_t i2c_bit_send_address(struct rt_i2c_bus_device *bus, struct rt_i2
|
||||
if ((ret != 1) && !ignore_nack)
|
||||
{
|
||||
bit_dbg("NACK: sending repeated addr\n");
|
||||
|
||||
return -RT_EIO;
|
||||
}
|
||||
}
|
||||
@ -359,9 +368,9 @@ static rt_err_t i2c_bit_send_address(struct rt_i2c_bus_device *bus, struct rt_i2
|
||||
return RT_EOK;
|
||||
}
|
||||
|
||||
|
||||
static rt_size_t i2c_bit_xfer(struct rt_i2c_bus_device *bus,
|
||||
struct rt_i2c_msg msgs[], rt_uint32_t num)
|
||||
struct rt_i2c_msg msgs[],
|
||||
rt_uint32_t num)
|
||||
{
|
||||
struct rt_i2c_msg *msg;
|
||||
struct rt_i2c_bit_ops *ops = bus->priv;
|
||||
@ -392,8 +401,7 @@ static rt_size_t i2c_bit_xfer(struct rt_i2c_bus_device *bus,
|
||||
{
|
||||
ret = i2c_recv_bytes(bus, msg);
|
||||
if (ret >= 1)
|
||||
bit_dbg("read %d byte%s\n",
|
||||
ret, ret == 1 ? "" : "s");
|
||||
bit_dbg("read %d byte%s\n", ret, ret == 1 ? "" : "s");
|
||||
if (ret < msg->len)
|
||||
{
|
||||
if (ret >= 0)
|
||||
@ -405,8 +413,7 @@ static rt_size_t i2c_bit_xfer(struct rt_i2c_bus_device *bus,
|
||||
{
|
||||
ret = i2c_send_bytes(bus, msg);
|
||||
if (ret >= 1)
|
||||
bit_dbg("write %d byte%s\n",
|
||||
ret, ret == 1 ? "" : "s");
|
||||
bit_dbg("write %d byte%s\n", ret, ret == 1 ? "" : "s");
|
||||
if (ret < msg->len)
|
||||
{
|
||||
if (ret >= 0)
|
||||
@ -424,7 +431,6 @@ out:
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
||||
static const struct rt_i2c_bus_device_ops i2c_bit_bus_ops =
|
||||
{
|
||||
i2c_bit_xfer,
|
||||
@ -432,8 +438,8 @@ static const struct rt_i2c_bus_device_ops i2c_bit_bus_ops =
|
||||
RT_NULL
|
||||
};
|
||||
|
||||
|
||||
rt_err_t rt_i2c_bit_add_bus(struct rt_i2c_bus_device *bus, const char *bus_name)
|
||||
rt_err_t rt_i2c_bit_add_bus(struct rt_i2c_bus_device *bus,
|
||||
const char *bus_name)
|
||||
{
|
||||
struct rt_i2c_bit_ops *bit_ops = bus->priv;
|
||||
RT_ASSERT(bit_ops != RT_NULL);
|
||||
|
@ -1,7 +1,7 @@
|
||||
/*
|
||||
* File : i2c_core.c
|
||||
* This file is part of RT-Thread RTOS
|
||||
* COPYRIGHT (C) 2006, RT-Thread Development Team
|
||||
* COPYRIGHT (C) 2006 - 2012, RT-Thread Development Team
|
||||
*
|
||||
* The license and distribution terms for this file may be
|
||||
* found in the file LICENSE in this distribution or at
|
||||
@ -33,10 +33,10 @@ rt_err_t rt_i2c_bus_device_register(struct rt_i2c_bus_device *bus,
|
||||
i2c_dbg("I2C bus [%s] registered\n", bus_name);
|
||||
|
||||
rt_mutex_release(&i2c_core_lock);
|
||||
|
||||
return res;
|
||||
}
|
||||
|
||||
|
||||
struct rt_i2c_bus_device *rt_i2c_bus_device_find(const char *bus_name)
|
||||
{
|
||||
struct rt_i2c_bus_device *bus;
|
||||
@ -44,6 +44,7 @@ struct rt_i2c_bus_device* rt_i2c_bus_device_find(const char *bus_name)
|
||||
if (dev == RT_NULL || dev->type != RT_Device_Class_I2CBUS)
|
||||
{
|
||||
i2c_dbg("I2C bus %s not exist\n", bus_name);
|
||||
|
||||
return RT_NULL;
|
||||
}
|
||||
|
||||
@ -52,7 +53,6 @@ struct rt_i2c_bus_device* rt_i2c_bus_device_find(const char *bus_name)
|
||||
return bus;
|
||||
}
|
||||
|
||||
|
||||
rt_size_t rt_i2c_transfer(struct rt_i2c_bus_device *bus,
|
||||
struct rt_i2c_msg msgs[],
|
||||
rt_uint32_t num)
|
||||
@ -79,11 +79,11 @@ rt_size_t rt_i2c_transfer(struct rt_i2c_bus_device *bus,
|
||||
else
|
||||
{
|
||||
i2c_dbg("I2C bus operation not supported\n");
|
||||
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
rt_size_t rt_i2c_master_send(struct rt_i2c_bus_device *bus,
|
||||
rt_uint16_t addr,
|
||||
rt_uint16_t flags,
|
||||
@ -103,8 +103,6 @@ rt_size_t rt_i2c_master_send(struct rt_i2c_bus_device *bus,
|
||||
return (ret > 0) ? count : ret;
|
||||
}
|
||||
|
||||
|
||||
|
||||
rt_size_t rt_i2c_master_recv(struct rt_i2c_bus_device *bus,
|
||||
rt_uint16_t addr,
|
||||
rt_uint16_t flags,
|
||||
@ -126,10 +124,8 @@ rt_size_t rt_i2c_master_recv(struct rt_i2c_bus_device *bus,
|
||||
return (ret > 0) ? count : ret;
|
||||
}
|
||||
|
||||
|
||||
rt_err_t rt_i2c_core_init(void)
|
||||
{
|
||||
|
||||
return rt_mutex_init(&i2c_core_lock, "i2c_core_lock", RT_IPC_FLAG_FIFO);
|
||||
}
|
||||
|
||||
|
@ -1,3 +1,17 @@
|
||||
/*
|
||||
* File : i2c_dev.c
|
||||
* This file is part of RT-Thread RTOS
|
||||
* COPYRIGHT (C) 2006 - 2012, RT-Thread Development Team
|
||||
*
|
||||
* The license and distribution terms for this file may be
|
||||
* found in the file LICENSE in this distribution or at
|
||||
* http://www.rt-thread.org/license/LICENSE
|
||||
*
|
||||
* Change Logs:
|
||||
* Date Author Notes
|
||||
* 2012-04-25 weety first version
|
||||
*/
|
||||
|
||||
#include <rtdevice.h>
|
||||
|
||||
static rt_err_t i2c_bus_device_init(rt_device_t dev)
|
||||
@ -28,7 +42,6 @@ static rt_size_t i2c_bus_device_read (rt_device_t dev,
|
||||
return rt_i2c_master_recv(bus, addr, flags, buffer, count);
|
||||
}
|
||||
|
||||
|
||||
static rt_size_t i2c_bus_device_write(rt_device_t dev,
|
||||
rt_off_t pos,
|
||||
const void *buffer,
|
||||
@ -61,7 +74,8 @@ static rt_err_t i2c_bus_device_control(rt_device_t dev,
|
||||
|
||||
switch (cmd)
|
||||
{
|
||||
case RT_I2C_DEV_CTRL_10BIT: /* set 10-bit addr mode */
|
||||
/* set 10-bit addr mode */
|
||||
case RT_I2C_DEV_CTRL_10BIT:
|
||||
bus->flags |= RT_I2C_ADDR_10BIT;
|
||||
break;
|
||||
case RT_I2C_DEV_CTRL_ADDR:
|
||||
@ -85,7 +99,6 @@ static rt_err_t i2c_bus_device_control(rt_device_t dev,
|
||||
return RT_EOK;
|
||||
}
|
||||
|
||||
|
||||
rt_err_t rt_i2c_bus_device_device_init(struct rt_i2c_bus_device *bus,
|
||||
const char *name)
|
||||
{
|
||||
|
@ -1,7 +1,7 @@
|
||||
/*
|
||||
* File : i2c-bit-ops.h
|
||||
* This file is part of RT-Thread RTOS
|
||||
* COPYRIGHT (C) 2006, RT-Thread Development Team
|
||||
* COPYRIGHT (C) 2006 - 2012, RT-Thread Development Team
|
||||
*
|
||||
* The license and distribution terms for this file may be
|
||||
* found in the file LICENSE in this distribution or at
|
||||
|
@ -1,7 +1,7 @@
|
||||
/*
|
||||
* File : i2c.h
|
||||
* This file is part of RT-Thread RTOS
|
||||
* COPYRIGHT (C) 2006, RT-Thread Development Team
|
||||
* COPYRIGHT (C) 2006 - 2012, RT-Thread Development Team
|
||||
*
|
||||
* The license and distribution terms for this file may be
|
||||
* found in the file LICENSE in this distribution or at
|
||||
|
@ -1,3 +1,17 @@
|
||||
/*
|
||||
* File : i2c_dev.h
|
||||
* This file is part of RT-Thread RTOS
|
||||
* COPYRIGHT (C) 2006 - 2012, RT-Thread Development Team
|
||||
*
|
||||
* The license and distribution terms for this file may be
|
||||
* found in the file LICENSE in this distribution or at
|
||||
* http://www.rt-thread.org/license/LICENSE
|
||||
*
|
||||
* Change Logs:
|
||||
* Date Author Notes
|
||||
* 2012-04-25 weety first version
|
||||
*/
|
||||
|
||||
#ifndef __I2C_DEV_H__
|
||||
#define __I2C_DEV_H__
|
||||
|
||||
@ -21,7 +35,6 @@ struct rt_i2c_priv_data
|
||||
rt_err_t rt_i2c_bus_device_device_init(struct rt_i2c_bus_device *bus,
|
||||
const char *name);
|
||||
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
@ -20,7 +20,7 @@
|
||||
|
||||
#ifdef RT_USING_MTD_NAND
|
||||
|
||||
/*
|
||||
/**
|
||||
* RT-Thread Generic Device Interface
|
||||
*/
|
||||
static rt_err_t _mtd_init(rt_device_t dev)
|
||||
@ -38,12 +38,18 @@ static rt_err_t _mtd_close(rt_device_t dev)
|
||||
return RT_EOK;
|
||||
}
|
||||
|
||||
static rt_size_t _mtd_read(rt_device_t dev, rt_off_t pos, void *buffer, rt_size_t size)
|
||||
static rt_size_t _mtd_read(rt_device_t dev,
|
||||
rt_off_t pos,
|
||||
void *buffer,
|
||||
rt_size_t size)
|
||||
{
|
||||
return size;
|
||||
}
|
||||
|
||||
static rt_size_t _mtd_write(rt_device_t dev, rt_off_t pos, const void *buffer, rt_size_t size)
|
||||
static rt_size_t _mtd_write(rt_device_t dev,
|
||||
rt_off_t pos,
|
||||
const void *buffer,
|
||||
rt_size_t size)
|
||||
{
|
||||
return size;
|
||||
}
|
||||
@ -53,7 +59,8 @@ static rt_err_t _mtd_control(rt_device_t dev, rt_uint8_t cmd, void *args)
|
||||
return RT_EOK;
|
||||
}
|
||||
|
||||
rt_err_t rt_mtd_nand_register_device(const char* name, struct rt_mtd_nand_device* device)
|
||||
rt_err_t rt_mtd_nand_register_device(const char *name,
|
||||
struct rt_mtd_nand_device *device)
|
||||
{
|
||||
rt_device_t dev;
|
||||
|
||||
@ -75,4 +82,6 @@ rt_err_t rt_mtd_nand_register_device(const char* name, struct rt_mtd_nand_device
|
||||
/* register to RT-Thread device system */
|
||||
return rt_device_register(dev, name, RT_DEVICE_FLAG_RDWR | RT_DEVICE_FLAG_STANDALONE);
|
||||
}
|
||||
|
||||
|
||||
#endif
|
||||
|
@ -16,7 +16,7 @@
|
||||
|
||||
#ifdef RT_USING_MTD_NOR
|
||||
|
||||
/*
|
||||
/**
|
||||
* RT-Thread Generic Device Interface
|
||||
*/
|
||||
static rt_err_t _mtd_init(rt_device_t dev)
|
||||
@ -34,12 +34,18 @@ static rt_err_t _mtd_close(rt_device_t dev)
|
||||
return RT_EOK;
|
||||
}
|
||||
|
||||
static rt_size_t _mtd_read(rt_device_t dev, rt_off_t pos, void *buffer, rt_size_t size)
|
||||
static rt_size_t _mtd_read(rt_device_t dev,
|
||||
rt_off_t pos,
|
||||
void *buffer,
|
||||
rt_size_t size)
|
||||
{
|
||||
return size;
|
||||
}
|
||||
|
||||
static rt_size_t _mtd_write(rt_device_t dev, rt_off_t pos, const void *buffer, rt_size_t size)
|
||||
static rt_size_t _mtd_write(rt_device_t dev,
|
||||
rt_off_t pos,
|
||||
const void *buffer,
|
||||
rt_size_t size)
|
||||
{
|
||||
return size;
|
||||
}
|
||||
@ -49,7 +55,8 @@ static rt_err_t _mtd_control(rt_device_t dev, rt_uint8_t cmd, void *args)
|
||||
return RT_EOK;
|
||||
}
|
||||
|
||||
rt_err_t rt_mtd_nor_register_device(const char* name, struct rt_mtd_nor_device* device)
|
||||
rt_err_t rt_mtd_nor_register_device(const char *name,
|
||||
struct rt_mtd_nor_device *device)
|
||||
{
|
||||
rt_device_t dev;
|
||||
|
||||
@ -71,4 +78,5 @@ rt_err_t rt_mtd_nor_register_device(const char* name, struct rt_mtd_nor_device*
|
||||
/* register to RT-Thread device system */
|
||||
return rt_device_register(dev, name, RT_DEVICE_FLAG_RDWR | RT_DEVICE_FLAG_STANDALONE);
|
||||
}
|
||||
|
||||
#endif
|
||||
|
@ -89,6 +89,7 @@ rt_err_t rt_completion_wait(struct rt_completion *completion,
|
||||
|
||||
__exit:
|
||||
rt_hw_interrupt_enable(level);
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
|
@ -46,9 +46,11 @@ rt_size_t rt_ringbuffer_put(struct rt_ringbuffer *rb,
|
||||
size = rb->buffer_size - (rb->write_index - rb->read_index);
|
||||
|
||||
/* no space */
|
||||
if (size == 0) return 0;
|
||||
if (size == 0)
|
||||
return 0;
|
||||
/* drop some data */
|
||||
if (size < length) length = size;
|
||||
if (size < length)
|
||||
length = size;
|
||||
|
||||
write_position = (rb->write_index & mask);
|
||||
if (rb->buffer_size - write_position> length)
|
||||
@ -81,7 +83,8 @@ rt_size_t rt_ringbuffer_putchar(struct rt_ringbuffer* rb, const rt_uint8_t ch)
|
||||
mask = rb->buffer_size - 1;
|
||||
|
||||
/* whether has enough space */
|
||||
if (rb->write_index - rb->read_index == rb->buffer_size) return 0;
|
||||
if (rb->write_index - rb->read_index == rb->buffer_size)
|
||||
return 0;
|
||||
|
||||
/* put character */
|
||||
rb->buffer_ptr[rb->write_index & mask] = ch;
|
||||
@ -108,9 +111,11 @@ rt_size_t rt_ringbuffer_get(struct rt_ringbuffer *rb,
|
||||
size = rb->write_index - rb->read_index;
|
||||
|
||||
/* no data */
|
||||
if (size == 0) return 0;
|
||||
if (size == 0)
|
||||
return 0;
|
||||
/* less data */
|
||||
if (size < length) length = size;
|
||||
if (size < length)
|
||||
length = size;
|
||||
|
||||
read_position = rb->read_index & mask;
|
||||
if (rb->buffer_size - read_position >= length)
|
||||
@ -142,7 +147,8 @@ rt_size_t rt_ringbuffer_getchar(struct rt_ringbuffer *rb, rt_uint8_t *ch)
|
||||
RT_ASSERT(rb != RT_NULL);
|
||||
|
||||
/* ringbuffer is empty */
|
||||
if (rb->read_index == rb->write_index) return 0;
|
||||
if (rb->read_index == rb->write_index)
|
||||
return 0;
|
||||
|
||||
mask = rb->buffer_size - 1;
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user