- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
In QSYS I added a PS/2 Controller IP Core and wired it in Verilog.
My code:#include <stdio.h># include <stdlib.h># include "system.h"
# include <altera_up_avalon_ps2.h># include <altera_up_ps2_keyboard.h>
alt_up_ps2_dev *ps2;
KB_CODE_TYPE *decode_mode;
alt_u8 buf;
char ascii;
int main()
{
ps2 = alt_up_ps2_open_dev("/dev/ps2");
alt_up_ps2_init(ps2);
printf("Detected device: %d\n",ps2->device_type);
while (1)
{
decode_scancode(ps2,decode_mode,&buf,&ascii);
if (*decode_mode != 6)
printf("Decode mode: %d Buffer: 0x%X ASCII: %c\n",*decode_mode,buf,ascii);
}
return 0;
}
Decode mode is always 1 or 2, and the buffer is always one byte even if it should be longer. (for example Right Alt key)
Link Copied
2 Replies
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Problem solved. Can not execute decode_scan without any delay.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Can you help me?
I have a problem with ps2 keyboard interface. I used a ps2 controller and used code C in Nios ii for connect to PS2 keyboard But when I try to connected and detected device by instruction " printf("Detected device: %d\n", ps2->device_type);" then result is: "Detected device: -1". what wrong with my project? Please help me.
Reply
Topic Options
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page