esp-idf notes

This commit is contained in:
Thomas Bishop 2025-12-17 18:22:42 +00:00
parent c10e5312b8
commit d72ec5c812
4 changed files with 70 additions and 0 deletions

13
zk/ESP_ERROR_CHECK.md Normal file
View file

@ -0,0 +1,13 @@
---
tags:
- C
- ESP32
- ESP-IDF
---
A macro for handling errors arising from the ESP-IDF API's functions.
If a function returns anything other than `ESP_OK`, the macro prints a detailed
error message and then calls `abort()` to halt execution.
To achieve the same without aborting use `ESP_ERROR_CHECK_WITHOUT_ABORT`.

38
zk/Macros_in_C.md Normal file
View file

@ -0,0 +1,38 @@
---
tags:
- C
---
Think of them as a find and replace that takes place before compilation.
They are ephemeral and never make it into the compiled code.
With a macro, the computation happens "inline" without having to call functions
which make costly alterations to the stack.
A function and function call such as:
```c
int square(int x) { return x * x; }
int a = square(5);
```
Can be reduced to a macro:
```c
#define SQUARE(x) ((x) * (x))
int a = SQUARE(5);
```
Which, because it uses `#` is processed at the
[pre-processor compilation stage](./C_compilation_process.md), becomes:
```c
int a = ((5) * (5));
```
after pre-processing but before compilation.
## Syntax
`#define` always creates a macro but there are different types.

18
zk/Objects_in_C.md Normal file
View file

@ -0,0 +1,18 @@
---
tags: ["C"]
---
Basically, a technical term from the C standard for anything stored in memory.
(In practice, interchangeable with 'variable' or 'memory'.)
Inclusive of variables, structs, [arrays](./Arrays_in_C.md), array entities
`arr[2]` etc.
To be distinguished from entities which do not exist in memory such as type
definitions, [macros](./Macros_in_C.md'), things that are handled by the
pre-processor.
Where "memory" can be thought of **anything that survives compilation**.
They have nothing to do with "complex data types" that we would associate with
OOP.

View file

@ -3,6 +3,7 @@ tags:
- micro-controllers
- C
- ESP32
- ESP-IDF
---
> The ESP-IDF is the SDK, provided by Expressif, for programming the ESP32 with