Skip to content

Commit e76368c

Browse files
committed
Add license header, and fix coding style in flash_api.c
1 parent d83d608 commit e76368c

File tree

1 file changed

+36
-10
lines changed

1 file changed

+36
-10
lines changed

targets/TARGET_Atmel/TARGET_SAM_CortexM0P/flash_api.c

Lines changed: 36 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,19 @@
1+
/* mbed Microcontroller Library
2+
* Copyright (c) 2006-2019 ARM Limited
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* http://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/
16+
117
#include "flash_api.h"
218
#include "nvm.h"
319

@@ -6,7 +22,8 @@
622
* @param obj The flash object
723
* @return 0 for success, -1 for error
824
*/
9-
int32_t flash_init(flash_t *obj) {
25+
int32_t flash_init(flash_t *obj)
26+
{
1027
nvm_get_parameters(&obj->params);
1128

1229
const struct nvm_config config = {
@@ -29,7 +46,8 @@ int32_t flash_init(flash_t *obj) {
2946
* @param obj The flash object
3047
* @return 0 for success, -1 for error
3148
*/
32-
int32_t flash_free(flash_t *obj) {
49+
int32_t flash_free(flash_t *obj)
50+
{
3351
// no-op
3452
return 0;
3553
}
@@ -41,7 +59,8 @@ int32_t flash_free(flash_t *obj) {
4159
* @param address The sector starting address
4260
* @return 0 for success, -1 for error
4361
*/
44-
int32_t flash_erase_sector(flash_t *obj, uint32_t address) {
62+
int32_t flash_erase_sector(flash_t *obj, uint32_t address)
63+
{
4564
enum status_code status = nvm_erase_row(address);
4665

4766
return status == STATUS_OK ? 0 : -1;
@@ -56,7 +75,8 @@ int32_t flash_erase_sector(flash_t *obj, uint32_t address) {
5675
* @param size The number of bytes to read
5776
* @return 0 for success, -1 for error
5877
*/
59-
int32_t flash_read(flash_t *obj, uint32_t address, uint8_t *data, uint32_t size) {
78+
int32_t flash_read(flash_t *obj, uint32_t address, uint8_t *data, uint32_t size)
79+
{
6080
// apparently you can read / write multiple pages...
6181
uint32_t page_size = flash_get_page_size(obj);
6282
if (size % page_size != 0) return -1;
@@ -91,7 +111,8 @@ int32_t flash_read(flash_t *obj, uint32_t address, uint8_t *data, uint32_t size)
91111
* @param size The number of bytes to program
92112
* @return 0 for success, -1 for error
93113
*/
94-
int32_t flash_program_page(flash_t *obj, uint32_t address, const uint8_t *data, uint32_t size) {
114+
int32_t flash_program_page(flash_t *obj, uint32_t address, const uint8_t *data, uint32_t size)
115+
{
95116
// apparently you can read / write multiple pages...
96117
uint32_t page_size = flash_get_page_size(obj);
97118
if (size % page_size != 0) return -1;
@@ -122,7 +143,8 @@ int32_t flash_program_page(flash_t *obj, uint32_t address, const uint8_t *data,
122143
* @param address The sector starting address
123144
* @return The size of a sector
124145
*/
125-
uint32_t flash_get_sector_size(const flash_t *obj, uint32_t address) {
146+
uint32_t flash_get_sector_size(const flash_t *obj, uint32_t address)
147+
{
126148
if (address < flash_get_start_address(obj)) {
127149
return MBED_FLASH_INVALID_SIZE;
128150
}
@@ -140,7 +162,8 @@ uint32_t flash_get_sector_size(const flash_t *obj, uint32_t address) {
140162
* @param obj The flash object
141163
* @return The size of a page
142164
*/
143-
uint32_t flash_get_page_size(const flash_t *obj) {
165+
uint32_t flash_get_page_size(const flash_t *obj)
166+
{
144167
return obj->params.page_size;
145168
}
146169

@@ -149,7 +172,8 @@ uint32_t flash_get_page_size(const flash_t *obj) {
149172
* @param obj The flash object
150173
* @return The start address for the flash region
151174
*/
152-
uint32_t flash_get_start_address(const flash_t *obj) {
175+
uint32_t flash_get_start_address(const flash_t *obj)
176+
{
153177
return FLASH_ADDR;
154178
}
155179

@@ -158,7 +182,8 @@ uint32_t flash_get_start_address(const flash_t *obj) {
158182
* @param obj The flash object
159183
* @return The flash region size
160184
*/
161-
uint32_t flash_get_size(const flash_t *obj) {
185+
uint32_t flash_get_size(const flash_t *obj)
186+
{
162187
return FLASH_SIZE;
163188
}
164189

@@ -167,6 +192,7 @@ uint32_t flash_get_size(const flash_t *obj) {
167192
* @param obj The flash object
168193
* @return The flash erase value
169194
*/
170-
uint8_t flash_get_erase_value(const flash_t *obj) {
195+
uint8_t flash_get_erase_value(const flash_t *obj)
196+
{
171197
return 0xff;
172198
}

0 commit comments

Comments
 (0)