ARM9教程DSP教程FPGA教程CPLD教程42A软硬件设计0229
ARM9教程DSP教程FPGA教程CPLD教程42A软硬件设计0229
ARM9教程DSP教程FPGA教程CPLD教程 42A多核软硬件系统设计
PS2 Keyboard Mouse Software
第一部分 原理图
1.1 PS2_keyboard_mouse.SchDoc
ARM9教程DSP教程FPGA教程CPLD教程42A软硬件设计0229
1.2 PS2_Keyboard_Mouse_System. OpenBus
IO
MEM
XRAM
SOFT_TERMINAL
MOUSE
KEYBOARD
ARM9教程DSP教程FPGA教程CPLD教程42A软硬件设计0229
1.3 main.c
/***************************************************************************** |*
|* PS/2 Example |*
|* Keyboard functions:
|* - low level driver: scancodes
|* - device I/O (i.e. c library) interface: keyboard as stdin |*
|* Mouse functions: |* - polling mode
|* - streaming mode, with event callback |* |* NOTE:
|* Only one keyboard interface can be used. To test lower interface, |* unlink the context from the keyboard stack in the SwPlatform file and |* adjust the defines below.
\*****************************************************************************/
// choose one of the keyboard interfaces below and adjust the SwPlatform file accordingly #define USE_KEYBOARD_DEVIO 1 #define USE_PS2KB_DRIVER 0
#if ( USE_KEYBOARD_DEVIO == 1 ) // stdio.h is our interface #else
# include <drv_ps2kb.h> #endif
#include <stdio.h>
ARM9教程DSP教程FPGA教程CPLD教程42A软硬件设计0229
#include <timing.h> #include <drv_ps2mouse.h>
#include "devices.h"
// Save mouse packets
static ps2mouse_state_t mouse_state[100];
// Event synchronization
volatile uint8_t event_sync = 0;
// Event callback
static void mouse_event(ps2mouse_t *ps2mouse, ps2mouse_state_t *state, void *data) {
// Normally one would update program state here event_sync ^= 0x1; }
extern int main(void) {
#if ( USE_KEYBOARD_DEVIO == 1 ) // we use stdin #else
ps2kb_t *kbd; #endif
ps2mouse_t *mouse; ps2mouse_state_t state;
#if ( USE_KEYBOARD_DEVIO == 1 )
// In the SwPlatform file set the Posix name in the keyboard devio configuration to KEYBOARD_1 #else
ARM9教程DSP教程FPGA教程CPLD教程42A软硬件设计0229
// low level keyboard driver kbd = ps2kb_open(DRV_PS2KB_1); if (!kbd) {
return -1; } #endif
// mouse driver
mouse = ps2mouse_open(PS2MOUSE); if (!mouse) {
printf("Error opening mouse\n"); return -2; }
#if ( USE_KEYBOARD_DEVIO == 1 ) // Keyboard as stdin
printf("POSIX device I/O Example\n"); printf("- typing will print characters\n"); printf("- type 'q' to quit\n"); printf("Echo> ");
while (1) {
int ch = getchar();
if (ch != -1) {
putchar(ch); if (ch == 'q')
ARM9教程DSP教程FPGA教程CPLD教程42A软硬件设计0229
{
printf("\nFinished Keyboard Example\n\n"); break; } } } #else
// Low level keyboard example
printf("PS/2 Keyboard Driver Example\n"); printf("- typing will print scancodes\n"); printf("- type 'q' to quit\n"); printf("Scancodes:\n");
ps2kb_setleds(kbd, 0x0); // LED's off while (1) {
const uint8_t *scancode = ps2kb_get_scancode(kbd);
if (scancode[0] != 0) {
printf("0x%x 0x%x 0x%x 0x%x 0x%x 0x%x 0x%x 0x%x\n",
scancode[0], scancode[1], scancode[2], scancode[3], scancode[4], scancode[5], scancode[6], scancode[7]); if (scancode[0] == 0x15) // 'q' {
printf("\nFinished Keyboard Example\n\n"); break; } } }
ps2kb_setleds(kbd, 0x7); // LED's on #endif
ARM9教程DSP教程FPGA教程CPLD教程42A软硬件设计0229
// PS/2 mouse in polling mode
printf("PS/2 Mouse Test 1: polling mode\n"); printf("- move the mouse or press a button\n");
ps2mouse_set_streaming(mouse, false); // set remote mode // collect packets
for (int i = 0; i < 100; i++) {
while (ps2mouse_get_state(mouse, &state) < 0) /**/;
mouse_state[i] = state; delay_ms(50); }
// print packets
for (int i = 0; i < 100; i++) {
ps2mouse_state_t *state = &mouse_state[i]; printf("(x, y) buttons = (%d, %d) 0x%x\n", state->xmov, state->ymov, state->buttons); }
printf("\nFinished Mouse Test 1!\n\n");
// PS/2 mouse in streaming mode with event callback printf("PS/2 Mouse Test 2: event callback\n"); printf("- move the mouse or press a button\n");
ps2mouse_install_callback(mouse, mouse_event, &state, NULL); ps2mouse_set_streaming(mouse, true); // set streaming mode // collect packets
for (int i = 0; i < 100; i++)
ARM9教程DSP教程FPGA教程CPLD教程42A软硬件设计0229
{
uint8_t x = event_sync;
while (x == event_sync) /* wait for event */;
mouse_state[i] = state; }
ps2mouse_set_streaming(mouse, false); // stop interrupts // print packets
for (int i = 0; i < 100; i++) {
ps2mouse_state_t *state = &mouse_state[i]; printf("(x, y) buttons = (%d, %d) 0x%x\n", state->xmov, state->ymov, state->buttons); }
printf("\n\nFinished Mouse Test 2!\n\n");
printf("Finished all tests.\n"); return 0; }
ARM9教程DSP教程FPGA教程CPLD教程42A软硬件设计0229
1.4 PS2_keyboard_mouse. SwPlatform
…… 此处隐藏:2400字,全部文档内容请下载后查看。喜欢就下载吧 ……
相关推荐:
- [公文资料]市场营销专员岗位职责
- [公文资料]综合部经理岗位职责
- [公文资料]会计助理岗位职责
- [公文资料]林业站站长职责
- [公文资料]菜品研发部岗位职责
- [公文资料]街道综治办工作职责
- [公文资料]酒店前台的工作职责
- [公文资料]销售部经理岗位职责
- [公文资料]工程部副经理岗位职责
- [公文资料]手术室护士工作职责
- [公文资料]银行客户经理职责
- [公文资料]汽车4s店市场专员职责
- [公文资料]服装店长工作职责
- [公文资料]采购总监岗位职责
- [公文资料]大学行政秘书工作职责
- [公文资料]学校财务人员岗位职责
- [公文资料]财务统计员岗位职责
- [公文资料]物业工程主管工作职责
- [公文资料]公司后勤工作职责
- [公文资料]采矿工程师岗位职责
- 门面出租合同样板(门面出租的合同)
- 自用房屋租赁合同 自住房租房合同(汇总
- 最新酒店劳动合同管理制度(11篇)(酒店
- 2025年无产权车库买卖合同实用(14篇)(
- 建筑工程农民工劳动合同十五篇(通用)(
- 最新深圳标准劳动合同 深圳劳动合同如
- 解除劳动合同通知书(实用6篇)(解除劳动
- 2025年二手房屋买卖合同范围精选(二十
- 最新融资贷款居间合同大全(22篇)(融资
- 2025年个人二手房屋买卖合同协议书四篇
- 2025年果树苗木买卖合约书 签订果树苗
- 广东省劳动合同书填写(21篇)(广东省劳
- 最新餐饮行业没有劳动合同 劳动法餐饮
- 农村土地买卖合同(汇总21篇)(农村土地
- 最新房屋转租合同模版21篇(通用)(标准
- 2025年进口合同号查询五篇(大全)(进口
- 农村建房包工包料合同(通用8篇)(农村建
- 2025年安装监控合同协议书(15篇)(2025
- 2025年企业租赁经营合同(模板9篇)(2025
- 最新郊区土地租赁合同(优质23篇)(最新




