diff --git a/zk/ESP_ERROR_CHECK.md b/zk/ESP_ERROR_CHECK.md new file mode 100644 index 0000000..117022b --- /dev/null +++ b/zk/ESP_ERROR_CHECK.md @@ -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`. diff --git a/zk/Macros_in_C.md b/zk/Macros_in_C.md new file mode 100644 index 0000000..2b37f99 --- /dev/null +++ b/zk/Macros_in_C.md @@ -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. diff --git a/zk/Objects_in_C.md b/zk/Objects_in_C.md new file mode 100644 index 0000000..454a045 --- /dev/null +++ b/zk/Objects_in_C.md @@ -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. diff --git a/zk/Programming_ESP32_with_Expressif_IoT_Development_Framework.md b/zk/Programming_ESP32_with_Expressif_IoT_Development_Framework.md index 8322b65..b76a086 100644 --- a/zk/Programming_ESP32_with_Expressif_IoT_Development_Framework.md +++ b/zk/Programming_ESP32_with_Expressif_IoT_Development_Framework.md @@ -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