//LCD地址结构体
typedef struct
{
unsigned char sja0 ;
unsigned char sja1 ;
unsigned char sja2 ;
unsigned char sja3 ;
unsigned char sja4 ;
unsigned char sja5 ;
unsigned char sja6 ;
unsigned char sja7 ;
unsigned char sja8 ;
unsigned char sja9 ;
unsigned char sja10 ;
unsigned char sja11 ;
unsigned char sja12 ;
unsigned char sja13 ;
unsigned char sja14 ;
unsigned char sja15 ;
unsigned char sja16 ;
unsigned char sja17 ;
unsigned char sja18 ;
unsigned char sja19 ;
unsigned char sja20 ;
unsigned char sja21 ;
unsigned char sja22 ;
unsigned char sja23 ;
unsigned char sja24 ;
unsigned char sja25 ;
unsigned char sja26 ;
unsigned char sja27 ;
unsigned char sja28 ;
unsigned char sja29 ;
unsigned char sja30 ;
unsigned char sja31 ;
unsigned char sja96 ;
unsigned char sja97 ;
unsigned char sja98 ;
unsigned char sja99 ;
unsigned char sja100 ;
unsigned char sja101 ;
unsigned char sja102 ;
unsigned char sja103 ;
unsigned char sja104 ;
unsigned char sja105 ;
unsigned char sja106 ;
unsigned char sja107 ;
unsigned char sja108 ;
} SJA1000_AddTypeDef;
#define SJA1000_BASE ((vu32)(0x68000000))
#define SJA1000 ((SJA1000_AddTypeDef *) SJA1000_BASE)
/*******************************************************************************
* 函数名称:
* 函数功能: SJA1000硬件配置初始化
* 参 数:
* 返 回 值:
*******************************************************************************/
void SJA1000_HardwareConfiguration(void) //
{
GPIO_InitTypeDef GPIO_InitStructure;
FSMC_NORSRAMInitTypeDef FSMC_NORSRAMInitStructure;
FSMC_NORSRAMTimingInitTypeDef readWriteTiming;
FSMC_NORSRAMTimingInitTypeDef writeTiming;
RCC_AHB1PeriphClockCmd(RCC_AHB1Periph_GPIOB | RCC_AHB1Periph_GPIOD | RCC_AHB1Periph_GPIOE | RCC_AHB1Periph_GPIOG, ENABLE);
RCC_AHB3PeriphClockCmd(RCC_AHB3Periph_FSMC, ENABLE);
GPIO_InitStructure.GPIO_Pin = GPIO_Pin_0;//PE0 RESET
GPIO_InitStructure.GPIO_Mode = GPIO_Mode_OUT;//普通输出模式
GPIO_InitStructure.GPIO_OType = GPIO_OType_PP;//推挽输出
GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz;//100MHz
GPIO_InitStructure.GPIO_PuPd = GPIO_PuPd_UP;//上拉
GPIO_Init(GPIOE, &GPIO_InitStructure);//初始化
GPIO_InitStructure.GPIO_Pin = GPIO_Pin_7;// NL ALE
GPIO_InitStructure.GPIO_Mode = GPIO_Mode_AF;//复用输出
GPIO_InitStructure.GPIO_OType = GPIO_OType_PP;//推挽输出
GPIO_InitStructure.GPIO_Speed = GPIO_Speed_100MHz;//100MHz
GPIO_InitStructure.GPIO_PuPd = GPIO_PuPd_UP;//上拉
GPIO_Init(GPIOB, &GPIO_InitStructure);//初始化
// GPIO_InitStructure.GPIO_Pin = (3 << 0) | (3 << 4) | (7 << 8) | (3 << 14); //PD0,1,4,5,8,9,10,14,15 AF OUT
GPIO_InitStructure.GPIO_Pin = (GPIO_Pin_0 | GPIO_Pin_1 | GPIO_Pin_4 | GPIO_Pin_5 | GPIO_Pin_14 | GPIO_Pin_15);
GPIO_InitStructure.GPIO_Mode = GPIO_Mode_AF;//复用输出
GPIO_InitStructure.GPIO_OType = GPIO_OType_PP;//推挽输出
GPIO_InitStructure.GPIO_Speed = GPIO_Speed_100MHz;//100MHz
GPIO_InitStructure.GPIO_PuPd = GPIO_PuPd_UP;//上拉
GPIO_Init(GPIOD, &GPIO_InitStructure);//初始化
GPIO_InitStructure.GPIO_Pin = (GPIO_Pin_7 | GPIO_Pin_8 | GPIO_Pin_9 | GPIO_Pin_10);
GPIO_InitStructure.GPIO_Mode = GPIO_Mode_AF;//复用输出
GPIO_InitStructure.GPIO_OType = GPIO_OType_PP;//推挽输出
GPIO_InitStructure.GPIO_Speed = GPIO_Speed_100MHz;//100MHz
GPIO_InitStructure.GPIO_PuPd = GPIO_PuPd_UP;//上拉
GPIO_Init(GPIOE, &GPIO_InitStructure);//初始化
GPIO_InitStructure.GPIO_Pin = GPIO_Pin_10;//
GPIO_InitStructure.GPIO_Mode = GPIO_Mode_AF;//复用输出
GPIO_InitStructure.GPIO_OType = GPIO_OType_PP;//推挽输出
GPIO_InitStructure.GPIO_Speed = GPIO_Speed_100MHz;//100MHz
GPIO_InitStructure.GPIO_PuPd = GPIO_PuPd_UP;//上拉
GPIO_Init(GPIOG, &GPIO_InitStructure);//初始化
GPIO_PinAFConfig(GPIOD, GPIO_PinSource0, GPIO_AF_FSMC); //PD0,AF12
GPIO_PinAFConfig(GPIOD, GPIO_PinSource1, GPIO_AF_FSMC); //PD1,AF12
GPIO_PinAFConfig(GPIOD, GPIO_PinSource4, GPIO_AF_FSMC);
GPIO_PinAFConfig(GPIOD, GPIO_PinSource5, GPIO_AF_FSMC);
//GPIO_PinAFConfig(GPIOD, GPIO_PinSource8, GPIO_AF_FSMC);
//GPIO_PinAFConfig(GPIOD, GPIO_PinSource9, GPIO_AF_FSMC);
//GPIO_PinAFConfig(GPIOD, GPIO_PinSource10, GPIO_AF_FSMC);
GPIO_PinAFConfig(GPIOD, GPIO_PinSource14, GPIO_AF_FSMC);
GPIO_PinAFConfig(GPIOD, GPIO_PinSource15, GPIO_AF_FSMC); //PD15,AF12
GPIO_PinAFConfig(GPIOE, GPIO_PinSource7, GPIO_AF_FSMC); //PE7,AF12
GPIO_PinAFConfig(GPIOE, GPIO_PinSource8, GPIO_AF_FSMC);
GPIO_PinAFConfig(GPIOE, GPIO_PinSource9, GPIO_AF_FSMC);
GPIO_PinAFConfig(GPIOE, GPIO_PinSource10, GPIO_AF_FSMC);
//GPIO_PinAFConfig(GPIOE, GPIO_PinSource11, GPIO_AF_FSMC);
//GPIO_PinAFConfig(GPIOE, GPIO_PinSource12, GPIO_AF_FSMC);
//GPIO_PinAFConfig(GPIOE, GPIO_PinSource13, GPIO_AF_FSMC);
//GPIO_PinAFConfig(GPIOE, GPIO_PinSource14, GPIO_AF_FSMC);
//GPIO_PinAFConfig(GPIOE, GPIO_PinSource15, GPIO_AF_FSMC); //PE15,AF12
//GPIO_PinAFConfig(GPIOF, GPIO_PinSource12, GPIO_AF_FSMC); //PF12,AF12
GPIO_PinAFConfig(GPIOG, GPIO_PinSource10, GPIO_AF_FSMC);
readWriteTiming.FSMC_AddressSetupTime = 0x0f; //地址建立时间(ADDSET)为16个HCLK 1/168M=6ns*16=96ns
readWriteTiming.FSMC_AddressHoldTime = 0x00; //地址保持时间(ADDHLD)模式A未用到
readWriteTiming.FSMC_DataSetupTime = 0x3c; //数据保存时间为60个HCLK =6*60=360ns
readWriteTiming.FSMC_BusTurnAroundDuration = 0x00;
readWriteTiming.FSMC_CLKDivision = 0x00;
readWriteTiming.FSMC_DataLatency = 0x00;
readWriteTiming.FSMC_AccessMode = FSMC_AccessMode_B; //模式A
writeTiming.FSMC_AddressSetupTime = 0x0f; //地址建立时间(ADDSET)为16个HCLK 1/168M=6ns*16=96ns
writeTiming.FSMC_AddressHoldTime = 0x00; //地址保持时间(A
writeTiming.FSMC_DataSetupTime = 0x3c; //数据保存时间为60个HCLK =6*60=360ns
writeTiming.FSMC_BusTurnAroundDuration = 0x00;
writeTiming.FSMC_CLKDivision = 0x00;
writeTiming.FSMC_DataLatency = 0x00;
writeTiming.FSMC_AccessMode = FSMC_AccessMode_B; //模式A
FSMC_NORSRAMInitStructure.FSMC_Bank = FSMC_Bank1_NORSRAM3;// 这里我们使用NE4 ,也就对应BTCR[6],[7]。
FSMC_NORSRAMInitStructure.FSMC_DataAddressMux = FSMC_DataAddressMux_Enable; // 复用数据地址
FSMC_NORSRAMInitStructure.FSMC_MemoryType = FSMC_MemoryType_NOR; // FSMC_MemoryType_SRAM; //SRAM
FSMC_NORSRAMInitStructure.FSMC_MemoryDataWidth = FSMC_MemoryDataWidth_8b;//存储器数据宽度为16bit
FSMC_NORSRAMInitStructure.FSMC_BurstAccessMode = FSMC_BurstAccessMode_Disable; // FSMC_BurstAccessMode_Disable;
FSMC_NORSRAMInitStructure.FSMC_WaitSignalPolarity = FSMC_WaitSignalPolarity_Low;
FSMC_NORSRAMInitStructure.FSMC_AsynchronousWait = FSMC_AsynchronousWait_Disable;
FSMC_NORSRAMInitStructure.FSMC_WrapMode = FSMC_WrapMode_Disable;
FSMC_NORSRAMInitStructure.FSMC_WaitSignalActive = FSMC_WaitSignalActive_BeforeWaitState;
FSMC_NORSRAMInitStructure.FSMC_WriteOperation = FSMC_WriteOperation_Enable; // 存储器写使能
FSMC_NORSRAMInitStructure.FSMC_WaitSignal = FSMC_WaitSignal_Disable;
FSMC_NORSRAMInitStructure.FSMC_ExtendedMode = FSMC_ExtendedMode_Enable; // 读写使用不同的时序
FSMC_NORSRAMInitStructure.FSMC_WriteBurst = FSMC_WriteBurst_Disable;
FSMC_NORSRAMInitStructure.FSMC_ReadWriteTimingStruct = &readWriteTiming; //读写时序
FSMC_NORSRAMInitStructure.FSMC_WriteTimingStruct = &writeTiming; //写时序
FSMC_NORSRAMInit(&FSMC_NORSRAMInitStructure); //初始化FSMC配置
FSMC_NORSRAMCmd(FSMC_Bank1_NORSRAM3, ENABLE); // 使能BANK1
}
代码:NVAD为什么没有变化?有没有哪位大神用STM32驱动过SJA1000的,能不能分享一下,谢谢,不胜感激
一周热门 更多>