From 7a4c9a92ac827df5cf5620e6cd3b9ad33d42e237 Mon Sep 17 00:00:00 2001 From: cpldcpu Date: Sat, 28 Dec 2013 15:11:39 +0100 Subject: firmware: CRC checking of all received data backport of optimizations by @gblargg --- firmware/usbconfig.h | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 'firmware/usbconfig.h') diff --git a/firmware/usbconfig.h b/firmware/usbconfig.h index 560c34d..8ccee36 100644 --- a/firmware/usbconfig.h +++ b/firmware/usbconfig.h @@ -110,6 +110,12 @@ * for long transfers increases the driver size. */ /* #define USB_RX_USER_HOOK(data, len) if(usbRxToken == (uchar)USBPID_SETUP) blinkLED(); */ + +// Check CRC of all received data +#define USB_RX_USER_HOOK( data, len ) { \ +if ( usbCrc16( data, len + 2 ) != 0x4FFE )\ +return;\ +} /* This macro is a hook if you want to do unconventional things. If it is * defined, it's inserted at the beginning of received message processing. * If you eat the received message and don't want default processing to -- cgit v1.2.3 From 6d2ac9e09f61d6ff267961ba9ff79b0a07e78e28 Mon Sep 17 00:00:00 2001 From: cpldcpu Date: Tue, 31 Dec 2013 15:42:09 +0100 Subject: firmware: more global registers and unions types Saves 70(!) bytes or so.. --- firmware/usbconfig.h | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) (limited to 'firmware/usbconfig.h') diff --git a/firmware/usbconfig.h b/firmware/usbconfig.h index 8ccee36..dc5cafc 100644 --- a/firmware/usbconfig.h +++ b/firmware/usbconfig.h @@ -169,10 +169,15 @@ return;\ #ifndef __ASSEMBLER__ void calibrateOscillatorASM(void); - extern uint16_t idlePolls; -# define USB_RESET_HOOK(resetStarts) if(!resetStarts){ ((uint8_t*)&idlePolls)[1]= 0;calibrateOscillatorASM();} + + #if AUTO_EXIT_NO_USB_MS>0 + extern uint16_union_t idlePolls; + #define USB_RESET_HOOK(resetStarts) if(!resetStarts){ idlePolls.b[1]=0; calibrateOscillatorASM();} + #else + #define USB_RESET_HOOK(resetStarts) if(!resetStarts){ calibrateOscillatorASM();} + #endif -# define USB_CFG_HAVE_MEASURE_FRAME_LENGTH 0 + #define USB_CFG_HAVE_MEASURE_FRAME_LENGTH 0 #endif -- cgit v1.2.3