void REF_Init(void) { mutexHandle = FRTOS1_xSemaphoreCreateMutex(); if (mutexHandle==NULL) { for(;;); } timerHandle = TU1_Init(NULL); InitSensorValues(); if (FRTOS1_xTaskCreate(ReflTask, (signed portCHAR *)"Refl", configMINIMAL_STACK_SIZE, NULL, tskIDLE_PRIORITY+1, NULL) != pdPASS) { for(;;){} /* error */ } }
/* ** =================================================================== ** Method : PwmLdd1_Init (component PWM_LDD) ** ** Description : ** Initializes the device. Allocates memory for the device data ** structure, allocates interrupt vectors and sets interrupt ** priority, sets pin routing, sets timing, etc. If the ** property <"Enable in init. code"> is set to "yes" value then ** the device is also enabled (see the description of the ** <Enable> method). In this case the <Enable> method is not ** necessary and needn't to be generated. This method can be ** called only once. Before the second call of Init the <Deinit> ** must be called first. ** Parameters : ** NAME - DESCRIPTION ** * UserDataPtr - Pointer to the user or ** RTOS specific data. This pointer will be ** passed as an event or callback parameter. ** Returns : ** --- - Pointer to the dynamically allocated ** private structure or NULL if there was an ** error. ** =================================================================== */ LDD_TDeviceData* PwmLdd1_Init(LDD_TUserData *UserDataPtr) { /* Allocate device structure */ PwmLdd1_TDeviceData *DeviceDataPrv; /* {Default RTOS Adapter} Driver memory allocation: Dynamic allocation is simulated by a pointer to the static object */ DeviceDataPrv = &DeviceDataPrv__DEFAULT_RTOS_ALLOC; DeviceDataPrv->UserDataPtr = UserDataPtr; /* Store the RTOS device structure */ DeviceDataPrv->EnUser = TRUE; /* Set the flag "device enabled" */ DeviceDataPrv->RatioStore = 0x01U; /* Ratio after initialization */ DeviceDataPrv->LinkedDeviceDataPtr = TU1_Init((LDD_TUserData *)NULL); if (DeviceDataPrv->LinkedDeviceDataPtr == NULL) { /* Is initialization of TimerUnit unsuccessful? */ /* Deallocation of the device structure */ /* {Default RTOS Adapter} Driver memory deallocation: Dynamic allocation is simulated, no deallocation code is generated */ return NULL; /* If so, then the PWM initialization is also unsuccessful */ } /* Registration of the device structure */ PE_LDD_RegisterDeviceStructure(PE_LDD_COMPONENT_PwmLdd1_ID,DeviceDataPrv); return ((LDD_TDeviceData *)DeviceDataPrv); /* Return pointer to the device data structure */ }
/* ===================================================================*/ LDD_TDeviceData* TimerIntLdd1_Init(LDD_TUserData *UserDataPtr) { /* Allocate device structure */ TimerIntLdd1_TDeviceData *DeviceDataPrv; /* {Default RTOS Adapter} Driver memory allocation: Dynamic allocation is simulated by a pointer to the static object */ DeviceDataPrv = &DeviceDataPrv__DEFAULT_RTOS_ALLOC; DeviceDataPrv->UserDataPtr = UserDataPtr; /* Store the RTOS device structure */ DeviceDataPrv->EnEvents = 0x01u; /* Initial event mask */ DeviceDataPrv->EnUser = TRUE; /* Set the flag "device enabled" */ DeviceDataPrv->CmpVal = 0xBB80U; /* Initial value periodically addded to compare register */ /* Registration of the device structure */ PE_LDD_RegisterDeviceStructure(PE_LDD_COMPONENT_TimerIntLdd1_ID,DeviceDataPrv); DeviceDataPrv->LinkedDeviceDataPtr = TU1_Init((LDD_TUserData *)NULL); if (DeviceDataPrv->LinkedDeviceDataPtr == NULL) { /* Is initialization of TimerUnit unsuccessful? */ /* Unregistration of the device structure */ PE_LDD_UnregisterDeviceStructure(PE_LDD_COMPONENT_TimerIntLdd1_ID); /* Deallocation of the device structure */ /* {Default RTOS Adapter} Driver memory deallocation: Dynamic allocation is simulated, no deallocation code is generated */ return NULL; /* If so, then the TimerInt initialization is also unsuccessful */ } (void)TU1_SetEventMask(DeviceDataPrv->LinkedDeviceDataPtr, TU1_GetEventMask(DeviceDataPrv->LinkedDeviceDataPtr) | LDD_TIMERUNIT_ON_CHANNEL_0); /* Enable TimerUnit event */ return ((LDD_TDeviceData *)DeviceDataPrv); /* Return pointer to the device data structure */ }
void US_Init(void) { usDevice.state = ECHO_IDLE; usDevice.capture = 0; usDevice.echoDevice = TU1_Init(&usDevice); }
LDD_TDeviceData* TP1_initTimer(void) { return TU1_Init(NULL); }