LM3S9B96的EPI总线的HB16模式配置
全局变量定义区
//*****************************************************************************
volatile WORD usDI16 = 0x0000;
static volatile WORD *g_pusEPIPER;
//*****************************************************************************
// 函数声明区
//*****************************************************************************
extern void fs_init(void);
extern void fs_tick(unsigned long ulTickMS);
//*****************************************************************************
//
// The error routine that is called if the driver library encounters an error.
//
//*****************************************************************************
#ifdef DEBUG
void __error__(char *pcFilename, unsigned long ulLine)
{
}
#endif
//*****************************************************************************
//
// 系统时钟初始化函数
//
//*****************************************************************************
void SysClk_Init(void)
{
// 配置系统主时钟, 使用外部晶振16M.
SysCtlClockSet(SYSCTL_SYSdiv_1 | SYSCTL_USE_OSC | SYSCTL_OSC_MAIN | SYSCTL_XTAL_16MHZ);
}
//*****************************************************************************
//
// This example demonstrates the use of the Ethernet Controller.
//
//*****************************************************************************
int main(void)
{
// 系统时钟初始化为16MHz
SysClk_Init();
// 使能A~J管脚
// PinoutSet();
// 开总中断
IntMasterEnable();
// The EPI0 peripheral must be enabled for use
SysCtlPeripheralEnable(SYSCTL_PERIPH_EPI0);
// EPI0 is used with multiple pins on Port C, E, F, G, H, J
SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOC);
SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOE);
SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOF);
SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOG);
SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOH);
SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOJ);
GPIOPadConfigSet(GPIO_PORTC_BASE, EPI_PORTC_PINS, GPIO_STRENGTH_8MA, GPIO_PIN_TYPE_STD);
// GPIOPadConfigSet(GPIO_PORTD_BASE, EPI_PORTD_PINS, GPIO_STRENGTH_8MA, GPIO_PIN_TYPE_STD);
GPIOPadConfigSet(GPIO_PORTE_BASE, EPI_PORTE_PINS, GPIO_STRENGTH_8MA, GPIO_PIN_TYPE_STD);
GPIOPadConfigSet(GPIO_PORTF_BASE, EPI_PORTF_PINS, GPIO_STRENGTH_8MA, GPIO_PIN_TYPE_STD);
GPIOPadConfigSet(GPIO_PORTG_BASE, EPI_PORTG_PINS, GPIO_STRENGTH_8MA, GPIO_PIN_TYPE_STD);
GPIOPadConfigSet(GPIO_PORTH_BASE, EPI_PORTH_PINS, GPIO_STRENGTH_8MA, GPIO_PIN_TYPE_STD);
GPIOPadConfigSet(GPIO_PORTJ_BASE, EPI_PORTJ_PINS, GPIO_STRENGTH_8MA, GPIO_PIN_TYPE_STD);
GPIODirModeSet(GPIO_PORTC_BASE, EPI_PORTC_PINS, GPIO_DIR_MODE_HW);
// GPIODirModeSet(GPIO_PORTD_BASE, EPI_PORTD_PINS, GPIO_DIR_MODE_HW);
GPIODirModeSet(GPIO_PORTE_BASE, EPI_PORTE_PINS, GPIO_DIR_MODE_HW);
GPIODirModeSet(GPIO_PORTF_BASE, EPI_PORTF_PINS, GPIO_DIR_MODE_HW);
GPIODirModeSet(GPIO_PORTG_BASE, EPI_PORTG_PINS, GPIO_DIR_MODE_HW);
GPIODirModeSet(GPIO_PORTH_BASE, EPI_PORTH_PINS, GPIO_DIR_MODE_HW);
GPIODirModeSet(GPIO_PORTJ_BASE, EPI_PORTJ_PINS, GPIO_DIR_MODE_HW);
// configures the internal pin muxes to set the EPI pins for use with EPI
GPIOPinConfigure(GPIO_PH3_EPI0S0);
GPIOPinConfigure(GPIO_PH2_EPI0S1);
GPIOPinConfigure(GPIO_PC4_EPI0S2);
GPIOPinConfigure(GPIO_PC5_EPI0S3);
GPIOPinConfigure(GPIO_PC6_EPI0S4);
GPIOPinConfigure(GPIO_PC7_EPI0S5);
GPIOPinConfigure(GPIO_PH0_EPI0S6);
GPIOPinConfigure(GPIO_PH1_EPI0S7);
GPIOPinConfigure(GPIO_PE0_EPI0S8);
GPIOPinConfigure(GPIO_PE1_EPI0S9);
GPIOPinConfigure(GPIO_PH4_EPI0S10);
GPIOPinConfigure(GPIO_PH5_EPI0S11);
GPIOPinConfigure(GPIO_PF4_EPI0S12);
GPIOPinConfigure(GPIO_PG0_EPI0S13);
GPIOPinConfigure(GPIO_PG1_EPI0S14);
GPIOPinConfigure(GPIO_PF5_EPI0S15);
GPIOPinConfigure(GPIO_PJ0_EPI0S16);
GPIOPinConfigure(GPIO_PJ1_EPI0S17);
GPIOPinConfigure(GPIO_PJ2_EPI0S18);
GPIOPinConfigure(GPIO_PJ3_EPI0S19);
// GPIOPinConfigure(GPIO_PD2_EPI0S20);
// GPIOPinConfigure(GPIO_PD3_EPI0S21);
// GPIOPinConfigure(GPIO_PB5_EPI0S22);
// GPIOPinConfigure(GPIO_PB4_EPI0S23);
GPIOPinConfigure(GPIO_PE2_EPI0S24);
GPIOPinConfigure(GPIO_PE3_EPI0S25);
GPIOPinConfigure(GPIO_PJ4_EPI0S28);
GPIOPinConfigure(GPIO_PJ5_EPI0S29);
GPIOPinConfigure(GPIO_PJ6_EPI0S30);
GPIOPinConfigure(GPIO_PG7_EPI0S31);
// Configure the GPIO pins for EPI mode
GPIOPinTypeEPI(GPIO_PORTC_BASE, EPI_PORTC_PINS);
GPIOPinTypeEPI(GPIO_PORTE_BASE, EPI_PORTE_PINS);
GPIOPinTypeEPI(GPIO_PORTF_BASE, EPI_PORTF_PINS);
GPIOPinTypeEPI(GPIO_PORTG_BASE, EPI_PORTG_PINS);
GPIOPinTypeEPI(GPIO_PORTH_BASE, EPI_PORTH_PINS);
GPIOPinTypeEPI(GPIO_PORTJ_BASE, EPI_PORTJ_PINS);
// Sets the clock divider for the EPI module. EPIClock = SysClk.
EPIDividerSet(EPI0_BASE, 0);
// Sets the usage mode of the EPI module. EPI_MODE_HB16
HWREG(EPI_O_CFG) = (1 < 4) | 0x1;
// 读选通信号RDn(低电平有效), 最长等待时间(可以永远挂起), 写等待态(无等待态), 读等待态(1个等待态)
// 字节选择配置(数据按照16位宽度读写), 主机并行总线的子模式(ADNOMUX子模式)
HWREG(EPI_O_HB16CFG) = (1 < 20) | (0x00 < 8) | (0x01 < 4) | (1 < 0);
// 字访问模式(使能字访问模式), 双片选波特率(相同波特率), 片选配置(EPI0S30用作片选信号CSn)
HWREG(EPI_O_HB16CFG2) = (1 < 31) | (0x01 < 24);
// 片外外设空间大小64kB(低地址范围0x0000~0xFFFF),片外外设基地址(0xA000 0000)
HWREG(EPI_O_ADDRMAP) = (0x5 < 4);
/* 初始化完毕,就可以使用读取数据了 ----------------------------------------*/
// 指向外设基地址0xA000 0000处的指针
g_pusEPIPER = (unsigned short *)0xA0000000;
// 从外设基地址0xA0000000处,读取16位数据
usDI16 = *g_pusEPIPER;
usDI16 = ~usDI16;
// Loop forever. All the work is done in interrupt handlers.
while (1)
{
}
}
//*****************************************************************************
//
// R
LM3S9B96EPI总线HB16模式配 相关文章:
- Windows CE 进程、线程和内存管理(11-09)
- RedHatLinux新手入门教程(5)(11-12)
- uClinux介绍(11-09)
- openwebmailV1.60安装教学(11-12)
- Linux嵌入式系统开发平台选型探讨(11-09)
- Windows CE 进程、线程和内存管理(二)(11-09)