Procházet zdrojové kódy

fix most warnings with rp2040 -wconversion

hathach před 3 roky
rodič
revize
b9dc9dbd78
48 změnil soubory, kde provedl 140 přidání a 53 odebrání
  1. 3 0
      examples/device/audio_4_channel_mic/CMakeLists.txt
  2. 1 1
      examples/device/audio_4_channel_mic/src/main.c
  3. 2 2
      examples/device/audio_4_channel_mic/src/usb_descriptors.c
  4. 3 0
      examples/device/audio_test/CMakeLists.txt
  5. 1 1
      examples/device/audio_test/src/main.c
  6. 2 2
      examples/device/audio_test/src/usb_descriptors.c
  7. 3 0
      examples/device/board_test/CMakeLists.txt
  8. 3 0
      examples/device/cdc_dual_ports/CMakeLists.txt
  9. 2 2
      examples/device/cdc_dual_ports/src/usb_descriptors.c
  10. 3 0
      examples/device/cdc_msc/CMakeLists.txt
  11. 2 2
      examples/device/cdc_msc_freertos/src/usb_descriptors.c
  12. 4 1
      examples/device/dfu/CMakeLists.txt
  13. 1 1
      examples/device/dfu/src/usb_descriptors.c
  14. 3 0
      examples/device/dfu_runtime/CMakeLists.txt
  15. 2 2
      examples/device/dfu_runtime/src/usb_descriptors.c
  16. 3 0
      examples/device/dynamic_configuration/CMakeLists.txt
  17. 1 1
      examples/device/dynamic_configuration/src/main.c
  18. 3 3
      examples/device/dynamic_configuration/src/msc_disk.c
  19. 2 2
      examples/device/dynamic_configuration/src/usb_descriptors.c
  20. 3 0
      examples/device/hid_boot_interface/CMakeLists.txt
  21. 2 2
      examples/device/hid_boot_interface/src/usb_descriptors.c
  22. 3 0
      examples/device/hid_composite/CMakeLists.txt
  23. 2 2
      examples/device/hid_composite/src/usb_descriptors.c
  24. 2 2
      examples/device/hid_composite_freertos/src/usb_descriptors.c
  25. 3 0
      examples/device/hid_generic_inout/CMakeLists.txt
  26. 2 2
      examples/device/hid_generic_inout/src/usb_descriptors.c
  27. 3 0
      examples/device/hid_multiple_interface/CMakeLists.txt
  28. 2 2
      examples/device/hid_multiple_interface/src/usb_descriptors.c
  29. 3 0
      examples/device/midi_test/CMakeLists.txt
  30. 2 2
      examples/device/midi_test/src/usb_descriptors.c
  31. 3 0
      examples/device/msc_dual_lun/CMakeLists.txt
  32. 2 2
      examples/device/msc_dual_lun/src/usb_descriptors.c
  33. 3 0
      examples/device/net_lwip_webserver/CMakeLists.txt
  34. 2 2
      examples/device/net_lwip_webserver/src/usb_descriptors.c
  35. 3 0
      examples/device/uac2_headset/CMakeLists.txt
  36. 1 1
      examples/device/uac2_headset/src/usb_descriptors.c
  37. 3 0
      examples/device/usbtmc/CMakeLists.txt
  38. 1 1
      examples/device/usbtmc/src/usb_descriptors.c
  39. 3 0
      examples/device/video_capture/CMakeLists.txt
  40. 2 2
      examples/device/video_capture/src/usb_descriptors.c
  41. 3 0
      examples/device/webusb_serial/CMakeLists.txt
  42. 2 2
      examples/device/webusb_serial/src/usb_descriptors.c
  43. 1 1
      examples/dual/host_hid_to_device_cdc/src/usb_descriptors.c
  44. 25 0
      examples/example.cmake
  45. 5 1
      hw/bsp/rp2040/family.c
  46. 1 1
      src/class/audio/audio_device.c
  47. 3 2
      src/class/hid/hid_device.c
  48. 6 6
      src/class/midi/midi_device.c

+ 3 - 0
examples/device/audio_4_channel_mic/CMakeLists.txt

@@ -23,6 +23,9 @@ target_include_directories(${PROJECT} PUBLIC
   ${CMAKE_CURRENT_SOURCE_DIR}/src
 )
 
+# Example common such as compiler warnings
+include(${CMAKE_CURRENT_SOURCE_DIR}/../../example.cmake)
+
 # Configure compilation flags and libraries for the example... see the corresponding function
 # in hw/bsp/FAMILY/family.cmake for details.
 family_configure_device_example(${PROJECT})

+ 1 - 1
examples/device/audio_4_channel_mic/src/main.c

@@ -221,7 +221,7 @@ bool tud_audio_set_req_entity_cb(uint8_t rhport, tusb_control_request_t const *
         // Request uses format layout 2
         TU_VERIFY(p_request->wLength == sizeof(audio_control_cur_2_t));
 
-        volume[channelNum] = ((audio_control_cur_2_t*) pBuff)->bCur;
+        volume[channelNum] = (uint16_t) ((audio_control_cur_2_t*) pBuff)->bCur;
 
         TU_LOG2("    Set Volume: %d dB of channel: %u\r\n", volume[channelNum], channelNum);
       return true;

+ 2 - 2
examples/device/audio_4_channel_mic/src/usb_descriptors.c

@@ -149,7 +149,7 @@ uint16_t const* tud_descriptor_string_cb(uint8_t index, uint16_t langid)
     const char* str = string_desc_arr[index];
 
     // Cap at max char
-    chr_count = strlen(str);
+    chr_count = (uint8_t) strlen(str);
     if ( chr_count > 31 ) chr_count = 31;
 
     for(uint8_t i=0; i<chr_count; i++)
@@ -159,7 +159,7 @@ uint16_t const* tud_descriptor_string_cb(uint8_t index, uint16_t langid)
   }
 
   // first byte is length (including header), second byte is string type
-  _desc_str[0] = (TUSB_DESC_STRING << 8 ) | (2*chr_count + 2);
+  _desc_str[0] = (uint16_t) ((TUSB_DESC_STRING << 8 ) | (2*chr_count + 2));
 
   return _desc_str;
 }

+ 3 - 0
examples/device/audio_test/CMakeLists.txt

@@ -23,6 +23,9 @@ target_include_directories(${PROJECT} PUBLIC
   ${CMAKE_CURRENT_SOURCE_DIR}/src
 )
 
+# Example common such as compiler warnings
+include(${CMAKE_CURRENT_SOURCE_DIR}/../../example.cmake)
+
 # Configure compilation flags and libraries for the example... see the corresponding function
 # in hw/bsp/FAMILY/family.cmake for details.
 family_configure_device_example(${PROJECT})

+ 1 - 1
examples/device/audio_test/src/main.c

@@ -222,7 +222,7 @@ bool tud_audio_set_req_entity_cb(uint8_t rhport, tusb_control_request_t const *
         // Request uses format layout 2
         TU_VERIFY(p_request->wLength == sizeof(audio_control_cur_2_t));
 
-        volume[channelNum] = ((audio_control_cur_2_t*) pBuff)->bCur;
+        volume[channelNum] = (uint16_t) ((audio_control_cur_2_t*) pBuff)->bCur;
 
         TU_LOG2("    Set Volume: %d dB of channel: %u\r\n", volume[channelNum], channelNum);
       return true;

+ 2 - 2
examples/device/audio_test/src/usb_descriptors.c

@@ -149,7 +149,7 @@ uint16_t const* tud_descriptor_string_cb(uint8_t index, uint16_t langid)
     const char* str = string_desc_arr[index];
 
     // Cap at max char
-    chr_count = strlen(str);
+    chr_count = (uint8_t) strlen(str);
     if ( chr_count > 31 ) chr_count = 31;
 
     for(uint8_t i=0; i<chr_count; i++)
@@ -159,7 +159,7 @@ uint16_t const* tud_descriptor_string_cb(uint8_t index, uint16_t langid)
   }
 
   // first byte is length (including header), second byte is string type
-  _desc_str[0] = (TUSB_DESC_STRING << 8 ) | (2*chr_count + 2);
+  _desc_str[0] = (uint16_t) ((TUSB_DESC_STRING << 8 ) | (2*chr_count + 2));
 
   return _desc_str;
 }

+ 3 - 0
examples/device/board_test/CMakeLists.txt

@@ -36,6 +36,9 @@ else()
           ${CMAKE_CURRENT_SOURCE_DIR}/src
           )
 
+  # Example common such as compiler warnings
+  include(${CMAKE_CURRENT_SOURCE_DIR}/../../example.cmake)
+
   # Configure compilation flags and libraries for the example... see the corresponding function
   # in hw/bsp/FAMILY/family.cmake for details.
   family_configure_device_example(${PROJECT})

+ 3 - 0
examples/device/cdc_dual_ports/CMakeLists.txt

@@ -23,6 +23,9 @@ target_include_directories(${PROJECT} PUBLIC
         ${CMAKE_CURRENT_SOURCE_DIR}/src
         )
 
+# Example common such as compiler warnings
+include(${CMAKE_CURRENT_SOURCE_DIR}/../../example.cmake)
+
 # Configure compilation flags and libraries for the example... see the corresponding function
 # in hw/bsp/FAMILY/family.cmake for details.
 family_configure_device_example(${PROJECT})

+ 2 - 2
examples/device/cdc_dual_ports/src/usb_descriptors.c

@@ -236,7 +236,7 @@ uint16_t const* tud_descriptor_string_cb(uint8_t index, uint16_t langid)
     const char* str = string_desc_arr[index];
 
     // Cap at max char
-    chr_count = strlen(str);
+    chr_count = (uint8_t) strlen(str);
     if ( chr_count > 31 ) chr_count = 31;
 
     // Convert ASCII string into UTF-16
@@ -247,7 +247,7 @@ uint16_t const* tud_descriptor_string_cb(uint8_t index, uint16_t langid)
   }
 
   // first byte is length (including header), second byte is string type
-  _desc_str[0] = (TUSB_DESC_STRING << 8 ) | (2*chr_count + 2);
+  _desc_str[0] = (uint16_t) ((TUSB_DESC_STRING << 8 ) | (2*chr_count + 2));
 
   return _desc_str;
 }

+ 3 - 0
examples/device/cdc_msc/CMakeLists.txt

@@ -24,6 +24,9 @@ target_include_directories(${PROJECT} PUBLIC
         ${CMAKE_CURRENT_SOURCE_DIR}/src
         )
 
+# Example common such as compiler warnings
+include(${CMAKE_CURRENT_SOURCE_DIR}/../../example.cmake)
+
 # Configure compilation flags and libraries for the example... see the corresponding function
 # in hw/bsp/FAMILY/family.cmake for details.
 family_configure_device_example(${PROJECT})

+ 2 - 2
examples/device/cdc_msc_freertos/src/usb_descriptors.c

@@ -247,7 +247,7 @@ uint16_t const* tud_descriptor_string_cb(uint8_t index, uint16_t langid)
     const char* str = string_desc_arr[index];
 
     // Cap at max char
-    chr_count = strlen(str);
+    chr_count = (uint8_t) strlen(str);
     if ( chr_count > 31 ) chr_count = 31;
 
     // Convert ASCII string into UTF-16
@@ -258,7 +258,7 @@ uint16_t const* tud_descriptor_string_cb(uint8_t index, uint16_t langid)
   }
 
   // first byte is length (including header), second byte is string type
-  _desc_str[0] = (TUSB_DESC_STRING << 8 ) | (2*chr_count + 2);
+  _desc_str[0] = (uint16_t) ((TUSB_DESC_STRING << 8 ) | (2*chr_count + 2));
 
   return _desc_str;
 }

+ 4 - 1
examples/device/dfu/CMakeLists.txt

@@ -23,6 +23,9 @@ target_include_directories(${PROJECT} PUBLIC
         ${CMAKE_CURRENT_SOURCE_DIR}/src
         )
 
+# Example common such as compiler warnings
+include(${CMAKE_CURRENT_SOURCE_DIR}/../../example.cmake)
+
 # Configure compilation flags and libraries for the example... see the corresponding function
 # in hw/bsp/FAMILY/family.cmake for details.
-family_configure_device_example(${PROJECT})
+family_configure_device_example(${PROJECT})

+ 1 - 1
examples/device/dfu/src/usb_descriptors.c

@@ -152,7 +152,7 @@ uint16_t const* tud_descriptor_string_cb(uint8_t index, uint16_t langid)
     const char* str = string_desc_arr[index];
 
     // Cap at max char
-    chr_count = strlen(str);
+    chr_count = (uint8_t) strlen(str);
     if ( chr_count > 31 ) {
       chr_count = 31;
     }

+ 3 - 0
examples/device/dfu_runtime/CMakeLists.txt

@@ -23,6 +23,9 @@ target_include_directories(${PROJECT} PUBLIC
         ${CMAKE_CURRENT_SOURCE_DIR}/src
         )
 
+# Example common such as compiler warnings
+include(${CMAKE_CURRENT_SOURCE_DIR}/../../example.cmake)
+
 # Configure compilation flags and libraries for the example... see the corresponding function
 # in hw/bsp/FAMILY/family.cmake for details.
 family_configure_device_example(${PROJECT})

+ 2 - 2
examples/device/dfu_runtime/src/usb_descriptors.c

@@ -147,7 +147,7 @@ uint16_t const* tud_descriptor_string_cb(uint8_t index, uint16_t langid)
     const char* str = string_desc_arr[index];
 
     // Cap at max char
-    chr_count = strlen(str);
+    chr_count = (uint8_t) strlen(str);
     if ( chr_count > 31 ) {
       chr_count = 31;
     }
@@ -160,7 +160,7 @@ uint16_t const* tud_descriptor_string_cb(uint8_t index, uint16_t langid)
   }
 
   // first byte is length (including header), second byte is string type
-  _desc_str[0] = (uint16_t)((((uint16_t)TUSB_DESC_STRING) << 8 ) | (2u*chr_count + 2u));
+  _desc_str[0] = (uint16_t) ((TUSB_DESC_STRING << 8 ) | (2*chr_count + 2));
 
   return _desc_str;
 }

+ 3 - 0
examples/device/dynamic_configuration/CMakeLists.txt

@@ -24,6 +24,9 @@ target_include_directories(${PROJECT} PUBLIC
         ${CMAKE_CURRENT_SOURCE_DIR}/src
         )
 
+# Example common such as compiler warnings
+include(${CMAKE_CURRENT_SOURCE_DIR}/../../example.cmake)
+
 # Configure compilation flags and libraries for the example... see the corresponding function
 # in hw/bsp/FAMILY/family.cmake for details.
 family_configure_device_example(${PROJECT})

+ 1 - 1
examples/device/dynamic_configuration/src/main.c

@@ -181,7 +181,7 @@ void midi_task(void)
   start_ms += 286;
 
   // Previous positions in the note sequence.
-  int previous = note_pos - 1;
+  int previous = (int) (note_pos - 1);
 
   // If we currently are at position 0, set the
   // previous position to the last note in the sequence.

+ 3 - 3
examples/device/dynamic_configuration/src/msc_disk.c

@@ -184,7 +184,7 @@ int32_t tud_msc_read10_cb(uint8_t lun, uint32_t lba, uint32_t offset, void* buff
   uint8_t const* addr = msc_disk[lba] + offset;
   memcpy(buffer, addr, bufsize);
 
-  return bufsize;
+  return (int32_t) bufsize;
 }
 
 // Callback invoked when received WRITE10 command.
@@ -203,7 +203,7 @@ int32_t tud_msc_write10_cb(uint8_t lun, uint32_t lba, uint32_t offset, uint8_t*
   (void) lba; (void) offset; (void) buffer;
 #endif
 
-  return bufsize;
+  return (int32_t) bufsize;
 }
 
 // Callback invoked when received an SCSI command not in built-in list below
@@ -237,7 +237,7 @@ int32_t tud_msc_scsi_cb (uint8_t lun, uint8_t const scsi_cmd[16], void* buffer,
   {
     if(in_xfer)
     {
-      memcpy(buffer, response, resplen);
+      memcpy(buffer, response, (size_t) resplen);
     }else
     {
       // SCSI output

+ 2 - 2
examples/device/dynamic_configuration/src/usb_descriptors.c

@@ -226,7 +226,7 @@ uint16_t const* tud_descriptor_string_cb(uint8_t index, uint16_t langid)
     const char* str = string_desc_arr[index];
 
     // Cap at max char
-    chr_count = strlen(str);
+    chr_count = (uint8_t) strlen(str);
     if ( chr_count > 31 ) chr_count = 31;
 
     // Convert ASCII string into UTF-16
@@ -237,7 +237,7 @@ uint16_t const* tud_descriptor_string_cb(uint8_t index, uint16_t langid)
   }
 
   // first byte is length (including header), second byte is string type
-  _desc_str[0] = (TUSB_DESC_STRING << 8 ) | (2*chr_count + 2);
+  _desc_str[0] = (uint16_t) ((TUSB_DESC_STRING << 8 ) | (2*chr_count + 2));
 
   return _desc_str;
 }

+ 3 - 0
examples/device/hid_boot_interface/CMakeLists.txt

@@ -23,6 +23,9 @@ target_include_directories(${PROJECT} PUBLIC
         ${CMAKE_CURRENT_SOURCE_DIR}/src
         )
 
+# Example common such as compiler warnings
+include(${CMAKE_CURRENT_SOURCE_DIR}/../../example.cmake)
+
 # Configure compilation flags and libraries for the example... see the corresponding function
 # in hw/bsp/FAMILY/family.cmake for details.
 family_configure_device_example(${PROJECT})

+ 2 - 2
examples/device/hid_boot_interface/src/usb_descriptors.c

@@ -163,7 +163,7 @@ uint16_t const* tud_descriptor_string_cb(uint8_t index, uint16_t langid)
     const char* str = string_desc_arr[index];
 
     // Cap at max char
-    chr_count = strlen(str);
+    chr_count = (uint8_t) strlen(str);
     if ( chr_count > 31 ) chr_count = 31;
 
     // Convert ASCII string into UTF-16
@@ -174,7 +174,7 @@ uint16_t const* tud_descriptor_string_cb(uint8_t index, uint16_t langid)
   }
 
   // first byte is length (including header), second byte is string type
-  _desc_str[0] = (TUSB_DESC_STRING << 8 ) | (2*chr_count + 2);
+  _desc_str[0] = (uint16_t) ((TUSB_DESC_STRING << 8 ) | (2*chr_count + 2));
 
   return _desc_str;
 }

+ 3 - 0
examples/device/hid_composite/CMakeLists.txt

@@ -23,6 +23,9 @@ target_include_directories(${PROJECT} PUBLIC
         ${CMAKE_CURRENT_SOURCE_DIR}/src
         )
 
+# Example common such as compiler warnings
+include(${CMAKE_CURRENT_SOURCE_DIR}/../../example.cmake)
+
 # Configure compilation flags and libraries for the example... see the corresponding function
 # in hw/bsp/FAMILY/family.cmake for details.
 family_configure_device_example(${PROJECT})

+ 2 - 2
examples/device/hid_composite/src/usb_descriptors.c

@@ -210,7 +210,7 @@ uint16_t const* tud_descriptor_string_cb(uint8_t index, uint16_t langid)
     const char* str = string_desc_arr[index];
 
     // Cap at max char
-    chr_count = strlen(str);
+    chr_count = (uint8_t) strlen(str);
     if ( chr_count > 31 ) chr_count = 31;
 
     // Convert ASCII string into UTF-16
@@ -221,7 +221,7 @@ uint16_t const* tud_descriptor_string_cb(uint8_t index, uint16_t langid)
   }
 
   // first byte is length (including header), second byte is string type
-  _desc_str[0] = (TUSB_DESC_STRING << 8 ) | (2*chr_count + 2);
+  _desc_str[0] = (uint16_t) ((TUSB_DESC_STRING << 8 ) | (2*chr_count + 2));
 
   return _desc_str;
 }

+ 2 - 2
examples/device/hid_composite_freertos/src/usb_descriptors.c

@@ -208,7 +208,7 @@ uint16_t const* tud_descriptor_string_cb(uint8_t index, uint16_t langid)
     const char* str = string_desc_arr[index];
 
     // Cap at max char
-    chr_count = strlen(str);
+    chr_count = (uint8_t) strlen(str);
     if ( chr_count > 31 ) chr_count = 31;
 
     // Convert ASCII string into UTF-16
@@ -219,7 +219,7 @@ uint16_t const* tud_descriptor_string_cb(uint8_t index, uint16_t langid)
   }
 
   // first byte is length (including header), second byte is string type
-  _desc_str[0] = (TUSB_DESC_STRING << 8 ) | (2*chr_count + 2);
+  _desc_str[0] = (uint16_t) ((TUSB_DESC_STRING << 8 ) | (2*chr_count + 2));
 
   return _desc_str;
 }

+ 3 - 0
examples/device/hid_generic_inout/CMakeLists.txt

@@ -23,6 +23,9 @@ target_include_directories(${PROJECT} PUBLIC
         ${CMAKE_CURRENT_SOURCE_DIR}/src
         )
 
+# Example common such as compiler warnings
+include(${CMAKE_CURRENT_SOURCE_DIR}/../../example.cmake)
+
 # Configure compilation flags and libraries for the example... see the corresponding function
 # in hw/bsp/FAMILY/family.cmake for details.
 family_configure_device_example(${PROJECT})

+ 2 - 2
examples/device/hid_generic_inout/src/usb_descriptors.c

@@ -153,7 +153,7 @@ uint16_t const* tud_descriptor_string_cb(uint8_t index, uint16_t langid)
     const char* str = string_desc_arr[index];
 
     // Cap at max char
-    chr_count = strlen(str);
+    chr_count = (uint8_t) strlen(str);
     if ( chr_count > 31 ) chr_count = 31;
 
     // Convert ASCII string into UTF-16
@@ -164,7 +164,7 @@ uint16_t const* tud_descriptor_string_cb(uint8_t index, uint16_t langid)
   }
 
   // first byte is length (including header), second byte is string type
-  _desc_str[0] = (TUSB_DESC_STRING << 8 ) | (2*chr_count + 2);
+  _desc_str[0] = (uint16_t) ((TUSB_DESC_STRING << 8 ) | (2*chr_count + 2));
 
   return _desc_str;
 }

+ 3 - 0
examples/device/hid_multiple_interface/CMakeLists.txt

@@ -23,6 +23,9 @@ target_include_directories(${PROJECT} PUBLIC
         ${CMAKE_CURRENT_SOURCE_DIR}/src
         )
 
+# Example common such as compiler warnings
+include(${CMAKE_CURRENT_SOURCE_DIR}/../../example.cmake)
+
 # Configure compilation flags and libraries for the example... see the corresponding function
 # in hw/bsp/FAMILY/family.cmake for details.
 family_configure_device_example(${PROJECT})

+ 2 - 2
examples/device/hid_multiple_interface/src/usb_descriptors.c

@@ -171,7 +171,7 @@ uint16_t const* tud_descriptor_string_cb(uint8_t index, uint16_t langid)
     const char* str = string_desc_arr[index];
 
     // Cap at max char
-    chr_count = strlen(str);
+    chr_count = (uint8_t) strlen(str);
     if ( chr_count > 31 ) chr_count = 31;
 
     // Convert ASCII string into UTF-16
@@ -182,7 +182,7 @@ uint16_t const* tud_descriptor_string_cb(uint8_t index, uint16_t langid)
   }
 
   // first byte is length (including header), second byte is string type
-  _desc_str[0] = (TUSB_DESC_STRING << 8 ) | (2*chr_count + 2);
+  _desc_str[0] = (uint16_t) ((TUSB_DESC_STRING << 8 ) | (2*chr_count + 2));
 
   return _desc_str;
 }

+ 3 - 0
examples/device/midi_test/CMakeLists.txt

@@ -23,6 +23,9 @@ target_include_directories(${PROJECT} PUBLIC
         ${CMAKE_CURRENT_SOURCE_DIR}/src
         )
 
+# Example common such as compiler warnings
+include(${CMAKE_CURRENT_SOURCE_DIR}/../../example.cmake)
+
 # Configure compilation flags and libraries for the example... see the corresponding function
 # in hw/bsp/FAMILY/family.cmake for details.
 family_configure_device_example(${PROJECT})

+ 2 - 2
examples/device/midi_test/src/usb_descriptors.c

@@ -166,7 +166,7 @@ uint16_t const* tud_descriptor_string_cb(uint8_t index, uint16_t langid)
     const char* str = string_desc_arr[index];
 
     // Cap at max char
-    chr_count = strlen(str);
+    chr_count = (uint8_t) strlen(str);
     if ( chr_count > 31 ) chr_count = 31;
 
     // Convert ASCII string into UTF-16
@@ -177,7 +177,7 @@ uint16_t const* tud_descriptor_string_cb(uint8_t index, uint16_t langid)
   }
 
   // first byte is length (including header), second byte is string type
-  _desc_str[0] = (TUSB_DESC_STRING << 8 ) | (2*chr_count + 2);
+  _desc_str[0] = (uint16_t) ((TUSB_DESC_STRING << 8 ) | (2*chr_count + 2));
 
   return _desc_str;
 }

+ 3 - 0
examples/device/msc_dual_lun/CMakeLists.txt

@@ -24,6 +24,9 @@ target_include_directories(${PROJECT} PUBLIC
         ${CMAKE_CURRENT_SOURCE_DIR}/src
         )
 
+# Example common such as compiler warnings
+include(${CMAKE_CURRENT_SOURCE_DIR}/../../example.cmake)
+
 # Configure compilation flags and libraries for the example... see the corresponding function
 # in hw/bsp/FAMILY/family.cmake for details.
 family_configure_device_example(${PROJECT})

+ 2 - 2
examples/device/msc_dual_lun/src/usb_descriptors.c

@@ -168,7 +168,7 @@ uint16_t const* tud_descriptor_string_cb(uint8_t index, uint16_t langid)
     const char* str = string_desc_arr[index];
 
     // Cap at max char
-    chr_count = strlen(str);
+    chr_count = (uint8_t) strlen(str);
     if ( chr_count > 31 ) chr_count = 31;
 
     // Convert ASCII string into UTF-16
@@ -179,7 +179,7 @@ uint16_t const* tud_descriptor_string_cb(uint8_t index, uint16_t langid)
   }
 
   // first byte is length (including header), second byte is string type
-  _desc_str[0] = (TUSB_DESC_STRING << 8 ) | (2*chr_count + 2);
+  _desc_str[0] = (uint16_t) ((TUSB_DESC_STRING << 8 ) | (2*chr_count + 2));
 
   return _desc_str;
 }

+ 3 - 0
examples/device/net_lwip_webserver/CMakeLists.txt

@@ -69,6 +69,9 @@ if (EXISTS ${TOP}/lib/lwip/src)
             ${TOP}/lib/networking/rndis_reports.c
             )
 
+    # Example common such as compiler warnings
+    include(${CMAKE_CURRENT_SOURCE_DIR}/../../example.cmake)
+
     # Configure compilation flags and libraries for the example... see the corresponding function
     # in hw/bsp/FAMILY/family.cmake for details.
     family_configure_device_example(${PROJECT})

+ 2 - 2
examples/device/net_lwip_webserver/src/usb_descriptors.c

@@ -231,7 +231,7 @@ uint16_t const* tud_descriptor_string_cb(uint8_t index, uint16_t langid)
     const char* str = string_desc_arr[index];
 
     // Cap at max char
-    chr_count = strlen(str);
+    chr_count = (uint8_t) strlen(str);
     if ( chr_count > (TU_ARRAY_SIZE(_desc_str) - 1)) chr_count = TU_ARRAY_SIZE(_desc_str) - 1;
 
     // Convert ASCII string into UTF-16
@@ -242,7 +242,7 @@ uint16_t const* tud_descriptor_string_cb(uint8_t index, uint16_t langid)
   }
 
   // first byte is length (including header), second byte is string type
-  _desc_str[0] = (TUSB_DESC_STRING << 8 ) | (2*chr_count + 2);
+  _desc_str[0] = (uint16_t) ((TUSB_DESC_STRING << 8 ) | (2*chr_count + 2));
 
   return _desc_str;
 }

+ 3 - 0
examples/device/uac2_headset/CMakeLists.txt

@@ -23,6 +23,9 @@ target_include_directories(${PROJECT} PUBLIC
         ${CMAKE_CURRENT_SOURCE_DIR}/src
         )
 
+# Example common such as compiler warnings
+include(${CMAKE_CURRENT_SOURCE_DIR}/../../example.cmake)
+
 # Configure compilation flags and libraries for the example... see the corresponding function
 # in hw/bsp/FAMILY/family.cmake for details.
 family_configure_device_example(${PROJECT})

+ 1 - 1
examples/device/uac2_headset/src/usb_descriptors.c

@@ -155,7 +155,7 @@ uint16_t const* tud_descriptor_string_cb(uint8_t index, uint16_t langid)
     const char* str = string_desc_arr[index];
 
     // Cap at max char
-    chr_count = strlen(str);
+    chr_count = (uint8_t) strlen(str);
     if (chr_count > 31) chr_count = 31;
 
     for (uint8_t i = 0; i < chr_count; i++)

+ 3 - 0
examples/device/usbtmc/CMakeLists.txt

@@ -24,6 +24,9 @@ target_include_directories(${PROJECT} PUBLIC
         ${CMAKE_CURRENT_SOURCE_DIR}/src
         )
 
+# Example common such as compiler warnings
+include(${CMAKE_CURRENT_SOURCE_DIR}/../../example.cmake)
+
 # Configure compilation flags and libraries for the example... see the corresponding function
 # in hw/bsp/FAMILY/family.cmake for details.
 family_configure_device_example(${PROJECT})

+ 1 - 1
examples/device/usbtmc/src/usb_descriptors.c

@@ -175,7 +175,7 @@ uint16_t const* tud_descriptor_string_cb(uint8_t index, uint16_t langid)
     const char* str = string_desc_arr[index];
 
     // Cap at max char
-    chr_count = strlen(str);
+    chr_count = (uint8_t) strlen(str);
     if ( chr_count > 31 ) {
       chr_count = 31;
     }

+ 3 - 0
examples/device/video_capture/CMakeLists.txt

@@ -23,6 +23,9 @@ target_include_directories(${PROJECT} PUBLIC
   ${CMAKE_CURRENT_SOURCE_DIR}/src
 )
 
+# Example common such as compiler warnings
+include(${CMAKE_CURRENT_SOURCE_DIR}/../../example.cmake)
+
 # Configure compilation flags and libraries for the example... see the corresponding function
 # in hw/bsp/FAMILY/family.cmake for details.
 family_configure_device_example(${PROJECT})

+ 2 - 2
examples/device/video_capture/src/usb_descriptors.c

@@ -149,7 +149,7 @@ uint16_t const* tud_descriptor_string_cb(uint8_t index, uint16_t langid)
     const char* str = string_desc_arr[index];
 
     // Cap at max char
-    chr_count = strlen(str);
+    chr_count = (uint8_t) strlen(str);
     if ( chr_count > 31 ) chr_count = 31;
 
     // Convert ASCII string into UTF-16
@@ -160,7 +160,7 @@ uint16_t const* tud_descriptor_string_cb(uint8_t index, uint16_t langid)
   }
 
   // first byte is length (including header), second byte is string type
-  _desc_str[0] = (TUSB_DESC_STRING << 8 ) | (2*chr_count + 2);
+  _desc_str[0] = (uint16_t) ((TUSB_DESC_STRING << 8 ) | (2*chr_count + 2));
 
   return _desc_str;
 }

+ 3 - 0
examples/device/webusb_serial/CMakeLists.txt

@@ -23,6 +23,9 @@ target_include_directories(${PROJECT} PUBLIC
         ${CMAKE_CURRENT_SOURCE_DIR}/src
         )
 
+# Example common such as compiler warnings
+include(${CMAKE_CURRENT_SOURCE_DIR}/../../example.cmake)
+
 # Configure compilation flags and libraries for the example... see the corresponding function
 # in hw/bsp/FAMILY/family.cmake for details.
 family_configure_device_example(${PROJECT})

+ 2 - 2
examples/device/webusb_serial/src/usb_descriptors.c

@@ -235,7 +235,7 @@ uint16_t const* tud_descriptor_string_cb(uint8_t index, uint16_t langid)
     const char* str = string_desc_arr[index];
 
     // Cap at max char
-    chr_count = strlen(str);
+    chr_count = (uint8_t) strlen(str);
     if ( chr_count > 31 ) chr_count = 31;
 
     // Convert ASCII string into UTF-16
@@ -246,7 +246,7 @@ uint16_t const* tud_descriptor_string_cb(uint8_t index, uint16_t langid)
   }
 
   // first byte is length (including header), second byte is string type
-  _desc_str[0] = (TUSB_DESC_STRING << 8 ) | (2*chr_count + 2);
+  _desc_str[0] = (uint16_t) ((TUSB_DESC_STRING << 8 ) | (2*chr_count + 2));
 
   return _desc_str;
 }

+ 1 - 1
examples/dual/host_hid_to_device_cdc/src/usb_descriptors.c

@@ -259,7 +259,7 @@ uint16_t const* tud_descriptor_string_cb(uint8_t index, uint16_t langid)
   }
 
   // first byte is length (including header), second byte is string type
-  _desc_str[0] = (TUSB_DESC_STRING << 8 ) | (2*chr_count + 2);
+  _desc_str[0] = (uint16_t) ((TUSB_DESC_STRING << 8 ) | (2*chr_count + 2));
 
   return _desc_str;
 }

+ 25 - 0
examples/example.cmake

@@ -0,0 +1,25 @@
+target_compile_options(${PROJECT} PUBLIC
+        -Wall
+        -Wextra
+        -Werror
+        -Wfatal-errors
+        -Wdouble-promotion
+        #-Wstrict-prototypes
+        -Wstrict-overflow
+        #-Werror-implicit-function-declaration
+        -Wfloat-equal
+        #-Wundef
+        -Wshadow
+        -Wwrite-strings
+        -Wsign-compare
+        -Wmissing-format-attribute
+        -Wunreachable-code
+        -Wcast-align
+        -Wcast-function-type
+        -Wcast-qual
+        -Wnull-dereference
+        -Wuninitialized
+        -Wunused
+        -Wredundant-decls
+        -Wconversion
+        )

+ 5 - 1
hw/bsp/rp2040/family.c

@@ -53,7 +53,7 @@
 //
 // This doesn't work if others are trying to access flash at the same time,
 // e.g. XIP streamer, or the other core.
-bool __no_inline_not_in_flash_func(get_bootsel_button)() {
+bool __no_inline_not_in_flash_func(get_bootsel_button)(void) {
     const uint CS_PIN_INDEX = 1;
 
     // Must disable interrupts, as interrupt handlers may be in flash, and we
@@ -170,6 +170,8 @@ void board_init(void)
 
 void board_led_write(bool state)
 {
+  (void) state;
+
 #ifdef LED_PIN
   gpio_put(LED_PIN, state ? LED_STATE_ON : (1-LED_STATE_ON));
 #endif
@@ -192,6 +194,7 @@ int board_uart_read(uint8_t* buf, int len)
   }
   return len;
 #else
+  (void) buf; (void) len;
   return 0;
 #endif
 }
@@ -205,6 +208,7 @@ int board_uart_write(void const * buf, int len)
   }
   return len;
 #else
+  (void) buf; (void) len;
   return 0;
 #endif
 }

+ 1 - 1
src/class/audio/audio_device.c

@@ -1619,7 +1619,7 @@ static bool audiod_set_interface(uint8_t rhport, tusb_control_request_t const *
 
             // Reconfigure size of support FIFOs - this is necessary to avoid samples to get split in case of a wrap
 #if CFG_TUD_AUDIO_ENABLE_TYPE_I_ENCODING
-            const uint16_t active_fifo_depth = (audio->tx_supp_ff_sz_max / audio->n_bytes_per_sampe_tx) * audio->n_bytes_per_sampe_tx;
+            const uint16_t active_fifo_depth = (uint16_t) ((audio->tx_supp_ff_sz_max / audio->n_bytes_per_sampe_tx) * audio->n_bytes_per_sampe_tx);
             for (uint8_t cnt = 0; cnt < audio->n_tx_supp_ff; cnt++)
             {
               tu_fifo_config(&audio->tx_supp_ff[cnt], audio->tx_supp_ff[cnt].buffer, active_fifo_depth, 1, true);

+ 3 - 2
src/class/hid/hid_device.c

@@ -187,7 +187,8 @@ uint16_t hidd_open(uint8_t rhport, tusb_desc_interface_t const * desc_itf, uint1
   TU_VERIFY(TUSB_CLASS_HID == desc_itf->bInterfaceClass, 0);
 
   // len = interface + hid + n*endpoints
-  uint16_t const drv_len = sizeof(tusb_desc_interface_t) + sizeof(tusb_hid_descriptor_hid_t) + desc_itf->bNumEndpoints*sizeof(tusb_desc_endpoint_t);
+  uint16_t const drv_len = (uint16_t) (sizeof(tusb_desc_interface_t) + sizeof(tusb_hid_descriptor_hid_t) +
+                                       desc_itf->bNumEndpoints * sizeof(tusb_desc_endpoint_t));
   TU_ASSERT(max_len >= drv_len, 0);
 
   // Find available interface
@@ -408,7 +409,7 @@ bool hidd_xfer_cb(uint8_t rhport, uint8_t ep_addr, xfer_result_t result, uint32_
   // Received report
   else if (ep_addr == p_hid->ep_out)
   {
-    tud_hid_set_report_cb(instance, 0, HID_REPORT_TYPE_INVALID, p_hid->epout_buf, xferred_bytes);
+    tud_hid_set_report_cb(instance, 0, HID_REPORT_TYPE_INVALID, p_hid->epout_buf, (uint16_t) xferred_bytes);
     TU_ASSERT(usbd_edpt_xfer(rhport, p_hid->ep_out, p_hid->epout_buf, sizeof(p_hid->epout_buf)));
   }
 

+ 6 - 6
src/class/midi/midi_device.c

@@ -127,7 +127,7 @@ uint32_t tud_midi_n_available(uint8_t itf, uint8_t cable_num)
   midid_stream_t const* stream = &midi->stream_read;
 
   // when using with packet API stream total & index are both zero
-  return tu_fifo_count(&midi->rx_ff) + (stream->total - stream->index);
+  return tu_fifo_count(&midi->rx_ff) + (uint8_t) (stream->total - stream->index);
 }
 
 uint32_t tud_midi_n_stream_read(uint8_t itf, uint8_t cable_num, void* buffer, uint32_t bufsize)
@@ -179,7 +179,7 @@ uint32_t tud_midi_n_stream_read(uint8_t itf, uint8_t cable_num, void* buffer, ui
     }
 
     // Copy data up to bufsize
-    uint32_t const count = tu_min32(stream->total - stream->index, bufsize);
+    uint8_t const count = (uint8_t) tu_min32(stream->total - stream->index, bufsize);
 
     // Skip the header (1st byte) in the buffer
     memcpy(buf8, stream->buffer + 1 + stream->index, count);
@@ -276,13 +276,13 @@ uint32_t tud_midi_n_stream_write(uint8_t itf, uint8_t cable_num, uint8_t const*
       else if ( (msg >= 0x8 && msg <= 0xB) || msg == 0xE )
       {
         // Channel Voice Messages
-        stream->buffer[0] = (cable_num << 4) | msg;
+        stream->buffer[0] = (uint8_t) ((cable_num << 4) | msg);
         stream->total = 4;
       }
       else if ( msg == 0xC || msg == 0xD)
       {
         // Channel Voice Messages, two-byte variants (Program Change and Channel Pressure)
-        stream->buffer[0] = (cable_num << 4) | msg;
+        stream->buffer[0] = (uint8_t) ((cable_num << 4) | msg);
         stream->total = 3;
       }
       else if ( msg == 0xf )
@@ -312,7 +312,7 @@ uint32_t tud_midi_n_stream_write(uint8_t itf, uint8_t cable_num, uint8_t const*
       else
       {
         // Pack individual bytes if we don't support packing them into words.
-        stream->buffer[0] = cable_num << 4 | 0xf;
+        stream->buffer[0] = (uint8_t) (cable_num << 4 | 0xf);
         stream->buffer[2] = 0;
         stream->buffer[3] = 0;
         stream->index = 2;
@@ -513,7 +513,7 @@ bool midid_xfer_cb(uint8_t rhport, uint8_t ep_addr, xfer_result_t result, uint32
   // receive new data
   if ( ep_addr == p_midi->ep_out )
   {
-    tu_fifo_write_n(&p_midi->rx_ff, p_midi->epout_buf, xferred_bytes);
+    tu_fifo_write_n(&p_midi->rx_ff, p_midi->epout_buf, (uint16_t) xferred_bytes);
 
     // invoke receive callback if available
     if (tud_midi_rx_cb) tud_midi_rx_cb(itf);