I have three questions! (1)How can i get the device only ID,not bd_address? (2)If i define read bd address from OTP, it is different every time power on? (3) How to get the only bd address?
1. you mean the device_name? if yes, after powering up, it is stored in the handle. "GAPM_GET_ATT_HANDLE(GAP_IDX_DEVNAME),". you can call function "attmdb_att_get_value" to get the value. 2. no. every time when power on , device address will be read from OTP. it is a fix value. 3. the address is stored in 0x40000024 and 0x40000028
Hi Gongyu_Dialog About the second question ,I found it really different every time power on.And should I define APP_BOOT_FROM_OTP which boot from spi flash actually ?But if i undef APP_BOOT_FROM_OTP and all da14580 device's bd address are the same just like 0x13 0x89 0x67 0x45 0x23 0x01? void nvds_read_bdaddr_from_otp() { const uint16_t BDADDR_OFFSET = 0x7fd4; // offset of BD address in OTP header # ifndef APP_BOOT_FROM_OTP int cnt = 100000; #define XPMC_MODE_MREAD 0x1 uint8_t *otp_bdaddr = (uint8_t *)0x40000 + BDADDR_OFFSET; //where in OTP header is BDADDR
SetBits16(CLK_AMBA_REG, OTP_ENABLE, 1); // enable OTP clock while ((GetWord16(ANA_STATUS_REG) & LDO_OTP_OK) != LDO_OTP_OK && cnt--) /* Just wait */;
// set OTP in read mode SetWord32(OTPC_MODE_REG, XPMC_MODE_MREAD); # else uint8_t *otp_bdaddr = (uint8_t *)0x20000000 + BDADDR_OFFSET; //where in OTP header is BDADDR # endif //APP_BOOT_FROM_OTP
“APP_BOOT_FROM_OTP” is related with CFG_BOOT_FROM_OTP. If defined, means the booting procedure starts from OTP. otp code will copy to SRAM started from 0x20000000.
如果你是直接从flash引导,不要违抗ne CFG_BOOT_FROM_OTP.
and regarding the function "nvds_read_bdaddr_from_otp", if no otp booting procedure is involved, it will try to get the address from OTP(0x7fd4). and copy the address value to " dev_bdaddr".
later function "custom_nvds_get_func" will be used to get the bd address. If there is all zero for "dev_bdaddr", then will call "nvds_get_func" to get the address from "const struct nvds_data_struct nvds_data_storage".
1. you mean the device_name? if yes, after powering up, it is stored in the handle. "GAPM_GET_ATT_HANDLE(GAP_IDX_DEVNAME),".
you can call function "attmdb_att_get_value" to get the value.
2. no. every time when power on , device address will be read from OTP. it is a fix value.
3. the address is stored in 0x40000024 and 0x40000028
Hi Gongyu_Dialog
About the second question ,I found it really different every time power on.And should I define APP_BOOT_FROM_OTP which boot from spi flash actually ?But if i undef APP_BOOT_FROM_OTP and all da14580 device's bd address are the same just like 0x13 0x89 0x67 0x45 0x23 0x01?
void nvds_read_bdaddr_from_otp()
{
const uint16_t BDADDR_OFFSET = 0x7fd4; // offset of BD address in OTP header
# ifndef APP_BOOT_FROM_OTP
int cnt = 100000;
#define XPMC_MODE_MREAD 0x1
uint8_t *otp_bdaddr = (uint8_t *)0x40000 + BDADDR_OFFSET; //where in OTP header is BDADDR
SetBits16(CLK_AMBA_REG, OTP_ENABLE, 1); // enable OTP clock
while ((GetWord16(ANA_STATUS_REG) & LDO_OTP_OK) != LDO_OTP_OK && cnt--)
/* Just wait */;
// set OTP in read mode
SetWord32(OTPC_MODE_REG, XPMC_MODE_MREAD);
# else
uint8_t *otp_bdaddr = (uint8_t *)0x20000000 + BDADDR_OFFSET; //where in OTP header is BDADDR
# endif //APP_BOOT_FROM_OTP
memcpy(&dev_bdaddr, otp_bdaddr, sizeof(dev_bdaddr));
SetBits16(CLK_AMBA_REG, OTP_ENABLE, 0); //disable OTP clock
}
“APP_BOOT_FROM_OTP” is related with CFG_BOOT_FROM_OTP. If defined, means the booting procedure starts from OTP. otp code will copy to SRAM started from 0x20000000.
如果你是直接从flash引导,不要违抗ne CFG_BOOT_FROM_OTP.
and regarding the function "nvds_read_bdaddr_from_otp", if no otp booting procedure is involved, it will try to get the address from OTP(0x7fd4).
and copy the address value to " dev_bdaddr".
later function "custom_nvds_get_func" will be used to get the bd address. If there is all zero for "dev_bdaddr", then will call "nvds_get_func" to get the address from "const struct nvds_data_struct nvds_data_storage".