diff --git a/Makefile b/Makefile index 0bf79b5..a146d1e 100644 --- a/Makefile +++ b/Makefile @@ -8,7 +8,7 @@ OBJS = main.o VPATH += OBJS += OBJS += basic/basic.o basic/reinvoke_isp.o basic/delayms.o basic/voltage.o -OBJS += basic/keyin.o +OBJS += basic/keyin.o basic/uuid.o LIBS += core/libcore.a lcd/liblcd.a modules/libmodules.a filesystem/libfat.a usb/libusb.a ########################################################################## diff --git a/basic/basic.h b/basic/basic.h index 8b59e3a..8b4281a 100644 --- a/basic/basic.h +++ b/basic/basic.h @@ -139,4 +139,8 @@ uint32_t GetVoltage(void); #define BTN_ENTER (1<<4) uint8_t getInput(void); +//uuid.c +uint32_t GetUUID32(void); +uint16_t GetUUID16(void); + #endif diff --git a/basic/uuid.c b/basic/uuid.c new file mode 100644 index 0000000..51ab132 --- /dev/null +++ b/basic/uuid.c @@ -0,0 +1,18 @@ +#include "lpc134x.h" +#include "sysdefs.h" + +#include "core/iap/iap.h" + +uint32_t GetUUID32(void){ + IAP_return_t iap_return; + iap_return = iapReadSerialNumber(); + + return iap_return.Result[1]; +}; + +// What OpenBeacon used. Do we want this? +uint16_t GetUUID16(void){ + IAP_return_t iap_return; + iap_return = iapReadSerialNumber(); + return crc16 ((uint8_t *) iap_return.Result, sizeof (iap_return.Result)); +}; diff --git a/filesystem/ff.c b/filesystem/ff.c index 3b22fc3..c22f2c1 100644 --- a/filesystem/ff.c +++ b/filesystem/ff.c @@ -91,6 +91,7 @@ #include "ff.h" /* FatFs configurations and declarations */ #include "diskio.h" /* Declarations of low level disk I/O functions */ +#include "basic/basic.h" /*-------------------------------------------------------------------------- @@ -3692,7 +3693,7 @@ FRESULT f_mkfs ( tbl[BS_BootSig32] = 0x29; /* Extended boot signature */ mem_cpy(tbl+BS_VolLab32, "NO NAME " "FAT32 ", 19); /* Volume label, FAT signature */ } else { - ST_DWORD(tbl+BS_VolID, n); /* VSN */ + ST_DWORD(tbl+BS_VolID, GetUUID32()); /* VSN */ ST_WORD(tbl+BPB_FATSz16, n_fat); /* Number of sectors per FAT */ tbl[BS_DrvNum] = 0x80; /* Drive number */ tbl[BS_BootSig] = 0x29; /* Extended boot signature */