/*******************************************************************************
* mvRtcDS1339Init - Initialize the clock.
*
* DESCRIPTION:
*       This function initialize the clock registers and read\write functions
*
* INPUT:
*       None.
*
* OUTPUT:
*       None.
*
* RETURN:
*       None.
*
*******************************************************************************/
MV_VOID mvRtcDS1339Init(MV_VOID)
{
	MV_U8 ucTemp;
#if defined(CONFIG_USE_RS5C372)
	/* We will disable interrupts as default .*/

	/* Adjust OSC */
	ucTemp =  0x15;
	mvRtcCharWrite(RTC_ADJUST_XTAL,ucTemp);
	
	/* 24hour Set*/
	mvRtcCharRead(RTC_STATUS,&ucTemp);
	ucTemp |= RTC_CLOCK_HOUR_12_24_BIT;
	mvRtcCharWrite(RTC_STATUS,ucTemp);
#else
	/* We will disable interrupts as default .*/
	mvRtcCharRead(RTC_CONTROL,&ucTemp);
	ucTemp|=RTC_CONTROL_INTCN_BIT;
	mvRtcCharWrite(RTC_CONTROL,ucTemp);
    
	/* disable trickle */
	mvRtcCharWrite(RTC_TRICKLE_CHARGE,0);
#endif

	return;
}
Example #2
0
/*******************************************************************************
* mvRtcDS1339Init - Initialize the clock.
*
* DESCRIPTION:
*       This function initialize the clock registers and read\write functions
*
* INPUT:
*       None.
*
* OUTPUT:
*       None.
*
* RETURN:
*       None.
*
*******************************************************************************/
MV_VOID mvRtcDS1339Init(MV_VOID)
{
	MV_U8 ucTemp;

	/* We will disable interrupts as default .*/
	mvRtcCharRead(RTC1339_CONTROL,&ucTemp);
	ucTemp|=RTC_CONTROL_INTCN_BIT;
	mvRtcCharWrite(RTC1339_CONTROL,ucTemp);
    
	/* disable trickle */
	mvRtcCharWrite(RTC_TRICKLE_CHARGE,0);

	return;
}
Example #3
0
/*******************************************************************************
* mvRtcDS1338Init - Initialize the clock.
*
* DESCRIPTION:
*       This function initialize the clock registers and read\write functions
*
* INPUT:
*       None.
*
* OUTPUT:
*       None.
*
* RETURN:
*       None.
*
*******************************************************************************/
MV_VOID mvRtcDS1338Init(MV_VOID)
{
	MV_U8 ucTemp;

	/* We will enable OSC .*/
	mvRtcCharRead(RTC_CLOCK_SECONDS,&ucTemp);
	ucTemp &=~RTC_CONTROL_EOSC_MSK;
	mvRtcCharWrite(RTC_CLOCK_SECONDS,ucTemp);

	return;
}
Example #4
0
/*******************************************************************************
* mvRtcDS133xTimeSet - Update the Real Time Clock.
*
* DESCRIPTION:
*       This function sets a new time and date to the RTC from the given 
*       structure RTC_TIME . All fields within the structure must be assigned 
*		with a value prior to the use of this function.
*
* INPUT:
*       time - A pointer to a structure RTC_TIME (defined in mvDS133x.h).
* OUTPUT:
*       None.
*
* RETURN:
*       None.
*
*******************************************************************************/
MV_VOID mvRtcDS133xTimeSet(MV_RTC_TIME* time)
{
	MV_U8 tempValue;
	MV_U8 tens;
	MV_U8 single;

	/* seconds */
	tens = time->seconds / 10;
	single = time->seconds % 10;
	tempValue = ((tens  << RTC_CLOCK_10SECONDS_SHF )& RTC_CLOCK_10SECONDS_MSK )|
				(( single << RTC_CLOCK_SECONDS_SHF)&RTC_CLOCK_SECONDS_MSK) ;
	mvRtcCharWrite(RTC_CLOCK_SECONDS,tempValue);

	/* minutes */
	tens = time->minutes / 10;
	single = time->minutes % 10;
	tempValue = ((tens  << RTC_CLOCK_10MINUTES_SHF )& RTC_CLOCK_10MINUTES_MSK )|
			    (( single << RTC_CLOCK_MINUTES_SHF)& RTC_CLOCK_MINUTES_MSK) ;
	mvRtcCharWrite(RTC_CLOCK_MINUTES,tempValue);

	/* hours (24) */
	tens = time->hours / 10;
	single = time->hours % 10;
	tempValue = ((tens << RTC_CLOCK_10HOURS_SHF) & RTC_CLOCK_10HOURS_MSK2 )|
				(( single << RTC_CLOCK_HOURS_SHF ) & RTC_CLOCK_HOURS_MSK);
	mvRtcCharWrite(RTC_CLOCK_HOUR,tempValue);
  
	/* day */
	single = ++(time->day);
	tempValue = ((single << RTC_CLOCK_DAY_SHF ) & RTC_CLOCK_DAY_MSK) ;
	mvRtcCharWrite(RTC_CLOCK_DAY,tempValue);

	/* date */
	tens = time->date / 10;
	single = time->date % 10;
	tempValue = ((tens << RTC_CLOCK_10DATE_SHF ) & RTC_CLOCK_10DATE_MSK )|
				((single << RTC_CLOCK_DATE_SHF )& RTC_CLOCK_DATE_MSK) ;

	/* month */
	mvRtcCharWrite( RTC_CLOCK_DATE,tempValue);
	tens = time->month / 10;
	single = time->month % 10;
	tempValue = ((tens << RTC_CLOCK_10MONTH_SHF ) & RTC_CLOCK_10MONTH_MSK )|
				((single << RTC_CLOCK_MONTH_SHF)& RTC_CLOCK_MONTH_MSK);
	mvRtcCharWrite( RTC_CLOCK_MONTH_CENTURY,tempValue);
    
	/* year */
	tens = time->year / 10;
	single = time->year % 10;
	tempValue = ((tens << RTC_CLOCK_10YEAR_SHF) & RTC_CLOCK_10YEAR_MSK )|
				((single << RTC_CLOCK_YEAR_SHF) & RTC_CLOCK_YEAR_MSK);
	mvRtcCharWrite(RTC_CLOCK_YEAR,tempValue);

	return;
}
MV_VOID BufRtcDS1339AlarmBSet(int8_t data)
{
	mvRtcCharWrite(RTC_ALARM2_MINUTES, (MV_U8)data);
	return;
}