⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 altera_up_ps2_mouse.c

📁 花了半个月才改好的Atera DE1/DE2 ps2 IP 驱动核。放在FPGA工程目录下可以直接使用。本IP能够驱动PS/2键盘和鼠标。使用时只要调用HAL目录下的文件即可以直接使用!
💻 C
字号:
#include "altera_up_ps2_mouse.h"

int alt_up_ps2_mouse_reset(alt_up_ps2_dev *ps2)
{
	if (ps2->device_type != PS2_MOUSE)
		return -EINVAL;

	alt_u8 byte;

	//send the reset command
	int status = alt_up_ps2_write_data_byte_with_ack(ps2, MOUSE_RESET);
	if (status == 0) 
	{
		// get the ACK, now read the BAT result
		status = alt_up_ps2_read_data_byte(ps2, &byte);
		if ( status == 0 && byte == 0xAA) 
		{
			// BAT is passed, now get the device ID
			status = alt_up_ps2_read_data_byte(ps2, &byte); 
			// mouse should return 0x00 for device ID
			if ( byte == 0x00 )
				status = 0;
			else 
				status = -EIO;
		}
	}
	return status;
}

int alt_up_ps2_mouse_set_mode(alt_up_ps2_dev *ps2, alt_u8 byte)
{
	return alt_up_ps2_write_data_byte_with_ack(ps2, byte);
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -