Mouse code for the MacroRat

Dependencies:   ITG3200 QEI

Committer:
sahilmgandhi
Date:
Sun May 14 23:18:57 2017 +0000
Revision:
18:6a4db94011d3
Publishing again

Who changed what in which revision?

UserRevisionLine numberNew contents of line
sahilmgandhi 18:6a4db94011d3 1 /**
sahilmgandhi 18:6a4db94011d3 2 ******************************************************************************
sahilmgandhi 18:6a4db94011d3 3 * @file mib.h
sahilmgandhi 18:6a4db94011d3 4 * @brief Defines the structure of a Management Information Base (MIB)
sahilmgandhi 18:6a4db94011d3 5 * @internal
sahilmgandhi 18:6a4db94011d3 6 * @author ON Semiconductor
sahilmgandhi 18:6a4db94011d3 7 * $Rev: 2284 $
sahilmgandhi 18:6a4db94011d3 8 * $Date: 2013-09-12 15:08:22 +0530 (Thu, 12 Sep 2013) $
sahilmgandhi 18:6a4db94011d3 9 ******************************************************************************
sahilmgandhi 18:6a4db94011d3 10 * Copyright 2016 Semiconductor Components Industries LLC (d/b/a “ON Semiconductor”).
sahilmgandhi 18:6a4db94011d3 11 * All rights reserved. This software and/or documentation is licensed by ON Semiconductor
sahilmgandhi 18:6a4db94011d3 12 * under limited terms and conditions. The terms and conditions pertaining to the software
sahilmgandhi 18:6a4db94011d3 13 * and/or documentation are available at http://www.onsemi.com/site/pdf/ONSEMI_T&C.pdf
sahilmgandhi 18:6a4db94011d3 14 * (“ON Semiconductor Standard Terms and Conditions of Sale, Section 8 Software”) and
sahilmgandhi 18:6a4db94011d3 15 * if applicable the software license agreement. Do not use this software and/or
sahilmgandhi 18:6a4db94011d3 16 * documentation unless you have carefully read and you agree to the limited terms and
sahilmgandhi 18:6a4db94011d3 17 * conditions. By using this software and/or documentation, you agree to the limited
sahilmgandhi 18:6a4db94011d3 18 * terms and conditions.
sahilmgandhi 18:6a4db94011d3 19 *
sahilmgandhi 18:6a4db94011d3 20 * THIS SOFTWARE IS PROVIDED "AS IS". NO WARRANTIES, WHETHER EXPRESS, IMPLIED
sahilmgandhi 18:6a4db94011d3 21 * OR STATUTORY, INCLUDING, BUT NOT LIMITED TO, IMPLIED WARRANTIES OF
sahilmgandhi 18:6a4db94011d3 22 * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE APPLY TO THIS SOFTWARE.
sahilmgandhi 18:6a4db94011d3 23 * ON SEMICONDUCTOR SHALL NOT, IN ANY CIRCUMSTANCES, BE LIABLE FOR SPECIAL,
sahilmgandhi 18:6a4db94011d3 24 * INCIDENTAL, OR CONSEQUENTIAL DAMAGES, FOR ANY REASON WHATSOEVER.
sahilmgandhi 18:6a4db94011d3 25 * @endinternal
sahilmgandhi 18:6a4db94011d3 26 *
sahilmgandhi 18:6a4db94011d3 27 * @details
sahilmgandhi 18:6a4db94011d3 28 * This file defines the structure, as seen from the outside, of any Management
sahilmgandhi 18:6a4db94011d3 29 * Information Base (MIB) implementation. It does not define the contents of the
sahilmgandhi 18:6a4db94011d3 30 * MIB.
sahilmgandhi 18:6a4db94011d3 31 *
sahilmgandhi 18:6a4db94011d3 32 * A MIB is implemented as a map of parameters, each identified by a unique Object ID.
sahilmgandhi 18:6a4db94011d3 33 * The contents of the map have to be filled in by the actual MIB implementation, by
sahilmgandhi 18:6a4db94011d3 34 * assigning to the GlobMibMap variable. The mib_param_t data type defines the format
sahilmgandhi 18:6a4db94011d3 35 * of each parameter in the map. *NOTE:* The length of the last entry in the map must
sahilmgandhi 18:6a4db94011d3 36 * be 0.
sahilmgandhi 18:6a4db94011d3 37 *
sahilmgandhi 18:6a4db94011d3 38 * One parameter must always be present in the MIB map: the system revision. It has
sahilmgandhi 18:6a4db94011d3 39 * to be set by assigning a value to the systemRevision variable.
sahilmgandhi 18:6a4db94011d3 40 *
sahilmgandhi 18:6a4db94011d3 41 * Parameters can be of any data type, and read / write or read only. To resemble
sahilmgandhi 18:6a4db94011d3 42 * the hierarchical structure of an SNMP MIB, each Object ID consists of four nibbles
sahilmgandhi 18:6a4db94011d3 43 * (uint16_t) where the more significant nibbles correspond to a higher level in the
sahilmgandhi 18:6a4db94011d3 44 * hierarchy.
sahilmgandhi 18:6a4db94011d3 45 *
sahilmgandhi 18:6a4db94011d3 46 * The contents of the map can be accessed with the fMibSetBytes() and fMibGetBytes()
sahilmgandhi 18:6a4db94011d3 47 * functions. The implementation of the MIB may also make its parameters accessible
sahilmgandhi 18:6a4db94011d3 48 * in a more "direct" way; that is left to the implementation. The fMibSetBytes() and
sahilmgandhi 18:6a4db94011d3 49 * fMibGetBytes() functions are made available to the user interface (see ui.h). In
sahilmgandhi 18:6a4db94011d3 50 * order to do so, fMibUiInit() must be called during device initialization.
sahilmgandhi 18:6a4db94011d3 51 *
sahilmgandhi 18:6a4db94011d3 52 * Additionally, for parameters that have an array as their value, the individual
sahilmgandhi 18:6a4db94011d3 53 * elements of the array can be accessed using the fMibIndexedSetBytes() and
sahilmgandhi 18:6a4db94011d3 54 * fMibIndexedGetBytes() functions. The functions are similar to their non-indexed
sahilmgandhi 18:6a4db94011d3 55 * variants (fMibSetBytes() and fMibGetBytes()), except that they expect the index of
sahilmgandhi 18:6a4db94011d3 56 * the element as an argument.
sahilmgandhi 18:6a4db94011d3 57 *
sahilmgandhi 18:6a4db94011d3 58 * fMibGetBytes() and fMibSetBytes() will normally copy bytes from the MIB parameter
sahilmgandhi 18:6a4db94011d3 59 * into a given place in memory, or from memory to the MIB parameter. This behaviour
sahilmgandhi 18:6a4db94011d3 60 * can be overruled by assigning a function to the setAction and / or getAction
sahilmgandhi 18:6a4db94011d3 61 * fields of the MIB parameter.
sahilmgandhi 18:6a4db94011d3 62 *
sahilmgandhi 18:6a4db94011d3 63 * For parameters that have an array as their value, the length field has a slightly
sahilmgandhi 18:6a4db94011d3 64 * different meaning: the most significant 16 bits contain the length of the array;
sahilmgandhi 18:6a4db94011d3 65 * the least significant 16 bits contain the width of the array (i.e. the size in
sahilmgandhi 18:6a4db94011d3 66 * bytes of the array's elements). This implies that the normal fMibGetBytes() and
sahilmgandhi 18:6a4db94011d3 67 * fMibSetBytes() cannot be used on these parameters; instead, a get and set action
sahilmgandhi 18:6a4db94011d3 68 * needs to be provided to interpret the length field in case of a non-indexed get
sahilmgandhi 18:6a4db94011d3 69 * or set.
sahilmgandhi 18:6a4db94011d3 70 *
sahilmgandhi 18:6a4db94011d3 71 * To access the MIB fields over the user interface, the module ID must be equal to
sahilmgandhi 18:6a4db94011d3 72 * MIB_MODULE_ID or 0x01. The data in the packet must have the following structure:
sahilmgandhi 18:6a4db94011d3 73 * <table>
sahilmgandhi 18:6a4db94011d3 74 * <tr>
sahilmgandhi 18:6a4db94011d3 75 * <th>Get (0x00) / Set (0x01) code</th>
sahilmgandhi 18:6a4db94011d3 76 * <th>Object ID</th>
sahilmgandhi 18:6a4db94011d3 77 * <th>Value (only for set)</th>
sahilmgandhi 18:6a4db94011d3 78 * </tr>
sahilmgandhi 18:6a4db94011d3 79 * <tr>
sahilmgandhi 18:6a4db94011d3 80 * <td>1 Byte</td>
sahilmgandhi 18:6a4db94011d3 81 * <td>2 Bytes</td>
sahilmgandhi 18:6a4db94011d3 82 * <td>X bytes</td>
sahilmgandhi 18:6a4db94011d3 83 * </tr>
sahilmgandhi 18:6a4db94011d3 84 * </table>
sahilmgandhi 18:6a4db94011d3 85 *
sahilmgandhi 18:6a4db94011d3 86 * <table>
sahilmgandhi 18:6a4db94011d3 87 * <tr>
sahilmgandhi 18:6a4db94011d3 88 * <th>Indexed Get (0x02) / Set (0x03) code</th>
sahilmgandhi 18:6a4db94011d3 89 * <th>Object ID</th>
sahilmgandhi 18:6a4db94011d3 90 * <th>Index</th>
sahilmgandhi 18:6a4db94011d3 91 * <th>Value (only for set)</th>
sahilmgandhi 18:6a4db94011d3 92 * </tr>
sahilmgandhi 18:6a4db94011d3 93 * <tr>
sahilmgandhi 18:6a4db94011d3 94 * <td>1 Byte</td>
sahilmgandhi 18:6a4db94011d3 95 * <td>2 Bytes</td>
sahilmgandhi 18:6a4db94011d3 96 * <td>2 Bytes</td>
sahilmgandhi 18:6a4db94011d3 97 * <td>X bytes</td>
sahilmgandhi 18:6a4db94011d3 98 * </tr>
sahilmgandhi 18:6a4db94011d3 99 * </table>
sahilmgandhi 18:6a4db94011d3 100 *
sahilmgandhi 18:6a4db94011d3 101 * The reply to this request will have the same structure, with the value always
sahilmgandhi 18:6a4db94011d3 102 * being present (in case of a Set as well as a Get request).
sahilmgandhi 18:6a4db94011d3 103 *
sahilmgandhi 18:6a4db94011d3 104 * In case an error occurs during a Set or Get request, an error is returned by
sahilmgandhi 18:6a4db94011d3 105 * fMibGetBytes(), fMibSetBytes() or the UI. See the UI Module's documentation for
sahilmgandhi 18:6a4db94011d3 106 * the format of an error reply. The applicable error codes are:
sahilmgandhi 18:6a4db94011d3 107 * <table>
sahilmgandhi 18:6a4db94011d3 108 * <tr><th>0x01</th><td>Trying to set a read-only parameter.</td></tr>
sahilmgandhi 18:6a4db94011d3 109 * <tr><th>0x02</th><td>Requested value out of range.</td></tr>
sahilmgandhi 18:6a4db94011d3 110 * <tr><th>0x03</th><td>Object ID is unknown.</td></tr>
sahilmgandhi 18:6a4db94011d3 111 * <tr><th>0x04</th><td>Provided index is incorrect.</td></tr>
sahilmgandhi 18:6a4db94011d3 112 * </table>
sahilmgandhi 18:6a4db94011d3 113 *
sahilmgandhi 18:6a4db94011d3 114 * @ingroup mib
sahilmgandhi 18:6a4db94011d3 115 */
sahilmgandhi 18:6a4db94011d3 116
sahilmgandhi 18:6a4db94011d3 117 #ifndef MIB_H_
sahilmgandhi 18:6a4db94011d3 118 #define MIB_H_
sahilmgandhi 18:6a4db94011d3 119
sahilmgandhi 18:6a4db94011d3 120
sahilmgandhi 18:6a4db94011d3 121 #include <stdint.h>
sahilmgandhi 18:6a4db94011d3 122
sahilmgandhi 18:6a4db94011d3 123 #include "types.h"
sahilmgandhi 18:6a4db94011d3 124 #include "error.h"
sahilmgandhi 18:6a4db94011d3 125
sahilmgandhi 18:6a4db94011d3 126 /** A structure defining the format of the system revision parameter. */
sahilmgandhi 18:6a4db94011d3 127 typedef struct mib_systemRevision {
sahilmgandhi 18:6a4db94011d3 128 uint8_t hardwareRevision;
sahilmgandhi 18:6a4db94011d3 129 uint8_t patchLevel;
sahilmgandhi 18:6a4db94011d3 130 uint8_t bugFix;
sahilmgandhi 18:6a4db94011d3 131 uint8_t featureSet;
sahilmgandhi 18:6a4db94011d3 132 uint8_t generation;
sahilmgandhi 18:6a4db94011d3 133 uint8_t release;
sahilmgandhi 18:6a4db94011d3 134 } mib_systemRevision_t, *mib_systemRevision_pt;
sahilmgandhi 18:6a4db94011d3 135
sahilmgandhi 18:6a4db94011d3 136 /** The system revision. */
sahilmgandhi 18:6a4db94011d3 137 extern const mib_systemRevision_t systemRevision;
sahilmgandhi 18:6a4db94011d3 138
sahilmgandhi 18:6a4db94011d3 139
sahilmgandhi 18:6a4db94011d3 140 #endif /* MIB_H_ */