Skip to content

Commit d22d5d1

Browse files
ci(pre-commit): Apply automatic fixes
1 parent ef5a4cd commit d22d5d1

File tree

2 files changed

+31
-20
lines changed

2 files changed

+31
-20
lines changed

libraries/SD_MMC/examples/SD2USBMSC/SD2USBMSC.ino

Lines changed: 23 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -15,31 +15,39 @@ int d0 = 37;
1515
int d1 = 38;
1616
int d2 = 33;
1717
int d3 = 34;
18-
bool onebit = true; // set to false for 4-bit. 1-bit will ignore the d1-d3 pins (but d3 must be pulled high)
18+
bool onebit = true; // set to false for 4-bit. 1-bit will ignore the d1-d3 pins (but d3 must be pulled high)
1919

20-
static int32_t onWrite(uint32_t lba, uint32_t offset, uint8_t* buffer, uint32_t bufsize){
20+
static int32_t onWrite(uint32_t lba, uint32_t offset, uint8_t *buffer, uint32_t bufsize) {
2121
uint32_t secSize = SD_MMC.sectorSize();
22-
if (!secSize) return false; // disk error
22+
if (!secSize) {
23+
return false; // disk error
24+
}
2325
log_v("Write lba: %ld\toffset: %ld\tbufsize: %ld", lba, offset, bufsize);
24-
for (int x=0; x< bufsize/secSize; x++) {
26+
for (int x = 0; x < bufsize / secSize; x++) {
2527
uint8_t blkbuffer[secSize];
26-
memcpy(blkbuffer, (uint8_t*)buffer + secSize*x, secSize);
27-
if (!SD_MMC.writeRAW(blkbuffer, lba + x)) return false;
28+
memcpy(blkbuffer, (uint8_t *)buffer + secSize * x, secSize);
29+
if (!SD_MMC.writeRAW(blkbuffer, lba + x)) {
30+
return false;
31+
}
2832
}
2933
return bufsize;
3034
}
3135

32-
static int32_t onRead(uint32_t lba, uint32_t offset, void* buffer, uint32_t bufsize){
36+
static int32_t onRead(uint32_t lba, uint32_t offset, void *buffer, uint32_t bufsize) {
3337
uint32_t secSize = SD_MMC.sectorSize();
34-
if (!secSize) return false; // disk error
38+
if (!secSize) {
39+
return false; // disk error
40+
}
3541
log_v("Read lba: %ld\toffset: %ld\tbufsize: %ld\tsector: %lu", lba, offset, bufsize, secSize);
36-
for (int x=0; x < bufsize/secSize; x++) {
37-
if (!SD_MMC.readRAW((uint8_t*)buffer + (x * secSize), lba + x)) return false; // outside of volume boundary
42+
for (int x = 0; x < bufsize / secSize; x++) {
43+
if (!SD_MMC.readRAW((uint8_t *)buffer + (x * secSize), lba + x)) {
44+
return false; // outside of volume boundary
45+
}
3846
}
3947
return bufsize;
4048
}
4149

42-
static bool onStartStop(uint8_t power_condition, bool start, bool load_eject){
50+
static bool onStartStop(uint8_t power_condition, bool start, bool load_eject) {
4351
log_i("Start/Stop power: %u\tstart: %d\teject: %d", power_condition, start, load_eject);
4452
return true;
4553
}
@@ -58,13 +66,13 @@ static void usbEventCallback(void *arg, esp_event_base_t event_base, int32_t eve
5866
}
5967
}
6068

61-
void setup(){
69+
void setup() {
6270
Serial.begin(115200);
6371
Serial.println("Starting Serial");
6472

6573
Serial.println("Mounting SDcard");
6674
SD_MMC.setPins(clk, cmd, d0, d1, d2, d3);
67-
if(!SD_MMC.begin("/sdcard", onebit)){
75+
if (!SD_MMC.begin("/sdcard", onebit)) {
6876
Serial.println("Mount Failed");
6977
return;
7078
}
@@ -85,10 +93,10 @@ void setup(){
8593
USB.begin();
8694
USB.onEvent(usbEventCallback);
8795

88-
Serial.printf("Card Size: %lluMB\n", SD_MMC.totalBytes()/1024/1024);
96+
Serial.printf("Card Size: %lluMB\n", SD_MMC.totalBytes() / 1024 / 1024);
8997
Serial.printf("Sector: %d\tCount: %d\n", SD_MMC.sectorSize(), SD_MMC.numSectors());
9098
}
9199

92-
void loop(){
100+
void loop() {
93101
delay(-1);
94102
}

libraries/SD_MMC/src/SD_MMC.cpp

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -195,7 +195,6 @@ bool SDMMCFS::begin(const char *mountpoint, bool mode1bit, bool format_if_mount_
195195
_impl->mountpoint(mountpoint);
196196
_pdrv = ff_diskio_get_pdrv_card(_card);
197197

198-
199198
if (!perimanSetPinBus(_pin_cmd, ESP32_BUS_TYPE_SDMMC_CMD, (void *)(this), -1, -1)) {
200199
goto err;
201200
}
@@ -285,16 +284,20 @@ uint64_t SDMMCFS::usedBytes() {
285284
}
286285

287286
int SDMMCFS::sectorSize() {
288-
if (!_card) return 0;
287+
if (!_card) {
288+
return 0;
289+
}
289290
return _card->csd.sector_size;
290291
}
291292

292293
int SDMMCFS::numSectors() {
293-
if (!_card) return 0;
294-
return (totalBytes()/_card->csd.sector_size);
294+
if (!_card) {
295+
return 0;
296+
}
297+
return (totalBytes() / _card->csd.sector_size);
295298
}
296299

297-
bool SDMMCFS::readRAW(uint8_t* buffer, uint32_t sector) {
300+
bool SDMMCFS::readRAW(uint8_t *buffer, uint32_t sector) {
298301
return (disk_read(_pdrv, buffer, sector, 1) == 0);
299302
}
300303

0 commit comments

Comments
 (0)