在开高优化等级后,发现代码不能运行,检查后发现在system_n32wb03x.c中memcpy被优化掉了,不太清楚编译器为什么会这样做,但可以在110行左右做如下修改解决
void memcpy2(uint8_t *dst, const uint8_t *src, int len){
uint8_t __IO *dst2 = dst;
for(int i = 0; i < len; i++){
dst2[i] = src[i];
}
}
void SystemTrimValueRead(uint8_t* p_data,uint32_t byte_length)
{
uint32_t ramcode[TRIM_READ_CMD_CODE_LEN/4 +1 ];
trim_read_cmd_func_t trim_read_cmd_func = (trim_read_cmd_func_t)((uint8_t*)&ramcode[0] + 0x11);
memcpy2((void*)ramcode,(const void*)TRIM_READ_CMD_CODE,TRIM_READ_CMD_CODE_LEN);
(*trim_read_cmd_func)(TRIM_STORE_ADDR, p_data, byte_length);
}
|