📄 idk7a400_cpld_driver.c
字号:
/***********************************************************************
* $Workfile: idk7a400_cpld_driver.c $
* $Revision: 1.0 $
* $Author: WellsK $
* $Date: Apr 27 2004 11:43:46 $
*
* Project: LogicPD IDK7A400 CPLD driver
*
* Description:
* This file contains driver support for the CPLD module on the
* IDK7A400 EVB.
*
* Revision History:
* $Log: //smaicnt2/pvcs/VM/sharpmcu/archives/sharpmcu/software/csps/lh7a400/bsps/sdk7a400/source/idk7a400_cpld_driver.c-arc $
*
* Rev 1.0 Apr 27 2004 11:43:46 WellsK
* Initial revision.
*
*
***********************************************************************
* 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.
*
* COPYRIGHT (C) 2001 SHARP MICROELECTRONICS OF THE AMERICAS, INC.
* CAMAS, WA
**********************************************************************/
#include "idk7a400_cpld_driver.h"
/* Array that converts an IDK enumeration to a disable bit value */
const UNS_16 led_enum_to_bit[] =
{
IDK_LED_STANDBY,
IDK_LED_SLEEP,
IDK_LED_RUN,
IDK_RESET_LED
};
/* Shadowed value of the interrupt 0 masks register */
STATIC UNS_16 idk_masks0;
/* Shadowed value of the interrupt 1 masks register */
STATIC UNS_16 idk_masks1;
/***********************************************************************
* CPLD driver public functions
**********************************************************************/
/***********************************************************************
*
* Function: idk_cpld_init
*
* Purpose: Initializes the IDK CPLD driver (stub function only)
*
* Processing:
* Set the shadowed interrupt mask values to all disabled.
*
* Parameters: None
*
* Outputs: None
*
* Returns: Nothing
*
* Notes: None
*
**********************************************************************/
void idk_cpld_init(void)
{
/* All interrupts are initially masked */
idk_masks0 = idk_masks1 = 0xFFFF;
}
/***********************************************************************
*
* Function: idk_read_dip
*
* Purpose: Read the 16 DIP switches on the IDK
*
* Processing:
* Return the raw DIP switch value from the mapped memory location.
*
* Parameters: None
*
* Outputs: None
*
* Returns: The states on the 16 DIP switches
*
* Notes: None
*
**********************************************************************/
UNS_16 idk_read_dip(void)
{
return * (UNS_16 *) IDK_DIP_BASE;
}
/***********************************************************************
*
* Function: idk_enable_led
*
* Purpose: Turn on or off an IDK status LED
*
* Processing:
* Based on the selected LED enumeration and enable flag, turn on
* off the selected LED.
*
* Parameters:
* led : Must be an enumeration of type IDK_LED_SELECT_T
* turnon : TRUE to enable the selected LED, FALSE to disable it
*
* Outputs: None
*
* Returns: Nothing
*
* Notes: None
*
**********************************************************************/
void idk_enable_led(IDK_LED_SELECT_T led,
BOOL_32 turnon)
{
UNS_16 flags = 0;
if ((led >= IDK_STANDBY_LED) && (led <= IDK_RESET_LED))
{
/* Get disable bit for the selected LED */
flags = led_enum_to_bit[led];
if (turnon == TRUE)
{
* (UNS_16 *) IDK_LEDS_BASE |= flags;
}
else
{
* (UNS_16 *) IDK_LEDS_BASE &= ~flags;
}
}
}
/***********************************************************************
*
* Function: idk_interrupt0_pending
*
* Purpose: Determine if an IDK interrupt is pending in register 0
*
* Processing:
* For the selected interrupts, return the interrupt pending flags.
*
* Parameters:
* masks : Must be a combination of interrupt masks for interrupt
* register 0 (IDK_UART1INT_PEND, IDK_UART2INT_PEND,
* IDK_MMCINT_PEND, IDK_LANINT_PEND, IDK_USBDEVSUSP_PEND,
* IDK_USBHOSTSUSP_PEND, IDK_USBDEV_PEND, or
* IDK_USBHOST_PEND)
*
* Outputs: None
*
* Returns:
* 0 if none of the selected interrupts are pending, otherwise
* returns an OR'ed combination of selected interrupts that are
* pending based on the passed mask
*
* Notes: None
*
**********************************************************************/
UNS_16 idk_interrupt0_pending(UNS_16 masks)
{
return (masks & (* (UNS_16 *) IDK_IREG0_BASE));
}
/***********************************************************************
*
* Function: idk_set_interrupt0_masks
*
* Purpose:
* Enable and disable IDK interrupts used in interrupt register 0
*
* Processing:
* For the selected interrupts, enable or disable the interrupts.
*
* Parameters:
* masks : Must be a combination of interrupt masks for interrupt
* register 0 (IDK_UART1INT_PEND, IDK_UART2INT_PEND,
* IDK_MMCINT_PEND, IDK_LANINT_PEND, IDK_USBDEVSUSP_PEND,
* IDK_USBHOSTSUSP_PEND, IDK_USBDEV_PEND, or
* IDK_USBHOST_PEND)
* enable : If TRUE, all the interrupts selected with masks will
* be enabled, otherwise all the selected interrupts will
* be disabled.
*
* Outputs: None
*
* Returns:
* The previous value of the mask register (a '1' means the
* interrupt is masked, '0' is enabled).
*
* Notes: None
*
**********************************************************************/
UNS_16 idk_set_interrupt0_masks(UNS_16 masks,
BOOL_32 enable)
{
UNS_16 old_masks = idk_masks0;
if (enable == TRUE)
{
/* Enable selected interrupts */
idk_masks0 &= ~masks;
}
else
{
/* Disable selected interrupts */
idk_masks0 |= masks;
}
/* Set new masks value */
* (UNS_16 *) IDK_IMSK0_BASE = idk_masks0;
return old_masks;
}
/***********************************************************************
*
* Function: idk_interrupt1_pending
*
* Purpose: Determine if an IDK interrupt is pending in register 1
*
* Processing:
* For the selected interrupts, return the interrupt pending flags.
*
* Parameters:
* masks : Must be a combination of interrupt masks for interrupt
* register 1 (IDK_PCMCIARDYAINT_PEND, IDK_FXGINT_PEND,
* or IDK_BATTINT_PEND)
*
* Outputs: None
*
* Returns:
* 0 if none of the selected interrupts are pending, otherwise
* returns an OR'ed combination of selected interrupts that are
* pending based on the passed mask
*
* Notes: None
*
**********************************************************************/
UNS_16 idk_interrupt1_pending(UNS_16 masks)
{
return (masks & (* (UNS_16 *) IDK_IREG1_BASE));
}
/***********************************************************************
*
* Function: idk_set_interrupt1_masks
*
* Purpose:
* Enable and disable IDK interrupts used in interrupt register 1
*
* Processing:
* For the selected interrupts, enable or disable the interrupts.
*
* Parameters:
* masks : Must be a combination of interrupt masks for interrupt
* register 1 (IDK_PCMCIARDYAINT_PEND, IDK_FXGINT_PEND,
* or IDK_BATTINT_PEND)
* enable : If TRUE, all the interrupts selected with masks will
* be enabled, otherwise all the selected interrupts will
* be disabled.
*
* Outputs: None
*
* Returns:
* The previous value of the mask register (a '1' means the
* interrupt is masked, '0' is enabled).
*
* Notes: None
*
**********************************************************************/
UNS_16 idk_set_interrupt1_masks(UNS_16 masks,
BOOL_32 enable)
{
UNS_16 old_masks = idk_masks1;
if (enable == TRUE)
{
/* Enable selected interrupts */
idk_masks1 &= ~masks;
}
else
{
/* Disable selected interrupts */
idk_masks1 |= masks;
}
/* Set new masks value */
* (UNS_16 *) IDK_IMSK1_BASE = idk_masks1;
return old_masks;
}
/***********************************************************************
*
* Function: idk_misc_enable
*
* Purpose: Enable or disable an IDK miscellaneous signal
*
* Processing:
* For the selected signal, enable to disable the signal.
*
* Parameters:
* imisc : Signal name of type IDK_MISC_SIGNALS_T
* enable : TRUE to enable, FALSE to disable
*
* Outputs: None
*
* Returns: Nothing
*
* Notes: None
*
**********************************************************************/
void idk_misc_enable(IDK_MISC_SIGNALS_T imisc,
BOOL_32 enable)
{
switch (imisc)
{
case IDK_KEYBOARD_EN:
if (enable == TRUE)
{
/* Enable keyboard read signal */
* (UNS_16 *) IDK_CONTROL_BASE &= ~IDK_KEYBOARD2_NEN;
}
else
{
/* Disable keyboard read signal */
* (UNS_16 *) IDK_CONTROL_BASE |= IDK_KEYBOARD2_NEN;
}
break;
case IDK_MMC_EN:
if (enable == TRUE)
{
/* Enable MMC enable signal */
* (UNS_16 *) IDK_CONTROL_BASE &= ~IDK_MMC_NEN;
}
else
{
/* Disable MMC enable signal */
* (UNS_16 *) IDK_CONTROL_BASE |= IDK_MMC_NEN;
}
break;
case IDK_AUDIO_EN:
if (enable == TRUE)
{
/* Disable audio shutdown */
* (UNS_16 *) IDK_CONTROL_BASE |= IDK_AUDIO_SHDN;
}
else
{
/* Enable audio shutdown */
* (UNS_16 *) IDK_CONTROL_BASE &= ~IDK_AUDIO_SHDN;
}
break;
default:
break;
}
}
/***********************************************************************
*
* Function: idk_pcmcia_reset
*
* Purpose: Reset a PCMCIA slot
*
* Processing:
* Not implemented yet
*
* Parameters:
* pslot : Slot to reset, an enumeration of type IDK_PCMCIA_SLOT_T
* assert : TRUE to assert reset, FALSE to deassert
*
* Outputs: None
*
* Returns: Nothing
*
* Notes: None
*
**********************************************************************/
void idk_pcmcia_reset(IDK_PCMCIA_SLOT_T pslot,
BOOL_32 assert)
{
;
}
/***********************************************************************
*
* Function: idk_get_pcmcia_status
*
* Purpose: Read a PCMCIA slot status
*
* Processing:
* Not implemented yet
*
* Parameters:
* pslot : Slot to reset, an enumeration of type IDK_PCMCIA_SLOT_T
*
* Outputs: None
*
* Returns: PCMCIA slot status
*
* Notes: None
*
**********************************************************************/
UNS_16 idk_get_pcmcia_status(IDK_PCMCIA_SLOT_T pslot)
{
return 0;
}
/***********************************************************************
*
* Function: idk_pcmcia_enable_power
*
* Purpose: Enable or disable the power controller for a slot
*
* Processing:
* Not implemented yet
*
* Parameters:
* pslot : Slot to reset, an enumeration of type IDK_PCMCIA_SLOT_T
* enable : TRUE to enable power, FALSE to disable
*
* Outputs: None
*
* Returns: Nothing
*
* Notes: None
*
**********************************************************************/
void idk_pcmcia_enable_power(IDK_PCMCIA_SLOT_T pslot,
BOOL_32 enable)
{
;
}
/***********************************************************************
*
* Function: idk_pcmcia_vcc_set
*
* Purpose: Select VCC for a PCMCIA slot
*
* Processing:
* Not implemented yet
*
* Parameters:
* pslot : Slot to reset, an enumeration of type IDK_PCMCIA_SLOT_T
* pvolts : Voltage selection value
*
* Outputs: None
*
* Returns: Nothing
*
* Notes: None
*
**********************************************************************/
void idk_pcmcia_vcc_set(IDK_PCMCIA_SLOT_T pslot,
IDK_PCMCIA_VCC_T pvolts)
{
;
}
/***********************************************************************
*
* Function: idk_pcmcia_vpp_set
*
* Purpose: Select VPP for a PCMCIA slot
*
* Processing:
* Not implemented yet
*
* Parameters:
* pslot : Slot to reset, an enumeration of type IDK_PCMCIA_SLOT_T
* pvolts : Voltage selection value
*
* Outputs: None
*
* Returns: Nothing
*
* Notes: None
*
**********************************************************************/
void idk_pcmcia_vpp_set(IDK_PCMCIA_SLOT_T pslot,
IDK_PCMCIA_VPP_T pvolts)
{
;
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -