mirror of
https://gitee.com/mirrors_PX4/PX4-Autopilot.git
synced 2026-11-01 04:11:36 +08:00
IO firmware: Convert magic numbers to defines
This is necessary to allow more and better unit testing.
This commit is contained in:
committed by
Daniel Agar
parent
e395c1f3d7
commit
d401252c9e
@@ -465,7 +465,7 @@ mixer_callback(uintptr_t handle,
|
|||||||
* not loaded faithfully.
|
* not loaded faithfully.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
static char mixer_text[200]; /* large enough for one mixer */
|
static char mixer_text[PX4IO_MAX_MIXER_LENGHT]; /* large enough for one mixer */
|
||||||
static unsigned mixer_text_length = 0;
|
static unsigned mixer_text_length = 0;
|
||||||
|
|
||||||
int
|
int
|
||||||
|
|||||||
@@ -0,0 +1,42 @@
|
|||||||
|
/****************************************************************************
|
||||||
|
*
|
||||||
|
* Copyright (c) 2017 PX4 Development Team. All rights reserved.
|
||||||
|
*
|
||||||
|
* Redistribution and use in source and binary forms, with or without
|
||||||
|
* modification, are permitted provided that the following conditions
|
||||||
|
* are met:
|
||||||
|
*
|
||||||
|
* 1. Redistributions of source code must retain the above copyright
|
||||||
|
* notice, this list of conditions and the following disclaimer.
|
||||||
|
* 2. Redistributions in binary form must reproduce the above copyright
|
||||||
|
* notice, this list of conditions and the following disclaimer in
|
||||||
|
* the documentation and/or other materials provided with the
|
||||||
|
* distribution.
|
||||||
|
* 3. Neither the name PX4 nor the names of its contributors may be
|
||||||
|
* used to endorse or promote products derived from this software
|
||||||
|
* without specific prior written permission.
|
||||||
|
*
|
||||||
|
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||||
|
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||||
|
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
|
||||||
|
* FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
|
||||||
|
* COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
|
||||||
|
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
|
||||||
|
* BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
|
||||||
|
* OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
|
||||||
|
* AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||||
|
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
|
||||||
|
* ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||||
|
* POSSIBILITY OF SUCH DAMAGE.
|
||||||
|
*
|
||||||
|
****************************************************************************/
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @file mixer.h
|
||||||
|
*
|
||||||
|
* PX4IO mixer definitions
|
||||||
|
*
|
||||||
|
* @author Lorenz Meier <lorenz@px4.io>
|
||||||
|
*/
|
||||||
|
#pragma once
|
||||||
|
#define PX4IO_MAX_MIXER_LENGHT 230
|
||||||
@@ -82,16 +82,17 @@
|
|||||||
#define PX4IO_PROTOCOL_MAX_CONTROL_COUNT 8 /**< The protocol does not support more than set here, individual units might support less - see PX4IO_P_CONFIG_CONTROL_COUNT */
|
#define PX4IO_PROTOCOL_MAX_CONTROL_COUNT 8 /**< The protocol does not support more than set here, individual units might support less - see PX4IO_P_CONFIG_CONTROL_COUNT */
|
||||||
|
|
||||||
/* static configuration page */
|
/* static configuration page */
|
||||||
#define PX4IO_PAGE_CONFIG 0
|
#define PX4IO_PAGE_CONFIG 0
|
||||||
#define PX4IO_P_CONFIG_PROTOCOL_VERSION 0 /* PX4IO_PROTOCOL_VERSION */
|
#define PX4IO_P_CONFIG_PROTOCOL_VERSION 0 /* PX4IO_PROTOCOL_VERSION */
|
||||||
#define PX4IO_P_CONFIG_HARDWARE_VERSION 1 /* magic numbers TBD */
|
#define PX4IO_P_CONFIG_HARDWARE_VERSION 1 /* magic numbers TBD */
|
||||||
#define PX4IO_P_CONFIG_BOOTLOADER_VERSION 2 /* get this how? */
|
#define PX4IO_P_CONFIG_BOOTLOADER_VERSION 2 /* get this how? */
|
||||||
#define PX4IO_P_CONFIG_MAX_TRANSFER 3 /* maximum I2C transfer size */
|
#define PX4IO_P_CONFIG_MAX_TRANSFER 3 /* maximum I2C transfer size */
|
||||||
#define PX4IO_P_CONFIG_CONTROL_COUNT 4 /* hardcoded max control count supported */
|
#define PX4IO_P_CONFIG_CONTROL_COUNT 4 /* hardcoded max control count supported */
|
||||||
#define PX4IO_P_CONFIG_ACTUATOR_COUNT 5 /* hardcoded max actuator output count */
|
#define PX4IO_P_CONFIG_ACTUATOR_COUNT 5 /* hardcoded max actuator output count */
|
||||||
#define PX4IO_P_CONFIG_RC_INPUT_COUNT 6 /* hardcoded max R/C input count supported */
|
#define PX4IO_P_CONFIG_RC_INPUT_COUNT 6 /* hardcoded max R/C input count supported */
|
||||||
#define PX4IO_P_CONFIG_ADC_INPUT_COUNT 7 /* hardcoded max ADC inputs */
|
#define PX4IO_P_CONFIG_ADC_INPUT_COUNT 7 /* hardcoded max ADC inputs */
|
||||||
#define PX4IO_P_CONFIG_RELAY_COUNT 8 /* hardcoded # of relay outputs */
|
#define PX4IO_P_CONFIG_RELAY_COUNT 8 /* hardcoded # of relay outputs */
|
||||||
|
#define PX4IO_MAX_TRANSFER_LEN 64
|
||||||
|
|
||||||
/* dynamic status page */
|
/* dynamic status page */
|
||||||
#define PX4IO_PAGE_STATUS 1
|
#define PX4IO_PAGE_STATUS 1
|
||||||
@@ -338,6 +339,10 @@ struct IOPacket {
|
|||||||
};
|
};
|
||||||
#pragma pack(pop)
|
#pragma pack(pop)
|
||||||
|
|
||||||
|
#if (PX4IO_MAX_TRANSFER_LEN > PKT_MAX_REGS * 2)
|
||||||
|
#error The max transfer length of the IO protocol must not be larger than the IO packet size
|
||||||
|
#endif
|
||||||
|
|
||||||
#define PKT_CODE_READ 0x00 /* FMU->IO read transaction */
|
#define PKT_CODE_READ 0x00 /* FMU->IO read transaction */
|
||||||
#define PKT_CODE_WRITE 0x40 /* FMU->IO write transaction */
|
#define PKT_CODE_WRITE 0x40 /* FMU->IO write transaction */
|
||||||
#define PKT_CODE_SUCCESS 0x00 /* IO->FMU success reply */
|
#define PKT_CODE_SUCCESS 0x00 /* IO->FMU success reply */
|
||||||
|
|||||||
@@ -57,7 +57,8 @@
|
|||||||
/*
|
/*
|
||||||
* Constants and limits.
|
* Constants and limits.
|
||||||
*/
|
*/
|
||||||
#define PX4IO_SERVO_COUNT 8
|
#define PX4IO_BL_VERSION 3
|
||||||
|
#define PX4IO_SERVO_COUNT 8
|
||||||
#define PX4IO_CONTROL_CHANNELS 8
|
#define PX4IO_CONTROL_CHANNELS 8
|
||||||
#define PX4IO_CONTROL_GROUPS 4
|
#define PX4IO_CONTROL_GROUPS 4
|
||||||
#define PX4IO_RC_INPUT_CHANNELS 18
|
#define PX4IO_RC_INPUT_CHANNELS 18
|
||||||
|
|||||||
@@ -69,8 +69,8 @@ static const uint16_t r_page_config[] = {
|
|||||||
#else
|
#else
|
||||||
[PX4IO_P_CONFIG_HARDWARE_VERSION] = 1,
|
[PX4IO_P_CONFIG_HARDWARE_VERSION] = 1,
|
||||||
#endif
|
#endif
|
||||||
[PX4IO_P_CONFIG_BOOTLOADER_VERSION] = 3, /* XXX hardcoded magic number */
|
[PX4IO_P_CONFIG_BOOTLOADER_VERSION] = PX4IO_BL_VERSION,
|
||||||
[PX4IO_P_CONFIG_MAX_TRANSFER] = 64, /* XXX hardcoded magic number */
|
[PX4IO_P_CONFIG_MAX_TRANSFER] = PX4IO_MAX_TRANSFER_LEN,
|
||||||
[PX4IO_P_CONFIG_CONTROL_COUNT] = PX4IO_CONTROL_CHANNELS,
|
[PX4IO_P_CONFIG_CONTROL_COUNT] = PX4IO_CONTROL_CHANNELS,
|
||||||
[PX4IO_P_CONFIG_ACTUATOR_COUNT] = PX4IO_SERVO_COUNT,
|
[PX4IO_P_CONFIG_ACTUATOR_COUNT] = PX4IO_SERVO_COUNT,
|
||||||
[PX4IO_P_CONFIG_RC_INPUT_COUNT] = PX4IO_RC_INPUT_CHANNELS,
|
[PX4IO_P_CONFIG_RC_INPUT_COUNT] = PX4IO_RC_INPUT_CHANNELS,
|
||||||
|
|||||||
Reference in New Issue
Block a user