1 /* 2 * Copyright 2024 Microchip Technology Inc. and its subsidiaries. 3 * 4 * SPDX-License-Identifier: Apache-2.0 5 */ 6 #include <stddef.h> 7 #include <stdint.h> 8 9 #include <device_mec5.h> 10 #include "mec_pcfg.h" 11 #include "mec_defs.h" 12 #include "mec_rom_api.h" 13 #include "mec_retval.h" 14 15 #define MEC5_ROM_VERSION_ADDR 0xf001u 16 #define MEC5_ROM_OTP_RD8_ADDR 0xf009u 17 #define MEC5_ROM_OTP_WR8_ADDR 0xf00du 18 19 typedef uint32_t (*rom_ver_td)(void); 20 typedef uint8_t (*rom_otp_rd8_td)(uint16_t otp_index, uint8_t *data); 21 typedef uint8_t (*rom_otp_wr8_td)(uint16_t otp_index, uint8_t data); 22 mec_hal_rom_version(void)23uint32_t mec_hal_rom_version(void) 24 { 25 rom_ver_td fp = (rom_ver_td)(MEC5_ROM_VERSION_ADDR); 26 27 return (*fp)(); 28 } 29 mec_hal_rom_otp_read_byte(uint16_t otp_index,uint8_t * data)30int mec_hal_rom_otp_read_byte(uint16_t otp_index, uint8_t *data) 31 { 32 rom_otp_rd8_td fp = (rom_otp_rd8_td)(MEC5_ROM_OTP_RD8_ADDR); 33 uint8_t rval = 0u; 34 35 if (!data) { 36 return MEC_RET_ERR_INVAL; 37 } 38 39 rval = (*fp)(otp_index, data); 40 if (!rval) { 41 return MEC_RET_ERR; 42 } 43 44 return MEC_RET_OK; 45 } 46 mec_hal_rom_otp_write_byte(uint16_t otp_index,uint8_t data)47int mec_hal_rom_otp_write_byte(uint16_t otp_index, uint8_t data) 48 { 49 rom_otp_wr8_td fp = (rom_otp_wr8_td)(MEC5_ROM_OTP_WR8_ADDR); 50 51 uint8_t rval = (*fp)(otp_index, data); 52 53 if (!rval) { 54 return MEC_RET_ERR; 55 } 56 57 return MEC_RET_OK; 58 } 59 60 /* end mec_rom.c */ 61