blob: 6bd34e37ed4ad9d104d741439b0484f7fcb18737 [file] [log] [blame]
// Copyright 2021 The Pigweed Authors
// Licensed under the Apache License, Version 2.0 (the "License"); you may not
// use this file except in compliance with the License. You may obtain a copy of
// the License at
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
// WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
// License for the specific language governing permissions and limitations under
// the License.
// Configuration macros for the tokenizer module.
#pragma once
#include "FreeRTOS.h"
// Just like FreeRTOS Stream and Message Buffers, by default the optimized
// pw::sync::ThreadNotification uses the task notification at array index 0.
// This optimized backend is compatible with sharing the notification with
// Stream and Message Buffers and any other users which ONLY notify the task
// while the task is blocked and the task consumes the notification state
// before returning.
// The task's TCB uses a ucNotifyState which captures notification state even
// when the task is not waiting (taskNOT_WAITING_NOTIFICATION vs
// task_NOTIFICATION_RECEIVED). This notification state is used to determine
// whether the next task notification wait call should block, irrespective of
// the notification value. This means that one must ensure not just that
// the bits in the ulNotifiedValue are mutually exclusive, but also that the
// notification state is mutually exclusive!
namespace pw::sync::freertos::config {
inline constexpr UBaseType_t kThreadNotificationIndex =
// Ensure the index fits within the FreeRTOS configuration of the task
// notification array.
static_assert(kThreadNotificationIndex < configTASK_NOTIFICATION_ARRAY_ENTRIES);
#else // !defined(configTASK_NOTIFICATION_ARRAY_ENTRIES)
// This version of FreeRTOS does not support multiple task notifications, ensure
// the index is the default of 0.
static_assert(kThreadNotificationIndex == 0);
} // namespace pw::sync::freertos::config