#include "S3C2451_rtc.h"
#include "S3C2451_vector.h"
RTC_MemMapPtr const RTC_BASE_Ptr = RTC_BASE_PTR;
Time_InitTypeDef rt_time;
void RTC_IRQ_Init( U8 cnt,FunctionalState NewState)
{
/// rTICNT = 0xff;
if(NewState != DISABLE)
{
RTC_BASE_Ptr->TICNT0 |= 0x80;
RTC_BASE_Ptr->TICNT0 &= ~0x7f;
if(cnt>127)
cnt = 127;
RTC_BASE_Ptr->TICNT0 |= cnt;
}else
{
RTC_BASE_Ptr->TICNT0 &= ~0x80;
}
}
void RTCTick_Interrupt_IRQInit( U32 addr)
{
pISR_TICK = addr;
}
void RTC_Time_Set( Time_InitTypeDef rtc_init_struct )
{
RTC_BASE_Ptr->RTCCON = 1 ; //RTC read and write enable
RTC_BASE_Ptr->BCDYEAR = rtc_init_struct.year; //Äê
RTC_BASE_Ptr->BCDMON = rtc_init_struct.month ; //ÔÂ
RTC_BASE_Ptr->BCDDATE = rtc_init_struct.day ; //ÈÕ
RTC_BASE_Ptr->BCDDAY = rtc_init_struct.week ; //ÐÇÆÚ
RTC_BASE_Ptr->BCDHOUR = rtc_init_struct.hour ; //Сʱ
RTC_BASE_Ptr->BCDMIN = rtc_init_struct.minute ; //·Ö
RTC_BASE_Ptr->BCDSEC = rtc_init_struct.second ; //Ãë
RTC_BASE_Ptr->RTCCON &= ~1 ; //RTC read and write disable
}
void RTC_Time_Get(Time_InitTypeDef *rtc_init_struct )
{
RTC_BASE_Ptr->RTCCON = 1 ; //RTC read and write enable
rtc_init_struct->year = 0x2000+RTC_BASE_Ptr->BCDYEAR ; //Äê
rtc_init_struct->month = RTC_BASE_Ptr->BCDMON ; //ÔÂ 12 0x12
rtc_init_struct->day = RTC_BASE_Ptr->BCDDATE ; //ÈÕ
rtc_init_struct->week = RTC_BASE_Ptr->BCDDAY ; //ÐÇÆÚ
rtc_init_struct->hour = RTC_BASE_Ptr->BCDHOUR ; //Сʱ
rtc_init_struct->minute = RTC_BASE_Ptr->BCDMIN ; //·Ö
rtc_init_struct->second = RTC_BASE_Ptr->BCDSEC ; //Ãë
RTC_BASE_Ptr->RTCCON &= ~1 ; //RTC read and write disable
}
#include "S3C2451_vector.h"
RTC_MemMapPtr const RTC_BASE_Ptr = RTC_BASE_PTR;
Time_InitTypeDef rt_time;
void RTC_IRQ_Init( U8 cnt,FunctionalState NewState)
{
/// rTICNT = 0xff;
if(NewState != DISABLE)
{
RTC_BASE_Ptr->TICNT0 |= 0x80;
RTC_BASE_Ptr->TICNT0 &= ~0x7f;
if(cnt>127)
cnt = 127;
RTC_BASE_Ptr->TICNT0 |= cnt;
}else
{
RTC_BASE_Ptr->TICNT0 &= ~0x80;
}
}
void RTCTick_Interrupt_IRQInit( U32 addr)
{
pISR_TICK = addr;
}
void RTC_Time_Set( Time_InitTypeDef rtc_init_struct )
{
RTC_BASE_Ptr->RTCCON = 1 ; //RTC read and write enable
RTC_BASE_Ptr->BCDYEAR = rtc_init_struct.year; //Äê
RTC_BASE_Ptr->BCDMON = rtc_init_struct.month ; //ÔÂ
RTC_BASE_Ptr->BCDDATE = rtc_init_struct.day ; //ÈÕ
RTC_BASE_Ptr->BCDDAY = rtc_init_struct.week ; //ÐÇÆÚ
RTC_BASE_Ptr->BCDHOUR = rtc_init_struct.hour ; //Сʱ
RTC_BASE_Ptr->BCDMIN = rtc_init_struct.minute ; //·Ö
RTC_BASE_Ptr->BCDSEC = rtc_init_struct.second ; //Ãë
RTC_BASE_Ptr->RTCCON &= ~1 ; //RTC read and write disable
}
void RTC_Time_Get(Time_InitTypeDef *rtc_init_struct )
{
RTC_BASE_Ptr->RTCCON = 1 ; //RTC read and write enable
rtc_init_struct->year = 0x2000+RTC_BASE_Ptr->BCDYEAR ; //Äê
rtc_init_struct->month = RTC_BASE_Ptr->BCDMON ; //ÔÂ 12 0x12
rtc_init_struct->day = RTC_BASE_Ptr->BCDDATE ; //ÈÕ
rtc_init_struct->week = RTC_BASE_Ptr->BCDDAY ; //ÐÇÆÚ
rtc_init_struct->hour = RTC_BASE_Ptr->BCDHOUR ; //Сʱ
rtc_init_struct->minute = RTC_BASE_Ptr->BCDMIN ; //·Ö
rtc_init_struct->second = RTC_BASE_Ptr->BCDSEC ; //Ãë
RTC_BASE_Ptr->RTCCON &= ~1 ; //RTC read and write disable
}