summaryrefslogtreecommitdiff
path: root/components
diff options
context:
space:
mode:
authorMeco Man <[email protected]>2022-04-29 10:56:42 -0400
committerguo <[email protected]>2022-06-22 14:48:00 +0800
commit1c95670befc96680a804b05838b5c2282ae10dea (patch)
tree11cd24769bd5fdacc13143e49336ba4eef292e22 /components
parentc13b03604f4b5ac7067b0bc433ccc70b46370106 (diff)
[rtdevices] eliminate recursion
Diffstat (limited to 'components')
-rw-r--r--components/drivers/include/drivers/hwtimer.h1
-rw-r--r--components/drivers/include/drivers/mtd_nand.h69
-rw-r--r--components/drivers/include/drivers/mtd_nor.h33
-rw-r--r--components/drivers/include/drivers/pulse_encoder.h1
-rw-r--r--components/drivers/include/drivers/rt_drv_pwm.h1
-rw-r--r--components/drivers/include/drivers/rt_inputcapture.h1
-rw-r--r--components/drivers/misc/pulse_encoder.c1
-rw-r--r--components/drivers/misc/rt_drv_pwm.c2
-rw-r--r--components/drivers/misc/rt_inputcapture.c2
-rw-r--r--components/drivers/mtd/mtd_nand.c65
-rw-r--r--components/drivers/mtd/mtd_nor.c25
11 files changed, 108 insertions, 93 deletions
diff --git a/components/drivers/include/drivers/hwtimer.h b/components/drivers/include/drivers/hwtimer.h
index e67551aa5d..312f3b6eb9 100644
--- a/components/drivers/include/drivers/hwtimer.h
+++ b/components/drivers/include/drivers/hwtimer.h
@@ -10,7 +10,6 @@
#define __HWTIMER_H__
#include <rtthread.h>
-#include <rtdevice.h>
#ifdef __cplusplus
extern "C" {
diff --git a/components/drivers/include/drivers/mtd_nand.h b/components/drivers/include/drivers/mtd_nand.h
index 991dde4901..94bd5e8be6 100644
--- a/components/drivers/include/drivers/mtd_nand.h
+++ b/components/drivers/include/drivers/mtd_nand.h
@@ -16,7 +16,7 @@
#ifndef __MTD_NAND_H__
#define __MTD_NAND_H__
-#include <rtdevice.h>
+#include <rtthread.h>
struct rt_mtd_nand_driver_ops;
#define RT_MTD_NAND_DEVICE(device) ((struct rt_mtd_nand_device*)(device))
@@ -73,68 +73,21 @@ struct rt_mtd_nand_driver_ops
};
rt_err_t rt_mtd_nand_register_device(const char *name, struct rt_mtd_nand_device *device);
-
-rt_inline rt_uint32_t rt_mtd_nand_read_id(struct rt_mtd_nand_device *device)
-{
- RT_ASSERT(device->ops->read_id);
- return device->ops->read_id(device);
-}
-
-rt_inline rt_err_t rt_mtd_nand_read(
+rt_uint32_t rt_mtd_nand_read_id(struct rt_mtd_nand_device *device);
+rt_err_t rt_mtd_nand_read(
struct rt_mtd_nand_device *device,
rt_off_t page,
rt_uint8_t *data, rt_uint32_t data_len,
- rt_uint8_t *spare, rt_uint32_t spare_len)
-{
- RT_ASSERT(device->ops->read_page);
- return device->ops->read_page(device, page, data, data_len, spare, spare_len);
-}
-
-rt_inline rt_err_t rt_mtd_nand_write(
+ rt_uint8_t *spare, rt_uint32_t spare_len);
+rt_err_t rt_mtd_nand_write(
struct rt_mtd_nand_device *device,
rt_off_t page,
const rt_uint8_t *data, rt_uint32_t data_len,
- const rt_uint8_t *spare, rt_uint32_t spare_len)
-{
- RT_ASSERT(device->ops->write_page);
- return device->ops->write_page(device, page, data, data_len, spare, spare_len);
-}
-
-rt_inline rt_err_t rt_mtd_nand_move_page(struct rt_mtd_nand_device *device,
- rt_off_t src_page, rt_off_t dst_page)
-{
- RT_ASSERT(device->ops->move_page);
- return device->ops->move_page(device, src_page, dst_page);
-}
-
-rt_inline rt_err_t rt_mtd_nand_erase_block(struct rt_mtd_nand_device *device, rt_uint32_t block)
-{
- RT_ASSERT(device->ops->erase_block);
- return device->ops->erase_block(device, block);
-}
-
-rt_inline rt_err_t rt_mtd_nand_check_block(struct rt_mtd_nand_device *device, rt_uint32_t block)
-{
- if (device->ops->check_block)
- {
- return device->ops->check_block(device, block);
- }
- else
- {
- return -RT_ENOSYS;
- }
-}
-
-rt_inline rt_err_t rt_mtd_nand_mark_badblock(struct rt_mtd_nand_device *device, rt_uint32_t block)
-{
- if (device->ops->mark_badblock)
- {
- return device->ops->mark_badblock(device, block);
- }
- else
- {
- return -RT_ENOSYS;
- }
-}
+ const rt_uint8_t *spare, rt_uint32_t spare_len);
+rt_err_t rt_mtd_nand_move_page(struct rt_mtd_nand_device *device,
+ rt_off_t src_page, rt_off_t dst_page);
+rt_err_t rt_mtd_nand_erase_block(struct rt_mtd_nand_device *device, rt_uint32_t block);
+rt_err_t rt_mtd_nand_check_block(struct rt_mtd_nand_device *device, rt_uint32_t block);
+rt_err_t rt_mtd_nand_mark_badblock(struct rt_mtd_nand_device *device, rt_uint32_t block);
#endif /* MTD_NAND_H_ */
diff --git a/components/drivers/include/drivers/mtd_nor.h b/components/drivers/include/drivers/mtd_nor.h
index 5573c54920..caaba83bbd 100644
--- a/components/drivers/include/drivers/mtd_nor.h
+++ b/components/drivers/include/drivers/mtd_nor.h
@@ -11,7 +11,7 @@
#ifndef __MTD_NOR_H__
#define __MTD_NOR_H__
-#include <rtdevice.h>
+#include <rtthread.h>
struct rt_mtd_nor_driver_ops;
#define RT_MTD_NOR_DEVICE(device) ((struct rt_mtd_nor_device*)(device))
@@ -39,29 +39,12 @@ struct rt_mtd_nor_driver_ops
};
rt_err_t rt_mtd_nor_register_device(const char* name, struct rt_mtd_nor_device* device);
-
-rt_inline rt_uint32_t rt_mtd_nor_read_id(struct rt_mtd_nor_device* device)
-{
- return device->ops->read_id(device);
-}
-
-rt_inline rt_size_t rt_mtd_nor_read(
- struct rt_mtd_nor_device* device,
- rt_off_t offset, rt_uint8_t* data, rt_uint32_t length)
-{
- return device->ops->read(device, offset, data, length);
-}
-
-rt_inline rt_size_t rt_mtd_nor_write(
- struct rt_mtd_nor_device* device,
- rt_off_t offset, const rt_uint8_t* data, rt_uint32_t length)
-{
- return device->ops->write(device, offset, data, length);
-}
-
-rt_inline rt_err_t rt_mtd_nor_erase_block(struct rt_mtd_nor_device* device, rt_off_t offset, rt_size_t length)
-{
- return device->ops->erase_block(device, offset, length);
-}
+rt_uint32_t rt_mtd_nor_read_id(struct rt_mtd_nor_device* device);
+rt_size_t rt_mtd_nor_read(struct rt_mtd_nor_device* device,
+ rt_off_t offset, rt_uint8_t* data, rt_uint32_t length);
+rt_size_t rt_mtd_nor_write(struct rt_mtd_nor_device* device,
+ rt_off_t offset, const rt_uint8_t* data, rt_uint32_t length);
+rt_err_t rt_mtd_nor_erase_block(struct rt_mtd_nor_device* device,
+ rt_off_t offset, rt_size_t length);
#endif
diff --git a/components/drivers/include/drivers/pulse_encoder.h b/components/drivers/include/drivers/pulse_encoder.h
index 38ef7652b9..85928b6e78 100644
--- a/components/drivers/include/drivers/pulse_encoder.h
+++ b/components/drivers/include/drivers/pulse_encoder.h
@@ -12,7 +12,6 @@
#define __PULSE_ENCODER_H__
#include <rtthread.h>
-#include <rtdevice.h>
#ifdef __cplusplus
extern "C" {
diff --git a/components/drivers/include/drivers/rt_drv_pwm.h b/components/drivers/include/drivers/rt_drv_pwm.h
index 567b368daa..2570887d71 100644
--- a/components/drivers/include/drivers/rt_drv_pwm.h
+++ b/components/drivers/include/drivers/rt_drv_pwm.h
@@ -12,7 +12,6 @@
#define __DRV_PWM_H_INCLUDE__
#include <rtthread.h>
-#include <rtdevice.h>
#define PWM_CMD_ENABLE (RT_DEVICE_CTRL_BASE(PWM) + 0)
#define PWM_CMD_DISABLE (RT_DEVICE_CTRL_BASE(PWM) + 1)
diff --git a/components/drivers/include/drivers/rt_inputcapture.h b/components/drivers/include/drivers/rt_inputcapture.h
index 813ed3157b..12a8b54274 100644
--- a/components/drivers/include/drivers/rt_inputcapture.h
+++ b/components/drivers/include/drivers/rt_inputcapture.h
@@ -12,7 +12,6 @@
#define __RT_INPUT_CAPTURE_H__
#include <rtthread.h>
-#include <rtdevice.h>
#ifdef __cplusplus
extern "C" {
diff --git a/components/drivers/misc/pulse_encoder.c b/components/drivers/misc/pulse_encoder.c
index 5afb12664a..d5efcef8e7 100644
--- a/components/drivers/misc/pulse_encoder.c
+++ b/components/drivers/misc/pulse_encoder.c
@@ -8,7 +8,6 @@
* 2019-08-08 balanceTWK the first version
*/
-#include <rtthread.h>
#include <rtdevice.h>
static rt_err_t rt_pulse_encoder_init(struct rt_device *dev)
diff --git a/components/drivers/misc/rt_drv_pwm.c b/components/drivers/misc/rt_drv_pwm.c
index 5a1924f0c4..64eb613a84 100644
--- a/components/drivers/misc/rt_drv_pwm.c
+++ b/components/drivers/misc/rt_drv_pwm.c
@@ -9,7 +9,7 @@
* 2022-05-14 Stanley Lwin add pwm function
*/
-#include <drivers/rt_drv_pwm.h>
+#include <rtdevice.h>
static rt_err_t _pwm_control(rt_device_t dev, int cmd, void *args)
{
diff --git a/components/drivers/misc/rt_inputcapture.c b/components/drivers/misc/rt_inputcapture.c
index 134bbcee96..7e25a0411d 100644
--- a/components/drivers/misc/rt_inputcapture.c
+++ b/components/drivers/misc/rt_inputcapture.c
@@ -8,9 +8,7 @@
* 2019-08-13 balanceTWK the first version
*/
-#include <rtthread.h>
#include <rtdevice.h>
-#include <rtdbg.h>
static rt_err_t rt_inputcapture_init(struct rt_device *dev)
{
diff --git a/components/drivers/mtd/mtd_nand.c b/components/drivers/mtd/mtd_nand.c
index 4a1e74b76b..fb62de39b5 100644
--- a/components/drivers/mtd/mtd_nand.c
+++ b/components/drivers/mtd/mtd_nand.c
@@ -12,7 +12,7 @@
* COPYRIGHT (C) 2012, Shanghai Real Thread
*/
-#include <drivers/mtd_nand.h>
+#include <rtdevice.h>
#ifdef RT_USING_MTD_NAND
@@ -95,6 +95,69 @@ rt_err_t rt_mtd_nand_register_device(const char *name,
return rt_device_register(dev, name, RT_DEVICE_FLAG_RDWR | RT_DEVICE_FLAG_STANDALONE);
}
+rt_uint32_t rt_mtd_nand_read_id(struct rt_mtd_nand_device *device)
+{
+ RT_ASSERT(device->ops->read_id);
+ return device->ops->read_id(device);
+}
+
+rt_err_t rt_mtd_nand_read(
+ struct rt_mtd_nand_device *device,
+ rt_off_t page,
+ rt_uint8_t *data, rt_uint32_t data_len,
+ rt_uint8_t *spare, rt_uint32_t spare_len)
+{
+ RT_ASSERT(device->ops->read_page);
+ return device->ops->read_page(device, page, data, data_len, spare, spare_len);
+}
+
+rt_err_t rt_mtd_nand_write(
+ struct rt_mtd_nand_device *device,
+ rt_off_t page,
+ const rt_uint8_t *data, rt_uint32_t data_len,
+ const rt_uint8_t *spare, rt_uint32_t spare_len)
+{
+ RT_ASSERT(device->ops->write_page);
+ return device->ops->write_page(device, page, data, data_len, spare, spare_len);
+}
+
+rt_err_t rt_mtd_nand_move_page(struct rt_mtd_nand_device *device,
+ rt_off_t src_page, rt_off_t dst_page)
+{
+ RT_ASSERT(device->ops->move_page);
+ return device->ops->move_page(device, src_page, dst_page);
+}
+
+rt_err_t rt_mtd_nand_erase_block(struct rt_mtd_nand_device *device, rt_uint32_t block)
+{
+ RT_ASSERT(device->ops->erase_block);
+ return device->ops->erase_block(device, block);
+}
+
+rt_err_t rt_mtd_nand_check_block(struct rt_mtd_nand_device *device, rt_uint32_t block)
+{
+ if (device->ops->check_block)
+ {
+ return device->ops->check_block(device, block);
+ }
+ else
+ {
+ return -RT_ENOSYS;
+ }
+}
+
+rt_err_t rt_mtd_nand_mark_badblock(struct rt_mtd_nand_device *device, rt_uint32_t block)
+{
+ if (device->ops->mark_badblock)
+ {
+ return device->ops->mark_badblock(device, block);
+ }
+ else
+ {
+ return -RT_ENOSYS;
+ }
+}
+
#if defined(RT_MTD_NAND_DEBUG) && defined(RT_USING_FINSH)
#include <finsh.h>
#define __is_print(ch) ((unsigned int)((ch) - ' ') < 127u - ' ')
diff --git a/components/drivers/mtd/mtd_nor.c b/components/drivers/mtd/mtd_nor.c
index fd5ceb0d9f..af3b50e42f 100644
--- a/components/drivers/mtd/mtd_nor.c
+++ b/components/drivers/mtd/mtd_nor.c
@@ -8,7 +8,7 @@
* 2012-5-30 Bernard the first version
*/
-#include <drivers/mtd_nor.h>
+#include <rtdevice.h>
#ifdef RT_USING_MTD_NOR
@@ -91,4 +91,27 @@ rt_err_t rt_mtd_nor_register_device(const char *name,
return rt_device_register(dev, name, RT_DEVICE_FLAG_RDWR | RT_DEVICE_FLAG_STANDALONE);
}
+rt_uint32_t rt_mtd_nor_read_id(struct rt_mtd_nor_device* device)
+{
+ return device->ops->read_id(device);
+}
+
+rt_size_t rt_mtd_nor_read(struct rt_mtd_nor_device* device,
+ rt_off_t offset, rt_uint8_t* data, rt_uint32_t length)
+{
+ return device->ops->read(device, offset, data, length);
+}
+
+rt_size_t rt_mtd_nor_write(struct rt_mtd_nor_device* device,
+ rt_off_t offset, const rt_uint8_t* data, rt_uint32_t length)
+{
+ return device->ops->write(device, offset, data, length);
+}
+
+rt_err_t rt_mtd_nor_erase_block(struct rt_mtd_nor_device* device,
+ rt_off_t offset, rt_size_t length)
+{
+ return device->ops->erase_block(device, offset, length);
+}
+
#endif