LM3S9B96的EPI總線的HB8模式配置
本文引用地址:http://m.butianyuan.cn/article/201611/317014.htm
/* Includes -----------------------------------------*/
#include"inc/hw_memmap.h"
#include"inc/hw_types.h"
#include"driverlib/gpio.h"
#include"driverlib/sysctl.h"
#include"driverlib/epi.h"
/* Private variables ------------------------------*/
unsignedchartemp;
/*********************************************
*
* Use the following to specify the GPIO pins used by the HB8 EPI bus.
*
***********************************************/
#defineEPI_PORTC_PINS(GPIO_PIN_7|GPIO_PIN_6|GPIO_PIN_5|GPIO_PIN_4)
#defineEPI_PORTD_PINS(GPIO_PIN_3|GPIO_PIN_2)
#defineEPI_PORTE_PINS(GPIO_PIN_1|GPIO_PIN_0)
#defineEPI_PORTF_PINS(GPIO_PIN_5|GPIO_PIN_4)
#defineEPI_PORTG_PINS(GPIO_PIN_7|GPIO_PIN_1|GPIO_PIN_0)
#defineEPI_PORTH_PINS(GPIO_PIN_5|GPIO_PIN_4|GPIO_PIN_3|GPIO_PIN_2|
GPIO_PIN_1|GPIO_PIN_0)
#defineEPI_PORTJ_PINS(GPIO_PIN_6|GPIO_PIN_5|GPIO_PIN_4|GPIO_PIN_3|
GPIO_PIN_2|GPIO_PIN_1|GPIO_PIN_0)
/********************************************************
*
* A pointer to the EPI Peripheral. Note that g_pusEPIPER is declared
* as volatile so the compiler should not optimize reads out of the image.
*
**********************************************************/
staticvolatileunsignedshort*g_pusEPIPER;
/**********************************************************
* Function Name : main
* Description : Main program.
* Input : None
* Output : None
* Return : None
***********************************************************/
intmain(void)
{
// Set the clocking to run directly from the external crystal/oscillator
SysCtlClockSet(SYSCTL_SYSDIV_1 | SYSCTL_USE_OSC | SYSCTL_OSC_MAIN |
SYSCTL_XTAL_16MHZ);
// The EPI0 peripheral must be enabled for use
SysCtlPeripheralEnable(SYSCTL_PERIPH_EPI0);
// For this example EPI0 is used with multiple pins on PortC, E, F, G, H, and 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);
// 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. In this case set the
// divider to 0, making the EPIClock = SysClk.
EPIDividerSet(EPI0_BASE, 0);
// Sets the usage mode of the EPI module. EPI_MODE_HB8
EPIModeSet(EPI0_BASE, EPI_MODE_HB8);
// 使用相同波特率 地址數(shù)據(jù)不復(fù)用 cs信號 字節(jié)讀取
EPIConfigHB8Set(EPI0_BASE, EPI_HB8_MODE_ADDEMUX | EPI_HB8_WRWAIT_1 |
EPI_HB8_RDWAIT_1 | EPI_HB8_CSCFG_CS, 0);
// 映射到片外外設(shè)地址0xA000 0000
EPIAddressMapSet(EPI0_BASE, EPI_ADDR_PER_SIZE_256B | EPI_ADDR_PER_BASE_A);
g_pusEPIPER = (unsigned short *)0xA0000000;
// 初始化完畢,就可以使用讀寫數(shù)據(jù)了
g_pusEPIPER[0] = 0xff; // 表示向外設(shè)地址0處寫ff
temp = g_pusEPIPER[0]; // 表示讀地址0處的值
}
僅供參考!
評論