📄 kmi_example.c
字号:
/***********************************************************************
* $Workfile: kmi_example.c $
* $Revision: 1.2 $
* $Author: WellsK $
* $Date: Dec 08 2003 14:41:46 $
*
* Project: KMI polled mode driver example
*
* Description:
* A KMI driver (polled mode) example.
*
* Revision History:
* $Log: //smaicnt2/pvcs/VM/sharpmcu/archives/sharpmcu/software/csps/lh7a404/bsps/sdk7a404/examples/kmi_polled/kmi_example.c-arc $
*
* Rev 1.2 Dec 08 2003 14:41:46 WellsK
* Removed LCD based output. Simplified example to be used
* as a reference only since there is no PS/2 interface on the
* SDK to use with the example.
*
* Rev 1.1 Oct 28 2003 10:51:54 WellsK
* Updated to use common LCD parameters file.
*
* Rev 1.0 Oct 15 2003 17:03:10 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 "abl_types.h"
#include "abl_irq_fiq.h"
#include "lh7a404_gpio_driver.h"
#include "sdk7a404_cpld_driver.h"
#include "lh7a404_kmi_driver.h"
/* KMI device handle */
STATIC INT_32 kmidev;
/* PS/2 mouse reset command */
#define PS2_MOUSE_RESET 0xF4
/***********************************************************************
*
* Function: c_entry
*
* Purpose: Polled mode KMI driver example
*
* Processing:
* This example simply reads data from a mouse connected to the
* KMI port on the LH7A404.
*
* Parameters: None
*
* Outputs: None
*
* Returns: Always returns 1
*
* Notes: None
*
**********************************************************************/
int c_entry(void)
{
UNS_8 buffer[1];
INT_32 idx;
/* Disable interrupts */
disable_irq_fiq();
/* Initialize CPLD */
cpld_init();
/* Open KMI */
if ((kmidev = kmi_open(KMI, 0)) == 0x00000000)
{
return 0;
}
/* PS/2 protocol mode */
kmi_ioctl(kmidev, KMI_SET_PS2_KB, 0);
/* Issue mouse reset command to the PS/2 mouse - this will also
start the mouse issuing the data at about the default rate */
buffer[0] = PS2_MOUSE_RESET;
kmi_write_polled(kmidev, &buffer, 1);
/* Read raw data from port (100 raw items) */
idx = 0;
while (idx < 100)
{
/* Read data when it comes in. Data will only come in when a
mouse/keyboard event occurs */
if (kmi_read_polled(kmidev, buffer, sizeof(buffer)) != 0)
{
/* Don't do anything with the data - ideally, the data
can be processed here */
idx++;
}
}
return 1;
}
#ifndef __GNUC__
/* With ARM and GHS toolsets, the entry point is main() - this will
allow the linker to generate wrapper code to setup stacks, allocate
heap area, and initialize and copy code and data segments. For GNU
toolsets, the entry point is through __start() in the crt0_gnu.asm
file, and that startup code will setup stacks and data */
int main(void)
{
return c_entry();
}
#endif
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -