/* ===================================================================*/ LDD_TDeviceData* TimerIntLdd2_Init(LDD_TUserData *UserDataPtr) { /* Allocate device structure */ TimerIntLdd2_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" */ /* Registration of the device structure */ PE_LDD_RegisterDeviceStructure(PE_LDD_COMPONENT_TimerIntLdd2_ID,DeviceDataPrv); DeviceDataPrv->LinkedDeviceDataPtr = TU2_Init((LDD_TUserData *)NULL); if (DeviceDataPrv->LinkedDeviceDataPtr == NULL) { /* Is initialization of TimerUnit unsuccessful? */ /* Unregistration of the device structure */ PE_LDD_UnregisterDeviceStructure(PE_LDD_COMPONENT_TimerIntLdd2_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 */ } return ((LDD_TDeviceData *)DeviceDataPrv); /* Return pointer to the device data structure */ }
/**\fn US_Init(void) * \brief Init for US sensorss s * * * Initializes Ultrasonic sensors */ void US_Init(void) { /* Front sensor */ usDevices.usDevice[0].state = ECHO_IDLE; usDevices.usDevice[0].capture = 0; usDevices.usDevice[0].trigDevice = USTRIGFRONT_Init(NULL); usDevices.usDevice[0].echoDevice = TU2_Init(&usDevices); usDevices.usDevice[0].clrVal = USTRIGFRONT_ClrVal; usDevices.usDevice[0].setVal = USTRIGFRONT_SetVal; usDevices.usDevice[0].id = US_FRONT; /* Rear sensor */ usDevices.usDevice[1].state = ECHO_IDLE; usDevices.usDevice[1].capture = 0; usDevices.usDevice[1].trigDevice = USTRIGREAR_Init(NULL); usDevices.usDevice[1].echoDevice = usDevices.usDevice[0].echoDevice; usDevices.usDevice[1].clrVal = USTRIGREAR_ClrVal; usDevices.usDevice[1].setVal = USTRIGREAR_SetVal; usDevices.usDevice[1].id = US_REAR; /* Left sensor */ usDevices.usDevice[2].state = ECHO_IDLE; usDevices.usDevice[2].capture = 0; usDevices.usDevice[2].trigDevice = USTRIGLEFT_Init(NULL); usDevices.usDevice[2].echoDevice = usDevices.usDevice[0].echoDevice; usDevices.usDevice[2].clrVal = USTRIGLEFT_ClrVal; usDevices.usDevice[2].setVal = USTRIGLEFT_SetVal; usDevices.usDevice[3].id = US_LEFT; /* Right sensor */ usDevices.usDevice[3].state = ECHO_IDLE; usDevices.usDevice[3].capture = 0; usDevices.usDevice[3].trigDevice = USTRIGRIGHT_Init(NULL); usDevices.usDevice[3].echoDevice = usDevices.usDevice[0].echoDevice; usDevices.usDevice[3].clrVal = USTRIGRIGHT_ClrVal; usDevices.usDevice[3].setVal = USTRIGRIGHT_SetVal; usDevices.usDevice[3].id = US_RIGHT; }