LCOV - code coverage report
Current view: top level - AP_PiccoloCAN/piccolo_protocol - ServoDefines.c (source / functions) Hit Total Coverage
Test: lcov.info Lines: 0 144 0.0 %
Date: 2026-09-09 11:02:08 Functions: 0 12 0.0 %

          Line data    Source code
       1             : // ServoDefines.c was generated by ProtoGen version 3.2.a
       2             : 
       3             : /*
       4             :  * This file is free software: you can redistribute it and/or modify it
       5             :  * under the terms of the GNU General Public License as published by the
       6             :  * Free Software Foundation, either version 3 of the License, or
       7             :  * (at your option) any later version.
       8             :  *
       9             :  * This file is distributed in the hope that it will be useful, but
      10             :  * WITHOUT ANY WARRANTY; without even the implied warranty of
      11             :  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
      12             :  * See the GNU General Public License for more details.
      13             :  *
      14             :  * You should have received a copy of the GNU General Public License along
      15             :  * with this program.  If not, see <http://www.gnu.org/licenses/>.
      16             :  *
      17             :  * Author: Oliver Walters / Currawong Engineering Pty Ltd
      18             :  */
      19             : 
      20             : #include "ServoDefines.h"
      21             : #include "fielddecode.h"
      22             : #include "fieldencode.h"
      23             : #include "scaleddecode.h"
      24             : #include "scaledencode.h"
      25             : 
      26             : /*!
      27             :  * \brief Encode a Servo_StatusBits_t into a byte array
      28             :  *
      29             :  * Servo status bits
      30             :  * \param _pg_data points to the byte array to add encoded data to
      31             :  * \param _pg_bytecount points to the starting location in the byte array, and will be incremented by the number of encoded bytes.
      32             :  * \param _pg_user is the data to encode in the byte array
      33             :  */
      34           0 : void encodeServo_StatusBits_t(uint8_t* _pg_data, int* _pg_bytecount, const Servo_StatusBits_t* _pg_user)
      35             : {
      36           0 :     int _pg_byteindex = *_pg_bytecount;
      37             : 
      38             :     // Servo enabled status
      39           0 :     _pg_data[_pg_byteindex] = (uint8_t)_pg_user->enabled << 7;
      40             : 
      41             :     // Servo mode
      42           0 :     _pg_data[_pg_byteindex] |= (uint8_t)_pg_user->mode << 4;
      43             : 
      44             :     // Set if the servo has received a valid position command within the configured timeout period
      45           0 :     _pg_data[_pg_byteindex] |= (uint8_t)_pg_user->cmdReceived << 3;
      46             : 
      47             :     // Reserved for future use
      48           0 :     _pg_data[_pg_byteindex] |= (uint8_t)_pg_user->reservedA << 2;
      49             : 
      50             :     // Reserved for future use
      51           0 :     _pg_data[_pg_byteindex] |= (uint8_t)_pg_user->reservedB << 1;
      52             : 
      53             :     // Reserved for future use
      54           0 :     _pg_data[_pg_byteindex] |= (uint8_t)_pg_user->reservedC;
      55           0 :     _pg_byteindex += 1; // close bit field
      56             : 
      57           0 :     *_pg_bytecount = _pg_byteindex;
      58             : 
      59           0 : }// encodeServo_StatusBits_t
      60             : 
      61             : /*!
      62             :  * \brief Decode a Servo_StatusBits_t from a byte array
      63             :  *
      64             :  * Servo status bits
      65             :  * \param _pg_data points to the byte array to decoded data from
      66             :  * \param _pg_bytecount points to the starting location in the byte array, and will be incremented by the number of bytes decoded
      67             :  * \param _pg_user is the data to decode from the byte array
      68             :  * \return 1 if the data are decoded, else 0.
      69             :  */
      70           0 : int decodeServo_StatusBits_t(const uint8_t* _pg_data, int* _pg_bytecount, Servo_StatusBits_t* _pg_user)
      71             : {
      72           0 :     int _pg_byteindex = *_pg_bytecount;
      73             : 
      74             :     // Servo enabled status
      75           0 :     _pg_user->enabled = (_pg_data[_pg_byteindex] >> 7);
      76             : 
      77             :     // Servo mode
      78           0 :     _pg_user->mode = (ServoModes)((_pg_data[_pg_byteindex] >> 4) & 0x7);
      79             : 
      80             :     // Set if the servo has received a valid position command within the configured timeout period
      81           0 :     _pg_user->cmdReceived = ((_pg_data[_pg_byteindex] >> 3) & 0x1);
      82             : 
      83             :     // Reserved for future use
      84           0 :     _pg_user->reservedA = ((_pg_data[_pg_byteindex] >> 2) & 0x1);
      85             : 
      86             :     // Reserved for future use
      87           0 :     _pg_user->reservedB = ((_pg_data[_pg_byteindex] >> 1) & 0x1);
      88             : 
      89             :     // Reserved for future use
      90           0 :     _pg_user->reservedC = ((_pg_data[_pg_byteindex]) & 0x1);
      91           0 :     _pg_byteindex += 1; // close bit field
      92             : 
      93           0 :     *_pg_bytecount = _pg_byteindex;
      94             : 
      95           0 :     return 1;
      96             : 
      97             : }// decodeServo_StatusBits_t
      98             : 
      99             : /*!
     100             :  * \brief Encode a Servo_WarningBits_t into a byte array
     101             :  *
     102             :  * Servo warning bits
     103             :  * \param _pg_data points to the byte array to add encoded data to
     104             :  * \param _pg_bytecount points to the starting location in the byte array, and will be incremented by the number of encoded bytes.
     105             :  * \param _pg_user is the data to encode in the byte array
     106             :  */
     107           0 : void encodeServo_WarningBits_t(uint8_t* _pg_data, int* _pg_bytecount, const Servo_WarningBits_t* _pg_user)
     108             : {
     109           0 :     int _pg_byteindex = *_pg_bytecount;
     110             : 
     111             :     // Servo current exceeds warning threshold
     112           0 :     _pg_data[_pg_byteindex] = (uint8_t)_pg_user->overCurrent << 7;
     113             : 
     114             :     // Servo temperature exceeds warning threshold
     115           0 :     _pg_data[_pg_byteindex] |= (uint8_t)_pg_user->overTemperature << 6;
     116             : 
     117             :     // Servo accelerometer reading exceeds warning threshold
     118           0 :     _pg_data[_pg_byteindex] |= (uint8_t)_pg_user->overAcceleration << 5;
     119             : 
     120             :     // Most recent servo position command was outside valid range
     121           0 :     _pg_data[_pg_byteindex] |= (uint8_t)_pg_user->invalidInput << 4;
     122             : 
     123             :     // Servo position is outside calibrated range
     124           0 :     _pg_data[_pg_byteindex] |= (uint8_t)_pg_user->position << 3;
     125             : 
     126             :     // Servo potentiometer is not correctly calibrated
     127           0 :     _pg_data[_pg_byteindex] |= (uint8_t)_pg_user->potCalibration << 2;
     128             : 
     129             :     // Servo voltage is below operational threshold
     130           0 :     _pg_data[_pg_byteindex] |= (uint8_t)_pg_user->underVoltage << 1;
     131             : 
     132             :     // Servo voltage is above operational threshold
     133           0 :     _pg_data[_pg_byteindex] |= (uint8_t)_pg_user->overVoltage;
     134             : 
     135             :     // Reserved for future use
     136             :     // Range of reservedB is 0 to 255.
     137           0 :     _pg_data[_pg_byteindex + 1] = (uint8_t)_pg_user->reservedB;
     138           0 :     _pg_byteindex += 2; // close bit field
     139             : 
     140           0 :     *_pg_bytecount = _pg_byteindex;
     141             : 
     142           0 : }// encodeServo_WarningBits_t
     143             : 
     144             : /*!
     145             :  * \brief Decode a Servo_WarningBits_t from a byte array
     146             :  *
     147             :  * Servo warning bits
     148             :  * \param _pg_data points to the byte array to decoded data from
     149             :  * \param _pg_bytecount points to the starting location in the byte array, and will be incremented by the number of bytes decoded
     150             :  * \param _pg_user is the data to decode from the byte array
     151             :  * \return 1 if the data are decoded, else 0.
     152             :  */
     153           0 : int decodeServo_WarningBits_t(const uint8_t* _pg_data, int* _pg_bytecount, Servo_WarningBits_t* _pg_user)
     154             : {
     155           0 :     int _pg_byteindex = *_pg_bytecount;
     156             : 
     157             :     // Servo current exceeds warning threshold
     158           0 :     _pg_user->overCurrent = (_pg_data[_pg_byteindex] >> 7);
     159             : 
     160             :     // Servo temperature exceeds warning threshold
     161           0 :     _pg_user->overTemperature = ((_pg_data[_pg_byteindex] >> 6) & 0x1);
     162             : 
     163             :     // Servo accelerometer reading exceeds warning threshold
     164           0 :     _pg_user->overAcceleration = ((_pg_data[_pg_byteindex] >> 5) & 0x1);
     165             : 
     166             :     // Most recent servo position command was outside valid range
     167           0 :     _pg_user->invalidInput = ((_pg_data[_pg_byteindex] >> 4) & 0x1);
     168             : 
     169             :     // Servo position is outside calibrated range
     170           0 :     _pg_user->position = ((_pg_data[_pg_byteindex] >> 3) & 0x1);
     171             : 
     172             :     // Servo potentiometer is not correctly calibrated
     173           0 :     _pg_user->potCalibration = ((_pg_data[_pg_byteindex] >> 2) & 0x1);
     174             : 
     175             :     // Servo voltage is below operational threshold
     176           0 :     _pg_user->underVoltage = ((_pg_data[_pg_byteindex] >> 1) & 0x1);
     177             : 
     178             :     // Servo voltage is above operational threshold
     179           0 :     _pg_user->overVoltage = ((_pg_data[_pg_byteindex]) & 0x1);
     180             : 
     181             :     // Reserved for future use
     182             :     // Range of reservedB is 0 to 255.
     183           0 :     _pg_user->reservedB = _pg_data[_pg_byteindex + 1];
     184           0 :     _pg_byteindex += 2; // close bit field
     185             : 
     186           0 :     *_pg_bytecount = _pg_byteindex;
     187             : 
     188           0 :     return 1;
     189             : 
     190             : }// decodeServo_WarningBits_t
     191             : 
     192             : /*!
     193             :  * \brief Encode a Servo_ErrorBits_t into a byte array
     194             :  *
     195             :  * Servo error bits
     196             :  * \param _pg_data points to the byte array to add encoded data to
     197             :  * \param _pg_bytecount points to the starting location in the byte array, and will be incremented by the number of encoded bytes.
     198             :  * \param _pg_user is the data to encode in the byte array
     199             :  */
     200           0 : void encodeServo_ErrorBits_t(uint8_t* _pg_data, int* _pg_bytecount, const Servo_ErrorBits_t* _pg_user)
     201             : {
     202           0 :     int _pg_byteindex = *_pg_bytecount;
     203             : 
     204             :     // Servo position is outside measurement range
     205           0 :     _pg_data[_pg_byteindex] = (uint8_t)_pg_user->position << 7;
     206             : 
     207             :     // Error reading servo position
     208           0 :     _pg_data[_pg_byteindex] |= (uint8_t)_pg_user->potError << 6;
     209             : 
     210             :     // Error reading servo accelerometer data
     211           0 :     _pg_data[_pg_byteindex] |= (uint8_t)_pg_user->accError << 5;
     212             : 
     213             :     // Servo input/output map is not correctly calibrated
     214           0 :     _pg_data[_pg_byteindex] |= (uint8_t)_pg_user->mapCalibration << 4;
     215             : 
     216             :     // Error reading servo settings from memory
     217           0 :     _pg_data[_pg_byteindex] |= (uint8_t)_pg_user->settingsError << 3;
     218             : 
     219             :     // Error reading servo health tracking information from memory
     220           0 :     _pg_data[_pg_byteindex] |= (uint8_t)_pg_user->healthError << 2;
     221             : 
     222             :     // Servo position cannot match commanded position
     223           0 :     _pg_data[_pg_byteindex] |= (uint8_t)_pg_user->tracking << 1;
     224             : 
     225             :     // Reserved for future use
     226           0 :     _pg_data[_pg_byteindex] |= (uint8_t)_pg_user->reservedB;
     227           0 :     _pg_byteindex += 1; // close bit field
     228             : 
     229           0 :     *_pg_bytecount = _pg_byteindex;
     230             : 
     231           0 : }// encodeServo_ErrorBits_t
     232             : 
     233             : /*!
     234             :  * \brief Decode a Servo_ErrorBits_t from a byte array
     235             :  *
     236             :  * Servo error bits
     237             :  * \param _pg_data points to the byte array to decoded data from
     238             :  * \param _pg_bytecount points to the starting location in the byte array, and will be incremented by the number of bytes decoded
     239             :  * \param _pg_user is the data to decode from the byte array
     240             :  * \return 1 if the data are decoded, else 0.
     241             :  */
     242           0 : int decodeServo_ErrorBits_t(const uint8_t* _pg_data, int* _pg_bytecount, Servo_ErrorBits_t* _pg_user)
     243             : {
     244           0 :     int _pg_byteindex = *_pg_bytecount;
     245             : 
     246             :     // Servo position is outside measurement range
     247           0 :     _pg_user->position = (_pg_data[_pg_byteindex] >> 7);
     248             : 
     249             :     // Error reading servo position
     250           0 :     _pg_user->potError = ((_pg_data[_pg_byteindex] >> 6) & 0x1);
     251             : 
     252             :     // Error reading servo accelerometer data
     253           0 :     _pg_user->accError = ((_pg_data[_pg_byteindex] >> 5) & 0x1);
     254             : 
     255             :     // Servo input/output map is not correctly calibrated
     256           0 :     _pg_user->mapCalibration = ((_pg_data[_pg_byteindex] >> 4) & 0x1);
     257             : 
     258             :     // Error reading servo settings from memory
     259           0 :     _pg_user->settingsError = ((_pg_data[_pg_byteindex] >> 3) & 0x1);
     260             : 
     261             :     // Error reading servo health tracking information from memory
     262           0 :     _pg_user->healthError = ((_pg_data[_pg_byteindex] >> 2) & 0x1);
     263             : 
     264             :     // Servo position cannot match commanded position
     265           0 :     _pg_user->tracking = ((_pg_data[_pg_byteindex] >> 1) & 0x1);
     266             : 
     267             :     // Reserved for future use
     268           0 :     _pg_user->reservedB = ((_pg_data[_pg_byteindex]) & 0x1);
     269           0 :     _pg_byteindex += 1; // close bit field
     270             : 
     271           0 :     *_pg_bytecount = _pg_byteindex;
     272             : 
     273           0 :     return 1;
     274             : 
     275             : }// decodeServo_ErrorBits_t
     276             : 
     277             : /*!
     278             :  * \brief Encode a Servo_TelemetryPackets_t into a byte array
     279             :  *
     280             :  * Servo packet selection
     281             :  * \param _pg_data points to the byte array to add encoded data to
     282             :  * \param _pg_bytecount points to the starting location in the byte array, and will be incremented by the number of encoded bytes.
     283             :  * \param _pg_user is the data to encode in the byte array
     284             :  */
     285           0 : void encodeServo_TelemetryPackets_t(uint8_t* _pg_data, int* _pg_bytecount, const Servo_TelemetryPackets_t* _pg_user)
     286             : {
     287           0 :     int _pg_byteindex = *_pg_bytecount;
     288             : 
     289             :     // Select the *STATUS_A* packet
     290           0 :     _pg_data[_pg_byteindex] = (uint8_t)_pg_user->statusA << 7;
     291             : 
     292             :     // Select the *STATUS_B* packet
     293           0 :     _pg_data[_pg_byteindex] |= (uint8_t)_pg_user->statusB << 6;
     294             : 
     295             :     // Select the *STATUS_C* packet
     296           0 :     _pg_data[_pg_byteindex] |= (uint8_t)_pg_user->statusC << 5;
     297             : 
     298             :     // Select the *STATUS_D* packet
     299           0 :     _pg_data[_pg_byteindex] |= (uint8_t)_pg_user->statusD << 4;
     300             : 
     301             :     // Select the *ACCELEROMETER* packet
     302           0 :     _pg_data[_pg_byteindex] |= (uint8_t)_pg_user->accelerometer << 3;
     303             : 
     304             :     // Reserved field (set to zero)
     305           0 :     _pg_data[_pg_byteindex] |= (uint8_t)_pg_user->dbgA << 2;
     306             : 
     307             :     // Reserved field (set to zero)
     308           0 :     _pg_data[_pg_byteindex] |= (uint8_t)_pg_user->dbgB << 1;
     309             : 
     310             :     // Reserved field (set to zero)
     311           0 :     _pg_data[_pg_byteindex] |= (uint8_t)_pg_user->dbgC;
     312           0 :     _pg_byteindex += 1; // close bit field
     313             : 
     314           0 :     *_pg_bytecount = _pg_byteindex;
     315             : 
     316           0 : }// encodeServo_TelemetryPackets_t
     317             : 
     318             : /*!
     319             :  * \brief Decode a Servo_TelemetryPackets_t from a byte array
     320             :  *
     321             :  * Servo packet selection
     322             :  * \param _pg_data points to the byte array to decoded data from
     323             :  * \param _pg_bytecount points to the starting location in the byte array, and will be incremented by the number of bytes decoded
     324             :  * \param _pg_user is the data to decode from the byte array
     325             :  * \return 1 if the data are decoded, else 0.
     326             :  */
     327           0 : int decodeServo_TelemetryPackets_t(const uint8_t* _pg_data, int* _pg_bytecount, Servo_TelemetryPackets_t* _pg_user)
     328             : {
     329           0 :     int _pg_byteindex = *_pg_bytecount;
     330             : 
     331             :     // Select the *STATUS_A* packet
     332           0 :     _pg_user->statusA = (_pg_data[_pg_byteindex] >> 7);
     333             : 
     334             :     // Select the *STATUS_B* packet
     335           0 :     _pg_user->statusB = ((_pg_data[_pg_byteindex] >> 6) & 0x1);
     336             : 
     337             :     // Select the *STATUS_C* packet
     338           0 :     _pg_user->statusC = ((_pg_data[_pg_byteindex] >> 5) & 0x1);
     339             : 
     340             :     // Select the *STATUS_D* packet
     341           0 :     _pg_user->statusD = ((_pg_data[_pg_byteindex] >> 4) & 0x1);
     342             : 
     343             :     // Select the *ACCELEROMETER* packet
     344           0 :     _pg_user->accelerometer = ((_pg_data[_pg_byteindex] >> 3) & 0x1);
     345             : 
     346             :     // Reserved field (set to zero)
     347           0 :     _pg_user->dbgA = ((_pg_data[_pg_byteindex] >> 2) & 0x1);
     348             : 
     349             :     // Reserved field (set to zero)
     350           0 :     _pg_user->dbgB = ((_pg_data[_pg_byteindex] >> 1) & 0x1);
     351             : 
     352             :     // Reserved field (set to zero)
     353           0 :     _pg_user->dbgC = ((_pg_data[_pg_byteindex]) & 0x1);
     354           0 :     _pg_byteindex += 1; // close bit field
     355             : 
     356           0 :     *_pg_bytecount = _pg_byteindex;
     357             : 
     358           0 :     return 1;
     359             : 
     360             : }// decodeServo_TelemetryPackets_t
     361             : 
     362             : /*!
     363             :  * \brief Encode a Servo_TelemetrySettings_t into a byte array
     364             :  *
     365             :  * Servo telemetry configuration
     366             :  * \param _pg_data points to the byte array to add encoded data to
     367             :  * \param _pg_bytecount points to the starting location in the byte array, and will be incremented by the number of encoded bytes.
     368             :  * \param _pg_user is the data to encode in the byte array
     369             :  */
     370           0 : void encodeServo_TelemetrySettings_t(uint8_t* _pg_data, int* _pg_bytecount, const Servo_TelemetrySettings_t* _pg_user)
     371             : {
     372           0 :     int _pg_byteindex = *_pg_bytecount;
     373             : 
     374             :     // Servo telemetry period
     375             :     // Range of period is 0 to 255.
     376           0 :     uint8ToBytes(_pg_user->period, _pg_data, &_pg_byteindex);
     377             : 
     378             :     // Servo silence period (after boot)
     379             :     // Range of silence is 0 to 255.
     380           0 :     uint8ToBytes(_pg_user->silence, _pg_data, &_pg_byteindex);
     381             : 
     382             :     // Telemetry packet selection
     383           0 :     encodeServo_TelemetryPackets_t(_pg_data, &_pg_byteindex, &_pg_user->packets);
     384             : 
     385             :     // Command response packet selection
     386           0 :     encodeServo_TelemetryPackets_t(_pg_data, &_pg_byteindex, &_pg_user->responsePackets);
     387             : 
     388           0 :     *_pg_bytecount = _pg_byteindex;
     389             : 
     390           0 : }// encodeServo_TelemetrySettings_t
     391             : 
     392             : /*!
     393             :  * \brief Decode a Servo_TelemetrySettings_t from a byte array
     394             :  *
     395             :  * Servo telemetry configuration
     396             :  * \param _pg_data points to the byte array to decoded data from
     397             :  * \param _pg_bytecount points to the starting location in the byte array, and will be incremented by the number of bytes decoded
     398             :  * \param _pg_user is the data to decode from the byte array
     399             :  * \return 1 if the data are decoded, else 0.
     400             :  */
     401           0 : int decodeServo_TelemetrySettings_t(const uint8_t* _pg_data, int* _pg_bytecount, Servo_TelemetrySettings_t* _pg_user)
     402             : {
     403           0 :     int _pg_byteindex = *_pg_bytecount;
     404             : 
     405             :     // Servo telemetry period
     406             :     // Range of period is 0 to 255.
     407           0 :     _pg_user->period = uint8FromBytes(_pg_data, &_pg_byteindex);
     408             : 
     409             :     // Servo silence period (after boot)
     410             :     // Range of silence is 0 to 255.
     411           0 :     _pg_user->silence = uint8FromBytes(_pg_data, &_pg_byteindex);
     412             : 
     413             :     // Telemetry packet selection
     414           0 :     if(decodeServo_TelemetryPackets_t(_pg_data, &_pg_byteindex, &_pg_user->packets) == 0)
     415           0 :         return 0;
     416             : 
     417             :     // Command response packet selection
     418           0 :     if(decodeServo_TelemetryPackets_t(_pg_data, &_pg_byteindex, &_pg_user->responsePackets) == 0)
     419           0 :         return 0;
     420             : 
     421           0 :     *_pg_bytecount = _pg_byteindex;
     422             : 
     423           0 :     return 1;
     424             : 
     425             : }// decodeServo_TelemetrySettings_t
     426             : 
     427             : /*!
     428             :  * \brief Encode a Servo_ConfigBits_t into a byte array
     429             :  *
     430             : 
     431             :  * \param _pg_data points to the byte array to add encoded data to
     432             :  * \param _pg_bytecount points to the starting location in the byte array, and will be incremented by the number of encoded bytes.
     433             :  * \param _pg_user is the data to encode in the byte array
     434             :  */
     435           0 : void encodeServo_ConfigBits_t(uint8_t* _pg_data, int* _pg_bytecount, const Servo_ConfigBits_t* _pg_user)
     436             : {
     437           0 :     int _pg_byteindex = *_pg_bytecount;
     438             : 
     439             :     // 1 = I/O map is enabled
     440           0 :     _pg_data[_pg_byteindex] = (uint8_t)_pg_user->mapEnabled << 7;
     441             : 
     442             :     // 1 = The servo will listen for Piccolo autopilot CAN messages
     443           0 :     _pg_data[_pg_byteindex] |= (uint8_t)_pg_user->piccoloCmd << 6;
     444             : 
     445             :     // 1 = Servo neutral position is enabled, 0 = Neutral position disabled
     446           0 :     _pg_data[_pg_byteindex] |= (uint8_t)_pg_user->neutralPositionEnabled << 5;
     447             : 
     448             :     // Channel the servo will use to listen for Piccolo messages.
     449             :     // Range of piccoloChannel is 0 to 31.
     450           0 :     _pg_data[_pg_byteindex] |= (uint8_t)_pg_user->piccoloChannel;
     451             : 
     452             :     // Servo action at powerup
     453             :     // Range of timeoutAction is 0 to 3.
     454           0 :     _pg_data[_pg_byteindex + 1] = (uint8_t)_pg_user->timeoutAction << 6;
     455             : 
     456             :     // reserved for future use
     457             :     // Range of reservedB is 0 to 3.
     458           0 :     _pg_data[_pg_byteindex + 1] |= (uint8_t)_pg_user->reservedB << 4;
     459             : 
     460             :     // reserved for future use
     461             :     // Range of reservedC is 0 to 15.
     462           0 :     _pg_data[_pg_byteindex + 1] |= (uint8_t)_pg_user->reservedC;
     463           0 :     _pg_byteindex += 2; // close bit field
     464             : 
     465           0 :     *_pg_bytecount = _pg_byteindex;
     466             : 
     467           0 : }// encodeServo_ConfigBits_t
     468             : 
     469             : /*!
     470             :  * \brief Decode a Servo_ConfigBits_t from a byte array
     471             :  *
     472             : 
     473             :  * \param _pg_data points to the byte array to decoded data from
     474             :  * \param _pg_bytecount points to the starting location in the byte array, and will be incremented by the number of bytes decoded
     475             :  * \param _pg_user is the data to decode from the byte array
     476             :  * \return 1 if the data are decoded, else 0.
     477             :  */
     478           0 : int decodeServo_ConfigBits_t(const uint8_t* _pg_data, int* _pg_bytecount, Servo_ConfigBits_t* _pg_user)
     479             : {
     480           0 :     int _pg_byteindex = *_pg_bytecount;
     481             : 
     482             :     // 1 = I/O map is enabled
     483           0 :     _pg_user->mapEnabled = (_pg_data[_pg_byteindex] >> 7);
     484             : 
     485             :     // 1 = The servo will listen for Piccolo autopilot CAN messages
     486           0 :     _pg_user->piccoloCmd = ((_pg_data[_pg_byteindex] >> 6) & 0x1);
     487             : 
     488             :     // 1 = Servo neutral position is enabled, 0 = Neutral position disabled
     489           0 :     _pg_user->neutralPositionEnabled = ((_pg_data[_pg_byteindex] >> 5) & 0x1);
     490             : 
     491             :     // Channel the servo will use to listen for Piccolo messages.
     492             :     // Range of piccoloChannel is 0 to 31.
     493           0 :     _pg_user->piccoloChannel = ((_pg_data[_pg_byteindex]) & 0x1F);
     494             : 
     495             :     // Servo action at powerup
     496             :     // Range of timeoutAction is 0 to 3.
     497           0 :     _pg_user->timeoutAction = (_pg_data[_pg_byteindex + 1] >> 6);
     498             : 
     499             :     // reserved for future use
     500             :     // Range of reservedB is 0 to 3.
     501           0 :     _pg_user->reservedB = ((_pg_data[_pg_byteindex + 1] >> 4) & 0x3);
     502             : 
     503             :     // reserved for future use
     504             :     // Range of reservedC is 0 to 15.
     505           0 :     _pg_user->reservedC = ((_pg_data[_pg_byteindex + 1]) & 0xF);
     506           0 :     _pg_byteindex += 2; // close bit field
     507             : 
     508           0 :     *_pg_bytecount = _pg_byteindex;
     509             : 
     510           0 :     return 1;
     511             : 
     512             : }// decodeServo_ConfigBits_t
     513             : 
     514             : // end of ServoDefines.c

Generated by: LCOV version 1.14