Contiki-NG
cc2538-dev.h
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2015, Benoît Thébaudeau <benoit.thebaudeau.dev@gmail.com>
3  * All rights reserved.
4  *
5  * Redistribution and use in source and binary forms, with or without
6  * modification, are permitted provided that the following conditions
7  * are met:
8  * 1. Redistributions of source code must retain the above copyright
9  * notice, this list of conditions and the following disclaimer.
10  * 2. Redistributions in binary form must reproduce the above copyright
11  * notice, this list of conditions and the following disclaimer in the
12  * documentation and/or other materials provided with the distribution.
13  *
14  * 3. Neither the name of the copyright holder nor the names of its
15  * contributors may be used to endorse or promote products derived
16  * from this software without specific prior written permission.
17  *
18  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
19  * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
20  * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
21  * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
22  * COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
23  * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
24  * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
25  * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
26  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
27  * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
28  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
29  * OF THE POSSIBILITY OF SUCH DAMAGE.
30  */
31 /**
32  * \addtogroup cc2538
33  * @{
34  *
35  * \defgroup cc2538-devices cc2538 family of devices
36  *
37  * Definitions for the cc2538 family of devices
38  * @{
39  *
40  * \file
41  * Header file for the cc2538 devices definitions
42  */
43 #ifndef CC2538_DEV_H_
44 #define CC2538_DEV_H_
45 
46 #include "contiki.h"
47 #include "sys/cc.h"
48 /*----------------------------------------------------------------------------*/
49 /** \name Bit-fields for the CC2538 devices features
50  * @{
51  */
52 #define CC2538_DEV_ID_M 0x0000000F /**< ID mask */
53 #define CC2538_DEV_ID_S 0 /**< ID shift */
54 #define CC2538_DEV_FLASH_SIZE_KB_M 0x0000FFF0 /**< kiB flash size mask */
55 #define CC2538_DEV_FLASH_SIZE_KB_S 4 /**< kiB flash size shift */
56 #define CC2538_DEV_SRAM_SIZE_KB_M 0x00FF0000 /**< kiB SRAM size mask */
57 #define CC2538_DEV_SRAM_SIZE_KB_S 16 /**< kiB SRAM size shift */
58 #define CC2538_DEV_AES_SHA_M 0x01000000 /**< Security HW AES/SHA */
59 #define CC2538_DEV_ECC_RSA_M 0x02000000 /**< Security HW ECC/RSA */
60 /** @} */
61 /*----------------------------------------------------------------------------*/
62 /** \name Macro defining a CC2538 device from its features
63  * @{
64  */
65 #define CC2538_DEV_DEF(id, flash_size_kb, sram_size_kb, aes_sha, ecc_rsa) \
66  ((id) << CC2538_DEV_ID_S | (flash_size_kb) << CC2538_DEV_FLASH_SIZE_KB_S | \
67  (sram_size_kb) << CC2538_DEV_SRAM_SIZE_KB_S | \
68  ((aes_sha) ? CC2538_DEV_AES_SHA_M : 0) | \
69  ((ecc_rsa) ? CC2538_DEV_ECC_RSA_M : 0))
70 /** @} */
71 /*----------------------------------------------------------------------------*/
72 /** \name Available CC2538 devices
73  * @{
74  */
75 #define CC2538_DEV_CC2538SF53 CC2538_DEV_DEF(0, 512, 32, 1, 1)
76 #define CC2538_DEV_CC2538SF23 CC2538_DEV_DEF(1, 256, 32, 1, 1)
77 #define CC2538_DEV_CC2538NF53 CC2538_DEV_DEF(2, 512, 32, 1, 0)
78 #define CC2538_DEV_CC2538NF23 CC2538_DEV_DEF(3, 256, 32, 1, 0)
79 #define CC2538_DEV_CC2538NF11 CC2538_DEV_DEF(4, 128, 16, 1, 0)
80 /** @} */
81 /*----------------------------------------------------------------------------*/
82 /** \name CC2538 device used by Contiki
83  * @{
84  */
85 #ifdef CC2538_DEV_CONF
86 #define CC2538_DEV CC2538_DEV_CONF
87 #else
88 #define CC2538_DEV CC2538_DEV_CC2538SF53
89 #endif
90 /** @} */
91 /*----------------------------------------------------------------------------*/
92 /** \name Features of the CC2538 device used by Contiki
93  * @{
94  */
95 /** Flash address */
96 #define CC2538_DEV_FLASH_ADDR 0x00200000
97 /** Flash size in bytes */
98 #define CC2538_DEV_FLASH_SIZE (((CC2538_DEV & CC2538_DEV_FLASH_SIZE_KB_M) >> \
99  CC2538_DEV_FLASH_SIZE_KB_S) << 10)
100 /** SRAM (non-retention + low-leakage) address */
101 #define CC2538_DEV_SRAM_ADDR (CC2538_DEV_RLSRAM_SIZE ? \
102  CC2538_DEV_RLSRAM_ADDR : \
103  CC2538_DEV_LLSRAM_ADDR)
104 /** SRAM (non-retention + low-leakage) size in bytes */
105 #define CC2538_DEV_SRAM_SIZE (((CC2538_DEV & CC2538_DEV_SRAM_SIZE_KB_M) >> \
106  CC2538_DEV_SRAM_SIZE_KB_S) << 10)
107 /** Regular-leakage SRAM address */
108 #define CC2538_DEV_RLSRAM_ADDR 0x20000000
109 /** Regular-leakage SRAM size in bytes */
110 #define CC2538_DEV_RLSRAM_SIZE (CC2538_DEV_SRAM_SIZE - CC2538_DEV_LLSRAM_SIZE)
111 /** Low-leakage SRAM address */
112 #define CC2538_DEV_LLSRAM_ADDR 0x20004000
113 /** Low-leakage SRAM size in bytes */
114 #define CC2538_DEV_LLSRAM_SIZE MIN(CC2538_DEV_SRAM_SIZE, 16384)
115 /** Security HW AES/SHA */
116 #define CC2538_DEV_AES_SHA (!!(CC2538_DEV & CC2538_DEV_AES_SHA_M))
117 /** Security HW ECC/RSA */
118 #define CC2538_DEV_ECC_RSA (!!(CC2538_DEV & CC2538_DEV_ECC_RSA_M))
119 /** @} */
120 
121 #endif /* CC2538_DEV_H_ */
122 
123 /**
124  * @}
125  * @}
126  */
Default definitions of C compiler quirk work-arounds.