/******************** (C) COPYRIGHT 2017 EESKILL多功能开发学习板********************
* 文件名 :main.c
* 描述 :CPU不断读取DS1302时钟芯片上的数据,并显示在oled上
* 实验平台:EESKILL多功能开发学习板
* 库版本 :ST3.5.0
* 单片机IO | PB08 - JP45 - RST |时钟模块控制端
* | PB09 - IO |
* | PB10 - SCLK |
* -----------------------
* 单片机IO | PA0 - JP51 - DIN | OLED模块
* | PA1 - JP51 - SCK |
* | PA2 - JP51 - DC |
* | PA3 - JP51 - RES |
* | PA4 - JP51 - CS |
**********************************************************************************/
#include "stm32f10x.h"
#include "DS1302.h"
#include "oled.h"
#include "delay.h"
u8 Nian,Yue,Ri,XingQi,Shi,Fen,Miao;
/*
* 函数名:main
* 描述 : 主函数
* 输入 :无
* 输出 : 无
*/
int main(void)
{
/* 设置系统时钟为72M */
SystemInit();
DS1302_GPIO_Init();
OLED_Init(); //初始化OLED
DS1302_init(0x17,0x07,0x10,0x08,0x30,0x00);//设置年月日 时分秒
OLED_ShowString2(0,7,11,"DS1302 TEST");
OLED_ShowString2(0,5,5,"DATE:");
OLED_ShowString2(0,3,5,"TIME:");
while(1)
{
DS1302_read_time();
LCD_P8x16Ch2(40,5,(Nian>>4)+0x30);
LCD_P8x16Ch2(48,5,(Nian&0x0f)+0x30);
OLED_ShowString2(56,5,1,"-");
LCD_P8x16Ch2(64,5,(Yue>>4)+0x30);
LCD_P8x16Ch2(72,5,(Yue&0x0f)+0x30);
OLED_ShowString2(80,5,1,"-");
LCD_P8x16Ch2(88,5,(Ri>>4)+0x30);
LCD_P8x16Ch2(96,5,(Ri&0x0f)+0x30);
LCD_P8x16Ch2(40,3,(Shi>>4)+0x30);
LCD_P8x16Ch2(48,3,(Shi&0x0f)+0x30);
OLED_ShowString2(56,3,1,":");
LCD_P8x16Ch2(64,3,(Fen>>4)+0x30);
LCD_P8x16Ch2(72,3,(Fen&0x0f)+0x30);
OLED_ShowString2(80,3,1,":");
LCD_P8x16Ch2(88,3,(Miao>>4)+0x30);
LCD_P8x16Ch2(96,3,(Miao&0x0f)+0x30);
delay_ms(500);
}
}
/******************* (C) COPYRIGHT 2017 EESKILL多功能开发学习板*****END OF FILE****/