feat(firmware): add IMU data structures and UART v2 parser
- Add SwitchImuSample struct and IMU fields to SwitchInputState - Add fill_imu_report_data() to pack samples into imuData[36] - Rewrite switch_pro_apply_uart_packet() for v2 with checksum validation - Enlarge poll_uart_frames() buffer to 64 bytes for variable-length frames - Clear imu_sample_count after each USB report send (prevent stale IMU)
This commit is contained in:
parent
fa0ddcd10f
commit
4501528371
3 changed files with 135 additions and 28 deletions
|
|
@ -10,6 +10,15 @@
|
|||
#include <stdint.h>
|
||||
#include "switch_pro_descriptors.h"
|
||||
|
||||
typedef struct {
|
||||
int16_t accel_x;
|
||||
int16_t accel_y;
|
||||
int16_t accel_z;
|
||||
int16_t gyro_x;
|
||||
int16_t gyro_y;
|
||||
int16_t gyro_z;
|
||||
} SwitchImuSample;
|
||||
|
||||
typedef struct {
|
||||
bool dpad_up;
|
||||
bool dpad_down;
|
||||
|
|
@ -35,6 +44,9 @@ typedef struct {
|
|||
uint16_t ly;
|
||||
uint16_t rx;
|
||||
uint16_t ry;
|
||||
|
||||
uint8_t imu_sample_count; // 0-3
|
||||
SwitchImuSample imu_samples[3];
|
||||
} SwitchInputState;
|
||||
|
||||
// Initialize USB state and calibration before entering the main loop.
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue