board.h
Go to the documentation of this file.
1 /*
2  * Copyright (C) 2018 Gunar Schorcht
3  *
4  * This file is subject to the terms and conditions of the GNU Lesser
5  * General Public License v2.1. See the file LICENSE in the top level
6  * directory for more details.
7  */
8 
45 #ifndef BOARD_H
46 #define BOARD_H
47 
48 #include <stdint.h>
49 
55 #if !MODULE_ESP32_WROVER_KIT_CAMERA || DOXYGEN
56 #define LED0_PIN GPIO0
57 #define LED0_ACTIVE (1)
58 #endif
59 
60 #if !MODULE_SDCARD_SPI || DOXYGEN
61 #define LED1_PIN GPIO2
62 #define LED1_ACTIVE (1)
63 #endif
64 
65 #if !MODULE_ESP32_WROVER_KIT_CAMERA || DOXYGEN
66 #define LED2_PIN GPIO4
67 #define LED2_ACTIVE (1)
68 #endif
69 
70 #ifdef LED0_PIN
71 #define LED_RED_PIN LED0_PIN
72 #endif
73 #ifdef LED1_PIN
74 #define LED_GREEN_PIN LED1_PIN
75 #endif
76 #ifdef LED2_PIN
77 #define LED_BLUE_PIN LED2_PIN
78 #endif
79 
90 #if MODULE_SDCARD_SPI || DOXYGEN
91 #define SDCARD_SPI_PARAM_SPI SPI_DEV(0)
92 #define SDCARD_SPI_PARAM_CLK SPI0_SCK
93 #define SDCARD_SPI_PARAM_MOSI SPI0_MOSI
94 #define SDCARD_SPI_PARAM_MISO SPI0_MISO
95 #define SDCARD_SPI_PARAM_CS SPI0_CS0
96 #define SDCARD_SPI_PARAM_POWER GPIO_UNDEF
97 #endif
98 
106 #if MODULE_ILI9341 || DOXYGEN
107 #define LCD_CS GPIO22
108 #define LCD_RST GPIO18
109 #define LCD_DC GPIO21
110 #define LCD_BACKLIGHT GPIO5
111 
112 #define BACKLIGHT_ON gpio_clear(LCD_BACKLIGHT)
113 #define BACKLIGHT_OFF gpio_set(LCD_BACKLIGHT)
114 
115 #define ILI9341_PARAM_SPI SPI_DEV(1)
116 #define ILI9341_PARAM_SPI_CLK SPI_CLK_10MHZ
117 #define ILI9341_PARAM_CS LCD_CS
118 #define ILI9341_PARAM_DCX LCD_DC
119 #define ILI9341_PARAM_RST LCD_RST
120 #define ILi9341_PARAM_RGB 0
121 #define ILI9341_PARAM_INVERTED 0
122 #endif
123 
126 /* include common board definitions as last step */
127 #include "board_common.h"
128 
129 #ifdef __cplusplus
130 extern "C" {
131 #endif
132 
136 static inline void board_init(void) {
137 #if MODULE_ILI9341
138  gpio_init(LCD_BACKLIGHT, GPIO_OUT);
139 #endif
140 
141  /* there is nothing special to initialize on this board */
143 }
144 
145 #ifdef __cplusplus
146 } /* end extern "C" */
147 #endif
148 
149 #endif /* BOARD_H */
150 
GPIO_OUT
@ GPIO_OUT
configure as output in push-pull mode
Definition: gpio.h:122
gpio_init
int gpio_init(gpio_t pin, gpio_mode_t mode)
Initialize the given pin as general purpose input or output.
board_init_common
void board_init_common(void)
Initialize the hardware that is common for all ESP32 boards.
board_init
void board_init(void)
Board level initialization.