/***************************************************************************
* Project : shakti devt board
* Name of the file : spi.c
* Brief Description of file : Erase a sector of flash
* Name of Author : Sathya Narayanan
* Email ID : sathya281@gmail.com
Copyright (C) 2020 IIT Madras. All rights reserved.
This program 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 3 of the License, or
(at your option) any later version.
This program 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, see .
***************************************************************************/
/**
@file erase.c
@brief Erase a sector of on-board flash in arty 35t/100t
@detail Contains the code to erase a sector of on-board flash using spi
protocol.
*/
#include
#include "spi.h"
#include "uart.h"
/** @fn void main()
* @brief Configures the SPI flash and writes into a flash location.
* @details Configures the SPI flash, Confirms the flash device id,erases a sector
* and then write into a flash location and prints the value.
*/
void main()
{
configure_spi(SPI0_OFFSET);
spi_init();
printf("SPI init done\n");
flash_device_id();
waitfor(200);
flash_write_enable();
flash_erase(0x00b00000); //erases an entire sector
flash_status_register_read();
printf("\nErase complete");
asm volatile ("ebreak");
}