Skip to content

Commit 3e69a26

Browse files
committed
clang
1 parent c9f8d31 commit 3e69a26

File tree

2 files changed

+48
-45
lines changed

2 files changed

+48
-45
lines changed

src/arduino/msc/Adafruit_USBH_MSC.cpp

Lines changed: 24 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
/*
1+
/*
22
* The MIT License (MIT)
33
*
44
* Copyright (c) 2022 Ha Thach (tinyusb.org) for Adafruit Industries
@@ -26,8 +26,8 @@
2626

2727
#if CFG_TUH_ENABLED && CFG_TUH_MSC
2828

29-
#include "tusb.h"
3029
#include "Adafruit_USBH_MSC.h"
30+
#include "tusb.h"
3131

3232
#if __has_include("SdFat.h")
3333

@@ -46,17 +46,11 @@ bool Adafruit_USBH_MSC_BlockDevice::setActiveLUN(uint8_t lun) {
4646
return true;
4747
}
4848

49-
void Adafruit_USBH_MSC_BlockDevice::end(void) {
50-
_daddr = _lun = 0;
51-
}
49+
void Adafruit_USBH_MSC_BlockDevice::end(void) { _daddr = _lun = 0; }
5250

53-
bool Adafruit_USBH_MSC_BlockDevice::mounted(void) {
54-
return _daddr > 0;
55-
}
51+
bool Adafruit_USBH_MSC_BlockDevice::mounted(void) { return _daddr > 0; }
5652

57-
bool Adafruit_USBH_MSC_BlockDevice::isBusy(void) {
58-
return _busy;
59-
}
53+
bool Adafruit_USBH_MSC_BlockDevice::isBusy(void) { return _busy; }
6054

6155
bool Adafruit_USBH_MSC_BlockDevice::wait_for_io(void) {
6256
while (_busy) {
@@ -66,7 +60,8 @@ bool Adafruit_USBH_MSC_BlockDevice::wait_for_io(void) {
6660
return true;
6761
}
6862

69-
bool Adafruit_USBH_MSC_BlockDevice::_io_complete_cb(uint8_t dev_addr, tuh_msc_complete_data_t const* cb_data) {
63+
bool Adafruit_USBH_MSC_BlockDevice::_io_complete_cb(
64+
uint8_t dev_addr, tuh_msc_complete_data_t const *cb_data) {
7065
if (dev_addr != _daddr) {
7166
// something wrong occurred, maybe device removed while transferring
7267
return false;
@@ -77,8 +72,10 @@ bool Adafruit_USBH_MSC_BlockDevice::_io_complete_cb(uint8_t dev_addr, tuh_msc_co
7772
return true;
7873
}
7974

80-
static bool _msc_io_complete_cb(uint8_t dev_addr, tuh_msc_complete_data_t const* cb_data) {
81-
Adafruit_USBH_MSC_BlockDevice* sdfat_dev = (Adafruit_USBH_MSC_BlockDevice*) cb_data->user_arg;
75+
static bool _msc_io_complete_cb(uint8_t dev_addr,
76+
tuh_msc_complete_data_t const *cb_data) {
77+
Adafruit_USBH_MSC_BlockDevice *sdfat_dev =
78+
(Adafruit_USBH_MSC_BlockDevice *)cb_data->user_arg;
8279
sdfat_dev->_io_complete_cb(dev_addr, cb_data);
8380
return true;
8481
}
@@ -92,23 +89,28 @@ bool Adafruit_USBH_MSC_BlockDevice::syncDevice(void) {
9289
return true;
9390
}
9491

95-
bool Adafruit_USBH_MSC_BlockDevice::readSectors(uint32_t block, uint8_t *dst, size_t ns) {
92+
bool Adafruit_USBH_MSC_BlockDevice::readSectors(uint32_t block, uint8_t *dst,
93+
size_t ns) {
9694
_busy = true;
97-
if( tuh_msc_read10(_daddr, _lun, dst, block, (uint16_t) ns, _msc_io_complete_cb, (uintptr_t) this) ) {
95+
if (tuh_msc_read10(_daddr, _lun, dst, block, (uint16_t)ns,
96+
_msc_io_complete_cb, (uintptr_t)this)) {
9897
wait_for_io();
9998
return true;
100-
}else {
99+
} else {
101100
_busy = false;
102101
return false;
103102
}
104103
}
105104

106-
bool Adafruit_USBH_MSC_BlockDevice::writeSectors(uint32_t block, const uint8_t *src, size_t ns) {
105+
bool Adafruit_USBH_MSC_BlockDevice::writeSectors(uint32_t block,
106+
const uint8_t *src,
107+
size_t ns) {
107108
_busy = true;
108-
if( tuh_msc_write10(_daddr, _lun, src, block, (uint16_t) ns, _msc_io_complete_cb, (uintptr_t) this) ) {
109+
if (tuh_msc_write10(_daddr, _lun, src, block, (uint16_t)ns,
110+
_msc_io_complete_cb, (uintptr_t)this)) {
109111
wait_for_io();
110112
return true;
111-
}else {
113+
} else {
112114
_busy = false;
113115
return false;
114116
}
@@ -118,7 +120,8 @@ bool Adafruit_USBH_MSC_BlockDevice::readSector(uint32_t block, uint8_t *dst) {
118120
return readSectors(block, dst, 1);
119121
}
120122

121-
bool Adafruit_USBH_MSC_BlockDevice::writeSector(uint32_t block, const uint8_t *src) {
123+
bool Adafruit_USBH_MSC_BlockDevice::writeSector(uint32_t block,
124+
const uint8_t *src) {
122125
return writeSectors(block, src, 1);
123126
}
124127

@@ -128,8 +131,6 @@ bool Adafruit_USBH_MSC_BlockDevice::writeSector(uint32_t block, const uint8_t *s
128131
// MACRO TYPEDEF CONSTANT ENUM DECLARATION
129132
//--------------------------------------------------------------------+
130133

131-
132134
//------------- IMPLEMENTATION -------------//
133135

134-
135136
#endif

src/arduino/msc/Adafruit_USBH_MSC.h

Lines changed: 24 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
/*
1+
/*
22
* The MIT License (MIT)
33
*
44
* Copyright (c) 2022 Ha Thach (tinyusb.org) for Adafruit Industries
@@ -34,37 +34,39 @@
3434

3535
class Adafruit_USBH_MSC_BlockDevice : public FsBlockDeviceInterface {
3636
public:
37-
Adafruit_USBH_MSC_BlockDevice();
37+
Adafruit_USBH_MSC_BlockDevice();
3838

39-
bool begin(uint8_t dev_addr);
40-
void end(void);
39+
bool begin(uint8_t dev_addr);
40+
void end(void);
4141

42-
// Set active LUN
43-
bool setActiveLUN(uint8_t lun);
42+
// Set active LUN
43+
bool setActiveLUN(uint8_t lun);
4444

45-
bool mounted(void);
45+
bool mounted(void);
4646

47-
//------------- SdFat v2 FsBlockDeviceInterface API -------------//
48-
virtual bool isBusy();
49-
virtual uint32_t sectorCount();
50-
virtual bool syncDevice();
47+
//------------- SdFat v2 FsBlockDeviceInterface API -------------//
48+
virtual bool isBusy();
49+
virtual uint32_t sectorCount();
50+
virtual bool syncDevice();
5151

52-
virtual bool readSector(uint32_t block, uint8_t *dst);
53-
virtual bool readSectors(uint32_t block, uint8_t *dst, size_t ns);
54-
virtual bool writeSector(uint32_t block, const uint8_t *src);
55-
virtual bool writeSectors(uint32_t block, const uint8_t *src, size_t ns);
52+
virtual bool readSector(uint32_t block, uint8_t *dst);
53+
virtual bool readSectors(uint32_t block, uint8_t *dst, size_t ns);
54+
virtual bool writeSector(uint32_t block, const uint8_t *src);
55+
virtual bool writeSectors(uint32_t block, const uint8_t *src, size_t ns);
5656

57-
//------------- Internal APIs -------------//
58-
bool _io_complete_cb(uint8_t dev_addr, tuh_msc_complete_data_t const* cb_data);
57+
//------------- Internal APIs -------------//
58+
bool _io_complete_cb(uint8_t dev_addr,
59+
tuh_msc_complete_data_t const *cb_data);
5960

6061
private:
61-
uint8_t _daddr;
62-
uint8_t _lun;
62+
uint8_t _daddr;
63+
uint8_t _lun;
6364

64-
// TODO use mutex to prevent race condition or atomic for better implementation
65-
volatile bool _busy;
65+
// TODO use mutex to prevent race condition or atomic for better
66+
// implementation
67+
volatile bool _busy;
6668

67-
bool wait_for_io(void);
69+
bool wait_for_io(void);
6870
};
6971

7072
#endif

0 commit comments

Comments
 (0)