main/u8g2_esp32_hal.h

Tue, 03 Oct 2023 17:24:06 +0200

author
Michiel Broek <mbroek@mbse.eu>
date
Tue, 03 Oct 2023 17:24:06 +0200
changeset 77
15dc572a7fcb
parent 57
232f318a6b51
permissions
-rw-r--r--

Version 0.3.0. Backported network code from experimental roaming project. Will now connect after reset to the strongest AP. Id the signal level drops below -67, extra scans are done to see for a better AP. Nothing is done yet. Removed config.conf file, all info is taken from the project menu and live tests. Better log the board type and send it via json mqtt. Send bssid and current channel too.

/**
 * @file u8g2_esp32_hal.h
 * @date Feb 12, 2017
 * @author kolban
 */

#ifndef U8G2_ESP32_HAL_H_
#define U8G2_ESP32_HAL_H_
#include "u8g2.h"

#include "driver/gpio.h"
#include "driver/spi_master.h"
#include "driver/i2c.h"

#define U8G2_ESP32_HAL_UNDEFINED	(-1)			///<  Undefined value for this HAL

#define I2C_MASTER_NUM	(CONFIG_I2C_MASTER_PORT_NUM)		///<  I2C port number for master dev (original 1)
#define I2C_MASTER_TX_BUF_DISABLE	0			///<  I2C master do not need buffer
#define I2C_MASTER_RX_BUF_DISABLE	0			///<  I2C master do not need buffer
#define I2C_MASTER_FREQ_HZ	(CONFIG_I2C_MASTER_FREQUENCY)	///<  I2C master clock frequency (original 50000)
#define ACK_CHECK_EN			0x1			///<  I2C master will check ack from slave
#define ACK_CHECK_DIS			0x0			///<  I2C master will not check ack from slave

typedef struct {
	gpio_num_t clk;				///< SPI clock
	gpio_num_t mosi;			///< SPI mosi
	gpio_num_t sda;				///< data for I²C
	gpio_num_t scl;				///< clock for I²C
	gpio_num_t cs;				///< SPI cs
	gpio_num_t reset;			///< SPI reset
	gpio_num_t dc;
} u8g2_esp32_hal_t;				///< HAL structure

#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 }

/**
 * @brief Initialze the ESP32 HAL.
 */
void u8g2_esp32_hal_init(u8g2_esp32_hal_t u8g2_esp32_hal_param);

/**
 * @brief HAL callback function as prescribed by the U8G2 library.
 *        This callback is invoked to handle SPI communications.
 */
uint8_t u8g2_esp32_spi_byte_cb(u8x8_t *u8x8, uint8_t msg, uint8_t arg_int, void *arg_ptr);

/**
 * @brief HAL callback function as prescribed by the U8G2 library.
 *        This callback is invoked to handle I2C communications.
 */
uint8_t u8g2_esp32_i2c_byte_cb(u8x8_t *u8x8, uint8_t msg, uint8_t arg_int, void *arg_ptr);

/**
 * @brief HAL callback function as prescribed by the U8G2 library.
 *        This callback is invoked to handle callbacks for GPIO and delay functions.
 */
uint8_t u8g2_esp32_gpio_and_delay_cb(u8x8_t *u8x8, uint8_t msg, uint8_t arg_int, void *arg_ptr);
#endif /* U8G2_ESP32_HAL_H_ */

mercurial