⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 rtc.c.svn-base

📁 Spearhead2000 的 USB驱动程序
💻 SVN-BASE
字号:
/********************************************************************************                                                                           ****  Copyright (c) 2000 ST Microelectronics                                   ****  All rights reserved                                                      ****                                                                           ****      Filename  :  rtc.c                                                   ****      Author    :  Stefano Romano                                          ****      Revision  :  1.0                                                     ****                                                                           ****                                                                           ****                                                                           *********************************************************************************//******************************************************************************/#include "rtc.h"#include "vic_pl190.h"#include "uart.h"/************************ interrupt handler ************************/void rtc_int_handler(){	RTCCntl->STATUS_REG |= RTC_INT_CLR; //interrupt clear	/* Interrupt on GPIO0 *//* 	gpioWrite(0, 0);	gpioWrite(0, 1);	gpioWrite(0, 0);         */	/**********************/}/************************** initialization *************************/void rtc_init(){	/* interrupt enabling *//*	intctlIntRegister(ITC_RTC_int, rtc_int_handler, 1);	RTCCntl->CONTROL_REG = INT_ENA;                      */	/**********************/		/* Time setting *///	RTCCntl->TIME_REG = 0x00123015;       //12:30 15//	RTCCntl->DATE_REG = 0x20050929;       //29/09/2005	/***************/}/***************************** Execution ***************************/void rtc_test(void){	    	char schedule;    	char in_buf;	unsigned int date;	unsigned int time;		schedule = 'r';	while(schedule != 's')	{		UART_tx_vec("Select:",strlen("Select:"));		UART_tx_vec("0 -> Read date;",strlen("0 -> Set  time;"));		UART_tx_vec("1 -> Read time;",strlen("0 -> Set  time;"));		UART_tx_vec("2 -> Set  date;",strlen("0 -> Set  time;"));		UART_tx_vec("3 -> Set  time;",strlen("0 -> Set  time;"));		while (!(UART_getc(&in_buf)));		switch(in_buf)		{			case '0':				UART_print_ex((unsigned int)RTCCntl->DATE_REG);			break;			case '1':				UART_print_ex((unsigned int)RTCCntl->TIME_REG);			break;			case '2':				date = 0;				UART_tx_vec("Insert date (yyyymmdd)",strlen("Insert date (yyyymmdd)"));				date = UART_get_ex();				while (!(UART_putc(13)));				while (!(UART_putc(10)));				if(date == 0) 				{					UART_tx_vec("Error! digit a correct date.", strlen("Error! digit a correct date."));				}				else				{					UART_tx_vec("The inserted date is:",strlen("The inserted date is:"));					UART_print_ex(date);					RTCCntl->DATE_REG = date;				}			break;			case '3':				time = 0;				UART_tx_vec("Insert time (hhmmss)",strlen("Insert date (hhmmss)"));				time = UART_get_ex();				while (!(UART_putc(13)));				while (!(UART_putc(10)));				if(time == 0) 				{					UART_tx_vec("Error! digit a correct time.", strlen("Error! digit a correct time."));				}				else				{					UART_tx_vec("The inserted time is:",strlen("The inserted time is:"));					UART_print_ex(time);					RTCCntl->TIME_REG = time;				}			break;		}							while (!(UART_putc(13)));		while (!(UART_putc(10)));		UART_tx_vec("press s to stop r to run",strlen("press s to stop r to run"));		while (!(UART_getc(&schedule)));		while (!(UART_putc(13)));		while (!(UART_putc(10)));	}		}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -