一次按4字节倍数读取,怎么优雅改成按读1字节倍数读取呢?
程序代码:
int flash_read(UINT32 ptr_add,uint8_t *buffer,int Read_Lengh ) { UINT32 *ptr = (UINT32*)ptr_add; UINT32 buf = 0; int black = 0; int r_black = 0; black = Read_Lengh/4; while(black!= r_black) { buf = *ptr; buffer[0+r_black*4] = buf&0x000000ff; buffer[1+r_black*4] = buf>>8&0x000000ff; buffer[2+r_black*4] = buf>>16&0x000000ff; buffer[3+r_black*4] = buf>>24&0x000000ff; ptr++; printf("%02X %02X %02X %02X ",buffer[0+r_black*4],buffer[1+r_black*4],buffer[2+r_black*4],buffer[3+r_black*4]); r_black++; if ((r_black*4)%16==0) printf("\n"); } printf("\n"); return (r_black*4); }