/* Input_Init - display driver initialization routine */ INT8U Input_Init(POSDRV_DISPATCH pDispatch, PVOID *ppContext, POSDRV_CONFIG pConfig) { // allocate the data extension for use to save data for this driver *ppContext = DRV_MEMALLOC(sizeof(INPUT_EXT)); if (*ppContext == NULL) { return OS_DRV_BUFFER_SIZE; } // zero the data extension memset(*ppContext, 0, sizeof(INPUT_EXT)); // create a name for each device that we support OSDRV_AddName(pConfig, "INPUT"); // set up the supported entry points for this driver pDispatch->pOpen = Input_Open; // required pDispatch->pClose = Input_Close; // required pDispatch->pRead = NULL; // optional, not currently supported in this driver pDispatch->pWrite = NULL; // optional; not supported until adding the LCD pDispatch->pIoctl = Input_Ioctl; // optional // set this driver to accept non-serialized requests on each handle // any synchronization needs to be handled by the driver or caller above us pConfig->Exclusive = FALSE; // return success return OS_DRV_NO_ERR; }
/* Mp3_Init - SPI driver initialization routine */ INT8U Mp3_Init(POSDRV_DISPATCH pDispatch, PVOID *ppContext, POSDRV_CONFIG pConfig) { // allocate the data extension for use to save data for this driver *ppContext = DRV_MEMALLOC(sizeof(MP3_EXT)); // zero the data extension memset(*ppContext, 0, sizeof(MP3_EXT)); ((PMP3_EXT)*ppContext)->hSpi = OS_DRV_INVALID_HANDLE; // create a name for each device that we support OSDRV_AddName(pConfig, "MP30"); // setup the supported entry points for this driver pDispatch->pOpen = Mp3_Open; // required pDispatch->pClose = Mp3_Close; // required pDispatch->pRead = NULL; // optional, not currently supported in this driver pDispatch->pWrite = Mp3_Write; // optional pDispatch->pIoctl = Mp3_Ioctl; // optional // set this driver to accept serialized requests on each handle pConfig->Exclusive = TRUE; // return success return OS_DRV_NO_ERR; }
/* Spi_Init - SPI driver initialization routine */ INT8U Spi_Init(POSDRV_DISPATCH pDispatch, PVOID *ppContext, POSDRV_CONFIG pConfig) { PSPI_DEVICE pDevice; // allocate the data extension for use to save data for this driver *ppContext = DRV_MEMALLOC(sizeof(SPI_EXT)); if (*ppContext == NULL) { return OS_DRV_BUFFER_SIZE; } // zero the data extension memset(*ppContext, 0, sizeof(SPI_EXT)); // initialize the addresses for the supported devices pDevice = &((PSPI_EXT)*ppContext)->Device[0]; pDevice->pSSPnCR0 = (INT16U*)SSP0CR0; pDevice->pSSPnCR1 = (INT8U*)SSP0CR1; pDevice->pSSPnDR = (INT16U*)SSP0DR; pDevice->pSSPnSR = (INT8U*)SSP0SR; pDevice->pSSPnCPSR = (INT8U*)SSP0CPSR; pDevice->pSSPnIMSC = (INT8U*)SSP0IMSC; pDevice->pSSPnRIS = (INT8U*)SSP0RIS; pDevice->pSSPnMIS = (INT8U*)SSP0MIS; pDevice->pSSPnICR = (INT8U*)SSP0ICR; pDevice->pSSPnDMACR = (INT16U*)SSP0DMACR; //set the pins pDevice->PinSck = SPI0_SCK; pDevice->PinMISO = SPI0_MISO; pDevice->PinMOSI = SPI0_MOSI; // create a name for each device that we support OSDRV_AddName(pConfig, "SPI0"); // now do the second device pDevice = &((PSPI_EXT)*ppContext)->Device[1]; pDevice->pSSPnCR0 = (INT16U*)SSP1CR0; pDevice->pSSPnCR1 = (INT8U*)SSP1CR1; pDevice->pSSPnDR = (INT16U*)SSP1DR; pDevice->pSSPnSR = (INT8U*)SSP1SR; pDevice->pSSPnCPSR = (INT8U*)SSP1CPSR; pDevice->pSSPnIMSC = (INT8U*)SSP1IMSC; pDevice->pSSPnRIS = (INT8U*)SSP1RIS; pDevice->pSSPnMIS = (INT8U*)SSP1MIS; pDevice->pSSPnICR = (INT8U*)SSP1ICR; pDevice->pSSPnDMACR = (INT16U*)SSP1DMACR; //set the pins pDevice->PinSck = SPI1_SCK; pDevice->PinMISO = SPI1_MISO; pDevice->PinMOSI = SPI1_MOSI; // create a name for each device that we support OSDRV_AddName(pConfig, "SPI1"); // setup the supported entry points for this driver pDispatch->pOpen = Spi_Open; // required pDispatch->pClose = Spi_Close; // required pDispatch->pRead = NULL; // optional, not currently supported in this driver pDispatch->pWrite = Spi_Write; // optional pDispatch->pIoctl = Spi_Ioctl; // optional // set this driver to accept non-serialized requests on each handle // any synchronization needs to be handled by the driver or caller above us pConfig->Exclusive = FALSE; // return success return OS_DRV_NO_ERR; }