/* Motenpoche * * (c) 2023 Daniele Lacamera * * * Motenpoche is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * Motenpoche is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1335, USA * */ #ifndef FLASH_H #define FLASH_H #include "hardware/spi.h" #include "cryptoengine.h" #define SPI_FLASH_SECTOR_SIZE 0x1000 uint16_t flash_init(spi_inst_t *spi); int flash_sector_erase(uint32_t address); int flash_read(uint32_t address, void *data, int len); int flash_write(uint32_t address, const void *data, int len); int flash_write_svc(struct vault_service *svc, int idx); int flash_decrypt_read_sector(uint32_t sector, uint8_t *buf); int flash_encrypt_write_sector(uint32_t sector, uint8_t *buf); uint8_t flash_read_status(void); #endif