Initial commit

Dependencies:   FastPWM

Committer:
lypinator
Date:
Wed Sep 16 01:11:49 2020 +0000
Revision:
0:bb348c97df44
Added PWM

Who changed what in which revision?

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