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

📄 lh7a400_evb_cpld_driver.c

📁 sharp flash blob 的烧写代码
💻 C
📖 第 1 页 / 共 3 页
字号:
    if(dev & CPLD_BOOT_DEV_SYNCFLASH)
    {
        return SYNCFLASH;
    }
    if(dev & CPLD_BOOT_DEV_SRAM)
    {
        return SRAM;
    }
    /* should not get here */
    return FLASH;
}

/***********************************************************************
*   Function:   LH7A400_pld_mmc_card_present
*
*   Purpose:
*        Identifies whether an MMC card is detected or not
*
*   Processing:
*           Self explanatory
*
*   Parameters:	None
*
*   Outputs:	None
*
*   Returns:	0 if card is not detected
*              1 if card is detected
***********************************************************************/
UNS_32 LH7A400_pld_mmc_card_present(void)
{
    return (CPLD->boot_mmc_status & CPLD_MMC_CARD_PRESENT);
}

/***********************************************************************
*   Function:   LH7A400_pld_mmc_write_protected
*
*   Purpose:
*        Identifies whether an MMC card is write protected or not
*
*   Processing:
*           Self explanatory
*
*   Parameters:	None
*
*   Outputs:	None
*
*   Returns:	0 if card is not write protected
*              1 if card is write protected
***********************************************************************/
UNS_32 LH7A400_pld_mmc_write_protected(void)
{
    return ((CPLD->boot_mmc_status & CPLD_MMC_CARD_WP) >> 1);
}

/***********************************************************************
*   Function:   LH7A400_pld_get_ext_int_status
*
*   Purpose:
*        Gets the current status of the external masked interrupts
*
*   Processing:
*           Self explanatory
*
*   Parameters:	None
*
*   Outputs:	None
*
*   Returns:    A byte whose bits identify the currently latched 
*               interrupt
*
*   Notes:
*         A bit is set only if the interrupt mask has been enabled for 
*         it
***********************************************************************/
UNS_8 LH7A400_pld_get_ext_int_status(void)
{
    return ((UNS_8)CPLD->latched_ints);
}

/***********************************************************************
*   Function:   LH7A400_pld_clear_ext_int
*
*   Purpose:
*        Clears the latched status of the external interrupt
*
*   Processing:
*        Self explanatory
*
*   Parameters:	Enumerated type identifying the source of the interrupt
*                 that is to be cleared
*
*   Outputs:	None
*
*   Returns:	Nothing
***********************************************************************/
void LH7A400_pld_clear_ext_int(PLD_EXT_INT_T intr)
{
    CPLD->latched_ints = (UNS_8)(CPLD->latched_ints | \
                         (UNS_8)_BIT((UNS_32)(intr - 8)));
}

/***********************************************************************
*   Function:   LH7A400_pld_get_pb
*
*   Purpose:
*           Get the state of the pushbutton switches on the EVB
*
*   Processing:
*           It is the responsibility of the application to debounce
*           the switches. This function returns the raw state of the
*           switches.
*
*   Parameters:	None
*
*   Outputs:	None
*
*   Returns:    An 8-bit pattern representing the state of the 
*               pushbutton switches:
*              a set bit tells that the corresponding switch is 
*              depressed 
*              a cleared bit tells that the corresponding switch is not
*              pressed.
***********************************************************************/
UNS_8 LH7A400_pld_get_pb(void)
{
    return ((UNS_8) ((CPLD->rd_pb_keys) & _BITMASK(8)));
}

/***********************************************************************
*   Function:   LH7A400_pld_mmc_enable_pwr
*
*   Purpose:
*           Asserts the enable signal to the MAX1602 device on the I/O
*           board that supplies power to the Multimedia Card
*
*   Processing:
*            Self explanatory
*
*   Parameters:	None
*
*   Outputs:	None
*
*   Returns:	Nothing
***********************************************************************/
void LH7A400_pld_mmc_enable_pwr(void)
{
    io_brd_ctl = (UNS_8)(io_brd_ctl | (UNS_8)CPLD_MMC_PWR);
    CPLD->control.wr_io_brd_ctl = io_brd_ctl;
}

/***********************************************************************
*   Function:   LH7A400_pld_mmc_disable_pwr
*
*   Purpose:
*           De-asserts the enable signal to the MAX1602 device on the 
*           I/O board that supplies power to the Multimedia Card
*
*   Processing:
*           Self explanatory
*
*   Parameters:	None
*
*   Outputs:	None
*
*   Returns:	Nothing
***********************************************************************/
void LH7A400_pld_mmc_disable_pwr(void)
{
    io_brd_ctl = (UNS_8)(io_brd_ctl & (UNS_8)(~CPLD_MMC_PWR));
    CPLD->control.wr_io_brd_ctl = io_brd_ctl;
}

/***********************************************************************
*   Function:   LH7A400_pld_eth_sleep
*
*   Purpose:
*           Asserts (active low) the Sleep signal to the Ethernet
*           Controller on the I/O board
*
*   Processing:
*           Self Explanatory
*
*   Parameters:	None
*
*   Outputs:	None
*
*   Returns:	None
***********************************************************************/
void LH7A400_pld_eth_sleep(void)
{
    io_brd_ctl = (UNS_8)(io_brd_ctl & (UNS_8)(~CPLD_ETH_SLEEP));
    CPLD->control.wr_io_brd_ctl = io_brd_ctl;
}

/***********************************************************************
*   Function:   LH7A400_pld_eth_wake
*
*   Purpose:
*           De-asserts the Sleep signal to the Ethernet Controller on
*           the I/O board
*
*   Processing:
*           Self Explanatory
*
*   Parameters:	None
*
*   Outputs:	None
*
*   Returns:	None
***********************************************************************/
void LH7A400_pld_eth_wake(void)
{
    io_brd_ctl = (UNS_8)(io_brd_ctl | (UNS_8)(CPLD_ETH_SLEEP));
    CPLD->control.wr_io_brd_ctl = io_brd_ctl;
}

/***********************************************************************
*   Function:   LH7A400_pld_i2s_enable_pwr
*
*   Purpose:
*           Deasserts the (active low) shutdown signal to the LT1761
*           on the I/O board that powers the I2S audio codec
*
*   Processing:
*           Self explanatory
*
*   Parameters:	None
*
*   Outputs:	None
*
*   Returns:	Nothing
***********************************************************************/
void LH7A400_pld_i2s_enable_pwr(void)
{
    io_brd_ctl = (UNS_8)(io_brd_ctl & (UNS_8)(~CPLD_I2S_PWR));
    CPLD->control.wr_io_brd_ctl = io_brd_ctl;
}

/*********************************************************************** 
*   Function:   LH7A400_pld_i2s_disable_pwr
*
*   Purpose:	
*           Asserts the (active low) shutdown signal to the LT1761
*           on the I/O board that powers the I2S audio codec
*
*   Processing:	
*           Self explanatory           
*
*   Parameters:	None
*
*   Outputs:	None
*
*   Returns:	None
***********************************************************************/
void LH7A400_pld_i2s_disable_pwr(void)
{
    io_brd_ctl = (UNS_8)(io_brd_ctl | (UNS_8)(CPLD_I2S_PWR));
    CPLD->control.wr_io_brd_ctl = io_brd_ctl;
}

/*********************************************************************** 
*   Function:   LH7A400_pld_ac97_enable_pwr
*
*   Purpose:	
*           Deasserts the (active low) shutdown signal to the LT1761
*           on the I/O board that powers the AC97 audio codec
*
*   Processing:	
*           Self explanatory
*
*   Parameters:	None
*
*   Outputs:	None
*
*   Returns:	Nothing
***********************************************************************/
void LH7A400_pld_ac97_enable_pwr(void)
{
    io_brd_ctl = (UNS_8)(io_brd_ctl & (UNS_8)(~CPLD_AC97_PWR));
    CPLD->control.wr_io_brd_ctl = io_brd_ctl;
}

/*********************************************************************** 
*   Function:   LH7A400_pld_ac97_disable_pwr
*
*   Purpose:	
*           Asserts the (active low) shutdown signal to the LT1761
*           on the I/O board that powers the AC97 audio codec
*
*   Processing:	
*           Self explanatory
*
*   Parameters:	None
*
*   Outputs:	None
*
*   Returns:	None
***********************************************************************/
void LH7A400_pld_ac97_disable_pwr(void)
{
    io_brd_ctl = (UNS_8)(io_brd_ctl | (UNS_8)(CPLD_AC97_PWR));
    CPLD->control.wr_io_brd_ctl = io_brd_ctl;
}

/*********************************************************************** 
*   Function:   LH7A400_pld_pc_card_pwr_enable
*
*   Purpose:	
*           Enables power to the PCMCIA card slots
*
*   Processing:	
*           This function sets the PWR control signals to the MAX1602
*           that delivers power to the PCMCIA card slots according to
*           the following truth table (for each card):
*           PWR1     PWR2           Resultant Power Supply Voltage
*            0        0                       Hi-Z (Standby)
*            1        0                       +5V
*            0        1                      +3.3V
*            1        1                       GND (Standby)
*
*   Parameters:	card - PCMCIA slot number (1 or 2)
*                 pwr - power control signal number (1 or 2)
*                       (see table above)
*
*   Outputs:	None
*
*   Returns:	Nothing
***********************************************************************/
void LH7A400_pld_pc_card_pwr_enable(UNS_32 card, UNS_32 pwr)
{
    if(card > 2 || card < 1) return;
    if(pwr >2 || pwr < 1) return;
    io_brd_ctl = (UNS_8)(io_brd_ctl | (UNS_8)(_BIT((card + pwr) - 2)));
    CPLD->control.wr_io_brd_ctl = io_brd_ctl;
}

/*********************************************************************** 
*   Function:   LH7A400_pld_pc_card_pwr_disable
*
*   Purpose:	
*           Places the power supply signal to the PCMCIA slot in high
*           impedance state
*
*   Processing:	
*           See description of pld_pc_card_pwr_enable above. This 
*           function performs the equivalent of the first line of the
*           truth table.
*
*   Parameters:	card - PCMCIA slot number (1 or 2)
*
*   Outputs:	None
*
*   Returns:	Nothing
***********************************************************************/
void LH7A400_pld_pc_card_pwr_disable(UNS_32 card)
{   
    if(card > 2 || card < 1) return;
    if(1 == card)
    {
        io_brd_ctl = (UNS_8)(io_brd_ctl & (UNS_8)(~_BITMASK(2)));
    }
    else if(2 == card)
    {
      io_brd_ctl = (UNS_8)(io_brd_ctl & (UNS_8)(~(_BIT(2) | _BIT(3))));
    }
    CPLD->control.wr_io_brd_ctl = io_brd_ctl;
}

/*********************************************************************** 
*   Function:   LH7A400_pld_get_option_sw
*
*   Purpose:	
*           Read the user-defined option switches on the CPU board (S1)
*
*   Processing:	
*           Self explanatory
*
*   Parameters:	None
*
*   Outputs:	None
*
*   Returns:	8-bit bit-pattern that represents the state of the DIP 
*              switches. 
*              1 - the switch is ON
*              0 - the switch is OFF
***********************************************************************/
UNS_8 LH7A400_pld_get_option_sw(void)
{
    return ((UNS_8)(~(CPLD->control.rd_opt_dip_sw) & _BITMASK(8)));
}

⌨️ 快捷键说明

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