|
|
12 лет назад | |
|---|---|---|
| demos | 12 лет назад | |
| docs | 13 лет назад | |
| tests | 12 лет назад | |
| tinyusb | 12 лет назад | |
| tools | 12 лет назад | |
| vendor | 12 лет назад | |
| .travis.yml | 12 лет назад | |
| Doxyfile | 12 лет назад | |
| readme.md | 12 лет назад | |
| tinyusb.Doxyfile | 12 лет назад | |
| todo.md | 13 лет назад |
tinyusb is an open-source (BSD-licensed) USB Host/Device/OTG stack for embedded micro-controller. It is developed using Test-Driven Development (TDD) approach to eliminate bugs as soon as possible.
designed to be simple and run out-of-the-box provided the configuration is correct.
tinyusb is designed to be OS-ware and run across OS vendors, thanks to its OS Abstraction Layer (OSAL). However, it can also run without an OS (OSAL will be expanded to be a state machine in this case). Currently the following OS can be run with tinyusb (out of the box).
Although tinyusb is still in early stage of developing, but most of the code can run out of the box with supported boards.
coming soon ...
The following toolchain is supported
this code base can run out of the box with the following boards
C is a dangerous language by itself, plus tinyusb make use of goodies features of C99, which saves a tons of code lines (also means save a tons of bugs). However, those features can be misused and pave the way for bugs sneaking into. Therefore, to minimize bugs, the author try to comply with published Coding Standards like:
Where is possible, standards are followed but it is almost impossible to follow all of these without making some exceptions. I am pretty sure this code base violates more than what are described below, if you can find any, please report it to me or file an issue on github.
MISRA-C is well respected & a bar for industrial coding standard.
is a small & easy to remember but yet powerful coding guideline. Most (if not all) of the rules here are included in JPL. Because it is very small, all the rules will be listed here, those with italic are compliant, bold are violated.
Restrict to simple control flow constructs
yes, I hate goto statement, therefore there is none of those here
Give all loops a fixed upper-bound
one of my favorite rule
Do not use dynamic memory allocation after initialization
the tinyusb uses the static memory for all of its data.
Limit functions to no more than 60 lines of text
60 is a little bit too strict, I will update the relaxing number later
Use minimally two assertions per function on average
not sure the exact number, but I use a tons of those assert
Declare data objects at the smallest possible level of scope
one of the best & easiest rule to follow
Check the return value of non-void functions, and check the validity of function parameters
I did check all of the public application API's parameters. For internal API, calling function needs to trust their caller to reduce duplicated check.
Limit the use of the preprocessor to file inclusion and simple macros
Although I prefer inline function, however C macros are far powerful than that. I simply cannot hold myself to use, for example X-Macro technique to simplify code.
Limit the use of pointers. Use no more than two levels of dereferencing per expression
never intend to get in trouble with complex pointer dereferencing.
Compile with all warnings enabled, and use one or more source code analyzers
I try to use all the defensive options of gnu, let me know if I miss some.
-pedantic -Wextra -Wswitch-default -Wunsafe-loop-optimizations -Wcast-align -Wlogical-op -Wpacked-bitfield-compat -Wpadded -Wnested-externs -Wredundant-decls -Winline -Wpacked
coming soon ...
If you find my little USB stack is useful, please take some time to file any issues that you encountered. It is not necessary to be a software bug, it can be a question, request, suggestion etc. We can consider each github's issue as a forum's topic. Alternatively, you can buy me a cup of coffee if you happen to be in Hochiminh city.
BSD license for most of the code base, but each file is individually licensed especially those in /vendor folder. Please make sure you understand all the license term for files you use in your project.