@@ -615,6 +615,44 @@ static void i2c_write_flash_callback(uint8_t* pData, uint8_t size) {
615
615
i2c_fillBuffer ((uint8_t * ) pI2cCommand , 0 , 1 );
616
616
}
617
617
break ;
618
+ case gFlashCfgEncWindow_c :
619
+ if (size == 1 ) {
620
+ /* If size is 1 (only cmd id), this means it's a read */
621
+ uint32_t tempFileEncWindowStart = __REV (gflashConfig .fileEncWindowStart );
622
+ uint32_t tempFileEncWindowEnd = __REV (gflashConfig .fileEncWindowEnd );
623
+ i2c_fillBuffer ((uint8_t * ) pI2cCommand , 0 , 1 );
624
+ i2c_fillBuffer ((uint8_t * ) & tempFileEncWindowStart , 1 , sizeof (gflashConfig .fileEncWindowStart ));
625
+ i2c_fillBuffer ((uint8_t * ) & tempFileEncWindowEnd , 5 , sizeof (gflashConfig .fileEncWindowEnd ));
626
+ } else if (size == 9 ) {
627
+ /* If size is 9 (cmd id + 8B data), this means it's a write */
628
+ uint32_t tempFileEncWindowStart = pI2cCommand -> cmdData .data [0 ] << 24 |
629
+ pI2cCommand -> cmdData .data [1 ] << 16 |
630
+ pI2cCommand -> cmdData .data [2 ] << 8 |
631
+ pI2cCommand -> cmdData .data [3 ] << 0 ;
632
+ uint32_t tempFileEncWindowEnd = pI2cCommand -> cmdData .data [4 ] << 24 |
633
+ pI2cCommand -> cmdData .data [5 ] << 16 |
634
+ pI2cCommand -> cmdData .data [6 ] << 8 |
635
+ pI2cCommand -> cmdData .data [7 ] << 0 ;
636
+
637
+ /* Validate encoding window */
638
+ if (tempFileEncWindowStart <= tempFileEncWindowEnd ) {
639
+ gflashConfig .fileEncWindowStart = tempFileEncWindowStart ;
640
+ tempFileEncWindowStart = __REV (gflashConfig .fileEncWindowStart );
641
+ gflashConfig .fileEncWindowEnd = tempFileEncWindowEnd ;
642
+ tempFileEncWindowEnd = __REV (gflashConfig .fileEncWindowEnd );
643
+
644
+ i2c_fillBuffer ((uint8_t * ) pI2cCommand , 0 , 1 );
645
+ i2c_fillBuffer ((uint8_t * ) & tempFileEncWindowStart , 1 , sizeof (gflashConfig .fileEncWindowStart ));
646
+ i2c_fillBuffer ((uint8_t * ) & tempFileEncWindowEnd , 5 , sizeof (gflashConfig .fileEncWindowEnd ));
647
+ } else {
648
+ pI2cCommand -> cmdId = gFlashError_c ;
649
+ i2c_fillBuffer ((uint8_t * ) pI2cCommand , 0 , 1 );
650
+ }
651
+ } else {
652
+ pI2cCommand -> cmdId = gFlashError_c ;
653
+ i2c_fillBuffer ((uint8_t * ) pI2cCommand , 0 , 1 );
654
+ }
655
+ break ;
618
656
case gFlashCfgFileVisible_c :
619
657
if (size == 1 ) {
620
658
/* If size is 1 (only cmd id), this means it's a read */
@@ -658,6 +696,8 @@ static void i2c_write_flash_callback(uint8_t* pData, uint8_t size) {
658
696
memcpy (gflashConfig .fileName , FLASH_CFG_FILENAME , 11 );
659
697
gflashConfig .fileSize = FLASH_CFG_FILESIZE ;
660
698
gflashConfig .fileVisible = FLASH_CFG_FILEVISIBLE ;
699
+ gflashConfig .fileEncWindowStart = 0 ;
700
+ gflashConfig .fileEncWindowEnd = 0 ;
661
701
}
662
702
i2c_fillBuffer ((uint8_t * ) pI2cCommand , 0 , 1 );
663
703
break ;
0 commit comments