|
最近小弟写了一个基于s3c2440的裸机i2c驱动可是怎么都不好使,调试时能写入但是不能读出为什么
编译环境keil uvion 4.01b
代码
这个是ii2.h
- #include "S3C2440.h"
- //引脚配置+电源配置+频率配置+iic配置
- //函数iic写一个数据 iic读一个数据 iic初始化 iic地址设置
- #include "def.h"
- #define Slave_receive_Mode 0
- #define Slave_transmit_Mode 1
- #define Master_receive_Mode 2
- #define Master_transmit_mode 3
- #define E2PROM_ADRR (0xA<<4)
- #define Read 1
- #define Write 0
- #define LED1_BV (1<<5)
- #define LED2_BV (1<<6)
- #define LED3_BV (1<<7)
- #define LED4_BV (1<<8)
- #define I2C_SDA (1<<15)
- #define I2C_SCL (1<<14)
- void I2C_Init(void);
- void I2C_Read_A_Bety(void);
- void I2C_Write_A_Bety(uint8 Data);
- void I2C_Write_n_Bety(uint8 *pData);
- void I2C_Set_Addr(void);
- void I2C_Start(void);
- void AT24C08_Write_A_Bety(uint8 Data,uint16 Adrr_10bit);
- uint8 AT24C08_Read_A_Bety(uint16 Adrr_10bit);
- void wait_ok(void);
- void I2C_Delay(void);
复制代码
这个是iic.c
这个是main.c
- #include
- #include "i2c.h"
- #include"IIC.h"
- #include "MY_IIC.h"
- //unsigned int PCLK;
- void dealy()
- {long i;
- uint16 temp=0x0;
- for(i=0;i<500000;i++);
- }
- int main()
- { uint8 temp=0;
- uint8 i=0;
- GPBCON=0;
- INTMSK=~0;
- //GPBCON|=0x51400;
- GPBCON|=(0x55<<10);
- GPBUP=0;
- //一下的寄存器只有[10:0],才11位
- GPEUP |= 0xc000;
- GPECON |= 0xa00000;
- GPBDAT=~0;
- GPBDAT=0;
- GPBDAT|= LED1_BV;
- dealy();
- GPBDAT|= LED2_BV;
- dealy();
- GPBDAT|= LED3_BV;
- dealy();
- GPBDAT|= LED4_BV;
- dealy();
- GPBDAT=~0;//全灭
- AT24C08_Write_A_Bety(5,5);
- GPBDAT&=~ LED4_BV;
- dealy();
- GPBDAT=~0;//全灭
- temp=AT24C08_Read_A_Bety(5);
- { GPBDAT|= LED1_BV;
- dealy();
- dealy();
- dealy();
- dealy();
- GPBDAT&=~LED1_BV;
- dealy();
- dealy();
- dealy();
- }
- GPBDAT=~0;//全灭
- while(1)
- { GPBDAT=(temp&0xf)<<5;
- dealy();
- GPBDAT=0;
- dealy();
- }
- return 0;
- }
- 希望大家能帮我看看
复制代码
希望大家能帮我看看
|
|