@@ -28,8 +28,6 @@ static flash_t flashobj;
28
28
static void flash_ext_init (void )
29
29
{
30
30
if (!SpicFlashInitRtl8195A (SpicOneBitMode )){
31
-
32
- DBG_8195A ("SPI Init Fail!!!!!!\n" );
33
31
HAL_WRITE32 (SYSTEM_CTRL_BASE , REG_SYS_DSTBY_INFO3 , HAL_READ32 (SYSTEM_CTRL_BASE , REG_SYS_DSTBY_INFO3 )|0xf );
34
32
} else {
35
33
flash_inited = 1 ;
@@ -106,8 +104,7 @@ int flash_ext_write_word(flash_t *obj, uint32_t address, uint32_t data)
106
104
107
105
if (flashtype == FLASH_MICRON ){
108
106
SpicWaitOperationDoneRtl8195A (flashobj .SpicInitPara );
109
- } else
110
- {
107
+ } else {
111
108
SpicWaitWipDoneRefinedRtl8195A (flashobj .SpicInitPara );
112
109
}
113
110
@@ -206,7 +203,7 @@ int __flash_ext_stream_write(flash_t *obj, uint32_t addr, uint32_t len, const ui
206
203
for (i = 0 ; i < offset && len > 0 ; i ++ , len -- ) {
207
204
* ptr = * pbuf ;
208
205
pbuf ++ ;
209
- ptr ++ ;
206
+ ptr ++ ;
210
207
}
211
208
HAL_WRITE32 (SPI_FLASH_BASE , addr , word );
212
209
SpicWaitBusyDoneRtl8195A ();
@@ -285,11 +282,13 @@ int flash_ext_stream_write(flash_t *obj, uint32_t addr, uint32_t len, uint8_t *d
285
282
return status ;
286
283
}
287
284
288
- int flash_stream_read (flash_t * obj , uint32_t addr , uint32_t len , uint8_t * data ){
285
+ int flash_stream_read (flash_t * obj , uint32_t addr , uint32_t len , uint8_t * data )
286
+ {
289
287
return flash_ext_stream_read (obj , addr , len , data );
290
288
}
291
289
292
- int flash_stream_write (flash_t * obj , uint32_t addr , uint32_t len , uint8_t * data ){
290
+ int flash_stream_write (flash_t * obj , uint32_t addr , uint32_t len , uint8_t * data )
291
+ {
293
292
return flash_ext_stream_write (obj , addr , len , data );
294
293
}
295
294
@@ -320,7 +319,6 @@ int flash_ext_burst_write(flash_t *obj, uint32_t address ,uint32_t length, uint8
320
319
__flash_ext_turnon ();
321
320
322
321
flashtype = flashobj .SpicInitPara .flashtype ;
323
-
324
322
OccuSize = address & 0xFF ;
325
323
if ((length >= PageSize ) || ((length + OccuSize ) >= PageSize )){
326
324
ProgramSize = PageSize - OccuSize ;
@@ -337,11 +335,12 @@ int flash_ext_burst_write(flash_t *obj, uint32_t address ,uint32_t length, uint8
337
335
// Wait flash busy done (wip=0)
338
336
if (flashtype == FLASH_MICRON ){
339
337
SpicWaitOperationDoneRtl8195A (flashobj .SpicInitPara );
340
- } else
338
+ } else {
341
339
SpicWaitWipDoneRefinedRtl8195A (flashobj .SpicInitPara );
340
+ }
342
341
343
342
address += ProgramSize ;
344
- data += ProgramSize ;
343
+ data += ProgramSize ;
345
344
length -= ProgramSize ;
346
345
OccuSize = 0 ;
347
346
} else {
@@ -352,11 +351,12 @@ int flash_ext_burst_write(flash_t *obj, uint32_t address ,uint32_t length, uint8
352
351
// Wait flash busy done (wip=0)
353
352
if (flashtype == FLASH_MICRON ){
354
353
SpicWaitOperationDoneRtl8195A (flashobj .SpicInitPara );
355
- } else
354
+ } else {
356
355
SpicWaitWipDoneRefinedRtl8195A (flashobj .SpicInitPara );
356
+ }
357
357
358
358
address += PageSize ;
359
- data += PageSize ;
359
+ data += PageSize ;
360
360
length -= PageSize ;
361
361
}
362
362
flashobj .Length = length ;
@@ -367,16 +367,15 @@ int flash_ext_burst_write(flash_t *obj, uint32_t address ,uint32_t length, uint8
367
367
// Wait flash busy done (wip=0)
368
368
if (flashtype == FLASH_MICRON ){
369
369
SpicWaitOperationDoneRtl8195A (flashobj .SpicInitPara );
370
- } else
370
+ } else {
371
371
SpicWaitWipDoneRefinedRtl8195A (flashobj .SpicInitPara );
372
+ }
372
373
373
374
break ;
374
375
}
375
376
}
376
377
flashobj .Length = length ;
377
378
}
378
-
379
-
380
379
__flash_ext_turnoff ();
381
380
return 0 ;
382
381
@@ -393,10 +392,8 @@ int flash_ext_burst_write(flash_t *obj, uint32_t address ,uint32_t length, uint8
393
392
int flash_ext_burst_read (flash_t * obj , uint32_t address , uint32_t length , uint8_t * data )
394
393
{
395
394
__flash_ext_turnon ();
396
-
397
395
SpicWaitWipDoneRefinedRtl8195A (flashobj .SpicInitPara );
398
396
SpicUserReadRtl8195A (length , address , data , SpicOneBitMode );
399
-
400
397
__flash_ext_turnoff ();
401
398
return 0 ;
402
399
}
@@ -406,9 +403,7 @@ int flash_ext_get_status(flash_t *obj)
406
403
uint8_t status = 0 ;
407
404
408
405
__flash_ext_turnon ();
409
-
410
406
status = SpicGetFlashStatusRefinedRtl8195A (flashobj .SpicInitPara );
411
-
412
407
__flash_ext_turnoff ();
413
408
return status ;
414
409
}
@@ -427,11 +422,8 @@ The block protected area and the corresponding control bits are provided in the
427
422
int flash_ext_set_status (flash_t * obj , uint32_t data )
428
423
{
429
424
__flash_ext_turnon ();
430
-
431
425
SpicSetFlashStatusRefinedRtl8195A (data , flashobj .SpicInitPara );
432
426
SpicWaitWipDoneRefinedRtl8195A (flashobj .SpicInitPara );
433
- DBG_8195A ("Status Register After Setting= %x\n" , flash_ext_get_status (& flashobj ));
434
-
435
427
__flash_ext_turnoff ();
436
428
return 0 ;
437
429
}
@@ -443,10 +435,8 @@ This function aims to reset the status register, please make sure the operation
443
435
void flash_ext_reset_status (flash_t * obj )
444
436
{
445
437
__flash_ext_turnon ();
446
-
447
438
SpicSetFlashStatusRefinedRtl8195A (0 , flashobj .SpicInitPara );
448
439
SpicWaitWipDoneRefinedRtl8195A (flashobj .SpicInitPara );
449
-
450
440
__flash_ext_turnoff ();
451
441
}
452
442
@@ -468,11 +458,8 @@ Please refer to flash datasheet for more information about memory mapping.
468
458
int flash_ext_set_extend_addr (flash_t * obj , uint32_t data )
469
459
{
470
460
__flash_ext_turnon ();
471
-
472
461
SpicSetExtendAddrRtl8195A (data , flashobj .SpicInitPara );
473
462
SpicWaitWipDoneRefinedRtl8195A (flashobj .SpicInitPara );
474
- DBG_8195A ("Extended Address Register After Setting= %x\n" , flash_ext_get_extend_addr (& flashobj ));
475
-
476
463
__flash_ext_turnoff ();
477
464
return 0 ;
478
465
}
0 commit comments