/*---------------------------------------------------------------------------* * Routine: IInitialize *---------------------------------------------------------------------------* * Description: * Initialize the EEPROM workspace. * Inputs: * T_EEPROM_NXP_LPC17xx_40xx_Workspace *p -- Workspace *---------------------------------------------------------------------------*/ static void IInitialize(T_EEPROM_NXP_LPC17xx_40xx_Workspace *p) { uint32_t v; LPC_EEPROM->PWRDWN = 0x0; v = PROCESSOR_OSCILLATOR_FREQUENCY / 375000; LPC_EEPROM->CLKDIV = v; v = LPC_EEPROM->CLKDIV; v = ((((PROCESSOR_OSCILLATOR_FREQUENCY / 1000000) * 15) / 1000) + 1); v |= (((((PROCESSOR_OSCILLATOR_FREQUENCY / 1000000) * 55) / 1000) + 1) << 8); v |= (((((PROCESSOR_OSCILLATOR_FREQUENCY / 1000000) * 35) / 1000) + 1) << 16); LPC_EEPROM->WSTATE = v; v = LPC_EEPROM->WSTATE; LPC_EEPROM->INTENSET = ((0x1 << END_OF_RDWR) | (0x1 << END_OF_PROG)); /* Enable the KFLASH Interrupt */ InterruptRegister( KFLASH_IRQn, IFlashIRQHandler, INTERRUPT_PRIORITY_NORMAL, "KFlash"); InterruptEnable(KFLASH_IRQn); UEZSemaphoreCreateBinary(&p->iIRQReadySem); p->iInitialized = ETrue; }
/*---------------------------------------------------------------------------*/ 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 }
/*---------------------------------------------------------------------------*/ void UEZWAVConfig(TUInt8 onBoardSpeakerVolume) { T_uezError error; if(UEZAudioAmpOpen("AMP0", &) == UEZ_ERROR_NONE){ UEZAudioAmpSetLevel(amp, onBoardSpeakerVolume); G_AudioAmpOpen = ETrue; } volume = onBoardSpeakerVolume; error = UEZDeviceTableFind("AudioCodec0", &p_ac); error = UEZDeviceTableGetWorkspace(p_ac, (T_uezDeviceWorkspace **)&ac); (*ac)->UseConfiguration((void*)ac, 1); if(error != UEZ_ERROR_NONE){ (*ac)->UseConfiguration((void*)ac, 1); } wav = UEZMemAlloc(DATA_TO_READ); wav2 = UEZMemAlloc(DATA_TO_READ); error = UEZDeviceTableFind("I2S", &p_i2s); error = UEZDeviceTableGetWorkspace(p_i2s, (T_uezDeviceWorkspace **)&i2s); (*i2s)->Configure((void*)i2s, (HAL_I2S_Callback_Transmit_Low) i2sCallBack); UEZSemaphoreCreateBinary(&wavSem); playStatus = EFalse; }
/*---------------------------------------------------------------------------*/ T_uezError FDICmdStart( T_uezDevice aStream, void **aWorkspace, TUInt32 aStackSizeBytes, const T_consoleCmdEntry *aCommandTable) { T_FDICmdWorkspace *p; T_uezError error; // Make sure we have a stream opened if (!aStream) return UEZ_ERROR_NOT_OPEN; // Allocate the workspace p = UEZMemAlloc(sizeof(*p)); if (!p) return UEZ_ERROR_OUT_OF_MEMORY; // Initialize the default parameters p->iStream = aStream; p->iCommandTable = aCommandTable; p->iCmdLen = 0; p->iNeedPrompt = ETrue; p->iLastCmd[0] = '\0'; p->iSemCmdProcess = 0; p->iStop = EFalse; p->iStopped = EFalse; // Create a semaphore to ensure one command // and a time is processed error = UEZSemaphoreCreateBinary(&p->iSemCmdProcess); if (!error) { // Semaphore for command processing created // Create the task error = UEZTaskCreate( FDICmdTask, "CMD", aStackSizeBytes, p, UEZ_PRIORITY_NORMAL, &p->iTask); } // If any error, task is not running and we need to clean up if (error) { // Get rid of the semaphore if (p->iSemCmdProcess) UEZSemaphoreDelete(p->iSemCmdProcess); // Remove the memory used UEZMemFree(p); p = 0; } // Return the workspace pointer (if any) if (aWorkspace) *aWorkspace = (void *)p; return error; }
/*---------------------------------------------------------------------------* * Routine: LCD_LQ043T1DG28_InitializeWorkspace_8Bit *---------------------------------------------------------------------------* * Description: * Setup workspace for LQ043T1DG28 LCD. * Inputs: * void *aW -- Particular workspace * Outputs: * T_uezError -- Error code *---------------------------------------------------------------------------*/ T_uezError LCD_LQ043T1DG28_InitializeWorkspace_8Bit(void *aW) { T_LQ043T1DG28Workspace *p = (T_LQ043T1DG28Workspace *)aW; p->iBaseAddress = 0xA0000000; p->aNumOpen = 0; p->iBacklightLevel = 256; // 100% p->iConfiguration = &LCD_LQ043T1DG28_configuration_8Bit; return UEZSemaphoreCreateBinary(&p->iVSyncSem); }
/*---------------------------------------------------------------------------* * Routine: LCD_UMSH_8253MD_3T_InitializeWorkspace_I15Bit *---------------------------------------------------------------------------* * Description: * Setup workspace for UMSH_8253MD_3T LCD. * Inputs: * void *aW -- Particular workspace * Outputs: * T_uezError -- Error code *---------------------------------------------------------------------------*/ T_uezError LCD_UMSH_8253MD_3T_InitializeWorkspace_I15Bit(void *aW) { T_UMSH_8253MD_3TWorkspace *p = (T_UMSH_8253MD_3TWorkspace *)aW; p->iBaseAddress = 0xA0000000; p->aNumOpen = 0; p->iBacklightLevel = 256; // 100% p->iConfiguration = &LCD_UMSH_8253MD_3T_configuration_I15Bit; return UEZSemaphoreCreateBinary(&p->iVSyncSem); }
/*---------------------------------------------------------------------------* * Routine: LCD_RH320240T_InitializeWorkspace_16Bit *---------------------------------------------------------------------------* * Description: * Setup workspace for RH320240T LCD (16 bit mode). * Inputs: * void *aW -- Particular SPI workspace * Outputs: * T_uezError -- Error code *---------------------------------------------------------------------------*/ T_uezError LCD_RH320240T_InitializeWorkspace_16Bit(void *aW) { T_RH320240TWorkspace *p = (T_RH320240TWorkspace *)aW; p->iBaseAddress = 0x80000000; p->aNumOpen = 0; p->iBacklightLevel = 256; // 100% p->iConfiguration = &LCD_RH320240T_configuration_16Bit; return UEZSemaphoreCreateBinary(&p->iVSyncSem); }
/*---------------------------------------------------------------------------* * Routine: DAC_Generic_InitializeWorkspace *---------------------------------------------------------------------------* * Description: * Setup a DAC and semaphore to ensure single accesses * at all times. * Inputs: * void *aW -- Workspace * Outputs: * T_uezError -- Error code *---------------------------------------------------------------------------*/ T_uezError DAC_Generic_InitializeWorkspace(void *aW) { T_uezError error; T_DAC_Generic_Workspace *p = (T_DAC_Generic_Workspace *)aW; // Then create a semaphore to limit the number of accessors error = UEZSemaphoreCreateBinary(&p->iSem); return error; }
/*---------------------------------------------------------------------------* * Routine: Serial_GenericHalfDuplex_InitializeWorkspace *---------------------------------------------------------------------------* * Description: * Setup a GenericHalfDuplex serial workspace. Configure will * setup the next step. * Inputs: * void *aW -- Workspace * Outputs: * T_uezError -- Error code *---------------------------------------------------------------------------*/ T_uezError Serial_GenericHalfDuplex_InitializeWorkspace(void *aW) { T_uezError error; T_Serial_GenericHalfDuplex_Workspace *p = (T_Serial_GenericHalfDuplex_Workspace *)aW; p->iQueueSend = 0; p->iQueueReceive = 0; p->iTxBusy = EFalse; p->iDidOutput = EFalse; p->iNumOpen = 0; UEZSemaphoreCreateBinary(&p->iSemEmpty); UEZSemaphoreGrab(p->iSemEmpty, 0); p->iDriveEnablePort = 0; p->iDriveEnableReleaseCountdown = 0; p->iCountdown = 0; // Then create a semaphore to limit the number of accessors error = UEZSemaphoreCreateBinary(&p->iSem); return error; }
/*---------------------------------------------------------------------------* * Routine: LED_Generic_GPIO_InitializeWorkspace *---------------------------------------------------------------------------* * Description: * Setup of this workspace for a generic GPIO driver. * Inputs: * void *aW -- Workspace * Outputs: * T_uezError -- Error code *---------------------------------------------------------------------------*/ T_uezError LED_Generic_GPIO_InitializeWorkspace(void *aW) { T_uezError error; T_LED_Generic_GPIO_Workspace *p = (T_LED_Generic_GPIO_Workspace *)aW; // Then create a semaphore to limit the number of accessors error = UEZSemaphoreCreateBinary(&p->iSem); p->iNumEntries = 0; return error; }
/*---------------------------------------------------------------------------* * Routine: Temp_NXP_SA56004X_InitializeWorkspaceLocal *---------------------------------------------------------------------------* * Description: * Setup of this workspace for PCF8563. * Inputs: * void *aW -- Workspace * Outputs: * T_uezError -- Error code *---------------------------------------------------------------------------*/ T_uezError Temp_NXP_SA56004X_InitializeWorkspace(void *aW, TBool aIsRemote) { T_uezError error; T_Temp_NXP_SA56004X_Workspace *p = (T_Temp_NXP_SA56004X_Workspace *)aW; // Then create a semaphore to limit the number of accessors error = UEZSemaphoreCreateBinary(&p->iSem); p->iIsRemote = aIsRemote; return error; }
/*---------------------------------------------------------------------------* * Routine: Flash_NXP_LPC17xx_40xx_InitializeWorkspace *---------------------------------------------------------------------------* * Description: * Setup of this workspace for Data Flash. For the NXP LPC17xx_40xx, we allow the MCU to * access the data flash area. * Inputs: * void *aW -- Workspace * Outputs: * T_uezError -- Error code *---------------------------------------------------------------------------*/ T_uezError Flash_NXP_LPC17xx_40xx_InitializeWorkspace(void *aW) { T_uezError error; T_Flash_NXP_LPC17xx_40xx_Workspace *p = (T_Flash_NXP_LPC17xx_40xx_Workspace *)aW; // Then create a semaphore to limit the number of accessors error = UEZSemaphoreCreateBinary(&p->iSem); p->iNumOpen = 0; return error; }
/*---------------------------------------------------------------------------* * Routine: Generic_USBHost_InitializeWorkspace *---------------------------------------------------------------------------* * Description: * Setup the USB Host * Inputs: * void *aWorkspace -- USB Host controller workspace * Outputs: * T_uezError -- Any error if failed *---------------------------------------------------------------------------*/ static T_uezError Generic_USBHost_InitializeWorkspace(void *aWorkspace) { T_Generic_USBHost_Workspace *p = (T_Generic_USBHost_Workspace *)aWorkspace; T_uezError error; p->iRegistrations = 0; error = UEZSemaphoreCreateBinary(&p->iStatusChangeSem); if (error) return error; UEZSemaphoreGrab(p->iStatusChangeSem, 0); error = UEZSemaphoreCreateBinary(&p->iWaitForIRQEvent); if (error) return error; UEZSemaphoreGrab(p->iWaitForIRQEvent, 0); error = UEZSemaphoreCreateBinary(&p->iListSem); if (error) return error; return UEZSemaphoreCreateBinary(&p->iSem); }
/*---------------------------------------------------------------------------* * Routine: Temperature_AnalogDevices_ADT7420_InitializeWorkspace *---------------------------------------------------------------------------* * Description: * Setup of this workspace for PCF8563. * Inputs: * void *aW -- Workspace * Outputs: * T_uezError -- Error code *---------------------------------------------------------------------------*/ T_uezError Temperature_AnalogDevices_ADT7420_InitializeWorkspace(void *aW) { T_uezError error; T_Temperature_AnalogDevices_ADT7420_Workspace *p = (T_Temperature_AnalogDevices_ADT7420_Workspace *)aW; p->iConfigured = EFalse; // Then create a semaphore to limit the number of accessors error = UEZSemaphoreCreateBinary(&p->iSem); return error; }
/*---------------------------------------------------------------------------* * Routine: LCD_UMSH_8596MD_20T_InitializeWorkspace_8Bit *---------------------------------------------------------------------------* * Description: * Setup workspace for UMSH_8596MD_20T LCD. * Inputs: * void *aW -- Particular workspace * Outputs: * T_uezError -- Error code *---------------------------------------------------------------------------*/ T_uezError LCD_UMSH_8596MD_20T_InitializeWorkspace_8Bit(void *aW) { T_UMSH_8596MD_20TWorkspace *p = (T_UMSH_8596MD_20TWorkspace *)aW; p->iBaseAddress = 0xA0000000; p->aNumOpen = 0; p->iBacklightLevel = 256; // 100% p->iConfiguration = &LCD_UMSH_8596MD_20T_configuration_8Bit; #if UEZ_LCD_POWER_GPIO_PIN HALInterfaceFind(UEZ_LCD_POWER_GPIO_PORT, (T_halWorkspace **)&p->iPowerGPIOPort); #else p->iPowerGPIOPort = 0; #endif return UEZSemaphoreCreateBinary(&p->iVSyncSem); }
/*---------------------------------------------------------------------------* * Routine: Button_NXP_PCA9551_InitializeWorkspace *---------------------------------------------------------------------------* * Description: * Setup of this workspace for PCA9551. * Inputs: * void *aW -- Workspace * Outputs: * T_uezError -- Error code *---------------------------------------------------------------------------*/ T_uezError Button_NXP_PCA9551_InitializeWorkspace(void *aW) { T_uezError error; TUInt8 i; T_Button_NXP_PCA9551_Workspace *p = (T_Button_NXP_PCA9551_Workspace *)aW; // Then create a semaphore to limit the number of accessors error = UEZSemaphoreCreateBinary(&p->iSem); for (i=0; i<8; i++) p->iButtonsState[i] = STATE_OFF; return error; }
/*---------------------------------------------------------------------------* * Routine: TS_EXC7200_InitializeWorkspace *---------------------------------------------------------------------------* * Description: * Setup workspace for the TI TSC2046. * Inputs: * void *aW -- Particular SPI workspace * Outputs: * T_uezError -- Error code *---------------------------------------------------------------------------*/ T_uezError TS_EXC7200_InitializeWorkspace(void *aW) { T_EXC7200Workspace *p = (T_EXC7200Workspace *)aW; T_uezError error; p->aNumOpen = 0; p->iHaveCalibration = EFalse; p->iLastTouch = 0; p->iLastX = 0; p->iLastY = 0; error = UEZSemaphoreCreateBinary(&p->iSemWaitForTouch); if (error) return error; UEZSemaphoreGrab(p->iSemWaitForTouch, 0); return error; }
/*---------------------------------------------------------------------------* * Routine: ST_Accelo_LIS3LV02DQ_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 ST_Accelo_LIS3LV02DQ_I2C_InitializeWorkspace(void *aW) { T_uezError error; T_ST_Accelo_LIS3LV02DQ_I2C_Workspace *p = (T_ST_Accelo_LIS3LV02DQ_I2C_Workspace *)aW; // Then create a semaphore to limit the number of accessors error = UEZSemaphoreCreateBinary(&p->iSem); p->iLastReading.iX = 0; p->iLastReading.iY = 0; p->iLastReading.iZ = 0; return error; }
/*---------------------------------------------------------------------------* * Routine: InitializeWorkspace *---------------------------------------------------------------------------* * Description: * Sets the default settings for the amp * Inputs: * void *aWorkSpace * Outputs: * T_uezError -- Error code *---------------------------------------------------------------------------*/ T_uezError AudioAmp_8551T_InitializeWorkspace(void *aWorkSpace) { T_uezError error; T_AudioAmp_8551T_Workspace *p = (T_AudioAmp_8551T_Workspace *)aWorkSpace; p->iNumOpen = 0; p->iLevel = DEFAULT_LEVEL*4; p->iIsMuted = EFalse; p->iIsOn = EFalse; error = UEZSemaphoreCreateBinary(&p->iSem); if (error) return error; return UEZ_ERROR_NONE; }
/*---------------------------------------------------------------------------* * Routine: Flash_Renesas_RX63N_InitializeWorkspace *---------------------------------------------------------------------------* * Description: * Setup of this workspace for Data Flash. For the Renesas RX63N, we allow the MCU to * access the data flash area. * Inputs: * void *aW -- Workspace * Outputs: * T_uezError -- Error code *---------------------------------------------------------------------------*/ T_uezError Flash_Renesas_RX63N_InitializeWorkspace(void *aW) { T_uezError error; T_Flash_Renesas_RX63N_Workspace *p = (T_Flash_Renesas_RX63N_Workspace *)aW; // Then create a semaphore to limit the number of accessors error = UEZSemaphoreCreateBinary(&p->iSem); p->iBaseAddr = 0; p->iNumOpen = 0; p->iIsProgramMode = EFalse; p->iIsChipInfoReady = EFalse; // Grant Read Access here R_FlashDataAreaAccess(0xFFFF, 0x0000); return error; }
/*---------------------------------------------------------------------------* * Routine: ExternalInterrupt_NXP_LPC1756_InitializeWorkspace *---------------------------------------------------------------------------* * Description: * Setup of this workspace for PCA9555. * Inputs: * void *aW -- Workspace * Outputs: * T_uezError -- Error code *---------------------------------------------------------------------------*/ T_uezError ExternalInterrupt_NXP_LPC1756_InitializeWorkspace(void *aW) { T_uezError error; TUInt8 i; T_ExternalInterrupt_NXP_LPC1756_Workspace *p = (T_ExternalInterrupt_NXP_LPC1756_Workspace *)aW; // Then create a semaphore to limit the number of accessors error = UEZSemaphoreCreateBinary(&p->iSem); // None are in use yet for (i=0; i<NUM_EXTERNAL_INTERRUPTS; i++) G_eintCallbacks[i].iCallbackFunc = 0; return error; }
/*---------------------------------------------------------------------------* * 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: RS485_Generic_Timer_InitializeWorkspace *---------------------------------------------------------------------------* * Description: * Setup a Generic_Timer serial workspace. Configure will * setup the next step. * Inputs: * void *aW -- Workspace * Outputs: * T_uezError -- Error code *---------------------------------------------------------------------------*/ T_uezError RS485_Generic_Timer_InitializeWorkspace(void *aW) { T_uezError error; T_RS485_Generic_Timer_Workspace *p = (T_RS485_Generic_Timer_Workspace *)aW; p->iQueueSend = 0; p->iQueueReceive = 0; p->iTxBusy = EFalse; p->iDidOutput = EFalse; p->iNumOpen = 0; p->iDriveEnablePort = 0; p->iCountdown = 0; // Then create a semaphore to limit the number of accessors error = UEZSemaphoreCreateBinary(&p->iSem); 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: EEPROM_NXP_LPC17xx_40xx_InitializeWorkspace *---------------------------------------------------------------------------* * Description: * Setup of this workspace for LPC17xx_40xx. * Inputs: * void *aW -- Workspace * Outputs: * T_uezError -- Error code *---------------------------------------------------------------------------*/ static T_uezError EEPROM_NXP_LPC17xx_40xx_InitializeWorkspace(void *aW) { T_uezError error; T_EEPROM_NXP_LPC17xx_40xx_Workspace *p = (T_EEPROM_NXP_LPC17xx_40xx_Workspace *)aW; // Then create a semaphore to limit the number of accessors error = UEZSemaphoreCreateBinary(&p->iSem); // Setup some standard settings in case they are not setup p->iConfig.iCommSpeed = 100; // not really needed p->iConfig.iPageSize = 64; p->iConfig.iWriteTime = 25; p->iInitialized = EFalse; // Record the global G_lpc1788EEPROMWorkspace = p; return error; }
/*---------------------------------------------------------------------------* * Routine: MassStorage_SDCard_MCI_InitializeWorkspace *---------------------------------------------------------------------------* * Description: * Setup a MassStorage device's workspace on the SDCard. * Inputs: * void *aWorkspace -- Workspace * Outputs: * T_uezError -- Error code *---------------------------------------------------------------------------*/ static T_uezError MassStorage_SDCard_MCI_InitializeWorkspace(void *aWorkspace) { T_uezError error = UEZ_ERROR_NONE; T_MassStorage_SDCard_MCI_Workspace *p = (T_MassStorage_SDCard_MCI_Workspace *)aWorkspace; p->iCardType = 1; p->iInitPerformed = EFalse; p->iStat = STA_NOINIT; error = UEZSemaphoreCreateBinary(&p->iSem); if (error) return error; //error = UEZSemaphoreCreateCounting(&p->iIsComplete, 20, 0); error = UEZSemaphoreCreateCounting(&p->iIsComplete, 255, 0); if (error) return error; return error; }
/*---------------------------------------------------------------------------* * Routine: Keypad_NXP_I2C_PCA9555_InitializeWorkspace *---------------------------------------------------------------------------* * Description: * Setup of this workspace for PCA9555. * Inputs: * void *aW -- Workspace * Outputs: * T_uezError -- Error code *---------------------------------------------------------------------------*/ T_uezError Keypad_NXP_I2C_PCA9555_InitializeWorkspace(void *aW) { T_uezError error; T_Keypad_NXP_I2C_PCA9555_Workspace *p = (T_Keypad_NXP_I2C_PCA9555_Workspace *)aW; // Then create a semaphore to limit the number of accessors error = UEZSemaphoreCreateBinary(&p->iSem); if (error) return error; // Nobody has registered yet p->iRegisteredQueues = 0; p->iNumOpen = 0; #if KEYPAD_USES_EXTERNAL_IRQ error = UEZSemaphoreCreateCounting(&p->iReady, 1, 0); #endif return error; }
/*---------------------------------------------------------------------------*/ static TUInt32 ImageLoadTask(T_uezTask aMyTask, void *aParams) { TBool run = ETrue; T_uezFile file; char filename[50]; TUInt8 i = 1; T_ImageMessage QueueMessage; //create the queue to receive messages about //loading images from the SC card UEZQueueCreate(1, sizeof(TUInt32), &G_ImageLoadQueue); UEZSemaphoreCreateBinary(&G_LoadingSemaphore); //find how many images are on the SC card //file names only allows 99 files while(i <= 99){ sprintf(filename, IMAGE_NAME_DIR IMAGE_NAME_BASE "%02d" IMAGE_EXT, i); if (UEZFileOpen(filename, FILE_FLAG_READ_ONLY, &file) == UEZ_ERROR_NONE){ i++; UEZFileClose(file); } else { G_NumImagesOnCard = i-1; break; } } if(G_NumImagesOnCard == 0){ //nothing to do. no images found on card return 1; } //load the images to the SD Card while(run){ UEZQueueReceive(G_ImageLoadQueue, (void*)&QueueMessage, UEZ_TIMEOUT_INFINITE); switch(QueueMessage){ case IMAGE_INITILIZE: //the current image has already been loaded //so load the next and previous images UEZSemaphoreGrab(G_LoadingSemaphore, UEZ_TIMEOUT_INFINITE); sprintf(filename, IMAGE_NAME_DIR IMAGE_NAME_BASE "%02d" IMAGE_EXT, G_CurrentImage_Number + 1); if (UEZFileOpen(filename, FILE_FLAG_READ_ONLY, &file) == UEZ_ERROR_NONE){ UEZFileRead(file, G_NextImage, IMAGE_BUFFER_SIZE,&read); UEZFileClose(file); } sprintf(filename, IMAGE_NAME_DIR IMAGE_NAME_BASE "%02d" IMAGE_EXT, G_NumImagesOnCard); if (UEZFileOpen(filename, FILE_FLAG_READ_ONLY, &file) == UEZ_ERROR_NONE){ UEZFileRead(file, G_PreviousImage, IMAGE_BUFFER_SIZE,&read); UEZFileClose(file); } UEZSemaphoreRelease(G_LoadingSemaphore); break; case IMAGE_ADVANCED: UEZSemaphoreGrab(G_LoadingSemaphore, UEZ_TIMEOUT_INFINITE); if( G_CurrentImage_Number < G_NumImagesOnCard){ sprintf(filename, IMAGE_NAME_DIR IMAGE_NAME_BASE "%02d" IMAGE_EXT, G_CurrentImage_Number + 1); } else { sprintf(filename, IMAGE_NAME_DIR IMAGE_NAME_BASE "%02d" IMAGE_EXT, 1); } if (UEZFileOpen(filename, FILE_FLAG_READ_ONLY, &file) == UEZ_ERROR_NONE){ UEZFileRead(file, G_NextImage, IMAGE_BUFFER_SIZE,&read); UEZFileClose(file); } UEZSemaphoreRelease(G_LoadingSemaphore); break; case IMAGE_REVERSED: UEZSemaphoreGrab(G_LoadingSemaphore, UEZ_TIMEOUT_INFINITE); if (G_CurrentImage_Number > 1){ sprintf(filename, IMAGE_NAME_DIR IMAGE_NAME_BASE "%02d" IMAGE_EXT, G_CurrentImage_Number - 1); } else { sprintf(filename, IMAGE_NAME_DIR IMAGE_NAME_BASE "%02d" IMAGE_EXT, G_NumImagesOnCard); } if (UEZFileOpen(filename, FILE_FLAG_READ_ONLY, &file) == UEZ_ERROR_NONE){ UEZFileRead(file, G_PreviousImage, IMAGE_BUFFER_SIZE,&read); UEZFileClose(file); } UEZSemaphoreRelease(G_LoadingSemaphore); break; default: break; } } return 0; }
/*---------------------------------------------------------------------------* * 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; }