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

📄 ps2_mouse.c

📁 单片机连接ps2键盘源码,应用于C51单片机
💻 C
字号:
#include "ps2_mouse.h"

alt_u8 reset_mouse()
{
	alt_u8 byte;

	//send the reset command
	int status = write_data_byte_with_ack(MOUSE_RESET, DEFAULT_PS2_TIMEOUT_VAL);
	if (status == PS2_SUCCESS) 
	{
		// get the ACK, now read the BAT result
		status = read_data_byte_with_timeout(&byte, DEFAULT_PS2_TIMEOUT_VAL);
		if ( status == PS2_SUCCESS && byte == 0xAA) 
		{
			// BAT is passed, now get the device ID
			status = read_data_byte_with_timeout(&byte, DEFAULT_PS2_TIMEOUT_VAL); 
			// mouse should return 0x00 for device ID
			if ( byte == 0x00)
				status = PS2_SUCCESS;
			else 
				status = PS2_ERROR;
		}
	}
	return status;
}

int set_mouse_mode(alt_u8 byte)
{
	return write_data_byte_with_ack(byte, DEFAULT_PS2_TIMEOUT_VAL);
}

⌨️ 快捷键说明

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