New feature, menuconfig menu
This commit is contained in:
parent
46bbdbf3f5
commit
d820430865
80
BNO08x.cpp
80
BNO08x.cpp
|
|
@ -35,10 +35,10 @@ BNO08x::BNO08x(bno08x_config_t imu_config)
|
||||||
// SPI slave device specific config
|
// SPI slave device specific config
|
||||||
imu_spi_config.mode = 0x3; // set mode to 3 as per BNO08x datasheet (CPHA second edge, CPOL bus high when idle)
|
imu_spi_config.mode = 0x3; // set mode to 3 as per BNO08x datasheet (CPHA second edge, CPOL bus high when idle)
|
||||||
|
|
||||||
if (imu_config.sclk_speed > 3000000) // max sclk speed of 3MHz for BNO08x
|
if (imu_config.sclk_speed > 3000000UL) // max sclk speed of 3MHz for BNO08x
|
||||||
{
|
{
|
||||||
ESP_LOGE(TAG, "Max clock speed exceeded, %lld overwritten with 3000000Hz", imu_config.sclk_speed);
|
ESP_LOGE(TAG, "Max clock speed exceeded, %ld overwritten with 3MHz", imu_config.sclk_speed);
|
||||||
imu_config.sclk_speed = 3000000;
|
imu_config.sclk_speed = 3000000UL;
|
||||||
}
|
}
|
||||||
|
|
||||||
imu_spi_config.clock_source = SPI_CLK_SRC_DEFAULT;
|
imu_spi_config.clock_source = SPI_CLK_SRC_DEFAULT;
|
||||||
|
|
@ -74,7 +74,7 @@ BNO08x::BNO08x(bno08x_config_t imu_config)
|
||||||
gpio_config_t inputs_config;
|
gpio_config_t inputs_config;
|
||||||
inputs_config.pin_bit_mask = (1ULL << imu_config.io_int);
|
inputs_config.pin_bit_mask = (1ULL << imu_config.io_int);
|
||||||
inputs_config.mode = GPIO_MODE_INPUT;
|
inputs_config.mode = GPIO_MODE_INPUT;
|
||||||
inputs_config.pull_up_en = GPIO_PULLUP_ENABLE;
|
inputs_config.pull_up_en = GPIO_PULLUP_DISABLE;
|
||||||
inputs_config.pull_down_en = GPIO_PULLDOWN_DISABLE;
|
inputs_config.pull_down_en = GPIO_PULLDOWN_DISABLE;
|
||||||
inputs_config.intr_type = GPIO_INTR_NEGEDGE;
|
inputs_config.intr_type = GPIO_INTR_NEGEDGE;
|
||||||
gpio_config(&inputs_config);
|
gpio_config(&inputs_config);
|
||||||
|
|
@ -116,8 +116,9 @@ bool BNO08x::initialize()
|
||||||
// launch tasks
|
// launch tasks
|
||||||
data_proc_task_hdl = NULL;
|
data_proc_task_hdl = NULL;
|
||||||
spi_task_hdl = NULL;
|
spi_task_hdl = NULL;
|
||||||
xTaskCreate(&data_proc_task_trampoline, "bno08x_data_processing_task", 4096, this, 7, &data_proc_task_hdl); // launch data processing task
|
xTaskCreate(&data_proc_task_trampoline, "bno08x_data_processing_task", CONFIG_ESP32_BNO08X_DATA_PROC_TASK_SZ, this, 7,
|
||||||
xTaskCreate(&spi_task_trampoline, "bno08x_spi_task", 4096, this, 8, &spi_task_hdl); // launch SPI task
|
&data_proc_task_hdl); // launch data processing task
|
||||||
|
xTaskCreate(&spi_task_trampoline, "bno08x_spi_task", 4096, this, 8, &spi_task_hdl); // launch SPI task
|
||||||
|
|
||||||
if (!hard_reset())
|
if (!hard_reset())
|
||||||
return false;
|
return false;
|
||||||
|
|
@ -151,8 +152,9 @@ bool BNO08x::wait_for_rx_done()
|
||||||
// wait until an interrupt has been asserted and data received or timeout has occured
|
// wait until an interrupt has been asserted and data received or timeout has occured
|
||||||
if (xEventGroupWaitBits(evt_grp_spi, EVT_GRP_SPI_RX_DONE_BIT, pdTRUE, pdTRUE, HOST_INT_TIMEOUT_MS / portTICK_PERIOD_MS))
|
if (xEventGroupWaitBits(evt_grp_spi, EVT_GRP_SPI_RX_DONE_BIT, pdTRUE, pdTRUE, HOST_INT_TIMEOUT_MS / portTICK_PERIOD_MS))
|
||||||
{
|
{
|
||||||
if (imu_config.debug_en)
|
#ifdef CONFIG_ESP32_BNO08x_DEBUG_STATEMENTS
|
||||||
ESP_LOGI(TAG, "int asserted");
|
ESP_LOGI(TAG, "int asserted");
|
||||||
|
#endif
|
||||||
|
|
||||||
success = true;
|
success = true;
|
||||||
}
|
}
|
||||||
|
|
@ -190,8 +192,10 @@ bool BNO08x::wait_for_data()
|
||||||
// only return true if packet is valid
|
// only return true if packet is valid
|
||||||
if (xEventGroupGetBits(evt_grp_spi) & EVT_GRP_SPI_RX_VALID_PACKET)
|
if (xEventGroupGetBits(evt_grp_spi) & EVT_GRP_SPI_RX_VALID_PACKET)
|
||||||
{
|
{
|
||||||
if (imu_config.debug_en)
|
#ifdef CONFIG_ESP32_BNO08x_DEBUG_STATEMENTS
|
||||||
ESP_LOGI(TAG, "Valid packet received.");
|
ESP_LOGI(TAG, "Valid packet received.");
|
||||||
|
#endif
|
||||||
|
|
||||||
success = true;
|
success = true;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
|
@ -224,9 +228,9 @@ bool BNO08x::wait_for_tx_done()
|
||||||
|
|
||||||
if (xEventGroupWaitBits(evt_grp_spi, EVT_GRP_SPI_TX_DONE, pdTRUE, pdTRUE, HOST_INT_TIMEOUT_MS / portTICK_PERIOD_MS))
|
if (xEventGroupWaitBits(evt_grp_spi, EVT_GRP_SPI_TX_DONE, pdTRUE, pdTRUE, HOST_INT_TIMEOUT_MS / portTICK_PERIOD_MS))
|
||||||
{
|
{
|
||||||
|
#ifdef CONFIG_ESP32_BNO08x_DEBUG_STATEMENTS
|
||||||
if (imu_config.debug_en)
|
ESP_LOGI(TAG, "Packet sent successfully.");
|
||||||
ESP_LOGI(TAG, "Packet sent successfully.");
|
#endif
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
@ -411,8 +415,9 @@ bool BNO08x::receive_packet()
|
||||||
packet.length = (((uint16_t) packet.header[1]) << 8) | ((uint16_t) packet.header[0]);
|
packet.length = (((uint16_t) packet.header[1]) << 8) | ((uint16_t) packet.header[0]);
|
||||||
packet.length &= ~(1 << 15); // Clear the MSbit
|
packet.length &= ~(1 << 15); // Clear the MSbit
|
||||||
|
|
||||||
if (imu_config.debug_en)
|
#ifdef CONFIG_ESP32_BNO08x_DEBUG_STATEMENTS
|
||||||
ESP_LOGW(TAG, "packet rx length: %d", packet.length);
|
ESP_LOGW(TAG, "packet rx length: %d", packet.length);
|
||||||
|
#endif
|
||||||
|
|
||||||
if (packet.length == 0)
|
if (packet.length == 0)
|
||||||
return false;
|
return false;
|
||||||
|
|
@ -853,7 +858,7 @@ bool BNO08x::data_available()
|
||||||
/**
|
/**
|
||||||
* @brief Registers a callback to execute when new data from a report is received.
|
* @brief Registers a callback to execute when new data from a report is received.
|
||||||
*
|
*
|
||||||
* @param cb_fxn Pointer to the call-back function should be of void return type and void input parameters.
|
* @param cb_fxn Pointer to the call-back function should be of void return type and void input parameters.
|
||||||
* @return void, nothing to return
|
* @return void, nothing to return
|
||||||
*/
|
*/
|
||||||
void BNO08x::register_cb(std::function<void()> cb_fxn)
|
void BNO08x::register_cb(std::function<void()> cb_fxn)
|
||||||
|
|
@ -869,8 +874,9 @@ void BNO08x::register_cb(std::function<void()> cb_fxn)
|
||||||
*/
|
*/
|
||||||
uint16_t BNO08x::parse_packet(bno08x_rx_packet_t* packet)
|
uint16_t BNO08x::parse_packet(bno08x_rx_packet_t* packet)
|
||||||
{
|
{
|
||||||
if (imu_config.debug_en)
|
#ifdef CONFIG_ESP32_BNO08x_DEBUG_STATEMENTS
|
||||||
ESP_LOGE(TAG, "SHTP Header RX'd: 0x%X 0x%X 0x%X 0x%X", packet->header[0], packet->header[1], packet->header[2], packet->header[3]);
|
ESP_LOGW(TAG, "SHTP Header RX'd: 0x%X 0x%X 0x%X 0x%X", packet->header[0], packet->header[1], packet->header[2], packet->header[3]);
|
||||||
|
#endif
|
||||||
|
|
||||||
if (packet->body[0] == SHTP_REPORT_PRODUCT_ID_RESPONSE) // check to see that product ID matches what it should
|
if (packet->body[0] == SHTP_REPORT_PRODUCT_ID_RESPONSE) // check to see that product ID matches what it should
|
||||||
{
|
{
|
||||||
|
|
@ -885,23 +891,26 @@ uint16_t BNO08x::parse_packet(bno08x_rx_packet_t* packet)
|
||||||
// Check to see if this packet is a sensor reporting its data to us
|
// Check to see if this packet is a sensor reporting its data to us
|
||||||
if (packet->header[2] == CHANNEL_REPORTS && packet->body[0] == SHTP_REPORT_BASE_TIMESTAMP)
|
if (packet->header[2] == CHANNEL_REPORTS && packet->body[0] == SHTP_REPORT_BASE_TIMESTAMP)
|
||||||
{
|
{
|
||||||
if (imu_config.debug_en)
|
#ifdef CONFIG_ESP32_BNO08x_DEBUG_STATEMENTS
|
||||||
ESP_LOGI(TAG, "RX'd packet, channel report");
|
ESP_LOGI(TAG, "RX'd packet, channel report");
|
||||||
|
#endif
|
||||||
|
|
||||||
return parse_input_report(packet); // This will update the rawAccelX, etc variables depending on which feature
|
return parse_input_report(packet); // This will update the rawAccelX, etc variables depending on which feature
|
||||||
// report is found
|
// report is found
|
||||||
}
|
}
|
||||||
else if (packet->header[2] == CHANNEL_CONTROL)
|
else if (packet->header[2] == CHANNEL_CONTROL)
|
||||||
{
|
{
|
||||||
if (imu_config.debug_en)
|
#ifdef CONFIG_ESP32_BNO08x_DEBUG_STATEMENTS
|
||||||
ESP_LOGI(TAG, "RX'd packet, channel control");
|
ESP_LOGI(TAG, "RX'd packet, channel control");
|
||||||
|
#endif
|
||||||
|
|
||||||
return parse_command_report(packet); // This will update responses to commands, calibrationStatus, etc.
|
return parse_command_report(packet); // This will update responses to commands, calibrationStatus, etc.
|
||||||
}
|
}
|
||||||
else if (packet->header[2] == CHANNEL_GYRO)
|
else if (packet->header[2] == CHANNEL_GYRO)
|
||||||
{
|
{
|
||||||
if (imu_config.debug_en)
|
#ifdef CONFIG_ESP32_BNO08x_DEBUG_STATEMENTS
|
||||||
ESP_LOGI(TAG, "Rx packet, channel gyro");
|
ESP_LOGI(TAG, "Rx packet, channel gyro");
|
||||||
|
#endif
|
||||||
|
|
||||||
return parse_input_report(packet); // This will update the rawAccelX, etc variables depending on which feature
|
return parse_input_report(packet); // This will update the rawAccelX, etc variables depending on which feature
|
||||||
// report is found
|
// report is found
|
||||||
|
|
@ -2770,7 +2779,11 @@ void BNO08x::spi_task_trampoline(void* arg)
|
||||||
*/
|
*/
|
||||||
void BNO08x::spi_task()
|
void BNO08x::spi_task()
|
||||||
{
|
{
|
||||||
static uint64_t prev_time = 0;
|
#ifdef CONFIG_ESP32_BNO08x_DEBUG_STATEMENTS
|
||||||
|
static uint64_t prev_time = esp_timer_get_time();
|
||||||
|
static uint64_t current_time = 0;
|
||||||
|
#endif
|
||||||
|
|
||||||
bno08x_tx_packet_t tx_packet;
|
bno08x_tx_packet_t tx_packet;
|
||||||
|
|
||||||
while (1)
|
while (1)
|
||||||
|
|
@ -2781,11 +2794,12 @@ void BNO08x::spi_task()
|
||||||
gpio_intr_enable(imu_config.io_int);
|
gpio_intr_enable(imu_config.io_int);
|
||||||
|
|
||||||
ulTaskNotifyTake(pdTRUE, portMAX_DELAY); // block until notified by ISR (hint_handler)
|
ulTaskNotifyTake(pdTRUE, portMAX_DELAY); // block until notified by ISR (hint_handler)
|
||||||
if (imu_config.debug_en)
|
|
||||||
{
|
#ifdef CONFIG_ESP32_BNO08x_DEBUG_STATEMENTS
|
||||||
ESP_LOGI(TAG, "HINT asserted, time since last assertion: %llu", (esp_timer_get_time() - prev_time));
|
current_time = esp_timer_get_time();
|
||||||
prev_time = esp_timer_get_time();
|
ESP_LOGI(TAG, "HINT asserted, time since last assertion: %llu", (current_time - prev_time));
|
||||||
}
|
prev_time = current_time;
|
||||||
|
#endif
|
||||||
|
|
||||||
if (xQueueReceive(queue_tx_data, &tx_packet, 0)) // check for queued packet to be sent, non blocking
|
if (xQueueReceive(queue_tx_data, &tx_packet, 0)) // check for queued packet to be sent, non blocking
|
||||||
send_packet(&tx_packet); // send packet
|
send_packet(&tx_packet); // send packet
|
||||||
|
|
@ -2823,9 +2837,9 @@ void BNO08x::data_proc_task()
|
||||||
{
|
{
|
||||||
if (parse_packet(&packet) != 0) // check if packet is valid
|
if (parse_packet(&packet) != 0) // check if packet is valid
|
||||||
{
|
{
|
||||||
//execute any registered callbacks
|
// execute any registered callbacks
|
||||||
for(auto& cb_fxn : cb_list)
|
for (auto& cb_fxn : cb_list)
|
||||||
cb_fxn();
|
cb_fxn();
|
||||||
|
|
||||||
xEventGroupSetBits(evt_grp_spi, EVT_GRP_SPI_RX_VALID_PACKET); // indicate valid packet to wait_for_data()
|
xEventGroupSetBits(evt_grp_spi, EVT_GRP_SPI_RX_VALID_PACKET); // indicate valid packet to wait_for_data()
|
||||||
}
|
}
|
||||||
|
|
|
||||||
76
BNO08x.hpp
76
BNO08x.hpp
|
|
@ -1,5 +1,5 @@
|
||||||
#pragma once
|
#pragma once
|
||||||
//esp-idf includes
|
// esp-idf includes
|
||||||
#include <driver/gpio.h>
|
#include <driver/gpio.h>
|
||||||
#include <driver/spi_common.h>
|
#include <driver/spi_common.h>
|
||||||
#include <driver/spi_master.h>
|
#include <driver/spi_master.h>
|
||||||
|
|
@ -12,7 +12,7 @@
|
||||||
#include <freertos/queue.h>
|
#include <freertos/queue.h>
|
||||||
#include <rom/ets_sys.h>
|
#include <rom/ets_sys.h>
|
||||||
|
|
||||||
//standard library includes
|
// standard library includes
|
||||||
#include <inttypes.h>
|
#include <inttypes.h>
|
||||||
#include <math.h>
|
#include <math.h>
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
|
|
@ -50,62 +50,28 @@ typedef struct bno08x_config_t
|
||||||
gpio_num_t io_int; /// Host interrupt pin (connects to BNO08x INT pin)
|
gpio_num_t io_int; /// Host interrupt pin (connects to BNO08x INT pin)
|
||||||
gpio_num_t io_rst; /// Reset pin (connects to BNO08x RST pin)
|
gpio_num_t io_rst; /// Reset pin (connects to BNO08x RST pin)
|
||||||
gpio_num_t io_wake; ///<Wake pin (optional, connects to BNO08x P0)
|
gpio_num_t io_wake; ///<Wake pin (optional, connects to BNO08x P0)
|
||||||
uint64_t sclk_speed; ///<Desired SPI SCLK speed in Hz (max 3MHz)
|
uint32_t sclk_speed; ///<Desired SPI SCLK speed in Hz (max 3MHz)
|
||||||
bool debug_en; ///<Whether or not debugging print statements are enabled
|
|
||||||
|
|
||||||
#ifdef ESP32C3_IMU_CONFIG
|
/// @brief Default IMU configuration settings constructor.
|
||||||
/// @brief Default IMU configuration settings constructor for ESP32-C3, add
|
/// To modify default GPIO pins, run "idf.py menuconfig" esp32_BNO08x->GPIO Configuration.
|
||||||
/// add_compile_definitions("ESP32C3_IMU_CONFIG") to CMakeList to use
|
/// Alternatively, edit the default values in "Kconfig.projbuild"
|
||||||
bno08x_config_t()
|
bno08x_config_t()
|
||||||
: spi_peripheral(SPI2_HOST)
|
: spi_peripheral((spi_host_device_t)CONFIG_ESP32_BNO08x_SPI_HOST)
|
||||||
, io_mosi(GPIO_NUM_4)
|
, io_mosi((gpio_num_t)CONFIG_ESP32_BNO08X_GPIO_DI) // default:
|
||||||
, io_miso(GPIO_NUM_19)
|
, io_miso((gpio_num_t)CONFIG_ESP32_BNO08X_GPIO_SDA) // default:
|
||||||
, io_sclk(GPIO_NUM_18)
|
, io_sclk((gpio_num_t)CONFIG_ESP32_BNO08X_GPIO_SCL) // default:
|
||||||
, io_cs(GPIO_NUM_5)
|
, io_cs((gpio_num_t)CONFIG_ESP32_BNO08X_GPIO_CS) // default:
|
||||||
, io_int(GPIO_NUM_6)
|
, io_int((gpio_num_t)CONFIG_ESP32_BNO08X_GPIO_HINT) // default:
|
||||||
, io_rst(GPIO_NUM_7)
|
, io_rst((gpio_num_t)CONFIG_ESP32_BNO08X_GPIO_RST) // default:
|
||||||
, io_wake(GPIO_NUM_NC)
|
, io_wake((gpio_num_t)CONFIG_ESP32_BNO08X_GPIO_WAKE) // default: -1 (unused)
|
||||||
, sclk_speed(2000000UL) // 2MHz SCLK speed
|
, sclk_speed((uint32_t)CONFIG_ESP32_BNO08X_SCL_SPEED_HZ) // default: 2MH
|
||||||
, debug_en(false)
|
|
||||||
{
|
|
||||||
}
|
|
||||||
#elif defined(ESP32C6_IMU_CONFIG)
|
|
||||||
/// @brief Default IMU configuration settings constructor for ESP32-C6, add
|
|
||||||
/// add_compile_definitions("ESP32C6_IMU_CONFIG") to CMakeList to use
|
|
||||||
bno08x_config_t()
|
|
||||||
: spi_peripheral(SPI2_HOST)
|
|
||||||
, io_mosi(GPIO_NUM_22)
|
|
||||||
, io_miso(GPIO_NUM_21)
|
|
||||||
, io_sclk(GPIO_NUM_23)
|
|
||||||
, io_cs(GPIO_NUM_6)
|
|
||||||
, io_int(GPIO_NUM_4)
|
|
||||||
, io_rst(GPIO_NUM_5)
|
|
||||||
, io_wake(GPIO_NUM_NC)
|
|
||||||
, sclk_speed(2000000UL) // 2MHz SCLK speed
|
|
||||||
, debug_en(false)
|
|
||||||
{
|
|
||||||
}
|
|
||||||
#else
|
|
||||||
/// @brief Default IMU configuration settings constructor for ESP32
|
|
||||||
bno08x_config_t()
|
|
||||||
: spi_peripheral(SPI3_HOST)
|
|
||||||
, io_mosi(GPIO_NUM_23)
|
|
||||||
, io_miso(GPIO_NUM_19)
|
|
||||||
, io_sclk(GPIO_NUM_18)
|
|
||||||
, io_cs(GPIO_NUM_33)
|
|
||||||
, io_int(GPIO_NUM_26)
|
|
||||||
, io_rst(GPIO_NUM_32)
|
|
||||||
, io_wake(GPIO_NUM_NC)
|
|
||||||
, sclk_speed(2000000UL) // 2MHz SCLK speed
|
|
||||||
// , sclk_speed(10000U), //clock slowed to see on AD2
|
|
||||||
, debug_en(false)
|
|
||||||
|
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
#endif
|
|
||||||
/// @brief Overloaded IMU configuration settings constructor for custom pin settings
|
/// @brief Overloaded IMU configuration settings constructor for custom pin settings
|
||||||
bno08x_config_t(spi_host_device_t spi_peripheral, gpio_num_t io_mosi, gpio_num_t io_miso, gpio_num_t io_sclk, gpio_num_t io_cs,
|
bno08x_config_t(spi_host_device_t spi_peripheral, gpio_num_t io_mosi, gpio_num_t io_miso, gpio_num_t io_sclk, gpio_num_t io_cs,
|
||||||
gpio_num_t io_int, gpio_num_t io_rst, gpio_num_t io_wake, uint64_t sclk_speed, bool debug)
|
gpio_num_t io_int, gpio_num_t io_rst, gpio_num_t io_wake, uint32_t sclk_speed)
|
||||||
: spi_peripheral(spi_peripheral)
|
: spi_peripheral(spi_peripheral)
|
||||||
, io_mosi(io_mosi)
|
, io_mosi(io_mosi)
|
||||||
, io_miso(io_miso)
|
, io_miso(io_miso)
|
||||||
|
|
@ -115,8 +81,6 @@ typedef struct bno08x_config_t
|
||||||
, io_rst(io_rst)
|
, io_rst(io_rst)
|
||||||
, io_wake(io_wake)
|
, io_wake(io_wake)
|
||||||
, sclk_speed(sclk_speed)
|
, sclk_speed(sclk_speed)
|
||||||
, debug_en(false)
|
|
||||||
|
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
} bno08x_config_t;
|
} bno08x_config_t;
|
||||||
|
|
@ -354,8 +318,6 @@ class BNO08x
|
||||||
|
|
||||||
static bno08x_config_t default_imu_config; ///< default imu config settings
|
static bno08x_config_t default_imu_config; ///< default imu config settings
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
EventGroupHandle_t
|
EventGroupHandle_t
|
||||||
evt_grp_spi; ///<Event group for indicating when bno08x hint pin has triggered and when new data has been processed. Used by calls to sending or receiving functions.
|
evt_grp_spi; ///<Event group for indicating when bno08x hint pin has triggered and when new data has been processed. Used by calls to sending or receiving functions.
|
||||||
EventGroupHandle_t evt_grp_report_en; ///<Event group for indicating which reports are currently enabled.
|
EventGroupHandle_t evt_grp_report_en; ///<Event group for indicating which reports are currently enabled.
|
||||||
|
|
@ -363,9 +325,9 @@ class BNO08x
|
||||||
QueueHandle_t queue_rx_data; ///<Packet queue used to send data received from bno08x from spi_task to data_proc_task.
|
QueueHandle_t queue_rx_data; ///<Packet queue used to send data received from bno08x from spi_task to data_proc_task.
|
||||||
QueueHandle_t queue_tx_data; ///<Packet queue used to send data to be sent over SPI from sending functions to spi_task.
|
QueueHandle_t queue_tx_data; ///<Packet queue used to send data to be sent over SPI from sending functions to spi_task.
|
||||||
QueueHandle_t queue_frs_read_data; ///<Queue used to send packet body from data_proc_task to frs read functions.
|
QueueHandle_t queue_frs_read_data; ///<Queue used to send packet body from data_proc_task to frs read functions.
|
||||||
QueueHandle_t queue_reset_reason; ///<Queue used to send reset reason from product id report to reset_reason() function
|
QueueHandle_t queue_reset_reason; ///<Queue used to send reset reason from product id report to reset_reason() function
|
||||||
|
|
||||||
std::vector<std::function<void()>> cb_list; //Vector for storing any call-back functions added with register_cb()
|
std::vector<std::function<void()>> cb_list; // Vector for storing any call-back functions added with register_cb()
|
||||||
|
|
||||||
uint32_t meta_data[9]; ///<First 9 bytes of meta data returned from FRS read operation (we don't really need the rest) (See Ref. Manual 5.1)
|
uint32_t meta_data[9]; ///<First 9 bytes of meta data returned from FRS read operation (we don't really need the rest) (See Ref. Manual 5.1)
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,90 @@
|
||||||
|
menu "esp32_BNO08x"
|
||||||
|
|
||||||
|
menu "GPIO Configuration"
|
||||||
|
|
||||||
|
config ESP32_BNO08X_GPIO_HINT
|
||||||
|
int "INT GPIO NUM"
|
||||||
|
range 0 50
|
||||||
|
default 26
|
||||||
|
help
|
||||||
|
Host interrupt GPIO pin connected to BNO08x INT pin.
|
||||||
|
|
||||||
|
|
||||||
|
config ESP32_BNO08X_GPIO_RST
|
||||||
|
int "RST GPIO NUM"
|
||||||
|
range 0 50
|
||||||
|
default 32
|
||||||
|
help
|
||||||
|
Reset GPIO pin connected to BNO08x RST pin.
|
||||||
|
|
||||||
|
config ESP32_BNO08X_GPIO_CS
|
||||||
|
int "CS GPIO NUM"
|
||||||
|
range 0 50
|
||||||
|
default 33
|
||||||
|
help
|
||||||
|
Chip select GPIO pin connected to BNO08x CS pin.
|
||||||
|
|
||||||
|
config ESP32_BNO08X_GPIO_SCL
|
||||||
|
int "SCL GPIO NUM"
|
||||||
|
range 0 50
|
||||||
|
default 18
|
||||||
|
help
|
||||||
|
Clock GPIO pin connected to BNO08x SCL pin.
|
||||||
|
|
||||||
|
config ESP32_BNO08X_GPIO_DI
|
||||||
|
int "DI GPIO NUM"
|
||||||
|
range 0 50
|
||||||
|
default 23
|
||||||
|
help
|
||||||
|
MOSI GPIO pin connected to BNO08x DI pin.
|
||||||
|
|
||||||
|
config ESP32_BNO08X_GPIO_SDA
|
||||||
|
int "SDA GPIO NUM"
|
||||||
|
range 0 50
|
||||||
|
default 19
|
||||||
|
help
|
||||||
|
MISO GPIO pin connected to BNO08x SDA pin.
|
||||||
|
|
||||||
|
config ESP32_BNO08X_GPIO_WAKE
|
||||||
|
int "WAKE GPIO NUM (optional, -1 == unused)"
|
||||||
|
range -1 50
|
||||||
|
default -1
|
||||||
|
help
|
||||||
|
Wake GPIO pin, connected to BNO08x P0 pin (optional)
|
||||||
|
|
||||||
|
endmenu # GPIO Config
|
||||||
|
|
||||||
|
menu "SPI Configuration"
|
||||||
|
|
||||||
|
config ESP32_BNO08x_SPI_HOST
|
||||||
|
int "SPI Host Peripheral"
|
||||||
|
range 0 2
|
||||||
|
default 2
|
||||||
|
help
|
||||||
|
SPI controller peripheral inside ESP32.
|
||||||
|
|
||||||
|
|
||||||
|
config ESP32_BNO08X_SCL_SPEED_HZ
|
||||||
|
int "SCL SPEED (HZ)"
|
||||||
|
range 10000 3000000
|
||||||
|
default 2000000
|
||||||
|
help
|
||||||
|
SPI clock speed in Hz, default 2MHz.
|
||||||
|
|
||||||
|
endmenu #SPI Configuration
|
||||||
|
|
||||||
|
config ESP32_BNO08X_DATA_PROC_TASK_SZ
|
||||||
|
int "Callback task size, (data_proc_task())"
|
||||||
|
range 1024 20480
|
||||||
|
default 4096
|
||||||
|
help
|
||||||
|
Stack size of task responsible for parsing packets and executing callbacks.
|
||||||
|
Note that callbacks should remain as short as possible, pass the data out of
|
||||||
|
the callback with a queue or save it to different variables for longer operations.
|
||||||
|
|
||||||
|
config ESP32_BNO08x_DEBUG_STATEMENTS
|
||||||
|
bool "Print debug statements."
|
||||||
|
default "n"
|
||||||
|
help
|
||||||
|
Print the various debug statements scattered throughout the code when running.
|
||||||
|
endmenu
|
||||||
24
README.md
24
README.md
|
|
@ -10,7 +10,8 @@
|
||||||
<ul>
|
<ul>
|
||||||
<li><a href="#wiring">Wiring</a></li>
|
<li><a href="#wiring">Wiring</a></li>
|
||||||
<li><a href="#adding-to-project">Adding to Project</a></li>
|
<li><a href="#adding-to-project">Adding to Project</a></li>
|
||||||
<li><a href="#Examples">Examples</a></li>
|
<li><a href="#menuconfig">Menuconfig</a></li>
|
||||||
|
<li><a href="#examples">Examples</a></li>
|
||||||
</ul>
|
</ul>
|
||||||
</li>
|
</li>
|
||||||
<li><a href="#documentation">Documentation</a></li>
|
<li><a href="#documentation">Documentation</a></li>
|
||||||
|
|
@ -32,7 +33,10 @@ Currently, only SPI is supported. There are no plans to support I2C due to unpre
|
||||||
<p align="right">(<a href="#readme-top">back to top</a>)</p>
|
<p align="right">(<a href="#readme-top">back to top</a>)</p>
|
||||||
|
|
||||||
### Wiring
|
### Wiring
|
||||||
The default wiring is depicted below, it can be changed at driver initialization (see example section).
|
The default wiring is depicted below, it can be changed at driver initialization (see example section).
|
||||||
|
|
||||||
|
If your ESP does not have the GPIO pin numbers depicted below, you **must change the default GPIO settings in menuconfig**. See the Menuconfig section.
|
||||||
|
|
||||||

|

|
||||||
<p align="right">(<a href="#readme-top">back to top</a>)</p>
|
<p align="right">(<a href="#readme-top">back to top</a>)</p>
|
||||||
|
|
||||||
|
|
@ -59,6 +63,22 @@ The default wiring is depicted below, it can be changed at driver initialization
|
||||||
```
|
```
|
||||||
<p align="right">(<a href="#readme-top">back to top</a>)</p>
|
<p align="right">(<a href="#readme-top">back to top</a>)</p>
|
||||||
|
|
||||||
|
### Menuconfig
|
||||||
|
This library provides a menuconfig menu configured in Kconfig.projbuild. It contains settings to control the default GPIO and a few other things.
|
||||||
|
|
||||||
|
To access the menu:
|
||||||
|
|
||||||
|
1. Within esp-idf enabled terminal, execute the menuconfig command:
|
||||||
|
```sh
|
||||||
|
idf.py menuconfig
|
||||||
|
|
||||||
|
2. Scroll down to the esp_BNO08x menu and enter it, if you're using vsCode you may have to use the "j" and "k" keys instead of the arrow keys.
|
||||||
|

|
||||||
|
|
||||||
|
3. Modify whatever settings you'd like from the sub menus. The GPIO Configuration menu allows for the default GPIO pins to be modified, the SPI Configuration menu allows for the default SCLK frequency and host peripheral to be modified.
|
||||||
|

|
||||||
|
<p align="right">(<a href="#readme-top">back to top</a>)</p>
|
||||||
|
|
||||||
### Examples
|
### Examples
|
||||||
There are two ways data returned from the BNO08x can be accessed with this library:
|
There are two ways data returned from the BNO08x can be accessed with this library:
|
||||||
|
|
||||||
|
|
|
||||||
Binary file not shown.
|
After Width: | Height: | Size: 15 KiB |
Binary file not shown.
|
After Width: | Height: | Size: 21 KiB |
Loading…
Reference in New Issue