Mbed Cloud example program for workshop in W27 2018.

Dependencies:   MMA7660 LM75B

Embed: (wiki syntax)

« Back to documentation index

Show/hide line numbers arm_uc_pal_flashiap_mbed.cpp Source File

arm_uc_pal_flashiap_mbed.cpp

00001 // ----------------------------------------------------------------------------
00002 // Copyright 2016-2017 ARM Ltd.
00003 //
00004 // SPDX-License-Identifier: Apache-2.0
00005 //
00006 // Licensed under the Apache License, Version 2.0 (the "License");
00007 // you may not use this file except in compliance with the License.
00008 // You may obtain a copy of the License at
00009 //
00010 //     http://www.apache.org/licenses/LICENSE-2.0
00011 //
00012 // Unless required by applicable law or agreed to in writing, software
00013 // distributed under the License is distributed on an "AS IS" BASIS,
00014 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
00015 // See the License for the specific language governing permissions and
00016 // limitations under the License.
00017 // ----------------------------------------------------------------------------
00018 
00019 #if defined(TARGET_LIKE_MBED)
00020 
00021 #include "update-client-pal-flashiap/arm_uc_pal_flashiap_platform.h"
00022 #include "mbed.h"
00023 
00024 static FlashIAP flash;
00025 
00026 int32_t arm_uc_flashiap_init()
00027 {
00028     /* Workaround for https://github.com/ARMmbed/mbed-os/issues/4967
00029      * pal_init calls flash.init() before here. Second call to flash.init() will
00030      * return -1 error state. Hence we ignore the result of flash.init here.
00031      */
00032     flash.init();
00033     return 0;
00034 }
00035 
00036 int32_t arm_uc_flashiap_erase(uint32_t address, uint32_t size)
00037 {
00038     return flash.erase(address, size);
00039 }
00040 
00041 int32_t arm_uc_flashiap_program(const uint8_t* buffer, uint32_t address, uint32_t size)
00042 {
00043     return flash.program(buffer, address, size);
00044 }
00045 
00046 int32_t arm_uc_flashiap_read(uint8_t* buffer, uint32_t address, uint32_t size)
00047 {
00048     return flash.read(buffer, address, size);
00049 }
00050 
00051 uint32_t arm_uc_flashiap_get_page_size(void)
00052 {
00053     return flash.get_page_size();
00054 }
00055 
00056 uint32_t arm_uc_flashiap_get_sector_size(uint32_t address)
00057 {
00058     return flash.get_sector_size(address);
00059 }
00060 
00061 #endif