Make the two keyboard halves communicate with each other via I2C.
This commit is contained in:
@@ -1,6 +1,9 @@
|
||||
#include "include/board/board.h"
|
||||
#include "usb_composite_device.h"
|
||||
#include "usb_interface_mouse.h"
|
||||
#include "fsl_i2c.h"
|
||||
#include "i2c.h"
|
||||
#include "main.h"
|
||||
|
||||
static usb_device_endpoint_struct_t UsbMouseEndpoints[USB_MOUSE_ENDPOINT_COUNT] = {{
|
||||
USB_MOUSE_ENDPOINT_INDEX | (USB_IN << USB_DESCRIPTOR_ENDPOINT_ADDRESS_DIRECTION_SHIFT),
|
||||
@@ -39,8 +42,19 @@ static usb_mouse_report_t UsbMouseReport;
|
||||
static uint8_t scrollCounter = 0;
|
||||
static volatile usb_status_t UsbMouseAction(void)
|
||||
{
|
||||
uint8_t i2cBuffer[I2C_DATA_LENGTH];
|
||||
i2c_master_transfer_t masterXfer;
|
||||
masterXfer.slaveAddress = LEFT_KEYBOARD_HALF_I2C_ADDRESS_7BIT;
|
||||
masterXfer.direction = kI2C_Read;
|
||||
masterXfer.subaddress = 0;
|
||||
masterXfer.subaddressSize = 0;
|
||||
masterXfer.data = i2cBuffer;
|
||||
masterXfer.dataSize = I2C_DATA_LENGTH;
|
||||
masterXfer.flags = kI2C_TransferDefaultFlag;
|
||||
I2C_MasterTransferBlocking(EXAMPLE_I2C_MASTER_BASEADDR, &masterXfer);
|
||||
|
||||
UsbMouseReport.buttons = 0;
|
||||
UsbMouseReport.x = 0;
|
||||
UsbMouseReport.x = i2cBuffer[1] - i2cBuffer[0];
|
||||
UsbMouseReport.y = 0;
|
||||
UsbMouseReport.wheelX = 0;
|
||||
UsbMouseReport.wheelY = 0;
|
||||
|
||||
Reference in New Issue
Block a user