1.优化IOCTL指令为CTRL。

This commit is contained in:
MacRsh
2023-11-15 12:34:52 +08:00
parent 8e9b9fed42
commit dab63b8d02
8 changed files with 43 additions and 43 deletions

View File

@@ -66,7 +66,7 @@ static int mr_adc_ioctl(struct mr_dev *dev, int off, int cmd, void *args)
switch (cmd)
{
case MR_IOCTL_SET_CONFIG:
case MR_CTRL_SET_CONFIG:
{
if (args != MR_NULL)
{
@@ -99,7 +99,7 @@ static int mr_adc_ioctl(struct mr_dev *dev, int off, int cmd, void *args)
return MR_EINVAL;
}
case MR_IOCTL_GET_CONFIG:
case MR_CTRL_GET_CONFIG:
{
if (args != MR_NULL)
{

View File

@@ -66,7 +66,7 @@ static int mr_dac_ioctl(struct mr_dev *dev, int off, int cmd, void *args)
switch (cmd)
{
case MR_IOCTL_SET_CONFIG:
case MR_CTRL_SET_CONFIG:
{
if (args != MR_NULL)
{
@@ -93,7 +93,7 @@ static int mr_dac_ioctl(struct mr_dev *dev, int off, int cmd, void *args)
return MR_EINVAL;
}
case MR_IOCTL_GET_CONFIG:
case MR_CTRL_GET_CONFIG:
{
if (args != MR_NULL)
{

View File

@@ -59,7 +59,7 @@ static int mr_gpio_ioctl(struct mr_dev *dev, int off, int cmd, void *args)
switch (cmd)
{
case MR_IOCTL_SET_CONFIG:
case MR_CTRL_SET_CONFIG:
{
if (args != MR_NULL)
{

View File

@@ -223,7 +223,7 @@ static int mr_spi_bus_ioctl(struct mr_dev *dev, int off, int cmd, void *args)
switch (cmd)
{
case MR_IOCTL_SET_CONFIG:
case MR_CTRL_SET_CONFIG:
{
if (args != MR_NULL)
{
@@ -251,7 +251,7 @@ static int mr_spi_bus_ioctl(struct mr_dev *dev, int off, int cmd, void *args)
return MR_EINVAL;
}
case MR_IOCTL_GET_CONFIG:
case MR_CTRL_GET_CONFIG:
{
if (args != MR_NULL)
{
@@ -263,7 +263,7 @@ static int mr_spi_bus_ioctl(struct mr_dev *dev, int off, int cmd, void *args)
return MR_EINVAL;
}
case MR_IOCTL_SPI_TRANSFER:
case MR_CTRL_SPI_TRANSFER:
{
if (args != MR_NULL)
{
@@ -371,7 +371,7 @@ static void spi_dev_cs_configure(struct mr_spi_dev *spi_dev, int state)
{
struct mr_gpio_config config = {0};
mr_dev_ioctl(desc, MR_IOCTL_SET_OFFSET, mr_make_local(int, spi_dev->cs_pin));
mr_dev_ioctl(desc, MR_CTRL_SET_OFFSET, mr_make_local(int, spi_dev->cs_pin));
if (state == MR_ENABLE)
{
@@ -388,12 +388,12 @@ static void spi_dev_cs_configure(struct mr_spi_dev *spi_dev, int state)
config.mode = MR_GPIO_MODE_INPUT_DOWN;
}
}
mr_dev_ioctl(desc, MR_IOCTL_SET_CONFIG, &config);
mr_dev_ioctl(desc, MR_CTRL_SET_CONFIG, &config);
mr_dev_write(desc, mr_make_local(uint8_t, spi_dev->cs_active), sizeof(uint8_t));
} else
{
config.mode = MR_GPIO_MODE_NONE;
mr_dev_ioctl(desc, MR_IOCTL_SET_CONFIG, &config);
mr_dev_ioctl(desc, MR_CTRL_SET_CONFIG, &config);
}
}
}
@@ -551,7 +551,7 @@ static int mr_spi_dev_ioctl(struct mr_dev *dev, int off, int cmd, void *args)
switch (cmd)
{
case MR_IOCTL_SET_CONFIG:
case MR_CTRL_SET_CONFIG:
{
if (args != MR_NULL)
{
@@ -585,7 +585,7 @@ static int mr_spi_dev_ioctl(struct mr_dev *dev, int off, int cmd, void *args)
}
return MR_EINVAL;
}
case MR_IOCTL_SET_RD_BUFSZ:
case MR_CTRL_SET_RD_BUFSZ:
{
if (args != MR_NULL)
{
@@ -602,7 +602,7 @@ static int mr_spi_dev_ioctl(struct mr_dev *dev, int off, int cmd, void *args)
return MR_EINVAL;
}
case MR_IOCTL_GET_CONFIG:
case MR_CTRL_GET_CONFIG:
{
if (args != MR_NULL)
{
@@ -613,7 +613,7 @@ static int mr_spi_dev_ioctl(struct mr_dev *dev, int off, int cmd, void *args)
}
return MR_EINVAL;
}
case MR_IOCTL_GET_RD_BUFSZ:
case MR_CTRL_GET_RD_BUFSZ:
{
if (args != MR_NULL)
{
@@ -623,7 +623,7 @@ static int mr_spi_dev_ioctl(struct mr_dev *dev, int off, int cmd, void *args)
return MR_EINVAL;
}
case MR_IOCTL_SPI_TRANSFER:
case MR_CTRL_SPI_TRANSFER:
{
if (args != MR_NULL)
{

View File

@@ -81,7 +81,7 @@ struct mr_spi_config
/**
* @brief SPI control command.
*/
#define MR_IOCTL_SPI_TRANSFER ((0x1|0x80) << 16) /**< Transfer */
#define MR_CTRL_SPI_TRANSFER ((0x1|0x80) << 16) /**< Transfer */
/**
* @brief SPI transfer structure.

View File

@@ -88,7 +88,7 @@ static int mr_uart_ioctl(struct mr_dev *dev, int off, int cmd, void *args)
switch (cmd)
{
case MR_IOCTL_SET_CONFIG:
case MR_CTRL_SET_CONFIG:
{
if (args != MR_NULL)
{
@@ -103,7 +103,7 @@ static int mr_uart_ioctl(struct mr_dev *dev, int off, int cmd, void *args)
}
return MR_EINVAL;
}
case MR_IOCTL_SET_RD_BUFSZ:
case MR_CTRL_SET_RD_BUFSZ:
{
if (args != MR_NULL)
{
@@ -119,7 +119,7 @@ static int mr_uart_ioctl(struct mr_dev *dev, int off, int cmd, void *args)
}
return MR_EINVAL;
}
case MR_IOCTL_SET_WR_BUFSZ:
case MR_CTRL_SET_WR_BUFSZ:
{
if (args != MR_NULL)
{
@@ -136,7 +136,7 @@ static int mr_uart_ioctl(struct mr_dev *dev, int off, int cmd, void *args)
return MR_EINVAL;
}
case MR_IOCTL_GET_CONFIG:
case MR_CTRL_GET_CONFIG:
{
if (args != MR_NULL)
{
@@ -147,7 +147,7 @@ static int mr_uart_ioctl(struct mr_dev *dev, int off, int cmd, void *args)
}
return MR_EINVAL;
}
case MR_IOCTL_GET_RD_BUFSZ:
case MR_CTRL_GET_RD_BUFSZ:
{
if (args != MR_NULL)
{
@@ -156,7 +156,7 @@ static int mr_uart_ioctl(struct mr_dev *dev, int off, int cmd, void *args)
}
return MR_EINVAL;
}
case MR_IOCTL_GET_WR_BUFSZ:
case MR_CTRL_GET_WR_BUFSZ:
{
if (args != MR_NULL)
{

View File

@@ -192,28 +192,28 @@ struct mr_dev;
/**
* @brief Descriptor control command.
*/
#define MR_IOCTL_SET_OFFSET ((0x1|0x8) << 28) /**< Set offset */
#define MR_IOCTL_GET_OFFSET ((0x2|0x0) << 28) /**< Get offset */
#define MR_CTRL_SET_OFFSET ((0x1|0x8) << 28) /**< Set offset */
#define MR_CTRL_GET_OFFSET ((0x2|0x0) << 28) /**< Get offset */
/**
* @brief Device control general command.
*/
#define MR_IOCTL_SET_RD_CB ((0x1|0x8) << 24) /**< Set read callback */
#define MR_IOCTL_SET_WR_CB ((0x2|0x8) << 24) /**< Set write callback */
#define MR_IOCTL_SET_SLEEP ((0x3|0x8) << 24) /**< Set sleep */
#define MR_IOCTL_SET_WAKEUP ((0x4|0x8) << 24) /**< Set wakeup */
#define MR_IOCTL_GET_RD_CB ((0x1|0x0) << 24) /**< Get read callback */
#define MR_IOCTL_GET_WR_CB ((0x2|0x0) << 24) /**< Get write callback */
#define MR_CTRL_SET_RD_CB ((0x1|0x8) << 24) /**< Set read callback */
#define MR_CTRL_SET_WR_CB ((0x2|0x8) << 24) /**< Set write callback */
#define MR_CTRL_SET_SLEEP ((0x3|0x8) << 24) /**< Set sleep */
#define MR_CTRL_SET_WAKEUP ((0x4|0x8) << 24) /**< Set wakeup */
#define MR_CTRL_GET_RD_CB ((0x1|0x0) << 24) /**< Get read callback */
#define MR_CTRL_GET_WR_CB ((0x2|0x0) << 24) /**< Get write callback */
/**
* @brief Device control command.
*/
#define MR_IOCTL_SET_CONFIG ((0x1|0x8) << 20) /**< Set configuration */
#define MR_IOCTL_SET_RD_BUFSZ ((0x2|0x8) << 20) /**< Set read buffer size */
#define MR_IOCTL_SET_WR_BUFSZ ((0x3|0x8) << 20) /**< Set write buffer size */
#define MR_IOCTL_GET_CONFIG ((0x1|0x0) << 20) /**< Get configuration */
#define MR_IOCTL_GET_RD_BUFSZ ((0x2|0x0) << 20) /**< Get read buffer size */
#define MR_IOCTL_GET_WR_BUFSZ ((0x3|0x0) << 20) /**< Get write buffer size */
#define MR_CTRL_SET_CONFIG ((0x1|0x8) << 20) /**< Set configuration */
#define MR_CTRL_SET_RD_BUFSZ ((0x2|0x8) << 20) /**< Set read buffer size */
#define MR_CTRL_SET_WR_BUFSZ ((0x3|0x8) << 20) /**< Set write buffer size */
#define MR_CTRL_GET_CONFIG ((0x1|0x0) << 20) /**< Get configuration */
#define MR_CTRL_GET_RD_BUFSZ ((0x2|0x0) << 20) /**< Get read buffer size */
#define MR_CTRL_GET_WR_BUFSZ ((0x3|0x0) << 20) /**< Get write buffer size */
/**
* @brief ISR event.

View File

@@ -293,20 +293,20 @@ static int dev_ioctl(struct mr_dev *dev, int desc, int off, int cmd, void *args)
switch (cmd)
{
case MR_IOCTL_SET_RD_CB:
case MR_CTRL_SET_RD_CB:
{
dev->rd_cb.desc = desc;
dev->rd_cb.cb = (int (*)(int desc, void *args))args;
return MR_EOK;
}
case MR_IOCTL_SET_WR_CB:
case MR_CTRL_SET_WR_CB:
{
dev->wr_cb.desc = desc;
dev->wr_cb.cb = (int (*)(int desc, void *args))args;
return MR_EOK;
}
case MR_IOCTL_GET_RD_CB:
case MR_CTRL_GET_RD_CB:
{
if (args != MR_NULL)
{
@@ -315,7 +315,7 @@ static int dev_ioctl(struct mr_dev *dev, int desc, int off, int cmd, void *args)
}
return MR_EINVAL;
}
case MR_IOCTL_GET_WR_CB:
case MR_CTRL_GET_WR_CB:
{
if (args != MR_NULL)
{
@@ -639,7 +639,7 @@ int mr_dev_ioctl(int desc, int cmd, void *args)
switch (cmd)
{
case MR_IOCTL_SET_OFFSET:
case MR_CTRL_SET_OFFSET:
{
if (args != MR_NULL)
{
@@ -649,7 +649,7 @@ int mr_dev_ioctl(int desc, int cmd, void *args)
return MR_EINVAL;
}
case MR_IOCTL_GET_OFFSET:
case MR_CTRL_GET_OFFSET:
{
if (args != MR_NULL)
{