Nios® II Embedded Design Suite (EDS)
Support for Embedded Development Tools, Processors (SoCs and Nios® II processor), Embedded Development Suites (EDSs), Boot and Configuration, Operating Systems, C and C++
Announcements
Intel Support hours are Monday-Fridays, 8am-5pm PST, except Holidays. Thanks to our community members who provide support during our down time or before we get to your questions. We appreciate you!

Need Forum Guidance? Click here
Search our FPGA Knowledge Articles here.

Nios II PS2 Keyboard

Altera_Forum
Honored Contributor II
1,864 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
422 Views

Problem solved. Can not execute decode_scan without any delay.

Altera_Forum
Honored Contributor II
422 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.
Reply