Skip to content

Commit f7b2edc

Browse files
committed
Coding style fix
1 parent 0de89c7 commit f7b2edc

File tree

2 files changed

+15
-32
lines changed

2 files changed

+15
-32
lines changed

targets/TARGET_Realtek/TARGET_AMEBA/flash_api.c

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -21,10 +21,6 @@
2121

2222
int32_t flash_init(flash_t *obj)
2323
{
24-
//obj->flash_size = FLASH_SIZE;
25-
//obj->sector_size = FLASH_SECTOR_SIZE;
26-
//obj->page_size = FLASH_PAGE_SIZE;
27-
2824
__flash_ext_turnon();
2925

3026
return 0;
@@ -52,7 +48,7 @@ int32_t flash_program_page(flash_t *obj, uint32_t address, const uint8_t *data,
5248
uint32_t flash_get_sector_size(const flash_t *obj, uint32_t address)
5349
{
5450
if (address < FLASH_START || address >= FLASH_END)
55-
return (uint32_t)-1;
51+
return 0;
5652

5753
return FLASH_SECTOR_SIZE;
5854
}

targets/TARGET_Realtek/TARGET_AMEBA/flash_ext.c

Lines changed: 14 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -28,8 +28,6 @@ static flash_t flashobj;
2828
static void flash_ext_init(void)
2929
{
3030
if (!SpicFlashInitRtl8195A(SpicOneBitMode)){
31-
32-
DBG_8195A("SPI Init Fail!!!!!!\n");
3331
HAL_WRITE32(SYSTEM_CTRL_BASE, REG_SYS_DSTBY_INFO3, HAL_READ32(SYSTEM_CTRL_BASE, REG_SYS_DSTBY_INFO3)|0xf);
3432
} else {
3533
flash_inited = 1;
@@ -106,8 +104,7 @@ int flash_ext_write_word(flash_t *obj, uint32_t address, uint32_t data)
106104

107105
if(flashtype == FLASH_MICRON){
108106
SpicWaitOperationDoneRtl8195A(flashobj.SpicInitPara);
109-
} else
110-
{
107+
} else {
111108
SpicWaitWipDoneRefinedRtl8195A(flashobj.SpicInitPara);
112109
}
113110

@@ -206,7 +203,7 @@ int __flash_ext_stream_write(flash_t *obj, uint32_t addr, uint32_t len, const ui
206203
for (i = 0; i < offset && len > 0; i++, len--) {
207204
*ptr = *pbuf;
208205
pbuf++;
209-
ptr++;
206+
ptr++;
210207
}
211208
HAL_WRITE32(SPI_FLASH_BASE, addr, word);
212209
SpicWaitBusyDoneRtl8195A();
@@ -285,11 +282,13 @@ int flash_ext_stream_write(flash_t *obj, uint32_t addr, uint32_t len, uint8_t *d
285282
return status;
286283
}
287284

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+
{
289287
return flash_ext_stream_read(obj, addr, len, data);
290288
}
291289

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+
{
293292
return flash_ext_stream_write(obj, addr, len, data);
294293
}
295294

@@ -320,7 +319,6 @@ int flash_ext_burst_write(flash_t *obj, uint32_t address ,uint32_t length, uint8
320319
__flash_ext_turnon();
321320

322321
flashtype = flashobj.SpicInitPara.flashtype;
323-
324322
OccuSize = address & 0xFF;
325323
if((length >= PageSize) ||((length + OccuSize) >= PageSize)){
326324
ProgramSize = PageSize - OccuSize;
@@ -337,11 +335,12 @@ int flash_ext_burst_write(flash_t *obj, uint32_t address ,uint32_t length, uint8
337335
// Wait flash busy done (wip=0)
338336
if(flashtype == FLASH_MICRON){
339337
SpicWaitOperationDoneRtl8195A(flashobj.SpicInitPara);
340-
} else
338+
} else {
341339
SpicWaitWipDoneRefinedRtl8195A(flashobj.SpicInitPara);
340+
}
342341

343342
address += ProgramSize;
344-
data+= ProgramSize;
343+
data += ProgramSize;
345344
length -= ProgramSize;
346345
OccuSize = 0;
347346
} else{
@@ -352,11 +351,12 @@ int flash_ext_burst_write(flash_t *obj, uint32_t address ,uint32_t length, uint8
352351
// Wait flash busy done (wip=0)
353352
if(flashtype == FLASH_MICRON){
354353
SpicWaitOperationDoneRtl8195A(flashobj.SpicInitPara);
355-
} else
354+
} else {
356355
SpicWaitWipDoneRefinedRtl8195A(flashobj.SpicInitPara);
356+
}
357357

358358
address += PageSize;
359-
data+=PageSize;
359+
data += PageSize;
360360
length -= PageSize;
361361
}
362362
flashobj.Length = length;
@@ -367,16 +367,15 @@ int flash_ext_burst_write(flash_t *obj, uint32_t address ,uint32_t length, uint8
367367
// Wait flash busy done (wip=0)
368368
if(flashtype == FLASH_MICRON){
369369
SpicWaitOperationDoneRtl8195A(flashobj.SpicInitPara);
370-
} else
370+
} else {
371371
SpicWaitWipDoneRefinedRtl8195A(flashobj.SpicInitPara);
372+
}
372373

373374
break;
374375
}
375376
}
376377
flashobj.Length = length;
377378
}
378-
379-
380379
__flash_ext_turnoff();
381380
return 0;
382381

@@ -393,10 +392,8 @@ int flash_ext_burst_write(flash_t *obj, uint32_t address ,uint32_t length, uint8
393392
int flash_ext_burst_read(flash_t *obj, uint32_t address, uint32_t length, uint8_t *data)
394393
{
395394
__flash_ext_turnon();
396-
397395
SpicWaitWipDoneRefinedRtl8195A(flashobj.SpicInitPara);
398396
SpicUserReadRtl8195A(length, address, data, SpicOneBitMode);
399-
400397
__flash_ext_turnoff();
401398
return 0;
402399
}
@@ -406,9 +403,7 @@ int flash_ext_get_status(flash_t *obj)
406403
uint8_t status = 0;
407404

408405
__flash_ext_turnon();
409-
410406
status = SpicGetFlashStatusRefinedRtl8195A(flashobj.SpicInitPara);
411-
412407
__flash_ext_turnoff();
413408
return status;
414409
}
@@ -427,11 +422,8 @@ The block protected area and the corresponding control bits are provided in the
427422
int flash_ext_set_status(flash_t *obj, uint32_t data)
428423
{
429424
__flash_ext_turnon();
430-
431425
SpicSetFlashStatusRefinedRtl8195A(data, flashobj.SpicInitPara);
432426
SpicWaitWipDoneRefinedRtl8195A(flashobj.SpicInitPara);
433-
DBG_8195A("Status Register After Setting= %x\n", flash_ext_get_status(&flashobj));
434-
435427
__flash_ext_turnoff();
436428
return 0;
437429
}
@@ -443,10 +435,8 @@ This function aims to reset the status register, please make sure the operation
443435
void flash_ext_reset_status(flash_t *obj)
444436
{
445437
__flash_ext_turnon();
446-
447438
SpicSetFlashStatusRefinedRtl8195A(0, flashobj.SpicInitPara);
448439
SpicWaitWipDoneRefinedRtl8195A(flashobj.SpicInitPara);
449-
450440
__flash_ext_turnoff();
451441
}
452442

@@ -468,11 +458,8 @@ Please refer to flash datasheet for more information about memory mapping.
468458
int flash_ext_set_extend_addr(flash_t *obj, uint32_t data)
469459
{
470460
__flash_ext_turnon();
471-
472461
SpicSetExtendAddrRtl8195A(data, flashobj.SpicInitPara);
473462
SpicWaitWipDoneRefinedRtl8195A(flashobj.SpicInitPara);
474-
DBG_8195A("Extended Address Register After Setting= %x\n", flash_ext_get_extend_addr(&flashobj));
475-
476463
__flash_ext_turnoff();
477464
return 0;
478465
}

0 commit comments

Comments
 (0)