1.编码风格修改,宏回到全大写。

This commit is contained in:
MacRsh
2023-12-30 03:29:01 +08:00
parent 3ca21c0221
commit 714a3bec20
11 changed files with 81 additions and 81 deletions

View File

@@ -272,10 +272,10 @@ int mr_serial_register(struct mr_serial *serial, const char *name, struct mr_drv
}; };
struct mr_serial_config default_config = MR_SERIAL_CONFIG_DEFAULT; struct mr_serial_config default_config = MR_SERIAL_CONFIG_DEFAULT;
mr_assert(serial != MR_NULL); MR_ASSERT(serial != MR_NULL);
mr_assert(name != MR_NULL); MR_ASSERT(name != MR_NULL);
mr_assert(drv != MR_NULL); MR_ASSERT(drv != MR_NULL);
mr_assert(drv->ops != MR_NULL); MR_ASSERT(drv->ops != MR_NULL);
/* Initialize the fields */ /* Initialize the fields */
serial->config = default_config; serial->config = default_config;

View File

@@ -103,7 +103,7 @@ static int mr_soft_i2c_bus_configure(struct mr_i2c_bus *i2c_bus, struct mr_i2c_c
/* Configure SCL pin */ /* Configure SCL pin */
mr_dev_ioctl(soft_i2c_bus->desc, MR_CTL_PIN_SET_NUMBER, &soft_i2c_bus->scl_pin); mr_dev_ioctl(soft_i2c_bus->desc, MR_CTL_PIN_SET_NUMBER, &soft_i2c_bus->scl_pin);
int ret = mr_dev_ioctl(soft_i2c_bus->desc, MR_CTL_PIN_SET_MODE, mr_make_local(int, MR_PIN_MODE_OUTPUT_OD)); int ret = mr_dev_ioctl(soft_i2c_bus->desc, MR_CTL_PIN_SET_MODE, MR_MAKE_LOCAL(int, MR_PIN_MODE_OUTPUT_OD));
if (ret < 0) if (ret < 0)
{ {
return ret; return ret;
@@ -111,7 +111,7 @@ static int mr_soft_i2c_bus_configure(struct mr_i2c_bus *i2c_bus, struct mr_i2c_c
/* Configure SDA pin */ /* Configure SDA pin */
mr_dev_ioctl(soft_i2c_bus->desc, MR_CTL_PIN_SET_NUMBER, &soft_i2c_bus->sda_pin); mr_dev_ioctl(soft_i2c_bus->desc, MR_CTL_PIN_SET_NUMBER, &soft_i2c_bus->sda_pin);
ret = mr_dev_ioctl(soft_i2c_bus->desc, MR_CTL_PIN_SET_MODE, mr_make_local(int, MR_PIN_MODE_OUTPUT_OD)); ret = mr_dev_ioctl(soft_i2c_bus->desc, MR_CTL_PIN_SET_MODE, MR_MAKE_LOCAL(int, MR_PIN_MODE_OUTPUT_OD));
if (ret < 0) if (ret < 0)
{ {
return ret; return ret;
@@ -124,7 +124,7 @@ static int mr_soft_i2c_bus_configure(struct mr_i2c_bus *i2c_bus, struct mr_i2c_c
{ {
/* Reconfigure SCL pin */ /* Reconfigure SCL pin */
mr_dev_ioctl(soft_i2c_bus->desc, MR_CTL_PIN_SET_NUMBER, &soft_i2c_bus->scl_pin); mr_dev_ioctl(soft_i2c_bus->desc, MR_CTL_PIN_SET_NUMBER, &soft_i2c_bus->scl_pin);
int ret = mr_dev_ioctl(soft_i2c_bus->desc, MR_CTL_PIN_SET_MODE, mr_make_local(int, MR_PIN_MODE_NONE)); int ret = mr_dev_ioctl(soft_i2c_bus->desc, MR_CTL_PIN_SET_MODE, MR_MAKE_LOCAL(int, MR_PIN_MODE_NONE));
if (ret < 0) if (ret < 0)
{ {
return ret; return ret;
@@ -132,7 +132,7 @@ static int mr_soft_i2c_bus_configure(struct mr_i2c_bus *i2c_bus, struct mr_i2c_c
/* Reconfigure SDA pin */ /* Reconfigure SDA pin */
mr_dev_ioctl(soft_i2c_bus->desc, MR_CTL_PIN_SET_NUMBER, &soft_i2c_bus->sda_pin); mr_dev_ioctl(soft_i2c_bus->desc, MR_CTL_PIN_SET_NUMBER, &soft_i2c_bus->sda_pin);
ret = mr_dev_ioctl(soft_i2c_bus->desc, MR_CTL_PIN_SET_MODE, mr_make_local(int, MR_PIN_MODE_NONE)); ret = mr_dev_ioctl(soft_i2c_bus->desc, MR_CTL_PIN_SET_MODE, MR_MAKE_LOCAL(int, MR_PIN_MODE_NONE));
if (ret < 0) if (ret < 0)
{ {
return ret; return ret;
@@ -262,8 +262,8 @@ int mr_soft_i2c_bus_register(struct mr_soft_i2c_bus *soft_i2c_bus, const char *n
MR_NULL MR_NULL
}; };
mr_assert(soft_i2c_bus != MR_NULL); MR_ASSERT(soft_i2c_bus != MR_NULL);
mr_assert(name != MR_NULL); MR_ASSERT(name != MR_NULL);
/* Initialize the fields */ /* Initialize the fields */
soft_i2c_bus->delay = 0; soft_i2c_bus->delay = 0;

View File

@@ -121,10 +121,10 @@ int mr_spi_bus_register(struct mr_spi_bus *spi_bus, const char *name, struct mr_
}; };
struct mr_spi_config default_config = MR_SPI_CONFIG_DEFAULT; struct mr_spi_config default_config = MR_SPI_CONFIG_DEFAULT;
mr_assert(spi_bus != MR_NULL); MR_ASSERT(spi_bus != MR_NULL);
mr_assert(name != MR_NULL); MR_ASSERT(name != MR_NULL);
mr_assert(drv != MR_NULL); MR_ASSERT(drv != MR_NULL);
mr_assert(drv->ops != MR_NULL); MR_ASSERT(drv->ops != MR_NULL);
/* Initialize the fields */ /* Initialize the fields */
spi_bus->config = default_config; spi_bus->config = default_config;
@@ -156,7 +156,7 @@ static void spi_dev_cs_configure(struct mr_spi_dev *spi_dev, int state)
mr_dev_ioctl(desc, MR_CTL_PIN_GET_NUMBER, &old_number); mr_dev_ioctl(desc, MR_CTL_PIN_GET_NUMBER, &old_number);
/* Set the new number */ /* Set the new number */
mr_dev_ioctl(desc, MR_CTL_PIN_SET_NUMBER, mr_make_local(int, spi_dev->cs_pin)); mr_dev_ioctl(desc, MR_CTL_PIN_SET_NUMBER, MR_MAKE_LOCAL(int, spi_dev->cs_pin));
if (state == MR_ENABLE) if (state == MR_ENABLE)
{ {
int mode = MR_PIN_MODE_NONE; int mode = MR_PIN_MODE_NONE;
@@ -175,10 +175,10 @@ static void spi_dev_cs_configure(struct mr_spi_dev *spi_dev, int state)
} }
} }
mr_dev_ioctl(desc, MR_CTL_PIN_SET_MODE, &mode); mr_dev_ioctl(desc, MR_CTL_PIN_SET_MODE, &mode);
mr_dev_write(desc, mr_make_local(uint8_t, !spi_dev->cs_active), sizeof(uint8_t)); mr_dev_write(desc, MR_MAKE_LOCAL(uint8_t, !spi_dev->cs_active), sizeof(uint8_t));
} else } else
{ {
mr_dev_ioctl(desc, MR_CTL_PIN_SET_MODE, mr_make_local(int, MR_PIN_MODE_NONE)); mr_dev_ioctl(desc, MR_CTL_PIN_SET_MODE, MR_MAKE_LOCAL(int, MR_PIN_MODE_NONE));
} }
/* Restore the old number */ /* Restore the old number */
@@ -194,7 +194,7 @@ MR_INLINE void spi_dev_cs_set(struct mr_spi_dev *spi_dev, int state)
#ifdef MR_USING_PIN #ifdef MR_USING_PIN
if ((spi_dev->cs_active != MR_SPI_CS_ACTIVE_NONE) && (spi_bus->cs_desc >= 0)) if ((spi_dev->cs_active != MR_SPI_CS_ACTIVE_NONE) && (spi_bus->cs_desc >= 0))
{ {
mr_dev_write(spi_bus->cs_desc, mr_make_local(uint8_t, !(state ^ spi_dev->cs_active)), sizeof(uint8_t)); mr_dev_write(spi_bus->cs_desc, MR_MAKE_LOCAL(uint8_t, !(state ^ spi_dev->cs_active)), sizeof(uint8_t));
} }
#endif /* MR_USING_PIN */ #endif /* MR_USING_PIN */
} }
@@ -230,7 +230,7 @@ MR_INLINE int spi_dev_take_bus(struct mr_spi_dev *spi_dev)
#ifdef MR_USING_PIN #ifdef MR_USING_PIN
if (spi_bus->cs_desc >= 0) if (spi_bus->cs_desc >= 0)
{ {
mr_dev_ioctl(spi_bus->cs_desc, MR_CTL_PIN_SET_NUMBER, mr_make_local(int, spi_dev->cs_pin)); mr_dev_ioctl(spi_bus->cs_desc, MR_CTL_PIN_SET_NUMBER, MR_MAKE_LOCAL(int, spi_dev->cs_pin));
} }
#endif /* MR_USING_PIN */ #endif /* MR_USING_PIN */
} }
@@ -272,7 +272,7 @@ static ssize_t spi_dev_transfer(struct mr_spi_dev *spi_dev, void *rd_buf, const
case MR_SPI_DATA_BITS_8: case MR_SPI_DATA_BITS_8:
{ {
uint8_t *rd_data = (uint8_t *)rd_buf; uint8_t *rd_data = (uint8_t *)rd_buf;
mr_bits_clr(size, sizeof(*rd_data) - 1); MR_BIT_CLR(size, sizeof(*rd_data) - 1);
for (tf_size = 0; tf_size < size; tf_size += sizeof(*rd_data)) for (tf_size = 0; tf_size < size; tf_size += sizeof(*rd_data))
{ {
ops->write(spi_bus, 0); ops->write(spi_bus, 0);
@@ -284,7 +284,7 @@ static ssize_t spi_dev_transfer(struct mr_spi_dev *spi_dev, void *rd_buf, const
case MR_SPI_DATA_BITS_16: case MR_SPI_DATA_BITS_16:
{ {
uint16_t *rd_data = (uint16_t *)rd_buf; uint16_t *rd_data = (uint16_t *)rd_buf;
mr_bits_clr(size, sizeof(*rd_data) - 1); MR_BIT_CLR(size, sizeof(*rd_data) - 1);
for (tf_size = 0; tf_size < size; tf_size += sizeof(*rd_data)) for (tf_size = 0; tf_size < size; tf_size += sizeof(*rd_data))
{ {
ops->write(spi_bus, 0); ops->write(spi_bus, 0);
@@ -296,7 +296,7 @@ static ssize_t spi_dev_transfer(struct mr_spi_dev *spi_dev, void *rd_buf, const
case MR_SPI_DATA_BITS_32: case MR_SPI_DATA_BITS_32:
{ {
uint32_t *rd_data = (uint32_t *)rd_buf; uint32_t *rd_data = (uint32_t *)rd_buf;
mr_bits_clr(size, sizeof(*rd_data) - 1); MR_BIT_CLR(size, sizeof(*rd_data) - 1);
for (tf_size = 0; tf_size < size; tf_size += sizeof(*rd_data)) for (tf_size = 0; tf_size < size; tf_size += sizeof(*rd_data))
{ {
ops->write(spi_bus, 0); ops->write(spi_bus, 0);
@@ -318,7 +318,7 @@ static ssize_t spi_dev_transfer(struct mr_spi_dev *spi_dev, void *rd_buf, const
case MR_SPI_DATA_BITS_8: case MR_SPI_DATA_BITS_8:
{ {
uint8_t *wr_data = (uint8_t *)wr_buf; uint8_t *wr_data = (uint8_t *)wr_buf;
mr_bits_clr(size, sizeof(*wr_data) - 1); MR_BIT_CLR(size, sizeof(*wr_data) - 1);
for (tf_size = 0; tf_size < size; tf_size += sizeof(*wr_data)) for (tf_size = 0; tf_size < size; tf_size += sizeof(*wr_data))
{ {
ops->write(spi_bus, *wr_data); ops->write(spi_bus, *wr_data);
@@ -330,7 +330,7 @@ static ssize_t spi_dev_transfer(struct mr_spi_dev *spi_dev, void *rd_buf, const
case MR_SPI_DATA_BITS_16: case MR_SPI_DATA_BITS_16:
{ {
uint16_t *wr_data = (uint16_t *)wr_buf; uint16_t *wr_data = (uint16_t *)wr_buf;
mr_bits_clr(size, sizeof(*wr_data) - 1); MR_BIT_CLR(size, sizeof(*wr_data) - 1);
for (tf_size = 0; tf_size < size; tf_size += sizeof(*wr_data)) for (tf_size = 0; tf_size < size; tf_size += sizeof(*wr_data))
{ {
ops->write(spi_bus, *wr_data); ops->write(spi_bus, *wr_data);
@@ -342,7 +342,7 @@ static ssize_t spi_dev_transfer(struct mr_spi_dev *spi_dev, void *rd_buf, const
case MR_SPI_DATA_BITS_32: case MR_SPI_DATA_BITS_32:
{ {
uint32_t *wr_data = (uint32_t *)wr_buf; uint32_t *wr_data = (uint32_t *)wr_buf;
mr_bits_clr(size, sizeof(*wr_data) - 1); MR_BIT_CLR(size, sizeof(*wr_data) - 1);
for (tf_size = 0; tf_size < size; tf_size += sizeof(*wr_data)) for (tf_size = 0; tf_size < size; tf_size += sizeof(*wr_data))
{ {
ops->write(spi_bus, *wr_data); ops->write(spi_bus, *wr_data);
@@ -365,7 +365,7 @@ static ssize_t spi_dev_transfer(struct mr_spi_dev *spi_dev, void *rd_buf, const
{ {
uint8_t *rd_data = (uint8_t *)rd_buf; uint8_t *rd_data = (uint8_t *)rd_buf;
uint8_t *wr_data = (uint8_t *)wr_buf; uint8_t *wr_data = (uint8_t *)wr_buf;
mr_bits_clr(size, sizeof(*wr_data) - 1); MR_BIT_CLR(size, sizeof(*wr_data) - 1);
for (tf_size = 0; tf_size < size; tf_size += sizeof(*wr_data)) for (tf_size = 0; tf_size < size; tf_size += sizeof(*wr_data))
{ {
ops->write(spi_bus, *wr_data); ops->write(spi_bus, *wr_data);
@@ -379,7 +379,7 @@ static ssize_t spi_dev_transfer(struct mr_spi_dev *spi_dev, void *rd_buf, const
{ {
uint16_t *wr_data = (uint16_t *)wr_buf; uint16_t *wr_data = (uint16_t *)wr_buf;
uint16_t *rd_data = (uint16_t *)rd_buf; uint16_t *rd_data = (uint16_t *)rd_buf;
mr_bits_clr(size, sizeof(*wr_data) - 1); MR_BIT_CLR(size, sizeof(*wr_data) - 1);
for (tf_size = 0; tf_size < size; tf_size += sizeof(*wr_data)) for (tf_size = 0; tf_size < size; tf_size += sizeof(*wr_data))
{ {
ops->write(spi_bus, *wr_data); ops->write(spi_bus, *wr_data);
@@ -393,7 +393,7 @@ static ssize_t spi_dev_transfer(struct mr_spi_dev *spi_dev, void *rd_buf, const
{ {
uint32_t *wr_data = (uint32_t *)wr_buf; uint32_t *wr_data = (uint32_t *)wr_buf;
uint32_t *rd_data = (uint32_t *)rd_buf; uint32_t *rd_data = (uint32_t *)rd_buf;
mr_bits_clr(size, sizeof(*wr_data) - 1); MR_BIT_CLR(size, sizeof(*wr_data) - 1);
for (tf_size = 0; tf_size < size; tf_size += sizeof(*wr_data)) for (tf_size = 0; tf_size < size; tf_size += sizeof(*wr_data))
{ {
ops->write(spi_bus, *wr_data); ops->write(spi_bus, *wr_data);
@@ -666,9 +666,9 @@ int mr_spi_dev_register(struct mr_spi_dev *spi_dev, const char *name, int cs_pin
}; };
struct mr_spi_config default_config = MR_SPI_CONFIG_DEFAULT; struct mr_spi_config default_config = MR_SPI_CONFIG_DEFAULT;
mr_assert(spi_dev != MR_NULL); MR_ASSERT(spi_dev != MR_NULL);
mr_assert(name != MR_NULL); MR_ASSERT(name != MR_NULL);
mr_assert((cs_active >= MR_SPI_CS_ACTIVE_LOW) && (cs_active <= MR_SPI_CS_ACTIVE_NONE)); MR_ASSERT((cs_active >= MR_SPI_CS_ACTIVE_LOW) && (cs_active <= MR_SPI_CS_ACTIVE_NONE));
/* Initialize the fields */ /* Initialize the fields */
spi_dev->config = default_config; spi_dev->config = default_config;

View File

@@ -84,10 +84,10 @@ static int timer_calculate(struct mr_timer *timer, uint32_t timeout)
/* Check if reload can be used as period or prescaler */ /* Check if reload can be used as period or prescaler */
if ((reload_best > per_best) && (reload_best < per_max)) if ((reload_best > per_best) && (reload_best < per_max))
{ {
mr_swap(per_best, reload_best); MR_SWAP(per_best, reload_best);
} else if ((reload_best > psc_best) && (reload_best < psc_max)) } else if ((reload_best > psc_best) && (reload_best < psc_max))
{ {
mr_swap(psc_best, reload_best); MR_SWAP(psc_best, reload_best);
} }
} }
} }
@@ -129,7 +129,7 @@ static ssize_t mr_timer_read(struct mr_dev *dev, int off, void *buf, size_t size
uint32_t *rd_buf = (uint32_t *)buf; uint32_t *rd_buf = (uint32_t *)buf;
ssize_t rd_size = 0; ssize_t rd_size = 0;
mr_bits_clr(size, sizeof(*rd_buf) - 1); MR_BIT_CLR(size, sizeof(*rd_buf) - 1);
for (rd_size = 0; rd_size < size; rd_size += sizeof(*rd_buf)) for (rd_size = 0; rd_size < size; rd_size += sizeof(*rd_buf))
{ {
uint32_t count = ops->get_count(timer); uint32_t count = ops->get_count(timer);
@@ -151,7 +151,7 @@ static ssize_t mr_timer_write(struct mr_dev *dev, int off, const void *buf, size
ssize_t wr_size = 0; ssize_t wr_size = 0;
/* Only the last write is valid */ /* Only the last write is valid */
mr_bits_clr(size, sizeof(*wr_buf) - 1); MR_BIT_CLR(size, sizeof(*wr_buf) - 1);
for (wr_size = 0; wr_size < size; wr_size += sizeof(*wr_buf)) for (wr_size = 0; wr_size < size; wr_size += sizeof(*wr_buf))
{ {
timeout = *wr_buf; timeout = *wr_buf;
@@ -268,11 +268,11 @@ int mr_timer_register(struct mr_timer *timer, const char *name, struct mr_drv *d
}; };
struct mr_timer_config default_config = MR_TIMER_CONFIG_DEFAULT; struct mr_timer_config default_config = MR_TIMER_CONFIG_DEFAULT;
mr_assert(timer != MR_NULL); MR_ASSERT(timer != MR_NULL);
mr_assert(name != MR_NULL); MR_ASSERT(name != MR_NULL);
mr_assert(drv != MR_NULL); MR_ASSERT(drv != MR_NULL);
mr_assert(drv->ops != MR_NULL); MR_ASSERT(drv->ops != MR_NULL);
mr_assert(info != MR_NULL); MR_ASSERT(info != MR_NULL);
/* Initialize the fields */ /* Initialize the fields */
timer->config = default_config; timer->config = default_config;

View File

@@ -259,7 +259,7 @@ int serial_init(void)
return MR_EOK; return MR_EOK;
} }
/* 导出到自动初始化APP级 */ /* 导出到自动初始化APP级 */
MR_APP_EXPORT(serial_init); MR_INIT_APP_EXPORT(serial_init);
int main(void) int main(void)
{ {

View File

@@ -271,7 +271,7 @@ int serial_init(void)
return MR_EOK; return MR_EOK;
} }
/* Export to auto initialization (APP level) */ /* Export to auto initialization (APP level) */
MR_APP_EXPORT(serial_init); MR_INIT_APP_EXPORT(serial_init);
int main(void) int main(void)
{ {

View File

@@ -143,7 +143,7 @@ mr_dev_ioctl(ds, MR_CTL_SPI_GET_CONFIG, &config);
```c ```c
/* 设置寄存器值 */ /* 设置寄存器值 */
mr_dev_ioctl(ds, MR_CTL_SPI_SET_REG, mr_make_local(int, 0x12)); mr_dev_ioctl(ds, MR_CTL_SPI_SET_REG, MR_MAKE_LOCAL(int, 0x12));
/* 获取寄存器值 */ /* 获取寄存器值 */
uint8_t reg; uint8_t reg;
@@ -326,7 +326,7 @@ int spi_init(void)
return ret; return ret;
} }
/* 设置寄存器值 */ /* 设置寄存器值 */
mr_dev_ioctl(host_ds, MR_CTL_SPI_SET_REG, mr_make_local(int, 0x12)); mr_dev_ioctl(host_ds, MR_CTL_SPI_SET_REG, MR_MAKE_LOCAL(int, 0x12));
/* 打开SPI-SLAVE设备 */ /* 打开SPI-SLAVE设备 */
slave_ds = mr_dev_open("spi2/slave", MR_OFLAG_RDWR); slave_ds = mr_dev_open("spi2/slave", MR_OFLAG_RDWR);
@@ -347,7 +347,7 @@ int spi_init(void)
return MR_EOK; return MR_EOK;
} }
/* 导出到自动初始化APP级 */ /* 导出到自动初始化APP级 */
MR_APP_EXPORT(spi_init); MR_INIT_APP_EXPORT(spi_init);
int main(void) int main(void)
{ {

View File

@@ -149,7 +149,7 @@ The register value will be written first (range: `0` ~ `INT32_MAX`) before readi
```c ```c
/* Set register value */ /* Set register value */
mr_dev_ioctl(ds, MR_CTL_SPI_SET_REG, mr_make_local(int, 0x12)); mr_dev_ioctl(ds, MR_CTL_SPI_SET_REG, MR_MAKE_LOCAL(int, 0x12));
/* Get register value */ /* Get register value */
uint8_t reg; uint8_t reg;
@@ -344,7 +344,7 @@ int spi_init(void)
} }
/* Set register value */ /* Set register value */
mr_dev_ioctl(host_ds, MR_CTL_SPI_SET_REG, mr_make_local(int, 0x12)); mr_dev_ioctl(host_ds, MR_CTL_SPI_SET_REG, MR_MAKE_LOCAL(int, 0x12));
/* Open SLAVE SPI device */ /* Open SLAVE SPI device */
slave_ds = mr_dev_open("spi2/slave", MR_OFLAG_RDWR); slave_ds = mr_dev_open("spi2/slave", MR_OFLAG_RDWR);
@@ -366,7 +366,7 @@ int spi_init(void)
return MR_EOK; return MR_EOK;
} }
/* Export to auto init (APP level) */ /* Export to auto init (APP level) */
MR_APP_EXPORT(spi_init); MR_INIT_APP_EXPORT(spi_init);
int main(void) int main(void)
{ {

View File

@@ -78,7 +78,7 @@ TIMER设备配置
#define TIMER_MODE MR_TIMER_MODE_ONESHOT #define TIMER_MODE MR_TIMER_MODE_ONESHOT
/* 设置TIMER设备模式 */ /* 设置TIMER设备模式 */
mr_dev_ioctl(ds, MR_CTL_TIMER_SET_MODE, mr_make_local(int, TIMER_MODE)); mr_dev_ioctl(ds, MR_CTL_TIMER_SET_MODE, MR_MAKE_LOCAL(int, TIMER_MODE));
/* 获取TIMER设备模式 */ /* 获取TIMER设备模式 */
int mode; int mode;
@@ -195,7 +195,7 @@ int timer_init(void)
return MR_EOK; return MR_EOK;
} }
/* 导出到自动初始化APP级 */ /* 导出到自动初始化APP级 */
MR_APP_EXPORT(timer_init); MR_INIT_APP_EXPORT(timer_init);
int main(void) int main(void)
{ {

View File

@@ -80,7 +80,7 @@ TIMER device configuration:
#define TIMER_MODE MR_TIMER_MODE_ONESHOT #define TIMER_MODE MR_TIMER_MODE_ONESHOT
/* Set TIMER device mode */ /* Set TIMER device mode */
mr_dev_ioctl(ds, MR_CTL_TIMER_SET_MODE, mr_make_local(int, TIMER_MODE)); mr_dev_ioctl(ds, MR_CTL_TIMER_SET_MODE, MR_MAKE_LOCAL(int, TIMER_MODE));
/* Get TIMER device mode */ /* Get TIMER device mode */
int mode; int mode;
@@ -200,7 +200,7 @@ int timer_init(void)
return MR_EOK; return MR_EOK;
} }
/* Export to automatic initialization (APP level) */ /* Export to automatic initialization (APP level) */
MR_APP_EXPORT(timer_init); MR_INIT_APP_EXPORT(timer_init);
int main(void) int main(void)
{ {

View File

@@ -181,8 +181,8 @@ const char *mr_strerror(int err)
*/ */
void mr_ringbuf_init(struct mr_ringbuf *ringbuf, void *pool, size_t size) void mr_ringbuf_init(struct mr_ringbuf *ringbuf, void *pool, size_t size)
{ {
mr_assert(ringbuf != MR_NULL); MR_ASSERT(ringbuf != MR_NULL);
mr_assert((pool != MR_NULL) || (size == 0)); MR_ASSERT((pool != MR_NULL) || (size == 0));
ringbuf->read_index = 0; ringbuf->read_index = 0;
ringbuf->write_index = 0; ringbuf->write_index = 0;
@@ -203,7 +203,7 @@ void mr_ringbuf_init(struct mr_ringbuf *ringbuf, void *pool, size_t size)
*/ */
int mr_ringbuf_allocate(struct mr_ringbuf *ringbuf, size_t size) int mr_ringbuf_allocate(struct mr_ringbuf *ringbuf, size_t size)
{ {
mr_assert(ringbuf != MR_NULL); MR_ASSERT(ringbuf != MR_NULL);
/* Check the buffer size */ /* Check the buffer size */
if (mr_ringbuf_get_bufsz(ringbuf) == size) if (mr_ringbuf_get_bufsz(ringbuf) == size)
@@ -236,7 +236,7 @@ int mr_ringbuf_allocate(struct mr_ringbuf *ringbuf, size_t size)
*/ */
void mr_ringbuf_free(struct mr_ringbuf *ringbuf) void mr_ringbuf_free(struct mr_ringbuf *ringbuf)
{ {
mr_assert(ringbuf != MR_NULL); MR_ASSERT(ringbuf != MR_NULL);
mr_free(ringbuf->buffer); mr_free(ringbuf->buffer);
mr_ringbuf_init(ringbuf, MR_NULL, 0); mr_ringbuf_init(ringbuf, MR_NULL, 0);
@@ -249,7 +249,7 @@ void mr_ringbuf_free(struct mr_ringbuf *ringbuf)
*/ */
void mr_ringbuf_reset(struct mr_ringbuf *ringbuf) void mr_ringbuf_reset(struct mr_ringbuf *ringbuf)
{ {
mr_assert(ringbuf != MR_NULL); MR_ASSERT(ringbuf != MR_NULL);
ringbuf->read_index = 0; ringbuf->read_index = 0;
ringbuf->write_index = 0; ringbuf->write_index = 0;
@@ -266,7 +266,7 @@ void mr_ringbuf_reset(struct mr_ringbuf *ringbuf)
*/ */
size_t mr_ringbuf_get_data_size(struct mr_ringbuf *ringbuf) size_t mr_ringbuf_get_data_size(struct mr_ringbuf *ringbuf)
{ {
mr_assert(ringbuf != MR_NULL); MR_ASSERT(ringbuf != MR_NULL);
/* Empty or full according to the mirror flag */ /* Empty or full according to the mirror flag */
if (ringbuf->read_index == ringbuf->write_index) if (ringbuf->read_index == ringbuf->write_index)
@@ -298,7 +298,7 @@ size_t mr_ringbuf_get_data_size(struct mr_ringbuf *ringbuf)
*/ */
size_t mr_ringbuf_get_space_size(struct mr_ringbuf *ringbuf) size_t mr_ringbuf_get_space_size(struct mr_ringbuf *ringbuf)
{ {
mr_assert(ringbuf != MR_NULL); MR_ASSERT(ringbuf != MR_NULL);
return ringbuf->size - mr_ringbuf_get_data_size(ringbuf); return ringbuf->size - mr_ringbuf_get_data_size(ringbuf);
} }
@@ -312,7 +312,7 @@ size_t mr_ringbuf_get_space_size(struct mr_ringbuf *ringbuf)
*/ */
size_t mr_ringbuf_get_bufsz(struct mr_ringbuf *ringbuf) size_t mr_ringbuf_get_bufsz(struct mr_ringbuf *ringbuf)
{ {
mr_assert(ringbuf != MR_NULL); MR_ASSERT(ringbuf != MR_NULL);
return ringbuf->size; return ringbuf->size;
} }
@@ -327,8 +327,8 @@ size_t mr_ringbuf_get_bufsz(struct mr_ringbuf *ringbuf)
*/ */
size_t mr_ringbuf_pop(struct mr_ringbuf *ringbuf, uint8_t *data) size_t mr_ringbuf_pop(struct mr_ringbuf *ringbuf, uint8_t *data)
{ {
mr_assert(ringbuf != MR_NULL); MR_ASSERT(ringbuf != MR_NULL);
mr_assert(data != MR_NULL); MR_ASSERT(data != MR_NULL);
/* Get the buf size */ /* Get the buf size */
if (mr_ringbuf_get_data_size(ringbuf) == 0) if (mr_ringbuf_get_data_size(ringbuf) == 0)
@@ -362,8 +362,8 @@ size_t mr_ringbuf_read(struct mr_ringbuf *ringbuf, void *buffer, size_t size)
{ {
uint8_t *read_buffer = (uint8_t *)buffer; uint8_t *read_buffer = (uint8_t *)buffer;
mr_assert(ringbuf != MR_NULL); MR_ASSERT(ringbuf != MR_NULL);
mr_assert((buffer != MR_NULL) || (size == 0)); MR_ASSERT((buffer != MR_NULL) || (size == 0));
/* Get the buf size */ /* Get the buf size */
size_t data_size = mr_ringbuf_get_data_size(ringbuf); size_t data_size = mr_ringbuf_get_data_size(ringbuf);
@@ -407,7 +407,7 @@ size_t mr_ringbuf_read(struct mr_ringbuf *ringbuf, void *buffer, size_t size)
*/ */
size_t mr_ringbuf_push(struct mr_ringbuf *ringbuf, uint8_t data) size_t mr_ringbuf_push(struct mr_ringbuf *ringbuf, uint8_t data)
{ {
mr_assert(ringbuf != MR_NULL); MR_ASSERT(ringbuf != MR_NULL);
/* Get the space size */ /* Get the space size */
if (mr_ringbuf_get_space_size(ringbuf) == 0) if (mr_ringbuf_get_space_size(ringbuf) == 0)
@@ -440,7 +440,7 @@ size_t mr_ringbuf_push_force(struct mr_ringbuf *ringbuf, uint8_t data)
{ {
int state = 0; int state = 0;
mr_assert(ringbuf != MR_NULL); MR_ASSERT(ringbuf != MR_NULL);
/* Get the buffer size */ /* Get the buffer size */
if (mr_ringbuf_get_bufsz(ringbuf) == 0) if (mr_ringbuf_get_bufsz(ringbuf) == 0)
@@ -489,8 +489,8 @@ size_t mr_ringbuf_write(struct mr_ringbuf *ringbuf, const void *buffer, size_t s
{ {
uint8_t *write_buffer = (uint8_t *)buffer; uint8_t *write_buffer = (uint8_t *)buffer;
mr_assert(ringbuf != MR_NULL); MR_ASSERT(ringbuf != MR_NULL);
mr_assert((buffer != MR_NULL) || (size == 0)); MR_ASSERT((buffer != MR_NULL) || (size == 0));
/* Get the space size */ /* Get the space size */
size_t space_size = mr_ringbuf_get_space_size(ringbuf); size_t space_size = mr_ringbuf_get_space_size(ringbuf);
@@ -537,8 +537,8 @@ size_t mr_ringbuf_write_force(struct mr_ringbuf *ringbuf, const void *buffer, si
{ {
uint8_t *write_buffer = (uint8_t *)buffer; uint8_t *write_buffer = (uint8_t *)buffer;
mr_assert(ringbuf != MR_NULL); MR_ASSERT(ringbuf != MR_NULL);
mr_assert((buffer != MR_NULL) || (size == 0)); MR_ASSERT((buffer != MR_NULL) || (size == 0));
if ((mr_ringbuf_get_bufsz(ringbuf) == 0) || (size == 0)) if ((mr_ringbuf_get_bufsz(ringbuf) == 0) || (size == 0))
{ {
@@ -613,8 +613,8 @@ static void mr_avl_left_rotate(struct mr_avl **node)
(*node)->right_child = right_child->left_child; (*node)->right_child = right_child->left_child;
right_child->left_child = (*node); right_child->left_child = (*node);
(*node)->height = mr_max(mr_avl_get_height((*node)->left_child), mr_avl_get_height((*node)->right_child)) + 1; (*node)->height = MR_MAX(mr_avl_get_height((*node)->left_child), mr_avl_get_height((*node)->right_child)) + 1;
right_child->height = mr_max(mr_avl_get_height(right_child->left_child), right_child->height = MR_MAX(mr_avl_get_height(right_child->left_child),
mr_avl_get_height(right_child->right_child)) + 1; mr_avl_get_height(right_child->right_child)) + 1;
(*node) = right_child; (*node) = right_child;
@@ -627,8 +627,8 @@ static void mr_avl_right_rotate(struct mr_avl **node)
(*node)->left_child = left_child->right_child; (*node)->left_child = left_child->right_child;
left_child->right_child = (*node); left_child->right_child = (*node);
(*node)->height = mr_max(mr_avl_get_height((*node)->left_child), mr_avl_get_height((*node)->right_child)) + 1; (*node)->height = MR_MAX(mr_avl_get_height((*node)->left_child), mr_avl_get_height((*node)->right_child)) + 1;
left_child->height = mr_max(mr_avl_get_height(left_child->left_child), left_child->height = MR_MAX(mr_avl_get_height(left_child->left_child),
mr_avl_get_height(left_child->right_child)) + 1; mr_avl_get_height(left_child->right_child)) + 1;
(*node) = left_child; (*node) = left_child;
@@ -642,7 +642,7 @@ static void mr_avl_right_rotate(struct mr_avl **node)
*/ */
void mr_avl_init(struct mr_avl *node, uint32_t value) void mr_avl_init(struct mr_avl *node, uint32_t value)
{ {
mr_assert(node != MR_NULL); MR_ASSERT(node != MR_NULL);
node->height = 0; node->height = 0;
node->value = value; node->value = value;
@@ -658,8 +658,8 @@ void mr_avl_init(struct mr_avl *node, uint32_t value)
*/ */
void mr_avl_insert(struct mr_avl **tree, struct mr_avl *node) void mr_avl_insert(struct mr_avl **tree, struct mr_avl *node)
{ {
mr_assert(tree != MR_NULL); MR_ASSERT(tree != MR_NULL);
mr_assert(node != MR_NULL); MR_ASSERT(node != MR_NULL);
if ((*tree) == MR_NULL) if ((*tree) == MR_NULL)
{ {
@@ -677,7 +677,7 @@ void mr_avl_insert(struct mr_avl **tree, struct mr_avl *node)
return; return;
} }
(*tree)->height = mr_max(mr_avl_get_height((*tree)->left_child), mr_avl_get_height((*tree)->right_child)) + 1; (*tree)->height = MR_MAX(mr_avl_get_height((*tree)->left_child), mr_avl_get_height((*tree)->right_child)) + 1;
int balance = mr_avl_get_balance((*tree)); int balance = mr_avl_get_balance((*tree));
if (balance > 1 && node->value < (*tree)->left_child->value) if (balance > 1 && node->value < (*tree)->left_child->value)
@@ -715,8 +715,8 @@ void mr_avl_insert(struct mr_avl **tree, struct mr_avl *node)
*/ */
void mr_avl_remove(struct mr_avl **tree, struct mr_avl *node) void mr_avl_remove(struct mr_avl **tree, struct mr_avl *node)
{ {
mr_assert(tree != MR_NULL); MR_ASSERT(tree != MR_NULL);
mr_assert(node != MR_NULL); MR_ASSERT(node != MR_NULL);
if (*tree == MR_NULL) if (*tree == MR_NULL)
{ {
@@ -751,7 +751,7 @@ void mr_avl_remove(struct mr_avl **tree, struct mr_avl *node)
return; return;
} }
(*tree)->height = mr_max(mr_avl_get_height((*tree)->left_child), mr_avl_get_height((*tree)->right_child)) + 1; (*tree)->height = MR_MAX(mr_avl_get_height((*tree)->left_child), mr_avl_get_height((*tree)->right_child)) + 1;
int balance = mr_avl_get_balance(*tree); int balance = mr_avl_get_balance(*tree);