mirror of
https://bitbucket.org/librepilot/librepilot.git
synced 2024-12-02 10:24:11 +01:00
a688b95eb6
git-svn-id: svn://svn.openpilot.org/OpenPilot/trunk@1235 ebee16cc-31ac-478f-84a7-5cbb03baadba
93 lines
3.6 KiB
C
93 lines
3.6 KiB
C
/******************** (C) COPYRIGHT 2010 STMicroelectronics ********************
|
|
* File Name : flash_if.c
|
|
* Author : MCD Application Team
|
|
* Version : V3.2.1
|
|
* Date : 07/05/2010
|
|
* Description : specific media access Layer for internal flash
|
|
********************************************************************************
|
|
* THE PRESENT FIRMWARE WHICH IS FOR GUIDANCE ONLY AIMS AT PROVIDING CUSTOMERS
|
|
* WITH CODING INFORMATION REGARDING THEIR PRODUCTS IN ORDER FOR THEM TO SAVE TIME.
|
|
* AS A RESULT, STMICROELECTRONICS SHALL NOT BE HELD LIABLE FOR ANY DIRECT,
|
|
* INDIRECT OR CONSEQUENTIAL DAMAGES WITH RESPECT TO ANY CLAIMS ARISING FROM THE
|
|
* CONTENT OF SUCH FIRMWARE AND/OR THE USE MADE BY CUSTOMERS OF THE CODING
|
|
* INFORMATION CONTAINED HEREIN IN CONNECTION WITH THEIR PRODUCTS.
|
|
*******************************************************************************/
|
|
|
|
/* Includes ------------------------------------------------------------------*/
|
|
#include "flash_if.h"
|
|
#include "dfu_mal.h"
|
|
|
|
/* Private typedef -----------------------------------------------------------*/
|
|
/* Private define ------------------------------------------------------------*/
|
|
/* Private macro -------------------------------------------------------------*/
|
|
/* Private variables ---------------------------------------------------------*/
|
|
/* Private function prototypes -----------------------------------------------*/
|
|
/* Private functions ---------------------------------------------------------*/
|
|
|
|
/*******************************************************************************
|
|
* Function Name : FLASH_If_Init
|
|
* Description : Initializes the Media on the STM32
|
|
* Input : None
|
|
* Output : None
|
|
* Return : None
|
|
*******************************************************************************/
|
|
uint16_t FLASH_If_Init(void)
|
|
{
|
|
return MAL_OK;
|
|
}
|
|
|
|
/*******************************************************************************
|
|
* Function Name : FLASH_If_Erase
|
|
* Description : Erase sector
|
|
* Input : None
|
|
* Output : None
|
|
* Return : None
|
|
*******************************************************************************/
|
|
uint16_t FLASH_If_Erase(uint32_t SectorAddress)
|
|
{
|
|
FLASH_ErasePage(SectorAddress);
|
|
return MAL_OK;
|
|
}
|
|
|
|
/*******************************************************************************
|
|
* Function Name : FLASH_If_Write
|
|
* Description : Write sectors
|
|
* Input : None
|
|
* Output : None
|
|
* Return : None
|
|
*******************************************************************************/
|
|
uint16_t FLASH_If_Write(uint32_t SectorAddress, uint32_t DataLength)
|
|
{
|
|
uint32_t idx = 0;
|
|
|
|
if (DataLength & 0x3) /* Not an aligned data */
|
|
{
|
|
for (idx = DataLength; idx < ((DataLength & 0xFFFC) + 4); idx++)
|
|
{
|
|
MAL_Buffer[idx] = 0xFF;
|
|
}
|
|
}
|
|
/* Data received are Word multiple */
|
|
|
|
for (idx = 0; idx < DataLength; idx = idx + 4)
|
|
{
|
|
FLASH_ProgramWord(SectorAddress, *(uint32_t *)(MAL_Buffer + idx));
|
|
SectorAddress += 4;
|
|
}
|
|
return MAL_OK;
|
|
}
|
|
|
|
/*******************************************************************************
|
|
* Function Name : FLASH_If_Read
|
|
* Description : Read sectors
|
|
* Input : None
|
|
* Output : None
|
|
* Return : buffer address pointer
|
|
*******************************************************************************/
|
|
uint8_t *FLASH_If_Read (uint32_t SectorAddress, uint32_t DataLength)
|
|
{
|
|
return (uint8_t*)(SectorAddress);
|
|
}
|
|
|
|
/******************* (C) COPYRIGHT 2010 STMicroelectronics *****END OF FILE****/
|