@@ -1110,20 +1110,25 @@ int8_t WiFiDrv::downloadFile(const char* url, uint8_t url_len, const char *filen
11101110 return _data;
11111111}
11121112
1113- int8_t WiFiDrv::fileOperation (uint8_t operation, const char *filename, uint8_t filename_len, size_t offset, uint8_t * buffer, uint8_t len)
1113+ int8_t WiFiDrv::fileOperation (uint8_t operation, const char *filename, uint8_t filename_len, size_t offset, uint8_t * buffer, size_t len)
11141114{
11151115 WAIT_FOR_SLAVE_SELECT ();
11161116 // Send Command
1117- SpiDrv::sendCmd (operation, PARAM_NUMS_3);
1117+ uint8_t numParams = PARAM_NUMS_3;
1118+ if (operation == WRITE_FILE) {
1119+ numParams = PARAM_NUMS_4;
1120+ }
1121+
1122+ SpiDrv::sendCmd (operation, numParams);
11181123 SpiDrv::sendParam ((uint8_t *)&offset, sizeof (offset), NO_LAST_PARAM);
11191124 SpiDrv::sendParam ((uint8_t *)&len, sizeof (len), NO_LAST_PARAM);
11201125 SpiDrv::sendParam ((uint8_t *)filename, filename_len, (operation == WRITE_FILE) ? NO_LAST_PARAM : LAST_PARAM);
11211126 if (operation == WRITE_FILE) {
1122- SpiDrv::sendParam ((uint8_t *)buffer, len, LAST_PARAM);
1127+ SpiDrv::sendParamNoLen ((uint8_t *)buffer, len, LAST_PARAM);
11231128 }
11241129
11251130 // pad to multiple of 4
1126- int commandSize = 7 + sizeof (offset) + sizeof (len) + filename_len;
1131+ int commandSize = 4 + numParams + sizeof (offset) + sizeof (len) + filename_len;
11271132 while (commandSize % 4 ) {
11281133 SpiDrv::readChar ();
11291134 commandSize++;
0 commit comments