gusimplewhiteboard
wb_fsm_control_status.h
Go to the documentation of this file.
1/*
2 * wb_fsm_control_status.h
3 * gusimplewhiteboard / clfsm
4 *
5 * Created by Rene Hexel on 18/06/2014.
6 * Copyright (c) 2013, 2014, 2015, 2016 Rene Hexel. All rights reserved.
7 *
8 * Redistribution and use in source and binary forms, with or without
9 * modification, are permitted provided that the following conditions
10 * are met:
11 *
12 * 1. Redistributions of source code must retain the above copyright
13 * notice, this list of conditions and the following disclaimer.
14 *
15 * 2. Redistributions in binary form must reproduce the above
16 * copyright notice, this list of conditions and the following
17 * disclaimer in the documentation and/or other materials
18 * provided with the distribution.
19 *
20 * 3. All advertising materials mentioning features or use of this
21 * software must display the following acknowledgement:
22 *
23 * This product includes software developed by Rene Hexel.
24 *
25 * 4. Neither the name of the author nor the names of contributors
26 * may be used to endorse or promote products derived from this
27 * software without specific prior written permission.
28 *
29 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
30 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
31 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
32 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER
33 * OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
34 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
35 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
36 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
37 * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
38 * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
39 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
40 *
41 * -----------------------------------------------------------------------
42 * This program is free software; you can redistribute it and/or
43 * modify it under the above terms or under the terms of the GNU
44 * General Public License as published by the Free Software Foundation;
45 * either version 2 of the License, or (at your option) any later version.
46 *
47 * This program is distributed in the hope that it will be useful,
48 * but WITHOUT ANY WARRANTY; without even the implied warranty of
49 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
50 * GNU General Public License for more details.
51 *
52 * You should have received a copy of the GNU General Public License
53 * along with this program; if not, see http://www.gnu.org/licenses/
54 * or write to the Free Software Foundation, Inc., 51 Franklin Street,
55 * Fifth Floor, Boston, MA 02110-1301, USA.
56 *
57 */
58#ifndef gusimplewhiteboard_wb_fsm_control_status_h
59#define gusimplewhiteboard_wb_fsm_control_status_h
60
61#include <gu_util.h>
63
64#define CONTROLSTATUS_BYTE_SIZE (sizeof(gu_simple_message))
65#define CONTROLSTATUS_BIT_SIZE (CONTROLSTATUS_BYTE_SIZE*8)
66#define CONTROLSTATUS_BITS_RESERVED 2 // must be big enough for enum
67#define CONTROLSTATUS_NUM_FSMS (CONTROLSTATUS_BIT_SIZE - CONTROLSTATUS_BITS_RESERVED)
68#define CONTROLSTATUS_CMD (CONTROLSTATUS_BYTE_SIZE-1)
69#define CONTROLSTATUS_CMD_LO (1<<6)
70#define CONTROLSTATUS_CMD_HI (1<<7)
71#define CONTROLSTATUS_CMD_MASK (CONTROLSTATUS_CMD_LO|CONTROLSTATUS_CMD_HI)
72
73#define CONTROLSTATUS_CLR_FSM(s, fsm) ((s)->_fsms[(fsm)/8] &=~(1<<((fsm)%8)))
74#define CONTROLSTATUS_SET_FSM(s, fsm) ((s)->_fsms[(fsm)/8] |= (1<<((fsm)%8)))
75#define CONTROLSTATUS_GET_FSM(s, fsm) ((((s)->_fsms[(fsm)/8]) & (1<<((fsm)%8))) != 0)
76
77#ifndef __cplusplus
78#define CONTROLSTATUS_SET_CMD(s, cmd) ((s)->_fsms[CONTROLSTATUS_CMD] = (uint8_t)(((s)->_fsms[CONTROLSTATUS_CMD] & ~CONTROLSTATUS_CMD_MASK) | (((cmd) & 3) << 6)))
79#else
80#define CONTROLSTATUS_SET_CMD(s, cmd) ((s)->_fsms[CONTROLSTATUS_CMD] = static_cast<uint8_t>(((s)->_fsms[CONTROLSTATUS_CMD] & ~CONTROLSTATUS_CMD_MASK) | (((cmd) & 3) << 6)))
81#define CONTROLSTATUS_GET_CMD(s) ((((s)->_fsms[CONTROLSTATUS_CMD]) >> 6) & 3)
82
83namespace guWhiteboard
84{
85#endif
90 {
95 };
96#ifdef __cplusplus
97}
98#endif
99
111{
114
115#ifdef __cplusplus
118#endif
119};
120
121#endif
/file APM_Interface.h
FSMControlType
command for ControlStatus
@ FSMSuspend
suspend the corresponding state machines
@ FSMRestart
restart the corresponding state machine
@ FSMStatus
check status only
@ FSMResume
resume the corresponding state machines
Finite State Machine Control and Status information.
ARRAY_PROPERTY(uint8_t, fsms,(sizeof(gu_simple_message))) wb_fsm_control_status(guWhiteboard
bit vector of FSMs and command
#define CONTROLSTATUS_BYTE_SIZE
#define CONTROLSTATUS_SET_CMD(s, cmd)