Skip to content

Commit ff9ce88

Browse files
committed
Clean up code
- Remove useless comments - Apply Astyle Signed-off-by: Frederic Pillon <frederic.pillon@st.com>
1 parent b938d48 commit ff9ce88

File tree

5 files changed

+1779
-2060
lines changed

5 files changed

+1779
-2060
lines changed

src/MX25R6435F.cpp

Lines changed: 36 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -9,29 +9,13 @@
99
******************************************************************************
1010
* @attention
1111
*
12-
* <h2><center>&copy; COPYRIGHT(c) 2017 STMicroelectronics</center></h2>
12+
* <h2><center>&copy; Copyright (c) 2020 STMicroelectronics.
13+
* All rights reserved.</center></h2>
1314
*
14-
* Redistribution and use in source and binary forms, with or without modification,
15-
* are permitted provided that the following conditions are met:
16-
* 1. Redistributions of source code must retain the above copyright notice,
17-
* this list of conditions and the following disclaimer.
18-
* 2. Redistributions in binary form must reproduce the above copyright notice,
19-
* this list of conditions and the following disclaimer in the documentation
20-
* and/or other materials provided with the distribution.
21-
* 3. Neither the name of STMicroelectronics nor the names of its contributors
22-
* may be used to endorse or promote products derived from this software
23-
* without specific prior written permission.
24-
*
25-
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
26-
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
27-
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
28-
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
29-
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
30-
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
31-
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
32-
* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
33-
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
34-
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
15+
* This software component is licensed by ST under BSD 3-Clause license,
16+
* the "License"; You may not use this file except in compliance with the
17+
* License. You may obtain a copy of the License at:
18+
* opensource.org/licenses/BSD-3-Clause
3519
*
3620
******************************************************************************
3721
*/
@@ -55,6 +39,7 @@ void MX25R6435FClass::begin(uint8_t data0, uint8_t data1, uint8_t data2, uint8_t
5539

5640
if (BSP_QSPI_Init(&_qspi) == MEMORY_OK) {
5741
initDone = 1;
42+
}
5843
}
5944

6045
void MX25R6435FClass::end(void)
@@ -70,11 +55,13 @@ uint32_t MX25R6435FClass::write(uint8_t data, uint32_t addr)
7055

7156
uint32_t MX25R6435FClass::write(uint8_t *pData, uint32_t addr, uint32_t size)
7257
{
73-
if((pData == NULL) || (initDone == 0))
58+
if ((pData == NULL) || (initDone == 0)) {
7459
return 0;
60+
}
7561

76-
if(BSP_QSPI_Write(&_qspi, pData, addr, size) != MEMORY_OK)
62+
if (BSP_QSPI_Write(&_qspi, pData, addr, size) != MEMORY_OK) {
7763
return 0;
64+
}
7865

7966
return size;
8067
}
@@ -90,70 +77,79 @@ uint8_t MX25R6435FClass::read(uint32_t addr)
9077

9178
void MX25R6435FClass::read(uint8_t *pData, uint32_t addr, uint32_t size)
9279
{
93-
if((pData != NULL) && (initDone == 1))
80+
if ((pData != NULL) && (initDone == 1)) {
9481
BSP_QSPI_Read(&_qspi, pData, addr, size);
82+
}
9583
}
9684

9785
uint8_t *MX25R6435FClass::mapped(void)
9886
{
99-
if(BSP_QSPI_EnableMemoryMappedMode(&_qspi) != MEMORY_OK)
87+
if (BSP_QSPI_EnableMemoryMappedMode(&_qspi) != MEMORY_OK) {
10088
return NULL;
89+
}
10190

10291
return (uint8_t *)MEMORY_MAPPED_ADDRESS;
10392
}
10493

10594
uint8_t MX25R6435FClass::erase(uint32_t addr)
10695
{
107-
if(initDone == 0)
96+
if (initDone == 0) {
10897
return MEMORY_ERROR;
98+
}
10999

110100
return BSP_QSPI_Erase_Block(&_qspi, addr);
111101
}
112102

113103
uint8_t MX25R6435FClass::eraseChip(void)
114104
{
115-
if(initDone == 0)
105+
if (initDone == 0) {
116106
return MEMORY_ERROR;
107+
}
117108

118109
return BSP_QSPI_Erase_Chip(&_qspi);
119110
}
120111

121112
uint8_t MX25R6435FClass::eraseSector(uint32_t sector)
122113
{
123-
if(initDone == 0)
114+
if (initDone == 0) {
124115
return MEMORY_ERROR;
116+
}
125117

126118
return BSP_QSPI_Erase_Sector(&_qspi, sector);
127119
}
128120

129121
uint8_t MX25R6435FClass::suspendErase(void)
130122
{
131-
if(initDone == 0)
123+
if (initDone == 0) {
132124
return MEMORY_ERROR;
125+
}
133126

134127
return BSP_QSPI_SuspendErase(&_qspi);
135128
}
136129

137130
uint8_t MX25R6435FClass::resumeErase(void)
138131
{
139-
if(initDone == 0)
132+
if (initDone == 0) {
140133
return MEMORY_ERROR;
134+
}
141135

142136
return BSP_QSPI_ResumeErase(&_qspi);
143137
}
144138

145139
uint8_t MX25R6435FClass::sleep(void)
146140
{
147-
if(initDone == 0)
141+
if (initDone == 0) {
148142
return MEMORY_ERROR;
143+
}
149144

150145
return BSP_QSPI_EnterDeepPowerDown(&_qspi);
151146
}
152147

153148
uint8_t MX25R6435FClass::wakeup(void)
154149
{
155-
if(initDone == 0)
150+
if (initDone == 0) {
156151
return MEMORY_ERROR;
152+
}
157153

158154
return BSP_QSPI_LeaveDeepPowerDown(&_qspi);
159155
}
@@ -170,30 +166,30 @@ uint32_t MX25R6435FClass::info(memory_info_t info)
170166

171167
BSP_QSPI_GetInfo(&pInfo);
172168

173-
switch(info){
169+
switch (info) {
174170
case MEMORY_SIZE:
175171
res = pInfo.FlashSize;
176-
break;
172+
break;
177173

178174
case MEMORY_SECTOR_SIZE:
179175
res = pInfo.EraseSectorSize;
180-
break;
176+
break;
181177

182178
case MEMORY_SECTOR_NUMBER:
183179
res = pInfo.EraseSectorsNumber;
184-
break;
180+
break;
185181

186182
case MEMORY_PAGE_SIZE:
187183
res = pInfo.ProgPageSize;
188-
break;
184+
break;
189185

190186
case MEMORY_PAGE_NUMBER:
191187
res = pInfo.ProgPagesNumber;
192-
break;
188+
break;
193189

194190
default:
195191
res = 0;
196-
break;
192+
break;
197193
}
198194

199195
return res;

src/MX25R6435F.h

Lines changed: 13 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -1,37 +1,18 @@
11
/**
22
******************************************************************************
33
* @file MX25R6435F.h
4-
* @author WI6LABS
5-
* @version V1.0.0
6-
* @date 19-July-2017
74
* @brief MX25R6435F library for STM32 Arduino
85
*
96
******************************************************************************
107
* @attention
118
*
12-
* <h2><center>&copy; COPYRIGHT(c) 2017 STMicroelectronics</center></h2>
9+
* <h2><center>&copy; Copyright (c) 2020 STMicroelectronics.
10+
* All rights reserved.</center></h2>
1311
*
14-
* Redistribution and use in source and binary forms, with or without modification,
15-
* are permitted provided that the following conditions are met:
16-
* 1. Redistributions of source code must retain the above copyright notice,
17-
* this list of conditions and the following disclaimer.
18-
* 2. Redistributions in binary form must reproduce the above copyright notice,
19-
* this list of conditions and the following disclaimer in the documentation
20-
* and/or other materials provided with the distribution.
21-
* 3. Neither the name of STMicroelectronics nor the names of its contributors
22-
* may be used to endorse or promote products derived from this software
23-
* without specific prior written permission.
24-
*
25-
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
26-
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
27-
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
28-
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
29-
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
30-
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
31-
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
32-
* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
33-
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
34-
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
12+
* This software component is licensed by ST under BSD 3-Clause license,
13+
* the "License"; You may not use this file except in compliance with the
14+
* License. You may obtain a copy of the License at:
15+
* opensource.org/licenses/BSD-3-Clause
3516
*
3617
******************************************************************************
3718
*/
@@ -43,22 +24,22 @@
4324
#include "mx25r6435f_driver.h"
4425

4526
#ifndef MX25R6435F_D0
46-
#define MX25R6435F_D0 NC
27+
#define MX25R6435F_D0 NC
4728
#endif
4829
#ifndef MX25R6435F_D1
49-
#define MX25R6435F_D1 NC
30+
#define MX25R6435F_D1 NC
5031
#endif
5132
#ifndef MX25R6435F_D2
52-
#define MX25R6435F_D2 NC
33+
#define MX25R6435F_D2 NC
5334
#endif
5435
#ifndef MX25R6435F_D3
55-
#define MX25R6435F_D3 NC
36+
#define MX25R6435F_D3 NC
5637
#endif
5738
#ifndef MX25R6435F_SCLK
58-
#define MX25R6435F_SCLK NC
39+
#define MX25R6435F_SCLK NC
5940
#endif
6041
#ifndef MX25R6435F_SSEL
61-
#define MX25R6435F_SSEL NC
42+
#define MX25R6435F_SSEL NC
6243
#endif
6344

6445
/* Memory configuration paremeters */
@@ -80,8 +61,7 @@ typedef enum {
8061
/* Base address of the memory in mapped mode */
8162
#define MEMORY_MAPPED_ADDRESS ((uint32_t)0x90000000)
8263

83-
class MX25R6435FClass
84-
{
64+
class MX25R6435FClass {
8565
public:
8666
MX25R6435FClass();
8767

0 commit comments

Comments
 (0)