/** * All modules MUST provide a FULL cleanup function. This must cleanup all allocations etc * e.g. we will have to populate this when we add circular buffers! * **/ static BT_ERROR canCleanup(BT_HANDLE hCan) { canDisable(hCan); // Disable peripheral clock. disableCanPeripheralClock(hCan); // Free any buffers if used. if(hCan->eMode != BT_CAN_MODE_BUFFERED) { BT_CloseHandle(hCan->hRxFifo); BT_CloseHandle(hCan->hTxFifo); } BT_u32 i; BT_BOOL bClose = BT_TRUE; for (i = 0; i < 2; i++) { const BT_RESOURCE *pResource = BT_GetIntegratedResource(hCan->pDevice, BT_RESOURCE_ENUM, 0); if ((pResource->ulStart != i) && (g_CAN_HANDLES[i] != NULL)) { bClose = BT_FALSE; } } const BT_RESOURCE *pResource = BT_GetIntegratedResource(hCan->pDevice, BT_RESOURCE_IRQ, 0); if (bClose) BT_DisableInterrupt(pResource->ulStart); pResource = BT_GetIntegratedResource(hCan->pDevice, BT_RESOURCE_ENUM, 0); g_CAN_HANDLES[pResource->ulStart] = NULL; // Finally mark the hardware as not used. return BT_ERR_NONE; }
BT_HANDLE gpio_probe(const BT_INTEGRATED_DEVICE *pDevice, BT_ERROR *pError) { BT_ERROR Error; if(pError) { *pError = BT_ERR_NONE; } BT_HANDLE hGPIO = BT_CreateHandle(&oHandleInterface, sizeof(struct _BT_OPAQUE_HANDLE), pError); if(!hGPIO) { goto err_out; } const BT_RESOURCE *pResource = BT_GetIntegratedResource(pDevice, BT_RESOURCE_IO, 0); if(!pResource) { Error = BT_ERR_GENERIC; goto err_free_out; } BT_u32 base = pResource->ulStart; BT_u32 total = (pResource->ulEnd - pResource->ulStart) + 1; pResource = BT_GetIntegratedResource(pDevice, BT_RESOURCE_MEM, 0); if(!pResource) { Error = BT_ERR_GENERIC; goto err_free_out; } hGPIO->pRegs = (LPC11Axx_GPIO_REGS *) pResource->ulStart; pResource = BT_GetIntegratedResource(pDevice, BT_RESOURCE_IRQ, 0); if(!pResource) { Error = BT_ERR_GENERIC; goto err_free_out; } //Error = BT_EnableInterrupt(pResource->ulStart); Error = BT_RegisterGpioController(base, total, hGPIO); if(Error) { goto err_free_out; } return hGPIO; err_free_out: BT_DestroyHandle(hGPIO); if(pError) { *pError = Error; } err_out: return NULL; }
static BT_HANDLE nvic_probe(const BT_INTEGRATED_DEVICE *pDevice, BT_ERROR *pError) { BT_ERROR Error; if(g_hActiveHandle) { if(pError) { *pError = BT_ERR_GENERIC; } return NULL; } BT_HANDLE hNVIC = BT_CreateHandle(&oHandleInterface, sizeof(struct _BT_OPAQUE_HANDLE), pError); if(!hNVIC) { goto err_out; } const BT_RESOURCE *pResource; pResource = BT_GetIntegratedResource(pDevice, BT_RESOURCE_MEM, 0); if(!pResource) { Error = BT_ERR_NO_MEMORY; goto err_free_chip; } hNVIC->pRegs = (NVIC_REGS *) pResource->ulStart; pResource = BT_GetIntegratedResource(pDevice, BT_RESOURCE_IRQ, 0); if(!pResource) { Error = BT_ERR_GENERIC; goto err_free_chip; } BT_u32 base, total; base = pResource->ulStart; total = (pResource->ulEnd - pResource->ulStart) + 1; Error = BT_RegisterInterruptController(base, total, hNVIC); if(Error) { goto err_free_chip; } return hNVIC; err_free_chip: BT_DestroyHandle(hNVIC); if(pError) { *pError = Error; } err_out: return hNVIC; }
static BT_ERROR mac_cleanup(BT_HANDLE hMAC) { // Disable peripheral clock. disablemacPeripheralClock(hMAC); const BT_RESOURCE *pResource = BT_GetIntegratedResource(hMAC->pDevice, BT_RESOURCE_IRQ, 0); BT_DisableInterrupt(pResource->ulStart); pResource = BT_GetIntegratedResource(hMAC->pDevice, BT_RESOURCE_ENUM, 0); g_mac_HANDLES[pResource->ulStart] = NULL; // Finally mark the hardware as not used. return BT_ERR_NONE; }
static BT_HANDLE timer_probe(const BT_INTEGRATED_DEVICE *pDevice, BT_ERROR *pError) { BT_ERROR Error = BT_ERR_NONE; BT_HANDLE hTimer = BT_CreateHandle(&oHandleInterface, sizeof(struct _BT_OPAQUE_HANDLE), pError); if(!hTimer) { Error = BT_ERR_NO_MEMORY; goto err_out; } const BT_RESOURCE *pResource; pResource = BT_GetIntegratedResource(pDevice, BT_RESOURCE_MEM, 0); if(!pResource) { Error = BT_ERR_GENERIC; goto err_free_out; } hTimer->pRegs = (SYSTICK_REGS *) pResource->ulStart; hTimer->pRegs->CTRL &= ~0x04; hTimer->pRegs->CTRL |= BT_CONFIG_ARCH_ARM_SYSTICK_CLKSRC; pResource = BT_GetIntegratedResource(pDevice, BT_RESOURCE_IRQ, 0); if(!pResource) { Error = BT_ERR_GENERIC; goto err_free_out; } /* * In normal timer drivers we might register the interrupt here. * By default we want the linker to patch our vector table for us * and therefore its up to the Kernel to override the * correct symbol name... i.e. BT_NVIC_SysTick_Handler * */ return hTimer; err_free_out: BT_DestroyHandle(hTimer); err_out: if(pError) { *pError = Error; } return NULL; }
static BT_ERROR canSetBaudrate(BT_HANDLE hCan, BT_u32 ulBaudrate) { volatile LPC17xx_CAN_REGS *pRegs = hCan->pRegs; const BT_RESOURCE *pResource = BT_GetIntegratedResource(hCan->pDevice, BT_RESOURCE_ENUM, 0); BT_u32 ulInputClk = BT_LPC17xx_GetPeripheralClock(g_CAN_PERIPHERAL[pResource->ulStart]); BT_u32 ulPrescale = 0; BT_u32 ulCanClock = ulInputClk/(ulPrescale+1); while ((ulCanClock >= ulBaudrate*8) && (ulCanClock % ulBaudrate == 0)) { ulPrescale++; ulCanClock = ulInputClk/(ulPrescale+1); } BT_u32 ulTSEG1 = (ulInputClk/(ulPrescale*ulBaudrate)-4); BT_u32 ulTSEG2 = 1; if (ulTSEG1 > 15) { BT_u32 ulDiff = ulTSEG1 - 15; ulTSEG2 += ulDiff; ulTSEG1 -= ulDiff; } pRegs->CANBTR = (ulTSEG1 << 16) | (ulTSEG2 << 20) | (ulPrescale-1); return BT_ERR_NONE; };
/** * Function to test the current peripheral clock gate status of the devices. **/ static BT_BOOL isSpiPeripheralClockEnabled(BT_HANDLE hSpi) { const BT_RESOURCE *pResource = BT_GetIntegratedResource(hSpi->pDevice, BT_RESOURCE_ENUM, 0); switch(pResource->ulStart) { case 0: { if(LPC17xx_RCC->PCONP & LPC17xx_RCC_PCONP_SPIEN) { return BT_TRUE; } break; } case 1: { if(LPC17xx_RCC->PCONP & LPC17xx_RCC_PCONP_SSP0EN) { return BT_TRUE; } break; } case 2: { if(LPC17xx_RCC->PCONP & LPC17xx_RCC_PCONP_SSP1EN) { return BT_TRUE; } break; } default: { break; } } return BT_FALSE; }
/** * If the serial port is not in use, we can make it sleep! **/ static void disableTimerPeripheralClock(BT_HANDLE hTimer) { const BT_RESOURCE *pResource = BT_GetIntegratedResource(hTimer->pDevice, BT_RESOURCE_ENUM, 0); switch(pResource->ulStart) { case 0: { LM3Sxx_RCC->RCGC[1] &= ~LM3Sxx_RCC_RCGC_TIMER0EN; break; } case 1: { LM3Sxx_RCC->RCGC[1] &= ~LM3Sxx_RCC_RCGC_TIMER1EN; break; } case 2: { LM3Sxx_RCC->RCGC[1] &= ~LM3Sxx_RCC_RCGC_TIMER2EN; break; } case 3: { LM3Sxx_RCC->RCGC[1] &= ~LM3Sxx_RCC_RCGC_TIMER3EN; break; } default: { break; } } }
static BT_ERROR spiSetBaudrate(BT_HANDLE hSpi, BT_u32 ulBaudrate) { volatile LPC17xx_SPI_REGS *pRegs = hSpi->pRegs; const BT_RESOURCE *pResource = BT_GetIntegratedResource(hSpi->pDevice, BT_RESOURCE_ENUM, 0); BT_u32 ulInputClk = BT_LPC17xx_GetPeripheralClock(g_SPI_PERIPHERAL[pResource->ulStart]); if (pResource->ulStart == 0) { BT_u32 ulDivider = ulInputClk / ulBaudrate; if (ulDivider < 8) ulDivider = 8; if (ulDivider % 2) ulDivider++; pRegs->CCR = ulDivider; } else { pRegs->CR0 &= ~LPC17xx_SPI_CR0_SCR_MASK; BT_u32 ulDivider = (ulInputClk / ulBaudrate) / 256; if (ulDivider < 2) ulDivider = 2; if (ulDivider % 2) ulDivider++; pRegs->CPSR = ulDivider; pRegs->CR0 |= ((ulInputClk / (ulBaudrate * ulDivider)-1) << 8) & LPC17xx_SPI_CR0_SCR_MASK; } spiEnable(hSpi); return BT_ERR_NONE; }
static BT_ERROR pwm_cleanup(BT_HANDLE hPwm) { ResetPwm(hPwm); // Disable peripheral clock. disablePwmPeripheralClock(hPwm); const BT_RESOURCE *pResource = BT_GetIntegratedResource(hPwm->pDevice, BT_RESOURCE_IRQ, 0); BT_DisableInterrupt(pResource->ulStart); pResource = BT_GetIntegratedResource(hPwm->pDevice, BT_RESOURCE_ENUM, 0); g_PWM_HANDLES[pResource->ulStart] = NULL; // Finally mark the hardware as not used. return BT_ERR_NONE; }
/** * Function to test the current peripheral clock gate status of the devices. **/ static BT_BOOL isTimerPeripheralClockEnabled(BT_HANDLE hTimer) { const BT_RESOURCE *pResource = BT_GetIntegratedResource(hTimer->pDevice, BT_RESOURCE_ENUM, 0); switch(pResource->ulStart) { case 0: { if(LM3Sxx_RCC->RCGC[1] & LM3Sxx_RCC_RCGC_TIMER0EN) { return BT_TRUE; } break; } case 1: { if(LM3Sxx_RCC->RCGC[1] & LM3Sxx_RCC_RCGC_TIMER1EN) { return BT_TRUE; } break; } case 2: { if(LM3Sxx_RCC->RCGC[1] & LM3Sxx_RCC_RCGC_TIMER2EN) { return BT_TRUE; } break; } case 3: { if(LM3Sxx_RCC->RCGC[1] & LM3Sxx_RCC_RCGC_TIMER3EN) { return BT_TRUE; } break; } default: { break; } } return BT_FALSE; }
static BT_ERROR timer_cleanup(BT_HANDLE hTimer) { ResetTimer(hTimer); // Disable peripheral clock. disableTimerPeripheralClock(hTimer); const BT_RESOURCE *pResource = BT_GetIntegratedResource(hTimer->pDevice, BT_RESOURCE_IRQ, 0); BT_DisableInterrupt(pResource->ulStart); pResource = BT_GetIntegratedResource(hTimer->pDevice, BT_RESOURCE_ENUM, 0); g_TIMER_HANDLES[pResource->ulStart] = NULL; // Finally mark the hardware as not used. return BT_ERR_NONE; }
static BT_HANDLE devcfg_probe(const BT_INTEGRATED_DEVICE *pDevice, BT_ERROR *pError) { BT_ERROR Error; if(g_bInUse) { Error = BT_ERR_GENERIC; goto err_set_out; } g_bInUse = BT_TRUE; BT_HANDLE hDevcfg = BT_CreateHandle(&oHandleInterface, sizeof(struct _BT_OPAQUE_HANDLE), pError); if(!hDevcfg) { goto err_set_out; } const BT_RESOURCE *pResource = BT_GetIntegratedResource(pDevice, BT_RESOURCE_MEM, 0); if(!pResource) { Error = BT_ERR_GENERIC; goto err_free_out; } hDevcfg->pRegs = (volatile ZYNQ_DEVCFG_REGS *) bt_ioremap((void *) pResource->ulStart, sizeof(ZYNQ_DEVCFG_REGS)); hDevcfg->pRegs->UNLOCK = 0x757BDF0D; // Unlock the DEVCFG interface. hDevcfg->pRegs->INT_STS = 0xFFFFFFFF; // Clear all interrupt status signals. hDevcfg->pRegs->CTRL |= CTRL_PCFG_PROG_B; hDevcfg->pRegs->CTRL |= CTRL_PCAP_MODE; // Enable PCAP transfer mode. hDevcfg->pRegs->CTRL |= CTRL_PCAP_PR; // Select PCAP for reconfiguration, (disables ICAP). hDevcfg->pRegs->CTRL &= ~CTRL_QUARTER_PCAP_RATE; // Set full bandwidth PCAP loading rate. hDevcfg->pRegs->MCTRL &= ~MCTRL_PCAP_LPBK; // Ensure internal PCAP looback is disabled. hDevcfg->pSLCR = (volatile ZYNQ_SLCR_REGS *) bt_ioremap((void *) ZYNQ_SLCR_BASE, sizeof(ZYNQ_SLCR_REGS)); zynq_slcr_unlock(hDevcfg->pSLCR); zynq_slcr_preload_fpga(hDevcfg->pSLCR); zynq_slcr_lock(hDevcfg->pSLCR); devcfg_reset_pl(hDevcfg); if(pError) { *pError = BT_ERR_NONE; } return hDevcfg; err_free_out: BT_DestroyHandle(hDevcfg); err_set_out: if(pError) { *pError = Error; } return NULL; }
/** * This is really acting as a filter driver, so only the zynq HAL can know if the SDHCI * controller is enabled. * * If it is, we ask the generic SDHCI driver to do its stuff, otherwise we return an error. **/ static BT_HANDLE zynq_sdhci_probe(const BT_INTEGRATED_DEVICE *pDevice, BT_ERROR *pError) { BT_ERROR Error; BT_BOOL bEnabled = BT_FALSE; volatile ZYNQ_SLCR_REGS *pRegs = bt_ioremap((void *)ZYNQ_SLCR, BT_SIZE_4K); const BT_RESOURCE *pResource = BT_GetIntegratedResource(pDevice, BT_RESOURCE_ENUM, 0); if(!pResource) { goto err_out; } switch(pResource->ulStart) { case 0: bEnabled = (pRegs->SDIO_CLK_CTRL & ZYNQ_SLCR_CLK_CTRL_CLKACT_0); if(bEnabled) { // Attempt to reset the device! zynq_slcr_unlock(pRegs); pRegs->SDIO_RST_CTRL |= 0x11; pRegs->SDIO_RST_CTRL &= ~0x11; zynq_slcr_lock(pRegs); } break; case 1: bEnabled = (pRegs->SDIO_CLK_CTRL & ZYNQ_SLCR_CLK_CTRL_CLKACT_0); if(bEnabled) { zynq_slcr_unlock(pRegs); pRegs->SDIO_RST_CTRL |= 0x22; pRegs->SDIO_RST_CTRL &= ~0x22; zynq_slcr_lock(pRegs); } break; default: break; } bt_iounmap(pRegs); if(!bEnabled) { Error = BT_ERR_GENERIC; goto err_out; } BT_INTEGRATED_DRIVER *pDriver = BT_GetIntegratedDriverByName("mmc,sdhci"); if(!pDriver) { Error = BT_ERR_GENERIC; goto err_out; } return pDriver->pfnProbe(pDevice, pError); err_out: if(pError) { *pError = Error; } return NULL; }
static BT_u32 timer_getinputclock(BT_HANDLE hTimer, BT_ERROR *pError) { volatile LPC17xx_TIMER_REGS *pRegs = hTimer->pRegs; *pError = BT_ERR_NONE; const BT_RESOURCE *pResource = BT_GetIntegratedResource(hTimer->pDevice, BT_RESOURCE_ENUM, 0); return BT_LPC17xx_GetPeripheralClock(g_TIMER_PERIPHERAL[pResource->ulStart]) / (pRegs->TMRBPR+1); }
static void ResetSpi(BT_HANDLE hSpi) { volatile LPC17xx_SPI_REGS *pRegs = hSpi->pRegs; const BT_RESOURCE *pResource = BT_GetIntegratedResource(hSpi->pDevice, BT_RESOURCE_ENUM, 0); if (pResource->ulStart == 0) { pRegs->CR = LPC17xx_SPI_CR_8BITS | LPC17xx_SPI_CR_MASTER_MODE | LPC17xx_SPI_CR_BIT_ENABLE; } return; }
static BT_ERROR i2c_cleanup(BT_HANDLE hI2C) { const BT_RESOURCE *pResource = BT_GetIntegratedResource(hI2C->pDevice, BT_RESOURCE_IRQ, 0); if(!pResource) { return BT_ERR_GENERIC; } BT_ERROR Error = BT_UnregisterInterrupt(pResource->ulStart, i2c_irq_handler, hI2C); BT_kMutexDestroy(hI2C->pMutex); return Error; }
/** * All modules MUST provide a FULL cleanup function. This must cleanup all allocations etc * e.g. we will have to populate this when we add circular buffers! * **/ static BT_ERROR i2cCleanup(BT_HANDLE hI2C) { ResetI2C(hI2C); // Disable peripheral clock. disablei2cPeripheralClock(hI2C); const BT_RESOURCE *pResource = BT_GetIntegratedResource(hI2C->i2c_master.pDevice, BT_RESOURCE_IRQ, 0); BT_DisableInterrupt(pResource->ulStart); return BT_ERR_NONE; }
/** * If the serial port is not in use, we can make it sleep! **/ static void disableMCPWMPeripheralClock(BT_HANDLE hMCPWM) { const BT_RESOURCE *pResource = BT_GetIntegratedResource(hMCPWM->pDevice, BT_RESOURCE_ENUM, 0); switch(pResource->ulStart) { case 0: { LM3Sxx_RCC->RCGC[0] &= ~LM3Sxx_RCC_RCGC_PWM0EN; break; } default: { break; } } }
/** * If the serial port is not in use, we can make it sleep! **/ static void disablePwmPeripheralClock(BT_HANDLE hPwm) { const BT_RESOURCE *pResource = BT_GetIntegratedResource(hPwm->pDevice, BT_RESOURCE_ENUM, 0); switch(pResource->ulStart) { case 0: { LPC17xx_RCC->PCONP &= ~LPC17xx_RCC_PCONP_PWM0EN; break; } default: { break; } } }
/** * If the serial port is not in use, we can make it sleep! **/ static void disablei2cPeripheralClock(BT_HANDLE hI2C) { const BT_RESOURCE *pResource = BT_GetIntegratedResource(hI2C->i2c_master.pDevice, BT_RESOURCE_ENUM, 0); switch(pResource->ulStart) { case 0: { LPC11xx_RCC->SYSAHBCLKCTRL &= ~LPC11xx_RCC_SYSAHBCLKCTRL_I2C0EN; break; } default: { break; } } }
/** * All modules MUST provide a FULL cleanup function. This must cleanup all allocations etc * e.g. we will have to populate this when we add circular buffers! * **/ static BT_ERROR uartCleanup(BT_HANDLE hUart) { ResetUart(hUart); // Disable peripheral clock. disableUartPeripheralClock(hUart); // Free any buffers if used. if(hUart->eMode == BT_UART_MODE_BUFFERED) { BT_CloseHandle(hUart->hTxFifo); BT_CloseHandle(hUart->hRxFifo); } const BT_RESOURCE *pResource = BT_GetIntegratedResource(hUart->pDevice, BT_RESOURCE_IRQ, 0); BT_DisableInterrupt(pResource->ulStart); pResource = BT_GetIntegratedResource(hUart->pDevice, BT_RESOURCE_ENUM, 0); g_USART_HANDLES[pResource->ulStart] = NULL; // Finally mark the hardware as not used. return BT_ERR_NONE; }
/** * This actually allows the mac'S to be clocked! **/ static void enablemacPeripheralClock(BT_HANDLE hMAC) { const BT_RESOURCE *pResource = BT_GetIntegratedResource(hMAC->pDevice, BT_RESOURCE_ENUM, 0); switch(pResource->ulStart) { case 0: { LM3Sxx_RCC->RCGC[2] |= LM3Sxx_RCC_RCGC_MACEN; LM3Sxx_RCC->RCGC[2] |= LM3Sxx_RCC_RCGC_PHYEN; break; } default: { break; } } }
/** * Get a full configuration of the SPI. **/ static BT_ERROR spiGetConfig(BT_HANDLE hSpi, BT_SPI_CONFIG *pConfig) { volatile LPC17xx_SPI_REGS *pRegs = hSpi->pRegs; BT_ERROR Error = BT_ERR_NONE; const BT_RESOURCE *pResource = BT_GetIntegratedResource(hSpi->pDevice, BT_RESOURCE_ENUM, 0); BT_u32 ulInputClk = BT_LPC17xx_GetPeripheralClock(g_SPI_PERIPHERAL[pResource->ulStart]); if (pResource->ulStart == 0) { pConfig->ulBaudrate = ulInputClk / pRegs->CCR; pConfig->ucDataBits = (pRegs->CR >> 8) & LPC17xx_SPI_CR_DSS_MASK; pConfig->eCPOL = (pRegs->CR & LPC17xx_SPI_CR_CPOL); pConfig->eCPHA = (pRegs->CR & LPC17xx_SPI_CR_CPHA); }
/** * Function to test the current peripheral clock gate status of the devices. **/ static BT_BOOL isi2cPeripheralClockEnabled(BT_HANDLE hI2C) { const BT_RESOURCE *pResource = BT_GetIntegratedResource(hI2C->i2c_master.pDevice, BT_RESOURCE_ENUM, 0); switch(pResource->ulStart) { case 0: { if(LPC11xx_RCC->SYSAHBCLKCTRL & LPC11xx_RCC_SYSAHBCLKCTRL_I2C0EN) { return BT_TRUE; } break; } default: { break; } } return BT_FALSE; }
/** * Function to test the current peripheral clock gate status of the devices. **/ static BT_BOOL isMCPWMPeripheralClockEnabled(BT_HANDLE hMCPWM) { const BT_RESOURCE *pResource = BT_GetIntegratedResource(hMCPWM->pDevice, BT_RESOURCE_ENUM, 0); switch(pResource->ulStart) { case 0: { if(LM3Sxx_RCC->RCGC[0] & LM3Sxx_RCC_RCGC_PWM0EN) { return BT_TRUE; } break; } default: { break; } } return BT_FALSE; }
/** * This actually allows the CAN devices to be clocked! **/ static void enableCanPeripheralClock(BT_HANDLE hCan) { const BT_RESOURCE *pResource = BT_GetIntegratedResource(hCan->pDevice, BT_RESOURCE_ENUM, 0); switch(pResource->ulStart) { case 0: { LPC17xx_RCC->PCONP |= LPC17xx_RCC_PCONP_CAN1EN; break; } case 1: { LPC17xx_RCC->PCONP |= LPC17xx_RCC_PCONP_CAN2EN; break; } default: { break; } } }
/** * This is really acting as a filter driver, so only the zynq HAL can know if the SDHCI * controller is enabled. * * If it is, we ask the generic SDHCI driver to do its stuff, otherwise we return an error. **/ static BT_HANDLE zynq_sdhci_probe(const BT_INTEGRATED_DEVICE *pDevice, BT_ERROR *pError) { BT_ERROR Error; BT_BOOL bEnabled = BT_FALSE; const BT_RESOURCE *pResource = BT_GetIntegratedResource(pDevice, BT_RESOURCE_ENUM, 0); if(!pResource) { goto err_out; } switch(pResource->ulStart) { case 0: bEnabled = (ZYNQ_SLCR->SDIO_CLK_CTRL & ZYNQ_SLCR_CLK_CTRL_CLKACT_0); break; case 1: bEnabled = (ZYNQ_SLCR->SDIO_CLK_CTRL & ZYNQ_SLCR_CLK_CTRL_CLKACT_0); break; default: break; } if(!bEnabled) { Error = BT_ERR_GENERIC; goto err_out; } BT_INTEGRATED_DRIVER *pDriver = BT_GetIntegratedDriverByName("mmc,sdhci"); if(!pDriver) { Error = BT_ERR_GENERIC; goto err_out; } return pDriver->pfnProbe(pDevice, pError); err_out: if(pError) { *pError = Error; } return NULL; }
/** * If the serial port is not in use, we can make it sleep! **/ static void disableSpiPeripheralClock(BT_HANDLE hSpi) { const BT_RESOURCE *pResource = BT_GetIntegratedResource(hSpi->pDevice, BT_RESOURCE_ENUM, 0); switch(pResource->ulStart) { case 0: { LPC17xx_RCC->PCONP &= ~LPC17xx_RCC_PCONP_SPIEN; break; } case 1: { LPC17xx_RCC->PCONP &= ~LPC17xx_RCC_PCONP_SSP0EN; break; } case 2: { LPC17xx_RCC->PCONP &= ~LPC17xx_RCC_PCONP_SSP1EN; break; } default: { break; } } }
/** * If the serial port is not in use, we can make it sleep! **/ static void disableUartPeripheralClock(BT_HANDLE hUart) { const BT_RESOURCE *pResource = BT_GetIntegratedResource(hUart->pDevice, BT_RESOURCE_ENUM, 0); switch(pResource->ulStart) { case 0: { LM3Sxx_RCC->RCGC[1] &= ~LM3Sxx_RCC_RCGC_UART0EN; break; } case 1: { LM3Sxx_RCC->RCGC[1] &= ~LM3Sxx_RCC_RCGC_UART1EN; break; } case 2: { LM3Sxx_RCC->RCGC[1] &= ~LM3Sxx_RCC_RCGC_UART2EN; break; } default: { break; } } }