1.优化错误码,默认为负。

This commit is contained in:
MacRsh
2023-10-14 11:14:15 +08:00
parent 0ec7c93300
commit 7397961529
19 changed files with 100 additions and 100 deletions

View File

@@ -41,7 +41,7 @@ static mr_err_t drv_dac_configure(mr_dac_t dac, mr_state_t state)
break;
default:
return -MR_ERR_INVALID;
return MR_ERR_INVALID;
}
DAC_InitStructure.DAC_Trigger = DAC_Trigger_None;
@@ -71,7 +71,7 @@ static mr_err_t drv_dac_channel_configure(mr_dac_t dac, mr_dac_config_t config)
break;
default:
return -MR_ERR_INVALID;
return MR_ERR_INVALID;
}
if (config->channel._mask != 0)

View File

@@ -65,7 +65,7 @@ static mr_err_t drv_pin_configure(mr_pin_t pin, mr_pin_config_t config)
if (config->number < 0)
{
return -MR_ERR_INVALID;
return MR_ERR_INVALID;
}
RCC_APB2PeriphClockCmd(PIN_RCC(config->number), ENABLE);
@@ -134,7 +134,7 @@ static mr_err_t drv_pin_configure(mr_pin_t pin, mr_pin_config_t config)
{
if ((irq_mask[exti_line] != -1 && irq_mask[exti_line] != config->number))
{
return -MR_ERR_BUSY;
return MR_ERR_BUSY;
}
irq_mask[exti_line] = config->number;

View File

@@ -141,7 +141,7 @@ static mr_err_t drv_spi_configure(mr_spi_bus_t spi_bus, mr_spi_config_t config)
}
default:
return -MR_ERR_INVALID;
return MR_ERR_INVALID;
}
switch (config->mode)
@@ -175,7 +175,7 @@ static mr_err_t drv_spi_configure(mr_spi_bus_t spi_bus, mr_spi_config_t config)
}
default:
return -MR_ERR_INVALID;
return MR_ERR_INVALID;
}
switch (config->data_bits)
@@ -193,7 +193,7 @@ static mr_err_t drv_spi_configure(mr_spi_bus_t spi_bus, mr_spi_config_t config)
}
default:
return -MR_ERR_INVALID;
return MR_ERR_INVALID;
}
switch (config->bit_order)
@@ -211,7 +211,7 @@ static mr_err_t drv_spi_configure(mr_spi_bus_t spi_bus, mr_spi_config_t config)
}
default:
return -MR_ERR_INVALID;
return MR_ERR_INVALID;
}
switch (config->cs_active)
@@ -230,7 +230,7 @@ static mr_err_t drv_spi_configure(mr_spi_bus_t spi_bus, mr_spi_config_t config)
}
default:
return -MR_ERR_INVALID;
return MR_ERR_INVALID;
}
NVIC_InitStructure.NVIC_IRQChannel = spi_bus_data->irqno;

View File

@@ -147,7 +147,7 @@ static mr_err_t drv_timer_configure(mr_timer_t timer, mr_state_t state)
}
default:
return -MR_ERR_INVALID;
return MR_ERR_INVALID;
}
NVIC_InitStructure.NVIC_IRQChannel = timer_data->irqno;

View File

@@ -118,7 +118,7 @@ static mr_err_t drv_serial_configure(mr_serial_t serial, struct mr_serial_config
}
default:
return -MR_ERR_INVALID;
return MR_ERR_INVALID;
}
switch (config->stop_bits)
@@ -136,7 +136,7 @@ static mr_err_t drv_serial_configure(mr_serial_t serial, struct mr_serial_config
}
default:
return -MR_ERR_INVALID;
return MR_ERR_INVALID;
}
switch (config->parity)
@@ -160,7 +160,7 @@ static mr_err_t drv_serial_configure(mr_serial_t serial, struct mr_serial_config
}
default:
return -MR_ERR_INVALID;
return MR_ERR_INVALID;
}
switch (config->bit_order)
@@ -171,7 +171,7 @@ static mr_err_t drv_serial_configure(mr_serial_t serial, struct mr_serial_config
}
default:
return -MR_ERR_INVALID;
return MR_ERR_INVALID;
}
switch (config->invert)
@@ -182,7 +182,7 @@ static mr_err_t drv_serial_configure(mr_serial_t serial, struct mr_serial_config
}
default:
return -MR_ERR_INVALID;
return MR_ERR_INVALID;
}
GPIO_InitStructure.GPIO_Pin = uart_data->tx_gpio_pin;

View File

@@ -14,12 +14,12 @@
static mr_err_t err_io_adc_configure(mr_adc_t adc, mr_state_t state)
{
return -MR_ERR_IO;
return MR_ERR_IO;
}
static mr_err_t err_io_adc_channel_configure(mr_adc_t adc, mr_adc_config_t config)
{
return -MR_ERR_IO;
return MR_ERR_IO;
}
static mr_uint32_t err_io_adc_read(mr_adc_t adc, mr_off_t channel)
@@ -63,7 +63,7 @@ static mr_err_t mr_adc_ioctl(mr_device_t device, int cmd, void *args)
}
return ret;
}
return -MR_ERR_INVALID;
return MR_ERR_INVALID;
}
case MR_DEVICE_CTRL_GET_CONFIG:
@@ -74,11 +74,11 @@ static mr_err_t mr_adc_ioctl(mr_device_t device, int cmd, void *args)
*config = adc->config;
return MR_ERR_OK;
}
return -MR_ERR_INVALID;
return MR_ERR_INVALID;
}
default:
return -MR_ERR_UNSUPPORTED;
return MR_ERR_UNSUPPORTED;
}
}
@@ -90,7 +90,7 @@ static mr_ssize_t mr_adc_read(mr_device_t device, mr_off_t pos, void *buffer, mr
if (pos < 0)
{
return -MR_ERR_INVALID;
return MR_ERR_INVALID;
}
while ((read_size += sizeof(*read_buffer)) <= size)

View File

@@ -14,12 +14,12 @@
static mr_err_t err_io_dac_configure(mr_dac_t dac, mr_state_t state)
{
return -MR_ERR_IO;
return MR_ERR_IO;
}
static mr_err_t err_io_dac_channel_configure(mr_dac_t dac, struct mr_dac_config *config)
{
return -MR_ERR_IO;
return MR_ERR_IO;
}
static void err_io_dac_write(mr_dac_t dac, mr_off_t channel, mr_uint32_t value)
@@ -63,7 +63,7 @@ static mr_err_t mr_dac_ioctl(mr_device_t device, int cmd, void *args)
}
return ret;
}
return -MR_ERR_INVALID;
return MR_ERR_INVALID;
}
case MR_DEVICE_CTRL_GET_CONFIG:
@@ -74,11 +74,11 @@ static mr_err_t mr_dac_ioctl(mr_device_t device, int cmd, void *args)
*config = dac->config;
return MR_ERR_OK;
}
return -MR_ERR_INVALID;
return MR_ERR_INVALID;
}
default:
return -MR_ERR_UNSUPPORTED;
return MR_ERR_UNSUPPORTED;
}
}
@@ -90,7 +90,7 @@ static mr_ssize_t mr_dac_write(mr_device_t device, mr_off_t pos, const void *buf
if (pos < 0)
{
return -MR_ERR_INVALID;
return MR_ERR_INVALID;
}
while ((write_size += sizeof(*write_buffer)) <= size)

View File

@@ -17,7 +17,7 @@
static mr_err_t err_io_i2c_configure(mr_i2c_bus_t i2c_bus, mr_i2c_config_t config)
{
return -MR_ERR_IO;
return MR_ERR_IO;
}
static void err_io_i2c_start(mr_i2c_bus_t i2c_bus)
@@ -48,7 +48,7 @@ static mr_err_t mr_i2c_device_take_bus(mr_i2c_device_t i2c_device)
/* Check if the i2c-bus is valid */
if (i2c_bus == MR_NULL)
{
return -MR_ERR_UNSUPPORTED;
return MR_ERR_UNSUPPORTED;
}
/* Take the mutex lock of the i2c-bus */
@@ -102,7 +102,7 @@ static mr_err_t mr_i2c_device_connect_bus(mr_i2c_device_t i2c_device, const char
i2c_bus = mr_device_find(name);
if (i2c_bus == MR_NULL || i2c_bus->type != Mr_Device_Type_I2CBUS)
{
return -MR_ERR_NOT_FOUND;
return MR_ERR_NOT_FOUND;
}
}
@@ -209,7 +209,7 @@ static mr_err_t mr_i2c_device_ioctl(mr_device_t device, int cmd, void *args)
i2c_device->config = *config;
return MR_ERR_OK;
}
return -MR_ERR_INVALID;
return MR_ERR_INVALID;
}
case MR_DEVICE_CTRL_GET_CONFIG:
@@ -220,7 +220,7 @@ static mr_err_t mr_i2c_device_ioctl(mr_device_t device, int cmd, void *args)
*config = i2c_device->config;
return MR_ERR_OK;
}
return -MR_ERR_INVALID;
return MR_ERR_INVALID;
}
case MR_DEVICE_CTRL_CONNECT:
@@ -229,7 +229,7 @@ static mr_err_t mr_i2c_device_ioctl(mr_device_t device, int cmd, void *args)
}
default:
return -MR_ERR_UNSUPPORTED;
return MR_ERR_UNSUPPORTED;
}
}
@@ -456,7 +456,7 @@ mr_err_t mr_i2c_bus_add(mr_i2c_bus_t i2c_bus, const char *name, struct mr_i2c_bu
static mr_err_t err_io_soft_i2c_bus_configure(mr_soft_i2c_bus_t i2c_bus, mr_state_t state)
{
return -MR_ERR_IO;
return MR_ERR_IO;
}
static void err_io_soft_i2c_scl_write(mr_soft_i2c_bus_t i2c_bus, mr_level_t level)

View File

@@ -14,7 +14,7 @@
static mr_err_t err_io_pin_configure(mr_pin_t pin, struct mr_pin_config *config)
{
return -MR_ERR_IO;
return MR_ERR_IO;
}
static mr_level_t err_io_pin_read(mr_pin_t pin, mr_off_t number)
@@ -40,7 +40,7 @@ static mr_err_t mr_pin_ioctl(mr_device_t device, int cmd, void *args)
mr_pin_config_t config = (mr_pin_config_t)args;
return pin->ops->configure(pin, config);
}
return -MR_ERR_INVALID;
return MR_ERR_INVALID;
}
case MR_DEVICE_CTRL_SET_RX_CB:
@@ -50,7 +50,7 @@ static mr_err_t mr_pin_ioctl(mr_device_t device, int cmd, void *args)
}
default:
return -MR_ERR_UNSUPPORTED;
return MR_ERR_UNSUPPORTED;
}
}
@@ -62,7 +62,7 @@ static mr_ssize_t mr_pin_read(mr_device_t device, mr_off_t pos, void *buffer, mr
if (pos < 0)
{
return -MR_ERR_INVALID;
return MR_ERR_INVALID;
}
while ((read_size += sizeof(*read_buffer)) <= size)
@@ -82,7 +82,7 @@ static mr_ssize_t mr_pin_write(mr_device_t device, mr_off_t pos, const void *buf
if (pos < 0)
{
return -MR_ERR_INVALID;
return MR_ERR_INVALID;
}
while ((write_size += sizeof(*write_buffer)) <= size)

View File

@@ -14,7 +14,7 @@
static mr_err_t err_io_pwm_configure(mr_pwm_t pwm, mr_pwm_config_t config)
{
return -MR_ERR_IO;
return MR_ERR_IO;
}
static void err_io_pwm_write(mr_pwm_t pwm, mr_off_t channel, mr_uint32_t duty)
@@ -61,7 +61,7 @@ static mr_err_t mr_pwm_ioctl(mr_device_t device, int cmd, void *args)
}
return ret;
}
return -MR_ERR_INVALID;
return MR_ERR_INVALID;
}
case MR_DEVICE_CTRL_GET_CONFIG:
@@ -72,11 +72,11 @@ static mr_err_t mr_pwm_ioctl(mr_device_t device, int cmd, void *args)
*config = pwm->config;
return MR_ERR_OK;
}
return -MR_ERR_INVALID;
return MR_ERR_INVALID;
}
default:
return -MR_ERR_UNSUPPORTED;
return MR_ERR_UNSUPPORTED;
}
}
@@ -88,7 +88,7 @@ static mr_err_t mr_pwm_read(mr_device_t device, mr_off_t pos, void *buffer, mr_s
if (pos < 0)
{
return -MR_ERR_INVALID;
return MR_ERR_INVALID;
}
while ((read_size += sizeof(*read_buffer)) <= size)
@@ -108,7 +108,7 @@ static mr_err_t mr_pwm_write(mr_device_t device, mr_off_t pos, const void *buffe
if (pos < 0)
{
return -MR_ERR_INVALID;
return MR_ERR_INVALID;
}
while ((write_size += sizeof(*write_buffer)) <= size)

View File

@@ -14,7 +14,7 @@
static mr_err_t err_io_serial_configure(mr_serial_t serial, struct mr_serial_config *config)
{
return -MR_ERR_IO;
return MR_ERR_IO;
}
static void err_io_serial_write(mr_serial_t serial, mr_uint8_t data)
@@ -75,7 +75,7 @@ static mr_err_t mr_serial_ioctl(mr_device_t device, int cmd, void *args)
}
return ret;
}
return -MR_ERR_INVALID;
return MR_ERR_INVALID;
}
case MR_DEVICE_CTRL_GET_CONFIG:
@@ -86,7 +86,7 @@ static mr_err_t mr_serial_ioctl(mr_device_t device, int cmd, void *args)
*config = serial->config;
return MR_ERR_OK;
}
return -MR_ERR_INVALID;
return MR_ERR_INVALID;
}
case MR_DEVICE_CTRL_SET_RX_CB:
@@ -108,7 +108,7 @@ static mr_err_t mr_serial_ioctl(mr_device_t device, int cmd, void *args)
mr_size_t bufsz = *((mr_size_t *)args);
return mr_rb_allocate_buffer(&serial->rx_fifo, bufsz);
}
return -MR_ERR_INVALID;
return MR_ERR_INVALID;
}
case MR_DEVICE_CTRL_SET_TX_BUFSZ:
@@ -118,11 +118,11 @@ static mr_err_t mr_serial_ioctl(mr_device_t device, int cmd, void *args)
mr_size_t bufsz = *((mr_size_t *)args);
return mr_rb_allocate_buffer(&serial->tx_fifo, bufsz);
}
return -MR_ERR_INVALID;
return MR_ERR_INVALID;
}
default:
return -MR_ERR_UNSUPPORTED;
return MR_ERR_UNSUPPORTED;
}
}

View File

@@ -22,7 +22,7 @@
static mr_err_t err_io_spi_configure(mr_spi_bus_t spi_bus, struct mr_spi_config *config)
{
return -MR_ERR_IO;
return MR_ERR_IO;
}
static void err_io_spi_write(mr_spi_bus_t spi_bus, mr_uint32_t data)
@@ -53,7 +53,7 @@ mr_err_t mr_spi_device_take_bus(mr_spi_device_t spi_device)
/* Check if the spi-bus is valid */
if (spi_bus == MR_NULL)
{
return -MR_ERR_UNSUPPORTED;
return MR_ERR_UNSUPPORTED;
}
/* Take the mutex lock of the spi-bus */
@@ -109,7 +109,7 @@ static mr_err_t mr_spi_device_connect_bus(mr_spi_device_t spi_device, const char
spi_bus = mr_device_find(name);
if (spi_bus == MR_NULL || spi_bus->type != Mr_Device_Type_SPIBUS)
{
return -MR_ERR_NOT_FOUND;
return MR_ERR_NOT_FOUND;
}
}
@@ -229,7 +229,7 @@ static mr_ssize_t mr_spi_device_transfer(mr_spi_device_t spi_device,
}
default:
return -MR_ERR_INVALID;
return MR_ERR_INVALID;
}
} else if (rw == MR_SPI_RD)
{
@@ -272,7 +272,7 @@ static mr_ssize_t mr_spi_device_transfer(mr_spi_device_t spi_device,
}
default:
return -MR_ERR_INVALID;
return MR_ERR_INVALID;
}
} else
{
@@ -318,7 +318,7 @@ static mr_ssize_t mr_spi_device_transfer(mr_spi_device_t spi_device,
}
default:
return -MR_ERR_INVALID;
return MR_ERR_INVALID;
}
}
@@ -401,7 +401,7 @@ static mr_err_t mr_spi_device_ioctl(mr_device_t device, int cmd, void *args)
spi_device->config = *config;
return MR_ERR_OK;
}
return -MR_ERR_INVALID;
return MR_ERR_INVALID;
}
case MR_DEVICE_CTRL_GET_CONFIG:
@@ -412,7 +412,7 @@ static mr_err_t mr_spi_device_ioctl(mr_device_t device, int cmd, void *args)
*config = spi_device->config;
return MR_ERR_OK;
}
return -MR_ERR_INVALID;
return MR_ERR_INVALID;
}
case MR_DEVICE_CTRL_SET_RX_CB:
@@ -462,11 +462,11 @@ static mr_err_t mr_spi_device_ioctl(mr_device_t device, int cmd, void *args)
return (mr_err_t)tf_size;
}
return -MR_ERR_INVALID;
return MR_ERR_INVALID;
}
default:
return -MR_ERR_UNSUPPORTED;
return MR_ERR_UNSUPPORTED;
}
}

View File

@@ -14,7 +14,7 @@
static mr_err_t err_io_timer_configure(mr_timer_t timer, mr_state_t state)
{
return -MR_ERR_IO;
return MR_ERR_IO;
}
static void err_io_timer_start(mr_timer_t timer, mr_uint32_t prescaler, mr_uint32_t period)
@@ -41,7 +41,7 @@ static mr_err_t mr_timer_calculate(mr_timer_t timer, mr_uint32_t timeout, mr_uin
clk_mhz = timer->data->clk / 1000000u;
if (clk_mhz == 0)
{
return -MR_ERR_GENERIC;
return MR_ERR_GENERIC;
}
/* Calculate the prescaler */
@@ -141,7 +141,7 @@ static mr_err_t mr_timer_ioctl(mr_device_t device, int cmd, void *args)
timer->config = *config;
return ret;
}
return -MR_ERR_INVALID;
return MR_ERR_INVALID;
}
case MR_DEVICE_CTRL_GET_CONFIG:
@@ -152,7 +152,7 @@ static mr_err_t mr_timer_ioctl(mr_device_t device, int cmd, void *args)
*config = timer->config;
return MR_ERR_OK;
}
return -MR_ERR_INVALID;
return MR_ERR_INVALID;
}
case MR_DEVICE_CTRL_SET_RX_CB:
@@ -162,7 +162,7 @@ static mr_err_t mr_timer_ioctl(mr_device_t device, int cmd, void *args)
}
default:
return -MR_ERR_UNSUPPORTED;
return MR_ERR_UNSUPPORTED;
}
}

View File

@@ -130,14 +130,14 @@ typedef mr_int8_t mr_state_t; /* Type for
* @def Error code
*/
#define MR_ERR_OK 0 /* There is no error */
#define MR_ERR_GENERIC 1 /* Generic error happens */
#define MR_ERR_NO_MEMORY 2 /* No memory */
#define MR_ERR_IO 3 /* IO error */
#define MR_ERR_TIMEOUT 4 /* Timed out */
#define MR_ERR_BUSY 5 /* Busy */
#define MR_ERR_NOT_FOUND 6 /* Not found */
#define MR_ERR_UNSUPPORTED 7 /* Unsupported feature */
#define MR_ERR_INVALID 8 /* Invalid parameter */
#define MR_ERR_GENERIC (-1) /* Generic error happens */
#define MR_ERR_NO_MEMORY (-2) /* No memory */
#define MR_ERR_IO (-3) /* IO error */
#define MR_ERR_TIMEOUT (-4) /* Timed out */
#define MR_ERR_BUSY (-5) /* Busy */
#define MR_ERR_NOT_FOUND (-6) /* Not found */
#define MR_ERR_UNSUPPORTED (-7) /* Unsupported feature */
#define MR_ERR_INVALID (-8) /* Invalid parameter */
/**
* @addtogroup Auto init

View File

@@ -120,8 +120,8 @@ mr_err_t mr_icm20602_add(mr_icm20602_t icm20602, const char *name, mr_uint16_t c
/* Configure ICM20602 */
if (icm20602_self_check(icm20602) == MR_FALSE)
{
MR_DEBUG_D(DEBUG_TAG, "[%s] self check failed: [%d]\r\n", name, -MR_ERR_NOT_FOUND);
return -MR_ERR_NOT_FOUND;
MR_DEBUG_D(DEBUG_TAG, "[%s] self check failed: [%d]\r\n", name, MR_ERR_NOT_FOUND);
return MR_ERR_NOT_FOUND;
}
icm20602_write_reg(icm20602, ICM20602_PWR_MGMT_1, 0x80);
@@ -136,7 +136,7 @@ mr_err_t mr_icm20602_add(mr_icm20602_t icm20602, const char *name, mr_uint16_t c
if (count == 200)
{
MR_DEBUG_D(DEBUG_TAG, "%s failed to reset\r\n", name);
return -MR_ERR_NOT_FOUND;
return MR_ERR_NOT_FOUND;
}
icm20602_write_reg(icm20602, ICM20602_PWR_MGMT_1, 0x01);
@@ -184,7 +184,7 @@ mr_err_t mr_icm20602_config(mr_icm20602_t icm20602, mr_icm20602_config_t config)
break;
default:
return -MR_ERR_UNSUPPORTED;
return MR_ERR_UNSUPPORTED;
}
switch (config->gyro_range)
@@ -203,7 +203,7 @@ mr_err_t mr_icm20602_config(mr_icm20602_t icm20602, mr_icm20602_config_t config)
break;
default:
return -MR_ERR_UNSUPPORTED;
return MR_ERR_UNSUPPORTED;
}
icm20602->config = *config;

View File

@@ -16,12 +16,12 @@
static mr_ssize_t err_io_read(mr_device_t device, mr_off_t pos, void *buffer, mr_size_t size)
{
return -MR_ERR_IO;
return MR_ERR_IO;
}
static mr_ssize_t err_io_write(mr_device_t device, mr_off_t pos, const void *buffer, mr_size_t size)
{
return -MR_ERR_IO;
return MR_ERR_IO;
}
/**
@@ -134,8 +134,8 @@ mr_err_t mr_device_open(mr_device_t device, mr_uint8_t oflags)
/* Check whether the device supports opening in this mode */
if (oflags != (oflags & device->sflags))
{
MR_DEBUG_D(DEBUG_TAG, "[%s] open [%x] failed: [%d]\r\n", device->object.name, oflags, -MR_ERR_UNSUPPORTED);
return -MR_ERR_UNSUPPORTED;
MR_DEBUG_D(DEBUG_TAG, "[%s] open [%x] failed: [%d]\r\n", device->object.name, oflags, MR_ERR_UNSUPPORTED);
return MR_ERR_UNSUPPORTED;
}
/* Update the device open flag and reference count */
@@ -229,8 +229,8 @@ mr_err_t mr_device_ioctl(mr_device_t device, int cmd, void *args)
/* Check if the ioctl operation is supported */
if (device->ops->ioctl == MR_NULL)
{
MR_DEBUG_D(DEBUG_TAG, "[%s] ioctl [%x] failed: [%d]\r\n", device->object.name, cmd, -MR_ERR_UNSUPPORTED);
return -MR_ERR_UNSUPPORTED;
MR_DEBUG_D(DEBUG_TAG, "[%s] ioctl [%x] failed: [%d]\r\n", device->object.name, cmd, MR_ERR_UNSUPPORTED);
return MR_ERR_UNSUPPORTED;
}
/* Call the ioctl operation */
@@ -263,8 +263,8 @@ mr_ssize_t mr_device_read(mr_device_t device, mr_off_t pos, void *buffer, mr_siz
/* Check if the device is closed or unsupported */
if ((device->oflags & MR_DEVICE_OFLAG_RDONLY) == MR_FALSE)
{
MR_DEBUG_D(DEBUG_TAG, "[%s] read [%d] failed: [%d]\r\n", device->object.name, pos, -MR_ERR_UNSUPPORTED);
return -MR_ERR_UNSUPPORTED;
MR_DEBUG_D(DEBUG_TAG, "[%s] read [%d] failed: [%d]\r\n", device->object.name, pos, MR_ERR_UNSUPPORTED);
return MR_ERR_UNSUPPORTED;
}
/* Call the read operation */
@@ -298,8 +298,8 @@ mr_ssize_t mr_device_write(mr_device_t device, mr_off_t pos, const void *buffer,
/* Check if the device is closed or unsupported */
if ((device->oflags & MR_DEVICE_OFLAG_WRONLY) == MR_FALSE)
{
MR_DEBUG_D(DEBUG_TAG, "[%s] write [%d] failed: [%d]\r\n", device->object.name, pos, -MR_ERR_UNSUPPORTED);
return -MR_ERR_UNSUPPORTED;
MR_DEBUG_D(DEBUG_TAG, "[%s] write [%d] failed: [%d]\r\n", device->object.name, pos, MR_ERR_UNSUPPORTED);
return MR_ERR_UNSUPPORTED;
}
/* Call the write operation */

View File

@@ -107,13 +107,13 @@ mr_err_t mr_object_add(mr_object_t object, const char *name, mr_uint16_t type)
container = mr_object_container_find(type);
if (container == MR_NULL)
{
return -MR_ERR_UNSUPPORTED;
return MR_ERR_UNSUPPORTED;
}
/* Check if the object already exists in the container */
if (mr_object_find(name, type) != MR_NULL)
{
return -MR_ERR_BUSY;
return MR_ERR_BUSY;
}
/* Initialize the private fields */
@@ -148,7 +148,7 @@ mr_err_t mr_object_remove(mr_object_t object)
/* Check if the object already exists in the container */
if (mr_object_find(object->name, object->type) == MR_NULL)
{
return -MR_ERR_NOT_FOUND;
return MR_ERR_NOT_FOUND;
}
/* Disable interrupt */
@@ -187,13 +187,13 @@ mr_err_t mr_object_change_type(mr_object_t object, mr_uint16_t type)
container = mr_object_container_find(type);
if (container == MR_NULL)
{
return -MR_ERR_UNSUPPORTED;
return MR_ERR_UNSUPPORTED;
}
/* Check if the object already exists in the container */
if (mr_object_find(object->name, object->type) == MR_NULL)
{
return -MR_ERR_NOT_FOUND;
return MR_ERR_NOT_FOUND;
}
/* Change the object type */
@@ -256,7 +256,7 @@ mr_err_t mr_mutex_take(mr_mutex_t mutex, void *acquirer)
/* Check if the acquirer is valid */
if (acquirer == MR_NULL)
{
return -MR_ERR_INVALID;
return MR_ERR_INVALID;
}
/* Disable interrupt */
@@ -286,7 +286,7 @@ mr_err_t mr_mutex_take(mr_mutex_t mutex, void *acquirer)
/* Enable interrupt */
mr_interrupt_enable();
return -MR_ERR_BUSY;
return MR_ERR_BUSY;
}
/**
@@ -319,7 +319,7 @@ mr_err_t mr_mutex_release(mr_mutex_t mutex, void *owner)
return MR_ERR_OK;
}
return -MR_ERR_INVALID;
return MR_ERR_INVALID;
}
/**

View File

@@ -112,7 +112,7 @@ mr_err_t mr_console_init(void)
console_device = mr_device_find(MR_CFG_CONSOLE_NAME);
if (console_device == MR_NULL)
{
return -MR_ERR_NOT_FOUND;
return MR_ERR_NOT_FOUND;
}
return mr_device_open(console_device, MR_DEVICE_OFLAG_RDWR);
@@ -243,7 +243,7 @@ mr_err_t mr_rb_allocate_buffer(mr_rb_t rb, mr_size_t size)
pool = mr_malloc(size);
if (pool == MR_NULL && size != 0)
{
return -MR_ERR_NO_MEMORY;
return MR_ERR_NO_MEMORY;
}
mr_rb_init(rb, pool, size);