/*---------------------------------------------------------------------------*/ static void IUEZTSInitialize(void) { G_tsDevices = 0; if (UEZSemaphoreCreateBinary(&G_tsSem) == UEZ_ERROR_NONE){ G_tsDidInit = ETrue; #if UEZ_REGISTER UEZSemaphoreSetName(G_tsSem, "uEZ_TS", "\0"); #endif } UEZTaskCreate( (T_uezTaskFunction)IUEZTSMonitorTouchscreensTask, "TS_Mon", UEZ_TASK_STACK_BYTES( 1024 ), 0, UEZ_PRIORITY_HIGH, &G_tsMonitorTask); #ifdef NO_DYNAMIC_MEMORY_ALLOC { TUInt16 usLoop; /* initialise the TS queue list. */ for( usLoop = 0; usLoop < ( ueztsMAX_TS_QUEUES - 1 ); usLoop++ ) { xTsQueues[ usLoop ].iNext = &xTsQueues[ usLoop + 1 ]; } xTsQueues[ usLoop ].iNext = NULL; xFreeTsList = &xTsQueues[ 0 ]; } #endif // NO_DYNAMIC_MEMORY_ALLOC }
/*---------------------------------------------------------------------------* * Routine: Network_lwIP_InitializeWorkspace *---------------------------------------------------------------------------* * Description: * Setup a redpine networking subsystem workspace. * Inputs: * void *aWorkspace -- Workspace * Outputs: * T_uezError -- Error code *---------------------------------------------------------------------------*/ T_uezError Network_lwIP_InitializeWorkspace(void *aWorkspace) { T_uezError error; T_Network_lwIP_Workspace *p = (T_Network_lwIP_Workspace *)aWorkspace; p->iNumOpen = 0; memset(p->iSockets, 0, sizeof(p->iSockets)); // Then create a semaphore to limit the number of accessors error = UEZSemaphoreCreateBinary(&p->iSem); #if UEZ_REGISTER UEZSemaphoreSetName(p->iSem, "Lwip", "\0"); #endif p->iJoinStatus = UEZ_NETWORK_JOIN_STATUS_IDLE; p->iScanStatus = UEZ_NETWORK_SCAN_STATUS_IDLE; return error; }
/*---------------------------------------------------------------------------* * Routine: Accelerometer_Freescale_MMA7455_I2C_InitializeWorkspace *---------------------------------------------------------------------------* * Description: * Setup a SPI Bus called SPI0 and semaphore to ensure single accesses * at a time. * Inputs: * void *aW -- Workspace * Outputs: * T_uezError -- Error code *---------------------------------------------------------------------------*/ T_uezError Accelerometer_Freescale_MMA7455_I2C_InitializeWorkspace(void *aW) { T_uezError error; T_Accelerometer_Freescale_MMA7455_I2C_Workspace *p = (T_Accelerometer_Freescale_MMA7455_I2C_Workspace *)aW; // Then create a semaphore to limit the number of accessors error = UEZSemaphoreCreateBinary(&p->iSem); #if UEZ_REGISTER UEZSemaphoreSetName(p->iSem, "Accelerometer", "\0"); #endif p->iLastReading.iX = 0; p->iLastReading.iY = 0; p->iLastReading.iZ = 0; p->iI2CAddress = MMA7455_I2C_ADDR; return error; }
/*---------------------------------------------------------------------------* * Routine: Serial_GenericHalfDuplex_Configure *---------------------------------------------------------------------------* * Description: * Setup the GenericHalfDuplex configuration with the given queue sizes and * link to HAL Serial device. * Inputs: * T_uezDeviceWorkspace *aWorkspace -- This hardware device * HAL_Serial **aSerial -- Serial Device to use * TUInt32 aQueueSendSize -- Size of the send queue * TUInt32 aQueueReceiveSize -- Size of the receive queue * Outputs: * T_uezError -- Error code *---------------------------------------------------------------------------*/ T_uezError Serial_GenericHalfDuplex_Configure( T_uezDeviceWorkspace *aWorkspace, HAL_Serial **aSerial, TUInt32 aQueueSendSize, TUInt32 aQueueReceiveSize, HAL_GPIOPort **aDriveEnablePort, TUInt32 aDriveEnablePin, TBool aDriveEnablePolarity, TUInt32 aDriveEnableReleaseTime) { T_Serial_GenericHalfDuplex_Workspace *p = (T_Serial_GenericHalfDuplex_Workspace *)aWorkspace; T_uezError error; // Record serial device p->iSerial = aSerial; p->iDriveEnablePort = aDriveEnablePort; p->iDriveEnablePin = aDriveEnablePin; p->iDriveEnablePolarity = aDriveEnablePolarity; p->iDriveEnableReleaseCountdown = aDriveEnableReleaseTime; p->iCountdown = 0; error = UEZSemaphoreCreateBinary(&p->iDESem); if (error) return error; #if UEZ_REGISTER UEZSemaphoreSetName(p->iSemEmpty, "EmptyHD", (*(p->iSerial))->iInterface.iName); UEZSemaphoreSetName(p->iSemEmpty, "SerialHD", (*(p->iSerial))->iInterface.iName); #endif // Create queue to hold sending data error = UEZQueueCreate(aQueueSendSize, 1, &p->iQueueSend); if (error) return error; #if UEZ_REGISTER else UEZQueueSetName(p->iQueueSend, "SendHD", (*(p->iSerial))->iInterface.iName); #endif // Create queue to hold receiving data error = UEZQueueCreate(aQueueReceiveSize, 1, &p->iQueueReceive); if (error) { UEZQueueDelete(p->iQueueSend); p->iQueueSend = 0; return error; } #if UEZ_REGISTER else { UEZQueueSetName(p->iQueueReceive, "ReceiveHD", (*(p->iSerial))->iInterface.iName); } #endif // Make sure we are NOT driving enabled if (p->iDriveEnablePort) { if (p->iDriveEnablePolarity) { (*p->iDriveEnablePort)->Clear(p->iDriveEnablePort, p->iDriveEnablePin); } else { (*p->iDriveEnablePort)->Set(p->iDriveEnablePort, p->iDriveEnablePin); } } // setup the callbacks (*p->iSerial)->Configure( (void *)p->iSerial, (void *)p, ISerialGenericHalfDuplexCallbackReceivedByte, ISerialGenericHalfDuplexCallbackTransmitEmpty); UEZTaskCreate( (T_uezTaskFunction)Serial_GenericHalfDuplex_MonitorDriveEnable, "DriveEnable", 128, (void *)p, UEZ_PRIORITY_HIGH, 0); // Return last error return error; }