]> begriffs open source - cmsis/blob - CMSIS/Driver/DriverTemplates/Driver_Flash.c
Merge branch 'develop' of https://github.com/ARM-software/CMSIS_5 into develop
[cmsis] / CMSIS / Driver / DriverTemplates / Driver_Flash.c
1 /*
2  * Copyright (c) 2013-2018 Arm Limited. All rights reserved.
3  *
4  * SPDX-License-Identifier: Apache-2.0
5  *
6  * Licensed under the Apache License, Version 2.0 (the License); you may
7  * not use this file except in compliance with the License.
8  * You may obtain a copy of the License at
9  *
10  * www.apache.org/licenses/LICENSE-2.0
11  *
12  * Unless required by applicable law or agreed to in writing, software
13  * distributed under the License is distributed on an AS IS BASIS, WITHOUT
14  * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15  * See the License for the specific language governing permissions and
16  * limitations under the License.
17  */
18  
19 #include "Driver_Flash.h"
20
21 #define ARM_FLASH_DRV_VERSION    ARM_DRIVER_VERSION_MAJOR_MINOR(1, 0) /* driver version */
22
23 /* Sector Information */
24 #ifdef FLASH_SECTORS
25 static ARM_FLASH_SECTOR FLASH_SECTOR_INFO[FLASH_SECTOR_COUNT] = {
26     FLASH_SECTORS
27 };
28 #else
29 #define FLASH_SECTOR_INFO    NULL
30 #endif
31
32 /* Flash Information */
33 static ARM_FLASH_INFO FlashInfo = {
34     0, /* FLASH_SECTOR_INFO  */
35     0, /* FLASH_SECTOR_COUNT */
36     0, /* FLASH_SECTOR_SIZE  */
37     0, /* FLASH_PAGE_SIZE    */
38     0, /* FLASH_PROGRAM_UNIT */
39     0  /* FLASH_ERASED_VALUE */
40 };
41
42 /* Flash Status */
43 static ARM_FLASH_STATUS FlashStatus;
44
45 /* Driver Version */
46 static const ARM_DRIVER_VERSION DriverVersion = {
47     ARM_FLASH_API_VERSION,
48     ARM_FLASH_DRV_VERSION
49 };
50
51 /* Driver Capabilities */
52 static const ARM_FLASH_CAPABILITIES DriverCapabilities = {
53     0, /* event_ready */
54     0, /* data_width = 0:8-bit, 1:16-bit, 2:32-bit */
55     0  /* erase_chip */
56 };
57
58 //
59 // Functions
60 //
61
62 ARM_DRIVER_VERSION ARM_Flash_GetVersion(void)
63 {
64 }
65
66 ARM_FLASH_CAPABILITIES ARM_Flash_GetCapabilities(void)
67 {
68 }
69
70 int32_t ARM_Flash_Initialize(ARM_Flash_SignalEvent_t cb_event)
71 {
72 }
73
74 int32_t ARM_Flash_Uninitialize(void)
75 {
76 }
77
78 int32_t ARM_Flash_PowerControl(ARM_POWER_STATE state)
79 {
80     switch (state)
81     {
82     case ARM_POWER_OFF:
83         break;
84
85     case ARM_POWER_LOW:
86         break;
87
88     case ARM_POWER_FULL:
89         break;
90
91     default:
92         return ARM_DRIVER_ERROR_UNSUPPORTED;
93     }
94 }
95
96 int32_t ARM_Flash_ReadData(uint32_t addr, void *data, uint32_t cnt)
97 {
98 }
99
100 int32_t ARM_Flash_ProgramData(uint32_t addr, const void *data, uint32_t cnt)
101 {
102 }
103
104 int32_t ARM_Flash_EraseSector(uint32_t addr)
105 {
106 }
107
108 int32_t ARM_Flash_EraseChip(void)
109 {
110 }
111
112 ARM_FLASH_STATUS ARM_Flash_GetStatus(void)
113 {
114 }
115
116 ARM_FLASH_INFO * ARM_Flash_GetInfo(void)
117 {
118 }
119
120 void ARM_Flash_SignalEvent(uint32_t event)
121 {
122 }
123 // End Flash Interface
124
125 ARM_DRIVER_FLASH Driver_Flash0 = {
126     ARM_Flash_GetVersion,
127     ARM_Flash_GetCapabilities,
128     ARM_Flash_Initialize,
129     ARM_Flash_Uninitialize,
130     ARM_Flash_PowerControl,
131     ARM_Flash_ReadData,
132     ARM_Flash_ProgramData,
133     ARM_Flash_EraseSector,
134     ARM_Flash_EraseChip,
135     ARM_Flash_GetStatus,
136     ARM_Flash_GetInfo
137 };