📄 bsp_vfd.c
字号:
#include <includes.h>
/*
*********************************************************************************************************
* DISPLAY CONTROL LINE FUNCTIONS
*********************************************************************************************************
*/
#define GPIO1_LCD_DB0 DEF_BIT_00
#define GPIO1_LCD_DB1 DEF_BIT_01
#define GPIO1_LCD_DB2 DEF_BIT_02
#define GPIO1_LCD_DB3 DEF_BIT_03
#define GPIO1_LCD_DB4 DEF_BIT_04
#define GPIO1_LCD_DB5 DEF_BIT_05
#define GPIO1_LCD_DB6 DEF_BIT_06
#define GPIO1_LCD_DB7 DEF_BIT_07
#define GPIO1_LCD_RS DEF_BIT_08
#define GPIO1_LCD_W DEF_BIT_09
#define GPIO1_LCD_RD DEF_BIT_10
/******************************************************************************
** Function name: DispDly_uS (CPU_INT08U data)
**
** Descriptions: Non blocking delay.
**
** parameters: delay in microseconds
** Returned value: None
**
******************************************************************************/
void DispDly_uS (CPU_INT32U us)
{
CPU_INT32U us_per_tick;
CPU_INT32U ticks;
us_per_tick = 1000000L / OS_TICKS_PER_SEC;
ticks = us / us_per_tick + 1;
OSTimeDly(ticks);
}
/******************************************************************************
** Function name: DispX_High/Low ()
**
** Descriptions:
** parameters: none
** Returned value: None
**
******************************************************************************/
static void DispW_High (void)
{
FIO2SET = GPIO1_LCD_W; /* Raise the LCD /W pin */
}
static void DispRD_High (void)
{
FIO2SET = GPIO1_LCD_RD; /* Raise the LCD RD pin */
}
static void DispW_Low (void)
{
FIO2CLR = GPIO1_LCD_W; /* Lower the LCD /W pin */
}
static void DispRD_Low (void)
{
FIO2CLR = GPIO1_LCD_RD; /* Lower the LCD RD pin */
}
/******************************************************************************
** Function name: DispDataWr (CPU_INT08U data)
**
** Descriptions: The function reads the BUSY VFD pin, if it's set,
** it will wait 100 us and the write the byte to the
** VFD. In case of using more complex commands like
** scrolling, graphic mode then the 100us is NOT ENOUGH.
** for the VFD.
**
** parameters: Byte to write to the VFD.
** Returned value: None
**
******************************************************************************/
void DispDataWr (CPU_INT08U data)
{
CPU_INT32U value;
DispRD_Low(); /*Initiates the Read Mode*/
FIO2DIR &= ~GPIO1_LCD_DB7;
//while(FIO2PIN & GPIO1_LCD_DB7){
if(FIO2PIN & GPIO1_LCD_DB7){ /* Check the BUSY pin*/
DispDly_uS(100);
}
//}
DispRD_High(); /*Finishes the Read Mode*/
FIO2DIR |= GPIO1_LCD_DB7;
DispW_Low(); /* Initiates the Write Mode*/
value = (data & 0xFF); /*Write the byte through the parallel port*/
FIO2SET = value;
value = (~data & 0xFF);
FIO2CLR = value;
DispDly_uS(100);
DispW_High(); /*Finishes the Write Mode*/
FIO2DIR &= ~GPIO1_LCD_DB7;
// DispDly_uS(100);
}
/******************************************************************************
** Function name: VFD_Init
**
** Descriptions: Initialize display
**
** parameters: void
** Returned value: None
**
******************************************************************************/
void VFD_Init(void)
{
CPU_INT32U value;
value = (3 << 16) | (3 << 18) | (3 << 20); /* Create a mask for the LCD Control function bits */
PINSEL4 &= ~value; /* Clear and configure the associated function bits as GPIO */
value = (3 << 0) | (3 << 2) | (3 << 4) | (3 << 6) | (3 << 8) | (3 << 10) | (3 << 12) | (3 << 14);/* Create a mask for the LCD Data function bits */
PINSEL4 &= ~value; /* Clear and configure the associated function bits as GPIO */
value = GPIO1_LCD_DB0 | GPIO1_LCD_DB1 | GPIO1_LCD_DB2 | GPIO1_LCD_DB3 | GPIO1_LCD_DB4 | GPIO1_LCD_DB5 | GPIO1_LCD_DB6 | GPIO1_LCD_DB7 |GPIO1_LCD_RS | GPIO1_LCD_W | GPIO1_LCD_RD;
FIO2DIR |= 0x7FF; /* Configure all of the LCD pins as outputs */
FIO2CLR =0x7FF;
DispW_High(); /* Initialize the state of the LCD RW bit to High */
DispRD_High(); /* Initialize the state of the LCD RW bit to High */
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -