1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
/**
 *******************************************************************************
 * @file     pan_mac_addr.c
 * @create   2024-11-01    
 * @author   Panchip BLE GROUP
 * @note
 * Copyright (c) 2022 Shanghai Panchip Microelectronics Co.,Ltd.
 *
 *******************************************************************************
 */
 
 #include <stdint.h>
 #include "PanSeries.h"
 #include "app_log.h"
 
/******************************************************************************* 
 * Macro
 ******************************************************************************/
 
 
 /******************************************************************************* 
 * Variable Define & Declaration 
 ******************************************************************************/
extern uint8_t m_chip_mac[6]; // from soc.c
 
/******************************************************************************* 
 * Function Declaration
 ******************************************************************************/
 
 
/******************************************************************************* 
 * Function Define
 ******************************************************************************/
uint8_t pan10x_mac_addr_get(uint8_t *mac)
{
    uint8_t addr_null[6] = {0, 0, 0, 0, 0, 0};
    
    if (memcmp(m_chip_mac, addr_null, 6) == 0) {
        APP_LOG_WRN("Warnning: No chip mac addr\n");
        return 1;
    } else {
        memcpy(mac, m_chip_mac, 6);
        return 0;
    }
}
 
uint8_t pan10x_roll_mac_addr_get(uint8_t *mac)
{
    uint8_t addr_temp[6];
    uint8_t addr_null[] = {0xff, 0xff, 0xff, 0xff, 0xff, 0xff};
    
    FMC_ReadInfoArea(FLCTL, 0x100, CMD_DREAD, addr_temp, sizeof(addr_temp));
    
    if (memcmp(addr_temp, addr_null, 6) == 0) {
        APP_LOG_WRN("Warnning: No chip roll mac addr\n");
        return 1;
    } else {
        memcpy(mac, addr_temp, 6);
        return 0;
    }
}
 
char *addr_to_str(const void *addr)
{
    static char buf[6 * 2 + 5 + 1];
    const uint8_t *u8p;
 
    u8p = addr;
    sprintf(buf, "%02X:%02X:%02X:%02X:%02X:%02X",
            u8p[5], u8p[4], u8p[3], u8p[2], u8p[1], u8p[0]);
 
    return buf;
}