1/* 2 $License: 3 Copyright (C) 2011-2012 InvenSense Corporation, All Rights Reserved. 4 See included License.txt for License information. 5 $ 6 */ 7/** 8 * @defgroup Message_Layer message_layer 9 * @brief Motion Library - Message Layer 10 * Holds Low Occurance messages 11 * 12 * @{ 13 * @file message_layer.c 14 * @brief Holds Low Occurance Messages. 15 */ 16#include "message_layer.h" 17#include "log.h" 18 19struct message_holder_t { 20 long message; 21}; 22 23static struct message_holder_t mh; 24 25/** Sets a message. 26* @param[in] set The flags to set. 27* @param[in] clear Before setting anything this will clear these messages, 28* which is useful for mutually exclusive messages such 29* a motion or no motion message. 30* @param[in] level Level of the messages. It starts at 0, and may increase 31* in the future to allow more messages if the bit storage runs out. 32*/ 33void inv_set_message(long set, long clear, int level) 34{ 35 if (level == 0) { 36 mh.message &= ~clear; 37 mh.message |= set; 38 } 39} 40 41/** Returns Message Flags for Level 0 Messages. 42* Levels are to allow expansion of more messages in the future. 43* @param[in] clear If set, will clear the message. Typically this will be set 44* for one reader, so that you don't get the same message over and over. 45* @return bit field to corresponding message. 46*/ 47long inv_get_message_level_0(int clear) 48{ 49 long msg; 50 msg = mh.message; 51 if (clear) { 52 mh.message = 0; 53 } 54 return msg; 55} 56 57/** 58 * @} 59 */ 60