本文整理汇总了C++中rt_device_register函数的典型用法代码示例。如果您正苦于以下问题:C++ rt_device_register函数的具体用法?C++ rt_device_register怎么用?C++ rt_device_register使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了rt_device_register函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: rt_hw_uart_init
void rt_hw_uart_init(void)
{
struct rt_uart_lpc* uart;
#ifdef RT_USING_UART0
/* get uart device */
uart = &uart0_device;
uart0_device.UART = LPC_UART0;
uart0_device.UART_IRQn = UART0_IRQn;
/* device initialization */
uart->parent.type = RT_Device_Class_Char;
rt_memset(uart->rx_buffer, 0, sizeof(uart->rx_buffer));
uart->read_index = uart->save_index = 0;
/* device interface */
uart->parent.init = rt_uart_init;
uart->parent.open = rt_uart_open;
uart->parent.close = rt_uart_close;
uart->parent.read = rt_uart_read;
uart->parent.write = rt_uart_write;
uart->parent.control = RT_NULL;
uart->parent.user_data = RT_NULL;
rt_device_register(&uart->parent,
"uart0", RT_DEVICE_FLAG_RDWR | RT_DEVICE_FLAG_STREAM | RT_DEVICE_FLAG_INT_RX);
#endif
#ifdef RT_USING_UART1
/* get uart device */
uart = &uart1_device;
uart1_device.UART = (LPC_UART_TypeDef *)LPC_UART1;
uart1_device.UART_IRQn = UART1_IRQn;
/* device initialization */
uart->parent.type = RT_Device_Class_Char;
rt_memset(uart->rx_buffer, 0, sizeof(uart->rx_buffer));
uart->read_index = uart->save_index = 0;
/* device interface */
uart->parent.init = rt_uart_init;
uart->parent.open = rt_uart_open;
uart->parent.close = rt_uart_close;
uart->parent.read = rt_uart_read;
uart->parent.write = rt_uart_write;
uart->parent.control = RT_NULL;
uart->parent.user_data = RT_NULL;
rt_device_register(&uart->parent,
"uart1", RT_DEVICE_FLAG_RDWR | RT_DEVICE_FLAG_STREAM | RT_DEVICE_FLAG_INT_RX);
#endif
}
示例2: USBH_USR_MSC_Application
/**
* @brief USBH_USR_MSC_Application
* Demo application for mass storage
* @param None
* @retval Staus
*/
int USBH_USR_MSC_Application( void )
{
// FRESULT res;
int ret;
if( diskinited )
{
return 0;
}
mscdev.type = RT_Device_Class_Block;
mscdev.init = msc_init;
mscdev.open = msc_open;
mscdev.close = msc_close;
mscdev.read = msc_read;
mscdev.write = msc_write;
mscdev.control = msc_control;
mscdev.user_data = RT_NULL;
diskinited = 1;
rt_device_register( &mscdev, "udisk", RT_DEVICE_FLAG_RDWR | RT_DEVICE_FLAG_REMOVABLE );
rt_device_init( &mscdev );
rt_thread_delay( RT_TICK_PER_SECOND / 10 );
//ret = dfs_mount( "udisk", "/udisk", "elm", 0, 0 );
if(0 == f_mount(USB, &fs))
{
rt_kprintf("\n f_mount USB OK!");
}
//rt_kprintf( "\ndfs_mount ret=%x now udisk start", ret );
return 0;
}
示例3: USBH_USR_MSC_Application
/**
* @brief USBH_USR_MSC_Application
* Demo application for mass storage
* @param None
* @retval Staus
*/
int USBH_USR_MSC_Application( void )
{
int ret;
if( diskinited )
{
return 0;
}
mscdev.type = RT_Device_Class_Block;
mscdev.init = msc_init;
mscdev.open = msc_open;
mscdev.close = msc_close;
mscdev.read = msc_read;
mscdev.write = msc_write;
mscdev.control = msc_control;
mscdev.user_data = RT_NULL;
diskinited = 1;
rt_device_register( &mscdev, "udisk", RT_DEVICE_FLAG_RDWR | RT_DEVICE_FLAG_REMOVABLE );
rt_device_init( &mscdev );
rt_thread_delay( RT_TICK_PER_SECOND / 10 );
ret = dfs_mount( "udisk", "/udisk", "elm", 0, 0 );
rt_kprintf( "dfs_mount ret=%x now udisk start\r\n", ret );
USB_find_status = USB_FIND;
Show_Menu_5_2_ExportData();
return 0;
}
示例4: gd32_hw_lcd_init
int gd32_hw_lcd_init(void)
{
_rt_framebuffer = rt_malloc_align(sizeof(rt_uint16_t) * RT_HW_LCD_WIDTH * RT_HW_LCD_HEIGHT, 32);
if (_rt_framebuffer == RT_NULL)
return -1; /* no memory yet */
lcd_config();
tli_config();
tli_layer_enable(LAYER0);
tli_reload_config(TLI_FRAME_BLANK_RELOAD_EN);
tli_enable();
_lcd_info.bits_per_pixel = LCD_BITS_PER_PIXEL;
_lcd_info.pixel_format = RTGRAPHIC_PIXEL_FORMAT_RGB565;
_lcd_info.framebuffer = (void *)_rt_framebuffer;
_lcd_info.width = RT_HW_LCD_WIDTH;
_lcd_info.height = RT_HW_LCD_HEIGHT;
lcd.type = RT_Device_Class_Graphic;
lcd.init = NULL;
lcd.open = NULL;
lcd.close = NULL;
lcd.read = NULL;
lcd.write = NULL;
lcd.control = rt_lcd_control;
lcd.user_data = (void *)&_lcd_info;
/* register lcd device to RT-Thread */
rt_device_register(&lcd, "lcd", RT_DEVICE_FLAG_RDWR);
return 0;
}
示例5: rt_hw_lcd_init
/* LCD BL P5_4 */
void rt_hw_lcd_init(void)
{
rt_uint16_t * _rt_framebuffer = RT_NULL;
// _rt_framebuffer = rt_malloc_align(sizeof(rt_uint16_t)*RT_HW_LCD_HEIGHT*RT_HW_LCD_WIDTH, 8);
// if (_rt_framebuffer == RT_NULL) return; /* no memory yet */
_rt_framebuffer = (rt_uint16_t *)0xA0000000;
_lcd_info.bits_per_pixel = 16;
_lcd_info.pixel_format = RTGRAPHIC_PIXEL_FORMAT_RGB565;
_lcd_info.framebuffer = (void*)_rt_framebuffer;
_lcd_info.width = RT_HW_LCD_WIDTH;
_lcd_info.height = RT_HW_LCD_HEIGHT;
/* init device structure */
lcd.type = RT_Device_Class_Graphic;
lcd.init = rt_lcd_init;
lcd.open = RT_NULL;
lcd.close = RT_NULL;
lcd.control = rt_lcd_control;
lcd.user_data = (void*)&_lcd_info;
/* register lcd device to RT-Thread */
rt_device_register(&lcd, "lcd", RT_DEVICE_FLAG_RDWR);
}
示例6: rt_hw_console_init
/**
* This function initializes console
*
*/
void rt_hw_console_init(void)
{
rt_cga_init();
rt_serial_init();
init_keyboard();
/* install keyboard isr */
rt_hw_interrupt_install(INTKEYBOARD, rt_console_isr, RT_NULL, "kbd");
rt_hw_interrupt_umask(INTKEYBOARD);
rt_hw_interrupt_install(INTUART0_RX, rt_console_isr, RT_NULL, "COM1");
rt_hw_interrupt_umask(INTUART0_RX);
console_device.type = RT_Device_Class_Char;
console_device.rx_indicate = RT_NULL;
console_device.tx_complete = RT_NULL;
console_device.init = rt_console_init;
console_device.open = rt_console_open;
console_device.close = rt_console_close;
console_device.read = rt_console_read;
console_device.write = rt_console_write;
console_device.control = rt_console_control;
console_device.user_data = RT_NULL;
/* register a character device */
rt_device_register(&console_device,
"console",
RT_DEVICE_FLAG_RDWR | RT_DEVICE_FLAG_INT_RX | RT_DEVICE_FLAG_STREAM);
}
示例7: rt_hw_dc_init
void rt_hw_dc_init(void)
{
rt_device_t dc = rt_malloc(sizeof(struct rt_device));
if (dc == RT_NULL)
{
rt_kprintf("dc == RT_NULL\n");
return; /* no memory yet */
}
_dc_info.bits_per_pixel = 16;
_dc_info.pixel_format = RTGRAPHIC_PIXEL_FORMAT_RGB565P;
_dc_info.framebuffer = (rt_uint8_t*)HW_FB_ADDR;
_dc_info.width = FB_XSIZE;
_dc_info.height = FB_YSIZE;
/* init device structure */
dc->type = RT_Device_Class_Graphic;
dc->init = rt_dc_init;
dc->open = RT_NULL;
dc->close = RT_NULL;
dc->control = rt_dc_control;
dc->user_data = (void*)&_dc_info;
/* register Display Controller device to RT-Thread */
rt_device_register(dc, "dc", RT_DEVICE_FLAG_RDWR);
}
示例8: fm25_hw_init
void fm25_hw_init()
{
int i = 0xFFFFF;
fm25_spi_cfg();
while(i--);
//spi_config();
CS_LOW();
spi_readwrite( FM25_WRDI );
CS_HIGH();
spi_flash_device.type = RT_Device_Class_Block;
spi_flash_device.init = fm25_init;
spi_flash_device.open = fm25_open;
spi_flash_device.close = fm25_close;
spi_flash_device.read = fm25_read;
spi_flash_device.write = fm25_write;
spi_flash_device.control = fm25_control;
/* no private */
spi_flash_device.user_data = RT_NULL;
rt_device_register(&spi_flash_device, "fram0",
RT_DEVICE_FLAG_RDWR | RT_DEVICE_FLAG_STANDALONE);
}
示例9: rt_hw_rtc_init
void rt_hw_rtc_init(void)
{
rtc.type = RT_Device_Class_RTC;
RTC_Init(LPC_RTC);
if (RTC_ReadGPREG(LPC_RTC,0) != FIRST_DATA)
{
rt_kprintf("rtc is not configured\n");
rt_kprintf("please configure with set_date and set_time\n");
}
else
{
}
RTC_Cmd(LPC_RTC,ENABLE);
/* register rtc device */
rtc.init = RT_NULL;
rtc.open = rt_rtc_open;
rtc.close = RT_NULL;
rtc.read = rt_rtc_read;
rtc.write = RT_NULL;
rtc.control = rt_rtc_control;
/* no private */
rtc.user_data = RT_NULL;
rt_device_register(&rtc, "rtc", RT_DEVICE_FLAG_RDWR);
#ifdef RT_USING_FINSH
{
extern void list_date(void);
list_date();
}
#endif
return;
}
示例10: 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;
}
示例11: RS485_init
/*RS485设备初始化*/
void RS485_init( void )
{
//rt_sem_init( &sem_RS485, "sem_RS485", 0, 0 );
rt_mq_init( &mq_RS485, "mq_RS485", &RS485_rawinfo[0], 128 - sizeof( void* ), RS485_RAWINFO_SIZE, RT_IPC_FLAG_FIFO );
dev_RS485.type = RT_Device_Class_Char;
dev_RS485.init = dev_RS485_init;
dev_RS485.open = dev_RS485_open;
dev_RS485.close = dev_RS485_close;
dev_RS485.read = dev_RS485_read;
dev_RS485.write = dev_RS485_write;
dev_RS485.control = dev_RS485_control;
rt_device_register( &dev_RS485, "RS485", RT_DEVICE_FLAG_RDWR | RT_DEVICE_FLAG_STANDALONE );
rt_device_init( &dev_RS485 );
Cam_Device_init( );
rt_thread_init( &thread_RS485,
"RS485",
rt_thread_entry_RS485,
RT_NULL,
&thread_RS485_stack[0],
sizeof( thread_RS485_stack ), 9, 5 );
rt_thread_startup( &thread_RS485 );
}
示例12: sdlfb_hw_init
static void sdlfb_hw_init(void)
{
/* set video driver for VC++ debug */
//_putenv("SDL_VIDEODRIVER=windib");
//if (SDL_Init(SDL_INIT_VIDEO | SDL_INIT_TIMER | SDL_INIT_AUDIO) < 0)
if (SDL_Init(SDL_INIT_VIDEO) < 0)
{
fprintf(stderr, "Couldn't initialize SDL: %s\n", SDL_GetError());
exit(1);
}
_device.parent.init = sdlfb_init;
_device.parent.open = sdlfb_open;
_device.parent.close = sdlfb_close;
_device.parent.read = RT_NULL;
_device.parent.write = RT_NULL;
_device.parent.control = sdlfb_control;
_device.width = SDL_SCREEN_WIDTH;
_device.height = SDL_SCREEN_HEIGHT;
_device.screen = SDL_SetVideoMode(_device.width, _device.height, 16, SDL_SWSURFACE | SDL_DOUBLEBUF);
if (_device.screen == NULL)
{
fprintf(stderr, "Couldn't set video mode: %s\n", SDL_GetError());
exit(1);
}
SDL_WM_SetCaption("RT-Thread/GUI Simulator", NULL);
rt_device_register(RT_DEVICE(&_device), "sdl", RT_DEVICE_FLAG_RDWR);
sdllock = rt_mutex_create("fb", RT_IPC_FLAG_FIFO);
}
示例13: stm32_hw_lcd_init
int stm32_hw_lcd_init(void)
{
_rt_framebuffer = rt_malloc_align(sizeof(rt_uint16_t) * RT_HW_LCD_WIDTH * RT_HW_LCD_HEIGHT, 32);
if (_rt_framebuffer == RT_NULL)
return -1; /* no memory yet */
LTDC_CLK_Config();
MX_LTDC_Init();
lcd_backlight_init();
MX_DMA2D_Init();
_lcd_info.bits_per_pixel = LCD_BITS_PER_PIXEL;
_lcd_info.pixel_format = RTGRAPHIC_PIXEL_FORMAT_RGB565; // RTGRAPHIC_PIXEL_FORMAT_ARGB888
_lcd_info.framebuffer = (void *)_rt_framebuffer;
_lcd_info.width = RT_HW_LCD_WIDTH;
_lcd_info.height = RT_HW_LCD_HEIGHT;
/* init device structure */
lcd.type = RT_Device_Class_Graphic;
lcd.init = rt_lcd_init;
lcd.open = rt_lcd_open;
lcd.close = rt_lcd_close;
lcd.read = NULL;
lcd.write = NULL;
lcd.control = rt_lcd_control;
lcd.user_data = (void *)&_lcd_info;
/* register lcd device to RT-Thread */
rt_device_register(&lcd, "lcd", RT_DEVICE_FLAG_RDWR);
return 0;
}
示例14: 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;
}
示例15: rt_hw_sd_mmc_init
void rt_hw_sd_mmc_init()
{
if (sd_mmc_spi_internal_init())
{
rt_uint8_t *sector = rt_malloc(MMC_SECTOR_SIZE);
sd_mmc_spi_read_open(0);
if (sd_mmc_spi_read_sector_to_ram(sector))
{
if (dfs_filesystem_get_partition(&sd_mmc_partition, sector, 0) != RT_EOK)
{
sd_mmc_partition.offset = 0;
sd_mmc_partition.size = 0;
}
}
else
{
sd_mmc_partition.offset = 0;
sd_mmc_partition.size = 0;
}
sd_mmc_spi_read_close();
rt_free(sector);
rt_device_register(&sd_mmc_device, "sd0", RT_DEVICE_FLAG_RDWR | RT_DEVICE_FLAG_REMOVABLE | RT_DEVICE_FLAG_STANDALONE);
}
else
{
rt_kprintf("Failed to initialize SD/MMC card.\n");
}
}