Skip to content

Commit 01c153c

Browse files
committed
Fix devices include by splitting type from defines
1 parent da4dcee commit 01c153c

File tree

5 files changed

+80
-51
lines changed

5 files changed

+80
-51
lines changed
Lines changed: 78 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,78 @@
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_SUPERVISOR_SHARED_EXTERNAL_FLASH_DEVICE_H
27+
#define MICROPY_INCLUDED_SUPERVISOR_SHARED_EXTERNAL_FLASH_DEVICE_H
28+
29+
#include <stdbool.h>
30+
#include <stdint.h>
31+
32+
typedef struct {
33+
uint32_t total_size;
34+
uint16_t start_up_time_us;
35+
36+
// Three response bytes to 0x9f JEDEC ID command.
37+
uint8_t manufacturer_id;
38+
uint8_t memory_type;
39+
uint8_t capacity;
40+
41+
// Max clock speed for all operations and the fastest read mode.
42+
uint8_t max_clock_speed_mhz;
43+
44+
// Bitmask for Quad Enable bit if present. 0x00 otherwise. This is for the highest byte in the
45+
// status register.
46+
uint8_t quad_enable_bit_mask;
47+
48+
bool has_sector_protection : 1;
49+
50+
// Supports the 0x0b fast read command with 8 dummy cycles.
51+
bool supports_fast_read : 1;
52+
53+
// Supports the fast read, quad output command 0x6b with 8 dummy cycles.
54+
bool supports_qspi : 1;
55+
56+
// Supports the quad input page program command 0x32. This is known as 1-1-4 because it only
57+
// uses all four lines for data.
58+
bool supports_qspi_writes : 1;
59+
60+
// Requires a separate command 0x31 to write to the second byte of the status register.
61+
// Otherwise two byte are written via 0x01.
62+
bool write_status_register_split : 1;
63+
64+
// True when the status register is a single byte. This implies the Quad Enable bit is in the
65+
// first byte and the Read Status Register 2 command (0x35) is unsupported.
66+
bool single_status_byte : 1;
67+
68+
// Does not support using a ready bit within the status register
69+
bool no_ready_bit : 1;
70+
71+
// Does not support the erase command (0x20)
72+
bool no_erase_cmd : 1;
73+
74+
// Device does not have a reset command
75+
bool no_reset_cmd : 1;
76+
} external_flash_device;
77+
78+
#endif // MICROPY_INCLUDED_SUPERVISOR_SHARED_EXTERNAL_FLASH_DEVICE_H

supervisor/shared/external_flash/devices.h.jinja

Lines changed: 0 additions & 49 deletions
Original file line numberDiff line numberDiff line change
@@ -26,55 +26,6 @@
2626
#ifndef MICROPY_INCLUDED_SUPERVISOR_SHARED_EXTERNAL_FLASH_DEVICES_H
2727
#define MICROPY_INCLUDED_SUPERVISOR_SHARED_EXTERNAL_FLASH_DEVICES_H
2828

29-
#include <stdbool.h>
30-
#include <stdint.h>
31-
32-
typedef struct {
33-
uint32_t total_size;
34-
uint16_t start_up_time_us;
35-
36-
// Three response bytes to 0x9f JEDEC ID command.
37-
uint8_t manufacturer_id;
38-
uint8_t memory_type;
39-
uint8_t capacity;
40-
41-
// Max clock speed for all operations and the fastest read mode.
42-
uint8_t max_clock_speed_mhz;
43-
44-
// Bitmask for Quad Enable bit if present. 0x00 otherwise. This is for the highest byte in the
45-
// status register.
46-
uint8_t quad_enable_bit_mask;
47-
48-
bool has_sector_protection : 1;
49-
50-
// Supports the 0x0b fast read command with 8 dummy cycles.
51-
bool supports_fast_read : 1;
52-
53-
// Supports the fast read, quad output command 0x6b with 8 dummy cycles.
54-
bool supports_qspi : 1;
55-
56-
// Supports the quad input page program command 0x32. This is known as 1-1-4 because it only
57-
// uses all four lines for data.
58-
bool supports_qspi_writes : 1;
59-
60-
// Requires a separate command 0x31 to write to the second byte of the status register.
61-
// Otherwise two byte are written via 0x01.
62-
bool write_status_register_split : 1;
63-
64-
// True when the status register is a single byte. This implies the Quad Enable bit is in the
65-
// first byte and the Read Status Register 2 command (0x35) is unsupported.
66-
bool single_status_byte : 1;
67-
68-
// Does not support using a ready bit within the status register
69-
bool no_ready_bit : 1;
70-
71-
// Does not support the erase command (0x20)
72-
bool no_erase_cmd : 1;
73-
74-
// Device does not have a reset command
75-
bool no_reset_cmd : 1;
76-
} external_flash_device;
77-
7829
{% for device in nvms %}
7930
#define {{ device.sku }} { \
8031
.total_size = {{ device.total_size }}, \

supervisor/shared/external_flash/external_flash.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@
2727

2828
#include <stdint.h>
2929
#include <string.h>
30+
#include "genhdr/devices.h"
3031
#include "supervisor/flash.h"
3132
#include "supervisor/spi_flash_api.h"
3233
#include "supervisor/shared/external_flash/common_commands.h"

supervisor/spi_flash_api.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@
2929
#include <stdbool.h>
3030
#include <stdint.h>
3131

32-
#include "genhdr/devices.h"
32+
#include "shared/external_flash/device.h"
3333

3434
#include "shared-bindings/busio/SPI.h"
3535

supervisor/supervisor.mk

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,6 @@ $(HEADER_BUILD)/devices.h : ../../supervisor/shared/external_flash/devices.h.jin
5454
$(Q)install -d $(BUILD)/genhdr
5555
$(Q)$(PYTHON3) ../../tools/gen_nvm_devices.py $< $@
5656

57-
$(BUILD)/supervisor/shared/external_flash/spi_flash.o: $(HEADER_BUILD)/devices.h
5857
$(BUILD)/supervisor/shared/external_flash/external_flash.o: $(HEADER_BUILD)/devices.h
5958

6059
endif

0 commit comments

Comments
 (0)