1.优化代码。

This commit is contained in:
MacRsh
2023-11-13 01:25:01 +08:00
parent 9b809efb7a
commit cdaab96ebf
5 changed files with 44 additions and 3 deletions

View File

@@ -39,6 +39,14 @@ extern "C" {
#define MR_USING_UART8
#define MR_CFG_UART8_GROUP 1
#define MR_USING_SPI1
#define MR_USING_SPI2
#define MR_USING_SPI3
#define MR_CFG_SPI1_GROUP 1
#define MR_CFG_SPI2_GROUP 1
#define MR_CFG_SPI3_GROUP 1
#ifdef __cplusplus
}
#endif /* __cplusplus */

View File

@@ -50,6 +50,7 @@ void mr_auto_init(void);
*/
int mr_printf_output(const char *buf, size_t size);
int mr_printf(const char *fmt, ...);
const char *mr_strerror(int err);
/** @} */
/**

View File

@@ -113,10 +113,10 @@ typedef int (*mr_init_fn_t)(void);
#define MR_NULL ((void *)0)
/**
* @brief Enable/Disable.
* @brief Disable/enable.
*/
#define MR_ENABLE (1) /**< Enable */
#define MR_DISABLE (0) /**< Disable */
#define MR_ENABLE (1) /**< Enable */
/**
* @brief Double linked list structure.

View File

@@ -166,7 +166,7 @@ MR_INLINE int dev_register(struct mr_dev *dev, const char *name)
{
if (dev_find_or_register(name, dev, MR_REGISTER) != MR_NULL)
{
mr_log("%s dev register", name);
mr_log("%s register", name);
return MR_EOK;
}
return MR_EINVAL;

View File

@@ -147,6 +147,38 @@ int mr_printf(const char *fmt, ...)
return ret;
}
/**
* @brief This function get the error message.
*
* @param err The error code.
*
* @return The error message.
*/
const char *mr_strerror(int err)
{
switch (err)
{
case MR_EOK:
return "no error";
case MR_ENOMEM:
return "no enough memory";
case MR_EIO:
return "I/O error";
case MR_ENOTFOUND:
return "not found";
case MR_EBUSY:
return "resource busy";
case MR_EEXIST:
return "exists";
case MR_ENOTSUP:
return "operation not supported";
case MR_EINVAL:
return "invalid argument";
default:
return "unknown error";
}
}
/**
* @brief This function initialize the ringbuffer.
*