一起探讨学习
单片机源程序如下:
- #include "bsp.h"
- #include "stdio.h"
- #include "string.h"
- #include "ds1307.h"
- #include "soft_iic.h"
- #define led_1() GPIO_WriteHigh(GPIOD, GPIO_PIN_0)
- #define led_0() GPIO_WriteLow(GPIOD, GPIO_PIN_0)
- u8 sendData[] = "iic_test";
- u8 revData[10];
- u8 DeviceData[10];
- void main(void)
- {
- uint8_t rev_dat=0;
- uint8_t i=0;
- uint8_t t_data=0x11;
- uint8_t t_data1=0x00;
-
- uint8_t temp;
- BSP_Initializes();
- soft_IIC_init();
- IIC_Init();
- led_0();
- timer_delay_s(1);
- led_1();
-
- //IIC_Write(0xD0 , 0x07 , &t_data , 1); //用片内IIC写数据
- //IIC_Write(0xD0 , 0x03 , &t_data1 , 1);
-
- iic_write_ds1307(0xD0,0x07,0x13);//control SQ_pin ouuput square wave address 0x07
- // 0x10 <--> 1Hz 0x11 <--> 4096Hz 0x12 <--> 8192Hz 0x13 <--> 32.768kHz
-
- //iic_write_ds1307(0xD0,0x02,0xd);
- rev_dat = iic_read_ds1307(0xD0,0x01); //read mimutes
- while(1)
- {
-
- if(rev_dat==35)
- {
- led_0();
- timer_delay_s(1);
- led_1();
- timer_delay_s(1);
- }
-
- }
- }
- #ifdef USE_FULL_ASSERT
- void assert_failed(u8* file, u32 line)
- {
- /* User can add his own implementation to report the file name and line number,
- ex: printf("Wrong parameters value: file %s on line %d\r\n", file, line) */
- /* Infinite loop */
- while (1)
- {
- }
- }
- #endif
复制代码
所有资料51hei提供下载:
GPIO_IIC -1.7z
(3.83 MB, 下载次数: 64)
|