commit 07734b766a2838cd78e36ea8da0e88a567262b72
parent 07fdb2aac0f8978ce6e8f4a4dff7d953a0851b2a
Author: Valtteri Koskivuori <vkoskiv@gmail.com>
Date: Tue, 17 Oct 2023 00:33:31 +0300
trackpad-fw: Passive cleanup, remove copypasted stuff, fix indentation
No functional changes. Just cleaning up some of the copypasted stuff,
like the register definitions for the trackball sensor. Also made
indentation consistent (2 spaces)
Diffstat:
1 file changed, 18 insertions(+), 85 deletions(-)
diff --git a/reform2-trackpad-fw/Mouse.c b/reform2-trackpad-fw/Mouse.c
@@ -35,62 +35,6 @@
#include "i2cmaster/i2cmaster.h"
#include "azoteq.h"
-#define output_low(port,pin) port &= ~(1<<pin)
-#define output_high(port,pin) port |= (1<<pin)
-#define set_input(portdir,pin) portdir &= ~(1<<pin)
-#define set_output(portdir,pin) portdir |= (1<<pin)
-
-// Registers
-#define Product_ID 0x00
-#define Revision_ID 0x01
-#define Motion 0x02
-#define Delta_X_L 0x03
-#define Delta_X_H 0x04
-#define Delta_Y_L 0x05
-#define Delta_Y_H 0x06
-#define SQUAL 0x07
-#define Raw_Data_Sum 0x08
-#define Maximum_Raw_data 0x09
-#define Minimum_Raw_data 0x0A
-#define Shutter_Lower 0x0B
-#define Shutter_Upper 0x0C
-#define Control 0x0D
-#define Config1 0x0F
-#define Config2 0x10
-#define Angle_Tune 0x11
-#define Frame_Capture 0x12
-#define SROM_Enable 0x13
-#define Run_Downshift 0x14
-#define Rest1_Rate_Lower 0x15
-#define Rest1_Rate_Upper 0x16
-#define Rest1_Downshift 0x17
-#define Rest2_Rate_Lower 0x18
-#define Rest2_Rate_Upper 0x19
-#define Rest2_Downshift 0x1A
-#define Rest3_Rate_Lower 0x1B
-#define Rest3_Rate_Upper 0x1C
-#define Observation 0x24
-#define Data_Out_Lower 0x25
-#define Data_Out_Upper 0x26
-#define Raw_Data_Dump 0x29
-#define SROM_ID 0x2A
-#define Min_SQ_Run 0x2B
-#define Raw_Data_Threshold 0x2C
-#define Config5 0x2F
-#define Power_Up_Reset 0x3A
-#define Shutdown 0x3B
-#define Inverse_Product_ID 0x3F
-#define LiftCutoff_Tune3 0x41
-#define Angle_Snap 0x42
-#define LiftCutoff_Tune1 0x4A
-#define Motion_Burst 0x50
-#define LiftCutoff_Tune_Timeout 0x58
-#define LiftCutoff_Tune_Min_Length 0x5A
-#define SROM_Load_Burst 0x62
-#define Lift_Config 0x63
-#define Raw_Data_Burst 0x64
-#define LiftCutoff_Tune2 0x65
-
#include "Mouse.h"
/** Buffer to hold the previously generated Mouse HID report, for comparison purposes inside the HID class driver. */
@@ -122,24 +66,18 @@ uint8_t twi_read_buf[10];
void SetupHardware(void)
{
- /* Disable watchdog if enabled by bootloader/fuses */
- MCUSR &= ~(1 << WDRF);
- wdt_disable();
+ /* Disable watchdog if enabled by bootloader/fuses */
+ MCUSR &= ~(1 << WDRF);
+ wdt_disable();
- // Disable clock division
+ // Disable clock division
// this should yield 8Mhz with internal osc
- clock_prescale_set(clock_div_1);
+ clock_prescale_set(clock_div_1);
DDRD = 0b00000000;
DDRB = 0b00000100;
DDRC = 0b00000000;
- //output_high(PORTC, 5);
-
- // no jtag plox
- //MCUCR |=(1<<JTD);
- //MCUCR |=(1<<JTD);
-
i2c_init();
USB_Init();
@@ -173,23 +111,23 @@ void EVENT_USB_Device_Disconnect(void)
/** Event handler for the library USB Configuration Changed event. */
void EVENT_USB_Device_ConfigurationChanged(void)
{
- bool ConfigSuccess = true;
+ bool ConfigSuccess = true;
- ConfigSuccess &= HID_Device_ConfigureEndpoints(&Mouse_HID_Interface);
+ ConfigSuccess &= HID_Device_ConfigureEndpoints(&Mouse_HID_Interface);
- USB_Device_EnableSOFEvents();
+ USB_Device_EnableSOFEvents();
}
/** Event handler for the library USB Control Request reception event. */
void EVENT_USB_Device_ControlRequest(void)
{
- HID_Device_ProcessControlRequest(&Mouse_HID_Interface);
+ HID_Device_ProcessControlRequest(&Mouse_HID_Interface);
}
/** Event handler for the USB device Start Of Frame event. */
void EVENT_USB_Device_StartOfFrame(void)
{
- HID_Device_MillisecondElapsed(&Mouse_HID_Interface);
+ HID_Device_MillisecondElapsed(&Mouse_HID_Interface);
}
float dx2 = 0, dy2 = 0;
@@ -312,11 +250,6 @@ bool CALLBACK_HID_Device_CreateHIDReport(USB_ClassInfo_HID_Device_t* const HIDIn
dxx = (dx+dx2+dx3+dx4)/4.0;
dyy = (dy+dy2+dy3+dy4)/4.0;
- //if (dxx>MOTION_CLIP) dxx=MOTION_CLIP;
- //if (dxx<=-MOTION_CLIP) dxx=-MOTION_CLIP;
- //if (dyy>MOTION_CLIP) dyy=MOTION_CLIP;
- //if (dyy<=-MOTION_CLIP) dyy=-MOTION_CLIP;
-
if (wheeling) {
// horizontal and vertical scrolling
MouseReport->Pan = dxx;
@@ -375,18 +308,18 @@ void CALLBACK_HID_Device_ProcessHIDReport(USB_ClassInfo_HID_Device_t* const HIDI
const void* ReportData,
const uint16_t ReportSize)
{
- // Unused (but mandatory for the HID class driver) in this demo, since there are no Host->Device reports
+ // Unused (but mandatory for the HID class driver) in this demo, since there are no Host->Device reports
}
int main(void)
{
- SetupHardware();
- GlobalInterruptEnable();
+ SetupHardware();
+ GlobalInterruptEnable();
- for (;;)
- {
- HID_Device_USBTask(&Mouse_HID_Interface);
- USB_USBTask();
- }
+ for (;;)
+ {
+ HID_Device_USBTask(&Mouse_HID_Interface);
+ USB_USBTask();
+ }
}