diff options
Diffstat (limited to 'libs')
-rw-r--r-- | libs/NVRam/bitbang.c | 16 | ||||
-rw-r--r-- | libs/VPD/vpd.c | 4 |
2 files changed, 12 insertions, 8 deletions
diff --git a/libs/NVRam/bitbang.c b/libs/NVRam/bitbang.c index 0e8e67d..af99155 100644 --- a/libs/NVRam/bitbang.c +++ b/libs/NVRam/bitbang.c @@ -122,6 +122,7 @@ bool NVRam_sendBytes(uint8_t bytes[], uint32_t num_bytes) nvm_od.bits.SIOutputDisable = 0; // Drive MOSI RegNVMWrite_t nvm_write; + nvm_write.r32 = 0; NVM.Addr.r32 = nvm_od.r32; NVM.Write.r32 = nvm_write.r32; @@ -167,6 +168,7 @@ bool NVRam_sendAndGetBytes(uint8_t send_bytes[], uint8_t get_bytes[], int32_t nu nvm_od.bits.SIOutputDisable = 0; // Drive MOSI RegNVMWrite_t nvm_write; + nvm_write.r32 = 0; NVM.Addr.r32 = nvm_od.r32; NVM.Write.r32 = nvm_write.r32; @@ -196,11 +198,17 @@ uint32_t NVRam_bitbang_readWord(uint32_t address) }; uint8_t get_bytes[sizeof(send_bytes)]; uint32_t num_bytes = sizeof(send_bytes); - NVRam_sendAndGetBytes(send_bytes, get_bytes, num_bytes); - - uint32_t read_word = (get_bytes[4]) | (get_bytes[5] << 8) | (get_bytes[6] << 16) | (get_bytes[7] << 24); + if(NVRam_sendAndGetBytes(send_bytes, get_bytes, num_bytes)) + { + uint32_t read_word = (get_bytes[4]) | (get_bytes[5] << 8) | (get_bytes[6] << 16) | (get_bytes[7] << 24); - return read_word; + return read_word; + } + else + { + // TOOD: return an error. + return 0; + } } void NVRam_bitbang_writeWord(uint32_t address, uint32_t word) diff --git a/libs/VPD/vpd.c b/libs/VPD/vpd.c index c37c909..f0cf704 100644 --- a/libs/VPD/vpd.c +++ b/libs/VPD/vpd.c @@ -150,10 +150,6 @@ uint8_t *vpd_get_resource_by_index(uint8_t *buffer, uint32_t *len, uint16_t *nam { field = (vpd_field_t *)new_buf; - char *data = (char *)malloc(field->length + 1); - memcpy(data, &field->data, field->length); - data[field->length] = 0; - new_buf += field->length; new_buf += 3; |