• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

C++ rt_device_find函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了C++中rt_device_find函数的典型用法代码示例。如果您正苦于以下问题:C++ rt_device_find函数的具体用法?C++ rt_device_find怎么用?C++ rt_device_find使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。



在下文中一共展示了rt_device_find函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。

示例1: can_bus_hook


//.........这里部分代码省略.........
#ifdef RT_USING_CAN
#define CANRT1   8
#define CANERR1  9
#define CANRT2   37
#define CANERR2  38
static struct canledtype
{
    struct stm32_hw_pin_userdata rtd;
    struct stm32_hw_pin_userdata err;
} canled[] =
{
#ifdef USING_BXCAN1
    {
        {CANRT1, PIN_MODE_OUTPUT,},
        {CANERR1, PIN_MODE_OUTPUT,},
    },
#endif /*USING_BXCAN1*/
#ifdef USING_BXCAN2
    {
        {CANRT2, PIN_MODE_OUTPUT_OD,},
        {CANERR2, PIN_MODE_OUTPUT_OD,},
    },
#endif /*USING_BXCAN2*/
};
void can_bus_hook(struct rt_can_device *can, struct canledtype *led)
{
    if (can->timerinitflag == 1)
    {
        rt_pin_write(led->rtd.pin, 0);
    }
    else
    {
        if (can->status.rcvchange == 1 || can->status.sndchange == 1)
        {
            can->status.rcvchange = 0;
            can->status.sndchange = 0;
            rt_pin_write(led->rtd.pin, rt_pin_read(led->rtd.pin) ? 0 : 1);
        }
        else
        {
            rt_pin_write(led->rtd.pin, 1);
        }
    }
    if (can->timerinitflag == 1)
    {
        rt_pin_write(led->err.pin, 0);
    }
    else
    {
        if (can->status.errcode)
        {
            rt_pin_write(led->err.pin, 0);
        }
        else
        {
            rt_pin_write(led->err.pin, 1);
        }
    }
}
#ifdef USING_BXCAN1
void can1_bus_hook(struct rt_can_device *can)
{
    static rt_int32_t inited = 0;
    if (!inited)
    {
        inited = 1;
        rt_pin_mode(canled[0].rtd.pin, canled[0].rtd.mode);
        rt_pin_mode(canled[0].err.pin, canled[0].err.mode);
    }
    can_bus_hook(can, &canled[0]);
}
#endif /*USING_BXCAN1*/
#ifdef USING_BXCAN2
void can2_bus_hook(struct rt_can_device *can)
{
    static rt_int32_t inited = 0;
    if (!inited)
    {
        inited = 1;
        rt_pin_mode(canled[1].rtd.pin, canled[1].rtd.mode);
        rt_pin_mode(canled[1].err.pin, canled[1].err.mode);
    }
    can_bus_hook(can, &canled[1]);
}
#endif /*USING_BXCAN2*/
int can_bus_hook_init(void)
{
    rt_device_t candev;
#ifdef USING_BXCAN1
    candev = rt_device_find("bxcan1");
    RT_ASSERT(candev);
    rt_device_control(candev, RT_CAN_CMD_SET_BUS_HOOK, (void *)can1_bus_hook);
#endif /*USING_BXCAN1*/
#ifdef USING_BXCAN2
    candev = rt_device_find("bxcan2");
    RT_ASSERT(candev);
    rt_device_control(candev, RT_CAN_CMD_SET_BUS_HOOK, (void *)can2_bus_hook);
#endif /*USING_BXCAN2*/
    return RT_EOK;
}
开发者ID:chinesebear,项目名称:rt-thread,代码行数:101,代码来源:canapp.c


示例2: clock_settime

int clock_settime (clockid_t clockid, const struct timespec *tp)
{
	int second;
	rt_tick_t tick;
	rt_device_t device;

	if ((clockid != CLOCK_REALTIME) || (tp == RT_NULL)) {
		rt_set_errno(EINVAL);
		return -1;
	}

	/* get second */
	second = tp->tv_sec;
	/* get tick */
	tick = rt_tick_get();

	/* update timevalue */
	_timevalue.tv_usec = MICROSECOND_PER_SECOND - (tick % RT_TICK_PER_SECOND) * MICROSECOND_PER_TICK;
	_timevalue.tv_sec = second - tick/RT_TICK_PER_SECOND - 1;

	/* update for RTC device */
	device = rt_device_find("rtc");
	if (device != RT_NULL) {
		/* set realtime seconds */
		rt_device_control(device, RT_DEVICE_CTRL_RTC_SET_TIME, &second);
	} else return -1;

	return 0;
}
开发者ID:malooei,项目名称:yeejoin-workspace,代码行数:29,代码来源:clock_time.c


示例3: save_handler

static void save_handler(struct rtgui_widget* widget, rtgui_event_t* event)
{
    extern void brightness_set(unsigned int value);

    rt_uint32_t vol, bri;
    vol = rtgui_slider_get_value(slider_volume);
    bri = rtgui_slider_get_value(slider_brightness);

    //更新背光
    brightness_set(bri);

    //更新音量
    {
        rt_device_t dev = RT_NULL;
        dev = rt_device_find("snd");
        dev->control(dev, CODEC_CMD_VOLUME, &vol);
    }

    //保存配置
    radio_setup.default_volume = vol;
    radio_setup.lcd_brightness = bri;
    save_setup();

    //保存完毕,销毁本界面
    {
        rtgui_view_t* view;
        rtgui_workbench_t* workbench;

        /* remove view in workbench */
        view = RTGUI_VIEW(widget->parent);
        workbench = RTGUI_WORKBENCH(RTGUI_WIDGET(view)->parent);
        rtgui_workbench_remove_view(workbench, view);
        rtgui_view_destroy(view);
    }
}
开发者ID:Manish-cimcon,项目名称:micro,代码行数:35,代码来源:setup.c


示例4: led_thread_entry

static void led_thread_entry(void* parameter)
{
    unsigned int count=0;
    rt_device_t led_dev=rt_device_find("led");
    rt_uint8_t led_value=0;
    while (1)
    {
        /* led1 on */
#ifndef RT_USING_FINSH
        rt_kprintf("led on, count : %d\r\n",count);
#endif
        count++;
        led_value=1;
        led_dev->write(led_dev,count%4,&led_value,1);
        rt_thread_delay( RT_TICK_PER_SECOND/2 ); /* sleep 0.5 second and switch to other thread */

        /* led1 off */
#ifndef RT_USING_FINSH
        rt_kprintf("led off\r\n");
#endif
        led_value=0;
        led_dev->write(led_dev,count%4,&led_value,1);
        rt_thread_delay( RT_TICK_PER_SECOND/2 );
    }
}
开发者ID:liuweiqi,项目名称:RealBoard4088,代码行数:25,代码来源:application.c


示例5: rt_init_thread_entry

void rt_init_thread_entry(void *parameter)
{
#ifdef RT_USING_COMPONENTS_INIT
	/* initialization RT-Thread Components */
	rt_components_init();
#endif

	rt_platform_init();

	/* Filesystem Initialization */
#ifdef RT_USING_DFS
	/* mount sd card fat partition 1 as root directory */
	if (dfs_mount("sd0", "/", "elm", 0, 0) == 0)
	{
		rt_kprintf("File System initialized!\n");
	}
	else rt_kprintf("File System initialzation failed!\n");
#endif

#ifdef RT_USING_RTGUI
	gui_init();

	picture_show();

	/* initial touch. */
	{
        rt_device_t device;
	    device = rt_device_find("touch");
	    if (device != RT_NULL)
        {
            rt_device_init(device);
        }
	}
#endif /* RT_USING_RTGUI */
}
开发者ID:15863118785,项目名称:realtouch-stm32f4,代码行数:35,代码来源:application.c


示例6: time

time_t time(time_t* t)
#endif
{
    static rt_device_t device = RT_NULL;
    time_t time_now = 0;

    /* optimization: find rtc device only first. */
    if (device == RT_NULL)
    {
        device = rt_device_find("rtc");
    }

    /* read timestamp from RTC device. */
    if (device != RT_NULL)
    {
        rt_device_control(device, RT_DEVICE_CTRL_RTC_GET_TIME, &time_now);
    }

    /* if t is not NULL, write timestamp to *t */
    if (t != RT_NULL)
    {
        *t = time_now;
    }

    return time_now;
}
开发者ID:dlts200466,项目名称:PowerSupply,代码行数:26,代码来源:rtc.c


示例7: finsh_set_device

/**
 * @ingroup finsh
 *
 * This function sets the input device of finsh shell.
 *
 * @param device_name the name of new input device.
 */
void finsh_set_device(const char *device_name)
{
    rt_device_t dev = RT_NULL;

    RT_ASSERT(shell != RT_NULL);
    dev = rt_device_find(device_name);
    if (dev == RT_NULL)
    {
        rt_kprintf("finsh: can not find device: %s\n", device_name);
        return;
    }

    /* check whether it's a same device */
    if (dev == shell->device) return;
    /* open this device and set the new device in finsh shell */
    if (rt_device_open(dev, RT_DEVICE_OFLAG_RDWR | RT_DEVICE_FLAG_INT_RX | \
                       RT_DEVICE_FLAG_STREAM) == RT_EOK)
    {
        if (shell->device != RT_NULL)
        {
            /* close old finsh device */
            rt_device_close(shell->device);
            rt_device_set_rx_indicate(shell->device, RT_NULL);
        }

        /* clear line buffer before switch to new device */
        memset(shell->line, 0, sizeof(shell->line));
        shell->line_curpos = shell->line_position = 0;

        shell->device = dev;
        rt_device_set_rx_indicate(dev, finsh_rx_ind);
    }
}
开发者ID:SchumyHao,项目名称:rt-thread,代码行数:40,代码来源:shell.c


示例8: ads7843_init

rt_err_t ads7843_init(const char * name, const char * spi_device_name)
{

    rt_spi_device = (struct rt_spi_device *)rt_device_find(spi_device_name);
    if(rt_spi_device == RT_NULL)
    {
        rt_kprintf("spi device %s not found!\r\n", spi_device_name);
        return -RT_ENOSYS;
    }

    /* config spi */
    {
        struct rt_spi_configuration cfg;
        cfg.data_width = 8;
        cfg.mode = RT_SPI_MODE_0 | RT_SPI_MSB; /* SPI Compatible: Mode 0 and Mode 3 */
        cfg.max_hz = 2 * 1000 * 1000;
        rt_spi_configure(rt_spi_device, &cfg);
    }

    /* register device */
    ads7843_device.type    = RT_Device_Class_Block;
    ads7843_device.init    = RT_NULL;
    ads7843_device.open    = RT_NULL;
    ads7843_device.close   = RT_NULL;
    ads7843_device.read    = ads7843_read;
    ads7843_device.write   = RT_NULL;
    ads7843_device.control = RT_NULL;
    /* no private */
    ads7843_device.user_data = RT_NULL;

    rt_device_register(&ads7843_device, name,
                       RT_DEVICE_FLAG_RDWR | RT_DEVICE_FLAG_STANDALONE);

    return RT_EOK;
}
开发者ID:guzhaoyuan,项目名称:smartCar,代码行数:35,代码来源:drv_ads7843.c


示例9: log_trace_set_device

rt_err_t log_trace_set_device(const char *device_name)
{
    struct rt_device *output_device;

    /* find out output device */
    output_device = rt_device_find(device_name);
    if (output_device != RT_NULL)
    {
        rt_err_t result;

        /* open device */
        result = rt_device_open(output_device, RT_DEVICE_FLAG_STREAM | RT_DEVICE_FLAG_RDWR);
        if (result != RT_EOK)
        {
            rt_kprintf("Open trace device failed.\n");
            return -RT_ERROR;
        }
    }

    /* set trace out device */
    if (_traceout_device != RT_NULL)
        rt_device_close(_traceout_device);
    _traceout_device = output_device;

    return RT_EOK;
}
开发者ID:byteboy2013,项目名称:rt-thread,代码行数:26,代码来源:log_trace.c


示例10: wav

void wav(const char* filename)
{
    int fd;
	rt_size_t block_size;

	block_size = sbuf_get_size();
	block_size = (block_size / 512) * 512;

    fd = open(filename, O_RDONLY, 0);
    if (fd >= 0)
    {
		rt_uint8_t* buf;
		rt_size_t 	len;
		rt_device_t device;

		/* open audio device and set tx done call back */
		device = rt_device_find("snd");
		rt_device_set_tx_complete(device, wav_tx_done);
		rt_device_open(device, RT_DEVICE_OFLAG_WRONLY);

		do
		{
			buf = sbuf_alloc();
			len = read(fd, (char*)buf, block_size);
			if (len > 0) rt_device_write(device, 0, buf, len);
			else sbuf_release(buf);
		} while (len != 0);

		/* close device and file */
		rt_device_close(device);
		close(fd);
    }
}
开发者ID:Manish-cimcon,项目名称:micro,代码行数:33,代码来源:wav.c


示例11: rt_hw_lcd_init

int rt_hw_lcd_init(const char *name)
{
    
    struct lcd_device *dev;
    
    if(rt_device_find(name))
    {
        return -RT_EIO;
    }
    
    dev = rt_malloc(sizeof(struct lcd_device));
    if(!dev)
    {
        return RT_ENOMEM;
    }
    
	dev->rtdev.type         = RT_Device_Class_Graphic;
	dev->rtdev.rx_indicate  = RT_NULL;
	dev->rtdev.init         = rt_lcd_init;
	dev->rtdev.open         = RT_NULL;
	dev->rtdev.close		= RT_NULL;
	dev->rtdev.read 		= RT_NULL;
	dev->rtdev.write        = RT_NULL;
	dev->rtdev.control      = rt_lcd_control;
	dev->rtdev.user_data	= RT_NULL;

    /* initialize mutex */
    rt_mutex_init(&dev->lock, name, RT_IPC_FLAG_FIFO);
    rt_device_register(&dev->rtdev, name, RT_DEVICE_FLAG_RDWR);
    return RT_EOK;
}
开发者ID:yanbib,项目名称:smartcar,代码行数:31,代码来源:drv_lcd.c


示例12: uip_sys_init

void uip_sys_init(void)
{    
    struct rt_device *eth_dev;
    uip_ipaddr_t ipaddr;

    uip_init();   

    httpd_init();  
    /*#if   HELLO_WORLD
      hello_world_init();
#elif TELNETD
telnetd_init();
#elif WEBSERVER
httpd_init();
printf("httpd_init\n\n");
#elif WEBCLIENT
webclient_init();
resolv_init();
uip_ipaddr(ipaddr, 202,96,128,166);  //set DNS server 
resolv_conf(ipaddr);
resolv_query("www.rt-thread.org");
#else
uip_listen(HTONS(1234));
uip_ipaddr(ipaddr, 192,168,2,244);
uip_connect(&ipaddr, HTONS(5678)); 
#endif
     */
    eth_dev = rt_device_find("e0");
    RT_ASSERT(eth_dev != RT_NULL);

    return;
}
开发者ID:dreamflyforever,项目名称:rt-thread-1.1.0,代码行数:32,代码来源:uipif.c


示例13: rt_init_thread_entry

void rt_init_thread_entry(void *parameter)
{
#ifdef RT_USING_RTGUI
	{
		rt_device_t dc;

		/* init Display Controller */
		rt_hw_dc_init();
			
		/* re-init device driver */
		rt_device_init_all();
	
		/* find Display Controller device */
		dc = rt_device_find("dc");
	
		/* set Display Controller device as rtgui graphic driver */		
		rtgui_graphic_set_device(dc);
	}
#endif

#ifdef RT_USING_COMPONENTS_INIT
	/* initialization RT-Thread Components */
	rt_components_init();
#endif
}
开发者ID:304471720,项目名称:rt-thread,代码行数:25,代码来源:application.c


示例14: adc_thread_entry

static void adc_thread_entry(void *parameter)
{
    rt_device_t device;
    
#ifdef RT_USING_RTGUI
    struct rtgui_event_command ecmd;
    
    RTGUI_EVENT_COMMAND_INIT(&ecmd);
    ecmd.type = RTGUI_CMD_USER_INT;
    ecmd.command_id = ADC_UPDATE;
#else
    struct lcd_msg msg;
#endif	

    device = rt_device_find("adc");

    while(1)
    {
        rt_device_control(device, RT_DEVICE_CTRL_ADC_START, RT_NULL);    
        rt_device_control(device, RT_DEVICE_CTRL_ADC_RESULT, &adc_value);
        pwm_update(adc_value/3);
#ifdef RT_USING_RTGUI
        rtgui_thread_send(info_tid, &ecmd.parent, sizeof(ecmd));
#else
        msg.type = ADC_MSG;
		msg.adc_value = adc_value;
        rt_mq_send(&mq, &msg, sizeof(msg));
#endif
        rt_thread_delay(20);
    }
}
开发者ID:bright-pan,项目名称:smart-lock,代码行数:31,代码来源:adc.c


示例15: uart_thread_entry

//串口接收数据线程
void uart_thread_entry(void* parameter)
{
    char ch;

    device = rt_device_find("uart3");
    if(device != RT_NULL)
    {
        rt_device_open(device, RT_DEVICE_OFLAG_RDWR);
			
        rt_kprintf("open device uart3 succeed!\r\n");
				rt_sem_init(&rx_sem, "uartrx", 0, 0);
				
				rt_device_set_rx_indicate(device, uart_rx_ind);
				
        while(1)
        {
            if (rt_sem_take(&rx_sem, RT_WAITING_FOREVER) != RT_EOK) //默认情况线程挂起,有数据时,系统会调用uart_rx_ind函数,释放信号量,线程得以执行
							continue;
						while(rt_device_read(device, 0, &ch, 1) == 1)
            {
                uartRecvProc(ch);
            }
				}
    }
}
开发者ID:liubins313,项目名称:k60-rtt1.20,代码行数:26,代码来源:uart_thread.c


示例16: rt_spi_bus_attach_device

rt_err_t rt_spi_bus_attach_device(struct rt_spi_device *device,
                                  const char           *name,
                                  const char           *bus_name,
                                  void                 *user_data)
{
    rt_err_t result;
    rt_device_t bus;

    /* get physical spi bus */
    bus = rt_device_find(bus_name);
    if (bus != RT_NULL && bus->type == RT_Device_Class_SPIBUS)
    {
        device->bus = (struct rt_spi_bus *)bus;

        /* initialize spidev device */
        result = rt_spidev_device_init(device, name);
        if (result != RT_EOK)
            return result;

        rt_memset(&device->config, 0, sizeof(device->config));
        device->parent.user_data = user_data;

        return RT_EOK;
    }

    /* not found the host bus */
    return -RT_ERROR;
}
开发者ID:Bluebear233,项目名称:rt-thread-stm32f103,代码行数:28,代码来源:spi_core.c


示例17: uart1_rs485_set_device

void uart1_rs485_set_device(void)
{
	    rt_device_t dev = RT_NULL;

    dev = rt_device_find("uart2");
	if (dev == RT_NULL)
    {
        rt_kprintf("finsh: can not find device: %s\n", "uart1");
        return;
    }

    /* check whether it's a same device */
    if (dev == uart1_dev_my->device) return;
		
    if (rt_device_open(dev, RT_DEVICE_OFLAG_RDWR | RT_DEVICE_FLAG_INT_RX |\
                       RT_DEVICE_FLAG_STREAM) == RT_EOK)
    {
        if (uart1_dev_my->device != RT_NULL)
        {
            /* close old finsh device */
            rt_device_close(uart1_dev_my->device);
            rt_device_set_rx_indicate(uart1_dev_my->device, RT_NULL);
        }

        uart1_dev_my->device = dev;
        rt_device_set_rx_indicate(dev, rs485_rx_ind);
    }
}
开发者ID:pigeon0411,项目名称:aclean_ct,代码行数:28,代码来源:rs485_decode.c


示例18: Device_RTC_set

u8  Device_RTC_set(TDateTime now)
{
    rt_device_t device;

    RTC_DateStructure.RTC_Year = now.year;
    RTC_DateStructure.RTC_Month =now.month;  
    RTC_DateStructure.RTC_Date = now.day;   
    RTC_DateStructure.RTC_WeekDay=now.week;  
	

    	
    RTC_TimeStructure.RTC_Hours = now.hour;
    RTC_TimeStructure.RTC_Minutes = now.min;
    RTC_TimeStructure.RTC_Seconds 	= now.sec; 
  
    device = rt_device_find("rtc");
    if (device != RT_NULL)
    {
        rt_rtc_control(device, RT_DEVICE_CTRL_RTC_SET_DATE, &RTC_DateStructure);   
	 	
	    rt_rtc_control(device, RT_DEVICE_CTRL_RTC_SET_TIME, &RTC_TimeStructure);   	

		return 1;   
		
    }
		
		return 0;
}
开发者ID:nathanlnw,项目名称:tw705_shanxi_J,代码行数:28,代码来源:rtc.c


示例19: SetCurrentDateTime

void SetCurrentDateTime(CLOCK *clock)
{
    time_t now;
    struct tm* ti;
    rt_device_t device;

    ti = RT_NULL;

    /* get current time */
    time(&now);

    ti = localtime(&now);
    if (ti != RT_NULL)
    {
		ti->tm_year =   BCD2Char(clock->year) +100;
		ti->tm_mon 	= BCD2Char(clock->month )- 1; /* ti->tm_mon 	= month; 0~11 */
		ti->tm_mday = BCD2Char(clock->day);
		ti->tm_hour = BCD2Char(clock->hour);
		ti->tm_min 	= BCD2Char(clock->minute);
		ti->tm_sec 	= BCD2Char(clock->second);
    }

    now = mktime(ti);
    device = rt_device_find("rtc");
    if (device != RT_NULL)
    {
        rt_rtc_control(device, RT_DEVICE_CTRL_RTC_SET_TIME, &now);
    }
}
开发者ID:nodeboy,项目名称:nodeboyRepo,代码行数:29,代码来源:rtc.c


示例20: rt_hw_nRF24L01_init

rt_err_t rt_hw_nRF24L01_init(const char * spi_device_name){
	RF24L01_IO_Init();
	
	rt_spi_device = (struct rt_spi_device *)rt_device_find(spi_device_name);
	if(rt_spi_device == RT_NULL)
	{
			FLASH_TRACE("spi device %s not found!\r\n", spi_device_name);
			return -RT_ENOSYS;
	}

	/* config spi */
	{
			struct rt_spi_configuration cfg;
			cfg.data_width = 8;
			cfg.mode = RT_SPI_MODE_0 | RT_SPI_MSB; /* SPI Compatible: Mode 0 and Mode 3 */
			cfg.max_hz = 9 * 1000 * 1000; /* 9M */
			//cfg.max_hz = 50 * 1000 * 1000; /* 9M */
			rt_spi_configure(rt_spi_device, &cfg);
	}
//	SPI_RF24L01_RW(0x5a);	
	
	if(RF24L01_Check() == RT_EOK) {
		//这里直接启一个线程来处理相关数据。
		rt_kprintf("nRF24L01 is connected !\n");
		return	RT_EOK;
	}	else {
		rt_kprintf("nRF24L01 is not connected !\n");
		return RT_ERROR ;        //MCU与void RF24L01_Init(void)不正常连接		
	}
	
}
开发者ID:201409366,项目名称:Aerobat,代码行数:31,代码来源:nRF24L01.c



注:本文中的rt_device_find函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C++ rt_device_register函数代码示例发布时间:2022-05-30
下一篇:
C++ rt_device_control函数代码示例发布时间:2022-05-30
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap