您的位置 首页 嵌入式

LM3S9B96的EPI总线的HB8形式装备

下面是EPI的HB8模式的例子:/*Includes—————————————–*/#includeinc/hw_memmap.h#include

下面是EPI的HB8形式的比如:


/* 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);
// 运用相同波特率 地址数据不复用 cs信号 字节读取
EPIConfigHB8Set(EPI0_BASE, EPI_HB8_MODE_ADDEMUX | EPI_HB8_WRWAIT_1 |
EPI_HB8_RDWAIT_1 | EPI_HB8_CSCFG_CS, 0);
// 映射到片外外设地址0xA000 0000
EPIAddressMapSet(EPI0_BASE, EPI_ADDR_PER_SIZE_256B | EPI_ADDR_PER_BASE_A);
g_pusEPIPER = (unsigned short *)0xA0000000;
// 初始化结束,就可以运用读写数据了
g_pusEPIPER[0] = 0xff; // 表明向外设地址0处写ff
temp = g_pusEPIPER[0]; // 表明读地址0处的值
}

仅供参考!

声明:本文内容来自网络转载或用户投稿,文章版权归原作者和原出处所有。文中观点,不代表本站立场。若有侵权请联系本站删除(kf@86ic.com)https://www.86ic.net/qianrushi/275162.html

为您推荐

联系我们

联系我们

在线咨询: QQ交谈

邮箱: kf@86ic.com

关注微信
微信扫一扫关注我们

微信扫一扫关注我们

返回顶部