/* * Copyright (c) 2013-2018 Arm Limited. All rights reserved. * * SPDX-License-Identifier: Apache-2.0 * * Licensed under the Apache License, Version 2.0 (the License); you may * not use this file except in compliance with the License. * You may obtain a copy of the License at * * www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an AS IS BASIS, WITHOUT * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * * ----------------------------------------------------------------------- * * $Date: 19. April 2018 * $Revision: V1.0 * * Driver: Driver_Flash# (default: Driver_Flash0) * Project: Flash Device Driver - Template * ----------------------------------------------------------------------- * Use the following configuration settings in the middleware component * to connect to this driver. * * Configuration Setting Value * --------------------- ----- * Connect to hardware via Driver_Flash# = n (default: 0) * -------------------------------------------------------------------- */ #include "Driver_Flash.h" #include "Flash_Template.h" #define ARM_FLASH_DRV_VERSION ARM_DRIVER_VERSION_MAJOR_MINOR(1,0) /* driver version */ #ifndef DRIVER_FLASH_NUM #define DRIVER_FLASH_NUM 0 /* Default driver number */ #endif /* Sector Information */ #ifdef FLASH_SECTORS static ARM_FLASH_SECTOR FLASH_SECTOR_INFO[FLASH_SECTOR_COUNT] = { FLASH_SECTORS }; #else #define FLASH_SECTOR_INFO NULL #endif /* Flash Information */ static ARM_FLASH_INFO FlashInfo = { FLASH_SECTOR_INFO, FLASH_SECTOR_COUNT, FLASH_SECTOR_SIZE, FLASH_PAGE_SIZE, FLASH_PROGRAM_UNIT, FLASH_ERASED_VALUE, #if (ARM_FLASH_API_VERSION > 0x201U) { 0U, 0U, 0U } #endif }; /* Flash Status */ static ARM_FLASH_STATUS FlashStatus; /* Driver Version */ static const ARM_DRIVER_VERSION DriverVersion = { ARM_FLASH_API_VERSION, ARM_FLASH_DRV_VERSION }; /* Driver Capabilities */ static const ARM_FLASH_CAPABILITIES DriverCapabilities = { 0, /* event_ready */ 0, /* data_width = 0:8-bit, 1:16-bit, 2:32-bit */ 0, /* erase_chip */ #if (ARM_FLASH_API_VERSION > 0x200U) 0U /* reserved */ #endif }; /** \fn ARM_DRIVER_VERSION ARM_Flash_GetVersion (void) \brief Get driver version. \return \ref ARM_DRIVER_VERSION */ static ARM_DRIVER_VERSION GetVersion (void) { return DriverVersion; } /** \fn ARM_FLASH_CAPABILITIES ARM_Flash_GetCapabilities (void) \brief Get driver capabilities. \return \ref ARM_FLASH_CAPABILITIES */ static ARM_FLASH_CAPABILITIES GetCapabilities (void) { return DriverCapabilities; } /** \fn int32_t ARM_Flash_Initialize (ARM_Flash_SignalEvent_t cb_event) \brief Initialize the Flash Interface. \param[in] cb_event Pointer to \ref ARM_Flash_SignalEvent \return \ref execution_status */ static int32_t Initialize (ARM_Flash_SignalEvent_t cb_event) { /* ... */ return ARM_DRIVER_OK; } /** \fn int32_t ARM_Flash_Uninitialize (void) \brief De-initialize the Flash Interface. \return \ref execution_status */ static int32_t Uninitialize (void) { /* ... */ return ARM_DRIVER_OK; } /** \fn int32_t ARM_Flash_PowerControl (ARM_POWER_STATE state) \brief Control the Flash interface power. \param[in] state Power state \return \ref execution_status */ static int32_t PowerControl (ARM_POWER_STATE state) { /* ... */ return ARM_DRIVER_OK; } /** \fn int32_t ARM_Flash_ReadData (uint32_t addr, void *data, uint32_t cnt) \brief Read data from Flash. \param[in] addr Data address. \param[out] data Pointer to a buffer storing the data read from Flash. \param[in] cnt Number of data items to read. \return number of data items read or \ref execution_status */ static int32_t ReadData (uint32_t addr, void *data, uint32_t cnt) { /* ... */ return 0; } /** \fn int32_t ARM_Flash_ProgramData (uint32_t addr, const void *data, uint32_t cnt) \brief Program data to Flash. \param[in] addr Data address. \param[in] data Pointer to a buffer containing the data to be programmed to Flash. \param[in] cnt Number of data items to program. \return number of data items programmed or \ref execution_status */ static int32_t ProgramData (uint32_t addr, const void *data, uint32_t cnt) { /* ... */ return ARM_DRIVER_OK; } /** \fn int32_t ARM_Flash_EraseSector (uint32_t addr) \brief Erase Flash Sector. \param[in] addr Sector address \return \ref execution_status */ static int32_t EraseSector (uint32_t addr) { /* ... */ return ARM_DRIVER_OK; } /** \fn int32_t ARM_Flash_EraseChip (void) \brief Erase complete Flash. Optional function for faster full chip erase. \return \ref execution_status */ static int32_t EraseChip (void) { return ARM_DRIVER_ERROR_UNSUPPORTED; } /** \fn ARM_FLASH_STATUS ARM_Flash_GetStatus (void) \brief Get Flash status. \return Flash status \ref ARM_FLASH_STATUS */ static ARM_FLASH_STATUS GetStatus (void) { return FlashStatus; } /** \fn ARM_FLASH_INFO * ARM_Flash_GetInfo (void) \brief Get Flash information. \return Pointer to Flash information \ref ARM_FLASH_INFO */ static ARM_FLASH_INFO * GetInfo (void) { return &FlashInfo; } /* Flash Driver Control Block */ extern ARM_DRIVER_FLASH ARM_Driver_Flash_(DRIVER_FLASH_NUM); ARM_DRIVER_FLASH ARM_Driver_Flash_(DRIVER_FLASH_NUM) = { GetVersion, GetCapabilities, Initialize, Uninitialize, PowerControl, ReadData, ProgramData, EraseSector, EraseChip, GetStatus, GetInfo };