forked

Committer:
AnnaBridge
Date:
Thu Jul 06 15:42:05 2017 +0100
Revision:
168:9672193075cf
Parent:
167:e84263d55307
Child:
170:19eb464bc2be
This updates the lib to the mbed lib v 146

Who changed what in which revision?

UserRevisionLine numberNew contents of line
AnnaBridge 167:e84263d55307 1 /* mbed Microcontroller Library
AnnaBridge 167:e84263d55307 2 * Copyright (c) 2013-2016 Realtek Semiconductor Corp.
AnnaBridge 167:e84263d55307 3 *
AnnaBridge 167:e84263d55307 4 * Licensed under the Apache License, Version 2.0 (the "License");
AnnaBridge 167:e84263d55307 5 * you may not use this file except in compliance with the License.
AnnaBridge 167:e84263d55307 6 * You may obtain a copy of the License at
AnnaBridge 167:e84263d55307 7 *
AnnaBridge 167:e84263d55307 8 * http://www.apache.org/licenses/LICENSE-2.0
AnnaBridge 167:e84263d55307 9 *
AnnaBridge 167:e84263d55307 10 * Unless required by applicable law or agreed to in writing, software
AnnaBridge 167:e84263d55307 11 * distributed under the License is distributed on an "AS IS" BASIS,
AnnaBridge 167:e84263d55307 12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
AnnaBridge 167:e84263d55307 13 * See the License for the specific language governing permissions and
AnnaBridge 167:e84263d55307 14 * limitations under the License.
AnnaBridge 167:e84263d55307 15 */
AnnaBridge 168:9672193075cf 16 #include "flash_ext.h"
AnnaBridge 167:e84263d55307 17
AnnaBridge 168:9672193075cf 18 #define FLASH_START (SPI_FLASH_BASE + FLASH_OFS_START)
AnnaBridge 168:9672193075cf 19 #define FLASH_END (SPI_FLASH_BASE + FLASH_OFS_END)
AnnaBridge 168:9672193075cf 20 #define FLASH_OFS(addr) ((addr) - SPI_FLASH_BASE)
AnnaBridge 167:e84263d55307 21
AnnaBridge 168:9672193075cf 22 int32_t flash_init(flash_t *obj)
AnnaBridge 167:e84263d55307 23 {
AnnaBridge 168:9672193075cf 24 __flash_ext_turnon();
AnnaBridge 167:e84263d55307 25
AnnaBridge 168:9672193075cf 26 return 0;
AnnaBridge 167:e84263d55307 27 }
AnnaBridge 167:e84263d55307 28
AnnaBridge 168:9672193075cf 29 int32_t flash_free(flash_t *obj)
AnnaBridge 167:e84263d55307 30 {
AnnaBridge 168:9672193075cf 31 __flash_ext_turnoff();
AnnaBridge 167:e84263d55307 32
AnnaBridge 168:9672193075cf 33 return 0;
AnnaBridge 167:e84263d55307 34 }
AnnaBridge 167:e84263d55307 35
AnnaBridge 168:9672193075cf 36 int32_t flash_erase_sector(flash_t *obj, uint32_t address)
AnnaBridge 167:e84263d55307 37 {
AnnaBridge 168:9672193075cf 38 __flash_ext_erase_sector(obj, FLASH_OFS(address));
AnnaBridge 167:e84263d55307 39
AnnaBridge 168:9672193075cf 40 return 0;
AnnaBridge 167:e84263d55307 41 }
AnnaBridge 167:e84263d55307 42
AnnaBridge 168:9672193075cf 43 int32_t flash_program_page(flash_t *obj, uint32_t address, const uint8_t *data, uint32_t size)
AnnaBridge 167:e84263d55307 44 {
AnnaBridge 168:9672193075cf 45 return __flash_ext_stream_write(obj, FLASH_OFS(address), size, data);
AnnaBridge 168:9672193075cf 46 }
AnnaBridge 167:e84263d55307 47
AnnaBridge 168:9672193075cf 48 uint32_t flash_get_sector_size(const flash_t *obj, uint32_t address)
AnnaBridge 168:9672193075cf 49 {
AnnaBridge 168:9672193075cf 50 if (address < FLASH_START || address >= FLASH_END)
AnnaBridge 168:9672193075cf 51 return 0;
AnnaBridge 167:e84263d55307 52
AnnaBridge 168:9672193075cf 53 return FLASH_SECTOR_SIZE;
AnnaBridge 167:e84263d55307 54 }
AnnaBridge 167:e84263d55307 55
AnnaBridge 168:9672193075cf 56 uint32_t flash_get_page_size(const flash_t *obj)
AnnaBridge 167:e84263d55307 57 {
AnnaBridge 168:9672193075cf 58 return FLASH_PAGE_SIZE;
AnnaBridge 167:e84263d55307 59 }
AnnaBridge 167:e84263d55307 60
AnnaBridge 168:9672193075cf 61 uint32_t flash_get_start_address(const flash_t *obj)
AnnaBridge 167:e84263d55307 62 {
AnnaBridge 168:9672193075cf 63 return FLASH_START;
AnnaBridge 167:e84263d55307 64 }
AnnaBridge 167:e84263d55307 65
AnnaBridge 168:9672193075cf 66 uint32_t flash_get_size(const flash_t *obj)
AnnaBridge 167:e84263d55307 67 {
AnnaBridge 168:9672193075cf 68 return FLASH_SIZE;
AnnaBridge 167:e84263d55307 69 }
AnnaBridge 167:e84263d55307 70