//-------------------------------------------------------- //鼠标报告描述符发送 //-------------------------------------------------------- void Mouse_Send(void) { u8 Mouse_Buffer[4] = {0, 0, 0, 0}; s8 X = 0, Y = 0;
//========方向键处理(步长=ADC采样结果的高4位+1(1~16)) if (!GPIO_ReadInputDataBit(GPIOD, JOY_RIGHT)) { X += (ADC_ConvertedValue/256+1); } if (!GPIO_ReadInputDataBit(GPIOD, JOY_LEFT)) { X -= (ADC_ConvertedValue/256+1); } if (!GPIO_ReadInputDataBit(GPIOD, JOY_UP)) { Y -= (ADC_ConvertedValue/256+1); } if (!GPIO_ReadInputDataBit(GPIOD, JOY_DOWN)) { Y += (ADC_ConvertedValue/256+1); } Mouse_Buffer[1] = X; // prepare buffer to send Mouse_Buffer[2] = Y;
//========按键处理 if (!GPIO_ReadInputDataBit(GPIOD, MOUSE_LEFT)) { Mouse_Buffer[0] = 0X01; } if (!GPIO_ReadInputDataBit(GPIOD, MOUSE_RIGHT)) { Mouse_Buffer[0] = 0X02; } if (!GPIO_ReadInputDataBit(GPIOD, JOY_SEL)) { Mouse_Buffer[0] = 0X04; }
//======== UserToPMABufferCopy(Mouse_Buffer, GetEPTxAddr(ENDP1), 4); //copy mouse position info in ENDP1 Tx Packet Memory Area SetEPTxValid(ENDP1); // enable endpoint for transmission } //略。。。。。
文章评论(0条评论)
登录后参与讨论