Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 10 additions & 1 deletion .PVS-Studio/.pvsconfig
Original file line number Diff line number Diff line change
@@ -1 +1,10 @@
//-V::2506,2514
//V_EXCLUDE_PATH */iar/cxarm*
//V_EXCLUDE_PATH */pico-sdk/*

//-V::2506 MISRA. A function should have a single point of exit at the end.
//-V::2514 MISRA. Unions should not be used.
//-V:memcpy:2547 [MISRA-C-17.7] The return value of non-void function 'memcpy' should be used.
//-V:printf:2547 [MISRA-C-17.7] The return value of non-void function 'printf' should be used.
//-V::2600 [MISRA-C-21.6] The function with the 'printf' name should not be used.
//+V2614 DISABLE_LENGHT_LIMIT_CHECK:YES
//-V:memcpy:2628 Pointer arguments to the 'memcpy' function should be pointers to qualified or unqualified versions of compatible types.
102 changes: 62 additions & 40 deletions .clang-format
Original file line number Diff line number Diff line change
@@ -1,66 +1,88 @@
# Generated from CLion C/C++ Code Style settings
---
Language: Cpp
BasedOnStyle: LLVM
AccessModifierOffset: -2
AlignAfterOpenBracket: Align
AlignConsecutiveAssignments: None
AlignOperands: Align
AlignAfterOpenBracket: AlwaysBreak
AlignConsecutiveAssignments:
Enabled: true
AcrossEmptyLines: false
AcrossComments: false
AlignConsecutiveBitFields:
Enabled: true
AcrossEmptyLines: false
AcrossComments: false
AlignConsecutiveDeclarations:
Enabled: true
AcrossEmptyLines: false
AcrossComments: false
AlignConsecutiveMacros:
Enabled: true
AcrossEmptyLines: true
AcrossComments: false
AlignConsecutiveShortCaseStatements:
Enabled: true
AcrossEmptyLines: true
AcrossComments: true
AlignCaseColons: false
AlignEscapedNewlines: LeftWithLastLine
AlignOperands: true
AlignTrailingComments:
Kind: Always
OverEmptyLines: 2
AllowAllArgumentsOnNextLine: false
AllowAllConstructorInitializersOnNextLine: false
AllowAllParametersOfDeclarationOnNextLine: false
AllowShortBlocksOnASingleLine: Always
AllowShortCaseLabelsOnASingleLine: false
AllowShortFunctionsOnASingleLine: All
AllowShortIfStatementsOnASingleLine: Always
AllowShortLambdasOnASingleLine: All
AllowShortLoopsOnASingleLine: true
AlwaysBreakAfterReturnType: None
AllowShortBlocksOnASingleLine: Empty
AllowShortCaseExpressionOnASingleLine: true
AllowShortCaseLabelsOnASingleLine: true
AllowShortFunctionsOnASingleLine: None
AllowShortIfStatementsOnASingleLine: Never
AlwaysBreakTemplateDeclarations: Yes
BreakBeforeBraces: Custom
BraceWrapping:
AfterCaseLabel: false
AfterClass: false
AfterControlStatement: Never
AfterControlStatement: false
AfterEnum: false
AfterFunction: false
AfterNamespace: false
AfterStruct: false
AfterUnion: false
BeforeCatch: false
AfterExternBlock: false
BeforeCatch: true
BeforeElse: false
IndentBraces: false
SplitEmptyFunction: false
BeforeLambdaBody: false
BeforeWhile: false
SplitEmptyFunction: true
SplitEmptyRecord: true
BreakBeforeBinaryOperators: None
BreakBeforeTernaryOperators: true
BreakConstructorInitializers: BeforeColon
BreakInheritanceList: BeforeColon
ColumnLimit: 0
CompactNamespaces: false
ContinuationIndentWidth: 4
SplitEmptyNamespace: true
BracedInitializerIndentWidth: 2
BreakConstructorInitializers: AfterColon
BreakConstructorInitializersBeforeComma: false
ColumnLimit: 120
ConstructorInitializerAllOnOneLineOrOnePerLine: false
Cpp11BracedListStyle: true
IncludeCategories:
- Regex: '^<.*'
Priority: 1
- Regex: '^".*'
Priority: 2
- Regex: '.*'
Priority: 3
IncludeIsMainRegex: '([-_](test|unittest))?$'
InsertBraces: true
IndentCaseLabels: true
IndentPPDirectives: BeforeHash
IndentWidth: 2
KeepEmptyLinesAtTheStartOfBlocks: true
InsertNewlineAtEOF: true
MacroBlockBegin: ''
MacroBlockEnd: ''
MaxEmptyLinesToKeep: 2
NamespaceIndentation: All
ObjCSpaceAfterProperty: false
ObjCSpaceBeforeProtocolList: true
PointerAlignment: Right
ReflowComments: false
SpaceAfterCStyleCast: true
SpaceAfterLogicalNot: false
SpaceAfterTemplateKeyword: false
SpaceBeforeAssignmentOperators: true
SpaceBeforeCpp11BracedList: false
SpaceBeforeCtorInitializerColon: true
SpaceBeforeInheritanceColon: true
SpaceBeforeParens: ControlStatements
SpaceBeforeRangeBasedForLoopColon: false
SpaceInEmptyParentheses: false
SpacesBeforeTrailingComments: 0
SpacesInAngles: false
SpacesInConditionalStatement: false
SpacesInCStyleCastParentheses: false
SpacesInContainerLiterals: true
SpacesInParentheses: false
SpacesInSquareBrackets: false
TabWidth: 2
UseTab: Never
...
3 changes: 2 additions & 1 deletion .github/workflows/build_util.yml
Original file line number Diff line number Diff line change
Expand Up @@ -60,8 +60,9 @@ jobs:
- name: Build
env:
IAR_LMS_BEARER_TOKEN: ${{ secrets.IAR_LMS_BEARER_TOKEN }}
TOOLCHAIN: ${{ inputs.toolchain }}
run: |
if [ "${{ inputs.toolchain }}" == "esp-idf" ]; then
if [ "$TOOLCHAIN" == "esp-idf" ]; then
docker run --rm -v $PWD:/project -w /project espressif/idf:tinyusb python tools/build.py ${{ matrix.arg }}
else
python tools/build.py -s ${{ inputs.build-system }} ${{ steps.setup-toolchain.outputs.build_option }} ${{ steps.set-one-per-family.outputs.build_option }} ${{ matrix.arg }}
Expand Down
3 changes: 2 additions & 1 deletion .github/workflows/static_analysis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -183,7 +183,8 @@ jobs:
--define sonar.cfamily.compile-commands=${{ env.BUILD_WRAPPER_OUT_DIR }}/compile_commands.json

IAR-CStat:
if: github.repository_owner == 'hathach'
#if: github.repository_owner == 'hathach'
if: false
runs-on: ubuntu-latest
strategy:
fail-fast: false
Expand Down
6 changes: 4 additions & 2 deletions README.rst
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
|Build Status| |CircleCI Status| |Documentation Status| |Fuzzing Status| |License|
|Build Status| |CircleCI Status| |Documentation Status| |Static Analysis| |Fuzzing Status| |License|

Sponsors
========
Expand Down Expand Up @@ -252,11 +252,13 @@ The following tools are provided freely to support the development of the TinyUS


.. |Build Status| image:: https://github.com/hathach/tinyusb/actions/workflows/build.yml/badge.svg
:target: https://github.com/hathach/tinyusb/actions
:target: https://github.com/hathach/tinyusb/actions/workflows/build.yml
.. |CircleCI Status| image:: https://dl.circleci.com/status-badge/img/circleci/4AYHvUhFxdnY4rA7LEsdqW/QmrpoL2AjGqetvFQNqtWyq/tree/master.svg?style=svg
:target: https://dl.circleci.com/status-badge/redirect/circleci/4AYHvUhFxdnY4rA7LEsdqW/QmrpoL2AjGqetvFQNqtWyq/tree/master
.. |Documentation Status| image:: https://readthedocs.org/projects/tinyusb/badge/?version=latest
:target: https://docs.tinyusb.org/en/latest/?badge=latest
.. |Static Analysis| image:: https://github.com/hathach/tinyusb/actions/workflows/static_analysis.yml/badge.svg
:target: https://github.com/hathach/tinyusb/actions/workflows/static_analysis.yml
.. |Fuzzing Status| image:: https://oss-fuzz-build-logs.storage.googleapis.com/badges/tinyusb.svg
:target: https://oss-fuzz-build-logs.storage.googleapis.com/index.html#tinyusb
.. |License| image:: https://img.shields.io/badge/license-MIT-brightgreen.svg
Expand Down
8 changes: 6 additions & 2 deletions examples/device/audio_4_channel_mic/src/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -156,7 +156,9 @@ void tud_resume_cb(void) {
void audio_task(void) {
static uint32_t start_ms = 0;
uint32_t curr_ms = board_millis();
if (start_ms == curr_ms) return;// not enough time
if (start_ms == curr_ms) {
return; // not enough time
}
start_ms = curr_ms;
tud_audio_write(i2s_dummy_buffer, AUDIO_SAMPLE_RATE / 1000 * CFG_TUD_AUDIO_FUNC_1_N_BYTES_PER_SAMPLE_TX * CFG_TUD_AUDIO_FUNC_1_N_CHANNELS_TX);
}
Expand Down Expand Up @@ -406,7 +408,9 @@ void led_blinking_task(void) {
static bool led_state = false;

// Blink every interval ms
if (board_millis() - start_ms < blink_interval_ms) return;// not enough time
if (board_millis() - start_ms < blink_interval_ms) {
return; // not enough time
}
start_ms += blink_interval_ms;

board_led_write(led_state);
Expand Down
12 changes: 8 additions & 4 deletions examples/device/audio_4_channel_mic/src/usb_descriptors.c
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,7 @@ enum {
};

// array of pointer to string descriptors
char const* string_desc_arr [] = {
static char const* string_desc_arr [] = {
(const char[]) { 0x09, 0x04 }, // 0: is supported language is English (0x0409)
"PaniRCorp", // 1: Manufacturer
"MicNode_4_Ch", // 2: Product
Expand Down Expand Up @@ -156,18 +156,22 @@ uint16_t const *tud_descriptor_string_cb(uint8_t index, uint16_t langid) {
// Note: the 0xEE index string is a Microsoft OS 1.0 Descriptors.
// https://docs.microsoft.com/en-us/windows-hardware/drivers/usbcon/microsoft-defined-usb-descriptors

if ( !(index < sizeof(string_desc_arr) / sizeof(string_desc_arr[0])) ) return NULL;
if ( !(index < sizeof(string_desc_arr) / sizeof(string_desc_arr[0])) ) {
return NULL;
}

const char *str = string_desc_arr[index];

// Cap at max char
chr_count = strlen(str);
size_t const max_count = sizeof(_desc_str) / sizeof(_desc_str[0]) - 1; // -1 for string type
if ( chr_count > max_count ) chr_count = max_count;
if ( chr_count > max_count ) {
chr_count = max_count;
}

// Convert ASCII string into UTF-16
for ( size_t i = 0; i < chr_count; i++ ) {
_desc_str[1 + i] = str[i];
_desc_str[1 + i] = (uint16_t) str[i];
}
break;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -156,14 +156,18 @@ uint16_t const *tud_descriptor_string_cb(uint8_t index, uint16_t langid) {
// Note: the 0xEE index string is a Microsoft OS 1.0 Descriptors.
// https://docs.microsoft.com/en-us/windows-hardware/drivers/usbcon/microsoft-defined-usb-descriptors

if ( !(index < sizeof(string_desc_arr) / sizeof(string_desc_arr[0])) ) return NULL;
if (!(index < sizeof(string_desc_arr) / sizeof(string_desc_arr[0]))) {
return NULL;
}

const char *str = string_desc_arr[index];

// Cap at max char
chr_count = strlen(str);
size_t const max_count = sizeof(_desc_str) / sizeof(_desc_str[0]) - 1; // -1 for string type
if ( chr_count > max_count ) chr_count = max_count;
if ( chr_count > max_count ) {
chr_count = max_count;
}

// Convert ASCII string into UTF-16
for ( size_t i = 0; i < chr_count; i++ ) {
Expand Down
8 changes: 6 additions & 2 deletions examples/device/audio_test/src/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,9 @@ void tud_resume_cb(void) {
void audio_task(void) {
static uint32_t start_ms = 0;
uint32_t curr_ms = board_millis();
if (start_ms == curr_ms) return;// not enough time
if (start_ms == curr_ms) {
return; // not enough time
}
start_ms = curr_ms;
for (size_t cnt = 0; cnt < sizeof(test_buffer_audio) / 2; cnt++) {
test_buffer_audio[cnt] = startVal++;
Expand Down Expand Up @@ -400,7 +402,9 @@ void led_blinking_task(void) {
static bool led_state = false;

// Blink every interval ms
if (board_millis() - start_ms < blink_interval_ms) return;// not enough time
if (board_millis() - start_ms < blink_interval_ms) {
return; // not enough time
}
start_ms += blink_interval_ms;

board_led_write(led_state);
Expand Down
8 changes: 6 additions & 2 deletions examples/device/audio_test/src/usb_descriptors.c
Original file line number Diff line number Diff line change
Expand Up @@ -158,14 +158,18 @@ uint16_t const *tud_descriptor_string_cb(uint8_t index, uint16_t langid) {
// Note: the 0xEE index string is a Microsoft OS 1.0 Descriptors.
// https://docs.microsoft.com/en-us/windows-hardware/drivers/usbcon/microsoft-defined-usb-descriptors

if ( !(index < sizeof(string_desc_arr) / sizeof(string_desc_arr[0])) ) return NULL;
if (!(index < sizeof(string_desc_arr) / sizeof(string_desc_arr[0]))) {
return NULL;
}

const char *str = string_desc_arr[index];

// Cap at max char
chr_count = strlen(str);
size_t const max_count = sizeof(_desc_str) / sizeof(_desc_str[0]) - 1; // -1 for string type
if ( chr_count > max_count ) chr_count = max_count;
if (chr_count > max_count) {
chr_count = max_count;
}

// Convert ASCII string into UTF-16
for ( size_t i = 0; i < chr_count; i++ ) {
Expand Down
8 changes: 6 additions & 2 deletions examples/device/audio_test_freertos/src/usb_descriptors.c
Original file line number Diff line number Diff line change
Expand Up @@ -158,14 +158,18 @@ uint16_t const *tud_descriptor_string_cb(uint8_t index, uint16_t langid) {
// Note: the 0xEE index string is a Microsoft OS 1.0 Descriptors.
// https://docs.microsoft.com/en-us/windows-hardware/drivers/usbcon/microsoft-defined-usb-descriptors

if ( !(index < sizeof(string_desc_arr) / sizeof(string_desc_arr[0])) ) return NULL;
if (!(index < sizeof(string_desc_arr) / sizeof(string_desc_arr[0]))) {
return NULL;
}

const char *str = string_desc_arr[index];

// Cap at max char
chr_count = strlen(str);
size_t const max_count = sizeof(_desc_str) / sizeof(_desc_str[0]) - 1; // -1 for string type
if ( chr_count > max_count ) chr_count = max_count;
if (chr_count > max_count) {
chr_count = max_count;
}

// Convert ASCII string into UTF-16
for ( size_t i = 0; i < chr_count; i++ ) {
Expand Down
8 changes: 6 additions & 2 deletions examples/device/audio_test_multi_rate/src/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -147,7 +147,9 @@ void tud_resume_cb(void) {
void audio_task(void) {
static uint32_t start_ms = 0;
uint32_t curr_ms = board_millis();
if (start_ms == curr_ms) return;// not enough time
if (start_ms == curr_ms) {
return; // not enough time
}
start_ms = curr_ms;
// 16bit
if (bytesPerSample == 2) {
Expand Down Expand Up @@ -612,7 +614,9 @@ void led_blinking_task(void) {
static bool led_state = false;

// Blink every interval ms
if (board_millis() - start_ms < blink_interval_ms) return;// not enough time
if (board_millis() - start_ms < blink_interval_ms) {
return; // not enough time
}
start_ms += blink_interval_ms;

board_led_write(led_state);
Expand Down
8 changes: 6 additions & 2 deletions examples/device/audio_test_multi_rate/src/usb_descriptors.c
Original file line number Diff line number Diff line change
Expand Up @@ -213,14 +213,18 @@ uint16_t const *tud_descriptor_string_cb(uint8_t index, uint16_t langid) {
// Note: the 0xEE index string is a Microsoft OS 1.0 Descriptors.
// https://docs.microsoft.com/en-us/windows-hardware/drivers/usbcon/microsoft-defined-usb-descriptors

if ( !(index < sizeof(string_desc_arr) / sizeof(string_desc_arr[0])) ) return NULL;
if (!(index < sizeof(string_desc_arr) / sizeof(string_desc_arr[0]))) {
return NULL;
}

const char *str = string_desc_arr[index];

// Cap at max char
chr_count = strlen(str);
size_t const max_count = sizeof(_desc_str) / sizeof(_desc_str[0]) - 1; // -1 for string type
if ( chr_count > max_count ) chr_count = max_count;
if (chr_count > max_count) {
chr_count = max_count;
}

// Convert ASCII string into UTF-16
for ( size_t i = 0; i < chr_count; i++ ) {
Expand Down
4 changes: 2 additions & 2 deletions examples/device/audio_test_multi_rate/src/usb_descriptors.h
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,8 @@
*
*/

#ifndef _USB_DESCRIPTORS_H_
#define _USB_DESCRIPTORS_H_
#ifndef USB_DESCRIPTORS_H_
#define USB_DESCRIPTORS_H_

// #include "tusb.h"

Expand Down
Loading