#ifdef RT_USING_DEVICE_OPS //增加对RT_USING_DEVICE_OPS的支持conststaticstructrt_device_ops adc_ops ={ RT_NULL, RT_NULL, RT_NULL, _adc_read, RT_NULL, _adc_control };#endifrt_err_t rt_hw_adc_register(rt_adc_device_t device,constchar*name,conststructrt_adc_ops *ops,constvoid*user...
memset(_lcd.lcd_info.framebuffer,0xFF, lcd_buff_size); #ifdefRT_USING_DEVICE_OPS device->ops = &lcd_ops; #else device->init = drv_lcd_init; device->control = drv_lcd_control; #endif /* 注册 LCD 设备 */ rt_device_register(device,"lcd", RT_DEVICE_FLAG_RDWR); __exit: if(resu...
rt_device_open rt_device_close 操作最好成对出现,原因是rt_device内部有引用计数,如你open两次,close一次,计数为1,没有真正的close。 一般通过rt_device_find,通过设备名称,查找设备,获取设备的操作句柄,也就是设备结构体指针,从而可以进一步进行操作设备的操作接口ops或通过设备的标准操作接口操作设备。 RT-Thread...
const struct dfs_file_ops *fops; struct rt_wqueue wait_queue; #endif void *user_data; /**< device private data */ }; 1.parent rt_object的实例化,因为rt_device也是继承于rt_object 2.type设备的类型,RTT中支持以下一些设备类型的定义: enumrt_device_class_type{RT_Device_Class_Char=0,/**<...
#if defined(RT_USING_POSIX) const struct dfs_file_ops *fops; struct rt_wqueue wait_queue; #endif void *user_data; /**< device private data */ }; 1. 2. 3. 4. 5. 6. 7. 8. 9. 10. 11. 12. 13. 14. 15. 16. 17. ...
rt_err_t (*control)(rt_device_t dev, int cmd, void *args); #endif #if defined(RT_USING_POSIX) const struct dfs_file_ops *fops; struct rt_wqueue wait_queue; #endif void *user_data; /**< device private data */ }; 2.1.1 设备类型 type ...
int rt_device_pin_register(const char *name, const struct rt_pin_ops *ops, void *user_data) { _hw_pin.parent.type = RT_Device_Class_Miscellaneous; _hw_pin.parent.rx_indicate = RT_NULL; _hw_pin.parent.tx_complete = RT_NULL; #ifdef RT_USING_DEVICE_OPS _hw_pin.parent.ops = &pi...
#ifdef RT_USING_DEVICE_OPS _hw_pin.parent.ops = &pin_ops; #else _hw_pin.parent.init = RT_NULL; /* 以下标准的rt_device设备操作接口,根据需要实现 */ _hw_pin.parent.open = RT_NULL; _hw_pin.parent.close = RT_NULL; _hw_pin.parent.read = _pin_read; ...
static rt_err_t _pin_control(rt_device_t dev, int cmd, void *args) //可调用的 int rt_device_pin_register(const char *name, const struct rt_pin_ops *ops, void *user_data); /* Get pin number by name,such as PA.0,P0.12 */ ...
return rt_device_pin_register("pin", &_stm32_pin_ops, RT_NULL); } 1. 2. 3. 4. 5. 6. PIN设备驱动层 这一层主要起到承上启下的,为上层应用提供统一的API,为下层驱动,提供注册函数。 其中注册函数如下: int rt_device_pin_register(const char *name, const struct rt_pin_ops *ops, void...