13 #include "esp_system.h" |
13 #include "esp_system.h" |
14 #include "driver/gpio.h" |
14 #include "driver/gpio.h" |
15 #include "freertos/task.h" |
15 #include "freertos/task.h" |
16 #include "esp_heap_caps.h" |
16 #include "esp_heap_caps.h" |
17 #include "soc/spi_reg.h" |
17 #include "soc/spi_reg.h" |
|
18 #include "rom/gpio.h" |
18 |
19 |
19 // ==================================================== |
20 // ==================================================== |
20 // ==== Global variables, default values ============== |
21 // ==== Global variables, default values ============== |
21 |
22 |
22 // Converts colors to grayscale if set to 1 |
23 // Converts colors to grayscale if set to 1 |
861 |
862 |
862 //================= |
863 //================= |
863 void TFT_PinsInit() |
864 void TFT_PinsInit() |
864 { |
865 { |
865 // Route all used pins to GPIO control |
866 // Route all used pins to GPIO control |
866 esp_rom_gpio_pad_select_gpio(PIN_NUM_CS); |
867 gpio_pad_select_gpio(PIN_NUM_CS); |
867 esp_rom_gpio_pad_select_gpio(PIN_NUM_MISO); |
868 gpio_pad_select_gpio(PIN_NUM_MISO); |
868 esp_rom_gpio_pad_select_gpio(PIN_NUM_MOSI); |
869 gpio_pad_select_gpio(PIN_NUM_MOSI); |
869 esp_rom_gpio_pad_select_gpio(PIN_NUM_CLK); |
870 gpio_pad_select_gpio(PIN_NUM_CLK); |
870 esp_rom_gpio_pad_select_gpio(PIN_NUM_DC); |
871 gpio_pad_select_gpio(PIN_NUM_DC); |
871 |
872 |
872 gpio_set_direction(PIN_NUM_MISO, GPIO_MODE_INPUT); |
873 gpio_set_direction(PIN_NUM_MISO, GPIO_MODE_INPUT); |
873 gpio_set_pull_mode(PIN_NUM_MISO, GPIO_PULLUP_ONLY); |
874 gpio_set_pull_mode(PIN_NUM_MISO, GPIO_PULLUP_ONLY); |
874 gpio_set_direction(PIN_NUM_CS, GPIO_MODE_OUTPUT); |
875 gpio_set_direction(PIN_NUM_CS, GPIO_MODE_OUTPUT); |
875 gpio_set_direction(PIN_NUM_MOSI, GPIO_MODE_OUTPUT); |
876 gpio_set_direction(PIN_NUM_MOSI, GPIO_MODE_OUTPUT); |
876 gpio_set_direction(PIN_NUM_CLK, GPIO_MODE_OUTPUT); |
877 gpio_set_direction(PIN_NUM_CLK, GPIO_MODE_OUTPUT); |
877 gpio_set_direction(PIN_NUM_DC, GPIO_MODE_OUTPUT); |
878 gpio_set_direction(PIN_NUM_DC, GPIO_MODE_OUTPUT); |
878 gpio_set_level(PIN_NUM_DC, 0); |
879 gpio_set_level(PIN_NUM_DC, 0); |
879 #if USE_TOUCH |
880 #if USE_TOUCH |
880 esp_rom_gpio_pad_select_gpio(PIN_NUM_TCS); |
881 gpio_pad_select_gpio(PIN_NUM_TCS); |
881 gpio_set_direction(PIN_NUM_TCS, GPIO_MODE_OUTPUT); |
882 gpio_set_direction(PIN_NUM_TCS, GPIO_MODE_OUTPUT); |
882 #endif |
883 #endif |
883 #if PIN_NUM_BCKL |
884 #if PIN_NUM_BCKL |
884 esp_rom_gpio_pad_select_gpio(PIN_NUM_BCKL); |
885 gpio_pad_select_gpio(PIN_NUM_BCKL); |
885 gpio_set_direction(PIN_NUM_BCKL, GPIO_MODE_OUTPUT); |
886 gpio_set_direction(PIN_NUM_BCKL, GPIO_MODE_OUTPUT); |
886 gpio_set_level(PIN_NUM_BCKL, PIN_BCKL_OFF); |
887 gpio_set_level(PIN_NUM_BCKL, PIN_BCKL_OFF); |
887 #endif |
888 #endif |
888 |
889 |
889 #if PIN_NUM_RST |
890 #if PIN_NUM_RST |
890 esp_rom_gpio_pad_select_gpio(PIN_NUM_RST); |
891 gpio_pad_select_gpio(PIN_NUM_RST); |
891 gpio_set_direction(PIN_NUM_RST, GPIO_MODE_OUTPUT); |
892 gpio_set_direction(PIN_NUM_RST, GPIO_MODE_OUTPUT); |
892 gpio_set_level(PIN_NUM_RST, 0); |
893 gpio_set_level(PIN_NUM_RST, 0); |
893 #endif |
894 #endif |
894 } |
895 } |
895 |
896 |