/** * Create a Notifier for timer event notification. * @param handler The handler is called at the notification time which is set * using StartSingle or StartPeriodic. */ Notifier::Notifier(TimerEventHandler handler, void *param) { if (handler == NULL) wpi_setWPIErrorWithContext(NullParameter, "handler must not be NULL"); m_handler = handler; m_param = param; m_periodic = false; m_expirationTime = 0; m_period = 0; m_nextEvent = NULL; m_queued = false; m_handlerSemaphore = semBCreate(SEM_Q_PRIORITY, SEM_FULL); if (queueSemaphore == NULL) { queueSemaphore = semBCreate(SEM_Q_PRIORITY, SEM_FULL); } tRioStatusCode localStatus = NiFpga_Status_Success; { Synchronized sync(queueSemaphore); // do the first time intialization of static variables if (refcount == 0) { manager = new tInterruptManager(1 << kTimerInterruptNumber, false, &localStatus); manager->registerHandler(ProcessQueue, NULL, &localStatus); manager->enable(&localStatus); talarm = tAlarm::create(&localStatus); } refcount++; } wpi_setError(localStatus); }
/** * @brief Initializes semaphors for joysticks and switches, and starts the Proxy166 task. */ Proxy166::Proxy166(void): driveStickRight(T166_DRIVER_STICK_LEFT), // USB port for 1st stick driveStickLeft(T166_DRIVER_STICK_RIGHT), // USB port for 2nd stick driveStickCopilot(T166_COPILOT_STICK), Banner(0), Inclinometer(0), SonarDistance(0.0), CameraBearing(90), areSettingJoysticks(true) { ProxyHandle = this; // initialize memory for banner // note use of semaphores are commented out for now // they are not required for atomic actions // and they appeared to be causing tasks to crash for(unsigned i=0;i<NUMBER_OF_JOYSTICKS;i++) { // Initializing semaphores for joysticks JoystickLocks[i] = semBCreate(SEM_Q_PRIORITY, SEM_FULL); Joysticks[i] = ProxyJoystick(); } for(unsigned i=0;i<NUMBER_OF_SWITCHES;i++) { // Initializing semaphores for switches SwitchLocks[i] = semBCreate(SEM_Q_PRIORITY, SEM_FULL); } // Set the initial distance // Start the actual task Start((char *)"166ProxyTask", PROXY_CYCLE_TIME); }
void main (void) { /* Add your code here: create tasks, semaphores, ... */ initHardware(0); analogInputs = semBCreate (SEM_Q_PRIORITY, SEM_FULL); writeDisplay = semBCreate (SEM_Q_PRIORITY, SEM_FULL); int readInputsID; readInputsID = taskSpawn ("readInputs", 150, 0,0x1000,(FUNCPTR) readInputs,0,0,0,0,0,0,0,0,0,0); int showInputsID; showInputsID = taskSpawn ("showInputs", 160, 0,0x1000,(FUNCPTR) showInputs,0,0,0,0,0,0,0,0,0,0); int readKeyboardID; readKeyboardID = taskSpawn ("readKeyboard", 170, 0,0x1000,(FUNCPTR) readKeyboard,0,0,0,0,0,0,0,0,0,0); int timerID; timerID = taskSpawn ("timer", 140, 0,0x1000,(FUNCPTR) timer,0,0,0,0,0,0,0,0,0,0); int tcpServerID; tcpServerID = taskSpawn ("tcpServer", 200, 0,0x1000,(FUNCPTR) tcpServer,0,0,0,0,0,0,0,0,0,0); printf("Hello World"); /* Suspend own task */ taskSuspend (0); } /* main */
SimpleMonitor* SimpleMonitorCreate() { int ticksPerMs = CLOCKS_PER_SEC / 1000; MAX_SIMPLE_CONDVAR_WAIT_MS = SQUAWK_MAXINT / ticksPerMs; SimpleMonitor* mon = (SimpleMonitor*)malloc(sizeof(SimpleMonitor)); mon->mu = semBCreate(SEM_Q_PRIORITY, SEM_FULL); mon->cv = semBCreate(SEM_Q_PRIORITY, SEM_EMPTY); mon->lockCount = 0; return mon; }
Telnet :: Telnet() { printf("telnet Konstruktor!\n\r"); analogInputs = semBCreate (SEM_Q_PRIORITY, SEM_FULL); writeDisplay = semBCreate (SEM_Q_PRIORITY, SEM_FULL); int tcpServerID; tcpServerID = taskSpawn ("tcpServer", 200, 0,0x1000,(FUNCPTR) tcpServer,0,0,0,0,0,0,0,0,0,0); return; }
Diagnostics::Diagnostics() { m_buf = m_buf_a; m_buf_len = 0; m_log = fopen("/3322-diag.txt", "w"); m_task = new Task("3322Diagnostics", (FUNCPTR)Diagnostics::InitTask); m_flushing = semBCreate(SEM_Q_PRIORITY, SEM_EMPTY); m_writing = semBCreate(SEM_Q_PRIORITY, SEM_FULL); if (!m_task->Start((INT32)this)) { // FIXME: how to use WPI error handling? } SmartDashboard::init(); }
/* ★描述 : 创建一颗有序平衡二叉树 ★参数描述: keyCompareFunc:比较两个节点的大小(关键字的比较) ★返回值 : 成功 : 平衡二叉树的指针 失败 : 空指针 *******************************************************************/ tAVLTree *avlTreeCreate(int *keyCompareFunc,int *freeFunc) { tAVLTree *pTree = (tAVLTree *)0; if(!keyCompareFunc || !freeFunc) return (tAVLTree *)0; pTree = (tAVLTree *)malloc(sizeof(tAVLTree)); if(pTree != (tAVLTree *)0) { memset((void *)pTree , 0 , sizeof(tAVLTree)); pTree->keyCompare = (void *)keyCompareFunc; pTree->free = (void *)freeFunc; #ifdef ORDER_LIST_WANTED pTree->pListHeader = pTree->pListTail = AVL_NULL; #endif #if OS==3 || OS==4 pTree->sem = semBCreate(0 , 1); if(!pTree->sem) { free((void *)pTree); return (tAVLTree *)0; } #endif } return (tAVLTree *)pTree; }
int pocoregress_init() { long t1, t2; WDOG_ID wd; wd = wdCreate(); if (!wd) { logMsg("cannot create watchdog\n"); return 0; } sem = semBCreate(0, SEM_EMPTY); if (!sem) { logMsg("cannot create semaphore\n"); return 0; } logMsg("waiting %d ticks...\n", 10); t1 = tickGet(); wdStart(wd, 10, wddone, 0); semTake(sem, WAIT_FOREVER); t2 = tickGet(); logMsg("watchodog triggered after %d ticks (should be %d)\n", t2-t1, 10); wdDelete(wd); return 0; }
/* * Initialize Barrier semaphore and interval value * * Author Greg Brissey 8/18/05 * */ initBarrier(int uploadcnt) { if (pBarrierWaitSem == NULL) pBarrierWaitSem = semBCreate(SEM_Q_FIFO,SEM_EMPTY); uploadSyncCount = uploadSyncCntDown = uploadcnt; }
int taskResponseTest(void) { struct sigaction newAction; //init signal newAction.sa_handler = Action; //set the new handler sigemptyset(&newAction.sa_mask); //no other signals blocked newAction.sa_flags = 0; //no special options if(sigaction(SIGINT, &newAction, NULL) == -1) printf("Could not install signal handler\n"); //init semaphore semMutex = semBCreate(SEM_Q_PRIORITY, SEM_EMPTY); //create task A and B if((taskRTA = taskCreate("taskRTA", 100, NULL, STACK_SIZE, (FUNCPTR)TaskRTA, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0)) == NULL) printf("Could not create task A\n"); if((taskRTB = taskCreate("taskRTB", 99, NULL, STACK_SIZE, (FUNCPTR)TaskRTB, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0)) == NULL ) printf("Could not create task B\n"); taskRTMaster = taskIdSelf(); //resume task B taskResume(taskRTB); //resume task A taskResume(taskRTA); printf("It is task response test.\n"); return 0; }
// ADC初始化 void adc_init(void) { SysCtlPeripheralEnable(SYSCTL_PERIPH_ADC); //使能ADC模块 SysCtlADCSpeedSet(SYSCTL_ADCSPEED_500KSPS); //设置ADC采样速率 ADCSequenceDisable(ADC_BASE, 0); // 配置前先禁止采样序列 ADCSequenceConfigure(ADC_BASE, 0, ADC_TRIGGER_PROCESSOR, 0); //配置ADC采样序列的触发事件和优先级:ADC基址,采样序列编号,触发事件,采样优先级 ADCSequenceStepConfigure(ADC_BASE, 0, 0, ADC_CTL_END | ADC_CTL_CH0 | ADC_CTL_IE); //配置ADC采样序列发生器的步进 :ADC基址,采样序列编号,步值,通道设置 intConnect(INT_ADC0, ADC_Sequence_0_ISR, 0u); ADCIntEnable(ADC_BASE, 0); //使能ADC采样序列的中断 // IntEnable(INT_ADC0); // 使能ADC采样序列中断 intEnable(INT_ADC0); IntMasterEnable(); // 使能处理器中断 ADCSequenceEnable(ADC_BASE, 0); // 使能一个ADC采样序列 the_lock = semBCreate(0); // printf("%x\n", the_lock); }
/* Test routine, increase avg. cpu load by exactly 50% */ int cpuBurnLoad50(int seconds) { test_wd = wdCreate(); if (!test_wd) { printf("Error: cannot create watchdog timer\n"); return -1; } test_sem = semBCreate(SEM_Q_FIFO, SEM_EMPTY); if (!test_sem) { printf("Error: cannot create semaphore\n"); wdDelete(test_wd); return -1; } test_ticks = seconds*sysClkRateGet(); test_burn = FALSE; wdStart(test_wd, 1, testTick, 0); while (test_ticks) { /* sleep for one tick */ semTake(test_sem, WAIT_FOREVER); /* burn cpu for one tick */ while (test_burn) { test_counter++; } } semDelete(test_sem); wdDelete(test_wd); return 0; }
PUBLIC IX_STATUS ixOsalMutexInit (IxOsalMutex * mutex) { *mutex = (IxOsalMutex) semBCreate (SEM_Q_PRIORITY, SEM_FULL); return *mutex != NULL ? IX_SUCCESS : IX_FAIL; }
static void rootTask(long a0, long a1, long a2, long a3, long a4, long a5, long a6, long a7, long a8, long a9) { int ret; traceobj_enter(&trobj); traceobj_mark(&trobj, 1); sem_id = semBCreate(SEM_Q_FIFO, SEM_FULL); traceobj_assert(&trobj, sem_id != 0); ret = semGive(sem_id); traceobj_assert(&trobj, ret == OK); traceobj_mark(&trobj, 2); ret = semTake(sem_id, NO_WAIT); traceobj_assert(&trobj, ret == OK); traceobj_mark(&trobj, 3); ret = semTake(sem_id, WAIT_FOREVER); traceobj_assert(&trobj, ret == ERROR && errno == S_objLib_OBJ_DELETED); traceobj_mark(&trobj, 4); traceobj_exit(&trobj); }
/** * Allocate a PID object with the given constants for P, I, D * @param Kp the proportional coefficient * @param Ki the integral coefficient * @param Kd the derivative coefficient * @param source The PIDSource object that is used to get values * @param output The PIDOutput object that is set to the output value * @param period the loop time for doing calculations. This particularly effects calculations of the * integral and differental terms. The default is 50ms. */ PIDController::PIDController(float Kp, float Ki, float Kd, PIDSource *source, PIDOutput *output, float period) : m_semaphore (0) { m_semaphore = semBCreate(SEM_Q_PRIORITY, SEM_FULL); m_controlLoop = new Notifier(PIDController::CallCalculate, this); m_P = Kp; m_I = Ki; m_D = Kd; m_maximumOutput = 1.0; m_minimumOutput = -1.0; m_maximumInput = 0; m_minimumInput = 0; m_continuous = false; m_enabled = false; m_setpoint = 0; m_prevError = 0; m_totalError = 0; m_tolerance = .05; m_result = 0; m_pidInput = source; m_pidOutput = output; m_period = period; m_controlLoop->StartPeriodic(m_period); }
RobotTelemetry::RobotTelemetry() { isEnabled = false; robotDiagnostics = new RobotTelemetryData(); mRobotTelemetry = semBCreate(SEM_Q_FIFO,SEM_FULL); startTime = GetFPGATime(); initTelemetryData(); }
static tEplKernel EplApiProcessImageCreateCompletion( tEplApiProcessImageCopyJobInt* pCopyJob_p) { tEplKernel Ret = kEplSuccessful; #if (TARGET_SYSTEM == _LINUX_) && defined(__KERNEL__) pCopyJob_p->m_Event.m_pCompletion = EPL_MALLOC(sizeof (*pCopyJob_p->m_Event.m_pCompletion)); if (pCopyJob_p->m_Event.m_pCompletion == NULL) { Ret = kEplApiPIOutOfMemory; goto Exit; } init_completion(&pCopyJob_p->m_Event.m_pCompletion->m_Completion); kref_init(&pCopyJob_p->m_Event.m_pCompletion->m_Kref); // increment ref counter once again for copy job queue reader kref_get(&pCopyJob_p->m_Event.m_pCompletion->m_Kref); EPL_MEMSET (pCopyJob_p->m_Event.m_pCompletion->m_apPageIn, 0, sizeof (pCopyJob_p->m_Event.m_pCompletion->m_apPageIn)); EPL_MEMSET (pCopyJob_p->m_Event.m_pCompletion->m_apPageOut, 0, sizeof (pCopyJob_p->m_Event.m_pCompletion->m_apPageOut)); // fetch page pointers for userspace memory Ret = EplApiProcessImageGetUserPages(&EplApiProcessImageInstance_g.m_In, &pCopyJob_p->m_CopyJob.m_In, FALSE, pCopyJob_p->m_Event.m_pCompletion->m_apPageIn); if (Ret != kEplSuccessful) { goto Exit; } Ret = EplApiProcessImageGetUserPages(&EplApiProcessImageInstance_g.m_Out, &pCopyJob_p->m_CopyJob.m_Out, TRUE, pCopyJob_p->m_Event.m_pCompletion->m_apPageOut); if (Ret != kEplSuccessful) { goto Exit; } #elif (TARGET_SYSTEM == _LINUX_) && !defined(__KERNEL__) sem_init(&pCopyJob_p->m_Event.m_semCompletion, 0, 0); #elif (TARGET_SYSTEM == _WIN32_) pCopyJob_p->m_Event.m_hEvent = CreateEvent(NULL, FALSE, FALSE, NULL); #elif (TARGET_SYSTEM == _VXWORKS_) if ((pCopyJob_p->m_Event.m_semCompletion = semBCreate(SEM_Q_FIFO, SEM_EMPTY)) == NULL) { Ret = kEplNoResource; } #else #error "OS currently not supported by EplApiProcessImage!" #endif #if (TARGET_SYSTEM == _LINUX_) && defined(__KERNEL__) Exit: #endif return Ret; }
bhs_MutexRobot::bhs_MutexRobot() : m_robot() , m_disabledInitialized(false) , m_autonomousInitialized(false) , m_teleopInitialized(false) , m_period(k_defaultPeriod) { // configure for round-robin scheduling kernelTimeSlice(sysClkRateGet() / 100); // 1/100th of a second - what each task gets for time slice //taskDelay(sysClkRateGet() / 2); // create mutex for sync m_startSem = semBCreate(SEM_Q_FIFO, SEM_EMPTY); m_periodSem = semBCreate(SEM_Q_FIFO, SEM_EMPTY); // start timer tasks taskSpawn("BHS_Timer_Task", 0, 0, 20000, (FUNCPTR) bhs_MutexRobot::timerTask, (int) this, 0, 0, 0, 0, 0, 0, 0, 0, 0); }
void rtExtModeTornadoStartup(RTWExtModeInfo *ei, int_T numSampTimes, boolean_T *stopReqPtr, int_T priority, int32_T stack_size, SEM_ID startStopSem) { uploadSem = semBCreate(SEM_Q_PRIORITY, SEM_EMPTY); commSem = semBCreate(SEM_Q_PRIORITY, SEM_FULL); pktSem = semBCreate(SEM_Q_PRIORITY, SEM_FULL); rt_ExtModeInit(); extern_pkt_tid = taskSpawn("tExternPkt", priority+(numSampTimes), VX_FP_TASK, stack_size, (FUNCPTR)rt_PktServer, (int_T) ei, (int_T) numSampTimes, (int_T) stopReqPtr, 0, 0, 0, 0, 0, 0, 0); if (extern_pkt_tid == ERROR) { #ifndef EXTMODE_DISABLEPRINTF printf("handle taskpawn error"); #endif } extern_upload_tid = taskSpawn("tExternUpload", priority+(numSampTimes)+1,VX_FP_TASK, stack_size,(FUNCPTR)rt_UploadServer, (int_T) numSampTimes, 0, 0, 0, 0, 0, 0, 0, 0, 0); if (extern_upload_tid == ERROR) { #ifndef EXTMODE_DISABLEPRINTF printf("handle taskpawn error"); #endif } /* * Pause until receive model start packet - if external mode. * Make sure the external mode tasks are running so that * we are listening for commands from the host. */ if (ExtWaitForStartPkt()) { #ifndef EXTMODE_DISABLEPRINTF printf("\nWaiting for start packet from host.\n"); #endif semTake(startStopSem, WAIT_FOREVER); } modelStatus = TARGET_STATUS_RUNNING; }
static void install_fifo_finished(void) { if (!finished_sem) { finished_sem = semBCreate(SEM_Q_FIFO,SEM_EMPTY); fpgaIntConnect(handle_fifo_finished,0,1<<RF_fifo_finished_status_pos); fpgaIntConnect(handle_fifo_finished,1,1<<RF_fifo_underflow_status_pos); fpgaIntConnect(handle_fifo_finished,2,1<<RF_fifo_overflow_status_pos); } }
/***************************************************************************** ** user system initialization *****************************************************************************/ void user_sysinit( void ) { printf( "\r\nCreating Queue QUEUE2" ); errno = 0; queue2_id = msgQCreate( 1, 128, MSG_Q_PRIORITY ); if ( errno != OK ) printf( "... returned error %x\r\n", errno ); printf( "\r\nCreating Queue QUEUE3" ); errno = 0; queue3_id = msgQCreate( 3, 128, MSG_Q_FIFO ); if ( errno != OK ) printf( "... returned error %x\r\n", errno ); printf( "\r\nCreating Semaphore SEM2" ); errno = 0; sema42_id = semBCreate( SEM_Q_FIFO, SEM_EMPTY ); if ( errno != OK ) printf( "... returned error %x\r\n", errno ); printf( "\r\nCreating Semaphore SEM3" ); errno = 0; sema43_id = semBCreate( SEM_Q_FIFO, SEM_EMPTY ); if ( errno != OK ) printf( "... returned error %x\r\n", errno ); /* Turn on round-robin timeslicing */ enableRoundRobin(); puts( "\r\nCreating Task 1" ); task1_id = taskSpawn( "TSK1", 10, 0, 0, task1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ); puts( "\r\nCreating Task 2" ); task2_id = taskSpawn( "TSK2", 10, 0, 0, task2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ); puts( "\r\nCreating Task 3" ); task3_id = taskSpawn( "TSK3", 10, 0, 0, task3, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ); }
StateMachine :: StateMachine() { // Create the semaphores needed semQueue = semBCreate(SEM_Q_PRIORITY, SEM_FULL); semEvent = semCCreate(SEM_Q_PRIORITY, 0); int diagramNo; for (diagramNo = 0; diagramNo < diagrams; diagramNo++) { diaTimerTable[diagramNo] = new DiaTimer(this); // Create one timer object for each diagram diaTimerTable[diagramNo]->timerName = timerNames[diagramNo]; // Assign numbers to timer objects } return; }
void s3_sem2(void) { int taskIdOne; int taskIdTwo; semBinary = semBCreate(SEM_Q_FIFO, SEM_FULL); /*semTake(semBinary, WAIT_FOREVER); /* NOTE 2 */ taskIdOne = taskSpawn("task1", 90, 0, 2000, (FUNCTION)taskOne, 1, 2, 3, 4, 5); taskIdTwo = taskSpawn("task2", 90, 0, 2000, (FUNCTION)taskTwo, 1, 2, 3, 4, 5); }
/** * Create a new timer object. * * Create a new timer object and reset the time to zero. The timer is initially not running and * must be started. */ Timer::Timer() : m_startTime (0.0) , m_accumulatedTime (0.0) , m_running (false) , m_semaphore (0) { //Creates a semaphore to control access to critical regions. //Initially 'open' m_semaphore = semBCreate(SEM_Q_PRIORITY, SEM_FULL); Reset(); }
// This must be called to add values to the data field bool Proxy::add(string name) { for(unsigned i=0;i<name.size();i++) { name[i] = toupper(name[i]); } if(data.find(name) == data.end()) { data[name] = make_pair(0.0,semBCreate(SEM_Q_PRIORITY, SEM_FULL)); return true; } else { return false; } }
SEM_ID semCreate (void) { SEM_ID semId; if ((!semOLibInstalled) && (semOLibInit () != OK)) /* initialize package */ return (NULL); if ((semId = semBCreate (SEM_Q_PRIORITY, SEM_EMPTY)) != NULL) semId->semType = SEM_TYPE_OLD; /* change type to OLD */ return (semId); }
/*** * Initialisation des Variables et sémaphore associé. * PostCondition: Le simulateur est pret a être utilisé. */ void init_simu_eol() { int num_eol; for(num_eol=0; num_eol<NOMBRE_EOL; num_eol++) { sem_dir_vent[num_eol]=semBCreate(SEM_Q_FIFO, SEM_EMPTY); angleDirectionVent[num_eol] = 180; // Initialement à l'ouest mot_mat[NOMBRE_EOL] = 90; //Initialement au Nord printf("Eolienne #%d en marche !\n",&num_eol); } printf("\n\n"); }
MutexImpl::MutexImpl(bool fast) { if (fast) { _sem = semBCreate(SEM_Q_PRIORITY, SEM_FULL); } else { _sem = semMCreate(SEM_INVERSION_SAFE | SEM_Q_PRIORITY); } if (_sem == 0) throw Poco::SystemException("cannot create mutex"); }
/* initialization */ int sy527Init() { int i; printf("sy527Init: 1: sizeof(HV)=%d\n",sizeof(HV));fflush(stdout); for(i=0; i<MAX_HVPS; i++) { printf("sy527Init: 11: %d\n",i);fflush(stdout); Demand[i] = calloc(1,sizeof(HV)); printf("sy527Init: 12: %d\n",i);fflush(stdout); Measure[i] = calloc(1,sizeof(HV)); printf("sy527Init: 13: %d\n",i);fflush(stdout); } printf("sy527Init: 2\n");fflush(stdout); nmainframes = 0; memset(Measure[0],0,sizeof(HV)); printf("sy527Init: 3\n");fflush(stdout); memset(Demand[0],0,sizeof(HV)); printf("sy527Init: 4\n");fflush(stdout); for(i=0; i<MAX_HVPS; i++) { printf("sy527Init: 5\n");fflush(stdout); Measure[i]->id = -1; printf("sy527Init: 6\n");fflush(stdout); Demand[i]->id = -1; printf("sy527Init: 7\n");fflush(stdout); mainframes[i] = -1; } printf("sy527Init: 8\n");fflush(stdout); #ifndef vxWorks /* set mutex attributes */ pthread_mutexattr_init(&mattr); pthread_mutexattr_setpshared(&mattr, PTHREAD_PROCESS_SHARED); /* init global mutex */ pthread_mutex_init(&global_mutex, &mattr); #else global_mutex = semBCreate(SEM_Q_FIFO, SEM_FULL); if(global_mutex == NULL) { printf("ERROR: could not allocate 'global_mutex' semaphore\n"); return(0); } #endif printf("sy527Init: 9\n");fflush(stdout); return(CAENHV_OK); }
void main (void) { unsigned char tempOut; /* Connect interrupt service routine to vector and all stuff */ intConnect (INUM_TO_IVEC(aioIntNum), my_ISR, aioIntNum); sysIntEnablePIC (aioIRQNum); /* Enable interrupts on the aio: * All interrupts and interrupt from counter 1 too */ tempOut = 0x24; sysOutByte (aioBase + intEnAddress, tempOut); /* Start counter 1 as timer with 50 ms period * It has a clock input of 1 MHz = 1 µs * Therefore the load value is 0xC350 = 50000 */ tempOut = 0x74; sysOutByte (aioBase + cntCntrlReg, tempOut); tempOut = 0x50; sysOutByte (aioBase + cnt1Address, tempOut); tempOut = 0xC3; sysOutByte (aioBase + cnt1Address, tempOut); /* Add your code here: create tasks, semaphores, ... */ //printf("Hello World!"); /*The second task shall do the following: * - It starts counter a as an auto-reload timer with a period of 50 ms. * - The interrupt generated by this counter activates the task. * This shall be done with a semaphore. * - The task reads the analog inputs of both the potentiometer and the temperature. * - If the values have changed compared to the previous ones, these shall be written into global * variables (AIn). * - A hysteresis of e.g. 10 – 20 bit is necessary due to the noise of the analog inputs. * * */ initHardware(0); int readTask; readTask = taskSpawn("tRead", 101, 0, 0x1000, (FUNCPTR) tRead,0,0,0,0,0,0,0,0,0,0); timIntSem = semBCreate(SEM_Q_PRIORITY, SEM_EMPTY); /* The third task shall do the following: * - It writes the values of the global variables (AIn) onto the display. * - This shall happen approx. each 100 ms */ int writeTask; writeTask = taskSpawn("tWrite",102,0,0x1000, (FUNCPTR) tWrite,0,0,0,0,0,0,0,0,0,0); /* Suspend own task */ taskSuspend (0); //suspended sich selber } /* main */