此程序有IIC读写功能,有从机无响应功能
stm32单片机源程序如下:
- /**
- ******************************************************************************
- * @file main.c
- * @author fire
- * @version V1.0
- * @date 2013-xx-xx
- * @brief AT24C02测试(软件模拟I2C)
- */
-
- #include "stm32f10x.h"
- #include "./usart/bsp_usart.h"
- #include "./led/bsp_led.h"
- #include "./i2c/bsp_i2c_ee.h"
- #include "./bsp_beep.h"
- void Delay(__IO u32 nCount);
- /**
- * @brief 主函数
- * @param 无
- * @retval 无
- */
- int main(void)
- {
- uint8_t ee_Test(void);
- uint8_t ee_Test(void);
- LED_GPIO_Config();
- BEEP_GPIO_Config();
-
- /* 串口初始化 */
- USART_Config();
-
- i2c_CfgGpio();
- printf("eeprom 软件模拟i2c测试例程 \r\n");
-
- if(ee_Test() ==1)
- {
- LED_G(ON);
- }
- else
- {
- while(1)
- {
- BEEP( ON1 ); // 响
- Delay(0x0FFFFF);
- }
- }
- while(1);
- }
- void Delay(__IO uint32_t nCount) //简单的延时函数
- {
- for(; nCount != 0; nCount--);
- }
- /*********************************************END OF FILE**********************/
复制代码
所有资料51hei提供下载:
模拟i2c.rar
(302.72 KB, 下载次数: 63)
|