Toyomasa Watarai / simple-mbed-cloud-client

Dependents:  

Committer:
MACRUM
Date:
Mon Jul 02 06:30:39 2018 +0000
Revision:
0:276e7a263c35
Initial commit

Who changed what in which revision?

UserRevisionLine numberNew contents of line
MACRUM 0:276e7a263c35 1 /*******************************************************************************
MACRUM 0:276e7a263c35 2 * Copyright 2016, 2017 ARM Ltd.
MACRUM 0:276e7a263c35 3 *
MACRUM 0:276e7a263c35 4 * Licensed under the Apache License, Version 2.0 (the "License");
MACRUM 0:276e7a263c35 5 * you may not use this file except in compliance with the License.
MACRUM 0:276e7a263c35 6 * You may obtain a copy of the License at
MACRUM 0:276e7a263c35 7 *
MACRUM 0:276e7a263c35 8 * http://www.apache.org/licenses/LICENSE-2.0
MACRUM 0:276e7a263c35 9 *
MACRUM 0:276e7a263c35 10 * Unless required by applicable law or agreed to in writing, software
MACRUM 0:276e7a263c35 11 * distributed under the License is distributed on an "AS IS" BASIS,
MACRUM 0:276e7a263c35 12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
MACRUM 0:276e7a263c35 13 * See the License for the specific language governing permissions and
MACRUM 0:276e7a263c35 14 * limitations under the License.
MACRUM 0:276e7a263c35 15 *******************************************************************************/
MACRUM 0:276e7a263c35 16 #ifndef PAL_FLASH_H
MACRUM 0:276e7a263c35 17 #define PAL_FLASH_H
MACRUM 0:276e7a263c35 18
MACRUM 0:276e7a263c35 19 #ifdef __cplusplus
MACRUM 0:276e7a263c35 20 extern "C" {
MACRUM 0:276e7a263c35 21 #endif
MACRUM 0:276e7a263c35 22
MACRUM 0:276e7a263c35 23
MACRUM 0:276e7a263c35 24 #ifndef _PAL_H
MACRUM 0:276e7a263c35 25 #error "Please do not include this file directly, use pal.h instead"
MACRUM 0:276e7a263c35 26 #endif
MACRUM 0:276e7a263c35 27
MACRUM 0:276e7a263c35 28
MACRUM 0:276e7a263c35 29
MACRUM 0:276e7a263c35 30 #define PAL_INT_FLASH_BLANK_VAL 0xFF
MACRUM 0:276e7a263c35 31
MACRUM 0:276e7a263c35 32
MACRUM 0:276e7a263c35 33 /*! \brief This function initialized the flash API module,
MACRUM 0:276e7a263c35 34 * And should be called prior flash APIs calls
MACRUM 0:276e7a263c35 35 *
MACRUM 0:276e7a263c35 36 * \return PAL_SUCCESS upon successful operation. \n
MACRUM 0:276e7a263c35 37 * PAL_FILE_SYSTEM_ERROR - see error code \c palError_t.
MACRUM 0:276e7a263c35 38 *
MACRUM 0:276e7a263c35 39 * \note should be called only once unless \c pal_internalFlashDeinit function is called
MACRUM 0:276e7a263c35 40 * \note This function is Blocking till completion!!
MACRUM 0:276e7a263c35 41 *
MACRUM 0:276e7a263c35 42 */
MACRUM 0:276e7a263c35 43 palStatus_t pal_internalFlashInit(void);
MACRUM 0:276e7a263c35 44
MACRUM 0:276e7a263c35 45 /*! \brief This function destroy the flash module
MACRUM 0:276e7a263c35 46 *
MACRUM 0:276e7a263c35 47 * \return PAL_SUCCESS upon successful operation. \n
MACRUM 0:276e7a263c35 48 * PAL_ERR_INTERNAL_FLASH_ERROR - see error code \c palError_t.
MACRUM 0:276e7a263c35 49 *
MACRUM 0:276e7a263c35 50 * \note Should be called only after \c pal_internalFlashinit() is called.
MACRUM 0:276e7a263c35 51 * \note Flash APIs will not work after calling this function
MACRUM 0:276e7a263c35 52 * \note This function is Blocking till completion!!
MACRUM 0:276e7a263c35 53 *
MACRUM 0:276e7a263c35 54 */
MACRUM 0:276e7a263c35 55 palStatus_t pal_internalFlashDeInit(void);
MACRUM 0:276e7a263c35 56
MACRUM 0:276e7a263c35 57 /*! \brief This function writes to the internal flash
MACRUM 0:276e7a263c35 58 *
MACRUM 0:276e7a263c35 59 * @param[in] buffer - pointer to the buffer to be written
MACRUM 0:276e7a263c35 60 * @param[in] size - the size of the buffer in bytes.
MACRUM 0:276e7a263c35 61 * @param[in] address - the address of the internal flash, must be aligned to minimum writing unit (page size).
MACRUM 0:276e7a263c35 62 *
MACRUM 0:276e7a263c35 63 * \return PAL_SUCCESS upon successful operation. \n
MACRUM 0:276e7a263c35 64 * PAL_ERR_INTERNAL_FLASH_ERROR - see error code \c palError_t.
MACRUM 0:276e7a263c35 65 *
MACRUM 0:276e7a263c35 66 * \note ALL address can be written to!! No protection to boot loader, program or other...
MACRUM 0:276e7a263c35 67 * \note This function is Blocking till completion!!
MACRUM 0:276e7a263c35 68 * \note This function is Thread Safe!!
MACRUM 0:276e7a263c35 69 */
MACRUM 0:276e7a263c35 70 palStatus_t pal_internalFlashWrite(const size_t size, const uint32_t address, const uint32_t * buffer);
MACRUM 0:276e7a263c35 71
MACRUM 0:276e7a263c35 72 /*! \brief This function copies the memory data into the user given buffer
MACRUM 0:276e7a263c35 73 *
MACRUM 0:276e7a263c35 74 * @param[in] size - the size of the buffer in bytes.
MACRUM 0:276e7a263c35 75 * @param[in] address - the address of the internal flash.
MACRUM 0:276e7a263c35 76 * @param[out] buffer - pointer to the buffer to write to
MACRUM 0:276e7a263c35 77 *
MACRUM 0:276e7a263c35 78 * \return PAL_SUCCESS upon successful operation. \n
MACRUM 0:276e7a263c35 79 * PAL_ERR_INTERNAL_FLASH_ERROR - see error code \c palError_t.
MACRUM 0:276e7a263c35 80 * \note This function is Blocking till completion!!
MACRUM 0:276e7a263c35 81 * \note This function is Thread Safe!!
MACRUM 0:276e7a263c35 82 *
MACRUM 0:276e7a263c35 83 */
MACRUM 0:276e7a263c35 84 palStatus_t pal_internalFlashRead(const size_t size, const uint32_t address, uint32_t * buffer);
MACRUM 0:276e7a263c35 85
MACRUM 0:276e7a263c35 86 /*! \brief This function Erase the sector
MACRUM 0:276e7a263c35 87 *
MACRUM 0:276e7a263c35 88 * @param[in] size - the size to be erased
MACRUM 0:276e7a263c35 89 * @param[in] address - sector start address to be erased, must be align to sector.
MACRUM 0:276e7a263c35 90 *
MACRUM 0:276e7a263c35 91 * \return PAL_SUCCESS upon successful operation. \n
MACRUM 0:276e7a263c35 92 * PAL_ERR_INTERNAL_FLASH_ERROR - see error code \c palError_t.
MACRUM 0:276e7a263c35 93 *
MACRUM 0:276e7a263c35 94 * \note ALL sectors can be erased!! No protection to bootloader, program or other...
MACRUM 0:276e7a263c35 95 * \note This function is Blocking till completion!!
MACRUM 0:276e7a263c35 96 * \note Only one sector can be erased in each function call
MACRUM 0:276e7a263c35 97 * \note This function is Thread Safe!!
MACRUM 0:276e7a263c35 98 */
MACRUM 0:276e7a263c35 99 palStatus_t pal_internalFlashErase(uint32_t address, size_t size);
MACRUM 0:276e7a263c35 100
MACRUM 0:276e7a263c35 101
MACRUM 0:276e7a263c35 102 /*! \brief This function returns the minimum writing unit to the flash
MACRUM 0:276e7a263c35 103 *
MACRUM 0:276e7a263c35 104 * \return size_t the 2, 4, 8....
MACRUM 0:276e7a263c35 105 */
MACRUM 0:276e7a263c35 106 size_t pal_internalFlashGetPageSize(void);
MACRUM 0:276e7a263c35 107
MACRUM 0:276e7a263c35 108
MACRUM 0:276e7a263c35 109 /*! \brief This function returns the sector size for the given address
MACRUM 0:276e7a263c35 110 *
MACRUM 0:276e7a263c35 111 * @param[in] the starting address of the sector is question
MACRUM 0:276e7a263c35 112 *
MACRUM 0:276e7a263c35 113 * \return size of sector, 0 if error
MACRUM 0:276e7a263c35 114 */
MACRUM 0:276e7a263c35 115 size_t pal_internalFlashGetSectorSize(uint32_t address);
MACRUM 0:276e7a263c35 116
MACRUM 0:276e7a263c35 117
MACRUM 0:276e7a263c35 118 ///////////////////////////////////////////////////////////////
MACRUM 0:276e7a263c35 119 ////-------------------SOTP functions------------------------//
MACRUM 0:276e7a263c35 120 ///////////////////////////////////////////////////////////////
MACRUM 0:276e7a263c35 121
MACRUM 0:276e7a263c35 122 /*! \brief This function return the SOTP section data
MACRUM 0:276e7a263c35 123 *
MACRUM 0:276e7a263c35 124 * @param[in] section - the section number (0 or 1)
MACRUM 0:276e7a263c35 125 * @param[out] data - the information about the section
MACRUM 0:276e7a263c35 126 *
MACRUM 0:276e7a263c35 127 * \return PAL_SUCCESS upon successful operation. \n
MACRUM 0:276e7a263c35 128 * PAL_ERR_INTERNAL_FLASH_ERROR - see error code \c palError_t.
MACRUM 0:276e7a263c35 129 *
MACRUM 0:276e7a263c35 130 */
MACRUM 0:276e7a263c35 131 palStatus_t pal_internalFlashGetAreaInfo(uint8_t section, palSotpAreaData_t *data);
MACRUM 0:276e7a263c35 132
MACRUM 0:276e7a263c35 133 #ifdef __cplusplus
MACRUM 0:276e7a263c35 134 }
MACRUM 0:276e7a263c35 135 #endif
MACRUM 0:276e7a263c35 136 #endif //PAL_FLASH_H