rt_err_t rt_device_open (rt_device_t dev, rt_uint16_t oflag) 入口参数: dev:设备句柄 oflags:访问模式 oflags支持以下参数: RT_DEVICE_OFLAG_CLOSE /* 设备已经关闭(内部使用)*/ RT_DEVICE_OFLAG_RDONLY /* 以只读方式打开设备 */ RT_DEVICE_OFLAG_WRONLY /* 以只写方式打开设备 */ RT_DEVICE_...
}/* device is a stand alone device and opened */if((dev->flag & RT_DEVICE_FLAG_STANDALONE) && (dev->open_flag & RT_DEVICE_OFLAG_OPEN)) {return-RT_EBUSY; }/* call deviceopeninterface */if(dev->open!= RT_NULL) { result = dev->open(dev, oflag); }/* setopenflag */if(resu...
int count = 1; struct rt_device_pin *pin_dev = RT_NULL; pin_dev = (struct rt_device_pin *)rt_device_find("pin"); rt_device_open((rt_device_t)pin_dev, RT_DEVICE_OFLAG_RDWR); pin_dev->ops->pin_mode(&pin_dev->parent, LED_PIN, PIN_MODE_OUTPUT); while (count++) { pin_d...
if (new_device == old_device) return RT_NULL; if (new_device != RT_NULL) { if (_console_device != RT_NULL) { /* close old console device */ rt_device_close(_console_device); } /* set new console device */ rt_device_open(new_device, RT_DEVICE_OFLAG_RDWR | RT_DEVICE_FLAG...
| RT_DEVICE_FLAG_INT_TX | uart_obj[i].uart_dma_flag , NULL); RT_ASSERT(result == RT_EOK); } return result; } 这个uart_obj是struct stm32_uart类型,主要成员是config和serial, config默认配置是: static struct stm32_uart_config uart_config[] = ...
22ret = rt_device_open(hw_dev, RT_DEVICE_OFLAG_RDWR); 23if(ret != RT_EOK) 24{ 25rt_kprintf("open %s device failed! ", HWTIMER_DEV_NAME); 26returnret; 27} 28/* 设置超时回调函数 */ 29rt_device_set_rx_indicate(hw_dev, timeout_cb); ...
rt_kprintf("hwtimer sample run failed!can't find %s device!n", HWTIMER_DEV_NAME); return RT_ERROR; } /以读写方式打开设备/ ret = rt_device_open(hw_dev, RT_DEVICE_OFLAG_RDWR); if (ret != RT_EOK) { rt_kprintf("open %s device failed!n", HWTIMER_DEV_NAME); ...
rt_device_open(snd_dev,RT_DEVICE_OFLAG_WRONLY) 打开Audio 录音设备使用示例如下所示: rt_device_open(mic_dev,RT_DEVICE_FLAG_RDONLY) 控制Audio 设备 通过命令控制字,应用程序可以对 Audio 设备进行配置,通过如下函数完成: rt_err_trt_device_control(rt_device_tdev,rt_uint8_tcmd,void*arg); ...
RT_DEVICE_OFLAG_RDWR | RT_DEVICE_FLAG_INT_RX | RT_DEVICE_FLAG_INT_TX ,NULL); 相应的配置宏如下所示: #defineRT_DEVICE_FLAG_RDONLY 0x001/* 只读 */ #defineRT_DEVICE_FLAG_WRONLY 0x002/* 只写 */ #defineRT_DEVICE_FLAG_RDWR 0x003/* 读写 */ ...
#define RT_DEVICE_OFLAG_NONBLOCKING 0x004 /**< non-blocking io mode */ ... #define RT_DEVICE_CTRL_BLOCKING 0x05 /**< blocking io */ serialX.h 添加串口驱动缓存和 DMA 二级缓存大小定义(放弃使用 `RT_SERIAL_RB_BUFSZ`): #ifndef RT_SERIAL_FIFO_BUFSZ ...