/**
******************************************************************************
* @file main.c
* @author 568581185
* @version V1.1.0
* @date 2013-01-28
* @brief Main program body
* @pins:
* Nokia5110:RST=PC0,CE=PC1,DC=PC2,DIN=PC3,CLK=PC4;
* DS1302: RST=PC5,CLK=PC6,IO=PB0;
******************************************************************************
*/
/* Includes ------------------------------------------------------------------*/
#include "main.h"
/* Private typedef -----------------------------------------------------------*/
/* Private define ------------------------------------------------------------*/
/* Private macro -------------------------------------------------------------*/
#define ABS(x) (x < 0) ? (-x) : x
/* Private variables ---------------------------------------------------------*/
RCC_ClocksTypeDef RCC_Clocks;
__IO uint32_t TimingDelay = 0;
__IO uint32_t UserButtonPressed = 0;
__IO uint8_t DataReady = 0;
__IO uint8_t PrevXferComplete = 1;
__IO uint32_t USBConnectTimeOut = 100;
/* Private function prototypes -----------------------------------------------*/
/* Private functions ---------------------------------------------------------*/
void GPIO_LCD_Init(void)
{
/* Configure all the GPIOA in Input Floating mode */
GPIO_InitTypeDef GPIO_InitStructure;
RCC_AHBPeriphClockCmd(RCC_AHBPeriph_GPIOC, ENABLE);
GPIO_InitStructure.GPIO_Pin = GPIO_Pin_0 | GPIO_Pin_1 | GPIO_Pin_2 | GPIO_Pin_3 | GPIO_Pin_4 | GPIO_Pin_5 | GPIO_Pin_6;
GPIO_InitStructure.GPIO_Mode = GPIO_Mode_OUT;
GPIO_InitStructure.GPIO_OType = GPIO_OType_PP;
GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz;
GPIO_InitStructure.GPIO_PuPd = GPIO_PuPd_NOPULL;
GPIO_Init(GPIOC, &GPIO_InitStructure);
}
/**
* @brief Main program.
* @param None
* @retval None
*/
int main(void)
{
SystemInit();
/* SysTick end of count event each 10ms */
RCC_GetClocksFreq(&RCC_Clocks);
SysTick_Config(RCC_Clocks.HCLK_Frequency / 100);
GPIO_LCD_Init();
LCD_Init();
LCD_write_english_string(0,0,"20 - - ");
LCD_write_english_string(0,1," : : ");
LCD_write_english_string(0,3,"STM32F3 DS1302");
LCD_write_english_string(0,4,"21IC ID:");
LCD_write_english_string(0,5," 568581185");
ds1302_init();
ds1302_write_time();
while (1)
{
ds1302_read_time();
LCD_Write_2Num(2,0,time_buf[1]);
LCD_Write_2Num(5,0,time_buf[2]);
LCD_Write_2Num(8,0,time_buf[3]);
LCD_Write_2Num(0,1,time_buf[4]);
LCD_Write_2Num(3,1,time_buf[5]);
LCD_Write_2Num(6,1,time_buf[6]);
Show_Week();
}
}
/**
* @brief Inserts a delay time.
* @param nTime: specifies the delay time length, in 10 ms.
* @retval None
*/
void Delay(__IO uint32_t nTime)
{
TimingDelay = nTime;
while(TimingDelay != 0);
}
/**
* @brief Decrements the TimingDelay variable.
* @param None
* @retval None
*/
void TimingDelay_Decrement(void)
{
if (TimingDelay != 0x00)
{
TimingDelay--;
}
}
// 显示星期几
void Show_Week(void)
{
switch(time_buf[7])
{
case 1:
LCD_write_english_string(0,2,"Monday");
break;
case 2:
LCD_write_english_string(0,2,"Tuesday");
break;
case 3:
LCD_write_english_string(0,2,"Wednesday");
break;
case 4:
LCD_write_english_string(0,2,"Thursday");
break;
case 5:
LCD_write_english_string(0,2,"Friday");
break;
case 6:
LCD_write_english_string(0,2,"Saturday");
break;
case 7:
LCD_write_english_string(0,2,"Sunday");
break;
default:
break;
}
}
用手机流量发的,实在是找不到地方上网,为了发这个帖子用了将近10M的流量。