@@ -209,25 +209,32 @@ static int np_send_bad_block_info(uint32_t addr)
209
209
return 0 ;
210
210
}
211
211
212
- static int np_cmd_nand_read_id (np_prog_t * prog )
212
+ static int _np_cmd_nand_read_id (np_prog_t * prog )
213
213
{
214
214
np_resp_id_t resp ;
215
215
size_t resp_len = sizeof (resp );
216
216
217
217
DEBUG_PRINT ("Read ID command\r\n" );
218
218
219
- led_rd_set (true);
220
-
221
219
resp .header .code = NP_RESP_DATA ;
222
220
resp .header .info = resp_len - sizeof (resp .header );
223
221
nand_read_id (& resp .nand_id );
224
222
225
223
if (np_comm_cb )
226
224
np_comm_cb -> send ((uint8_t * )& resp , resp_len );
227
225
226
+ return 0 ;
227
+ }
228
+
229
+ static int np_cmd_nand_read_id (np_prog_t * prog )
230
+ {
231
+ int ret ;
232
+
233
+ led_rd_set (true);
234
+ ret = _np_cmd_nand_read_id (prog );
228
235
led_rd_set (false);
229
236
230
- return 0 ;
237
+ return ret ;
231
238
}
232
239
233
240
static int np_nand_erase (np_prog_t * prog , uint32_t page )
@@ -257,7 +264,7 @@ static int np_nand_erase(np_prog_t *prog, uint32_t page)
257
264
return 0 ;
258
265
}
259
266
260
- static int np_cmd_nand_erase (np_prog_t * prog )
267
+ static int _np_cmd_nand_erase (np_prog_t * prog )
261
268
{
262
269
uint32_t addr , page , pages_in_block , len ;
263
270
np_erase_cmd_t * erase_cmd = (np_erase_cmd_t * )prog -> rx_buf ;
@@ -267,8 +274,6 @@ static int np_cmd_nand_erase(np_prog_t *prog)
267
274
268
275
DEBUG_PRINT ("Erase at 0x%lx %lx bytes command\r\n" , addr , len );
269
276
270
- led_wr_set (true);
271
-
272
277
if (addr & (prog -> chip_info -> block_size - 1 ))
273
278
return np_send_error (NP_ERR_ADDR_NOT_ALIGN );
274
279
@@ -296,9 +301,18 @@ static int np_cmd_nand_erase(np_prog_t *prog)
296
301
page += pages_in_block ;
297
302
}
298
303
304
+ return np_send_ok_status ();
305
+ }
306
+
307
+ static int np_cmd_nand_erase (np_prog_t * prog )
308
+ {
309
+ int ret ;
310
+
311
+ led_wr_set (true);
312
+ ret = _np_cmd_nand_erase (prog );
299
313
led_wr_set (false);
300
314
301
- return np_send_ok_status () ;
315
+ return ret ;
302
316
}
303
317
304
318
static int np_send_write_ack (uint32_t bytes_ack )
@@ -526,7 +540,7 @@ static int np_nand_read(uint32_t addr, np_page_t *page,
526
540
return 0 ;
527
541
}
528
542
529
- static int np_cmd_nand_read (np_prog_t * prog )
543
+ static int _np_cmd_nand_read (np_prog_t * prog )
530
544
{
531
545
uint32_t addr ;
532
546
static np_page_t page ;
@@ -536,8 +550,6 @@ static int np_cmd_nand_read(np_prog_t *prog)
536
550
np_read_cmd_t * read_cmd = (np_read_cmd_t * )prog -> rx_buf ;
537
551
np_resp_t * resp = (np_resp_t * )np_packet_send_buf ;
538
552
539
- led_rd_set (true);
540
-
541
553
DEBUG_PRINT ("Read at 0x%lx %lx bytes command\r\n" , read_cmd -> addr ,
542
554
read_cmd -> len );
543
555
@@ -598,9 +610,18 @@ static int np_cmd_nand_read(np_prog_t *prog)
598
610
}
599
611
}
600
612
613
+ return 0 ;
614
+ }
615
+
616
+ static int np_cmd_nand_read (np_prog_t * prog )
617
+ {
618
+ int ret ;
619
+
620
+ led_rd_set (true);
621
+ ret = _np_cmd_nand_read (prog );
601
622
led_rd_set (false);
602
623
603
- return 0 ;
624
+ return ret ;
604
625
}
605
626
606
627
static int np_cmd_nand_select (np_prog_t * prog )
@@ -660,13 +681,11 @@ static int np_read_bad_block_info_from_page(np_prog_t *prog, uint32_t block,
660
681
return 0 ;
661
682
}
662
683
663
- static int np_cmd_read_bad_blocks (np_prog_t * prog )
684
+ static int _np_cmd_read_bad_blocks (np_prog_t * prog )
664
685
{
665
686
bool is_bad ;
666
687
uint32_t block , block_num , page_num , page ;
667
688
668
- led_rd_set (true);
669
-
670
689
block_num = prog -> chip_info -> size / prog -> chip_info -> block_size ;
671
690
page_num = prog -> chip_info -> block_size / prog -> chip_info -> page_size ;
672
691
@@ -689,9 +708,18 @@ static int np_cmd_read_bad_blocks(np_prog_t *prog)
689
708
}
690
709
}
691
710
711
+ return np_send_ok_status ();
712
+ }
713
+
714
+ int np_cmd_read_bad_blocks (np_prog_t * prog )
715
+ {
716
+ int ret ;
717
+
718
+ led_rd_set (true);
719
+ ret = _np_cmd_read_bad_blocks (prog );
692
720
led_rd_set (false);
693
721
694
- return np_send_ok_status () ;
722
+ return ret ;
695
723
}
696
724
697
725
static np_cmd_handler_t cmd_handler [] =
0 commit comments