[core] Add lt_get_device_mac() function
This commit is contained in:
@@ -29,12 +29,6 @@ lt_cpu_model_t lt_cpu_get_model() {
|
|||||||
return CPU_MODEL_ENUM(FAMILY, chipId);
|
return CPU_MODEL_ENUM(FAMILY, chipId);
|
||||||
}
|
}
|
||||||
|
|
||||||
uint32_t lt_cpu_get_mac_id() {
|
|
||||||
uint8_t mac[6];
|
|
||||||
cfg_load_mac(mac); // force loading MAC from TLV (ignore user-set WiFi MAC)
|
|
||||||
return (mac[3]) | (mac[4] << 8) | (mac[5] << 16);
|
|
||||||
}
|
|
||||||
|
|
||||||
const char *lt_cpu_get_core_type() {
|
const char *lt_cpu_get_core_type() {
|
||||||
return "ARM968E-S";
|
return "ARM968E-S";
|
||||||
}
|
}
|
||||||
@@ -45,6 +39,10 @@ const char *lt_cpu_get_core_type() {
|
|||||||
| | | |/ _ \ \ / / |/ __/ _ \
|
| | | |/ _ \ \ / / |/ __/ _ \
|
||||||
| |__| | __/\ V /| | (_| __/
|
| |__| | __/\ V /| | (_| __/
|
||||||
|_____/ \___| \_/ |_|\___\__*/
|
|_____/ \___| \_/ |_|\___\__*/
|
||||||
|
void lt_get_device_mac(uint8_t *mac) {
|
||||||
|
cfg_load_mac(mac);
|
||||||
|
}
|
||||||
|
|
||||||
void lt_reboot() {
|
void lt_reboot() {
|
||||||
bk_reboot();
|
bk_reboot();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -38,6 +38,7 @@ uint32_t lt_cpu_get_unique_id();
|
|||||||
/**
|
/**
|
||||||
* @brief Get CPU ID based on the last three octets of MAC address.
|
* @brief Get CPU ID based on the last three octets of MAC address.
|
||||||
* Note: the number is 24-bit (with the MSB being zero).
|
* Note: the number is 24-bit (with the MSB being zero).
|
||||||
|
* The 3rd-to-last octet is least-significant, the last octet is most-significant.
|
||||||
*/
|
*/
|
||||||
uint32_t lt_cpu_get_mac_id();
|
uint32_t lt_cpu_get_mac_id();
|
||||||
|
|
||||||
|
|||||||
@@ -20,6 +20,13 @@ const char *lt_get_board_code();
|
|||||||
*/
|
*/
|
||||||
const char *lt_get_device_name();
|
const char *lt_get_device_name();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Read device's *default* MAC address into 'mac' array.
|
||||||
|
* This can be used even without Wi-Fi enabled, and will ignore
|
||||||
|
* user-changed Wi-Fi MAC (if changing is possible).
|
||||||
|
*/
|
||||||
|
void lt_get_device_mac(uint8_t *mac);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief Reboot the CPU.
|
* @brief Reboot the CPU.
|
||||||
*/
|
*/
|
||||||
|
|||||||
@@ -39,6 +39,12 @@ __attribute__((weak)) uint32_t lt_cpu_get_unique_id() {
|
|||||||
return lt_cpu_get_mac_id();
|
return lt_cpu_get_mac_id();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
__attribute__((weak)) uint32_t lt_cpu_get_mac_id() {
|
||||||
|
uint8_t mac[6];
|
||||||
|
lt_get_device_mac(mac);
|
||||||
|
return (mac[3] << 0) | (mac[4] << 8) | (mac[5] << 16);
|
||||||
|
}
|
||||||
|
|
||||||
__attribute__((weak)) uint8_t lt_cpu_get_core_count() {
|
__attribute__((weak)) uint8_t lt_cpu_get_core_count() {
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -158,10 +158,7 @@ IPAddress WiFiClass::localIP() {
|
|||||||
|
|
||||||
uint8_t *WiFiClass::macAddress(uint8_t *mac) {
|
uint8_t *WiFiClass::macAddress(uint8_t *mac) {
|
||||||
if ((getMode() & WIFI_MODE_STA) == 0) {
|
if ((getMode() & WIFI_MODE_STA) == 0) {
|
||||||
uint8_t *efuse = (uint8_t *)malloc(512);
|
lt_get_device_mac(mac);
|
||||||
EFUSE_LogicalMap_Read(efuse);
|
|
||||||
memcpy(mac, efuse + 0x11A, ETH_ALEN);
|
|
||||||
free(efuse);
|
|
||||||
return mac;
|
return mac;
|
||||||
}
|
}
|
||||||
memcpy(mac, NETIF_RTW_STA.hwaddr, ETH_ALEN);
|
memcpy(mac, NETIF_RTW_STA.hwaddr, ETH_ALEN);
|
||||||
|
|||||||
@@ -57,6 +57,13 @@ uint32_t lt_cpu_get_freq() {
|
|||||||
| | | |/ _ \ \ / / |/ __/ _ \
|
| | | |/ _ \ \ / / |/ __/ _ \
|
||||||
| |__| | __/\ V /| | (_| __/
|
| |__| | __/\ V /| | (_| __/
|
||||||
|_____/ \___| \_/ |_|\___\__*/
|
|_____/ \___| \_/ |_|\___\__*/
|
||||||
|
void lt_get_device_mac(uint8_t *mac) {
|
||||||
|
uint8_t *efuse = (uint8_t *)malloc(512);
|
||||||
|
EFUSE_LogicalMap_Read(efuse);
|
||||||
|
memcpy(mac, efuse + 0x11A, 6);
|
||||||
|
free(efuse);
|
||||||
|
}
|
||||||
|
|
||||||
bool lt_reboot_download_mode() {
|
bool lt_reboot_download_mode() {
|
||||||
// mww 0x40000138 0x8
|
// mww 0x40000138 0x8
|
||||||
HAL_WRITE32(SYSTEM_CTRL_BASE, REG_SYS_NORESET_FF, 0x08);
|
HAL_WRITE32(SYSTEM_CTRL_BASE, REG_SYS_NORESET_FF, 0x08);
|
||||||
|
|||||||
@@ -28,12 +28,6 @@ lt_cpu_model_t lt_cpu_get_model() {
|
|||||||
return CPU_MODEL_ENUM(FAMILY, (chip_id & 0xFF) | flash_mode);
|
return CPU_MODEL_ENUM(FAMILY, (chip_id & 0xFF) | flash_mode);
|
||||||
}
|
}
|
||||||
|
|
||||||
uint32_t lt_cpu_get_mac_id() {
|
|
||||||
uint8_t mac[3];
|
|
||||||
efuse_logical_read(0x11A + 3, 3, mac);
|
|
||||||
return (mac[0] << 0) | (mac[1] << 8) | (mac[2] << 16);
|
|
||||||
}
|
|
||||||
|
|
||||||
const char *lt_cpu_get_core_type() {
|
const char *lt_cpu_get_core_type() {
|
||||||
return "ARM Cortex-M4";
|
return "ARM Cortex-M4";
|
||||||
}
|
}
|
||||||
@@ -48,6 +42,10 @@ uint32_t lt_cpu_get_freq() {
|
|||||||
| | | |/ _ \ \ / / |/ __/ _ \
|
| | | |/ _ \ \ / / |/ __/ _ \
|
||||||
| |__| | __/\ V /| | (_| __/
|
| |__| | __/\ V /| | (_| __/
|
||||||
|_____/ \___| \_/ |_|\___\__*/
|
|_____/ \___| \_/ |_|\___\__*/
|
||||||
|
void lt_get_device_mac(uint8_t *mac) {
|
||||||
|
efuse_logical_read(0x11A, 6, mac);
|
||||||
|
}
|
||||||
|
|
||||||
void lt_reboot() {
|
void lt_reboot() {
|
||||||
sys_cpu_reset();
|
sys_cpu_reset();
|
||||||
while (1) {}
|
while (1) {}
|
||||||
|
|||||||
Reference in New Issue
Block a user