2 ******************************************************************************
3 * @addtogroup UAVObjects OpenPilot UAVObjects
5 * @addtogroup $(NAME) $(NAME)
6 * @brief $(DESCRIPTION)
8 * Autogenerated files and functions for $(NAME) Object
12 * @author The OpenPilot Team, http://www.openpilot.org Copyright (C) 2010-2013.
13 * @brief Implementation of the $(NAME) object. This file has been
14 * automatically generated by the UAVObjectGenerator.
16 * @note Object definition file: $(XMLFILE).
17 * This is an automatically generated file.
18 * DO NOT modify manually.
20 * @see The GNU Public License (GPL) Version 3
22 *****************************************************************************/
24 * This program is free software; you can redistribute it and/or modify
25 * it under the terms of the GNU General Public License as published by
26 * the Free Software Foundation; either version 3 of the License, or
27 * (at your option) any later version.
29 * This program is distributed in the hope that it will be useful, but
30 * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
31 * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
34 * You should have received a copy of the GNU General Public License along
35 * with this program; if not, write to the Free Software Foundation, Inc.,
36 * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
39 #include <openpilot.h>
40 #include "$(NAMELC).h"
43 #if (defined(__MACH__) && defined(__APPLE__))
44 static UAVObjHandle handle __attribute__((section("__DATA,_uavo_handles")));
46 static UAVObjHandle handle __attribute__((section("_uavo_handles")));
52 * \return -1 Failure to initialize or -2 for already initialized
54 int32_t $(NAME)Initialize(void)
56 // Compile time assertion that the $(NAME)DataPacked and $(NAME)Data structs
57 // have the same size (though instances of $(NAME)Data
58 // should be placed in memory by the linker/compiler on a 4 byte alignment).
59 PIOS_STATIC_ASSERT(sizeof($(NAME)DataPacked) == sizeof($(NAME)Data));
61 // Don't set the handle to null if already registered
62 if (UAVObjGetByID($(NAMEUC)_OBJID)) {
66 // Register object with the object manager
67 handle = UAVObjRegister($(NAMEUC)_OBJID,
68 $(NAMEUC)_ISSINGLEINST, $(NAMEUC)_ISSETTINGS, $(NAMEUC)_ISPRIORITY, $(NAMEUC)_NUMBYTES, &$(NAME)SetDefaults);
71 return handle ? 0 : -1;
75 * Initialize object fields and metadata with the default values.
76 * If a default value is not specified the object fields
77 * will be initialized to zero.
79 void $(NAME)SetDefaults(UAVObjHandle obj, uint16_t instId)
83 // Initialize object fields to their default values
84 UAVObjGetInstanceData(obj, instId, &data);
85 memset(&data, 0, sizeof($(NAME)Data));
87 UAVObjSetInstanceData(obj, instId, &data);
89 // Initialize object metadata to their default values
91 UAVObjMetadata metadata;
93 $(FLIGHTACCESS) << UAVOBJ_ACCESS_SHIFT |
94 $(GCSACCESS) << UAVOBJ_GCS_ACCESS_SHIFT |
95 $(FLIGHTTELEM_ACKED) << UAVOBJ_TELEMETRY_ACKED_SHIFT |
96 $(GCSTELEM_ACKED) << UAVOBJ_GCS_TELEMETRY_ACKED_SHIFT |
97 $(FLIGHTTELEM_UPDATEMODE) << UAVOBJ_TELEMETRY_UPDATE_MODE_SHIFT |
98 $(GCSTELEM_UPDATEMODE) << UAVOBJ_GCS_TELEMETRY_UPDATE_MODE_SHIFT |
99 $(LOGGING_UPDATEMODE) << UAVOBJ_LOGGING_UPDATE_MODE_SHIFT;
100 metadata.telemetryUpdatePeriod = $(FLIGHTTELEM_UPDATEPERIOD);
101 metadata.gcsTelemetryUpdatePeriod = $(GCSTELEM_UPDATEPERIOD);
102 metadata.loggingUpdatePeriod = $(LOGGING_UPDATEPERIOD);
103 UAVObjSetMetadata(obj, &metadata);
110 UAVObjHandle $(NAME)Handle()
116 * Get/Set object Functions