HiveMind
FreeRTOSConfig.h
Go to the documentation of this file.
1 /*
2  * FreeRTOS Kernel V10.4.1
3  * Copyright (C) 2020 Amazon.com, Inc. or its affiliates. All Rights Reserved.
4  *
5  * Permission is hereby granted, free of charge, to any person obtaining a copy of
6  * this software and associated documentation files (the "Software"), to deal in
7  * the Software without restriction, including without limitation the rights to
8  * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
9  * the Software, and to permit persons to whom the Software is furnished to do so,
10  * subject to the following conditions:
11  *
12  * The above copyright notice and this permission notice shall be included in all
13  * copies or substantial portions of the Software.
14  *
15  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16  * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
17  * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
18  * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
19  * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
20  * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
21  *
22  * http://www.FreeRTOS.org
23  * http://aws.amazon.com/freertos
24  *
25  * 1 tab == 4 spaces!
26  */
27 
28 #ifndef FREERTOS_CONFIG_H
29 #define FREERTOS_CONFIG_H
30 
31 /*-----------------------------------------------------------
32  * Application specific definitions.
33  *
34  * These definitions should be adjusted for your particular hardware and
35  * application requirements.
36  *
37  * THESE PARAMETERS ARE DESCRIBED WITHIN THE 'CONFIGURATION' SECTION OF THE
38  * FreeRTOS API DOCUMENTATION AVAILABLE ON THE FreeRTOS.org WEB SITE.
39  *
40  * See http://www.freertos.org/a00110.html
41  *----------------------------------------------------------*/
42 
43 #include <stdint.h>
44 
45 #include <freertos_platform_config.h>
46 
47 #define configUSE_PREEMPTION 1
48 #define configUSE_IDLE_HOOK 1
49 #define configUSE_TICK_HOOK 1
50 #define configMAX_PRIORITIES (56)
51 #define configMINIMAL_STACK_SIZE ((unsigned short)128)
52 #define configTOTAL_HEAP_SIZE ((size_t)(8 * 1024)) // Using heap3 so it's ingored anyway2
53 #define configMAX_TASK_NAME_LEN (20)
54 #define configUSE_TRACE_FACILITY 1
55 #define configUSE_16_BIT_TICKS 0
56 #define configIDLE_SHOULD_YIELD 1
57 #define configUSE_MUTEXES 1
58 #define configQUEUE_REGISTRY_SIZE 8
59 #define configCHECK_FOR_STACK_OVERFLOW 2
60 #define configUSE_RECURSIVE_MUTEXES 1
61 #define configUSE_MALLOC_FAILED_HOOK 1
62 #define configUSE_APPLICATION_TASK_TAG 0
63 #define configUSE_COUNTING_SEMAPHORES 1
64 #define configSUPPORT_DYNAMIC_ALLOCATION 1
65 #define configSUPPORT_STATIC_ALLOCATION 1
66 #define configUSE_PORT_OPTIMISED_TASK_SELECTION 0
67 
68 /* Co-routine definitions. */
69 #define configUSE_CO_ROUTINES 0
70 #define configMAX_CO_ROUTINE_PRIORITIES (2)
71 
72 /* Software timer definitions. */
73 #define configUSE_TIMERS 1
74 #define configTIMER_TASK_PRIORITY (2)
75 #define configTIMER_QUEUE_LENGTH 10
76 #define configTIMER_TASK_STACK_DEPTH (configMINIMAL_STACK_SIZE * 2)
77 
78 /* Set the following definitions to 1 to include the API function, or zero
79 to exclude the API function. */
80 #define INCLUDE_vTaskPrioritySet 1
81 #define INCLUDE_uxTaskPriorityGet 1
82 #define INCLUDE_vTaskDelete 1
83 #define INCLUDE_vTaskCleanUpResources 1
84 #define INCLUDE_vTaskSuspend 1
85 #define INCLUDE_vTaskDelayUntil 1
86 #define INCLUDE_vTaskDelay 1
87 
88 /* Cortex-M specific definitions. */
89 #ifdef __NVIC_PRIO_BITS
90 /* __BVIC_PRIO_BITS will be specified when CMSIS is being used. */
91 #define configPRIO_BITS __NVIC_PRIO_BITS
92 #else
93 #define configPRIO_BITS 4 /* 15 priority levels */
94 #endif
95 
96 /* The lowest interrupt priority that can be used in a call to a "set priority"
97 function. */
98 #define configLIBRARY_LOWEST_INTERRUPT_PRIORITY 0xf
99 
100 /* The highest interrupt priority that can be used by any interrupt service
101 routine that makes calls to interrupt safe FreeRTOS API functions. DO NOT CALL
102 INTERRUPT SAFE FREERTOS API FUNCTIONS FROM ANY INTERRUPT THAT HAS A HIGHER
103 PRIORITY THAN THIS! (higher priorities are lower numeric values. */
104 #define configLIBRARY_MAX_SYSCALL_INTERRUPT_PRIORITY 5
105 
106 /* Interrupt priorities used by the kernel port layer itself. These are generic
107 to all Cortex-M ports, and do not rely on any particular library functions. */
108 #define configKERNEL_INTERRUPT_PRIORITY \
109  (configLIBRARY_LOWEST_INTERRUPT_PRIORITY << (8 - configPRIO_BITS))
110 /* !!!! configMAX_SYSCALL_INTERRUPT_PRIORITY must not be set to zero !!!!
111 See http://www.FreeRTOS.org/RTOS-Cortex-M3-M4.html. */
112 #define configMAX_SYSCALL_INTERRUPT_PRIORITY \
113  (configLIBRARY_MAX_SYSCALL_INTERRUPT_PRIORITY << (8 - configPRIO_BITS))
114 
115 /* Normal assert() semantics without relying on the provision of an assert.h
116 header file. */
117 #define configASSERT(x) \
118  if ((x) == 0) { \
119  taskDISABLE_INTERRUPTS(); \
120  for (;;) \
121  ; \
122  }
123 
124 #endif /* FREERTOS_CONFIG_H */
PositionsTable
Definition: IInterloc.h:10
HiveMindHostApiRequestHandler::m_hostQueue
ICircularQueue< MessageDTO > & m_hostQueue
Definition: HiveMindHostApiRequestHandler.h:28
MessageDispatcher::m_hiveconnectApiMessageHandler
IHiveConnectHiveMindApiMessageHandler & m_hiveconnectApiMessageHandler
Definition: MessageDispatcher.h:38
MessageDispatcher::m_greetSender
IGreetSender & m_greetSender
Definition: MessageDispatcher.h:39
LogLevel::Debug
@ Debug
IBSP::getUUId
virtual uint16_t getUUId() const =0
Returns the unique id associated with the board.
MessageDispatcher::deserializeAndDispatch
bool deserializeAndDispatch() override
deserialize a message and dispatches it in the appropriate queue
Definition: MessageDispatcher.cpp:27
MessageDispatcher::m_buzzOutputQueue
ICircularQueue< MessageDTO > & m_buzzOutputQueue
Definition: MessageDispatcher.h:32
IInterloc::getRobotPosition
virtual std::optional< RelativePosition > getRobotPosition(uint16_t robotId) const =0
Returns the last known relative position of a given robot.
HiveMindHostApiRequestHandler::m_interloc
const IInterloc & m_interloc
Definition: HiveMindHostApiRequestHandler.h:30
MessageDispatcher::dispatchRequest
bool dispatchRequest(const MessageDTO &message, const RequestDTO &request)
Definition: MessageDispatcher.cpp:96
MessageDispatcher::m_bsp
const IBSP & m_bsp
Definition: MessageDispatcher.h:40
MessageDispatcher::dispatchUserCall
bool dispatchUserCall(const MessageDTO &message, const UserCallTargetDTO &dest)
Definition: MessageDispatcher.cpp:60
MessageDispatcher::MessageDispatcher
MessageDispatcher(ICircularQueue< MessageDTO > &buzzOutputQ, ICircularQueue< MessageDTO > &hostOutputQ, ICircularQueue< MessageDTO > &remoteOutputQ, ICircularQueue< MessageDTO > &interlocQ, IHiveMindHostDeserializer &deserializer, IHiveMindHostApiRequestHandler &hivemindApiReqHandler, IHiveConnectHiveMindApiMessageHandler &hiveconnectApiMessageHandler, IGreetSender &greetSender, const IBSP &bsp, ILogger &logger)
Definition: MessageDispatcher.cpp:5
IInterloc::getPositionsTable
virtual const PositionsTable & getPositionsTable() const =0
Returns the position table for all robots in the swarm.
HiveConnectHiveMindApiMessageHandler::m_logger
ILogger & m_logger
Definition: HiveConnectHiveMindApiMessageHandler.h:25
BSPContainer.h
GreetHandler::m_deserializer
IHiveMindHostDeserializer & m_deserializer
Definition: GreetHandler.h:21
ILogger::log
virtual LogRet log(LogLevel level, const char *format,...)=0
Logs if the provided level is higher than the current log level (Thread-safe)
HiveMindHostApiRequestHandler::HiveMindHostApiRequestHandler
HiveMindHostApiRequestHandler(const IBSP &bsp, ICircularQueue< MessageDTO > &hostQueue, ICircularQueue< MessageDTO > &remoteQueue, const IInterloc &interloc, ILogger &logger)
Definition: HiveMindHostApiRequestHandler.cpp:3
LoggerContainer.h
HiveMindHostApiRequestHandler::m_remoteQueue
ICircularQueue< MessageDTO > & m_remoteQueue
Definition: HiveMindHostApiRequestHandler.h:29
HiveMindHostApiRequestHandler
Definition: HiveMindHostApiRequestHandler.h:10
GreetHandler::GreetHandler
GreetHandler(IHiveMindHostSerializer &serializer, IHiveMindHostDeserializer &deserializer, IBSP &bsp)
Definition: GreetHandler.cpp:3
MessageHandlerContainer::getBuzzMsgQueue
ThreadSafeQueue< MessageDTO > & getBuzzMsgQueue()
get the buzz message queue
Definition: MessageHandlerContainer.cpp:35
MessageDispatcher::dispatchUserCallResponse
bool dispatchUserCallResponse(const MessageDTO &message, const UserCallResponseDTO &response)
Definition: MessageDispatcher.cpp:90
IHiveConnectHiveMindApiMessageHandler::handleMessage
virtual bool handleMessage(uint16_t sourceId, uint16_t destId, const HiveConnectHiveMindApiDTO &message)=0
handles HiveConnectHiveMindApi
GreetHandler.h
HiveMindHostApiRequestHandler.h
RelativePosition::m_isInLineOfSight
bool m_isInLineOfSight
Definition: RelativePosition.h:22
HiveConnectHiveMindApiMessageHandler::handleMessage
bool handleMessage(uint16_t sourceId, uint16_t destId, const HiveConnectHiveMindApiDTO &message) override
handles HiveConnectHiveMindApi
Definition: HiveConnectHiveMindApiMessageHandler.cpp:9
HiveMindHostApiRequestHandler::m_logger
ILogger & m_logger
Definition: HiveMindHostApiRequestHandler.h:31
IHiveMindHostApiRequestHandler
Handles HiveMindApi requests and sends the response to the appropriate target.
Definition: IHiveMindHostApiRequestHandler.h:10
HiveMindHostApiRequestHandler::m_bsp
const IBSP & m_bsp
Definition: HiveMindHostApiRequestHandler.h:27
HiveConnectHiveMindApiMessageHandler::m_hostQueue
ICircularQueue< MessageDTO > & m_hostQueue
Definition: HiveConnectHiveMindApiMessageHandler.h:23
HiveConnectHiveMindApiMessageHandler::HiveConnectHiveMindApiMessageHandler
HiveConnectHiveMindApiMessageHandler(ICircularQueue< MessageDTO > &hostQueue, ICircularQueue< MessageDTO > &remoteQueue, ILogger &logger)
Definition: HiveConnectHiveMindApiMessageHandler.cpp:3
InterlocContainer.h
vApplicationMallocFailedHook
void vApplicationMallocFailedHook(void)
Definition: freertos_hooks.c:12
MessageDispatcher::dispatchResponse
bool dispatchResponse(const MessageDTO &message, const ResponseDTO &response)
Definition: MessageDispatcher.cpp:118
HiveConnectHiveMindApiMessageHandler
Definition: HiveConnectHiveMindApiMessageHandler.h:10
GreetSender.h
MessageHandlerContainer::getRemoteMsgQueue
NotificationQueue< MessageDTO > & getRemoteMsgQueue()
get the remote message queue
Definition: MessageHandlerContainer.cpp:57
HiveConnectHiveMindApiMessageHandler.h
RelativePosition::m_angle
float m_angle
Angle of other agent in current agent frame (in degrees)
Definition: RelativePosition.h:17
MessageHandlerContainer::createMessageDispatcher
MessageDispatcher createMessageDispatcher(IHiveMindHostDeserializer &deserializer, IHiveMindHostApiRequestHandler &hivemindApiReqHandler, IHiveConnectHiveMindApiMessageHandler &hiveconnectApiMessageHandler, IGreetSender &greetSender)
create a message dispatcher
Definition: MessageHandlerContainer.cpp:24
LogLevel::Warn
@ Warn
HiveMindHostApiRequestHandler::handleRequest
bool handleRequest(const MessageDTO &message) override
handles HiveMindHostAPI request and sends a response to the approriate target
Definition: HiveMindHostApiRequestHandler.cpp:15
MessageHandlerContainer::createHiveMindHostApiRequestHandler
HiveMindHostApiRequestHandler createHiveMindHostApiRequestHandler()
create a request handler
Definition: MessageHandlerContainer.cpp:18
PositionsTable::m_positionsLength
uint16_t m_positionsLength
Definition: IInterloc.h:12
HiveConnectHiveMindApiMessageHandler::m_remoteQueue
ICircularQueue< MessageDTO > & m_remoteQueue
Definition: HiveConnectHiveMindApiMessageHandler.h:24
IBSP
Definition: IBSP.h:6
MessageSender.h
MessageSender::m_serializer
IHiveMindHostSerializer & m_serializer
Definition: MessageSender.h:23
IHiveConnectHiveMindApiMessageHandler
Handles HiveConnectHiveMindApi messages and makes the proper request.
Definition: IHiveConnectHiveMindApiMessageHandler.h:9
GreetHandler::m_bsp
IBSP & m_bsp
Definition: GreetHandler.h:22
MessageSender::m_inputQueue
ICircularQueue< MessageDTO > & m_inputQueue
Definition: MessageSender.h:22
vApplicationStackOverflowHook
void vApplicationStackOverflowHook(TaskHandle_t xTask, char *pcTaskName)
Definition: freertos_hooks.c:19
MessageDispatcher::dispatchUserCallRequest
bool dispatchUserCallRequest(const MessageDTO &message, const UserCallRequestDTO &request)
Definition: MessageDispatcher.cpp:84
LoggerContainer::getLogger
Logger & getLogger()
Return a reference to the global logger.
Definition: LoggerContainer.cpp:5
MessageDispatcher::m_deserializer
IHiveMindHostDeserializer & m_deserializer
Definition: MessageDispatcher.h:36
MessageDispatcher::dispatchMessage
bool dispatchMessage(const MessageDTO &message)
Definition: MessageDispatcher.cpp:131
ILogger
A logger class with basic logging capabilities.
Definition: ILogger.h:35
GreetHandler::greet
bool greet() override
wait for a greet and then send the greet response. Serializes directly to the stream and not the the ...
Definition: GreetHandler.cpp:8
MessageDispatcher::m_hostOutputQueue
ICircularQueue< MessageDTO > & m_hostOutputQueue
Definition: MessageDispatcher.h:33
BSPContainer::getBSP
IBSP & getBSP()
Returns an instance of the platform dependent BSP.
Definition: BSPContainer.cpp:13
InterlocContainer::getInterloc
IInterloc & getInterloc()
Definition: InterlocContainer.cpp:12
MessageDispatcher::m_logger
ILogger & m_logger
Definition: MessageDispatcher.h:41
GreetSender::GreetSender
GreetSender(ICircularQueue< MessageDTO > &outputQueue, IBSP &bsp)
Definition: GreetSender.cpp:3
IHiveMindHostApiRequestHandler::handleRequest
virtual bool handleRequest(const MessageDTO &message)=0
handles HiveMindHostAPI request and sends a response to the approriate target
MessageDispatcher.h
RelativePosition
Definition: RelativePosition.h:6
MessageSender::processAndSerialize
bool processAndSerialize() override
process an item in the queue, serializes it and sends it to the deserializer
Definition: MessageSender.cpp:9
MessageDispatcher::m_interlocQueue
ICircularQueue< MessageDTO > & m_interlocQueue
Definition: MessageDispatcher.h:35
vApplicationTickHook
void vApplicationTickHook(void)
Definition: freertos_hooks.c:10
MessageHandlerContainer::getInterlocMsgQueue
NotificationQueue< MessageDTO > & getInterlocMsgQueue()
get the interloc message queue
Definition: MessageHandlerContainer.cpp:70
MessageDispatcher::m_remoteOutputQueue
ICircularQueue< MessageDTO > & m_remoteOutputQueue
Definition: MessageDispatcher.h:34
IInterloc
Definition: IInterloc.h:15
MessageHandlerContainer::createHiveConnectHiveMindApiMessageHandler
HiveConnectHiveMindApiMessageHandler createHiveConnectHiveMindApiMessageHandler()
create a message handler
Definition: MessageHandlerContainer.cpp:13
MessageHandlerContainer::getHostMsgQueue
NotificationQueue< MessageDTO > & getHostMsgQueue()
get the host message queue
Definition: MessageHandlerContainer.cpp:44
PositionsTable::m_positions
std::array< RelativePosition, MAX_AGENTS_IN_SWARM > m_positions
Definition: IInterloc.h:11
GreetSender::sendGreet
bool sendGreet() override
send a greet to the output queue
Definition: GreetSender.cpp:6
gc_queueMaxSize
constexpr uint16_t gc_queueMaxSize
Definition: MessageHandlerContainer.cpp:10
MessageDispatcher
Definition: MessageDispatcher.h:14
GreetHandler::m_serializer
IHiveMindHostSerializer & m_serializer
Definition: GreetHandler.h:20
GreetSender::m_outputQueue
ICircularQueue< MessageDTO > & m_outputQueue
Definition: GreetSender.h:18
MessageSender::MessageSender
MessageSender(ICircularQueue< MessageDTO > &inputQueue, IHiveMindHostSerializer &serializer, IBSP &bsp, ILogger &logger)
Definition: MessageSender.cpp:3
IGreetSender
Definition: IGreetSender.h:4
IGreetSender::sendGreet
virtual bool sendGreet()=0
send a greet to the output queue
GreetSender::m_bsp
IBSP & m_bsp
Definition: GreetSender.h:19
MessageDispatcher::m_hivemindApiReqHandler
IHiveMindHostApiRequestHandler & m_hivemindApiReqHandler
Definition: MessageDispatcher.h:37
IGreetHandler.h
HiveMindHostApiRequestHandler::handleHiveMindHostApiRequest
bool handleHiveMindHostApiRequest(uint16_t requestId, const MessageDTO &message, const HiveMindHostApiRequestDTO &request)
Definition: HiveMindHostApiRequestHandler.cpp:29
RelativePosition::m_distance
float m_distance
Distance in meters.
Definition: RelativePosition.h:12
MessageHandlerContainer.h