openMMC
Open Source Modular MMC for AMCs
Loading...
Searching...
No Matches
flash_spi.h
Go to the documentation of this file.
1/*
2 * openMMC -- Open Source modular IPM Controller firmware
3 *
4 * Copyright (C) 2015-2016 Henrique Silva <henrique.silva@lnls.br>
5 *
6 * This program is free software: you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation, either version 3 of the License, or
9 * (at your option) any later version.
10 *
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
15 *
16 * You should have received a copy of the GNU General Public License
17 * along with this program. If not, see <http://www.gnu.org/licenses/>.
18 *
19 * @license GPL-3.0+ <http://spdx.org/licenses/GPL-3.0+>
20 */
21
22#ifndef FLASH_SPI_H_
23#define FLASH_SPI_H_
24
25#define FLASH_SPI_BITRATE 1000000
26#define FLASH_SPI_FRAME_SIZE 8
27
28/* M25P128 Flash commands */
29#define FLASH_WRITE_ENABLE 0x06
30#define FLASH_WRITE_DISABLE 0x04
31#define FLASH_READ_ID 0x9F
32#define FLASH_READ_STATUS_REG 0x05
33#define FLASH_WRITE_STATUS_REG 0x01
34#define FLASH_READ_LOCK_REG 0xE8
35#define FLASH_WRITE_LOCK_REG 0xE5
36#define FLASH_READ_DATA 0x03
37#define FLASH_FAST_READ_DATA 0x0B
38#define FLASH_PROGRAM_PAGE 0x02
39#define FLASH_SECTOR_ERASE 0xD8
40#define FLASH_BULK_ERASE 0xC7
41
42void flash_write_enable( void );
43void flash_write_disable( void );
44void flash_read_id( uint8_t * id_buffer, uint8_t buff_size );
45uint8_t flash_read_status_reg( void );
46void flash_write_status_reg( uint8_t data );
47uint8_t flash_read_data( uint32_t address );
48void flash_fast_read_data( uint32_t start_addr, uint8_t * dst, uint32_t size );
49void flash_program_page( uint32_t address, uint8_t * data, uint16_t size );
50void flash_sector_erase( uint32_t address );
51void flash_bulk_erase( void );
52uint8_t flash_read_lock_reg( uint32_t address );
53void flash_write_lock_reg( uint32_t address, uint8_t data );
54uint8_t is_flash_busy( void );
55
56#endif
void flash_write_enable(void)
Definition flash_spi.c:31
uint8_t flash_read_status_reg(void)
Definition flash_spi.c:63
void flash_sector_erase(uint32_t address)
Definition flash_spi.c:175
void flash_write_lock_reg(uint32_t address, uint8_t data)
Definition flash_spi.c:101
uint8_t flash_read_lock_reg(uint32_t address)
Definition flash_spi.c:84
void flash_write_disable(void)
Definition flash_spi.c:39
void flash_bulk_erase(void)
Definition flash_spi.c:189
void flash_program_page(uint32_t address, uint8_t *data, uint16_t size)
Definition flash_spi.c:155
void flash_read_id(uint8_t *id_buffer, uint8_t buff_size)
Definition flash_spi.c:47
void flash_fast_read_data(uint32_t start_addr, uint8_t *dst, uint32_t size)
Definition flash_spi.c:134
uint8_t is_flash_busy(void)
Definition flash_spi.c:198
uint8_t flash_read_data(uint32_t address)
Definition flash_spi.c:117
void flash_write_status_reg(uint8_t data)
Definition flash_spi.c:75