EVE 1.0
eve-module.h
Go to the documentation of this file.
1 #ifndef EVE_MODULE_H
2 #define EVE_MODULE_H
3 /**********************************************************************/
4 /*
5  * Copyright (c) 2015-2016, Jetro AS
6  * All rights reserved.
7  *
8  * Redistribution and use in source and binary forms, with or without modification,
9  * are permitted provided that the following conditions are met:
10  *
11  * 1. Redistributions of source code must retain the above copyright notice,
12  * this list of conditions and the following disclaimer.
13  * 2. Redistributions in binary form must reproduce the above copyright notice,
14  * this list of conditions and the following disclaimer in the documentation
15  * and/or other materials provided with the distribution.
16  * 3. The name of the author may not be used to endorse or promote products
17  * derived from this software without specific prior written permission.
18  *
19  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONRIBUTORS ``AS IS'' AND ANY EXPRESS
20  * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
21  * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT
22  * SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
23  * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT
24  * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
25  * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
26  * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
27  * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY
28  * OF SUCH DAMAGE.
29  *
30  * This file is part of the EVE platform.
31  */
32 
33 /**
34  * \file
35  * \brief EVE module stub.
36  *
37  * The file is actually a placeholder for an module-specific part of board.h
38  * Not yet completed.
39  *
40  * \author KLO, Jetro AS
41  * \internal
42  */ /******************************************************************/
43 
44 #include <nrf.h>
45 
46 /***********************************************************************
47  * EVE product type enumeration
48  **********************************************************************/
49 #define EVE_PRODUCT_TYPE_USB 0
50 #define EVE_PRODUCT_TYPE_BLE 1
51 #define EVE_PRODUCT_TYPE_ETH 2
52 
53 #define EVE_IS_USB() (EVE_PRODUCT_TYPE == EVE_PRODUCT_TYPE_USB)
54 #define EVE_IS_BLE() (EVE_PRODUCT_TYPE == EVE_PRODUCT_TYPE_BLE)
55 #define EVE_IS_ETH() (EVE_PRODUCT_TYPE == EVE_PRODUCT_TYPE_ETH)
56 
57 #define EVE_STANDARD 1
58 #define EVE_EXTENDED 2
59 
60 #ifndef EVE_PRODUCT_VERSION // KŲ!! PE!!
61 #define EVE_PRODUCT_VERSION EVE_STANDARD
62 #endif
63 
64 /***********************************************************************
65  * EVE_Module.c
66  **********************************************************************/
67 extern const struct spi_t Spi0;
68 extern const struct spi_memory_t ExtFlash;
69 
70 /***********************************************************************
71  * Returns 64bits unique microcontroller number
72  **********************************************************************/
73 static inline const uint32_t EveUniqueNumber(void)
74 {
75  return *(uint64_t *) &NRF_FICR->DEVICEID[0];
76 }
77 
78 
79 #if (EVE_PRODUCT_VERSION == EVE_STANDARD)
80 /***********************************************************************
81  * Definition of SPI-based 2 MByte FLASH memory type S25FL216K from Spansion
82 ***********************************************************************/
83 /* This memory was used in EVE modules 1.0. Now replaced by S25FL132K.
84 enum spi_memory_protection_t
85 {
86  SPI_MEMORY_PROTECTION_BLOCK_NONE = (0x00 << 2), // 0 block
87  SPI_MEMORY_PROTECTION_BLOCK_31 = (0x01 << 2), // 1 block
88  SPI_MEMORY_PROTECTION_BLOCK_30_31 = (0x02 << 2), // 2 blocks
89  SPI_MEMORY_PROTECTION_BLOCK_28_31 = (0x03 << 2), // 4 blocks
90  SPI_MEMORY_PROTECTION_BLOCK_24_31 = (0x04 << 2), // 8 blocks
91  SPI_MEMORY_PROTECTION_BLOCK_16_31 = (0x05 << 2), // 16 blocks
92  SPI_MEMORY_PROTECTION_BLOCK_0_15 = (0x0a << 2), // 16 blocks
93  SPI_MEMORY_PROTECTION_BLOCK_0_23 = (0x0b << 2), // 24 blocks
94  SPI_MEMORY_PROTECTION_BLOCK_0_27 = (0x0c << 2), // 28 blocks
95  SPI_MEMORY_PROTECTION_BLOCK_0_29 = (0x0d << 2), // 30 blocks
96  SPI_MEMORY_PROTECTION_BLOCK_0_30 = (0x0e << 2), // 31 blocks
97  SPI_MEMORY_PROTECTION_BLOCK_ALL = (0x0f << 2), // 32 blocks
98  SPI_MEMORY_PROTECTION_BLOCK_MASK = (0x0f << 2), // Mask
99 };
100 
101 #define EXT_FLASH_PAGE_SIZE_EXPONENT (8)
102 #define EXT_FLASH_SECTOR_SIZE_EXPONENT (12)
103 #define EXT_FLASH_BLOCK_SIZE_EXPONENT (16)
104 #define EXT_FLASH_SIZE_EXPONENT (21)
105 */
106 
107 
108 /***********************************************************************
109  * Definition of SPI-based 4 MByte FLASH memory type S25FL132K from Spansion
110 ***********************************************************************/
111 /* S25FL132K from Spansion */
112 enum spi_memory_protection_t
113 {
114  SPI_MEMORY_PROTECTION_BLOCK_NONE = (0x00 << 2), // 0 block
115  SPI_MEMORY_PROTECTION_BLOCK_63 = (0x01 << 2), // 1 block
116  SPI_MEMORY_PROTECTION_BLOCK_62_63 = (0x02 << 2), // 2 blocks
117  SPI_MEMORY_PROTECTION_BLOCK_60_63 = (0x03 << 2), // 4 blocks
118  SPI_MEMORY_PROTECTION_BLOCK_56_63 = (0x04 << 2), // 8 blocks
119  SPI_MEMORY_PROTECTION_BLOCK_48_63 = (0x05 << 2), // 16 blocks
120  SPI_MEMORY_PROTECTION_BLOCK_32_63 = (0x06 << 2), // 32 blocks
121  SPI_MEMORY_PROTECTION_BLOCK_0 = (0x09 << 2), // 1 block
122  SPI_MEMORY_PROTECTION_BLOCK_0_1 = (0x0a << 2), // 2 blocks
123  SPI_MEMORY_PROTECTION_BLOCK_0_3 = (0x0b << 2), // 4 blocks
124  SPI_MEMORY_PROTECTION_BLOCK_0_7 = (0x0c << 2), // 8 blocks
125  SPI_MEMORY_PROTECTION_BLOCK_0_15 = (0x0d << 2), // 16 blocks
126  SPI_MEMORY_PROTECTION_BLOCK_0_31 = (0x0e << 2), // 32 blocks
127  SPI_MEMORY_PROTECTION_BLOCK_0_63 = (0x0f << 2), // 64 blocks
128  SPI_MEMORY_PROTECTION_BLOCK_ALL = (0x0f << 2), // 64 blocks
129  SPI_MEMORY_PROTECTION_BLOCK_MASK = (0x0f << 2), // Mask
130 };
131 
132 #define EXT_FLASH_PAGE_SIZE_EXPONENT (8)
133 #define EXT_FLASH_SECTOR_SIZE_EXPONENT (12)
134 #define EXT_FLASH_BLOCK_SIZE_EXPONENT (16)
135 #define EXT_FLASH_SIZE_EXPONENT (22)
136 
137 #elif (EVE_PRODUCT_VERSION == EVE_EXTENDED)
138 /***********************************************************************
139  * Definition of SPI-based 16 MByte FLASH memory type W25Q128FV from Winbond
140 ***********************************************************************/
141 enum spi_memory_protection_t
142 {
143  SPI_MEMORY_PROTECTION_BLOCK_NONE = (0x00 << 2), // 0 block
144  SPI_MEMORY_PROTECTION_BLOCK_252_255 = (0x01 << 2), // 4 block
145  SPI_MEMORY_PROTECTION_BLOCK_248_255 = (0x02 << 2), // 8 blocks
146  SPI_MEMORY_PROTECTION_BLOCK_240_255 = (0x03 << 2), // 16 blocks
147  SPI_MEMORY_PROTECTION_BLOCK_224_255 = (0x04 << 2), // 32 blocks
148  SPI_MEMORY_PROTECTION_BLOCK_192_255 = (0x05 << 2), // 64 blocks
149  SPI_MEMORY_PROTECTION_BLOCK_128_255 = (0x06 << 2), // 128 blocks
150  SPI_MEMORY_PROTECTION_BLOCK_0_3 = (0x09 << 2), // 4 block
151  SPI_MEMORY_PROTECTION_BLOCK_0_7 = (0x0a << 2), // 8 blocks
152  SPI_MEMORY_PROTECTION_BLOCK_0_15 = (0x0b << 2), // 16 blocks
153  SPI_MEMORY_PROTECTION_BLOCK_0_31 = (0x0c << 2), // 32 blocks
154  SPI_MEMORY_PROTECTION_BLOCK_0_63 = (0x0d << 2), // 64 blocks
155  SPI_MEMORY_PROTECTION_BLOCK_0_127 = (0x0e << 2), // 128 blocks
156  SPI_MEMORY_PROTECTION_BLOCK_0_255 = (0x0f << 2), // 256 blocks
157  SPI_MEMORY_PROTECTION_BLOCK_ALL = (0x0f << 2), // 256 blocks
158  SPI_MEMORY_PROTECTION_BLOCK_MASK = (0x0f << 2), // Mask
159 };
160 
161 // W25Q128FV from Winbond
162 #define EXT_FLASH_PAGE_SIZE_EXPONENT (8)
163 #define EXT_FLASH_SECTOR_SIZE_EXPONENT (12)
164 #define EXT_FLASH_BLOCK_SIZE_EXPONENT (16)
165 #define EXT_FLASH_SIZE_EXPONENT (24)
166 #endif
167 
168 /***********************************************************************
169  * Common definition for SPI-based flash memory
170 ***********************************************************************/
171 #define EXT_FLASH_PAGE_SIZE (1UL << EXT_FLASH_PAGE_SIZE_EXPONENT)
172 #define EXT_FLASH_SECTOR_SIZE (1UL << EXT_FLASH_SECTOR_SIZE_EXPONENT)
173 #define EXT_FLASH_BLOCK_SIZE (1UL << EXT_FLASH_BLOCK_SIZE_EXPONENT)
174 #define EXT_FLASH_SIZE (1UL << EXT_FLASH_SIZE_EXPONENT)
175 #define EXT_FLASH_PAGES_PR_SECTOR (EXT_FLASH_SECTOR_SIZE / EXT_FLASH_PAGE_SIZE)
176 
177  /**
178  * @name Functions called from application programs
179  * @{
180  */
181 
182 /**********************************************************************/
183 /**
184  * @brief Name: EveSpiPowerUp\n
185  * Power up VCC for components connected to SPI.
186  * SpiEnable() must be called after this function to get SPI pin setup.
187  *
188  * @param Spi SPI to be used
189  ***********************************************************************/
190 extern void EveSpiPowerUp(const struct spi_t *Spi);
191 
192 /**********************************************************************/
193 /**
194  * @brief Name: EveSpiPowerDown\n
195  * Power down VCC for components connected to SPI.
196  * SpiDisable() must be called prior to this function to get default pin setup.
197  *
198  * @param Spi SPI to be used
199  ***********************************************************************/
200 extern void EveSpiPowerDown(const struct spi_t *Spi);
201 
202 /** @} */
203 
204 #endif //EVE_MODULE_H
const struct spi_t * Spi
Definition: spi-memory.h:88
void EveSpiPowerDown(const struct spi_t *Spi)
Name: EveSpiPowerDown Power down VCC for components connected to SPI. SpiDisable() must be called pri...
void EveSpiPowerUp(const struct spi_t *Spi)
Name: EveSpiPowerUp Power up VCC for components connected to SPI. SpiEnable() must be called after th...
Definition: spi.h:166