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

📄 lh7a400_csc_driver.c.bak

📁 sharp触摸屏测试代码
💻 BAK
📖 第 1 页 / 共 3 页
字号:
/**********************************************************************
 *	$Workfile:   LH7A400_CSC_driver.c  $
 *	$Revision:   1.6  $
 *	$Author:   MaysR  $
 *	$Date:   Jun 20 2002 14:02:10  $
 *
 *	Project: LH7A400
 *
 *	Description:
 *   LH7A400 Clock and State Controller device driver
 *   
 *	Revision History:
 *	$Log:   //smaicnt2/pvcs/VM/CHIPS/archives/LH7A400/CSC/Drivers/LH7A400_CSC_driver.c-arc  $
 * 
 *    Rev 1.6   Jun 20 2002 14:02:10   MaysR
 * Restored previous function names, since coding standard 
 * does not require chip specific prefix to name 
 * 
 *    Rev 1.5   Jun 20 2002 11:51:00   MaysR
 * Renamed all functions to match coding standard.
 * Moved functions "LH7A400_clk_set" and "LH7A400_get_hclk"
 * from LH7A400_evbutil.c to this file.
 * 
 *    Rev 1.4   Jun 20 2002 11:04:52   MaysR
 * Removed function "csc_clock_set".  Function is duplicate of 
 * "LH7A400_clock_set" in file LH7A400_evbutil.c.  
 * 
 *    Rev 1.3   Dec 05 2001 16:46:58   WellsK
 * Corrected csc_get_hclk. Added csc_get_cpuclk and
 * csc_get_pclk.
 * 
 *    Rev 1.2   Nov 28 2001 11:29:34   SuryanG
 * Changed HALLA_BASE_CLOCK to LH7A400_BASE_CLOCK
 * in csc_get_hclk.
 * 
 *    Rev 1.1   Nov 28 2001 10:39:58   SuryanG
 * Improved implementation of csc_get_hclk(). Inserted NOPs 
 * after accessing CLKSET to allow for processor going into
 * Standby mode briefly.
 * 
 *    Rev 1.0   Nov 27 2001 18:55:56   SuryanG
 * Initial Revision
 * 
 *	COPYRIGHT (C) 2001 SHARP MICROELECTRONICS OF THE AMERICAS, INC.
 *		CAMAS, WA
 *********************************************************************/
 
#include "LH7A400_map.h"
#include "LH7A400_evb.h"
#include "LH7A400_CSC_driver.h"


#define BLEOI_CLEAR              (0x0)
#define MCEOI_CLEAR              (0x0)
#define TEOI_CLEAR               (0x0)
#define PWRCNT_PGMCLK_DISABLE    (0xFFFF00FF)
#define PWRCNT_DMA_FIELD_OFFSET  (16)

/**********************************************************************
 * LH7A400_clkset_default - global variable
 * Used by the startup code to establish the
 * argument for LH7A400_clock_set when called from assembly language 
 *********************************************************************/
const UNS_32 LH7A400_clkset_default = (UNS_32)(CLKSET_DEFAULT);


/**********************************************************************
 *  Function: csc_enter_standby
 *  Purpose: 
 *        Places the LH7A400 in Standby mode
 *
 *  Processing:
 *        Reads from the STANDBY location in the CSC to inform
          the LH7A400 to enter the Standby mode. NOPs are 
          inserted to clear the pipeline when the processor is
          brought out of the Standby mode and resumes execution
 *
 *  Parameters:  None
 *  Outputs: None
 *  Returns: Nothing
 *********************************************************************/
void csc_enter_standby(void)
{
    volatile UNS_32 tmp;

    tmp = CLKSC->stby;

    /* NOPs to clear the pipeline after coming out of standby */
    __asm__(	\
    
        "NOP \n"	\
        "NOP \n"	\
        "NOP \n"	\
        "NOP \n"	\
        "NOP \n"	\
    );
}


/*********************************************************************
 *  Function: csc_halt
 *  Purpose: 
 *        Places the LH7A400 in the Halt mode.
 *
 *  Processing:
 *        Reads from the HALT location in the CSC to instruct the 
          LH7A400 to enter the Halt mode. NOPs are inserted to clear
          the pipeline when the processor comes out of the Halt mode.
 *
 *  Parameters: None
 *  Outputs: None
 *  Returns: Nothing
 *********************************************************************/
void csc_halt(void)
{
    volatile UNS_32 tmp;
    
    tmp = CLKSC->halt;

    /* NOPs to clear the pipeline after coming out of halt */
    __asm__(	\
    
        "NOP \n"	\
        "NOP \n"	\
        "NOP \n"	\
        "NOP \n"	\
        "NOP \n"	\
    );
    
}


/*********************************************************************
 *  Function: csc_clear_batlow_intr
 *  Purpose: 
 *        Signals the end of servicing a battery low interrupt
 *
 *  Processing:
          Writes to the battery low end-of-interrupt location
 *
 *  Parameters: None
 *  Outputs: None
 *  Returns: Nothing
 *********************************************************************/
void csc_clear_batlow_intr(void)
{
    CLKSC->bleoi = BLEOI_CLEAR;    
}

/*********************************************************************
 *  Function: csc_clear_medchg_intr
 *  Purpose: 
 *        Signals the end of servicing a media-change interrupt
 *
 *  Processing:
 *        Writes to the media change end-of-interrupt location
 *
 *  Parameters: None
 *  Outputs: None
 *  Returns: Nothing
 *********************************************************************/
void csc_clear_medchg_intr(void)
{
    CLKSC->mceoi = MCEOI_CLEAR;
}

/*********************************************************************
 *  Function: csc_clear_tick_intr
 *  Purpose: 
 *        Signals the end of servicing a tick interrupt
 *
 *  Processing:
 *        Writes to the tick end-of-interrupt location
 *
 *  Parameters: None
 *  Outputs: None
 *  Returns: Nothing
 *********************************************************************/
void csc_clear_tick_intr(void)
{
    CLKSC->teoi = TEOI_CLEAR;
}

/*********************************************************************
 *  Function: csc_coldstart
 *  Purpose: 
 *        Determines if the LH7A400 was reset via a power-on
 *        reset
 *
 *  Processing:
 *        Reads the cold boot status bit and shifts it right to the
 *        LSB
 *
 *  Parameters: None
 *  Outputs: None
 *  Returns: 1 if the LH7A400 was cold started 
 *           0 if the LH7A400 was not cold started
 *********************************************************************/
UNS_32 csc_coldstart(void)
{
   return((CLKSC->pwrsr & PWRSR_CLDFLG) >> PWRSR_CLDFLG_BIT);
}

/*********************************************************************
 *  Function: csc_pwrfail
 *  Purpose: 
 *        Determines if the LH7A400 was reset due to a power fail
 *        input
 *
 *  Processing:
 *        Reads the power fail status bit and shifts it right to the
 *        LSB
 *
 *  Parameters: None
 *  Outputs: None
 *  Returns: 1 if the LH7A400 was reset due to a power fail input
             0 if the LH7A400 was not reset due to a power fail input
 *********************************************************************/
UNS_32 csc_pwrfail(void)
{
   return((CLKSC->pwrsr & PWRSR_PFFLG) >> PWRSR_PFFLG_BIT);
}

/*********************************************************************
 *  Function: csc_user_reset
 *  Purpose: 
 *        Determines if the LH7A400 was reset via the soft reset key
 *
 *  Processing:
 *        Reads the user reset status bit and shifts it right to the
 *        LSB
 *
 *  Parameters: None
 *  Outputs: None
 *  Returns: 1 if the LH7A400 was reset via the soft reset key
 *           0 if the LH7A400 was not reset via the soft reset key
 *********************************************************************/
UNS_32 csc_user_reset(void)
{
   return((CLKSC->pwrsr & PWRSR_RSTFLG) >> PWRSR_RSTFLG_BIT);
}

/*********************************************************************
 *  Function: csc_user_wakeup
 *  Purpose: 
 *        Determines if the LH7A400 was issued a Wakeup signal via
 *        the Wakeup pin
 *
 *  Processing:
 *        Reads the wakeup status bit and shifts it right to the
 *        LSB
 *
 *  Parameters: None
 *  Outputs: None
 *  Returns: 1 if the LH7A400 was issued a Wakeup via the wakeup pin
 *          0 if the LH7A400 was not issued a wakeup via the Wakeup pin
 *********************************************************************/
UNS_32 csc_user_wakeup(void)
{
   return((CLKSC->pwrsr & PWRSR_WUON) >> PWRSR_WUON_BIT);
}


/*********************************************************************
 *  Function: csc_new_bat
 *  Purpose: 
 *        Determines if a battery change was signalled on the NBATCHG
 *        input
 *
 *  Processing:
 *         Reads the new battery status bit and shifts it right to the
 *         LSB
 *
 *  Parameters: None
 *  Outputs: None
 *  Returns: 1 if a battery change was signalled
 *           0 if a battery change was not signalled
 *********************************************************************/
UNS_32 csc_new_bat(void)
{
   return((CLKSC->pwrsr & PWRSR_NBFLG) >> PWRSR_NBFLG_BIT);
}

/***************************************************************
 *  Function: csc_get_wakeup
 *  Purpose: 
 *        Read the direct state of the Wakeup pin
 *
 *  Processing: 
 *        Reads the wakeup direct read bit and shifts it right
 *        to the LSB
 *
 *  Parameters: None
 *  Outputs: None
 *  Returns: State of the Wakeup pin
 ***************************************************************/
UNS_32 csc_get_wakeup(void)
{
   return((CLKSC->pwrsr & PWRSR_WUDR) >> PWRSR_WUDR_BIT);
}

/***************************************************************
 *  Function: csc_get_medchg
 *  Purpose: 
 *        Read the direct state of the MEDCHG pin
 *
 *  Processing: 
 *        Read the media change direct read bit and shift it
 *        right to the LSB
 *
 *  Parameters: None
 *  Outputs: None
 *  Returns: State of the MEDCHG pin
 ***************************************************************/
UNS_32 csc_get_medchg(void)
{
   return((CLKSC->pwrsr & PWRSR_MCDR) >> PWRSR_MCDR_BIT);
}

/*********************************************************************
 *  Function: csc_stby_wakeup_disable
 *  Purpose: 
 *        Inhibits the LH7A400 from waking up from Standby on a
 *        Wakeup keypress
 *
 *  Processing:
 *        Sets the Wake disable bit in the CSC
 *
 *  Parameters: None
 *  Outputs: None
 *  Returns: Nothing
 *********************************************************************/
void csc_stby_wakeup_disable(void)
{
   CLKSC->pwrcnt |= PWRCNT_WAKEDIS;
}

/*********************************************************************
 *  Function: csc_set_pgmclk_divisor
 *  Purpose: 
 *        Enables the Programmable clock output and sets its frequency
 *
 *  Processing:
 *        Sets the programmable clock divisor between 1 and 255 per
 *        the value passed as argument
 *
 *  Parameters: div - clock divisor, 1 - 255 (zero disables clock)
 *  Outputs: Clock on the PGMCLK pin
 *  Returns: Nothing
 *********************************************************************/
void csc_set_pgmclk_divisor(UNS_8 div)
{
   CLKSC->pwrcnt |= PWRCNT_PGMCLK(div);
}

/*********************************************************************
 *  Function: csc_disable_pgmclk
 *  Purpose: 
 *        Disables generation and output of the programmable clock
 *
 *  Processing:
 *         This is a special case of the previous function. Sets the
 *         programmable clock value to zero to inhibit the clock
 *
 *  Parameters: None
 *  Outputs: None
 *  Returns: Nothing
 *********************************************************************/
void csc_disable_pgmclk(void)
{
   CLKSC->pwrcnt &= PWRCNT_PGMCLK_DISABLE;
}

/*********************************************************************
 *  Function: csc_enable_dma
 *  Purpose: 
 *        Turn on HCLK to the DMA controller and enable the DMA
 *        channel passed as argument
 *
 *  Processing:
 *        Sets the bit corresponding to the DMA channel to be enabled
 *        in the CSC PWRCNT register. The bit number is computed from 
 *        the argument passed by adding an offset to it.
 *
 *  Parameters: channel - enumerated type identifying the DMA channel
 *                        to be enabled
 *  Outputs: None
 *  Returns: Nothing
 *********************************************************************/
void csc_enable_dma(dma_channel_t channel)
{
   CLKSC->pwrcnt |= _BIT((UNS_32)channel + PWRCNT_DMA_FIELD_OFFSET);
}

/*********************************************************************
 *  Function: csc_disable_dma
 *  Purpose: 
 *        Disable DMA on a particular channel
 *
 *  Processing:
 *       Clears the bit corresponding to the DMA channel to be disabled
 *       in the PWRCNT register. The bit number is computed from the
 *       argument passed by adding an offset to it. 
 *
 *  Parameters: channel - enumerated type identifying the DMA channel
 *                        to be disabled
 *  
 *  Outputs: None
 *  Returns: Nothing
 *********************************************************************/
void csc_disable_dma(dma_channel_t channel)
{
   CLKSC->pwrcnt &= ~_BIT((UNS_32)channel + PWRCNT_DMA_FIELD_OFFSET);
}

/*********************************************************************
 *  Function: csc_reset_usb_control
 *  Purpose: 
 *        Resets the control side of the USB
 *
 *  Processing:
 *        Sets the bit in the USB reset register to reset the
 *        USB control side
 *
 *  Parameters: None
 *  Outputs: None
 *  Returns: Nothing
 *********************************************************************/
void csc_reset_usb_control(void)
{
   CLKSC->usbreset |= USBRESET_APB;
}

/*********************************************************************
 *  Function: csc_reset_usb_io
 *  Purpose: 
 *        Resets the I/O side of the USB
 *
 *  Processing:
 *        Sets the bit in the USB reset register to reset the
 *        USB I/O side
 *
 *  Parameters: None
 *  Outputs: None
 *  Returns: Nothing
 *********************************************************************/
void csc_reset_usb_io(void)
{
   CLKSC->usbreset |= USBRESET_IO;
}


⌨️ 快捷键说明

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