Revision cda14729

View differences:

README.txt
300 300
Next, you have to configure the main thread to whitelist the event flag (all I/O
301 301
events are blacklisted by default). While system relevant events like power down
302 302
are whitelisted by the OS, any custom events need to be added exl´plicitely.
303
This is done via the optional AMIROOS_CFG_MAIN_LOOP_IOEVENT_MASK macro, which
304
should be defined in the module.h file. Example:
305

  
306
  #define AMIROOS_CFG_MAIN_LOOP_IOEVENT_MASK                \
307
    (AOS_IOEVENT_FLAG(padX) | AOS_IOEVENT_FLAG(padY) | AOS_IOEVENT_FLAG(padZ))
308

  
309
When AMIROOS_CFG_MAIN_LOOP_IOEVENT_MASK has been defined correctly, the main
310
thread will be notified by the according events and execute its event handling
311
routine. Hence you have to implement another macro in module.h to handle the
312
custom event(s) appropriately: MODULE_MAIN_LOOP_IO_EVENT(eventflags). As you can
313
see, the variable 'eventflags' is propagated to the hook. This variable is a
314
mask, that allows to identify the GPIO pad(s), which caused the event, by the
315
bits set. Following the example above, you can check which GPIOs have caused
316
events by using if-clauses in the implementation of the hook:
317

  
318
  #define MODULE_MAIN_LOOP_IO_EVENT(eventflags) {           \
319
    if (eventflags & AOS_IOEVENT_FLAG(padX)) {              \
303
This is done via the optional AMIROOS_CFG_MAIN_LOOP_GPIOEVENT_FLAGSMASK macro,
304
which should be defined in the module.h file. Example:
305

  
306
  #define AMIROOS_CFG_MAIN_LOOP_GPIOEVENT_FLAGSMASK         \
307
    (AOS_GPIOEVENT_FLAG(padX) | AOS_GPIOEVENT_FLAG(padY) | AOS_GPIOEVENT_FLAG(padZ))
308

  
309
When AMIROOS_CFG_MAIN_LOOP_GPIOEVENT_FLAGSMASK has been defined correctly, the
310
main thread will be notified by the according events and execute its event
311
handling routine. Hence you have to implement another macro in module.h to
312
handle the custom event(s) appropriately: MODULE_MAIN_LOOP_GPIOEVENT(eventflags).
313
As you can see, the variable 'eventflags' is propagated to the hook. This
314
variable is a mask, that allows to identify the GPIO pad(s), which caused the
315
event, by the bits set. Following the example above, you can check which GPIOs
316
have caused events by using if-clauses in the implementation of the hook:
317

  
318
  #define MODULE_MAIN_LOOP_GPIOEVENT(eventflags) {          \
319
    if (eventflags & AOS_GPIOEVENT_FLAG(padX)) {            \
320 320
      /* handle event */                                    \
321 321
    }                                                       \
322 322
    if (eventflags & (AOS_IOEVENT_FLAG(padY) |              \
323
          AOS_IOEVENT_FLAG(padZ))) {                        \
323
          AOS_GPIOEVENT_FLAG(padZ))) {                      \
324 324
      /* handle combined event */                           \
325 325
    }                                                       \
326 326
  }
327 327

  
328 328
Summing up, you have to
329 329
1) configure and enable the GPIO interrupt.
330
2) define the AMIROOS_CFG_MAIN_LOOP_IOEVENT_MASK macro.
331
3) implement the MODULE_MAIN_LOOP_IO_EVENT(eventflags) hook.
330
2) define the AMIROOS_CFG_MAIN_LOOP_GPIOEVENT_FLAGSMASK macro.
331
3) implement the MODULE_MAIN_LOOP_GPIOEVENT(eventflags) hook.
332 332

  
333 333

  
334 334
4.3  Implementing a New Low-Level Driver
amiroos.h
45 45
 * @brief   The operating system minor version.
46 46
 * @note    A higher minor version implies new functionalty, but all old interfaces are still available.
47 47
 */
48
#define AMIROOS_VERSION_MINOR         0
48
#define AMIROOS_VERSION_MINOR         1
49 49

  
50 50
/**
51 51
 * @brief   The operating system patch level.
52 52
 */
53
#define AMIROOS_VERSION_PATCH         1
53
#define AMIROOS_VERSION_PATCH         0
54 54

  
55 55
/** @} */
56 56

  
57 57
/******************************************************************************/
58
/* CONFIGURATION                                                              */
59
/******************************************************************************/
60

  
61
#include <aosconf.h>
62
#if !defined(_AMIRO_OS_CFG_)
63
#error "invalid AMiRo-OS configuration file"
64
#elif (AMIRO_OS_CFG_VERSION_MAJOR != AMIROOS_VERSION_MAJOR) || (AMIRO_OS_CFG_VERSION_MINOR < AMIROOS_VERSION_MINOR)
65
#error "incompatible AMiRo-OS configuration file"
66
#endif
67

  
68
/******************************************************************************/
58 69
/* SUBSYSTEMS                                                                 */
59 70
/******************************************************************************/
60 71

  
61
/* Bootloader (AMiRo-BLT) */
62
#include <amiroblt.h>
72
/* Bootloader */
73
#include <aos_bootloader.h>
63 74

  
64 75
/* System Kerne (ChibiOS)l */
65 76
#include <hal.h>
......
72 83
/* AMiRo-OS CORE                                                              */
73 84
/******************************************************************************/
74 85

  
75
/* configuration */
76
#include <aosconf.h>
77
#if !defined(_AMIRO_OS_CFG_)
78
#error "invalid AMiRo-OS configuration file"
79
#elif (AMIRO_OS_CFG_VERSION_MAJOR != AMIROOS_VERSION_MAJOR) || (AMIRO_OS_CFG_VERSION_MINOR < AMIROOS_VERSION_MINOR)
80
#error "incompatible AMiRo-OS configuration file"
81
#endif
82 86
#include "core/inc/aos_confcheck.h"
83 87

  
84
/* core headers */
85 88
#include "core/inc/aos_types.h"
86 89
#include "core/inc/aos_debug.h"
87 90
#include "core/inc/aos_time.h"
88 91
#include "core/inc/aos_timer.h"
89 92
#include "core/inc/aos_iostream.h"
90 93
#include "core/inc/aos_shell.h"
94
#include "core/inc/aos_sssp.h"
91 95
#include "core/inc/aos_system.h"
92 96
#include "core/inc/aos_thread.h"
93 97
#include "core/inc/aos_test.h"
94 98

  
95
/* module specifications */
99
/******************************************************************************/
100
/* MODULE                                                                     */
101
/******************************************************************************/
102

  
96 103
#include <module.h>
97 104

  
98 105
#endif /* AMIROOS_H */
bootloader/aos_bootloader.h
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_bootloader.h
21
 * @brief   Bootloader wrapper header.
22
 *
23
 * @addtogroup aos_bootloader
24
 * @{
25
 */
26

  
27
#ifndef AMIROOS_BOOTLOADER_H
28
#define AMIROOS_BOOTLOADER_H
29

  
30
#include <amiroos.h>
31

  
32
/******************************************************************************/
33
/* CONSTANTS                                                                  */
34
/******************************************************************************/
35

  
36
/**
37
 * @brief   Identifier for the case that no bootloader is installed/available.
38
 */
39
#define AOS_BOOTLOADER_NONE                     0
40

  
41
/**
42
 * @brief   Identifier for AMiRo-BLT
43
 * @note    The version of the installed AMiRo-BLT can be retreived via the AMiRo-BLT interface.
44
 */
45
#define AOS_BOOTLOADER_AMiRoBLT                 1
46

  
47
/******************************************************************************/
48
/* SETTINGS                                                                   */
49
/******************************************************************************/
50

  
51
#if (AMIROOS_CFG_BOOTLOADER == AOS_BOOTLOADER_AMiRoBLT)
52
#include <amiroblt.h>
53
#endif
54

  
55
/******************************************************************************/
56
/* CHECKS                                                                     */
57
/******************************************************************************/
58

  
59
#if (AMIROOS_CFG_BOOTLOADER != AOS_BOOTLOADER_NONE) &&                        \
60
    (AMIROOS_CFG_BOOTLOADER != AOS_BOOTLOADER_AMiRoBLT)
61
  #error "AMIROOS_CFG_BOOTLOADER set to invalid value in aosconf.h"
62
#endif
63

  
64
/******************************************************************************/
65
/* DATA STRUCTURES AND TYPES                                                  */
66
/******************************************************************************/
67

  
68
/******************************************************************************/
69
/* MACROS                                                                     */
70
/******************************************************************************/
71

  
72
/******************************************************************************/
73
/* EXTERN DECLARATIONS                                                        */
74
/******************************************************************************/
75

  
76
/******************************************************************************/
77
/* INLINE FUNCTIONS                                                           */
78
/******************************************************************************/
79

  
80
#endif /* AMIROOS_BOOTLOADER_H */
81

  
82
/** @} */
bootloader/bootloader.mk
30 30
AMIROBLT := $(AMIROOS_BOOTLOADER_DIR)AMiRo-BLT
31 31

  
32 32
# include paths
33
AMIROOS_BOOTLOADER_INC = $(AMIROBLT)/Target/Source/AMiRo
33
AMIROOS_BOOTLOADER_INC = $(AMIROOS_BOOTLOADER_DIR) \
34
                         $(AMIROBLT)/Target/Source/AMiRo
34 35

  
35 36
# load module ID constants
36 37
include $(AMIROBLT)/Target/Modules/moduleids.mk
core/inc/aos_confcheck.h
59 59
  #error "AMIROOS_CFG_MAIN_LOOP_TIMEOUT not defined in aosconf.h"
60 60
#endif /* !defined(AMIROOS_CFG_MAIN_LOOP_TIMEOUT) */
61 61

  
62
/* bootloader parameters and options */
63

  
64
#if !defined(AMIROOS_CFG_BOOTLOADER)
65
  #error "AMIROOS_CFG_BOOTLOADER not defined in aosconf.h"
66
#endif /* !defined(AMIROOS_CFG_BOOTLOADER)*/
67

  
62 68
/* SSSP parameters and options */
63 69

  
64 70
#if !defined(AMIROOS_CFG_SSSP_ENABLE)
65 71
  #error "AMIROOS_CFG_SSSP_ENABLE not defined in aosconf.h"
66 72
#endif /* !defined(AMIROOS_CFG_SSSP_ENABLE) */
67 73

  
68
# if (AMIROOS_CFG_SSSP_ENABLE == true)
74
#if (AMIROOS_CFG_SSSP_ENABLE == true)
75

  
76
  #if !defined(AMIROOS_CFG_SSSP_STARTUP)
77
    #error "AMIROOS_CFG_SSSP_STARTUP not defined in aosconf.h"
78
  #else /* !defined(AMIROOS_CFG_SSSP_STARTUP) */
79
    #if (AMIROOS_CFG_SSSP_STARTUP == true)
80
      #if (AMIROOS_CFG_BOOTLOADER == AOS_BOOTLOADER_AMiRoBLT)
81
        #error "AMIROOS_CFG_SSSP_STARTUP is enabled in aosconf.h, but SSSP startup phase is already handled by AMiRo-BLT."
82
      #endif /* (AMIROOS_CFG_BOOTLOADER == AOS_BOOTLOADER_AMiRoBLT) */
83
    #else /* (AMIROOS_CFG_SSSP_STARTUP == true) */
84
      #if (AMIROOS_CFG_BOOTLOADER == AOS_BOOTLOADER_NONE)
85
        #error "AMIROOS_CFG_SSSP_STARTUP is disabled in aosconf.h, but no bootloader is defined to handle SSSP startup phase instead."
86
      #endif /* (AMIROOS_CFG_BOOTLOADER == AOS_BOOTLOADER_NONE) */
87
    #endif /* (AMIROOS_CFG_SSSP_STARTUP == true) */
88
  #endif /* !defined(AMIROOS_CFG_SSSP_STARTUP) */
89

  
90
  #if !defined(AMIROOS_CFG_SSSP_SHUTDOWN)
91
    #error "AMIROOS_CFG_SSSP_SHUTDOWN not defined in aosconf.h"
92
  #else /* !defined(AMIROOS_CFG_SSSP_SHUTDOWN) */
93
    #if (AMIROOS_CFG_SSSP_SHUTDOWN != true)
94
      #if (AMIROOS_CFG_BOOTLOADER == AOS_BOOTLOADER_NONE)
95
        #error "AMIROOS_CFG_SSSP_SHUTDOWN is disabled in aosconf.h, but no bootloader is defined to handle SSSP shutdown phase instead."
96
      #endif /* (AMIROOS_CFG_BOOTLOADER == AOS_BOOTLOADER_NONE) */
97
    #endif /* (AMIROOS_CFG_SSSP_SHUTDOWN != true) && (AMIROOS_CFG_BOOTLOADER == AOS_BOOTLOADER_NONE) */
98
  #endif /* !defined(AMIROOS_CFG_SSSP_SHUTDOWN) */
99

  
100
  #if !defined(AMIROOS_CFG_SSSP_MSI)
101
    #error "AMIROOS_CFG_SSSP_MSI not defined in aosconf.h"
102
  #endif /* !defined(AMIROOS_CFG_SSSP_MSI) */
103

  
104
  #if !defined(AMIROOS_CFG_SSSP_MODULEIDWIDTH)
105
    #error "AMIROOS_CFG_SSSP_MODULEIDWIDTH not defined in aosconf.h"
106
  #endif /* !defined(AMIROOS_CFG_SSSP_MODULEIDWIDTH) */
69 107

  
70 108
  #if !defined(AMIROOS_CFG_SSSP_MASTER)
71 109
    #error "AMIROOS_CFG_SSSP_MASTER not defined in aosconf.h"
......
94 132
    #error "AMIROOS_CFG_SSSP_SYSSYNCPERIOD not defined in aosconf.h"
95 133
  #endif /* !defined(AMIROOS_CFG_SSSP_SYSSYNCPERIOD) */
96 134

  
135
#else /* (AMIROOS_CFG_SSSP_ENABLE == true) */
136

  
137
  #if (AMIROOS_CFG_BOOTLOADER == AOS_BOOTLOADER_AMiRoBLT)
138
    #warning "SSSP is disabled in aosconf.h, but AMiRo-BLT implements it nevertheless."
139
  #endif /* (AMIROOS_CFG_BOOTLOADER == AOS_BOOTLOADER_AMiRoBLT) */
140

  
97 141
#endif /* (AMIROOS_CFG_SSSP_ENABLE == true) */
98 142

  
99 143
/* system shell options */
......
123 167
#else /* (AMIROOS_CFG_SHELL_ENABLE == true) */
124 168

  
125 169
  #if (AMIROOS_CFG_TESTS_ENABLE == true)
126
    #pragma message "AMiRo-OS shell enabled implicitely via AMIROOS_CFG_TESTS_ENABLE"
170
    #error "Enabling AMIROOS_CFG_TESTS_ENABLE in aosconf.h requires AMIROOS_CFG_SHELL_ENABLE to be enabled as well."
127 171
  #endif /* (AMIROOS_CFG_TESTS_ENABLE == true) */
128 172

  
129 173
#endif /* (AMIROOS_CFG_SHELL_ENABLE == true) */
core/inc/aos_shell.h
29 29

  
30 30
#include <amiroos.h>
31 31

  
32
#if (AMIROOS_CFG_SHELL_ENABLE == true) || (AMIROOS_CFG_TESTS_ENABLE == true)
32
#if (AMIROOS_CFG_SHELL_ENABLE == true) || defined(__DOXYGEN__)
33 33

  
34 34
/******************************************************************************/
35 35
/* CONSTANTS                                                                  */
......
418 418
/* INLINE FUNCTIONS                                                           */
419 419
/******************************************************************************/
420 420

  
421
#endif /* (AMIROOS_CFG_SHELL_ENABLE == true) || (AMIROOS_CFG_TESTS_ENABLE == true) */
421
#endif /* (AMIROOS_CFG_SHELL_ENABLE == true) */
422 422

  
423 423
#endif /* AMIROOS_SHELL_H */
424 424

  
core/inc/aos_sssp.h
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 pahse.          */
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