Skip to content

Commit f39dcae

Browse files
committed
fix several warnings
1 parent 878c8f2 commit f39dcae

File tree

39 files changed

+145
-128
lines changed

39 files changed

+145
-128
lines changed

examples/device/audio_4_channel_mic/src/usb_descriptors.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@
3939
//--------------------------------------------------------------------+
4040
// Device Descriptors
4141
//--------------------------------------------------------------------+
42-
tusb_desc_device_t const desc_device =
42+
static tusb_desc_device_t const desc_device =
4343
{
4444
.bLength = sizeof(tusb_desc_device_t),
4545
.bDescriptorType = TUSB_DESC_DEVICE,

examples/device/audio_4_channel_mic_freertos/src/usb_descriptors.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@
3939
//--------------------------------------------------------------------+
4040
// Device Descriptors
4141
//--------------------------------------------------------------------+
42-
tusb_desc_device_t const desc_device =
42+
static tusb_desc_device_t const desc_device =
4343
{
4444
.bLength = sizeof(tusb_desc_device_t),
4545
.bDescriptorType = TUSB_DESC_DEVICE,

examples/device/audio_test/src/usb_descriptors.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@
3939
//--------------------------------------------------------------------+
4040
// Device Descriptors
4141
//--------------------------------------------------------------------+
42-
tusb_desc_device_t const desc_device =
42+
static tusb_desc_device_t const desc_device =
4343
{
4444
.bLength = sizeof(tusb_desc_device_t),
4545
.bDescriptorType = TUSB_DESC_DEVICE,

examples/device/audio_test_freertos/src/usb_descriptors.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@
3939
//--------------------------------------------------------------------+
4040
// Device Descriptors
4141
//--------------------------------------------------------------------+
42-
tusb_desc_device_t const desc_device =
42+
static tusb_desc_device_t const desc_device =
4343
{
4444
.bLength = sizeof(tusb_desc_device_t),
4545
.bDescriptorType = TUSB_DESC_DEVICE,

examples/device/audio_test_multi_rate/src/usb_descriptors.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@
4141
//--------------------------------------------------------------------+
4242
// Device Descriptors
4343
//--------------------------------------------------------------------+
44-
tusb_desc_device_t const desc_device =
44+
static tusb_desc_device_t const desc_device =
4545
{
4646
.bLength = sizeof(tusb_desc_device_t),
4747
.bDescriptorType = TUSB_DESC_DEVICE,

examples/device/cdc_dual_ports/src/usb_descriptors.c

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@
4242
//--------------------------------------------------------------------+
4343
// Device Descriptors
4444
//--------------------------------------------------------------------+
45-
tusb_desc_device_t const desc_device = {
45+
static tusb_desc_device_t const desc_device = {
4646
.bLength = sizeof(tusb_desc_device_t),
4747
.bDescriptorType = TUSB_DESC_DEVICE,
4848
.bcdUSB = USB_BCD,
@@ -127,7 +127,7 @@ enum {
127127
#define EPNUM_CDC_1_IN 0x84
128128
#endif
129129

130-
uint8_t const desc_fs_configuration[] = {
130+
static uint8_t const desc_fs_configuration[] = {
131131
// Config number, interface count, string index, total length, attribute, power in mA
132132
TUD_CONFIG_DESCRIPTOR(1, ITF_NUM_TOTAL, 0, CONFIG_TOTAL_LEN, 0x00, 100),
133133

@@ -140,7 +140,7 @@ uint8_t const desc_fs_configuration[] = {
140140

141141
#if TUD_OPT_HIGH_SPEED
142142
// Per USB specs: high speed capable device must report device_qualifier and other_speed_configuration
143-
uint8_t const desc_hs_configuration[] = {
143+
static uint8_t const desc_hs_configuration[] = {
144144
// Config number, interface count, string index, total length, attribute, power in mA
145145
TUD_CONFIG_DESCRIPTOR(1, ITF_NUM_TOTAL, 0, CONFIG_TOTAL_LEN, 0x00, 100),
146146

@@ -152,7 +152,7 @@ uint8_t const desc_hs_configuration[] = {
152152
};
153153

154154
// device qualifier is mostly similar to device descriptor since we don't change configuration based on speed
155-
tusb_desc_device_qualifier_t const desc_device_qualifier = {
155+
static tusb_desc_device_qualifier_t const desc_device_qualifier = {
156156
.bLength = sizeof(tusb_desc_device_t),
157157
.bDescriptorType = TUSB_DESC_DEVICE,
158158
.bcdUSB = USB_BCD,
@@ -213,7 +213,7 @@ enum {
213213
};
214214

215215
// array of pointer to string descriptors
216-
char const *string_desc_arr[] = {
216+
static char const *string_desc_arr[] = {
217217
(const char[]) { 0x09, 0x04 }, // 0: is supported language is English (0x0409)
218218
"TinyUSB", // 1: Manufacturer
219219
"TinyUSB Device", // 2: Product

examples/device/cdc_msc/src/main.c

Lines changed: 13 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,7 @@ enum {
4242
};
4343

4444
static uint32_t blink_interval_ms = BLINK_NOT_MOUNTED;
45+
static bool blink_enable = true;
4546

4647
void led_blinking_task(void);
4748
void cdc_task(void);
@@ -135,11 +136,13 @@ void tud_cdc_line_state_cb(uint8_t itf, bool dtr, bool rts) {
135136
(void) itf;
136137
(void) rts;
137138

138-
// TODO set some indicator
139139
if (dtr) {
140140
// Terminal connected
141+
blink_enable = false;
142+
board_led_write(true);
141143
} else {
142144
// Terminal disconnected
145+
blink_enable = true;
143146
}
144147
}
145148

@@ -155,10 +158,14 @@ void led_blinking_task(void) {
155158
static uint32_t start_ms = 0;
156159
static bool led_state = false;
157160

158-
// Blink every interval ms
159-
if (board_millis() - start_ms < blink_interval_ms) return; // not enough time
160-
start_ms += blink_interval_ms;
161+
if (blink_enable) {
162+
// Blink every interval ms
163+
if (board_millis() - start_ms < blink_interval_ms) {
164+
return; // not enough time
165+
}
166+
start_ms += blink_interval_ms;
161167

162-
board_led_write(led_state);
163-
led_state = 1 - led_state; // toggle
168+
board_led_write(led_state);
169+
led_state = !led_state;
170+
}
164171
}

examples/device/cdc_msc/src/msc_disk.c

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ enum {
4848
#ifdef CFG_EXAMPLE_MSC_READONLY
4949
const
5050
#endif
51-
uint8_t msc_disk[DISK_BLOCK_NUM][DISK_BLOCK_SIZE] = {
51+
static uint8_t msc_disk[DISK_BLOCK_NUM][DISK_BLOCK_SIZE] = {
5252
//------------- Block0: Boot Sector -------------//
5353
// byte_per_sector = DISK_BLOCK_SIZE; fat12_sector_num_16 = DISK_BLOCK_NUM;
5454
// sector_per_cluster = 1; reserved_sectors = 1;
@@ -213,7 +213,9 @@ int32_t tud_msc_write10_cb(uint8_t lun, uint32_t lba, uint32_t offset, uint8_t *
213213
(void) lun;
214214

215215
// out of ramdisk
216-
if (lba >= DISK_BLOCK_NUM) return -1;
216+
if (lba >= DISK_BLOCK_NUM) {
217+
return -1;
218+
}
217219

218220
#ifndef CFG_EXAMPLE_MSC_READONLY
219221
uint8_t *addr = msc_disk[lba] + offset;

examples/device/cdc_msc/src/usb_descriptors.c

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@
4242
//--------------------------------------------------------------------+
4343
// Device Descriptors
4444
//--------------------------------------------------------------------+
45-
tusb_desc_device_t const desc_device = {
45+
static tusb_desc_device_t const desc_device = {
4646
.bLength = sizeof(tusb_desc_device_t),
4747
.bDescriptorType = TUSB_DESC_DEVICE,
4848
.bcdUSB = USB_BCD,
@@ -125,7 +125,7 @@ enum {
125125
#define CONFIG_TOTAL_LEN (TUD_CONFIG_DESC_LEN + TUD_CDC_DESC_LEN + TUD_MSC_DESC_LEN)
126126

127127
// full speed configuration
128-
uint8_t const desc_fs_configuration[] = {
128+
static uint8_t const desc_fs_configuration[] = {
129129
// Config number, interface count, string index, total length, attribute, power in mA
130130
TUD_CONFIG_DESCRIPTOR(1, ITF_NUM_TOTAL, 0, CONFIG_TOTAL_LEN, 0x00, 100),
131131

@@ -140,7 +140,7 @@ uint8_t const desc_fs_configuration[] = {
140140
// Per USB specs: high speed capable device must report device_qualifier and other_speed_configuration
141141

142142
// high speed configuration
143-
uint8_t const desc_hs_configuration[] = {
143+
static uint8_t const desc_hs_configuration[] = {
144144
// Config number, interface count, string index, total length, attribute, power in mA
145145
TUD_CONFIG_DESCRIPTOR(1, ITF_NUM_TOTAL, 0, CONFIG_TOTAL_LEN, 0x00, 100),
146146

@@ -152,10 +152,10 @@ uint8_t const desc_hs_configuration[] = {
152152
};
153153

154154
// other speed configuration
155-
uint8_t desc_other_speed_config[CONFIG_TOTAL_LEN];
155+
static uint8_t desc_other_speed_config[CONFIG_TOTAL_LEN];
156156

157157
// device qualifier is mostly similar to device descriptor since we don't change configuration based on speed
158-
tusb_desc_device_qualifier_t const desc_device_qualifier = {
158+
static tusb_desc_device_qualifier_t const desc_device_qualifier = {
159159
.bLength = sizeof(tusb_desc_device_qualifier_t),
160160
.bDescriptorType = TUSB_DESC_DEVICE_QUALIFIER,
161161
.bcdUSB = USB_BCD,
@@ -223,7 +223,7 @@ enum {
223223
};
224224

225225
// array of pointer to string descriptors
226-
char const *string_desc_arr[] = {
226+
static char const *string_desc_arr[] = {
227227
(const char[]) { 0x09, 0x04 }, // 0: is supported language is English (0x0409)
228228
"TinyUSB", // 1: Manufacturer
229229
"TinyUSB Device", // 2: Product

examples/device/cdc_msc_freertos/src/msc_disk.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,7 @@ enum {
7979
#ifdef CFG_EXAMPLE_MSC_READONLY
8080
const
8181
#endif
82-
uint8_t msc_disk[DISK_BLOCK_NUM][DISK_BLOCK_SIZE] =
82+
static uint8_t msc_disk[DISK_BLOCK_NUM][DISK_BLOCK_SIZE] =
8383
{
8484
//------------- Block0: Boot Sector -------------//
8585
// byte_per_sector = DISK_BLOCK_SIZE; fat12_sector_num_16 = DISK_BLOCK_NUM;

0 commit comments

Comments
 (0)