@@ -297,6 +297,14 @@ void programDataCompleteCallback(int32_t status, ARM_STORAGE_OPERATION operation
297
297
TEST_ASSERT ((operation == ARM_STORAGE_OPERATION_ERASE) || (operation == ARM_STORAGE_OPERATION_PROGRAM_DATA));
298
298
if (operation == ARM_STORAGE_OPERATION_ERASE) {
299
299
// printf("programming %u bytes at address %lu with pattern 0x%" PRIx32 "\n", sizeofData, (uint32_t)addr, BYTE_PATTERN);
300
+
301
+ size_t sizeofData = info.program_unit ;
302
+ TEST_ASSERT (BUFFER_SIZE >= sizeofData);
303
+ TEST_ASSERT ((sizeofData % sizeof (uint32_t )) == 0 );
304
+ for (size_t index = 0 ; index < sizeofData / sizeof (uint32_t ); index++) {
305
+ ((uint32_t *)buffer)[index] = BYTE_PATTERN;
306
+ }
307
+
300
308
status = drv->ProgramData (addr, buffer, sizeofData);
301
309
if (status < ARM_DRIVER_OK) {
302
310
return ; /* failure. this will trigger a timeout and cause test failure. */
@@ -345,13 +353,6 @@ control_t test_programDataUsingProgramUnit(const size_t call_count)
345
353
346
354
/* initialize the buffer to hold the pattern. */
347
355
ARM_STORAGE_CAPABILITIES capabilities = drv->GetCapabilities ();
348
- static const uint32_t BYTE_PATTERN = 0xAA551122 ;
349
- size_t sizeofData = info.program_unit ;
350
- TEST_ASSERT (BUFFER_SIZE >= sizeofData);
351
- TEST_ASSERT ((sizeofData % sizeof (uint32_t )) == 0 );
352
- for (size_t index = 0 ; index < sizeofData / sizeof (uint32_t ); index++) {
353
- ((uint32_t *)buffer)[index] = BYTE_PATTERN;
354
- }
355
356
356
357
/* Update the completion callback to 'programDataCompleteCallback'. */
357
358
if (call_count == 2 ) {
@@ -373,6 +374,14 @@ control_t test_programDataUsingProgramUnit(const size_t call_count)
373
374
} else {
374
375
TEST_ASSERT_EQUAL (firstBlock.attributes .erase_unit , rc);
375
376
377
+ static const uint32_t BYTE_PATTERN = 0xAA551122 ;
378
+ size_t sizeofData = info.program_unit ;
379
+ TEST_ASSERT (BUFFER_SIZE >= sizeofData);
380
+ TEST_ASSERT ((sizeofData % sizeof (uint32_t )) == 0 );
381
+ for (size_t index = 0 ; index < sizeofData / sizeof (uint32_t ); index++) {
382
+ ((uint32_t *)buffer)[index] = BYTE_PATTERN;
383
+ }
384
+
376
385
/* program the sector at addr */
377
386
// printf("programming %u bytes at address %lu with pattern 0x%" PRIx32 "\n", sizeofData, (uint32_t)addr, BYTE_PATTERN);
378
387
rc = drv->ProgramData ((uint32_t )addr, buffer, sizeofData);
@@ -413,6 +422,10 @@ void programDataOptimalCompleteCallback(int32_t status, ARM_STORAGE_OPERATION op
413
422
#ifndef __CC_ARM
414
423
printf (" programming %u bytes at address %lu with pattern 0x%x\n " , sizeofData, (uint32_t )addr, BYTE_PATTERN);
415
424
#endif
425
+ size_t sizeofData = info.optimal_program_unit ;
426
+ TEST_ASSERT (BUFFER_SIZE >= sizeofData);
427
+ memset (buffer, BYTE_PATTERN, sizeofData);
428
+
416
429
status = drv->ProgramData (addr, buffer, sizeofData);
417
430
if (status < ARM_DRIVER_OK) {
418
431
return ; /* failure. this will trigger a timeout and cause test failure. */
@@ -461,10 +474,6 @@ control_t test_programDataUsingOptimalProgramUnit(const size_t call_count)
461
474
462
475
/* initialize the buffer to hold the pattern. */
463
476
ARM_STORAGE_CAPABILITIES capabilities = drv->GetCapabilities ();
464
- static const uint8_t BYTE_PATTERN = 0xAA ;
465
- size_t sizeofData = info.optimal_program_unit ;
466
- TEST_ASSERT (BUFFER_SIZE >= sizeofData);
467
- memset (buffer, BYTE_PATTERN, sizeofData);
468
477
469
478
/* Update the completion callback to 'programDataCompleteCallback'. */
470
479
if (call_count == 2 ) {
@@ -487,6 +496,11 @@ control_t test_programDataUsingOptimalProgramUnit(const size_t call_count)
487
496
TEST_ASSERT_EQUAL (firstBlock.attributes .erase_unit , rc);
488
497
verifyBytePattern (addr, firstBlock.attributes .erase_unit , (uint8_t )0xFF );
489
498
499
+ static const uint8_t BYTE_PATTERN = 0xAA ;
500
+ size_t sizeofData = info.optimal_program_unit ;
501
+ TEST_ASSERT (BUFFER_SIZE >= sizeofData);
502
+ memset (buffer, BYTE_PATTERN, sizeofData);
503
+
490
504
/* program the sector at addr */
491
505
printf (" programming %u bytes at address %lu with pattern 0x%x\n " , sizeofData, (uint32_t )addr, BYTE_PATTERN);
492
506
rc = drv->ProgramData ((uint32_t )addr, buffer, sizeofData);
0 commit comments