Mbed Cloud example program for workshop in W27 2018.

Dependencies:   MMA7660 LM75B

Embed: (wiki syntax)

« Back to documentation index

Show/hide line numbers pal_internalFlash.h Source File

pal_internalFlash.h

00001 #ifndef PAL_FLASH_H
00002 #define PAL_FLASH_H
00003 
00004 #ifdef __cplusplus
00005 extern "C" {
00006 #endif
00007 
00008 /*! \brief This function initialized the flash API module,
00009  *          And should be called prior flash APIs calls
00010  *
00011  * \return   PAL_SUCCESS upon successful operation. \n
00012  *           PAL_FILE_SYSTEM_ERROR - see error code \c palError_t.
00013  *
00014  * \note should be called only once unless \c pal_internalFlashDeinit function is called
00015  * \note This function is Blocking till completion!!
00016  *
00017  */
00018 palStatus_t pal_internalFlashInit(void);
00019 
00020 /*! \brief This function destroy the flash module
00021  *
00022  * \return PAL_SUCCESS upon successful operation. \n
00023  *         PAL_ERR_INTERNAL_FLASH_ERROR - see error code \c palError_t.
00024  *
00025  * \note Should be called only after \c pal_internalFlashinit() is called.
00026  * \note Flash APIs will not work after calling this function
00027  * \note This function is Blocking till completion!!
00028  *
00029  */
00030 palStatus_t pal_internalFlashDeInit(void);
00031 
00032 /*! \brief This function writes to the internal flash
00033 *
00034 * @param[in]    buffer - pointer to the buffer to be written
00035 * @param[in]    size - the size of the buffer in bytes.
00036 * @param[in]    address - the address of the internal flash, must be aligned to minimum writing unit (page size).
00037 *
00038 * \return PAL_SUCCESS upon successful operation. \n
00039 *         PAL_ERR_INTERNAL_FLASH_ERROR - see error code \c palError_t.
00040 *
00041 * \note ALL address can be written to!! No protection to boot loader, program or other...
00042 * \note This function is Blocking till completion!!
00043 * \note This function is Thread Safe!!
00044 */
00045 palStatus_t pal_internalFlashWrite(const size_t size, const uint32_t address, const uint32_t * buffer);
00046 
00047 /*! \brief This function copies the memory data into the user given buffer
00048 *
00049 * @param[in]    size - the size of the buffer in bytes.
00050 * @param[in]    address - the address of the internal flash.
00051 * @param[out]   buffer - pointer to the buffer to write to
00052 *
00053 * \return PAL_SUCCESS upon successful operation. \n
00054 *         PAL_ERR_INTERNAL_FLASH_ERROR - see error code \c palError_t.
00055 * \note This function is Blocking till completion!!
00056 * \note This function is Thread Safe!!
00057 *
00058 */
00059 palStatus_t pal_internalFlashRead(const size_t size, const uint32_t address, uint32_t * buffer);
00060 
00061 /*! \brief This function Erase the sector
00062 *
00063 * @param[in]    size - the size to be erased
00064 * @param[in]    address - sector start address to be erased, must be align to sector.
00065 *
00066 * \return PAL_SUCCESS upon successful operation. \n
00067 *         PAL_ERR_INTERNAL_FLASH_ERROR - see error code \c palError_t.
00068 *
00069 * \note ALL sectors can be erased!! No protection to bootloader, program or other...
00070 * \note This function is Blocking till completion!!
00071 * \note Only one sector can be erased in each function call
00072 * \note This function is Thread Safe!!
00073 */
00074 palStatus_t pal_internalFlashErase(uint32_t address, size_t size);
00075 
00076 
00077 /*! \brief This function returns the minimum writing unit to the flash
00078 *
00079 * \return size_t the 2, 4, 8....
00080 */
00081 size_t pal_internalFlashGetPageSize(void);
00082 
00083 
00084 /*! \brief This function returns the sector size for the given address
00085  *
00086 * @param[in]    the starting address of the sector is question
00087 *
00088 * \return size of sector, 0 if error
00089 */
00090 size_t pal_internalFlashGetSectorSize(uint32_t address);
00091 
00092 
00093 ///////////////////////////////////////////////////////////////
00094 ////-------------------SOTP functions------------------------//
00095 ///////////////////////////////////////////////////////////////
00096 
00097 /*! \brief This function return the SOTP section data
00098 *
00099 * @param[in]    section - the section number (0 or 1)
00100 * @param[out]   data - the information about the section
00101 *
00102 * \return PAL_SUCCESS upon successful operation. \n
00103 *         PAL_ERR_INTERNAL_FLASH_ERROR - see error code \c palError_t.
00104 *
00105 */
00106 palStatus_t pal_internalFlashGetAreaInfo(bool section, palSotpAreaData_t * data);
00107 
00108 #ifdef __cplusplus
00109 }
00110 #endif
00111 #endif //PAL_FLASH_H