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:
Thu Nov 08 11:45:42 2018 +0000
Revision:
171:3a7713b1edbc
Parent:
170:e95d10626187
Child:
172:65be27845400
mbed library. Release version 164

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