Skip to content

Commit f67cf64

Browse files
author
Cruz Monrreal
authored
Merge pull request #4 from deepikabhavnani/add_license
Add license header and astyle changes
2 parents 3ddf49b + a37742f commit f67cf64

File tree

1 file changed

+25
-7
lines changed

1 file changed

+25
-7
lines changed

QSPI/main.cpp

Lines changed: 25 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,19 @@
1+
/*
2+
* Copyright (c) 2018 ARM Limited. All rights reserved.
3+
* SPDX-License-Identifier: Apache-2.0
4+
* Licensed under the Apache License, Version 2.0 (the License); you may
5+
* 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, WITHOUT
12+
* 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
#if !DEVICE_QSPI
218
#error [NOT_SUPPORTED] QSPI not supported for this target
319
#endif
@@ -32,7 +48,7 @@ static bool mem_ready()
3248
printf("Reading Status Register failed \n");
3349
}
3450
wait_ms(1);
35-
} while ( (status_value[0] & BIT_WIP) != 0 && retries);
51+
} while ((status_value[0] & BIT_WIP) != 0 && retries);
3652

3753
if ((status_value[0] & BIT_WIP) != 0) {
3854
printf ("mem_ready FALSE: status value = 0x%x\n", (int)status_value[0]);
@@ -51,7 +67,7 @@ static int write_enable()
5167
return status;
5268
}
5369

54-
if ( false == mem_ready()) {
70+
if (false == mem_ready()) {
5571
printf("Device not ready \n");
5672
return status;
5773
}
@@ -88,7 +104,7 @@ static int flash_init()
88104
return status;
89105
}
90106

91-
if ( false == mem_ready()) {
107+
if (false == mem_ready()) {
92108
printf("Device not ready \n");
93109
return -1;
94110
}
@@ -102,7 +118,7 @@ static int flash_init()
102118
return status;
103119
}
104120

105-
if ( false == mem_ready()) {
121+
if (false == mem_ready()) {
106122
printf("Device not ready \n");
107123
return -1;
108124
}
@@ -116,13 +132,13 @@ static int sector_erase(unsigned int flash_addr)
116132
return -1;
117133
}
118134

119-
if( QSPI_STATUS_OK!= qspi_device.command_transfer(CMD_ERASE, (((int)flash_addr) & 0x00FFF000), NULL, 0, NULL, 0))
135+
if (QSPI_STATUS_OK!= qspi_device.command_transfer(CMD_ERASE, (((int)flash_addr) & 0x00FFF000), NULL, 0, NULL, 0))
120136
{
121137
printf("Erase failed\n");
122138
return -1;
123139
}
124140

125-
if ( false == mem_ready()) {
141+
if (false == mem_ready()) {
126142
printf("Device not ready \n");
127143
return -1;
128144
}
@@ -157,14 +173,15 @@ int main() {
157173
printf("Write Enabe failed \n");
158174
return -1;
159175
}
176+
160177
result = qspi_device.write(CMD_WRITE, -1, address, tx_buf, &buf_len);
161178
if (result != QSPI_STATUS_OK) {
162179
printf("Write failed\n");
163180
return result;
164181
}
165182
printf("Write done: %s \n", tx_buf);
166183

167-
if ( false == mem_ready()) {
184+
if (false == mem_ready()) {
168185
printf("Device not ready \n");
169186
return -1;
170187
}
@@ -174,6 +191,7 @@ int main() {
174191
printf("Read failed\n");
175192
return result;
176193
}
194+
177195
printf ("Data Read = %s\n", rx_buf);
178196
return 0;
179197
}

0 commit comments

Comments
 (0)