static void rt_usb_vcom_init(struct ufunction *func) { rt_err_t result = RT_EOK; struct serial_configure config; struct vcom *data = (struct vcom*)func->user_data; /* initialize ring buffer */ rt_ringbuffer_init(&data->rx_ringbuffer, data->rx_rbp, CDC_RX_BUFSIZE); config.baud_rate = BAUD_RATE_115200; config.bit_order = BIT_ORDER_LSB; config.data_bits = DATA_BITS_8; config.parity = PARITY_NONE; config.stop_bits = STOP_BITS_1; config.invert = NRZ_NORMAL; data->serial.ops = &usb_vcom_ops; data->serial.int_rx = &data->vcom_int_rx; data->serial.config = config; /* register vcom device */ rt_hw_serial_register(&data->serial, VCOM_DEVICE, RT_DEVICE_FLAG_RDWR | RT_DEVICE_FLAG_INT_RX | RT_DEVICE_FLAG_INT_TX, func); /* create an vcom message queue */ rt_mq_init(&vcom_tx_thread_mq, "vcomq", vcom_tx_thread_mq_pool, VCOM_MQ_MSG_SZ, sizeof(vcom_tx_thread_mq_pool), RT_IPC_FLAG_FIFO); /* init usb device thread */ rt_thread_init(&vcom_thread, "vcom", vcom_tx_thread_entry, RT_NULL, vcom_thread_stack, 512, 8, 20); result = rt_thread_startup(&vcom_thread); RT_ASSERT(result == RT_EOK); }
/*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 ); }
int LCDPANELProcessInit(void) { rt_thread_t init_thread; rt_err_t result = RT_EOK; // 创建消息队列,分配队列存储空间 result = rt_mq_init(&rx_mq, "mqt", &msg_pool[0], 32 - sizeof(void*), sizeof(msg_pool), RT_IPC_FLAG_FIFO); if (result != RT_EOK) { rt_kprintf("init message queue failed.\n"); return result; } IWDG_WriteAccessCmd(IWDG_WriteAccess_Enable); // Enable write access to IWDG_PR and IWDG_RLR registers IWDG_SetPrescaler(IWDG_Prescaler_32); // IWDG counter clock: 40KHz(LSI) / 32 = 1.25 KHz IWDG_SetReload(1250); // Set counter reload value to 1250 IWDG_ReloadCounter(); // Reload IWDG counter // IWDG_Enable(); // Enable IWDG (the LSI oscillator will be enabled by hardware) init_thread = rt_thread_create( "lcdpanel", LCDPANELProcess_thread_entry, RT_NULL, 2048,10,10); if( init_thread != RT_NULL ) { rt_thread_startup(init_thread); } return 0; }
int rt_application_init(void) { rt_thread_t init_thread; rt_mq_init(&mq, "mqt", &msg_pool[0], 128 - sizeof(void*), sizeof(msg_pool), RT_IPC_FLAG_FIFO); init_thread = rt_thread_create("init", rt_init_thread_entry, RT_NULL, 1024, 21, 20); if(init_thread != RT_NULL) rt_thread_startup(init_thread); return 0; }
/* init gsm */ void _gsm_startup(void) { rt_err_t result; // 二. RT 相关初始化 //------------- sem init --------------------------------- // 创建DF 读写信号量 rt_sem_init( &sem_DF, "sem_DF", 0, 0 ); rt_sem_release( &sem_DF); rt_mq_init( &mq_GSM, "mq_GSM", &GSM_rawinfo[0], 1400 - sizeof( void * ), GSM_RAWINFO_SIZE, RT_IPC_FLAG_FIFO ); //--------- timer_gsm ---------- // 1. create timer 100ms=Dur timer_gsm = rt_timer_create("tim_gsm", timeout_gsm, RT_NULL, 100, RT_TIMER_FLAG_PERIODIC); //| RT_TIMER_FLAG_SOFT_TIMER); // 2. start timer if(timer_gsm != RT_NULL) rt_timer_start(timer_gsm); result = rt_thread_init(&gsm_thread, "GsmThrd", gsm_thread_entry, RT_NULL, &gsm_thread_stack[0], sizeof(gsm_thread_stack), Prio_GSM, 10); if (result == RT_EOK) { rt_thread_startup(&gsm_thread); } Device_GSM.type = RT_Device_Class_Char; Device_GSM.init = Device_GSM_init; Device_GSM.open = Device_GSM_open; Device_GSM.close = Device_GSM_close; Device_GSM.read = Device_GSM_read; Device_GSM.write = Device_GSM_write; Device_GSM.control = Device_GSM_control; rt_device_register( &Device_GSM, "GsmDev", RT_DEVICE_FLAG_RDWR | RT_DEVICE_FLAG_STANDALONE ); rt_device_init( &Device_GSM ); }
FtkSource* ftk_source_touch_create(const char* filename, FtkOnEvent on_event, void* user_data) { FtkSource* thiz = (FtkSource*)FTK_ZALLOC(sizeof(FtkSource) + sizeof(PrivInfo)); rt_device_t device = NULL; if (thiz != NULL) { DECL_PRIV(thiz, priv); thiz->get_fd = ftk_source_touch_get_fd; thiz->check = ftk_source_touch_check; thiz->dispatch = ftk_source_touch_dispatch; thiz->destroy = ftk_source_touch_destroy; thiz->ref = 1; priv->device = rt_device_find(filename); if (priv->device == NULL) { FTK_ZFREE(thiz, sizeof(thiz) + sizeof(PrivInfo)); return NULL; } rt_device_open(priv->device, 0); rt_device_control(priv->device, RT_TOUCH_EVENTPOST, ftk_source_touch_eventpost); rt_device_control(priv->device, RT_TOUCH_EVENTPOST_PARAM, thiz); rt_mq_init(&priv->mq, "tspipe", &priv->pipe[0], 64, sizeof(priv->pipe), RT_IPC_FLAG_FIFO); priv->fd = ftk_rtthread_select_fd_alloc(); priv->on_event = on_event; priv->user_data = user_data; ftk_logd("%s: %d=%s priv->user_data=%p\n", __func__, priv->fd, filename, priv->user_data); } return thiz; }
/*gps设备初始化*/ void gps_init( void ) { //rt_sem_init( &sem_gps, "sem_gps", 0, 0 ); rt_mq_init( &mq_gps, "mq_gps", &gps_rawinfo[0], 128 - sizeof( void* ), GPS_RAWINFO_SIZE, RT_IPC_FLAG_FIFO ); rt_thread_init( &thread_gps, "gps", rt_thread_entry_gps, RT_NULL, &thread_gps_stack[0], sizeof( thread_gps_stack ), Prio_GPS, 5 ); rt_thread_startup( &thread_gps ); dev_gps.type = RT_Device_Class_Char; dev_gps.init = dev_gps_init; dev_gps.open = dev_gps_open; dev_gps.close = dev_gps_close; dev_gps.read = dev_gps_read; dev_gps.write = dev_gps_write; dev_gps.control = dev_gps_control; rt_device_register( &dev_gps, "gps", RT_DEVICE_FLAG_RDWR | RT_DEVICE_FLAG_STANDALONE ); rt_device_init( &dev_gps ); }