1 | // espy Copyright (c) 2023 Josh Stockin <josh@joshstock.in> |
2 | // [https://joshstock.in] [https://github.com/joshuas3] |
3 | // |
4 | // This software is licensed and distributed under the terms of the MIT License. |
5 | // See the MIT License in the LICENSE file of this project's root folder. |
6 | // |
7 | // This comment block and its contents, including this disclaimer, MUST be |
8 | // preserved in all copies or distributions of this software's source. |
9 |
|
10 |
|
11 | // Filename: main.c |
12 | // Description: Program entry point, runs setups functions |
13 |
|
14 |
|
15 | #include "esp_err.h" |
16 | #include "esp_log.h" |
17 | #include "driver/gpio.h" |
18 |
|
19 | #include "input.h" |
20 | #include "pins.h" |
21 |
|
22 |
|
23 | static const char* TAG = "main.c"; |
24 |
|
25 |
|
26 | void indicate_error ( void ) { |
27 |
|
28 | gpio_reset_pin( LED_RED ); |
29 |
|
30 | gpio_config_t led_pin_conf = { |
31 | .pin_bit_mask = (1ULL << LED_RED), |
32 | .mode = GPIO_MODE_OUTPUT, |
33 | }; |
34 | gpio_config( &led_pin_conf ); |
35 |
|
36 | gpio_set_level( LED_RED, 1 ); |
37 |
|
38 | } |
39 |
|
40 |
|
41 | void app_main( void ) { |
42 |
|
43 | #ifdef DEBUG_MODE |
44 | #warning DEBUG_MODE active! |
45 | esp_log_level_set( "*", ESP_LOG_DEBUG ); |
46 | #else |
47 | esp_log_level_set( "*", ESP_LOG_INFO ); |
48 | #endif |
49 |
|
50 | esp_err_t ret = ESP_OK; |
51 |
|
52 | ESP_LOGI( TAG, "main thread enter" ); |
53 |
|
54 | ESP_LOGI( TAG, "installing GPIO ISR service" ); |
55 | gpio_install_isr_service( 0 ); |
56 |
|
57 | ESP_LOGI( TAG, "running input setup" ); |
58 | if ( (ret = setup_radio_and_rotenc_input()) != ESP_OK ) { |
59 | ESP_ERROR_CHECK_WITHOUT_ABORT( ret ); |
60 | indicate_error(); |
61 | return; |
62 | } |
63 | /* |
64 | |
65 | ESP_LOGI( TAG, "running control hardware setup" ); |
66 | if ( (ret = setup_control_hardware()) != ESP_OK ) { |
67 | ESP_ERROR_CHECK_WITHOUT_ABORT( ret ); |
68 | indicate_error(); |
69 | return; |
70 | } |
71 | |
72 | ESP_LOGI( TAG, "running control loop setup" ); |
73 | if ( (ret = setup_control_loop()) != ESP_OK ) { |
74 | ESP_ERROR_CHECK_WITHOUT_ABORT( ret ); |
75 | indicate_error(); |
76 | return; |
77 | } |
78 | */ |
79 |
|
80 | ESP_LOGI( TAG, "main thread exit" ); |
81 | return; |
82 |
|
83 | } |
84 |
|