The official Mbed 2 C/C++ SDK provides the software platform and libraries to build your applications.

Dependents:   hello SerialTestv11 SerialTestv12 Sierpinski ... more

mbed 2

This is the mbed 2 library. If you'd like to learn about Mbed OS please see the mbed-os docs.

Committer:
AnnaBridge
Date:
Wed Feb 20 20:53:29 2019 +0000
Revision:
172:65be27845400
Parent:
170:e95d10626187
mbed library release version 165

Who changed what in which revision?

UserRevisionLine numberNew contents of line
<> 138:093f2bd7b9eb 1 /* mbed Microcontroller Library
<> 138:093f2bd7b9eb 2 * Copyright (c) 2017 ARM Limited
AnnaBridge 172:65be27845400 3 * SPDX-License-Identifier: Apache-2.0
<> 138:093f2bd7b9eb 4 *
<> 138:093f2bd7b9eb 5 * Licensed under the Apache License, Version 2.0 (the "License");
<> 138:093f2bd7b9eb 6 * you may not use this file except in compliance with the License.
<> 138:093f2bd7b9eb 7 * You may obtain a copy of the License at
<> 138:093f2bd7b9eb 8 *
<> 138:093f2bd7b9eb 9 * http://www.apache.org/licenses/LICENSE-2.0
<> 138:093f2bd7b9eb 10 *
<> 138:093f2bd7b9eb 11 * Unless required by applicable law or agreed to in writing, software
<> 138:093f2bd7b9eb 12 * distributed under the License is distributed on an "AS IS" BASIS,
<> 138:093f2bd7b9eb 13 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
<> 138:093f2bd7b9eb 14 * See the License for the specific language governing permissions and
<> 138:093f2bd7b9eb 15 * limitations under the License.
<> 138:093f2bd7b9eb 16 */
<> 138:093f2bd7b9eb 17 #ifndef MBED_FLASH_DATA_H
<> 138:093f2bd7b9eb 18 #define MBED_FLASH_DATA_H
<> 138:093f2bd7b9eb 19
<> 138:093f2bd7b9eb 20 #include <stdint.h>
<> 138:093f2bd7b9eb 21
AnnaBridge 165:d1b4690b3f8b 22 /** Target flash algorithm structure
AnnaBridge 165:d1b4690b3f8b 23 */
<> 138:093f2bd7b9eb 24 typedef struct {
AnnaBridge 165:d1b4690b3f8b 25 const uint32_t init; /**< Init function address */
AnnaBridge 165:d1b4690b3f8b 26 const uint32_t uninit; /**< Uninit function address */
AnnaBridge 165:d1b4690b3f8b 27 const uint32_t erase_sector; /**< Erase sector function address */
AnnaBridge 165:d1b4690b3f8b 28 const uint32_t program_page; /**< Program page function address */
AnnaBridge 165:d1b4690b3f8b 29 const uint32_t static_base; /**< Static base address */
AnnaBridge 165:d1b4690b3f8b 30 uint32_t *algo_blob; /**< Pointer to flash algo binary blob */
<> 138:093f2bd7b9eb 31 } flash_algo_t;
<> 138:093f2bd7b9eb 32
AnnaBridge 165:d1b4690b3f8b 33 /** Sector information structure
AnnaBridge 165:d1b4690b3f8b 34 */
<> 138:093f2bd7b9eb 35 typedef struct {
AnnaBridge 165:d1b4690b3f8b 36 const uint32_t start; /**< Sector start address */
AnnaBridge 165:d1b4690b3f8b 37 const uint32_t size; /**< Sector size */
<> 138:093f2bd7b9eb 38 } sector_info_t;
<> 138:093f2bd7b9eb 39
AnnaBridge 165:d1b4690b3f8b 40 /** Flash configuration structure
AnnaBridge 165:d1b4690b3f8b 41 */
<> 138:093f2bd7b9eb 42 typedef struct {
AnnaBridge 165:d1b4690b3f8b 43 const uint32_t page_size; /**< The minimum program page size that can be written */
AnnaBridge 165:d1b4690b3f8b 44 const uint32_t flash_start; /**< Start address of the flash <0, flash_size) */
AnnaBridge 165:d1b4690b3f8b 45 const uint32_t flash_size; /**< Flash size. The size is accumulative sum of all sector sizes */
AnnaBridge 165:d1b4690b3f8b 46 const sector_info_t *sectors; /**< List of sectors - sector can vary in sizes */
AnnaBridge 165:d1b4690b3f8b 47 const uint32_t sector_info_count; /**< Number of sectors */
<> 138:093f2bd7b9eb 48 } flash_target_config_t;
<> 138:093f2bd7b9eb 49
AnnaBridge 165:d1b4690b3f8b 50 /** Target flash configuration
Anna Bridge 169:a7c7b631e539 51 * For targets not supporting TrustZone, its flash_set_target_config must define target_config.
Anna Bridge 169:a7c7b631e539 52 * For targets supporting TrustZone, it has the following requirements:
Anna Bridge 169:a7c7b631e539 53 * -# Flash IAP H/W can only configure to secure. It can access both secure/non-secure flash.
Anna Bridge 169:a7c7b631e539 54 * -# Flash IAP port is for secure build only. It exports secure functions for non-secure build.
Anna Bridge 169:a7c7b631e539 55 * -# In Flash IAP port, flash_set_target_config must define both target_config/target_config_ns for secure/non-secure flash respectively.
Anna Bridge 169:a7c7b631e539 56 * -# Non-secure application can access its non-secure flash only through secure flash IAP functions. It cannot access secure flash.
AnnaBridge 165:d1b4690b3f8b 57 */
<> 138:093f2bd7b9eb 58 struct flash_s {
Anna Bridge 169:a7c7b631e539 59 const flash_target_config_t *target_config; /**< Normal/secure flash configuration structure for targets not supporting/supporting TrustZone */
Anna Bridge 169:a7c7b631e539 60 #if defined(__CORTEX_M23) || defined(__CORTEX_M33)
Anna Bridge 169:a7c7b631e539 61 const flash_target_config_t *target_config_ns; /**< Non-secure flash configuration structure for targets supporting TrustZone */
Anna Bridge 169:a7c7b631e539 62 #endif
<> 138:093f2bd7b9eb 63 const flash_algo_t *flash_algo;
<> 138:093f2bd7b9eb 64 };
<> 138:093f2bd7b9eb 65
AnnaBridge 165:d1b4690b3f8b 66 /** Flash algo argument structure
AnnaBridge 165:d1b4690b3f8b 67 * Contains all registers that should be preserved
AnnaBridge 165:d1b4690b3f8b 68 */
<> 138:093f2bd7b9eb 69 typedef struct {
<> 138:093f2bd7b9eb 70 uint32_t r0;
<> 138:093f2bd7b9eb 71 uint32_t r1;
<> 138:093f2bd7b9eb 72 uint32_t r2;
<> 138:093f2bd7b9eb 73 uint32_t r3;
<> 138:093f2bd7b9eb 74 uint32_t r9;
<> 138:093f2bd7b9eb 75 uint32_t pc;
<> 138:093f2bd7b9eb 76 } args_t;
<> 138:093f2bd7b9eb 77
AnnaBridge 170:e95d10626187 78 typedef int32_t (*flash_algo_jump_t)(args_t *);
<> 138:093f2bd7b9eb 79
<> 138:093f2bd7b9eb 80 // prototypes for flash algo CMSIS API
<> 138:093f2bd7b9eb 81
<> 138:093f2bd7b9eb 82 typedef int (*CMSIS_Algo_Function_Init)(unsigned long adr, unsigned long clk, unsigned long fnc);
<> 138:093f2bd7b9eb 83 typedef int (*CMSIS_Algo_Function_UnInit)(unsigned long fnc);
<> 138:093f2bd7b9eb 84 typedef int (*CMSIS_Algo_Function_EraseSector)(unsigned long adr);
<> 138:093f2bd7b9eb 85 typedef int (*CMSIS_Algo_Function_EraseChip)(void);
<> 138:093f2bd7b9eb 86 typedef int (*CMSIS_Algo_Function_ProgramPage)(unsigned long adr, unsigned long sz, unsigned char *buf);
<> 138:093f2bd7b9eb 87 typedef unsigned long (*CMSIS_Algo_Function_Verify)(unsigned long adr, unsigned long sz, unsigned char *buf);
<> 138:093f2bd7b9eb 88
<> 138:093f2bd7b9eb 89 #ifdef __cplusplus
<> 138:093f2bd7b9eb 90 extern "C" {
<> 138:093f2bd7b9eb 91 #endif
<> 138:093f2bd7b9eb 92
<> 138:093f2bd7b9eb 93 /* Set target configuration
<> 138:093f2bd7b9eb 94 */
<> 138:093f2bd7b9eb 95 void flash_set_target_config(flash_t *obj);
<> 138:093f2bd7b9eb 96
<> 138:093f2bd7b9eb 97 #ifdef __cplusplus
<> 138:093f2bd7b9eb 98 };
<> 138:093f2bd7b9eb 99 #endif
<> 138:093f2bd7b9eb 100
<> 138:093f2bd7b9eb 101
<> 138:093f2bd7b9eb 102 #endif