Run clang-format again
This commit is contained in:
parent
594c16ed41
commit
1c5fbd725a
@ -432,12 +432,12 @@ esp_err_t sx127x_start(sx127x_t *handle) {
|
||||
SX127X_ERROR_CHECK(ret);
|
||||
|
||||
gpio_config_t irq_io_config;
|
||||
irq_io_config.intr_type = GPIO_INTR_POSEDGE;
|
||||
irq_io_config.mode = GPIO_MODE_INPUT;
|
||||
irq_io_config.intr_type = GPIO_INTR_POSEDGE;
|
||||
irq_io_config.mode = GPIO_MODE_INPUT;
|
||||
irq_io_config.pin_bit_mask = (1ULL << handle->config.irq_io_num);
|
||||
irq_io_config.pull_down_en = 0;
|
||||
irq_io_config.pull_up_en = 0;
|
||||
ret = gpio_config(&irq_io_config);
|
||||
irq_io_config.pull_up_en = 0;
|
||||
ret = gpio_config(&irq_io_config);
|
||||
SX127X_ERROR_CHECK2(ret, gpio_config)
|
||||
|
||||
ret = gpio_install_isr_service(ESP_INTR_FLAG_LEVEL1);
|
||||
|
@ -1,7 +1,7 @@
|
||||
#pragma once
|
||||
|
||||
#include <driver/spi_master.h>
|
||||
#include <driver/gpio.h>
|
||||
#include <driver/spi_master.h>
|
||||
#include <stdint.h>
|
||||
|
||||
#define SX127X_MAX_TRANSFER (256)
|
||||
|
@ -9,12 +9,12 @@
|
||||
|
||||
#include "u8g2_esp32_hal.h"
|
||||
|
||||
static const char *TAG = "u8g2_hal";
|
||||
static const char * TAG = "u8g2_hal";
|
||||
static const unsigned int I2C_TIMEOUT_MS = 1000;
|
||||
|
||||
static spi_device_handle_t handle_spi; // SPI handle.
|
||||
static i2c_cmd_handle_t handle_i2c; // I2C handle.
|
||||
static u8g2_esp32_hal_t u8g2_esp32_hal; // HAL state data.
|
||||
static spi_device_handle_t handle_spi; // SPI handle.
|
||||
static i2c_cmd_handle_t handle_i2c; // I2C handle.
|
||||
static u8g2_esp32_hal_t u8g2_esp32_hal; // HAL state data.
|
||||
|
||||
#undef ESP_ERROR_CHECK
|
||||
#define ESP_ERROR_CHECK(x) \
|
||||
@ -54,28 +54,28 @@ uint8_t u8g2_esp32_spi_byte_cb(u8x8_t *u8x8, uint8_t msg, uint8_t arg_int, void
|
||||
|
||||
spi_bus_config_t bus_config;
|
||||
memset(&bus_config, 0, sizeof(spi_bus_config_t));
|
||||
bus_config.sclk_io_num = u8g2_esp32_hal.clk; // CLK
|
||||
bus_config.mosi_io_num = u8g2_esp32_hal.mosi; // MOSI
|
||||
bus_config.miso_io_num = -1; // MISO
|
||||
bus_config.quadwp_io_num = -1; // Not used
|
||||
bus_config.quadhd_io_num = -1; // Not used
|
||||
bus_config.sclk_io_num = u8g2_esp32_hal.clk; // CLK
|
||||
bus_config.mosi_io_num = u8g2_esp32_hal.mosi; // MOSI
|
||||
bus_config.miso_io_num = -1; // MISO
|
||||
bus_config.quadwp_io_num = -1; // Not used
|
||||
bus_config.quadhd_io_num = -1; // Not used
|
||||
// ESP_LOGI(TAG, "... Initializing bus.");
|
||||
ESP_ERROR_CHECK(spi_bus_initialize(HSPI_HOST, &bus_config, 1));
|
||||
|
||||
spi_device_interface_config_t dev_config;
|
||||
dev_config.address_bits = 0;
|
||||
dev_config.command_bits = 0;
|
||||
dev_config.dummy_bits = 0;
|
||||
dev_config.mode = 0;
|
||||
dev_config.duty_cycle_pos = 0;
|
||||
dev_config.address_bits = 0;
|
||||
dev_config.command_bits = 0;
|
||||
dev_config.dummy_bits = 0;
|
||||
dev_config.mode = 0;
|
||||
dev_config.duty_cycle_pos = 0;
|
||||
dev_config.cs_ena_posttrans = 0;
|
||||
dev_config.cs_ena_pretrans = 0;
|
||||
dev_config.clock_speed_hz = 10000;
|
||||
dev_config.spics_io_num = u8g2_esp32_hal.cs;
|
||||
dev_config.flags = 0;
|
||||
dev_config.queue_size = 200;
|
||||
dev_config.pre_cb = NULL;
|
||||
dev_config.post_cb = NULL;
|
||||
dev_config.cs_ena_pretrans = 0;
|
||||
dev_config.clock_speed_hz = 10000;
|
||||
dev_config.spics_io_num = u8g2_esp32_hal.cs;
|
||||
dev_config.flags = 0;
|
||||
dev_config.queue_size = 200;
|
||||
dev_config.pre_cb = NULL;
|
||||
dev_config.post_cb = NULL;
|
||||
// ESP_LOGI(TAG, "... Adding device bus.");
|
||||
ESP_ERROR_CHECK(spi_bus_add_device(HSPI_HOST, &dev_config, &handle_spi));
|
||||
|
||||
@ -84,11 +84,11 @@ uint8_t u8g2_esp32_spi_byte_cb(u8x8_t *u8x8, uint8_t msg, uint8_t arg_int, void
|
||||
|
||||
case U8X8_MSG_BYTE_SEND: {
|
||||
spi_transaction_t trans_desc;
|
||||
trans_desc.addr = 0;
|
||||
trans_desc.cmd = 0;
|
||||
trans_desc.flags = 0;
|
||||
trans_desc.length = 8 * arg_int; // Number of bits NOT number of bytes.
|
||||
trans_desc.rxlength = 0;
|
||||
trans_desc.addr = 0;
|
||||
trans_desc.cmd = 0;
|
||||
trans_desc.flags = 0;
|
||||
trans_desc.length = 8 * arg_int; // Number of bits NOT number of bytes.
|
||||
trans_desc.rxlength = 0;
|
||||
trans_desc.tx_buffer = arg_ptr;
|
||||
trans_desc.rx_buffer = NULL;
|
||||
|
||||
@ -106,7 +106,7 @@ uint8_t u8g2_esp32_spi_byte_cb(u8x8_t *u8x8, uint8_t msg, uint8_t arg_int, void
|
||||
*/
|
||||
uint8_t u8g2_esp32_i2c_byte_cb(u8x8_t *u8x8, uint8_t msg, uint8_t arg_int, void *arg_ptr) {
|
||||
#define TXBUF_SIZE 32
|
||||
static uint8_t txbuf[TXBUF_SIZE];
|
||||
static uint8_t txbuf[TXBUF_SIZE];
|
||||
static uint8_t *txbuf_ptr;
|
||||
// ESP_LOGV(TAG, "i2c_cb: Received a msg: %d, arg_int: %d, arg_ptr: %p", msg,
|
||||
// arg_int, arg_ptr);
|
||||
@ -126,10 +126,10 @@ uint8_t u8g2_esp32_i2c_byte_cb(u8x8_t *u8x8, uint8_t msg, uint8_t arg_int, void
|
||||
i2c_config_t conf;
|
||||
conf.mode = I2C_MODE_MASTER;
|
||||
ESP_LOGD(TAG, "sda_io_num %d", u8g2_esp32_hal.sda);
|
||||
conf.sda_io_num = u8g2_esp32_hal.sda;
|
||||
conf.sda_io_num = u8g2_esp32_hal.sda;
|
||||
conf.sda_pullup_en = GPIO_PULLUP_ENABLE;
|
||||
ESP_LOGD(TAG, "scl_io_num %d", u8g2_esp32_hal.scl);
|
||||
conf.scl_io_num = u8g2_esp32_hal.scl;
|
||||
conf.scl_io_num = u8g2_esp32_hal.scl;
|
||||
conf.scl_pullup_en = GPIO_PULLUP_ENABLE;
|
||||
ESP_LOGD(TAG, "clk_speed %d", I2C_MASTER_FREQ_HZ);
|
||||
conf.master.clk_speed = I2C_MASTER_FREQ_HZ;
|
||||
@ -143,7 +143,7 @@ uint8_t u8g2_esp32_i2c_byte_cb(u8x8_t *u8x8, uint8_t msg, uint8_t arg_int, void
|
||||
|
||||
case U8X8_MSG_BYTE_SEND: {
|
||||
uint8_t *data_ptr = (uint8_t *)arg_ptr;
|
||||
size_t data_len = (size_t)arg_int;
|
||||
size_t data_len = (size_t)arg_int;
|
||||
// ESP_LOGV(TAG, "U8x8_MSG_BYTE_SEND. txbuf len: %d", txbuf_ptr - txbuf);
|
||||
// ESP_LOG_BUFFER_HEXDUMP(TAG, data_ptr, data_len, ESP_LOG_VERBOSE);
|
||||
|
||||
@ -158,7 +158,7 @@ uint8_t u8g2_esp32_i2c_byte_cb(u8x8_t *u8x8, uint8_t msg, uint8_t arg_int, void
|
||||
|
||||
case U8X8_MSG_BYTE_START_TRANSFER: {
|
||||
uint8_t i2c_address = u8x8_GetI2CAddress(u8x8);
|
||||
handle_i2c = i2c_cmd_link_create();
|
||||
handle_i2c = i2c_cmd_link_create();
|
||||
// ESP_LOGV(TAG, "Start I2C transfer to %02X.", i2c_address >> 1);
|
||||
ESP_ERROR_CHECK(i2c_master_start(handle_i2c));
|
||||
ESP_ERROR_CHECK(i2c_master_write_byte(handle_i2c, i2c_address | I2C_MASTER_WRITE, ACK_CHECK_EN));
|
||||
@ -206,10 +206,10 @@ uint8_t u8g2_esp32_gpio_and_delay_cb(u8x8_t *u8x8, uint8_t msg, uint8_t arg_int,
|
||||
}
|
||||
gpio_config_t gpioConfig;
|
||||
gpioConfig.pin_bit_mask = bitmask;
|
||||
gpioConfig.mode = GPIO_MODE_OUTPUT;
|
||||
gpioConfig.pull_up_en = GPIO_PULLUP_DISABLE;
|
||||
gpioConfig.mode = GPIO_MODE_OUTPUT;
|
||||
gpioConfig.pull_up_en = GPIO_PULLUP_DISABLE;
|
||||
gpioConfig.pull_down_en = GPIO_PULLDOWN_ENABLE;
|
||||
gpioConfig.intr_type = GPIO_INTR_DISABLE;
|
||||
gpioConfig.intr_type = GPIO_INTR_DISABLE;
|
||||
gpio_config(&gpioConfig);
|
||||
break;
|
||||
}
|
||||
@ -242,9 +242,7 @@ uint8_t u8g2_esp32_gpio_and_delay_cb(u8x8_t *u8x8, uint8_t msg, uint8_t arg_int,
|
||||
break;
|
||||
|
||||
// Delay for the number of milliseconds passed in through arg_int.
|
||||
case U8X8_MSG_DELAY_MILLI:
|
||||
vTaskDelay(arg_int / portTICK_PERIOD_MS);
|
||||
break;
|
||||
case U8X8_MSG_DELAY_MILLI: vTaskDelay(arg_int / portTICK_PERIOD_MS); break;
|
||||
}
|
||||
return 0;
|
||||
} // u8g2_esp32_gpio_and_delay_cb
|
@ -38,7 +38,7 @@ typedef struct {
|
||||
U8G2_ESP32_HAL_UNDEFINED, U8G2_ESP32_HAL_UNDEFINED, U8G2_ESP32_HAL_UNDEFINED \
|
||||
}
|
||||
|
||||
void u8g2_esp32_hal_init(u8g2_esp32_hal_t u8g2_esp32_hal_param);
|
||||
void u8g2_esp32_hal_init(u8g2_esp32_hal_t u8g2_esp32_hal_param);
|
||||
uint8_t u8g2_esp32_spi_byte_cb(u8x8_t *u8x8, uint8_t msg, uint8_t arg_int, void *arg_ptr);
|
||||
uint8_t u8g2_esp32_i2c_byte_cb(u8x8_t *u8x8, uint8_t msg, uint8_t arg_int, void *arg_ptr);
|
||||
uint8_t u8g2_esp32_gpio_and_delay_cb(u8x8_t *u8x8, uint8_t msg, uint8_t arg_int, void *arg_ptr);
|
||||
|
@ -89,14 +89,14 @@ void setup(void) {
|
||||
configASSERT(lora_packet_recv_queue != 0);
|
||||
configASSERT(lora_packet_isr_queue != 0);
|
||||
|
||||
sx127x_config_t lora_config = SX127X_CONFIG_DEFAULT;
|
||||
lora_config.tx_power = 17;
|
||||
sx127x_config_t lora_config = SX127X_CONFIG_DEFAULT;
|
||||
lora_config.tx_power = 17;
|
||||
lora_config.spreading_factor = 11;
|
||||
lora_config.signal_bandwidth = 125E3;
|
||||
lora_config.sync_word = 0x34;
|
||||
lora_config.crc = SX127X_CRC_ENABLED;
|
||||
lora_config.sync_word = 0x34;
|
||||
lora_config.crc = SX127X_CRC_ENABLED;
|
||||
|
||||
sx127x_t* lora;
|
||||
sx127x_t *lora;
|
||||
esp_err_t ret = sx127x_init(&lora_config, &lora);
|
||||
if (ret != ESP_OK) {
|
||||
const char *err_name = esp_err_to_name(ret);
|
||||
@ -178,8 +178,12 @@ void loop(void) {
|
||||
u8g2_DrawStr(&u8g2, 4, 8 + 8, buf);
|
||||
|
||||
if (packet.buffer_len) {
|
||||
ESP_LOGI(TAG, "lora received packet (len %d, rssi: %d, snr: %f): %s\n", packet.buffer_len, packet.rssi,
|
||||
packet.snr, packet.buffer);
|
||||
ESP_LOGI(TAG,
|
||||
"lora received packet (len %d, rssi: %d, snr: %f): %s\n",
|
||||
packet.buffer_len,
|
||||
packet.rssi,
|
||||
packet.snr,
|
||||
packet.buffer);
|
||||
u8g2_SetFont(&u8g2, u8g2_font_4x6_mf);
|
||||
snprintf(buf, 40, "lora pkt(rssi: %d, snr: %f)", packet.rssi, packet.snr);
|
||||
u8g2_DrawStr(&u8g2, 4, 8 + 8 + 8, buf);
|
||||
|
Loading…
x
Reference in New Issue
Block a user