EasyManuals Logo

Espressif ESP32-S2 User Manual

Espressif ESP32-S2
1695 pages
To Next Page IconTo Next Page
To Next Page IconTo Next Page
To Previous Page IconTo Previous Page
To Previous Page IconTo Previous Page
Page #1582 background imageLoading...
Page #1582 background image
Chapter 6. Contributions Guide
because MSYS2 uses Unix-style line endings, it is often easier to configure your text editor to use LF (Unix style)
endings when editing ESP-IDF source files.
If you accidentally have some commits in your branch that add LF endings, you can convert them to Unix by running
this command in an MSYS2 or Unix terminal (change directory to the IDF working directory and check the correct
branch is currently checked out, beforehand):
git rebase --exec 'git diff-tree --no-commit-id --name-only -r HEAD | xargs
,dos2unix && git commit -a --amend --no-edit --allow-empty' master
(Note that this line rebases on master, change the branch name at the end to rebase on another branch.)
For updating a single commit, its possible to run dos2unix FILENAME and then run git commit --amend
Formatting Your Code You can use astyle program to format your code according to the above recommen-
dations.
If you are writing a file from scratch, or doing a complete rewrite, feel free to re-format the entire file. If you are
changing a small portion of file, dont re-format the code you didnt change. This will help others when they review
your changes.
To re-format a file, run:
tools/format.sh components/my_component/file.c
Type Definitions Should be snake_case, ending with _t suffix:
typedef int signed_32_bit_t;
Enum Enums should be defined through the typedef and be namespaced:
typedef enum
{
MODULE_FOO_ONE,
MODULE_FOO_TWO,
MODULE_FOO_THREE
} module_foo_t;
Assertions The standard C assert() function, defined in assert.h should be used to check conditions that
should be true in source code. In the default configuration, an assert condition that returns false or 0 will call
abort() and trigger a Fatal Error.
assert() should only be used to detect unrecoverable errors due to a serious internal logic bug or corruption,
where its not possible for the program to continue. For recoverable errors, including errors that are possible due
to invalid external input, an error value should be returned.
Note: When asserting a value of type esp_err_t``is equal to ``ESP_OK, use the ESP_ERROR_CHECK
macro instead of an assert().
Its possible to configure ESP-IDF projects with assertions disabled (see CON-
FIG_COMPILER_OPTIMIZATION_ASSERTION_LEVEL). Therefore, functions called in an assert() statement
should not have side-eects.
Its also necessary to use particular techniques to avoid variable set but not usedwarnings when assertions are
disabled, due to code patterns such as:
Espressif Systems 1571
Submit Document Feedback
Release v4.4

Table of Contents

Questions and Answers:

Question and Answer IconNeed help?

Do you have a question about the Espressif ESP32-S2 and is the answer not in the manual?

Espressif ESP32-S2 Specifications

General IconGeneral
BrandEspressif
ModelESP32-S2
CategorySingle board computers
LanguageEnglish