Statistics
| Branch: | Tag: | Revision:

amiro-os / core / inc / aos_sssp.h @ c218345a

History | View | Annotate | Download (7.994 KB)

1
/*
2
AMiRo-OS is an operating system designed for the Autonomous Mini Robot (AMiRo) platform.
3
Copyright (C) 2016..2019  Thomas Schöpping et al.
4

5
This program is free software: you can redistribute it and/or modify
6
it under the terms of the GNU General Public License as published by
7
the Free Software Foundation, either version 3 of the License, or
8
(at your option) any later version.
9

10
This program is distributed in the hope that it will be useful,
11
but WITHOUT ANY WARRANTY; without even the implied warranty of
12
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13
GNU General Public License for more details.
14

15
You should have received a copy of the GNU General Public License
16
along with this program.  If not, see <http://www.gnu.org/licenses/>.
17
*/
18

    
19
/**
20
 * @file    aos_sssp.h
21
 * @brief   SSSP related macros, structures and functions.
22
 *
23
 * @addtogroup aos_sssp
24
 * @{
25
 */
26

    
27
#ifndef AMIROOS_SSSP_H
28
#define AMIROOS_SSSP_H
29

    
30
#include <amiroos.h>
31

    
32
#if (AMIROOS_CFG_SSSP_ENABLE == true) || defined(__DOXYGEN__)
33

    
34
/******************************************************************************/
35
/* CONSTANTS                                                                  */
36
/******************************************************************************/
37

    
38
/**
39
 * @brief   Major version of the implemented SSSP.
40
 */
41
#define AOS_SSSP_VERSION_MAJOR                  1
42

    
43
/**
44
 * @brief   Minor version of the implemented SSSP.
45
 */
46
#define AOS_SSSP_VERSION_MINOR                  4
47

    
48
/**
49
 * @brief   Time of delays in microseconds.
50
 */
51
#define AOS_SSSP_DELAY                          AMIROOS_CFG_SSSP_SIGNALDELAY
52

    
53
/**
54
 * @brief   Timeout delay in microseconds according to SSSP.
55
 * @details SSSP 1.x defines timeouts to be ten times longer than the signal delay time.
56
 */
57
#define AOS_SSSP_TIMEOUT                        (10 * AOS_SSSP_DELAY)
58

    
59
/**
60
 * @brief   Value to indicate an invalid module ID.
61
 */
62
#define AOS_SSSP_MODULEID_INVALID               ((aos_ssspmoduleid_t)0)
63

    
64
/**
65
 * @brief   Value for broadcasting, adressing all modules.
66
 * @note    This value is identical to @p AOS_SSSP_MODULEID_INVALID since in the case that no module IDs were applied, addressing of specific modules is not possible, thus every communication would be a broadcast.
67
 */
68
#define AOS_SSSP_MODULEID_BROADCAST             ((aos_ssspmoduleid_t)0)
69

    
70
/******************************************************************************/
71
/* SETTINGS                                                                   */
72
/******************************************************************************/
73

    
74
/******************************************************************************/
75
/* CHECKS                                                                     */
76
/******************************************************************************/
77

    
78
#if (AMIROOS_CFG_SSSP_MSI == true)
79
  #error "SSSP module stack initialization (MSI not implemented yet"
80
#endif
81

    
82
/******************************************************************************/
83
/* DATA STRUCTURES AND TYPES                                                  */
84
/******************************************************************************/
85

    
86
/**
87
 * @brief   Enumeration of the several stages of SSSP.
88
 */
89
typedef enum {
90
  AOS_SSSP_STAGE_UNDEFINED    = 0x0000, /**< Identifier of yet undefined stage variable.  */
91
  AOS_SSSP_STAGE_STARTUP      = 0x1000, /**< Identifier of SSSP startup phase.            */
92
  AOS_SSSP_STAGE_STARTUP_1    = 0x1100, /**< Identifier of SSSP startup phase stage 1.    */
93
  AOS_SSSP_STAGE_STARTUP_1_1  = 0x1110, /**< Identifier of SSSP startup phase stage 1-1.  */
94
  AOS_SSSP_STAGE_STARTUP_1_2  = 0x1120, /**< Identifier of SSSP startup phase stage 1-2.  */
95
  AOS_SSSP_STAGE_STARTUP_1_3  = 0x1130, /**< Identifier of SSSP startup phase stage 1-3.  */
96
  AOS_SSSP_STAGE_STARTUP_2    = 0x1200, /**< Identifier of SSSP startup phase stage 2.    */
97
  AOS_SSSP_STAGE_STARTUP_2_1  = 0x1210, /**< Identifier of SSSP startup phase stage 2-1.  */
98
  AOS_SSSP_STAGE_STARTUP_2_2  = 0x1220, /**< Identifier of SSSP startup phase stage 2-2.  */
99
  AOS_SSSP_STAGE_STARTUP_3    = 0x1300, /**< Identifier of SSSP startup phase stage 3.    */
100
  AOS_SSSP_STAGE_STARTUP_3_1  = 0x1310, /**< Identifier of SSSP startup phase stage 3-1.  */
101
  AOS_SSSP_STAGE_STARTUP_3_2  = 0x1320, /**< Identifier of SSSP startup phase stage 3-2.  */
102
  AOS_SSSP_STAGE_STARTUP_3_3  = 0x1330, /**< Identifier of SSSP startup phase stage 3-3.  */
103
  AOS_SSSP_STAGE_STARTUP_3_4  = 0x1340, /**< Identifier of SSSP startup phase stage 3-4.  */
104
  AOS_SSSP_STAGE_OPERATION    = 0x2000, /**< Identifier of SSSP operation phase.          */
105
  AOS_SSSP_STAGE_SHUTDOWN     = 0x3000, /**< Identifier of SSSP shutdown phase.           */
106
  AOS_SSSP_STAGE_SHUTDOWN_1   = 0x3100, /**< Identifier of SSSP shutdown phase stage 1.   */
107
  AOS_SSSP_STAGE_SHUTDOWN_1_1 = 0x3110, /**< Identifier of SSSP shutdown phase stage 1-1. */
108
  AOS_SSSP_STAGE_SHUTDOWN_1_2 = 0x3120, /**< Identifier of SSSP shutdown phase stage 1-2. */
109
  AOS_SSSP_STAGE_SHUTDOWN_1_3 = 0x3130, /**< Identifier of SSSP shutdown phase stage 1-3. */
110
  AOS_SSSP_STAGE_SHUTDOWN_2   = 0x3200, /**< Identifier of SSSP shutdown phase stage 2.   */
111
  AOS_SSSP_STAGE_SHUTDOWN_2_1 = 0x3210, /**< Identifier of SSSP shutdown phase stage 2-1. */
112
  AOS_SSSP_STAGE_SHUTDOWN_2_2 = 0x3220, /**< Identifier of SSSP shutdown phase stage 2-2. */
113
  AOS_SSSP_STAGE_SHUTDOWN_2_3 = 0x3230, /**< Identifier of SSSP shutdown phase stage 2-3. */
114
} aos_ssspstage_t;
115

    
116
/**
117
 * @brief   Type to represent module IDs.
118
 */
119
#if (AMIROOS_CFG_SSSP_MODULEIDWIDTH == 8)
120
typedef uint8_t aos_ssspmoduleid_t;
121
#elif (AMIROOS_CFG_SSSP_MODULEIDWIDTH == 16) || defined(__DOXYGEN__)
122
typedef uint16_t aos_ssspmoduleid_t;
123
#elif (AMIROOS_CFG_SSSP_MODULEIDWIDTH == 32)
124
typedef uint32_t aos_ssspmoduleid_t;
125
#else
126
#error "AMIROOS_CFG_SSSP_MODULEIDWIDTH set to an invalid value."
127
#endif
128

    
129
/**
130
 * @brief   Data structure holding module-wide SSSP information.
131
 */
132
typedef struct {
133
  /**
134
   * @brief   Current execution stage of SSSP.
135
   */
136
  aos_ssspstage_t stage;
137

    
138
#if (AMIROOS_CFG_SSSP_MSI == true) || defined(__DOXYGEN__)
139

    
140
  /**
141
   * @brief   Module identifier.
142
   * @details A value of @p AOS_SSSP_MODULEID_INVALID indicates an uninitialized ID.
143
   *          The values @p AOS_SSSP_MODULEID_INVALID and @p AOS_SSSP_MODULEID_ALL are reserved and must not be set.
144
   */
145
  aos_ssspmoduleid_t moduleId;
146

    
147
#endif /* (AMIROOS_CFG_SSSP_MSI == true) */
148

    
149
} aos_ssspdata_t;
150

    
151
/******************************************************************************/
152
/* MACROS                                                                     */
153
/******************************************************************************/
154

    
155
/******************************************************************************/
156
/* EXTERN DECLARATIONS                                                        */
157
/******************************************************************************/
158

    
159
#if defined(__cplusplus)
160
extern "C" {
161
#endif /* defined(__cplusplus) */
162
  void aosSsspInit(aos_timestamp_t* system_uptime);
163
  aos_status_t aosSsspProceed(event_listener_t* listener, eventflags_t flags, eventmask_t mask, eventmask_t* received);
164
  void aosSsspShutdownInit(bool active);
165
#if (AMIROOS_CFG_SSSP_SHUTDOWN == true) || defined(__DOXYGEN__)
166
  void aosSsspShutdownBroadcastIdentifier(unsigned int identifier);
167
  eventmask_t aosSsspShutdownWaitForIdentifierPulse(event_listener_t* gpiolistener, eventflags_t sflags, eventmask_t timermask, unsigned int* identifier);
168
#endif /* (AMIROOS_CFG_SSSP_SHUTDOWN == true) */
169
#if ((AMIROOS_CFG_SSSP_MASTER != true) && (AMIROOS_CFG_PROFILE == true)) || defined(__DOXYGEN__)
170
  float aosSsspGetSyncSkew(void);
171
#endif /* (AMIROOS_CFG_SSSP_MASTER != true) && (AMIROOS_CFG_PROFILE == true) */
172
#if defined(__cplusplus)
173
}
174
#endif /* defined(__cplusplus) */
175

    
176
/******************************************************************************/
177
/* INLINE FUNCTIONS                                                           */
178
/******************************************************************************/
179

    
180
#endif /* (AMIROOS_CFG_SSSP_ENABLE == true) */
181

    
182
#endif /* AMIROOS_SSSP_H */
183

    
184
/** @} */