|
| 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 |
0 commit comments