diff --git a/TODO.md b/TODO.md index cce0e7f..333f8b0 100644 --- a/TODO.md +++ b/TODO.md @@ -6,7 +6,8 @@ - [x] pca9685 驱动 - [x] Dshot 驱动 - [ ] pca9685 测试 -- [ ] dshot 测试 +- [x] dshot 测试 +- [ ] protobuf rpc 相关方法实现 ### 额外 diff --git a/components/aht30/aht30_intf.c b/components/aht30/aht30_intf.c index d2a339c..cabc0ec 100644 --- a/components/aht30/aht30_intf.c +++ b/components/aht30/aht30_intf.c @@ -34,27 +34,15 @@ * */ -#include "driver/i2c_master.h" // esp_driver_i2c -#include "sdkconfig.h" -#include "esp_log.h" #include "freertos/FreeRTOS.h" #include "freertos/task.h" -#include "aht30_intf.h" - -#if CONFIG_SUB_ENABLE_AHT30 +#include "esp_log.h" +#include "driver/i2c_master.h" // esp_driver_i2c - #if (CONFIG_SUB_AHT30_IIC_PORT == 0) && CONFIG_SUB_ENABLE_I2C0 - extern i2c_master_bus_handle_t i2c0_bus_handle; - #define AHT30_I2C_BUS i2c0_bus_handle - #elif (CONFIG_SUB_AHT30_IIC_PORT == 1) && CONFIG_SUB_ENABLE_I2C0 - extern i2c_master_bus_handle_t i2c1_bus_handle; - #define AHT30_I2C_BUS i2c1_bus_handle - #else - #error certain i2c num not found or disabled - #endif +#include "sdkconfig.h" -#endif +#include "aht30_intf.h" i2c_master_dev_handle_t aht30_i2c_dev_handle; @@ -68,6 +56,18 @@ i2c_master_dev_handle_t aht30_i2c_dev_handle; uint8_t aht30_interface_iic_init(void) { #if CONFIG_SUB_ENABLE_AHT30 + esp_err_t handle_ret; + i2c_master_bus_handle_t aht30_i2c_handle; + #if (CONFIG_SUB_AHT30_IIC_PORT == 0) && CONFIG_SUB_ENABLE_I2C0 + handle_ret = i2c_master_get_bus_handle(0, &aht30_i2c_handle); + #elif (CONFIG_SUB_AHT30_IIC_PORT == 1) && CONFIG_SUB_ENABLE_I2C0 + handle_ret = i2c_master_get_bus_handle(1, &aht30_i2c_handle); + #else + #error certain i2c num not found or disabled + #endif + if (ESP_OK != handle_ret) + return 1; // interface not init + i2c_device_config_t i2c_dev_conf = { .device_address = CONFIG_SUB_AHT30_IIC_ADDRESS, .scl_speed_hz = CONFIG_SUB_AHT30_IIC_FREQUENCY, diff --git a/components/dshot/Kconfig.projbuild b/components/dshot/Kconfig.projbuild index 0dc9bd1..ac8bfaa 100644 --- a/components/dshot/Kconfig.projbuild +++ b/components/dshot/Kconfig.projbuild @@ -3,7 +3,7 @@ menu "SUB:DSHOT" config SUB_DSHOT_RESOLUTION int "Resolution of Dshot" - default 32000000 + default 40000000 help Resolution of DSHOT, 32000000 is 32MHz. diff --git a/components/dshot/dshot.c b/components/dshot/dshot.c index a49c4ae..feecc93 100644 --- a/components/dshot/dshot.c +++ b/components/dshot/dshot.c @@ -4,11 +4,13 @@ * SPDX-License-Identifier: Apache-2.0 */ -#include "driver/rmt_tx.h" #include "freertos/FreeRTOS.h" #include "freertos/task.h" + #include "esp_log.h" #include "esp_check.h" +#include "driver/rmt_tx.h" + #include "sdkconfig.h" #include "dshot.h" @@ -216,6 +218,18 @@ int rmt_dshot_init(dshot_handle_t *handle, gpio_num_t gpio_num) return -1; } + rmt_transmit_config_t tx_config = { + .loop_count = -1, // infinite loop + }; + dshot_esc_throttle_t throttle = { + .throttle = 0, + .telemetry_req = false, // telemetry is not supported in this example + }; + if (ESP_OK != rmt_transmit(handle->channel, handle->encoder, &throttle, sizeof(throttle), &tx_config)) + { + return -1; + } + return 0; } diff --git a/components/pca9685/include/pca9685_app.h b/components/pca9685/include/pca9685_app.h index 0626184..9b1ed31 100644 --- a/components/pca9685/include/pca9685_app.h +++ b/components/pca9685/include/pca9685_app.h @@ -65,7 +65,7 @@ extern "C"{ #define PCA9685_APP_DEFAULT_SUBADDRESS_1 0xE2 /**< 0xE2 */ #define PCA9685_APP_DEFAULT_SUBADDRESS_2 0xE4 /**< 0xE4 */ #define PCA9685_APP_DEFAULT_SUBADDRESS_3 0xE8 /**< 0xE8 */ -#define PCA9685_APP_DEFAULT_OSCILLATOR_FREQUENCY 50000000 /**< 25MHz */ +#define PCA9685_APP_DEFAULT_OSCILLATOR_FREQUENCY 50000000 /**< 50MHz */ /** * @brief basic example init @@ -99,7 +99,7 @@ uint8_t pca9685_app_deinit(void); * 0.0 <= delay_percent <= 100.0 * 0.0 <= high_duty_cycle_percent <= 100.0 */ -uint8_t pca9685_app_write(pca9685_channel_t channel, float delay_percent, float high_duty_cycle_percent); +uint8_t pca9685_app_write(pca9685_channel_t channel, uint16_t high_duty_cycle_us); /** * @} diff --git a/components/pca9685/pca9685_app.c b/components/pca9685/pca9685_app.c index d5b71af..b502bf7 100644 --- a/components/pca9685/pca9685_app.c +++ b/components/pca9685/pca9685_app.c @@ -37,6 +37,7 @@ #include "pca9685_app.h" static pca9685_handle_t gs_handle; /**< pca9685 handle */ +static uint16_t g_output_freq_hz; /** * @brief basic example init @@ -111,6 +112,7 @@ uint8_t pca9685_app_init(pca9685_address_t addr, uint16_t hz) return 1; } + g_output_freq_hz = hz; /* set pre scale */ res = pca9685_set_prescaler(&gs_handle, reg); @@ -327,13 +329,19 @@ uint8_t pca9685_app_deinit(void) * 0.0 <= delay_percent <= 100.0 * 0.0 <= high_duty_cycle_percent <= 100.0 */ -uint8_t pca9685_app_write(pca9685_channel_t channel, float delay_percent, float high_duty_cycle_percent) +uint8_t pca9685_app_write(pca9685_channel_t channel, uint16_t high_duty_cycle_us) { uint8_t res; uint16_t on_count, off_count; - + + if (g_output_freq_hz == 0) + return 1; + float high_duty_cycle_percent = 1.f / (float)g_output_freq_hz; // 周期 in s + high_duty_cycle_percent *= 1000.f * 1000.f; // s to us + high_duty_cycle_percent = (float)high_duty_cycle_us / high_duty_cycle_percent; // final val + /* convert data */ - res = pca9685_pwm_convert_to_register(&gs_handle, delay_percent, high_duty_cycle_percent, (uint16_t *)&on_count, (uint16_t *)&off_count); + res = pca9685_pwm_convert_to_register(&gs_handle, 0.f, high_duty_cycle_percent, (uint16_t *)&on_count, (uint16_t *)&off_count); if (res != 0) { return 1; diff --git a/components/pca9685/pca9685_intf.c b/components/pca9685/pca9685_intf.c index 5f08a08..3aaf38e 100644 --- a/components/pca9685/pca9685_intf.c +++ b/components/pca9685/pca9685_intf.c @@ -34,28 +34,16 @@ * */ -#include "driver/i2c_master.h" // esp_driver_i2c -#include "driver/gpio.h" -#include "sdkconfig.h" -#include "esp_log.h" #include "freertos/FreeRTOS.h" #include "freertos/task.h" -#include "pca9685_intf.h" - -#if CONFIG_SUB_ENABLE_PCA9685 +#include "esp_log.h" +#include "driver/gpio.h" +#include "driver/i2c_master.h" - #if (CONFIG_SUB_PCA9685_IIC_PORT == 0) && CONFIG_SUB_ENABLE_I2C0 - extern i2c_master_bus_handle_t i2c0_bus_handle; - #define PCA9685_I2C_BUS i2c0_bus_handle - #elif (CONFIG_SUB_PCA9685_IIC_PORT == 1) && CONFIG_SUB_ENABLE_I2C1 - extern i2c_master_bus_handle_t i2c1_bus_handle; - #define PCA9685_I2C_BUS i2c1_bus_handle - #else - #error certain i2c num not found or disabled - #endif +#include "sdkconfig.h" -#endif +#include "pca9685_intf.h" i2c_master_dev_handle_t pca9685_i2c_dev_handle; @@ -69,11 +57,23 @@ i2c_master_dev_handle_t pca9685_i2c_dev_handle; uint8_t pca9685_interface_iic_init(void) { #if CONFIG_SUB_ENABLE_PCA9685 + esp_err_t handle_ret; + i2c_master_bus_handle_t pca9685_i2c_handle; + #if (CONFIG_SUB_PCA9685_IIC_PORT == 0) && CONFIG_SUB_ENABLE_I2C0 + handle_ret = i2c_master_get_bus_handle(0, &pca9685_i2c_handle); + #elif (CONFIG_SUB_PCA9685_IIC_PORT == 1) && CONFIG_SUB_ENABLE_I2C1 + handle_ret = i2c_master_get_bus_handle(1, &pca9685_i2c_handle); + #else + #error certain i2c num not found or disabled + #endif + if (ESP_OK != handle_ret) + return 1; // interface not init + i2c_device_config_t i2c_dev_conf = { .device_address = CONFIG_SUB_PCA9685_IIC_ADDRESS, .scl_speed_hz = CONFIG_SUB_PCA9685_IIC_FREQUENCY, }; - if (ESP_OK == i2c_master_bus_add_device(PCA9685_I2C_BUS, &i2c_dev_conf, &pca9685_i2c_dev_handle)) + if (ESP_OK == i2c_master_bus_add_device(pca9685_i2c_handle, &i2c_dev_conf, &pca9685_i2c_dev_handle)) return 0; else return 1; // NO_MEM diff --git a/components/protobuf_rpc/CMakeLists.txt b/components/protobuf_rpc/CMakeLists.txt new file mode 100644 index 0000000..f4f93ec --- /dev/null +++ b/components/protobuf_rpc/CMakeLists.txt @@ -0,0 +1,4 @@ +idf_component_register(SRCS "pb_rpc.c" "message_cmd.c" "navi_master.pb.c" + INCLUDE_DIRS "include" + PRIV_REQUIRES esp_driver_uart dshot pca9685 + REQUIRES nanopb) diff --git a/components/protobuf_rpc/Kconfig.projbuild b/components/protobuf_rpc/Kconfig.projbuild new file mode 100644 index 0000000..6a16b89 --- /dev/null +++ b/components/protobuf_rpc/Kconfig.projbuild @@ -0,0 +1,92 @@ +menu "SUB:ProtoBuf-RPC" + menu "Interface" + config SUB_PROTOBUF_UART_PORT + int "Which UARTx will be used" + default 0 + help + The interface that used to communicate with sub-navi. + + config SUB_PROTOBUF_UART_BAUDRATE + int "Set UART baudrate" + default 115200 + help + The baudrate of UARTx. + + config SUB_PROTOBUF_UART_QUEUE_SIZE + int "Set UART queue size" + default 20 + help + The queue size of UARTx. + + config SUB_PROTOBUF_UART_CUSTOM_PINS + bool "Use custom pins" + default n + help + If you want to use custom pins for UARTx, enable this option. + + if SUB_PROTOBUF_UART_CUSTOM_PINS + config SUB_PROTOBUF_UART_TX_PIN + int "UARTx TX pin" + default 17 + help + The TX pin of UARTx. + + config SUB_PROTOBUF_UART_RX_PIN + int "UARTx RX pin" + default 16 + help + The RX pin of UARTx. + endif + endmenu + + menu "Thruster" + config SUB_PROTOBUF_THRUSTER0_PIN + int "Thruster0 pin" + default 18 + help + The pin of thruster channel 0. + + config SUB_PROTOBUF_THRUSTER1_PIN + int "Thruster1 pin" + default 19 + help + The pin of thruster channel 1. + + config SUB_PROTOBUF_THRUSTER2_PIN + int "Thruster2 pin" + default 20 + help + The pin of thruster channel 2. + + config SUB_PROTOBUF_THRUSTER3_PIN + int "Thruster3 pin" + default 21 + help + The pin of thruster channel 3. + + config SUB_PROTOBUF_THRUSTER4_PIN + int "Thruster4 pin" + default 22 + help + The pin of thruster channel 4. + + config SUB_PROTOBUF_THRUSTER5_PIN + int "Thruster5 pin" + default 23 + help + The pin of thruster channel 5. + + config SUB_PROTOBUF_THRUSTER6_PIN + int "Thruster6 pin" + default 24 + help + The pin of thruster channel 6. + + config SUB_PROTOBUF_THRUSTER7_PIN + int "Thruster7 pin" + default 25 + help + The pin of thruster channel 7. + endmenu + +endmenu diff --git a/components/protobuf_rpc/include/message_cmd.h b/components/protobuf_rpc/include/message_cmd.h new file mode 100644 index 0000000..97ab6c9 --- /dev/null +++ b/components/protobuf_rpc/include/message_cmd.h @@ -0,0 +1,13 @@ +#ifndef SUB_PB_RPC_CMD_H +#define SUB_PB_RPC_CMD_H + +#include "navi_master.pb.h" + +// for main +int message_cmd_init(void); + +// for component itself +void message_thruster_cmd(ThrusterCommand *msg); +void message_pwmDev_cmd(PWMDevCommand *msg); + +#endif //SUB_PB_RPC_CMD_H diff --git a/components/protobuf_rpc/include/navi_master.pb.h b/components/protobuf_rpc/include/navi_master.pb.h new file mode 100644 index 0000000..66120d7 --- /dev/null +++ b/components/protobuf_rpc/include/navi_master.pb.h @@ -0,0 +1,227 @@ +/* Automatically generated nanopb header */ +/* Generated by nanopb-1.0.0-dev */ + +#ifndef PB_NAVI_MASTER_PB_H_INCLUDED +#define PB_NAVI_MASTER_PB_H_INCLUDED +#include + +#if PB_PROTO_HEADER_VERSION != 40 +#error Regenerate this file with the current version of nanopb generator. +#endif + +/* Struct definitions */ +typedef struct _ThrusterCommand { + bool has_throttle0; + uint32_t throttle0; + bool has_throttle1; + uint32_t throttle1; + bool has_throttle2; + uint32_t throttle2; + bool has_throttle3; + uint32_t throttle3; + bool has_throttle4; + uint32_t throttle4; + bool has_throttle5; + uint32_t throttle5; + bool has_throttle6; + uint32_t throttle6; + bool has_throttle7; + uint32_t throttle7; +} ThrusterCommand; + +typedef struct _PWMDevCommand { + bool has_duty0; + uint32_t duty0; + bool has_duty1; + uint32_t duty1; + bool has_duty2; + uint32_t duty2; + bool has_duty3; + uint32_t duty3; + bool has_duty4; + uint32_t duty4; + bool has_duty5; + uint32_t duty5; + bool has_duty6; + uint32_t duty6; + bool has_duty7; + uint32_t duty7; + bool has_duty8; + uint32_t duty8; + bool has_duty9; + uint32_t duty9; + bool has_duty10; + uint32_t duty10; + bool has_duty11; + uint32_t duty11; + bool has_duty12; + uint32_t duty12; + bool has_duty13; + uint32_t duty13; + bool has_duty14; + uint32_t duty14; + bool has_duty15; + uint32_t duty15; +} PWMDevCommand; + +typedef struct _Commands { + bool has_msgTC; + ThrusterCommand msgTC; + bool has_msgPDC; + PWMDevCommand msgPDC; +} Commands; + +typedef struct _DepthSensorResponse { + float depth; +} DepthSensorResponse; + +typedef struct _PressureSensorResponse { + int32_t pressure; +} PressureSensorResponse; + +typedef struct _Responses { + bool has_msgDSR; + DepthSensorResponse msgDSR; + bool has_msgPSR; + PressureSensorResponse msgPSR; +} Responses; + + +#ifdef __cplusplus +extern "C" { +#endif + +/* Initializer values for message structs */ +#define ThrusterCommand_init_default {false, 0, false, 0, false, 0, false, 0, false, 0, false, 0, false, 0, false, 0} +#define PWMDevCommand_init_default {false, 0, false, 0, false, 0, false, 0, false, 0, false, 0, false, 0, false, 0, false, 0, false, 0, false, 0, false, 0, false, 0, false, 0, false, 0, false, 0} +#define Commands_init_default {false, ThrusterCommand_init_default, false, PWMDevCommand_init_default} +#define DepthSensorResponse_init_default {0} +#define PressureSensorResponse_init_default {0} +#define Responses_init_default {false, DepthSensorResponse_init_default, false, PressureSensorResponse_init_default} +#define ThrusterCommand_init_zero {false, 0, false, 0, false, 0, false, 0, false, 0, false, 0, false, 0, false, 0} +#define PWMDevCommand_init_zero {false, 0, false, 0, false, 0, false, 0, false, 0, false, 0, false, 0, false, 0, false, 0, false, 0, false, 0, false, 0, false, 0, false, 0, false, 0, false, 0} +#define Commands_init_zero {false, ThrusterCommand_init_zero, false, PWMDevCommand_init_zero} +#define DepthSensorResponse_init_zero {0} +#define PressureSensorResponse_init_zero {0} +#define Responses_init_zero {false, DepthSensorResponse_init_zero, false, PressureSensorResponse_init_zero} + +/* Field tags (for use in manual encoding/decoding) */ +#define ThrusterCommand_throttle0_tag 1 +#define ThrusterCommand_throttle1_tag 2 +#define ThrusterCommand_throttle2_tag 3 +#define ThrusterCommand_throttle3_tag 4 +#define ThrusterCommand_throttle4_tag 5 +#define ThrusterCommand_throttle5_tag 6 +#define ThrusterCommand_throttle6_tag 7 +#define ThrusterCommand_throttle7_tag 8 +#define PWMDevCommand_duty0_tag 1 +#define PWMDevCommand_duty1_tag 2 +#define PWMDevCommand_duty2_tag 3 +#define PWMDevCommand_duty3_tag 4 +#define PWMDevCommand_duty4_tag 5 +#define PWMDevCommand_duty5_tag 6 +#define PWMDevCommand_duty6_tag 7 +#define PWMDevCommand_duty7_tag 8 +#define PWMDevCommand_duty8_tag 9 +#define PWMDevCommand_duty9_tag 10 +#define PWMDevCommand_duty10_tag 11 +#define PWMDevCommand_duty11_tag 12 +#define PWMDevCommand_duty12_tag 13 +#define PWMDevCommand_duty13_tag 14 +#define PWMDevCommand_duty14_tag 15 +#define PWMDevCommand_duty15_tag 16 +#define Commands_msgTC_tag 1 +#define Commands_msgPDC_tag 2 +#define DepthSensorResponse_depth_tag 1 +#define PressureSensorResponse_pressure_tag 1 +#define Responses_msgDSR_tag 1 +#define Responses_msgPSR_tag 2 + +/* Struct field encoding specification for nanopb */ +#define ThrusterCommand_FIELDLIST(X, a) \ +X(a, STATIC, OPTIONAL, UINT32, throttle0, 1) \ +X(a, STATIC, OPTIONAL, UINT32, throttle1, 2) \ +X(a, STATIC, OPTIONAL, UINT32, throttle2, 3) \ +X(a, STATIC, OPTIONAL, UINT32, throttle3, 4) \ +X(a, STATIC, OPTIONAL, UINT32, throttle4, 5) \ +X(a, STATIC, OPTIONAL, UINT32, throttle5, 6) \ +X(a, STATIC, OPTIONAL, UINT32, throttle6, 7) \ +X(a, STATIC, OPTIONAL, UINT32, throttle7, 8) +#define ThrusterCommand_CALLBACK NULL +#define ThrusterCommand_DEFAULT NULL + +#define PWMDevCommand_FIELDLIST(X, a) \ +X(a, STATIC, OPTIONAL, UINT32, duty0, 1) \ +X(a, STATIC, OPTIONAL, UINT32, duty1, 2) \ +X(a, STATIC, OPTIONAL, UINT32, duty2, 3) \ +X(a, STATIC, OPTIONAL, UINT32, duty3, 4) \ +X(a, STATIC, OPTIONAL, UINT32, duty4, 5) \ +X(a, STATIC, OPTIONAL, UINT32, duty5, 6) \ +X(a, STATIC, OPTIONAL, UINT32, duty6, 7) \ +X(a, STATIC, OPTIONAL, UINT32, duty7, 8) \ +X(a, STATIC, OPTIONAL, UINT32, duty8, 9) \ +X(a, STATIC, OPTIONAL, UINT32, duty9, 10) \ +X(a, STATIC, OPTIONAL, UINT32, duty10, 11) \ +X(a, STATIC, OPTIONAL, UINT32, duty11, 12) \ +X(a, STATIC, OPTIONAL, UINT32, duty12, 13) \ +X(a, STATIC, OPTIONAL, UINT32, duty13, 14) \ +X(a, STATIC, OPTIONAL, UINT32, duty14, 15) \ +X(a, STATIC, OPTIONAL, UINT32, duty15, 16) +#define PWMDevCommand_CALLBACK NULL +#define PWMDevCommand_DEFAULT NULL + +#define Commands_FIELDLIST(X, a) \ +X(a, STATIC, OPTIONAL, MESSAGE, msgTC, 1) \ +X(a, STATIC, OPTIONAL, MESSAGE, msgPDC, 2) +#define Commands_CALLBACK NULL +#define Commands_DEFAULT NULL +#define Commands_msgTC_MSGTYPE ThrusterCommand +#define Commands_msgPDC_MSGTYPE PWMDevCommand + +#define DepthSensorResponse_FIELDLIST(X, a) \ +X(a, STATIC, REQUIRED, FLOAT, depth, 1) +#define DepthSensorResponse_CALLBACK NULL +#define DepthSensorResponse_DEFAULT NULL + +#define PressureSensorResponse_FIELDLIST(X, a) \ +X(a, STATIC, REQUIRED, INT32, pressure, 1) +#define PressureSensorResponse_CALLBACK NULL +#define PressureSensorResponse_DEFAULT NULL + +#define Responses_FIELDLIST(X, a) \ +X(a, STATIC, OPTIONAL, MESSAGE, msgDSR, 1) \ +X(a, STATIC, OPTIONAL, MESSAGE, msgPSR, 2) +#define Responses_CALLBACK NULL +#define Responses_DEFAULT NULL +#define Responses_msgDSR_MSGTYPE DepthSensorResponse +#define Responses_msgPSR_MSGTYPE PressureSensorResponse + +extern const pb_msgdesc_t ThrusterCommand_msg; +extern const pb_msgdesc_t PWMDevCommand_msg; +extern const pb_msgdesc_t Commands_msg; +extern const pb_msgdesc_t DepthSensorResponse_msg; +extern const pb_msgdesc_t PressureSensorResponse_msg; +extern const pb_msgdesc_t Responses_msg; + +/* Defines for backwards compatibility with code written before nanopb-0.4.0 */ +#define ThrusterCommand_fields &ThrusterCommand_msg +#define PWMDevCommand_fields &PWMDevCommand_msg +#define Commands_fields &Commands_msg +#define DepthSensorResponse_fields &DepthSensorResponse_msg +#define PressureSensorResponse_fields &PressureSensorResponse_msg +#define Responses_fields &Responses_msg + +/* Maximum encoded size of messages (where known) */ +#define Commands_size 149 +#define DepthSensorResponse_size 5 +#define NAVI_MASTER_PB_H_MAX_SIZE Commands_size +#define PWMDevCommand_size 97 +#define PressureSensorResponse_size 11 +#define Responses_size 20 +#define ThrusterCommand_size 48 + +#ifdef __cplusplus +} /* extern "C" */ +#endif + +#endif \ No newline at end of file diff --git a/main/pb_com.h b/components/protobuf_rpc/include/pb_rpc.h similarity index 77% rename from main/pb_com.h rename to components/protobuf_rpc/include/pb_rpc.h index 99d103a..ba069f6 100644 --- a/main/pb_com.h +++ b/components/protobuf_rpc/include/pb_rpc.h @@ -1,5 +1,5 @@ -#ifndef SUB_MAIN_PB_COM_H -#define SUB_MAIN_PB_COM_H +#ifndef SUB_PB_RPC_H +#define SUB_PB_RPC_H #include "pb_common.h" diff --git a/components/protobuf_rpc/message_cmd.c b/components/protobuf_rpc/message_cmd.c new file mode 100644 index 0000000..7322de5 --- /dev/null +++ b/components/protobuf_rpc/message_cmd.c @@ -0,0 +1,172 @@ +#include "esp_log.h" + +#include "dshot.h" +#include "pca9685_app.h" + +#include "sdkconfig.h" + +#include "message_cmd.h" + +static const char *TAG = "protobuf_commu_rpc_cmd"; + +static dshot_handle_t dshot_chan0, dshot_chan1, dshot_chan2, dshot_chan3, + dshot_chan4, dshot_chan5, dshot_chan6, dshot_chan7; + +static int thruster_init(void) +{ + int ret = 0; + ret += rmt_dshot_init(&dshot_chan0, CONFIG_SUB_PROTOBUF_THRUSTER0_PIN); + ret += rmt_dshot_init(&dshot_chan1, CONFIG_SUB_PROTOBUF_THRUSTER1_PIN); + ret += rmt_dshot_init(&dshot_chan2, CONFIG_SUB_PROTOBUF_THRUSTER2_PIN); + ret += rmt_dshot_init(&dshot_chan3, CONFIG_SUB_PROTOBUF_THRUSTER3_PIN); + ret += rmt_dshot_init(&dshot_chan4, CONFIG_SUB_PROTOBUF_THRUSTER4_PIN); + ret += rmt_dshot_init(&dshot_chan5, CONFIG_SUB_PROTOBUF_THRUSTER5_PIN); + ret += rmt_dshot_init(&dshot_chan6, CONFIG_SUB_PROTOBUF_THRUSTER6_PIN); + ret += rmt_dshot_init(&dshot_chan7, CONFIG_SUB_PROTOBUF_THRUSTER7_PIN); + return ret; +} + +static int pwmDev_init(void) +{ + if (0 != pca9685_app_init(PCA9685_ADDRESS_A000000, 50)) // 50Hz + return -1; + // pca9685_app_write ... + return 0; +} + +int message_cmd_init(void) +{ + int ret = 0; + ret += thruster_init(); + ret += pwmDev_init(); + // other cmd init ... + return ret; +} + +void message_thruster_cmd(ThrusterCommand *msg) +{ + if (msg->has_throttle0) + { + ESP_LOGD(TAG, "dshot_chan0: %ld", msg->throttle0); + rmt_dshot_write_throttle(dshot_chan0, msg->throttle0); + } + if (msg->has_throttle1) + { + ESP_LOGD(TAG, "dshot_chan1: %ld", msg->throttle1); + rmt_dshot_write_throttle(dshot_chan1, msg->throttle1); + } + if (msg->has_throttle2) + { + ESP_LOGD(TAG, "dshot_chan2: %ld", msg->throttle2); + rmt_dshot_write_throttle(dshot_chan2, msg->throttle2); + } + if (msg->has_throttle3) + { + ESP_LOGD(TAG, "dshot_chan3: %ld", msg->throttle3); + rmt_dshot_write_throttle(dshot_chan3, msg->throttle3); + } + if (msg->has_throttle4) + { + ESP_LOGD(TAG, "dshot_chan4: %ld", msg->throttle4); + rmt_dshot_write_throttle(dshot_chan4, msg->throttle4); + } + if (msg->has_throttle5) + { + ESP_LOGD(TAG, "dshot_chan5: %ld", msg->throttle5); + rmt_dshot_write_throttle(dshot_chan5, msg->throttle5); + } + if (msg->has_throttle6) + { + ESP_LOGD(TAG, "dshot_chan6: %ld", msg->throttle6); + rmt_dshot_write_throttle(dshot_chan6, msg->throttle6); + } + if (msg->has_throttle7) + { + ESP_LOGD(TAG, "dshot_chan7: %ld", msg->throttle7); + rmt_dshot_write_throttle(dshot_chan7, msg->throttle7); + } +} + +void message_pwmDev_cmd(PWMDevCommand *msg) +{ + if (msg->has_duty0) + { + ESP_LOGD(TAG, "pwm_chan0: %ld", msg->duty0); + pca9685_app_write(PCA9685_CHANNEL_0, msg->duty0); + } + if (msg->has_duty1) + { + ESP_LOGD(TAG, "pwm_chan1: %ld", msg->duty1); + pca9685_app_write(PCA9685_CHANNEL_1, msg->duty1); + } + if (msg->has_duty2) + { + ESP_LOGD(TAG, "pwm_chan2: %ld", msg->duty2); + pca9685_app_write(PCA9685_CHANNEL_2, msg->duty2); + } + if (msg->has_duty3) + { + ESP_LOGD(TAG, "pwm_chan3: %ld", msg->duty3); + pca9685_app_write(PCA9685_CHANNEL_3, msg->duty3); + } + if (msg->has_duty4) + { + ESP_LOGD(TAG, "pwm_chan4: %ld", msg->duty4); + pca9685_app_write(PCA9685_CHANNEL_4, msg->duty4); + } + if (msg->has_duty5) + { + ESP_LOGD(TAG, "pwm_chan5: %ld", msg->duty5); + pca9685_app_write(PCA9685_CHANNEL_5, msg->duty5); + } + if (msg->has_duty6) + { + ESP_LOGD(TAG, "pwm_chan6: %ld", msg->duty6); + pca9685_app_write(PCA9685_CHANNEL_6, msg->duty6); + } + if (msg->has_duty7) + { + ESP_LOGD(TAG, "pwm_chan7: %ld", msg->duty7); + pca9685_app_write(PCA9685_CHANNEL_7, msg->duty7); + } + if (msg->has_duty8) + { + ESP_LOGD(TAG, "pwm_chan8: %ld", msg->duty8); + pca9685_app_write(PCA9685_CHANNEL_8, msg->duty8); + } + if (msg->has_duty9) + { + ESP_LOGD(TAG, "pwm_chan9: %ld", msg->duty9); + pca9685_app_write(PCA9685_CHANNEL_9, msg->duty9); + } + if (msg->has_duty10) + { + ESP_LOGD(TAG, "pwm_chan10: %ld", msg->duty10); + pca9685_app_write(PCA9685_CHANNEL_10, msg->duty10); + } + if (msg->has_duty11) + { + ESP_LOGD(TAG, "pwm_chan11: %ld", msg->duty11); + pca9685_app_write(PCA9685_CHANNEL_11, msg->duty11); + } + if (msg->has_duty12) + { + ESP_LOGD(TAG, "pwm_chan12: %ld", msg->duty12); + pca9685_app_write(PCA9685_CHANNEL_12, msg->duty12); + } + if (msg->has_duty13) + { + ESP_LOGD(TAG, "pwm_chan13: %ld", msg->duty13); + pca9685_app_write(PCA9685_CHANNEL_13, msg->duty13); + } + if (msg->has_duty14) + { + ESP_LOGD(TAG, "pwm_chan14: %ld", msg->duty14); + pca9685_app_write(PCA9685_CHANNEL_14, msg->duty14); + } + if (msg->has_duty15) + { + ESP_LOGD(TAG, "pwm_chan15: %ld", msg->duty15); + pca9685_app_write(PCA9685_CHANNEL_15, msg->duty15); + } +} diff --git a/main/navi_master.pb.c b/components/protobuf_rpc/navi_master.pb.c similarity index 69% rename from main/navi_master.pb.c rename to components/protobuf_rpc/navi_master.pb.c index 5528e22..39557aa 100644 --- a/main/navi_master.pb.c +++ b/components/protobuf_rpc/navi_master.pb.c @@ -9,16 +9,16 @@ PB_BIND(ThrusterCommand, ThrusterCommand, AUTO) -PB_BIND(ArmCommand, ArmCommand, AUTO) +PB_BIND(PWMDevCommand, PWMDevCommand, AUTO) PB_BIND(Commands, Commands, AUTO) -PB_BIND(DepthResponse, DepthResponse, AUTO) +PB_BIND(DepthSensorResponse, DepthSensorResponse, AUTO) -PB_BIND(CleanPressureResponse, CleanPressureResponse, AUTO) +PB_BIND(PressureSensorResponse, PressureSensorResponse, AUTO) PB_BIND(Responses, Responses, AUTO) diff --git a/main/pb_com.c b/components/protobuf_rpc/pb_rpc.c similarity index 94% rename from main/pb_com.c rename to components/protobuf_rpc/pb_rpc.c index ea6db75..fc8c193 100644 --- a/main/pb_com.c +++ b/components/protobuf_rpc/pb_rpc.c @@ -1,16 +1,19 @@ -#include "driver/uart.h" #include "freertos/FreeRTOS.h" #include "freertos/queue.h" #include "freertos/task.h" + #include "esp_log.h" -#include "sdkconfig.h" +#include "driver/uart.h" #include "pb_decode.h" #include "pb_encode.h" +#include "message_cmd.h" #include "navi_master.pb.h" -#include "pb_com.h" +#include "sdkconfig.h" + +#include "pb_rpc.h" static const char *TAG = "protobuf_commu"; @@ -65,13 +68,15 @@ static int protobuf_command_rpc(uint8_t *data, size_t size) { ThrusterCommand msg = {}; status = decode_unionmessage_contents(&stream, ThrusterCommand_fields, &msg); - ESP_LOGD(TAG, "Got MsgType1"); + ESP_LOGD(TAG, "Got ThrusterCommand"); + message_thruster_cmd(&msg); } - else if (type == ArmCommand_fields) + else if (type == PWMDevCommand_fields) { - ArmCommand msg = {}; - status = decode_unionmessage_contents(&stream, ArmCommand_fields, &msg); - ESP_LOGD(TAG, "Got MsgType2"); + PWMDevCommand msg = {}; + status = decode_unionmessage_contents(&stream, PWMDevCommand_fields, &msg); + ESP_LOGD(TAG, "Got ArmCommand"); + message_pwmDev_cmd(&msg); } if (!status) diff --git a/components/sub_bus_init/CMakeLists.txt b/components/sub_bus_init/CMakeLists.txt index 8d6db62..abc856a 100644 --- a/components/sub_bus_init/CMakeLists.txt +++ b/components/sub_bus_init/CMakeLists.txt @@ -1,5 +1,3 @@ idf_component_register(SRCS "sub_intf_init.c" - "sub_i2c.c" - "sub_spi.c" INCLUDE_DIRS "include" PRIV_REQUIRES esp_driver_i2c esp_driver_spi) \ No newline at end of file diff --git a/components/sub_bus_init/include/sub_i2c.h b/components/sub_bus_init/include/sub_i2c.h deleted file mode 100644 index dbb7f77..0000000 --- a/components/sub_bus_init/include/sub_i2c.h +++ /dev/null @@ -1,9 +0,0 @@ -#ifndef SUB_INTF_INIT_I2C_H -#define SUB_INTF_INIT_I2C_H - -#include "esp_err.h" - -esp_err_t sub_i2c_intf_init(void); -esp_err_t sub_i2c_intf_deinit(void); - -#endif diff --git a/components/sub_bus_init/include/sub_intf_init.h b/components/sub_bus_init/include/sub_intf_init.h index d37e20f..836b74e 100644 --- a/components/sub_bus_init/include/sub_intf_init.h +++ b/components/sub_bus_init/include/sub_intf_init.h @@ -1,9 +1,11 @@ #ifndef SUB_INTF_INIT_ALL_H #define SUB_INTF_INIT_ALL_H -#include "esp_err.h" - -esp_err_t sub_all_intf_init(void); -esp_err_t sub_all_intf_deinit(void); +/** + * @brief init all bus interface + * @param void + * @return 0 on success, other on failure + */ +int sub_all_intf_init(void); #endif diff --git a/components/sub_bus_init/include/sub_spi.h b/components/sub_bus_init/include/sub_spi.h deleted file mode 100644 index 07393f3..0000000 --- a/components/sub_bus_init/include/sub_spi.h +++ /dev/null @@ -1,9 +0,0 @@ -#ifndef SUB_INTF_INIT_SPI_H -#define SUB_INTF_INIT_SPI_H - -#include "esp_err.h" - -esp_err_t sub_spi_intf_init(void); -esp_err_t sub_spi_intf_deinit(void); - -#endif diff --git a/components/sub_bus_init/sub_i2c.c b/components/sub_bus_init/sub_i2c.c deleted file mode 100644 index 23f2b5b..0000000 --- a/components/sub_bus_init/sub_i2c.c +++ /dev/null @@ -1,53 +0,0 @@ -#include "driver/i2c_master.h" // esp_driver_i2c -#include "sdkconfig.h" - -#include "sub_i2c.h" - -#if CONFIG_SUB_ENABLE_I2C0 -i2c_master_bus_handle_t i2c0_bus_handle; -#endif -#if CONFIG_SUB_ENABLE_I2C1 -i2c_master_bus_handle_t i2c1_bus_handle; -#endif - -esp_err_t sub_i2c_intf_init() -{ - esp_err_t ret = ESP_OK; -#if CONFIG_SUB_ENABLE_I2C0 -{ - i2c_master_bus_config_t i2c_bus_config = { - .i2c_port = 0, - .sda_io_num = CONFIG_SUB_I2C0_SDA_PIN, - .scl_io_num = CONFIG_SUB_I2C0_SCL_PIN, - .clk_source = I2C_CLK_SRC_DEFAULT, - .glitch_ignore_cnt = 7, - }; - ret += i2c_new_master_bus(&i2c_bus_config, &i2c0_bus_handle); -} -#endif -#if CONFIG_SUB_ENABLE_I2C1 -{ - i2c_master_bus_config_t i2c_bus_config = { - .i2c_port = 1, - .sda_io_num = CONFIG_SUB_I2C1_SDA_PIN, - .scl_io_num = CONFIG_SUB_I2C1_SCL_PIN, - .clk_source = I2C_CLK_SRC_DEFAULT, - .glitch_ignore_cnt = 7, - }; - ret += i2c_new_master_bus(&i2c_bus_config, &i2c1_bus_handle); -} -#endif - return ret; -} - -esp_err_t sub_i2c_intf_deinit() -{ - esp_err_t ret = ESP_OK; -#if CONFIG_SUB_ENABLE_I2C0 - ret += i2c_del_master_bus(i2c0_bus_handle); -#endif -#if CONFIG_SUB_ENABLE_I2C1 - ret += i2c_del_master_bus(i2c1_bus_handle); -#endif - return ret; -} diff --git a/components/sub_bus_init/sub_intf_init.c b/components/sub_bus_init/sub_intf_init.c index c5ce775..c45799c 100644 --- a/components/sub_bus_init/sub_intf_init.c +++ b/components/sub_bus_init/sub_intf_init.c @@ -1,19 +1,67 @@ +#include "driver/spi_master.h" +#include "driver/i2c_master.h" + +#include "sdkconfig.h" + #include "sub_intf_init.h" -#include "sub_i2c.h" -#include "sub_spi.h" -esp_err_t sub_all_intf_init(void) +int sub_all_intf_init(void) { - esp_err_t ret = ESP_OK; - ret += sub_i2c_intf_init(); - ret += sub_spi_intf_init(); - return ret; + int ret = ESP_OK; +// IIC ------------------------ +#if CONFIG_SUB_ENABLE_I2C0 +{ + i2c_master_bus_handle_t i2c0_bus_handle; + i2c_master_bus_config_t i2c_bus_config = { + .i2c_port = 0, + .sda_io_num = CONFIG_SUB_I2C0_SDA_PIN, + .scl_io_num = CONFIG_SUB_I2C0_SCL_PIN, + .clk_source = I2C_CLK_SRC_DEFAULT, + .glitch_ignore_cnt = 7, + }; + ret += i2c_new_master_bus(&i2c_bus_config, &i2c0_bus_handle); } +#endif +#if CONFIG_SUB_ENABLE_I2C1 +{ + i2c_master_bus_handle_t i2c1_bus_handle; + i2c_master_bus_config_t i2c_bus_config = { + .i2c_port = 1, + .sda_io_num = CONFIG_SUB_I2C1_SDA_PIN, + .scl_io_num = CONFIG_SUB_I2C1_SCL_PIN, + .clk_source = I2C_CLK_SRC_DEFAULT, + .glitch_ignore_cnt = 7, + }; + ret += i2c_new_master_bus(&i2c_bus_config, &i2c1_bus_handle); +} +#endif -esp_err_t sub_all_intf_deinit(void) +// SPI ------------------------ +#if CONFIG_SUB_ENABLE_SPI2 +{ + spi_bus_config_t buscfg = { + .miso_io_num = CONFIG_SUB_SPI2_MISO_PIN, + .mosi_io_num = CONFIG_SUB_SPI2_MOSI_PIN, + .sclk_io_num = CONFIG_SUB_SPI2_CLK_PIN, + .quadwp_io_num = -1, + .quadhd_io_num = -1, + .max_transfer_sz = SOC_SPI_MAXIMUM_BUFFER_SIZE, + }; + ret += spi_bus_initialize(SPI2_HOST, &buscfg, SPI_DMA_CH_AUTO); +} +#endif +#if CONFIG_SUB_ENABLE_SPI3 { - esp_err_t ret = ESP_OK; - ret += sub_i2c_intf_deinit(); - ret += sub_spi_intf_deinit(); + spi_bus_config_t buscfg = { + .miso_io_num = CONFIG_SUB_SPI3_MISO_PIN, + .mosi_io_num = CONFIG_SUB_SPI3_MOSI_PIN, + .sclk_io_num = CONFIG_SUB_SPI3_CLK_PIN, + .quadwp_io_num = -1, + .quadhd_io_num = -1, + .max_transfer_sz = SOC_SPI_MAXIMUM_BUFFER_SIZE, + }; + ret += spi_bus_initialize(SPI3_HOST, &buscfg, SPI_DMA_CH_AUTO); +} +#endif return ret; } diff --git a/components/sub_bus_init/sub_spi.c b/components/sub_bus_init/sub_spi.c deleted file mode 100644 index 6c8faee..0000000 --- a/components/sub_bus_init/sub_spi.c +++ /dev/null @@ -1,48 +0,0 @@ -#include "driver/spi_master.h" // esp_driver_i2c -#include "sdkconfig.h" - -#include "sub_spi.h" - -esp_err_t sub_spi_intf_init(void) -{ - esp_err_t ret = ESP_OK; -#if CONFIG_SUB_ENABLE_SPI2 -{ - spi_bus_config_t buscfg = { - .miso_io_num = CONFIG_SUB_SPI2_MISO_PIN, - .mosi_io_num = CONFIG_SUB_SPI2_MOSI_PIN, - .sclk_io_num = CONFIG_SUB_SPI2_CLK_PIN, - .quadwp_io_num = -1, - .quadhd_io_num = -1, - .max_transfer_sz = SOC_SPI_MAXIMUM_BUFFER_SIZE, - }; - ret += spi_bus_initialize(SPI2_HOST, &buscfg, SPI_DMA_CH_AUTO); -} -#endif -#if CONFIG_SUB_ENABLE_SPI3 -{ - spi_bus_config_t buscfg = { - .miso_io_num = CONFIG_SUB_SPI3_MISO_PIN, - .mosi_io_num = CONFIG_SUB_SPI3_MOSI_PIN, - .sclk_io_num = CONFIG_SUB_SPI3_CLK_PIN, - .quadwp_io_num = -1, - .quadhd_io_num = -1, - .max_transfer_sz = SOC_SPI_MAXIMUM_BUFFER_SIZE, - }; - ret += spi_bus_initialize(SPI3_HOST, &buscfg, SPI_DMA_CH_AUTO); -} -#endif - return ret; -} - -esp_err_t sub_spi_intf_deinit(void) -{ - esp_err_t ret = ESP_OK; -#if CONFIG_SUB_ENABLE_SPI2 - ret += spi_bus_free(SPI2_HOST); -#endif -#if CONFIG_SUB_ENABLE_SPI3 - ret += spi_bus_free(SPI3_HOST); -#endif - return ret; -} diff --git a/main/CMakeLists.txt b/main/CMakeLists.txt index 700cfd2..b792ef6 100644 --- a/main/CMakeLists.txt +++ b/main/CMakeLists.txt @@ -1,7 +1,7 @@ idf_component_register(SRCS "main.c" - "navi_master.pb.c" "pb_com.c" INCLUDE_DIRS "." PRIV_REQUIRES - esp_driver_uart - nanopb sub_bus_init pca9685 aht30 dshot) \ No newline at end of file + nanopb protobuf_rpc # sub-navi + sub_bus_init dshot # interface + pca9685 aht30) # peripheral \ No newline at end of file diff --git a/main/Kconfig.projbuild b/main/Kconfig.projbuild deleted file mode 100644 index 6e99a0d..0000000 --- a/main/Kconfig.projbuild +++ /dev/null @@ -1,40 +0,0 @@ -menu "SUB:Main:ProtoBuf" - config SUB_PROTOBUF_UART_PORT - int "Which UARTx will be used" - default 0 - help - The interface that used to communicate with sub-navi. - - config SUB_PROTOBUF_UART_BAUDRATE - int "Set UART baudrate" - default 115200 - help - The baudrate of UARTx. - - config SUB_PROTOBUF_UART_QUEUE_SIZE - int "Set UART queue size" - default 20 - help - The queue size of UARTx. - - config SUB_PROTOBUF_UART_CUSTOM_PINS - bool "Use custom pins" - default n - help - If you want to use custom pins for UARTx, enable this option. - - if SUB_PROTOBUF_UART_CUSTOM_PINS - config SUB_PROTOBUF_UART_TX_PIN - int "UARTx TX pin" - default 17 - help - The TX pin of UARTx. - - config SUB_PROTOBUF_UART_RX_PIN - int "UARTx RX pin" - default 16 - help - The RX pin of UARTx. - endif - -endmenu diff --git a/main/main.c b/main/main.c index efbbb9e..5fa299f 100644 --- a/main/main.c +++ b/main/main.c @@ -6,16 +6,13 @@ #include "freertos/task.h" #include "esp_log.h" + // components #include "dshot.h" #include "aht30_app.h" #include "pca9685_app.h" #include "sub_intf_init.h" -// mains -#include "pb_com.h" -#include "navi_master.pb.h" - void app_main(void) { diff --git a/main/navi_master.pb.h b/main/navi_master.pb.h deleted file mode 100644 index 983fad4..0000000 --- a/main/navi_master.pb.h +++ /dev/null @@ -1,166 +0,0 @@ -/* Automatically generated nanopb header */ -/* Generated by nanopb-1.0.0-dev */ - -#ifndef PB_NAVI_MASTER_PB_H_INCLUDED -#define PB_NAVI_MASTER_PB_H_INCLUDED -#include - -#if PB_PROTO_HEADER_VERSION != 40 -#error Regenerate this file with the current version of nanopb generator. -#endif - -/* Struct definitions */ -typedef struct _ThrusterCommand { - bool has_throttle0; - int32_t throttle0; - bool has_throttle1; - int32_t throttle1; - bool has_throttle2; - int32_t throttle2; - bool has_throttle3; - int32_t throttle3; - bool has_throttle4; - int32_t throttle4; - bool has_throttle5; - int32_t throttle5; - bool has_throttle6; - int32_t throttle6; - bool has_throttle7; - int32_t throttle7; -} ThrusterCommand; - -typedef struct _ArmCommand { - int32_t value; -} ArmCommand; - -typedef struct _Commands { - bool has_msgTC; - ThrusterCommand msgTC; - bool has_msgAC; - ArmCommand msgAC; -} Commands; - -typedef struct _DepthResponse { - float depth; -} DepthResponse; - -typedef struct _CleanPressureResponse { - int32_t pressure; -} CleanPressureResponse; - -typedef struct _Responses { - bool has_msgDR; - DepthResponse msgDR; - bool has_msgCPR; - CleanPressureResponse msgCPR; -} Responses; - - -#ifdef __cplusplus -extern "C" { -#endif - -/* Initializer values for message structs */ -#define ThrusterCommand_init_default {false, 0, false, 0, false, 0, false, 0, false, 0, false, 0, false, 0, false, 0} -#define ArmCommand_init_default {0} -#define Commands_init_default {false, ThrusterCommand_init_default, false, ArmCommand_init_default} -#define DepthResponse_init_default {0} -#define CleanPressureResponse_init_default {0} -#define Responses_init_default {false, DepthResponse_init_default, false, CleanPressureResponse_init_default} -#define ThrusterCommand_init_zero {false, 0, false, 0, false, 0, false, 0, false, 0, false, 0, false, 0, false, 0} -#define ArmCommand_init_zero {0} -#define Commands_init_zero {false, ThrusterCommand_init_zero, false, ArmCommand_init_zero} -#define DepthResponse_init_zero {0} -#define CleanPressureResponse_init_zero {0} -#define Responses_init_zero {false, DepthResponse_init_zero, false, CleanPressureResponse_init_zero} - -/* Field tags (for use in manual encoding/decoding) */ -#define ThrusterCommand_throttle0_tag 1 -#define ThrusterCommand_throttle1_tag 2 -#define ThrusterCommand_throttle2_tag 3 -#define ThrusterCommand_throttle3_tag 4 -#define ThrusterCommand_throttle4_tag 5 -#define ThrusterCommand_throttle5_tag 6 -#define ThrusterCommand_throttle6_tag 7 -#define ThrusterCommand_throttle7_tag 8 -#define ArmCommand_value_tag 1 -#define Commands_msgTC_tag 1 -#define Commands_msgAC_tag 2 -#define DepthResponse_depth_tag 1 -#define CleanPressureResponse_pressure_tag 1 -#define Responses_msgDR_tag 1 -#define Responses_msgCPR_tag 2 - -/* Struct field encoding specification for nanopb */ -#define ThrusterCommand_FIELDLIST(X, a) \ -X(a, STATIC, OPTIONAL, INT32, throttle0, 1) \ -X(a, STATIC, OPTIONAL, INT32, throttle1, 2) \ -X(a, STATIC, OPTIONAL, INT32, throttle2, 3) \ -X(a, STATIC, OPTIONAL, INT32, throttle3, 4) \ -X(a, STATIC, OPTIONAL, INT32, throttle4, 5) \ -X(a, STATIC, OPTIONAL, INT32, throttle5, 6) \ -X(a, STATIC, OPTIONAL, INT32, throttle6, 7) \ -X(a, STATIC, OPTIONAL, INT32, throttle7, 8) -#define ThrusterCommand_CALLBACK NULL -#define ThrusterCommand_DEFAULT NULL - -#define ArmCommand_FIELDLIST(X, a) \ -X(a, STATIC, REQUIRED, INT32, value, 1) -#define ArmCommand_CALLBACK NULL -#define ArmCommand_DEFAULT NULL - -#define Commands_FIELDLIST(X, a) \ -X(a, STATIC, OPTIONAL, MESSAGE, msgTC, 1) \ -X(a, STATIC, OPTIONAL, MESSAGE, msgAC, 2) -#define Commands_CALLBACK NULL -#define Commands_DEFAULT NULL -#define Commands_msgTC_MSGTYPE ThrusterCommand -#define Commands_msgAC_MSGTYPE ArmCommand - -#define DepthResponse_FIELDLIST(X, a) \ -X(a, STATIC, REQUIRED, FLOAT, depth, 1) -#define DepthResponse_CALLBACK NULL -#define DepthResponse_DEFAULT NULL - -#define CleanPressureResponse_FIELDLIST(X, a) \ -X(a, STATIC, REQUIRED, INT32, pressure, 1) -#define CleanPressureResponse_CALLBACK NULL -#define CleanPressureResponse_DEFAULT NULL - -#define Responses_FIELDLIST(X, a) \ -X(a, STATIC, OPTIONAL, MESSAGE, msgDR, 1) \ -X(a, STATIC, OPTIONAL, MESSAGE, msgCPR, 2) -#define Responses_CALLBACK NULL -#define Responses_DEFAULT NULL -#define Responses_msgDR_MSGTYPE DepthResponse -#define Responses_msgCPR_MSGTYPE CleanPressureResponse - -extern const pb_msgdesc_t ThrusterCommand_msg; -extern const pb_msgdesc_t ArmCommand_msg; -extern const pb_msgdesc_t Commands_msg; -extern const pb_msgdesc_t DepthResponse_msg; -extern const pb_msgdesc_t CleanPressureResponse_msg; -extern const pb_msgdesc_t Responses_msg; - -/* Defines for backwards compatibility with code written before nanopb-0.4.0 */ -#define ThrusterCommand_fields &ThrusterCommand_msg -#define ArmCommand_fields &ArmCommand_msg -#define Commands_fields &Commands_msg -#define DepthResponse_fields &DepthResponse_msg -#define CleanPressureResponse_fields &CleanPressureResponse_msg -#define Responses_fields &Responses_msg - -/* Maximum encoded size of messages (where known) */ -#define ArmCommand_size 11 -#define CleanPressureResponse_size 11 -#define Commands_size 103 -#define DepthResponse_size 5 -#define NAVI_MASTER_PB_H_MAX_SIZE Commands_size -#define Responses_size 20 -#define ThrusterCommand_size 88 - -#ifdef __cplusplus -} /* extern "C" */ -#endif - -#endif \ No newline at end of file