⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 gpio.c

📁 MC56F802BLDC 可以使用的算法 就是电机启动有点慢
💻 C
字号:
/******************************************************************************
*
* Motorola Inc.
* (c) Copyright 2001 Motorola, Inc.
* ALL RIGHTS RESERVED.
*
*******************************************************************************
*
* FILE NAME: gpio.c   
*
* DESCRIPTION: Source file for GPIO Driver
*
* MODULES INCLUDED:
*
* NOTES:
*
*******************************************************************************/

#include "types.h"
#include "arch.h"
#include "periph.h"

#include "appconfig.h"
#include "gpio.h"

/********************************************************************************
 gpioInit() function performs the GPIO module static configuration
 based on the configurable items from appconfig.h 
********************************************************************************/
void gpioInit(arch_sPort *pGpioBase)
{
	if (pGpioBase == GPIO_A)
	{
		/* configure GPIO PORT A */
		#ifdef GPIO_A_PULLUP_ENABLE_REG
		periphMemWrite(GPIO_A_PULLUP_ENABLE_REG, &((arch_sPort*)pGpioBase)->PullUpReg);
		#endif
		
		#ifdef GPIO_A_DATA_DIRECTION_REG
		periphMemWrite(GPIO_A_DATA_DIRECTION_REG, &((arch_sPort*)pGpioBase)->DataDirectionReg);
		#endif
		
		#ifdef GPIO_A_PERIPHERAL_ENABLE_REG
		periphMemWrite(GPIO_A_PERIPHERAL_ENABLE_REG, &((arch_sPort*)pGpioBase)->PeripheralReg);
		#endif
		
		#ifdef GPIO_A_INTERRUPT_ENABLE_REG
		periphMemWrite(GPIO_A_INTERRUPT_ENABLE_REG, &((arch_sPort*)pGpioBase)->IntEnableReg);
		#endif
		
		#ifdef GPIO_A_INTERRUPT_POLARITY_REG
		periphMemWrite(GPIO_A_INTERRUPT_POLARITY_REG, &((arch_sPort*)pGpioBase)->IntPolarityReg);
		#endif
	}
	#if( !(defined(DSP56F803)) )
	else if (pGpioBase == GPIO_B)
	{
		/* configure GPIO PORT B */
		#ifdef GPIO_B_PULLUP_ENABLE_REG
		periphMemWrite(GPIO_B_PULLUP_ENABLE_REG, &pGpioBase->PullUpReg);
		#endif
		
		#ifdef GPIO_B_DATA_DIRECTION_REG
		periphMemWrite(GPIO_B_DATA_DIRECTION_REG, &pGpioBase->DataDirectionReg);
		#endif
		
		#ifdef GPIO_B_PERIPHERAL_ENABLE_REG
		periphMemWrite(GPIO_B_PERIPHERAL_ENABLE_REG, &pGpioBase->PeripheralReg);
		#endif
		
		#ifdef GPIO_B_INTERRUPT_ENABLE_REG
		periphMemWrite(GPIO_B_INTERRUPT_ENABLE_REG, &pGpioBase->IntEnableReg);
		#endif
		
		#ifdef GPIO_B_INTERRUPT_POLARITY_REG
		periphMemWrite(GPIO_B_INTERRUPT_POLARITY_REG, &pGpioBase->IntPolarityReg);
		#endif	
	}
	#endif
	#if( defined(DSP56F805) || defined(DSP56F807) )
	else if (pGpioBase == GPIO_D)
	{
		/* configure GPIO PORT D */
		#ifdef GPIO_D_PULLUP_ENABLE_REG
		periphMemWrite(GPIO_D_PULLUP_ENABLE_REG, &pGpioBase->PullUpReg);
		#endif
		
		#ifdef GPIO_D_DATA_DIRECTION_REG
		periphMemWrite(GPIO_D_DATA_DIRECTION_REG, &pGpioBase->DataDirectionReg);
		#endif
		
		#ifdef GPIO_D_PERIPHERAL_ENABLE_REG
		periphMemWrite(GPIO_D_PERIPHERAL_ENABLE_REG, &pGpioBase->PeripheralReg);
		#endif
		
		#ifdef GPIO_D_INTERRUPT_ENABLE_REG
		periphMemWrite(GPIO_D_INTERRUPT_ENABLE_REG, &pGpioBase->IntEnableReg);
		#endif
		
		#ifdef GPIO_D_INTERRUPT_POLARITY_REG
		periphMemWrite(GPIO_D_INTERRUPT_POLARITY_REG,&pGpioBase->IntPolarityReg);
		#endif	
	}
	#endif
	#if( !(defined(DSP56F801)) )
	else if (pGpioBase == GPIO_E)
	{
		/* configure GPIO PORT E */
		#ifdef GPIO_E_PULLUP_ENABLE_REG
		periphMemWrite(GPIO_E_PULLUP_ENABLE_REG, &pGpioBase->PullUpReg);
		#endif
		
		#ifdef GPIO_E_DATA_DIRECTION_REG
		periphMemWrite(GPIO_E_DATA_DIRECTION_REG, &pGpioBase->DataDirectionReg);
		#endif
		
		#ifdef GPIO_E_PERIPHERAL_ENABLE_REG
		periphMemWrite(GPIO_E_PERIPHERAL_ENABLE_REG, &pGpioBase->PeripheralReg);
		#endif
		
		#ifdef GPIO_E_INTERRUPT_ENABLE_REG
		periphMemWrite(GPIO_E_INTERRUPT_ENABLE_REG, &pGpioBase->IntEnableReg);
		#endif
	
		#ifdef GPIO_E_INTERRUPT_POLARITY_REG
		periphMemWrite(GPIO_E_INTERRUPT_POLARITY_REG, &pGpioBase->IntPolarityReg);
		#endif
	}
	#endif
}


⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -