📄 lh7a400_evb_cpld_driver.c
字号:
/**********************************************************************
*
* Function: LH7A400_pld_irq_next_available
*
* Purpose:
* Return the lowest available priority number in the range specified
*
* Processing: n/a
*
* Parameters:
* range_start: the start number of the set of vectors to search
* range_end: the end number of the set of vectors to search
*
* Outputs: None
*
* Returns:
* Returns the lowest priority available or range_end
*
* Notes:
* range_start must be smaller than range_end
*
**********************************************************************/
INT_8 LH7A400_pld_irq_next_available(INT_8 range_start, INT_8 range_end)
{
return priority_next_available(&CPLD_prio,
range_start,
range_end,
LH7A400_pld_null_handler);
}
/***********************************************************************
* Function: LH7A400_pld_lcd_pwr_enable
*
* Purpose: B.0 workaround bit for HR-TFT power enable
*
* Processing:
*
* Parameters: None
*
* Outputs: None
*
* Returns: Nothing
***********************************************************************/
void LH7A400_pld_lcd_pwr_enable(void)
{
CPLD->lcd_pwr_cntl |= CPLD_LCD_LOW_VOLT_EN;
}
/***********************************************************************
* Function: LH7A400_pld_cstn_power_on
*
* Purpose: Switch on the 26.8V power source to the LCD
*
* Processing: Self explanatory
*
* Parameters: None
*
* Outputs: None
*
* Returns: Nothing
***********************************************************************/
void LH7A400_pld_cstn_power_on(void)
{
CPLD->lcd_pwr_cntl &= ((~CPLD_LCD_nSHUT) & _BITMASK(8));
}
/***********************************************************************
* Function: LH7A400_pld_lcd_output_enable
*
* Purpose: Gate the buffered data lines to the LCD and assert the
* TFT enable signal
*
* Processing: Self explanatory
*
* Parameters: None
*
* Outputs: None
*
* Returns: Nothing
***********************************************************************/
void LH7A400_pld_lcd_output_enable(void)
{
CPLD->lcd_pwr_cntl |= CPLD_LCD_OE;
}
/***********************************************************************
* Function: LH7A400_pld_lcd_backlight_on
*
* Purpose:
* Switch on the LCD backlight
*
* Processing:
* Self explanatory
*
* Parameters: None
*
* Outputs: None
*
* Returns: Nothing
***********************************************************************/
void LH7A400_pld_lcd_backlight_on(void)
{
CPLD->lcd_pwr_cntl |= CPLD_LCD_BKLT;
}
/***********************************************************************
* Function: LH7A400_pld_lcd_backlight_off
*
* Purpose: Switch off the LCD backlight
*
* Processing: Self explanatory
*
* Parameters: None
*
* Outputs: None
*
* Returns: Nothing
***********************************************************************/
void LH7A400_pld_lcd_backlight_off(void)
{
CPLD->lcd_pwr_cntl &= ((~CPLD_LCD_BKLT) & _BITMASK(8));
}
/***********************************************************************
* Function: LH7A400_pld_lcd_output_disable
*
* Purpose: Deassert the TFT enable signal and disable the buffered
* TFT data lines
*
* Processing: Self explanatory
*
* Parameters: None
*
* Outputs: None
*
* Returns: Nothing
***********************************************************************/
void LH7A400_pld_lcd_output_disable(void)
{
CPLD->lcd_pwr_cntl &= ((~CPLD_LCD_OE) & _BITMASK(8));
}
/***********************************************************************
* Function: LH7A400_pld_cstn_power_off
*
* Purpose: Switch off the 26.8 V power supply to the LCD
*
* Processing: Self explanatory
*
* Parameters: None
*
* Outputs: None
*
* Returns: Nothing
***********************************************************************/
void LH7A400_pld_cstn_power_off(void)
{
CPLD->lcd_pwr_cntl |= CPLD_LCD_nSHUT;
}
/***********************************************************************
* Function: LH7A400_pld_lcd_pwr_disable
*
* Purpose: B.0 work around for HR-TFT power disable
*
* Processing:
*
* Parameters: None
*
* Outputs: None
*
* Returns: Nothing
***********************************************************************/
void LH7A400_pld_lcd_pwr_disable(void)
{
CPLD->lcd_pwr_cntl &= ((~CPLD_LCD_LOW_VOLT_EN) & _BITMASK(8));
}
/***********************************************************************
* Function: LH7A400_pld_get_display_brd_switch
*
* Purpose:
* Read the option switches on the display board and return
* their state
*
* Processing:
* Self explanatory
*
* Parameters: None
*
* Outputs: None
*
* Returns: A byte representing the display board switch settings -
* A bit that is set indicates a switch that is ON;
* a bit that is not set indicates a switch that is OFF
***********************************************************************/
UNS_8 LH7A400_pld_get_display_brd_switch(void)
{
return ((UNS_8)(~(CPLD->extsettings.rd_disp_brd_sw) & _BITMASK(8)));
}
/***********************************************************************
* Function: LH7A400_pld_lcd_display_enable
*
* Purpose: Asserts the display enable signal
*
* Processing: Self Explanatory
*
* Parameters: None
*
* Outputs: None
*
* Returns: Nothing
*
* Notes: JP13 has to be jumpered between pins 2 and 3 for this
* signal to take effect
***********************************************************************/
void LH7A400_pld_lcd_display_enable(void)
{
CPLD->lcd_pwr_cntl |= CPLD_LCD_DISP_E;
}
/***********************************************************************
* Function: LH7A400_pld_lcd_display_disable
*
* Purpose: Deasserts the display enable signal
*
* Processing: Self explanatory
*
* Parameters: None
*
* Outputs: None
*
* Returns: Nothing
***********************************************************************/
void LH7A400_pld_lcd_display_disable(void)
{
CPLD->lcd_pwr_cntl &= ((~CPLD_LCD_DISP_E) & _BITMASK(8));
}
/***********************************************************************
* Function: LH7A400_pld_enable_ext_int
*
* Purpose:
* Establishes the event mask against which incoming interrupts
* will be compared to raise the unified CPLD interrupt to the
* processor
*
* Processing:
* This is a write-only register, so previous state has to be
* maintained. This is done using the static variable ev_mask.
*
* Parameters: intr - enumerated type identifying the interrupt to be
enabled
*
* Outputs: None
*
* Returns: Nothing
***********************************************************************/
void LH7A400_pld_enable_ext_int(PLD_EXT_INT_T intr)
{
ext_int_mask = (UNS_8) (ext_int_mask | (UNS_8) _BIT(intr - 8));
CPLD->extsettings.wr_ext_int_mask = ext_int_mask;
}
/***********************************************************************
* Function: LH7A400_pld_disable_ext_int
*
* Purpose:
* Establishes the event mask against which incoming interrupts
* will be compared to raise the unified CPLD interrupt to the
* processor
*
* Processing:
* This is a write-only register, so previous state has to be
* maintained. This is done using the static variable ev_mask.
*
* Parameters: intr - enumerated type identifying the interrupt to be
disabled
*
* Outputs: None
*
* Returns: Nothing
***********************************************************************/
void LH7A400_pld_disable_ext_int(PLD_EXT_INT_T intr)
{
ext_int_mask = (UNS_8)(ext_int_mask & (UNS_8)(~_BIT(intr - 8)));
CPLD->extsettings.wr_ext_int_mask = ext_int_mask;
}
/***********************************************************************
* Function: LH7A400_pld_enable_pb_int
*
* Purpose:
* Establishes the event mask against which switch presses
* will be compared to raise the unified CPLD interrupt to the
* processor
*
* Processing:
* This is a write-only register, so previous state has to be
* maintained. This is done using the static variable ev_mask.
*
* Parameters: sw - number between 1 and 8 that identifies the switch
* which should generate an interrupt when depressed
* 1 corresponds to SW1 (SW10 on EVB), 8 corresponds
* to SW8 (SW17 on EVB)
*
* Outputs: None
*
* Returns: Nothing
***********************************************************************/
void LH7A400_pld_enable_pb_int(PLD_PB_INT_T button)
{
pb_int_mask = (UNS_8)(pb_int_mask | (UNS_8)(_BIT(button)));
CPLD->status.intmask.wr_pb_int_mask = pb_int_mask;
}
/***********************************************************************
* Function: LH7A400_pld_disable_pb_int
*
* Purpose:
* Establishes the event mask against which switch presses
* will be compared to raise the unified CPLD interrupt to the
* processor
*
* Processing:
* This is a write-only register, so previous state has to be
* maintained. This is done using the static variable ev_mask.
*
* Parameters: sw - number between 1 and 8 that identifies the switch
* which should generate an interrupt when depressed
* 1 corresponds to SW1 (SW10 on EVB), 8 corresponds
* to SW8 (SW17 on EVB)
*
* Outputs: None
*
* Returns: Nothing
***********************************************************************/
void LH7A400_pld_disable_pb_int(PLD_PB_INT_T button)
{
pb_int_mask = (UNS_8)(pb_int_mask & (UNS_8)(~_BIT(button)));
CPLD->status.intmask.wr_pb_int_mask = pb_int_mask;
}
/***********************************************************************
* Function: LH7A400_pld_read_row_sense
*
* Purpose:
* Read the keyboard matrix row sense register
*
* Processing:
* Self explanatory
*
* Parameters: None
*
* Outputs: None
*
* Returns: 14 bits representing the state of the row sense register
***********************************************************************/
UNS_16 LH7A400_pld_read_row_sense(void)
{
return ((UNS_16)((CPLD->status.rd_kpd_row_sense)&_BITMASK(14)));
}
/***********************************************************************
* Function: LH7A400_pld_get_boot_device
*
* Purpose:
* Gets the boot memory device
*
* Processing:
* The Boot Device and MMC status register holds the identifier
* of the current boot device. Bit 4 of the register is set if
* the boot device is Flash memory, Bit 5 is set if the device
* is SyncFlash and Bit 6 is set if the boot device is static
* RAM
*
* Parameters: None
*
* Outputs: None
*
* Returns: Enumerated type specifying the type of boot memory
***********************************************************************/
PLD_BOOT_DEVICE_T LH7A400_pld_get_boot_device(void)
{
UNS_8 dev;
dev = CPLD->boot_mmc_status;
if(dev & CPLD_BOOT_DEV_FLASH)
{
return FLASH;
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -