Ejemplo n.º 1
0
/**
 *	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;
}
Ejemplo n.º 2
0
/**
 *	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;
}
Ejemplo n.º 3
0
BT_ERROR BT_UnregisterInterrupt(BT_u32 ulIRQ, BT_FN_INTERRUPT_HANDLER pfnHandler, void *pParam) {

    BT_ERROR Error;

    const BT_INTERRUPT_CONTROLLER *pIntc = getInterruptController(ulIRQ);
    if(!pIntc) {
        return -1;
    }

    BT_DisableInterrupt(ulIRQ);

    Error = pIntc->BT_IF_IRQ_OPS(hIRQ)->pfnUnregister(pIntc->hIRQ, ulIRQ-pIntc->ulBaseIRQ, pfnHandler, pParam);

    return Error;
}
Ejemplo n.º 4
0
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;
}
Ejemplo n.º 5
0
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;
}
Ejemplo n.º 6
0
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;
}
Ejemplo n.º 7
0
/**
 *	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;
}