此程序有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)
2018-7-10 19:12 上傳
點擊文件名下載附件
|