Nios® V/II Embedded Design Suite (EDS)
Support for Embedded Development Tools, Processors (SoCs and Nios® V/II processor), Embedded Development Suites (EDSs), Boot and Configuration, Operating Systems, C and C++

Nios II PS2 Keyboard

Altera_Forum
Honored Contributor II
2,784 Views

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)
0 Kudos
2 Replies
Altera_Forum
Honored Contributor II
1,342 Views

Problem solved. Can not execute decode_scan without any delay.

0 Kudos
Altera_Forum
Honored Contributor II
1,342 Views

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.
0 Kudos
Reply