Skip to content

Commit 2ab9238

Browse files
committed
Structify flash device definitions.
1 parent 568c04e commit 2ab9238

13 files changed

Lines changed: 264 additions & 512 deletions

File tree

ports/atmel-samd/boards/circuitplayground_express/mpconfigboard.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@
3838

3939
#define SPEAKER_ENABLE_PIN (&pin_PA30)
4040

41-
#include "external_flash/external_flash.h"
41+
#include "external_flash/devices.h"
4242

4343
// If you change this, then make sure to update the linker scripts as well to
4444
// make sure you don't overwrite code.
@@ -47,8 +47,8 @@
4747

4848
#define BOARD_FLASH_SIZE (0x00040000 - 0x2000 - CIRCUITPY_INTERNAL_NVM_SIZE)
4949

50-
#include "external_flash/devices/S25FL216K.h"
51-
#include "external_flash/devices/GD25Q16C.h"
50+
#define EXTERNAL_FLASH_DEVICES 25FL216K, \
51+
GD25Q16C
5252

5353
#define CALIBRATE_CRYSTALLESS 1
5454

ports/atmel-samd/boards/metro_m4_express/mpconfigboard.h

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -20,14 +20,16 @@
2020

2121
#define AUTORESET_DELAY_MS 500
2222

23-
#include "external_flash/external_flash.h"
24-
2523
// If you change this, then make sure to update the linker scripts as well to
2624
// make sure you don't overwrite code
2725
// #define CIRCUITPY_INTERNAL_NVM_SIZE 256
2826
#define CIRCUITPY_INTERNAL_NVM_SIZE 0
2927

3028
#define BOARD_FLASH_SIZE (FLASH_SIZE - 0x4000 - CIRCUITPY_INTERNAL_NVM_SIZE)
3129

32-
#include "external_flash/devices/S25FL116K.h"
33-
#include "external_flash/devices/GD25Q16C.h"
30+
#include "external_flash/devices.h"
31+
32+
#define EXTERNAL_FLASH_DEVICE_COUNT 2
33+
#define EXTERNAL_FLASH_DEVICES S25FL116K, GD25Q16C
34+
35+
#include "external_flash/external_flash.h"
Lines changed: 180 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,180 @@
1+
/*
2+
* This file is part of the MicroPython project, http://micropython.org/
3+
*
4+
* The MIT License (MIT)
5+
*
6+
* Copyright (c) 2018 Scott Shawcroft for Adafruit Industries LLC
7+
*
8+
* Permission is hereby granted, free of charge, to any person obtaining a copy
9+
* of this software and associated documentation files (the "Software"), to deal
10+
* in the Software without restriction, including without limitation the rights
11+
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
12+
* copies of the Software, and to permit persons to whom the Software is
13+
* furnished to do so, subject to the following conditions:
14+
*
15+
* The above copyright notice and this permission notice shall be included in
16+
* all copies or substantial portions of the Software.
17+
*
18+
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
19+
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
20+
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
21+
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
22+
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
23+
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
24+
* THE SOFTWARE.
25+
*/
26+
#ifndef MICROPY_INCLUDED_ATMEL_SAMD_EXTERNAL_FLASH_DEVICES_H
27+
#define MICROPY_INCLUDED_ATMEL_SAMD_EXTERNAL_FLASH_DEVICES_H
28+
29+
#include <stdbool.h>
30+
#include <stdint.h>
31+
32+
typedef struct {
33+
uint32_t total_size;
34+
uint16_t erase_size;
35+
uint16_t page_size;
36+
uint16_t start_up_time_us;
37+
uint8_t manufacturer_id;
38+
uint8_t memory_type;
39+
uint8_t capacity;
40+
uint8_t max_clock_speed_mhz;
41+
bool has_sector_protection;
42+
bool supports_qspi;
43+
bool supports_qspi_writes;
44+
} external_flash_device;
45+
46+
// Settings for the Adesto Tech AT25DF081A 1MiB SPI flash. Its on the SAMD21
47+
// Xplained board.
48+
// Datasheet: https://www.adestotech.com/wp-content/uploads/doc8715.pdf
49+
#define AT25DF081A {\
50+
.total_size = (1 << 20), /* 1 MiB */ \
51+
.erase_size = (1 << 12), /* 4 KiB */ \
52+
.page_size = 256, /*256 bytes */ \
53+
.start_up_time_us = 10000, \
54+
.manufacturer_id = 0x1f, \
55+
.memory_type = 0x45, \
56+
.capacity = 0x01, \
57+
.max_clock_speed_mhz = 104, \
58+
.has_sector_protection = true, \
59+
.supports_qspi = true, \
60+
.supports_qspi_writes = false, \
61+
}
62+
63+
// Settings for the Gigadevice GD25Q16C 2MiB SPI flash.
64+
// Datasheet: http://www.gigadevice.com/wp-content/uploads/2017/12/DS-00086-GD25Q16C-Rev2.6.pdf
65+
66+
#define GD25Q16C {\
67+
.total_size = (1 << 21), /* 2 MiB */ \
68+
.erase_size = (1 << 12), /* 4 KiB */ \
69+
.page_size = 256, /*256 bytes */ \
70+
.start_up_time_us = 5000, \
71+
.manufacturer_id = 0xc8, \
72+
.memory_type = 0x40, \
73+
.capacity = 0x15, \
74+
.max_clock_speed_mhz = 104, \
75+
.has_sector_protection = true, \
76+
.supports_qspi = true, \
77+
.supports_qspi_writes = false, \
78+
}
79+
80+
// Settings for the Cypress (was Spansion) S25FL064L 8MiB SPI flash.
81+
// Datasheet: http://www.cypress.com/file/316661/download
82+
#define S25FL064L {\
83+
.total_size = (1 << 23), /* 8 MiB */ \
84+
.erase_size = (1 << 12), /* 4 KiB */ \
85+
.page_size = 256, /*256 bytes */ \
86+
.start_up_time_us = 300, \
87+
.manufacturer_id = 0x01, \
88+
.memory_type = 0x60, \
89+
.capacity = 0x17, \
90+
.max_clock_speed_mhz = 104, \
91+
.has_sector_protection = true, \
92+
.supports_qspi = true, \
93+
.supports_qspi_writes = false, \
94+
}
95+
96+
// Settings for the Cypress (was Spansion) S25FL116K 2MiB SPI flash.
97+
// Datasheet: http://www.cypress.com/file/196886/download
98+
#define S25FL116K {\
99+
.total_size = (1 << 21), /* 2 MiB */ \
100+
.erase_size = (1 << 12), /* 4 KiB */ \
101+
.page_size = 256, /*256 bytes */ \
102+
.start_up_time_us = 10000, \
103+
.manufacturer_id = 0x01, \
104+
.memory_type = 0x40, \
105+
.capacity = 0x15, \
106+
.max_clock_speed_mhz = 104, \
107+
.has_sector_protection = true, \
108+
.supports_qspi = true, \
109+
.supports_qspi_writes = false, \
110+
}
111+
112+
113+
// Settings for the Cypress (was Spansion) S25FL216K 2MiB SPI flash.
114+
// Datasheet: http://www.cypress.com/file/197346/download
115+
116+
#define S25FL216K {\
117+
.total_size = (1 << 21), /* 2 MiB */ \
118+
.erase_size = (1 << 12), /* 4 KiB */ \
119+
.page_size = 256, /*256 bytes */ \
120+
.start_up_time_us = 10000, \
121+
.manufacturer_id = 0x01, \
122+
.memory_type = 0x40, \
123+
.capacity = 0x15, \
124+
.max_clock_speed_mhz = 104, \
125+
.has_sector_protection = false, \
126+
.supports_qspi = true, \
127+
.supports_qspi_writes = false, \
128+
}
129+
130+
// Settings for the Winbond W25Q16FW 2MiB SPI flash.
131+
// Datasheet: https://www.winbond.com/resource-files/w25q16fw%20revj%2005182017%20sfdp.pdf
132+
133+
#define W25Q16FW {\
134+
.total_size = (1 << 21), /* 2 MiB */ \
135+
.erase_size = (1 << 12), /* 4 KiB */ \
136+
.page_size = 256, /*256 bytes */ \
137+
.start_up_time_us = 5000, \
138+
.manufacturer_id = 0xef, \
139+
.memory_type = 0x60, \
140+
.capacity = 0x15, \
141+
.max_clock_speed_mhz = 104, \
142+
.has_sector_protection = false, \
143+
.supports_qspi = true, \
144+
.supports_qspi_writes = false, \
145+
}
146+
147+
// Settings for the Winbond W25Q32BV 2MiB SPI flash.
148+
// Datasheet: https://www.winbond.com/resource-files/w25q32bv_revi_100413_wo_automotive.pdf
149+
150+
#define W25Q32BV {\
151+
.total_size = (1 << 21), /* 2 MiB */ \
152+
.erase_size = (1 << 12), /* 4 KiB */ \
153+
.page_size = 256, /*256 bytes */ \
154+
.start_up_time_us = 5000, \
155+
.manufacturer_id = 0xef, \
156+
.memory_type = 0x60, \
157+
.capacity = 0x16, \
158+
.max_clock_speed_mhz = 104, \
159+
.has_sector_protection = false, \
160+
.supports_qspi = true, \
161+
.supports_qspi_writes = false, \
162+
}
163+
164+
// Settings for the Winbond W25Q80DL 1MiB SPI flash.
165+
// Datasheet: https://www.winbond.com/resource-files/w25q80dv%20dl_revh_10022015.pdf
166+
#define W25Q80DL {\
167+
.total_size = (1 << 20), /* 1 MiB */ \
168+
.erase_size = (1 << 12), /* 4 KiB */ \
169+
.page_size = 256, /*256 bytes */ \
170+
.start_up_time_us = 5000, \
171+
.manufacturer_id = 0xef, \
172+
.memory_type = 0x60, \
173+
.capacity = 0x14, \
174+
.max_clock_speed_mhz = 104, \
175+
.has_sector_protection = false, \
176+
.supports_qspi = true, \
177+
.supports_qspi_writes = false, \
178+
}
179+
180+
#endif // MICROPY_INCLUDED_ATMEL_SAMD_EXTERNAL_FLASH_DEVICES_H

ports/atmel-samd/external_flash/devices/AT25DF081A.h

Lines changed: 0 additions & 52 deletions
This file was deleted.

ports/atmel-samd/external_flash/devices/GD25Q16C.h

Lines changed: 0 additions & 56 deletions
This file was deleted.

ports/atmel-samd/external_flash/devices/S25FL064L.h

Lines changed: 0 additions & 56 deletions
This file was deleted.

0 commit comments

Comments
 (0)