Expand file tree Collapse file tree 3 files changed +10
-7
lines changed Original file line number Diff line number Diff line change 1
1
// ===================================================================================
2
2
// Project: picoSTK AVR ISP Programmer based on CH551, CH552, CH554
3
- // Version: v1.2
3
+ // Version: v1.3
4
4
// Year: 2023
5
5
// Author: Stefan Wagner
6
6
// Github: https://github.com/wagiminator
Original file line number Diff line number Diff line change @@ -260,9 +260,11 @@ uint8_t write_flash(uint16_t length) {
260
260
}
261
261
262
262
uint8_t write_eeprom (uint16_t length ) {
263
- uint16_t x ;
264
- for (x = 0 ; x < length ; x ++ ) {
265
- spi_transaction (0xC0 , 0x00 , (_addr << 1 ) + x , buff [x ]);
263
+ uint16_t x = 0 ;
264
+ _addr <<= 1 ;
265
+ while (x < length ) {
266
+ spi_transaction (0xC0 , _addr >> 8 , _addr , buff [x ++ ]);
267
+ _addr ++ ;
266
268
DLY_us (9600 );
267
269
}
268
270
return STK_OK ;
@@ -310,9 +312,10 @@ uint8_t flash_read_page(uint16_t length) {
310
312
}
311
313
312
314
uint8_t eeprom_read_page (uint16_t length ) {
313
- uint16_t x ;
314
- for (x = 0 ; x < length ; x ++ ) {
315
- CDC_write (spi_transaction (0xA0 , 0x00 , (_addr << 1 ) + x , 0xFF ));
315
+ _addr <<= 1 ;
316
+ while (length -- ) {
317
+ CDC_write (spi_transaction (0xA0 , _addr >> 8 , _addr , 0xFF ));
318
+ _addr ++ ;
316
319
}
317
320
return STK_OK ;
318
321
}
0 commit comments