Improved accuracy
[hackover2013-badge-firmware.git] / core / iap / iap.c
1 /**************************************************************************/
2 /*!
3 @file iap.c
4 Source: http://knowledgebase.nxp.com/showthread.php?t=1594
5 */
6 /**************************************************************************/
7 #include "iap.h"
8
9 IAP_return_t iap_return;
10
11 #define IAP_ADDRESS 0x1FFF1FF1
12 uint32_t param_table[5];
13
14 /**************************************************************************/
15 /*!
16 Sends the IAP command and stores the result
17 */
18 /**************************************************************************/
19 void iap_entry(uint32_t param_tab[], uint32_t result_tab[])
20 {
21 void (*iap)(uint32_t[], uint32_t[]);
22 iap = (void (*)(uint32_t[], uint32_t[]))IAP_ADDRESS;
23 iap(param_tab,result_tab);
24 }
25
26 /**************************************************************************/
27 /*!
28 Returns the CPU's unique 128-bit serial number (4 words long)
29
30 @section Example
31
32 @code
33 #include "core/iap/iap.h"
34
35 IAP_return_t iap_return;
36 iap_return = iapReadSerialNumber();
37
38 if (iap_return.ReturnCode == 0)
39 {
40 printf("Serial Number: %08X %08X %08X %08X %s",
41 iap_return.Result[0],
42 iap_return.Result[1],
43 iap_return.Result[2],
44 iap_return.Result[3],
45 CFG_PRINTF_NEWLINE);
46 }
47 @endcode
48 */
49 /**************************************************************************/
50 IAP_return_t iapReadSerialNumber(void)
51 {
52 // ToDo: Why does IAP sometime cause the application to halt when read???
53 param_table[0] = IAP_CMD_READUID;
54 iap_entry(param_table,(uint32_t*)(&iap_return));
55 return iap_return;
56 }
57
This page took 0.058362 seconds and 5 git commands to generate.