36
36
#include "cdc_enumerate.h"
37
37
38
38
const char RomBOOT_Version [] = SAM_BA_VERSION ;
39
- const char RomBOOT_ExtendedCapabilities [] = "[Arduino:XY ]" ;
39
+ const char RomBOOT_ExtendedCapabilities [] = "[Arduino:XYZ ]" ;
40
40
41
41
/* Provides one common interface to handle both USART and USB-CDC */
42
42
typedef struct
@@ -186,9 +186,8 @@ void sam_ba_monitor_run(void)
186
186
}
187
187
}
188
188
189
- #if 0
190
189
// Prints a 32-bit integer in hex.
191
- void printn (uint32_t n ) {
190
+ void put_uint32 (uint32_t n ) {
192
191
char buff [8 ];
193
192
int i ;
194
193
for (i = 0 ; i < 8 ; i ++ ) {
@@ -199,7 +198,6 @@ void printn(uint32_t n) {
199
198
}
200
199
ptr_monitor_if -> putdata (buff , 8 );
201
200
}
202
- #endif
203
201
204
202
void sam_ba_monitor_loop (void )
205
203
{
@@ -393,6 +391,27 @@ void sam_ba_monitor_loop(void)
393
391
// Notify command completed
394
392
ptr_monitor_if -> putdata ("Y\n\r" , 3 );
395
393
}
394
+ else if (command == 'Z' )
395
+ {
396
+ // This command calculate CRC for a given area of memory.
397
+ // It's useful to quickly check if a transfer has been done
398
+ // successfully.
399
+
400
+ // Syntax: Z[START_ADDR],[SIZE]#
401
+ // Returns: Z[CRC]#
402
+
403
+ uint8_t * data = (uint8_t * )ptr_data ;
404
+ uint32_t size = current_number ;
405
+ uint16_t crc = 0 ;
406
+ uint32_t i = 0 ;
407
+ for (i = 0 ; i < size ; i ++ )
408
+ crc = add_crc (* data ++ , crc );
409
+
410
+ // Send response
411
+ ptr_monitor_if -> putdata ("Z" , 1 );
412
+ put_uint32 (crc );
413
+ ptr_monitor_if -> putdata ("#\n\r" , 3 );
414
+ }
396
415
397
416
command = 'z' ;
398
417
current_number = 0 ;
0 commit comments