static struct worker *make_worker(void) { struct worker *q = (struct worker *)MALLOC(sizeof(*q), OTHER); os_sem_init(&q->ready); os_sem_init(&q->done); return q; }
__task void initTask(void){ //sem init os_sem_init(&semIncMin, 0); os_sem_init(&semKeyPress, 0); os_sem_init(&semIncHour, 0); os_sem_init(&semIncSec, 0); initTexts(); //mutex init os_mut_init(&mutTime); os_mut_init(&mut_msg_ptr); os_mut_init(&mut_msg_offset); //task init os_tsk_create(taskSerial, 0x82); os_tsk_create(clock_task, 0x90); os_tsk_create(taskIncHour, 0x7F); os_tsk_create(taskIncMin, 0x80); os_tsk_create(taskIncSec, 0x81); disTaskId = os_tsk_create(updateDisplay, 0x10); keyTaskId = os_tsk_create(key_task, 0x7E); joyTaskId = os_tsk_create(joy_task, 0x7D); //display stuff... os_evt_set(DIS_EVT_MSG_PTR, disTaskId); //end os_tsk_delete_self(); }
/***usart1.2发送数据 将测量结果提供给主板***/ __task void send_result(void) { u8 j=0; u8 send_i=0; os_sem_init(resultsem,0); while(1) { os_sem_wait(resultsem,0xffff); if(send_config==1) { for(j=view_detial[send_i][0]+1;j<view_detial[send_i][0]+4;j++) { itoa(view_detial[send_i][j],view_send,10); usart_send_str(USART1,view_send); usart_send_str(USART1," "); } } /*** ***/ else { itoa(refresh.yy,view_send,10); usart_send_str(USART1,view_send); usart_send_str(USART1," "); itoa(refresh.wj,view_send,10); usart_send_str(USART1,view_send); usart_send_str(USART1," "); itoa(refresh.yj,view_send,10); usart_send_str(USART1,view_send); usart_send_str(USART1," "); itoa(refresh.jb,view_send,10); usart_send_str(USART1,view_send); usart_send_str(USART1," "); } /*******/ // usart_send_str(USART1," "); // itoa(t1,view_send,10); // usart_send_str(USART1,view_send); // usart_send_str(USART1," "); // itoa(t2,view_send,10); // usart_send_str(USART1,view_send); /***调试 计数***/ memset(view_detial[send_i],0,106); send_i++; if(send_i==5) send_i=0; i++; itoa(i,view_send,10); usart_send_str(USART1," "); usart_send_str(USART1,view_send); /*** ***/ memset(view_send,0,10); usart_send_enter(USART1); } }
/** * init_tasks * * Called by main.c after sysinit(). This function performs initializations * that are required before tasks are running. * * @return int 0 success; error otherwise. */ static void init_tasks(void) { os_stack_t *pstack; (void)pstack; /* Initialize global test semaphore */ os_sem_init(&g_test_sem, 0); #if defined(SPI_MASTER) pstack = malloc(sizeof(os_stack_t)*TASK1_STACK_SIZE); assert(pstack); os_task_init(&task1, "spim", spim_task_handler, NULL, TASK1_PRIO, OS_WAIT_FOREVER, pstack, TASK1_STACK_SIZE); #endif #if defined(SPI_SLAVE) pstack = malloc(sizeof(os_stack_t)*TASK1_STACK_SIZE); assert(pstack); os_task_init(&task1, "spis", spis_task_handler, NULL, TASK1_PRIO, OS_WAIT_FOREVER, pstack, TASK1_STACK_SIZE); #endif }
/** * init_tasks * * Called by main.c after sysinit(). This function performs initializations * that are required before tasks are running. * * @return int 0 success; error otherwise. */ static void init_tasks(void) { os_stack_t *pstack; /* Initialize global test semaphore */ os_sem_init(&g_test_sem, 0); pstack = malloc(sizeof(os_stack_t)*TASK1_STACK_SIZE); assert(pstack); os_task_init(&task1, "task1", task1_handler, NULL, TASK1_PRIO, OS_WAIT_FOREVER, pstack, TASK1_STACK_SIZE); pstack = malloc(sizeof(os_stack_t)*TASK2_STACK_SIZE); assert(pstack); os_task_init(&task2, "task2", task2_handler, NULL, TASK2_PRIO, OS_WAIT_FOREVER, pstack, TASK2_STACK_SIZE); pstack = malloc(sizeof(os_stack_t)*TASK3_STACK_SIZE); assert(pstack); os_task_init(&task3, "task3", task3_handler, NULL, TASK3_PRIO, OS_WAIT_FOREVER, pstack, TASK3_STACK_SIZE); /* Initialize eventq and designate it as the default. Packages that need * to schedule work items will piggyback on this eventq. Example packages * which do this are sys/shell and mgmt/newtmgr. */ os_eventq_init(&slinky_oic_evq); os_eventq_dflt_set(&slinky_oic_evq); mgmt_evq_set(&slinky_oic_evq); }
static void wq_init(wq_t *wq) { wq->ev = 0; wq->wait = 0; os_thread_mutex_init(&wq->lock); os_sem_init(&wq->sem, 0); }
void semihost_init(void) { // Called from main task semihostEnabled = 0; os_sem_init(semihostStoppedSem,0); // Create semihost task semihostTask = os_tsk_create(sh_main, SEMIHOST_TASK_PRIORITY); return; }
/// Constructor. /// @param name device path to export (e.g. /dev/usbser0). /// @param vendor_id USB vendor ID to report /// @param product_id USB device ID to report /// @param product_release USB product version to report. MbedRawUSBSerial(const char* name, uint16_t vendor_id = 0x1f00, uint16_t product_id = 0x2012, uint16_t product_release = 0x0001) : USBCDC(vendor_id, product_id, product_release), Serial(name), txPending(false) { os_sem_init(&rxSem, 0); os_thread_t thread; os_thread_create(&thread, "usbserial.rx", 3, 1024, &_RxThread, this); }
/***上传测量数据任务 100ms上传一次***/ __task void upload_refresh_data(void) { u16 data[4]; os_sem_init(rfsem,0); memset(data,0,8); while(1) { os_sem_wait(rfsem,0xffff); data[0]=refresh.yy; data[1]=refresh.wj; data[2]=refresh.yj; data[3]=refresh.jb; usart_send_data(USART2,(u8 *)data,4); os_dly_wait(1000); os_sem_init(rfsem,0); } }
static void init_interrupt(struct lis2dw12_int * interrupt, struct sensor_int *ints) { os_error_t error; error = os_sem_init(&interrupt->wait, 0); assert(error == OS_OK); interrupt->active = false; interrupt->asleep = false; interrupt->ints = ints; }
/***假币报警***/ __task void single_jb(void) { os_sem_init(jbsem,0); while(1) { os_sem_wait(jbsem,0xffff); give_single_state(0); os_dly_wait(30); give_single_state(1); } }
LOG_HANDLE log_open(const char* url) { int ret, type; LOG_CTX* ctx = NULL; for(type=0; type<sizeof(map)/sizeof(map[0]); type++) { if(memcmp(map[type].name, url, strlen(map[type].name))==0) { ctx = (LOG_CTX*)malloc(sizeof(LOG_CTX)+map[type].size+map[type].tbuflen); memset(ctx, 0, sizeof(LOG_CTX)+map[type].size+map[type].tbuflen); break; } } if(ctx==NULL) return NULL; ctx->type = type; ctx->ptr = (void*)(ctx+1); if(map[type].tbuflen==0) { memset(&ctx->stream, 0, sizeof(ctx->stream)); return ctx; } ctx->stream.buf = (char*)ctx + sizeof(LOG_CTX) + map[type].size; ctx->stream.cur = 0; ctx->stream.len = 0; ctx->stream.max = map[type].tbuflen; os_sem_init(&ctx->stream.inque, 0); os_sem_init(&ctx->stream.ouque, 0); os_mutex_init(&ctx->stream.mtx); ctx->stream.inque_size = 0; ctx->stream.ouque_size = 0; ret = map[ctx->type].func_open(ctx, url+strlen(map[type].name)); if(ret!=ERR_NOERROR) { free(ctx); return NULL; } os_thread_begin(&ctx->stream.thread, log_thread, (void*)ctx); return ctx; }
/** * init_tasks * * Called by main.c after os_init(). This function performs initializations * that are required before tasks are running. * * @return int 0 success; error otherwise. */ int init_tasks(void) { /* Initialize global test semaphore */ os_sem_init(&g_test_sem, 0); os_task_init(&task1, "task1", task1_handler, NULL, TASK1_PRIO, OS_WAIT_FOREVER, stack1, TASK1_STACK_SIZE); os_task_init(&task2, "task2", task2_handler, NULL, TASK2_PRIO, OS_WAIT_FOREVER, stack2, TASK2_STACK_SIZE); tasks_initialized = 1; return 0; }
__task void u1recive(void) { // char str[20],*s="hello,word!"; u16 limit=0; os_sem_init(u1recsem,0); memset(u1rec_buff,0,20); // memset(str,0,20); default_setting(send_config); while(1) { analyze_u1rec_command(&send_config,&limit); if(limit!=0) limitup=limit; os_dly_wait(1000); } }
/** * init_tasks * * Called by main.c after sysinit(). This function performs initializations * that are required before tasks are running. * * @return int 0 success; error otherwise. */ static void init_tasks(void) { os_stack_t *pstack; /* Initialize global test semaphore */ os_sem_init(&g_test_sem, 0); pstack = malloc(sizeof(os_stack_t)*TASK1_STACK_SIZE); assert(pstack); os_task_init(&task1, "task1", task1_handler, NULL, TASK1_PRIO, OS_WAIT_FOREVER, pstack, TASK1_STACK_SIZE); pstack = malloc(sizeof(os_stack_t)*TASK2_STACK_SIZE); assert(pstack); os_task_init(&task2, "task2", task2_handler, NULL, TASK2_PRIO, OS_WAIT_FOREVER, pstack, TASK2_STACK_SIZE); }
int video_output_open(video_t **video, struct video_output_info *info) { struct video_output *out; pthread_mutexattr_t attr; if (!valid_video_params(info)) return VIDEO_OUTPUT_INVALIDPARAM; out = bzalloc(sizeof(struct video_output)); if (!out) goto fail; memcpy(&out->info, info, sizeof(struct video_output_info)); out->frame_time = (uint64_t)(1000000000.0 * (double)info->fps_den / (double)info->fps_num); out->initialized = false; if (pthread_mutexattr_init(&attr) != 0) goto fail; if (pthread_mutexattr_settype(&attr, PTHREAD_MUTEX_RECURSIVE) != 0) goto fail; if (pthread_mutex_init(&out->data_mutex, &attr) != 0) goto fail; if (pthread_mutex_init(&out->input_mutex, &attr) != 0) goto fail; if (os_sem_init(&out->update_semaphore, 0) != 0) goto fail; if (pthread_create(&out->thread, NULL, video_thread, out) != 0) goto fail; init_cache(out); out->initialized = true; *video = out; return VIDEO_OUTPUT_SUCCESS; fail: video_output_close(out); return VIDEO_OUTPUT_FAIL; }
static inline bool mp_media_init_internal(mp_media_t *m, const struct mp_media_info *info) { if (pthread_mutex_init(&m->mutex, NULL) != 0) { blog(LOG_WARNING, "MP: Failed to init mutex"); return false; } if (os_sem_init(&m->sem, 0) != 0) { blog(LOG_WARNING, "MP: Failed to init semaphore"); return false; } m->path = info->path ? bstrdup(info->path) : NULL; m->format_name = info->format ? bstrdup(info->format) : NULL; m->hw = info->hardware_decoding; if (pthread_create(&m->thread, NULL, mp_media_thread_start, m) != 0) { blog(LOG_WARNING, "MP: Could not create media thread"); return false; } m->thread_valid = true; return true; }
static inline bool reset_semaphore(struct rtmp_stream *stream) { os_sem_destroy(stream->send_sem); return os_sem_init(&stream->send_sem, 0) == 0; }
os_result os_procCreate( const char *executable_file, const char *name, const char *arguments, os_procAttr *procAttr, os_procId *procId) { int procTaskId; int sched_policy; os_result rv = os_resultSuccess; os_procContextData process_procContextData; os_int32 startRoutine = 0; os_int32 pOptions,privateSet; os_int32 len,i=0,n=0; char *converted = NULL; assert(executable_file != NULL); assert(name != NULL); assert(arguments != NULL); assert(procAttr != NULL); assert(procId != NULL); len = strlen(arguments); converted = (char*)os_malloc(len+1); for (; i < len ; i++) { if (arguments[i] != '\"') { converted[n] = arguments[i]; n++; } } converted[n] = '\0'; pOptions = 0; privateSet = 0; taskOptionsGet(taskIdSelf(),&pOptions); if ((pOptions & VX_PRIVATE_ENV) == 0) { envPrivateCreate(taskIdSelf(), 0); privateSet = 1; } putenv("SPLICE_NEW_PROCESS=no"); if (procAttr->schedClass == OS_SCHED_REALTIME) { sched_policy = SCHED_FIFO; } else if (procAttr->schedClass == OS_SCHED_TIMESHARE) { return os_resultInvalid; } else if (procAttr->schedClass == OS_SCHED_DEFAULT) { sched_policy = SCHED_OTHER; } else { return os_resultInvalid; } if ((procAttr->schedPriority > VXWORKS_PRIORITY_MIN) || (procAttr->schedPriority < VXWORKS_PRIORITY_MAX) ) { return os_resultInvalid; } { os_library binlib; os_libraryAttr attr; os_libraryAttrInit(&attr); /* Dynamic load of services is a special case, so try just static via os_libraryOpen */ attr.staticLibOnly=1; binlib = os_libraryOpen( executable_file, &attr); /* FIXME existing use of os_int32 for pointer is CRAZY!! */ if ( binlib != NULL ) { startRoutine = (os_int32)os_libraryGetSymbol( binlib, executable_file ); } if ( startRoutine == 0 && os_dynamicLibPlugin != NULL ) { startRoutine = (os_uint32)os_dynamicLibPlugin->dlp_loadLib( executable_file ); } if ( startRoutine == 0 ) { OS_REPORT(OS_ERROR, "os_procCreate", 1, "Unable to load %s (%s)", executable_file, name); rv = os_resultInvalid; } } if (rv == os_resultSuccess) { process_procContextData = (os_procContextData )os_malloc((size_t)OS_SIZEOF(os_procContextData)); if (process_procContextData == (os_procContextData) NULL) { OS_REPORT(OS_WARNING, "os_procCreate", 1, "malloc failed with error %d (%s, %s)", os_getErrno(), executable_file, name); rv = os_resultInvalid; } else { #if defined ( _WRS_VXWORKS_MAJOR ) && ( _WRS_VXWORKS_MAJOR > 6 ) || ( _WRS_VXWORKS_MAJOR == 6 && _WRS_VXWORKS_MINOR > 8 ) /* the blockParent semaphore is used to prevent this task exiting before the spawned task has completed copying its environ. */ os_sem_t blockParent; os_sem_init( &blockParent, 0); #endif os_procInit(process_procContextData, name, executable_file, converted); process_procContextData->procAttrPrio = procAttr->schedPriority; procTaskId = taskSpawn((char *)name, procAttr->schedPriority, VX_FP_TASK #if ! defined ( _WRS_VXWORKS_MAJOR ) || _WRS_VXWORKS_MAJOR < 6 || ( _WRS_VXWORKS_MAJOR == 6 && _WRS_VXWORKS_MINOR < 9 ) /* VX_PRIVATE_ENV flag is no longer functional in vxworks 6.9 */ | VX_PRIVATE_ENV #endif #if defined ( VXWORKS_55 ) || defined ( VXWORKS_54 ) | VX_STDIO | VX_DEALLOC_STACK #endif , VXWORKS_PROC_DEFAULT_STACK, (FUNCPTR)os_procWrapper, (int)process_procContextData, (int)process_procContextData->executable, (int)startRoutine, (int)process_procContextData->arguments, taskIdSelf(), #if ! defined ( _WRS_VXWORKS_MAJOR ) || _WRS_VXWORKS_MAJOR < 6 || ( _WRS_VXWORKS_MAJOR == 6 && _WRS_VXWORKS_MINOR < 9 ) 0, #else &blockParent, #endif 0, 0, 0, 0); #if defined ( _WRS_VXWORKS_MAJOR ) && ( _WRS_VXWORKS_MAJOR > 6 || ( _WRS_VXWORKS_MAJOR == 6 && _WRS_VXWORKS_MINOR > 8 ) ) os_sem_wait(&blockParent); os_sem_destroy(&blockParent); #endif if (procTaskId == ERROR) { os_free(process_procContextData); rv = os_resultInvalid; } else { *procId = *(os_procId *)&process_procContextData; rv = os_resultSuccess; } } } putenv("SPLICE_NEW_PROCESS=empty"); if ( privateSet == 1) { envPrivateDestroy(taskIdSelf()); } os_free(converted); return rv; }
void GUI_X_InitOS(void) { os_sem_init(GUI_Semaphore, 1); }
/** * sem test basic * * Basic semaphore tests * * @return int */ static void sem_test_basic_handler(void *arg) { struct os_task *t; struct os_sem *sem; os_error_t err; sem = &g_sem1; t = os_sched_get_current_task(); /* Test some error cases */ TEST_ASSERT(os_sem_init(NULL, 1) == OS_INVALID_PARM); TEST_ASSERT(os_sem_delete(NULL) == OS_INVALID_PARM); TEST_ASSERT(os_sem_release(NULL) == OS_INVALID_PARM); TEST_ASSERT(os_sem_pend(NULL, 1) == OS_INVALID_PARM); /* Get the semaphore */ err = os_sem_pend(sem, 0); TEST_ASSERT(err == 0, "Did not get free semaphore immediately (err=%d)", err); /* Check semaphore internals */ TEST_ASSERT(sem->sem_tokens == 0 && SLIST_EMPTY(&sem->sem_head), "Semaphore internals wrong after getting semaphore\n" "%s\n" "Task: task=%p prio=%u", sem_test_sem_to_s(sem), t, t->t_prio); /* Get the semaphore again; should fail */ err = os_sem_pend(sem, 0); TEST_ASSERT(err == OS_TIMEOUT, "Did not time out waiting for semaphore (err=%d)", err); /* Check semaphore internals */ TEST_ASSERT(sem->sem_tokens == 0 && SLIST_EMPTY(&sem->sem_head), "Semaphore internals wrong after getting semaphore\n" "%s\n" "Task: task=%p prio=%u\n", sem_test_sem_to_s(sem), t, t->t_prio); /* Release semaphore */ err = os_sem_release(sem); TEST_ASSERT(err == 0, "Could not release semaphore I own (err=%d)", err); /* Check semaphore internals */ TEST_ASSERT(sem->sem_tokens == 1 && SLIST_EMPTY(&sem->sem_head), "Semaphore internals wrong after releasing semaphore\n" "%s\n" "Task: task=%p prio=%u\n", sem_test_sem_to_s(sem), t, t->t_prio); /* Release it again */ err = os_sem_release(sem); TEST_ASSERT(err == 0, "Could not release semaphore again (err=%d)\n", err); /* Check semaphore internals */ TEST_ASSERT(sem->sem_tokens == 2 && SLIST_EMPTY(&sem->sem_head), "Semaphore internals wrong after releasing semaphore\n" "%s\n" "Task: task=%p prio=%u\n", sem_test_sem_to_s(sem), t, t->t_prio); /* "Delete" it */ err = os_sem_delete(sem); TEST_ASSERT(err == 0, "Could not delete semaphore (err=%d)", err); /* Check semaphore internals */ TEST_ASSERT(sem->sem_tokens == 0 && SLIST_EMPTY(&sem->sem_head), "Semaphore internals wrong after deleting semaphore\n" "%s\n" "Task: task=%p prio=%u\n", sem_test_sem_to_s(sem), t, t->t_prio); os_test_restart(); }
/* ********************************************************* * * void os_mbox_init( os_mail_t *MBox ) * initialize a Mailbox */ void os_mbox_init( os_mail_t *MBox ) { os_sem_init( &MBox->mbox_sem ); MBox->msg_queue.next = MBox->msg_queue.last = (k_list_t *)MBox; }
/* A new device is handled by the server, do the init operations in order to make the device usable */ int export_device(const exa_uuid_t *uuid, char *device_path) { device_t *dev; int i, err; /* If device was already exported, do nothing */ if (find_device_from_uuid(uuid) != NULL) return EXA_SUCCESS; dev = os_malloc(sizeof(struct device)); if (dev == NULL) { err = -NBD_ERR_MALLOC_FAILED; goto error; } dev->handle = NULL; err = -CMD_EXP_ERR_OPEN_DEVICE; dev->handle = exa_rdev_handle_alloc(device_path); if (dev->handle == NULL) goto error; err = get_nb_sectors(device_path, &dev->size_in_sectors); if (err != EXA_SUCCESS) goto error; uuid_copy(&dev->uuid, uuid); strlcpy(dev->path, device_path, sizeof(dev->path)); for (i = 0; i < NBMAX_DISKS_PER_NODE; i++) if (nbd_server.devices[i] == NULL) break; if (i >= NBMAX_DISKS_PER_NODE) { exalog_error("maximum number of exportable devices exceeded"); err = -NBD_ERR_NB_RDEVS_CREATED; } dev->dev_index = i; dev->exit_thread = false; nbd_init_list(&nbd_server.list_root, &dev->disk_queue); /* resource needed to lock/unlock a zone */ os_sem_init (&dev->lock_sem_disk, 0); /* launch disk thread (TD) */ if (!exathread_create_named(&nbd_server.td_pid[dev->dev_index], NBD_THREAD_STACK_SIZE + MIN_THREAD_STACK_SIZE, exa_td_main, dev, "TD_thread")) { os_sem_destroy(&dev->lock_sem_disk); err = -NBD_ERR_THREAD_CREATION; goto error; } nbd_server.devices[dev->dev_index] = dev; return EXA_SUCCESS; error: if (dev != NULL) { if (dev->handle != NULL) exa_rdev_handle_free(dev->handle); os_free(dev); } return err; }
/***接收ad转换数据 读取传感器数值 测量硬币种类***/ __task void get_adc_value(void) { u8 bf=0,read_flash[2],dia_b=0,n; u16 adc_data=0,clear_config=0; u32 adc_buff=0; os_sem_init(adcsem,0); memset(view_detial,0,530); memset(view_send,0,10); memset(read_flash,0,4); ReadFlashNByte(0,read_flash,2); limitup=read_flash[0]+read_flash[1]*256; if(limitup==0||limitup==0xffff) limitup=7500; while(1) { // os_sem_wait(adcsem,0xffff); while(1) { adc_value1=spi_readwrite_byte(SPI1,adc_data); adc_value=change_data(adc_value1); if((1000<adc_value&&adc_value<7500)) break; clear_config++; if(clear_config==50000) { clear_config=0; memset(&refresh,0,8); i=0; //5秒种没有硬币就将计数清零 } os_dly_wait(1); } GPIO_ResetBits(GPIOC,GPIO_Pin_5); os_sem_send(iosem); TIM_Cmd(TIM4,ENABLE); value_count=0; // while(add_count<25) // { while(adc_value<7500) // while(1) { adc_buff=adc_buff+adc_value; add_count++; //采样次数 0.2ms一次 view_detial[view_i][add_count]=adc_value; os_dly_wait(1); adc_value=spi_readwrite_byte(SPI1,adc_data); adc_value=change_data(adc_value); // if(count==50) // break; if(add_count==49) break; } // } // view_detial[view_i][add_count+2]=count; //view_detial数据位后面第二位是金属传感器检测的时间 // count=0; GPIO_SetBits(GPIOC,GPIO_Pin_5); adc_buff=adc_buff/add_count; if(add_count>20) { dia_b=(add_count/2)-2; adc_buff=0; for(n=0;n<5;n++) adc_buff=view_detial[view_i][dia_b+n]+adc_buff; adc_buff=adc_buff/5; } else adc_buff=8888; //调试看数据 view_detial[view_i][0]=add_count; //对金属传感器采样的详细数据个数 view_detial[view_i][add_count+1]=adc_buff; //view_detial数据位后面第一位是对金属传感器采样得到数据的平均值 //*** coin_kind[bf]=deal_value(adc_buff); //比较金属传感器的电压值,得出币种 // if(view_detial[view_i][10]>6000) // coin_kind[bf]=0; view_i++; if(view_i==5) view_i=0; bf++; if(bf==5) bf=0; adc_buff=0; add_count=0; clear_config=0; // os_sem_send(iosem); // os_sem_send(resultsem); } }
/***读取IO状态 对IO特定状态计时 测量硬币直径***/ __task void io_keep_time(void) { u8 bf=0,n=0; os_sem_init(iosem,0); while(1) { os_sem_wait(iosem,0xffff); /***光钎传感器 测直径***/ while(1) { if(get_diasensor_state()==0) { TIM_Cmd(TIM2,ENABLE); TIM_Cmd(TIM4,DISABLE); value_count=0; break; } iotask_overtime(); os_dly_wait(1); } while(1) { if(get_diasensor_state()==1) { TIM_Cmd(TIM2,DISABLE); n=view_detial[view_j][0]; view_detial[view_j][n+2]=count; //view_detial数据位后面第三位是光钎传感器测得的时间 t2=count; count=0; break; } os_dly_wait(1); } /*** ***/ if(coin_kind[bf]!=0) { if(coin_kind[bf]==1&&deal_time(t2)==1) coin_kind[bf]=1; //比较通过时间长度 得出币种 else if(coin_kind[bf]==2&&deal_time(t2)>1) { coin_kind[bf]=deal_time(t2); } else coin_kind[bf]=0; } b_kind=coin_kind[bf]; bf++; if(bf==5) bf=0; view_detial[view_j][n+3]=b_kind; view_j++; if(view_j==5) view_j=0; deal_coin(b_kind); // b_kind=0; if(b_kind==0) os_sem_send(jbsem); // no_i=0; // os_sem_send(rfsem); os_sem_send(resultsem); } }