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

📄 rtc.c

📁 SHARP_ARM720T_LH79524/5软件开发包_支持TFT_LCD_NAND_FLASH_ETH_USB
💻 C
字号:
/**********************************************************************
 * Copyright (c) 2002 Sharp Microelectronics of the Americas
 *
 *        All rights reserved
 *      
 * $Workfile:   rtc.c  $
 * $Revision:   1.0  $
 * $Author:   ZhangJ  $
 * $Date:   Oct 20 2004 09:26:32  $
 *
 * SHARP MICROELECTRONICS OF THE AMERICAS MAKES NO REPRESENTATION
 * OR WARRANTIES WITH RESPECT TO THE PERFORMANCE OF THIS SOFTWARE,
 * AND SPECIFICALLY DISCLAIMS ANY RESPONSIBILITY FOR ANY DAMAGES, 
 * SPECIAL OR CONSEQUENTIAL, CONNECTED WITH THE USE OF THIS SOFTWARE.
 *
 * SHARP MICROELECTRONICS OF THE AMERICAS PROVIDES THIS SOFTWARE SOLELY 
 * FOR THE PURPOSE OF SOFTWARE DEVELOPMENT INCORPORATING THE USE OF A 
 * SHARP MICROCONTROLLER OR SYSTEM-ON-CHIP PRODUCT. USE OF THIS SOURCE
 * FILE IMPLIES ACCEPTANCE OF THESE CONDITIONS.
 *
 * Project: LH79520 EVB Example Code
 *
 * Description:
 *    This example shows how to use RTC driver
 *
 * Notes:
 *  
 * Revision History:
 * $Log:   //smaicnt2/pvcs/VM/sharpmcu/archives/sharpmcu/software/csps/lh79524/bsps/sdk79524/examples/rtc/rtc.c-arc  $
 * 
 *    Rev 1.0   Oct 20 2004 09:26:32   ZhangJ
 * Initial revision.
 * 
 *    Rev 1.0   Jul 09 2003 09:13:12   LiJ
 * Initial revision.
 * 
 * 
 *********************************************************************/

#include "lh79524_int_driver.h"
#include "lh79524_rtc_driver.h"
#include "sdk79524_board.h"

STATIC INT_32 dev_rtc = 0;
STATIC volatile INT_32 rtc_occured = 0;

/**********************************************************************
*
* Function: rtc_int_handler
*
* Purpose:
*   Real time clock interruption handler 
*  
* Processing:
*
* Parameters:
*   None
*
* Outputs:
*   None
*
* Returns:
*   Nothing
*
* Notes:
*   None
*
**********************************************************************/
void rtc_int_handler(void)
{
    /* Clear rtc int bit */
    rtc_ioctl(dev_rtc, RTC_CLEAR_MATCH_INT, 0);
    
    /* Set indication bit */
    rtc_occured = 1;    
}

 
/**********************************************************************
*
* Function: c_entry
*
* Purpose:
*   Function entry point from the startup code.
*  
* Processing:
*   
*
* Parameters:
*   None
*
* Outputs:
*   None
*
* Returns:
*   Nothing
*
* Notes:
*   None
*
**********************************************************************/
INT_32 c_entry (void)
{
    INT_32 dev_irq;

    INT_32 temp;
        
    /* Open IRQ */
    if ((dev_irq = irq_open(0,0)) == 0x0)
    {
        /* Error opening the device */
        return 0;
    }
    
    /* Open RTC */
    if ((dev_rtc = rtc_open(RTC,0)) == 0x0)
    {
        /* Error opening the device */
        return 0;
    }
    
    /* Enable IRQ source */
    irq_ioctl(dev_irq, IRQ_ENABLE_SOURCE, VIC_RTCINT);
    
    /* Set up priority for RTC interrupt */
    irq_ioctl(dev_irq, IRQ_SET_PRIORITY, 1);
    
    /* Set up interruption handler */
    irq_ioctl(dev_irq, IRQ_SET_HANDLER, (INT_32)rtc_int_handler);
    
    /* Clear existing RTC interrupt if there is */
    rtc_ioctl(dev_rtc, RTC_CLEAR_MATCH_INT, 0);
    
    /* Enable global IRQ bit */
    irq_ioctl(dev_irq, IRQ_GLOBAL_ENABLE, 1);
    
    CPLD_LED = 0xff;

    for (temp = 1; temp <50; temp ++)
    {
        /* Set up RTC time in milisecond */
        rtc_ioctl(dev_rtc, RTC_SET_TIME_SECOND, 1);

        /* Start RTC */
        rtc_ioctl(dev_rtc, RTC_START, 0);
        
        /* Enable interrupt */      
        rtc_ioctl(dev_rtc, RTC_ENABLE_MATCH_INT, 0);
        
        /* Wait until interrupt occured */
        while(rtc_occured == 0);

        /* Set LED */       
        CPLD_LED = temp;
        
        /* Clear indication bit */
        rtc_occured = 0;
    }
        
    
    /* Done with the example, close the device */
        
    /* Disable IRQ source */
    irq_ioctl(dev_irq, IRQ_DISABLE_SOURCE, VIC_RTCINT);
    
    /* Remove IRQ  handler */
    irq_ioctl(dev_irq, IRQ_REMOVE_HANDLER, VIC_RTCINT);
        
    /* Disable global IRQ bit */
    irq_ioctl(dev_irq, IRQ_GLOBAL_ENABLE, 0);
    
    /* Close RTC */
    rtc_close(dev_rtc);
    
    /* Close IRQ */
    irq_close(dev_irq);
    
    return 1;
}


#ifdef __iar

void main(void)
{
	c_entry();
	while(1);
}

#endif


⌨️ 快捷键说明

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