Skip to content

Commit a26449f

Browse files
committed
code style fix
replace tab with 4 spaces; remove "#ifndef CONFIG_MBED_ENABLED" code; make if else pretty; add comment to PinNames.h;
1 parent 2bbc1f2 commit a26449f

File tree

16 files changed

+163
-1242
lines changed

16 files changed

+163
-1242
lines changed

targets/TARGET_Realtek/TARGET_AMEBA/RTWInterface.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -41,9 +41,9 @@ static rtw_result_t scan_result_handler( rtw_scan_handler_result_t* malloced_sca
4141
wifi_scan_hdl *scan_handler = (wifi_scan_hdl *)malloced_scan_result->user_data;
4242
if (malloced_scan_result->scan_complete != RTW_TRUE) {
4343
if(scan_handler->ap_details && scan_handler->scan_num > scan_handler->ap_num){
44-
nsapi_wifi_ap_t ap;
44+
nsapi_wifi_ap_t ap;
4545
rtw_scan_result_t* record = &malloced_scan_result->ap_details;
46-
record->SSID.val[record->SSID.len] = 0; /* Ensure the SSID is null terminated */
46+
record->SSID.val[record->SSID.len] = 0; /* Ensure the SSID is null terminated */
4747
memset((void*)&ap, 0x00, sizeof(nsapi_wifi_ap_t));
4848
memcpy(ap.ssid, record->SSID.val, record->SSID.len);
4949
memcpy(ap.bssid, record->BSSID.octet, 6);
@@ -156,7 +156,7 @@ nsapi_error_t RTWInterface::connect()
156156
break;
157157
case NSAPI_SECURITY_NONE:
158158
sec = RTW_SECURITY_OPEN;
159-
break;
159+
break;
160160
default:
161161
return NSAPI_ERROR_PARAMETER;
162162
}
@@ -230,7 +230,7 @@ nsapi_error_t RTWInterface::disconnect()
230230
wlan_emac_link_change(false);
231231
if(wifi_is_connected_to_ap() != RTW_SUCCESS)
232232
return NSAPI_ERROR_NO_CONNECTION;
233-
if(wifi_disconnect()<0){
233+
if(wifi_disconnect()<0){
234234
return NSAPI_ERROR_DEVICE_ERROR;
235235
}
236236
while(1){

targets/TARGET_Realtek/TARGET_AMEBA/TARGET_RTL8195A/PinNames.h

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -109,6 +109,7 @@ typedef enum {
109109
PF_3 = (PORT_F<<4|3),
110110
PF_4 = (PORT_F<<4|4),
111111
PF_5 = (PORT_F<<4|5),
112+
/* unavailable pins */
112113
// PF_6 = (PORT_F<<4|6),
113114
// PF_7 = (PORT_F<<4|7),
114115

@@ -146,6 +147,7 @@ typedef enum {
146147
PJ_4 = (PORT_J<<4|4),
147148
PJ_5 = (PORT_J<<4|5),
148149
PJ_6 = (PORT_J<<4|6),
150+
/* unavailable pins */
149151
// PJ_7 = (PORT_J<<4|7),
150152

151153
PK_0 = (PORT_K<<4|0),
@@ -155,6 +157,7 @@ typedef enum {
155157
PK_4 = (PORT_K<<4|4),
156158
PK_5 = (PORT_K<<4|5),
157159
PK_6 = (PORT_K<<4|6),
160+
/* unavailable pins */
158161
// PK_7 = (PORT_K<<4|7),
159162

160163
AD_1 = (PORT_V<<4|1),
@@ -193,15 +196,15 @@ typedef enum {
193196

194197

195198
// Generic signals namings
196-
199+
/* LED1~4 are defined as alias of GPIO pins, they are not the LEDs on board*/
197200
LED1 = PB_4,
198201
LED2 = PB_5,
199202
LED3 = PB_6,
200203
LED4 = PB_7,
201204
SERIAL_TX = PA_7,
202205
SERIAL_RX = PA_6,
203-
USBTX = PB_0, //PA_7
204-
USBRX = PB_1, //PA_6
206+
USBTX = PB_0,
207+
USBRX = PB_1,
205208
I2C_SCL = PC_5,
206209
I2C_SDA = PC_4,
207210
SPI_MOSI = PC_2,

targets/TARGET_Realtek/TARGET_AMEBA/analogin_api.c

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -38,12 +38,12 @@ void analogin_init (analogin_t *obj, PinName pin){
3838

3939
HAL_ADC_INIT_DAT HalADCInitDataTmp;
4040
PHAL_ADC_INIT_DAT pHalADCInitDataTmp = &HalADCInitDataTmp;
41-
/* To backup user config first */
42-
41+
/* To backup user config first */
42+
4343
_memset(&(obj->HalADCInitData), 0, sizeof(HAL_ADC_INIT_DAT));
4444
_memcpy(pHalADCInitDataTmp, &(obj->HalADCInitData), sizeof(HAL_ADC_INIT_DAT));
45-
_memset(obj, 0x00, sizeof(analogin_t));
46-
45+
_memset(obj, 0x00, sizeof(analogin_t));
46+
4747
ConfigDebugErr &= (~(_DBG_ADC_|_DBG_GDMA_));
4848
ConfigDebugInfo&= (~(_DBG_ADC_|_DBG_GDMA_));
4949

@@ -114,12 +114,12 @@ void analogin_init (analogin_t *obj, PinName pin){
114114

115115
/* Load user setting */
116116
if ((pHalADCInitDataTmp->ADCEndian == ADC_DATA_ENDIAN_LITTLE) || (pHalADCInitDataTmp->ADCEndian == ADC_DATA_ENDIAN_BIG)) {
117-
DBG_8195A("K\n");
117+
DBG_8195A("K\n");
118118
pSalADCHND->pInitDat->ADCEndian = pHalADCInitDataTmp->ADCEndian;
119119
}
120120

121121
if ((pHalADCInitDataTmp->ADCAudioEn != ADC_FEATURE_DISABLED) && (pHalADCInitDataTmp->ADCAudioEn < 2)) {
122-
DBG_8195A("O\n");
122+
DBG_8195A("O\n");
123123
pSalADCHND->pInitDat->ADCAudioEn = pHalADCInitDataTmp->ADCAudioEn;
124124
}
125125

targets/TARGET_Realtek/TARGET_AMEBA/analogout_api.c

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@
2828

2929

3030
/** \brief analogout_init:\n
31-
* to initialize DAC
31+
* to initialize DAC
3232
*
3333
* This function is mainly to initialize a DAC channel.
3434
* \para dac_t *: obj
@@ -85,7 +85,7 @@ void analogout_init(dac_t *obj, PinName pin) {
8585
}
8686

8787
/** \brief analogout_free:\n
88-
* to free DAC
88+
* to free DAC
8989
*
9090
* This function is mainly to free a DAC channel.
9191
* \para dac_t *: obj
@@ -100,7 +100,7 @@ void analogout_free(dac_t *obj) {
100100
}
101101

102102
/** \brief analogout_write:\n
103-
* to execute analogout_write
103+
* to execute analogout_write
104104
*
105105
* This function is mainly to execute analog output and the value is a ratio.
106106
* The upper/lower bound of DAC register input value is defined by
@@ -139,7 +139,7 @@ void analogout_write(dac_t *obj, float value) {
139139
}
140140

141141
/** \brief analogout_write_u16:\n
142-
* to execute analogout_write_u16
142+
* to execute analogout_write_u16
143143
*
144144
* The register value of DAC input is a format of 2's complement.
145145
* The most maximum value of positive value drives DAC to output a voltage about 3.3V.
@@ -159,7 +159,7 @@ void analogout_write_u16(dac_t *obj, uint16_t value) {
159159
}
160160

161161
/** \brief analogout_read_u16:\n
162-
* to read back analog output value in float format
162+
* to read back analog output value in float format
163163
*
164164
* This function is NOT available in rtl8195a hardware design.
165165
* It always returns a fixed value of 0.0;
@@ -170,7 +170,7 @@ float analogout_read(dac_t *obj) {
170170
}
171171

172172
/** \brief analogout_read_u16:\n
173-
* to read back analog output register value
173+
* to read back analog output register value
174174
*
175175
* This function is NOT available in rtl8195a hardware design.
176176
* It always returns a fixed value of 0xFFFF;

targets/TARGET_Realtek/TARGET_AMEBA/flash_api.c

Lines changed: 37 additions & 48 deletions
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ static void flash_turnon();
4242
/**
4343
* global data structure
4444
*/
45-
//flash_t flash;
45+
//flash_t flash;
4646

4747
/**
4848
* @brief Control the flash chip write protect enable/disable
@@ -66,20 +66,19 @@ void flash_write_protect(flash_t *obj, uint32_t protect)
6666
*/
6767
void flash_init(flash_t *obj)
6868
{
69-
//SPIC_INIT_PARA spic_init_para;
69+
//SPIC_INIT_PARA spic_init_para;
7070

71-
// Init SPI Flash Controller
72-
// DBG_8195A("Initial Spi Flash Controller\n");
73-
//SPI_FLASH_PIN_FCTRL(ON);
71+
// Init SPI Flash Controller
72+
// DBG_8195A("Initial Spi Flash Controller\n");
73+
//SPI_FLASH_PIN_FCTRL(ON);
7474

75-
if (!SpicFlashInitRtl8195A(SpicOneBitMode)){
75+
if (!SpicFlashInitRtl8195A(SpicOneBitMode)){
7676

77-
DBG_8195A("SPI Init Fail!!!!!!\n");
78-
HAL_WRITE32(SYSTEM_CTRL_BASE, REG_SYS_DSTBY_INFO3, HAL_READ32(SYSTEM_CTRL_BASE, REG_SYS_DSTBY_INFO3)|0xf);
79-
}
80-
else {
81-
isinit = 1;
82-
}
77+
DBG_8195A("SPI Init Fail!!!!!!\n");
78+
HAL_WRITE32(SYSTEM_CTRL_BASE, REG_SYS_DSTBY_INFO3, HAL_READ32(SYSTEM_CTRL_BASE, REG_SYS_DSTBY_INFO3)|0xf);
79+
} else {
80+
isinit = 1;
81+
}
8382
flashobj.SpicInitPara.flashtype = SpicInitParaAllClk[0][0].flashtype;
8483

8584
//DBG_8195A("Flash ID is = %x %x %x \n",SpicInitParaAllClk[0][0].id[0],SpicInitParaAllClk[0][0].id[1],SpicInitParaAllClk[0][0].id[2]);
@@ -128,17 +127,17 @@ void flash_erase_block(flash_t *obj, uint32_t address)
128127
*/
129128
int flash_read_word(flash_t *obj, uint32_t address, uint32_t * data)
130129
{
131-
130+
132131
flash_turnon();
133132
if(isinit == 0)
134133
flash_init(&flashobj);
135-
// Wait flash busy done (wip=0)
136-
SpicWaitWipDoneRefinedRtl8195A(flashobj.SpicInitPara);
134+
// Wait flash busy done (wip=0)
135+
SpicWaitWipDoneRefinedRtl8195A(flashobj.SpicInitPara);
137136

138-
* data = HAL_READ32(SPI_FLASH_BASE, address);
137+
* data = HAL_READ32(SPI_FLASH_BASE, address);
139138
SpicDisableRtl8195A();
140139

141-
return 1;
140+
return 1;
142141
}
143142

144143
/**
@@ -159,17 +158,16 @@ int flash_write_word(flash_t *obj, uint32_t address, uint32_t data)
159158

160159
flashtype = flashobj.SpicInitPara.flashtype;
161160

162-
//Write word
163-
HAL_WRITE32(SPI_FLASH_BASE, address, data);
161+
//Write word
162+
HAL_WRITE32(SPI_FLASH_BASE, address, data);
164163

165-
// Wait spic busy done
166-
SpicWaitBusyDoneRtl8195A();
167-
168-
// Wait flash busy done (wip=0)
164+
// Wait spic busy done
165+
SpicWaitBusyDoneRtl8195A();
166+
167+
// Wait flash busy done (wip=0)
169168
if(flashtype == FLASH_MICRON){
170169
SpicWaitOperationDoneRtl8195A(flashobj.SpicInitPara);
171-
}
172-
else
170+
} else
173171
SpicWaitWipDoneRefinedRtl8195A(flashobj.SpicInitPara);
174172

175173
SpicDisableRtl8195A();
@@ -199,7 +197,7 @@ int flash_stream_read(flash_t *obj, uint32_t address, uint32_t len, uint8_t * d
199197
flash_init(&flashobj);
200198

201199

202-
// Wait flash busy done (wip=0)
200+
// Wait flash busy done (wip=0)
203201
SpicWaitWipDoneRefinedRtl8195A(flashobj.SpicInitPara);
204202

205203
offset_to_align = address & 0x03;
@@ -232,8 +230,7 @@ int flash_stream_read(flash_t *obj, uint32_t address, uint32_t len, uint8_t * d
232230
address += 4;
233231
len -= 4;
234232
}
235-
}
236-
else {
233+
} else {
237234
while (len >= 4) {
238235
*((u32 *)pbuf) = HAL_READ32(SPI_FLASH_BASE, address);
239236
pbuf += 4;
@@ -301,8 +298,7 @@ int flash_stream_write(flash_t *obj, uint32_t address, uint32_t len, uint8_t *
301298
// Wait flash busy done (wip=0)
302299
if(flashtype == FLASH_MICRON){
303300
SpicWaitOperationDoneRtl8195A(flashobj.SpicInitPara);
304-
}
305-
else
301+
} else
306302
SpicWaitWipDoneRefinedRtl8195A(flashobj.SpicInitPara);
307303

308304

@@ -320,16 +316,14 @@ int flash_stream_write(flash_t *obj, uint32_t address, uint32_t len, uint8_t *
320316
// Wait flash busy done (wip=0)
321317
if(flashtype == FLASH_MICRON){
322318
SpicWaitOperationDoneRtl8195A(flashobj.SpicInitPara);
323-
}
324-
else
319+
} else
325320
SpicWaitWipDoneRefinedRtl8195A(flashobj.SpicInitPara);
326321

327322
pbuf += 4;
328323
address += 4;
329324
len -= 4;
330325
}
331-
}
332-
else {
326+
} else {
333327
while (len >= 4) {
334328
//Write word
335329
HAL_WRITE32(SPI_FLASH_BASE, address, (u32)*((u32 *)pbuf));
@@ -338,8 +332,7 @@ int flash_stream_write(flash_t *obj, uint32_t address, uint32_t len, uint8_t *
338332
// Wait flash busy done (wip=0)
339333
if(flashtype == FLASH_MICRON){
340334
SpicWaitOperationDoneRtl8195A(flashobj.SpicInitPara);
341-
}
342-
else
335+
} else
343336
SpicWaitWipDoneRefinedRtl8195A(flashobj.SpicInitPara);
344337

345338
pbuf += 4;
@@ -362,8 +355,7 @@ int flash_stream_write(flash_t *obj, uint32_t address, uint32_t len, uint8_t *
362355
// Wait flash busy done (wip=0)
363356
if(flashtype == FLASH_MICRON){
364357
SpicWaitOperationDoneRtl8195A(flashobj.SpicInitPara);
365-
}
366-
else
358+
} else
367359
SpicWaitWipDoneRefinedRtl8195A(flashobj.SpicInitPara);
368360

369361
}
@@ -406,10 +398,11 @@ int flash_burst_write(flash_t *obj, uint32_t address ,uint32_t Length, uint8_t *
406398
flashtype = flashobj.SpicInitPara.flashtype;
407399

408400
OccuSize = address & 0xFF;
409-
if((Length >= PageSize) ||((Length + OccuSize) >= PageSize))
401+
if((Length >= PageSize) ||((Length + OccuSize) >= PageSize)){
410402
ProgramSize = PageSize - OccuSize;
411-
else
403+
} else {
412404
ProgramSize = Length;
405+
}
413406

414407
flashobj.Length = Length;
415408
while(Length > 0){
@@ -420,25 +413,22 @@ int flash_burst_write(flash_t *obj, uint32_t address ,uint32_t Length, uint8_t *
420413
// Wait flash busy done (wip=0)
421414
if(flashtype == FLASH_MICRON){
422415
SpicWaitOperationDoneRtl8195A(flashobj.SpicInitPara);
423-
}
424-
else
416+
} else
425417
SpicWaitWipDoneRefinedRtl8195A(flashobj.SpicInitPara);
426418

427419
address += ProgramSize;
428420
data+= ProgramSize;
429421
Length -= ProgramSize;
430422
OccuSize = 0;
431-
}
432-
else{
423+
} else{
433424
while((flashobj.Length) >= PageSize){
434425
SpicUserProgramRtl8195A(data, flashobj.SpicInitPara, address, &(flashobj.Length));
435426
// Wait spic busy done
436427
SpicWaitBusyDoneRtl8195A();
437428
// Wait flash busy done (wip=0)
438429
if(flashtype == FLASH_MICRON){
439430
SpicWaitOperationDoneRtl8195A(flashobj.SpicInitPara);
440-
}
441-
else
431+
} else
442432
SpicWaitWipDoneRefinedRtl8195A(flashobj.SpicInitPara);
443433

444434
address += PageSize;
@@ -453,8 +443,7 @@ int flash_burst_write(flash_t *obj, uint32_t address ,uint32_t Length, uint8_t *
453443
// Wait flash busy done (wip=0)
454444
if(flashtype == FLASH_MICRON){
455445
SpicWaitOperationDoneRtl8195A(flashobj.SpicInitPara);
456-
}
457-
else
446+
} else
458447
SpicWaitWipDoneRefinedRtl8195A(flashobj.SpicInitPara);
459448

460449
break;

targets/TARGET_Realtek/TARGET_AMEBA/flash_api.h

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -28,18 +28,18 @@ typedef struct flash_s flash_t;
2828
/**
2929
* global data structure
3030
*/
31-
extern flash_t flash;
31+
extern flash_t flash;
3232

3333
enum {
3434
FLASH_COMPLETE = 0,
3535
FLASH_ERROR_2 = 1,
3636
};
3737

38-
//void flash_init (flash_t *obj);
39-
void flash_erase_sector (flash_t *obj, uint32_t address);
38+
//void flash_init (flash_t *obj);
39+
void flash_erase_sector (flash_t *obj, uint32_t address);
4040
void flash_erase_block(flash_t * obj, uint32_t address);
41-
int flash_read_word (flash_t *obj, uint32_t address, uint32_t * data);
42-
int flash_write_word (flash_t *obj, uint32_t address, uint32_t data);
41+
int flash_read_word (flash_t *obj, uint32_t address, uint32_t * data);
42+
int flash_write_word (flash_t *obj, uint32_t address, uint32_t data);
4343
int flash_stream_read (flash_t *obj, uint32_t address, uint32_t len, uint8_t * data);
4444
int flash_stream_write (flash_t *obj, uint32_t address, uint32_t len, uint8_t * data);
4545
void flash_write_protect (flash_t *obj, uint32_t protect);

0 commit comments

Comments
 (0)