diff --git a/dev/adc.c b/dev/adc.c index 9f07bc3..8d64566 100644 --- a/dev/adc.c +++ b/dev/adc.c @@ -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) { diff --git a/dev/dac.c b/dev/dac.c index 632e913..7b8e2b5 100644 --- a/dev/dac.c +++ b/dev/dac.c @@ -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) { diff --git a/dev/gpio.c b/dev/gpio.c index e9c24c4..f776cdb 100644 --- a/dev/gpio.c +++ b/dev/gpio.c @@ -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) { diff --git a/dev/spi.c b/dev/spi.c index b767ce5..23e2dfc 100644 --- a/dev/spi.c +++ b/dev/spi.c @@ -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) { diff --git a/dev/spi.h b/dev/spi.h index c57b63c..3642722 100644 --- a/dev/spi.h +++ b/dev/spi.h @@ -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. diff --git a/dev/uart.c b/dev/uart.c index 0bc4ba1..e460550 100644 --- a/dev/uart.c +++ b/dev/uart.c @@ -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) { diff --git a/inc/mr_def.h b/inc/mr_def.h index e8b1da3..fd8a73d 100644 --- a/inc/mr_def.h +++ b/inc/mr_def.h @@ -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. diff --git a/src/dev.c b/src/dev.c index 141cfb9..a728146 100644 --- a/src/dev.c +++ b/src/dev.c @@ -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) {