libopencm3
A free/libre/open-source firmware library for various ARM Cortex-M3 microcontrollers.
desig.h
Go to the documentation of this file.
1/*
2 * This file is part of the libopencm3 project.
3 *
4 * Copyright (C) 2012 Karl Palsson <karlp@tweak.net.au>
5 *
6 * This library is free software: you can redistribute it and/or modify
7 * it under the terms of the GNU Lesser General Public License as published by
8 * the Free Software Foundation, either version 3 of the License, or
9 * (at your option) any later version.
10 *
11 * This library is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU Lesser General Public License for more details.
15 *
16 * You should have received a copy of the GNU Lesser General Public License
17 * along with this library. If not, see <http://www.gnu.org/licenses/>.
18 */
19
20#ifndef LIBOPENCM3_DESIG_H
21#define LIBOPENCM3_DESIG_H
22
25
26/* --- Device Electronic Signature -------------------------------- */
27
29
30/**
31 * Read the on board flash size
32 * @return flash size in KB
33 */
34uint16_t desig_get_flash_size(void);
35
36/**
37 * Read the full 96 bit unique identifier
38 * Note: ST specifies that bits 31..16 are _also_ reserved for future use
39 * @param result pointer to at least 3xuint32_ts (96 bits)
40 */
41void desig_get_unique_id(uint32_t *result);
42
43/**
44 * Read the full 96 bit unique identifier and return it as a
45 * zero-terminated string
46 * @param string memory region to write the result to
47 * @param string_len the size of string in bytes
48 */
49void desig_get_unique_id_as_string(char *string,
50 unsigned int string_len);
51
52/**
53 * Generate the same serial number from the unique id registers as
54 * the DFU bootloader.
55 *
56 * This document: http://www.usb.org/developers/docs/devclass_docs/usbmassbulk_10.pdf
57 * says that the serial number has to be at least 12 digits long and that
58 * the last 12 digits need to be unique. It also stipulates that the valid
59 * character set is that of upper-case hexadecimal digits.
60 * The onboard DFU bootloader produces a 12-digit serial based on the
61 * 96-bit unique ID. Show the serial with ```dfu-util -l``` while the
62 * MCU is in DFU mode.
63 * @see https://my.st.com/52d187b7 for the algorithim used.
64 * @param string pointer to store serial in, must be at least 13 bytes
65 */
66void desig_get_unique_id_as_dfu(char *string);
67
69
70#endif
#define END_DECLS
Definition: common.h:34
#define BEGIN_DECLS
Definition: common.h:33
void desig_get_unique_id_as_dfu(char *string)
Generate the same serial number from the unique id registers as the DFU bootloader.
void desig_get_unique_id(uint32_t *result)
Read the full 96 bit unique identifier Note: ST specifies that bits 31..16 are also reserved for futu...
Definition: desig.c:48
uint16_t desig_get_flash_size(void)
Read the on board flash size.
Definition: desig.c:24
void desig_get_unique_id_as_string(char *string, unsigned int string_len)
Read the full 96 bit unique identifier and return it as a zero-terminated string.