10 |
10 |
11 #include "driver/gpio.h" |
11 #include "driver/gpio.h" |
12 #include "driver/spi_master.h" |
12 #include "driver/spi_master.h" |
13 #include "driver/i2c.h" |
13 #include "driver/i2c.h" |
14 |
14 |
15 #define U8G2_ESP32_HAL_UNDEFINED (-1) |
15 #define U8G2_ESP32_HAL_UNDEFINED (-1) ///< Undefined value for this HAL |
16 |
16 |
17 #define I2C_MASTER_NUM (CONFIG_I2C_MASTER_PORT_NUM) ///< I2C port number for master dev (original 1) |
17 #define I2C_MASTER_NUM (CONFIG_I2C_MASTER_PORT_NUM) ///< I2C port number for master dev (original 1) |
18 #define I2C_MASTER_TX_BUF_DISABLE 0 ///< I2C master do not need buffer |
18 #define I2C_MASTER_TX_BUF_DISABLE 0 ///< I2C master do not need buffer |
19 #define I2C_MASTER_RX_BUF_DISABLE 0 ///< I2C master do not need buffer |
19 #define I2C_MASTER_RX_BUF_DISABLE 0 ///< I2C master do not need buffer |
20 #define I2C_MASTER_FREQ_HZ (CONFIG_I2C_MASTER_FREQUENCY) ///< I2C master clock frequency (original 50000) |
20 #define I2C_MASTER_FREQ_HZ (CONFIG_I2C_MASTER_FREQUENCY) ///< I2C master clock frequency (original 50000) |
21 #define ACK_CHECK_EN 0x1 ///< I2C master will check ack from slave |
21 #define ACK_CHECK_EN 0x1 ///< I2C master will check ack from slave |
22 #define ACK_CHECK_DIS 0x0 ///< I2C master will not check ack from slave |
22 #define ACK_CHECK_DIS 0x0 ///< I2C master will not check ack from slave |
23 |
23 |
24 typedef struct { |
24 typedef struct { |
25 gpio_num_t clk; |
25 gpio_num_t clk; ///< SPI clock |
26 gpio_num_t mosi; |
26 gpio_num_t mosi; ///< SPI mosi |
27 gpio_num_t sda; // data for I²C |
27 gpio_num_t sda; ///< data for I²C |
28 gpio_num_t scl; // clock for I²C |
28 gpio_num_t scl; ///< clock for I²C |
29 gpio_num_t cs; |
29 gpio_num_t cs; ///< SPI cs |
30 gpio_num_t reset; |
30 gpio_num_t reset; ///< SPI reset |
31 gpio_num_t dc; |
31 gpio_num_t dc; |
32 } u8g2_esp32_hal_t ; |
32 } u8g2_esp32_hal_t; ///< HAL structure |
33 |
33 |
34 #define U8G2_ESP32_HAL_DEFAULT {U8G2_ESP32_HAL_UNDEFINED, U8G2_ESP32_HAL_UNDEFINED, U8G2_ESP32_HAL_UNDEFINED, U8G2_ESP32_HAL_UNDEFINED, U8G2_ESP32_HAL_UNDEFINED, U8G2_ESP32_HAL_UNDEFINED, U8G2_ESP32_HAL_UNDEFINED } |
34 #define U8G2_ESP32_HAL_DEFAULT {U8G2_ESP32_HAL_UNDEFINED, U8G2_ESP32_HAL_UNDEFINED, U8G2_ESP32_HAL_UNDEFINED, U8G2_ESP32_HAL_UNDEFINED, U8G2_ESP32_HAL_UNDEFINED, U8G2_ESP32_HAL_UNDEFINED, U8G2_ESP32_HAL_UNDEFINED } |
35 |
35 |
|
36 /** |
|
37 * @brief Initialze the ESP32 HAL. |
|
38 */ |
36 void u8g2_esp32_hal_init(u8g2_esp32_hal_t u8g2_esp32_hal_param); |
39 void u8g2_esp32_hal_init(u8g2_esp32_hal_t u8g2_esp32_hal_param); |
|
40 |
|
41 /** |
|
42 * @brief HAL callback function as prescribed by the U8G2 library. |
|
43 * This callback is invoked to handle SPI communications. |
|
44 */ |
37 uint8_t u8g2_esp32_spi_byte_cb(u8x8_t *u8x8, uint8_t msg, uint8_t arg_int, void *arg_ptr); |
45 uint8_t u8g2_esp32_spi_byte_cb(u8x8_t *u8x8, uint8_t msg, uint8_t arg_int, void *arg_ptr); |
|
46 |
|
47 /** |
|
48 * @brief HAL callback function as prescribed by the U8G2 library. |
|
49 * This callback is invoked to handle I2C communications. |
|
50 */ |
38 uint8_t u8g2_esp32_i2c_byte_cb(u8x8_t *u8x8, uint8_t msg, uint8_t arg_int, void *arg_ptr); |
51 uint8_t u8g2_esp32_i2c_byte_cb(u8x8_t *u8x8, uint8_t msg, uint8_t arg_int, void *arg_ptr); |
|
52 |
|
53 /** |
|
54 * @brief HAL callback function as prescribed by the U8G2 library. |
|
55 * This callback is invoked to handle callbacks for GPIO and delay functions. |
|
56 */ |
39 uint8_t u8g2_esp32_gpio_and_delay_cb(u8x8_t *u8x8, uint8_t msg, uint8_t arg_int, void *arg_ptr); |
57 uint8_t u8g2_esp32_gpio_and_delay_cb(u8x8_t *u8x8, uint8_t msg, uint8_t arg_int, void *arg_ptr); |
40 #endif /* U8G2_ESP32_HAL_H_ */ |
58 #endif /* U8G2_ESP32_HAL_H_ */ |