×
单片机 > 单片机程序设计 > 详情

LM3S9B96的EPI总线的HB8模式配置

发布时间:2020-06-20 发布时间:
|
下面是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 ------------------------------*/
unsigned char temp;
 
/*********************************************
*
* Use the following to specify the GPIO pins used by the HB8 EPI bus.
*
***********************************************/
#define EPI_PORTC_PINS (GPIO_PIN_7 | GPIO_PIN_6 | GPIO_PIN_5 | GPIO_PIN_4)
#define EPI_PORTD_PINS (GPIO_PIN_3 | GPIO_PIN_2)
#define EPI_PORTE_PINS (GPIO_PIN_1 | GPIO_PIN_0)
#define EPI_PORTF_PINS (GPIO_PIN_5 | GPIO_PIN_4)
#define EPI_PORTG_PINS (GPIO_PIN_7 | GPIO_PIN_1 | GPIO_PIN_0)
#define EPI_PORTH_PINS (GPIO_PIN_5 | GPIO_PIN_4 | GPIO_PIN_3 | GPIO_PIN_2 | \
                        GPIO_PIN_1 | GPIO_PIN_0)
#define EPI_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.
*
**********************************************************/
static volatile unsigned short *g_pusEPIPER; 
 
 
/**********************************************************
* Function Name  : main
* Description    : Main program.
* Input          : None
* Output         : None
* Return         : None
***********************************************************/
int main(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处的值
}
 

 

仅供参考!
关键字:LM3S9B96  EPI总线  HB8模式配置 

『本文转载自网络,版权归原作者所有,如有侵权请联系删除』

热门文章 更多
TQ210天嵌开发板S5PV210 LED闪烁程序C语言代码记录