示例#1
0
/*
*------------------------------------------------------------------------------
* void InitializeRtc(void)
*
* Summary	: Initialize the I2C module and RTC
*
* Input		: None
*
* Output	: None
*
*------------------------------------------------------------------------------
*/
void RTC_Init(void)
{
	UINT8 tempVar;
	// Read seconds register contents
	tempVar = ReadByteI2C(DEV_ADDR_RTC,RTC_REG_SEC);
	// Enable oscillator (bit 7=0)
	tempVar = tempVar & 0x7F;
	WriteByteI2C(DEV_ADDR_RTC,RTC_REG_SEC,tempVar);

	// set RTC control register to o/p 1Hz sqr wave o/p
	WriteByteI2C(DEV_ADDR_RTC,RTC_REG_CTR,0x90);
/*
	ReadRtcTimeAndDate((UINT8*)&stRtcRegs);
	stRtcRegs.mSeconds	= 0x00;							// second = 00
	stRtcRegs.mMinute  	= 0x29;							// minute = 29
	stRtcRegs.mHour  	= 0x21;							// hour = 21 ,24-hour mode(bit 6=0)
	stRtcRegs.mDay		= 0x01;							// Day = 1 or sunday
	stRtcRegs.mDate		= 0x12;							// Date = 12
	stRtcRegs.mMonth	= 0x10;							// month = October
	stRtcRegs.mYear		= 0x08;							// year = 08 or 2008
	WriteRtcTimeAndDate((UINT8*)&stRtcRegs);			// Set RTC
*/
#ifdef TIME_DEBUG
	stRtcRegs.mSeconds	= 0;							// second 
	stRtcRegs.mMinute  	= 5;							// minute 
	stRtcRegs.mHour  	= 12;							// hour
#endif
	// Setup task to run
//#ifdef TIME_DEBUG
//	SCH_AddTask(UpdateRealTimeClockTask ,0,TASK_10MSEC_PERIOD);
//#else
//	SCH_AddTask(UpdateRealTimeClockTask ,0,TASK_100MSEC_PERIOD);
//#endif
}
示例#2
0
/*************************************************************************************
 *
 * Function:     WriteLcdDataByte
 *
 * Description:  Function used to split 8 bit commands into two 4 bit commands.
 *               Note: This can only be used after setting LCD module in 4 bit mode
 *
 * Parameters:   byte: Byte value to trigger, Bank: Setting of RS bit
 *
 * Return:       void
 *
 *************************************************************************************/
void WriteLcdDataByte(char byte, unsigned char Bank)
{
    unsigned char highnib;
    unsigned char lownib;
    
    if(Bank == INSTRUCTION_REG)
    {
        lownib = (byte & 0x0F) << 4 | BL;
        highnib = (byte & 0xF0) | BL;
    }
    
    if(Bank == DATA_REG)
    {
        lownib = (byte & 0x0F) << 4 | BL | RS;
        highnib = (byte & 0xF0) | BL | RS;
    }
    
    /* First write the 4 MSB bits */
    WriteByteI2C(highnib);
    
    /* Trigger the data */
    PulseEnable(highnib);
    
    /* Now write the 4 LSB bits */
    WriteByteI2C(lownib);
    
    /* Trigger the data */
    PulseEnable(lownib);
}
示例#3
0
/*
*------------------------------------------------------------------------------
* void InitializeRtc(void)
*
* Summary	: Initialize the I2C module and RTC
*
* Input		: None
*
* Output	: None
*
*------------------------------------------------------------------------------
*/
void InitializeRtc(void)
{
	UINT8 tempVar;

#ifdef RTC_DS3232
	// Read Oscillator control register
	tempVar = ReadByteI2C(DEV_ADDR_RTC,RTC_REG_CTR);

	// check if the RTC oscillator run flag is enabled
	if(tempVar & 0x80)
	{
		//Enable oscillator (bit 7=0)
		WriteByteI2C(DEV_ADDR_RTC,RTC_REG_CTR,0x00);	
	}
#else
	// Read seconds register contents
	tempVar = ReadByteI2C(DEV_ADDR_RTC,RTC_REG_SEC);
	
	// check if the RTC oscillator run flag is enabled
	if(tempVar & 0x80)
	{
		// Enable oscillator (bit 7=0)
		tempVar = tempVar & 0x7F;
		WriteByteI2C(DEV_ADDR_RTC,RTC_REG_SEC,tempVar);
	}
#endif

/*
	ReadRtcTimeAndDate((UINT8*)&stRtcRegs);
	stRtcRegs.mSeconds	= 0x00;							// second = 00
	stRtcRegs.mMinute  	= 0x29;							// minute = 29
	stRtcRegs.mHour  	= 0x21;							// hour = 21 ,24-hour mode(bit 6=0)
	stRtcRegs.mDay		= 0x01;							// Day = 1 or sunday
	stRtcRegs.mDate		= 0x12;							// Date = 12
	stRtcRegs.mMonth	= 0x10;							// month = October
	stRtcRegs.mYear		= 0x08;							// year = 08 or 2008
	WriteRtcTimeAndDate((UINT8*)&stRtcRegs);			// Set RTC
*/
#ifdef TIME_DEBUG
	stRtcRegs.mSeconds	= 0;							// second = 00
	stRtcRegs.mMinute  	= 50;							// minute = 29
	stRtcRegs.mHour  	= 6;
#endif
	// Setup task to run
#ifdef TIME_DEBUG
	SCH_AddTask(UpdateRealTimeClockTask ,0,TASK_10MSEC_PERIOD);
#else
//	SCH_AddTask(UpdateRealTimeClockTask ,0,TASK_100MSEC_PERIOD);
#endif
}
示例#4
0
/*************************************************************************************
 *
 * Function:     PulseEnable
 *
 * Description:  This functions triggers the data in value via E pin
 *
 * Parameters:   Byte to trigger
 *
 * Return:       void
 *
 *************************************************************************************/
void PulseEnable(char value)
{
    /* Backlight on */
    value |= BL;
    
    /* Set the Enable pin high and keep backlight on */
    WriteByteI2C(value | En);
    
    /* Wait at least 450ns while E pin is high */
    usleep(1);
    
    /* Set the Enable pin low again */
    WriteByteI2C(value & ~En);
    
    /* Commands needs at least 37us to settle */
    usleep(50);
}
示例#5
0
/*************************************************************************************
 *
 * Function:     WriteLcdDataNibble
 *
 * Description:  Function that writes only 4 bits to the LCD
 *
 * Parameters:   Nibble value to trigger
 *
 * Return:       void
 *
 *************************************************************************************/
void WriteLcdDataNibble(unsigned char nibble)
{
  /* High nibble */
  unsigned char nibble_val = (nibble & 0x0F) << 4 | BL;
    
  /* Write the byte to I2C (nibble value in above 4 bits) */
  WriteByteI2C(nibble_val);
    
  /* Trigger the data */
  PulseEnable(nibble_val);
}