Kevin Schoedel | 3a50501 | 2021-09-08 15:21:38 -0400 | [diff] [blame] | 1 | /* |
| 2 | * |
| 3 | * Copyright (c) 2021 Project CHIP Authors |
| 4 | * |
| 5 | * Licensed under the Apache License, Version 2.0 (the "License"); |
| 6 | * you may not use this file except in compliance with the License. |
| 7 | * You may obtain a copy of the License at |
| 8 | * |
| 9 | * http://www.apache.org/licenses/LICENSE-2.0 |
| 10 | * |
| 11 | * Unless required by applicable law or agreed to in writing, software |
| 12 | * distributed under the License is distributed on an "AS IS" BASIS, |
| 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 14 | * See the License for the specific language governing permissions and |
| 15 | * limitations under the License. |
| 16 | */ |
| 17 | |
| 18 | /** |
| 19 | * @file |
Jean-Francois Penven | b686463 | 2022-04-20 11:43:39 -0400 | [diff] [blame] | 20 | * This file declares an implementation of LayerImplFreeRTOS using LwIP. |
Kevin Schoedel | 3a50501 | 2021-09-08 15:21:38 -0400 | [diff] [blame] | 21 | */ |
| 22 | |
| 23 | #pragma once |
| 24 | |
| 25 | #include <lib/support/ObjectLifeCycle.h> |
| 26 | #include <system/SystemLayer.h> |
Kevin Schoedel | 51e5bfb | 2021-12-07 09:45:23 -0500 | [diff] [blame] | 27 | #include <system/SystemTimer.h> |
Kevin Schoedel | 3a50501 | 2021-09-08 15:21:38 -0400 | [diff] [blame] | 28 | |
| 29 | namespace chip { |
| 30 | namespace System { |
| 31 | |
Jean-Francois Penven | b686463 | 2022-04-20 11:43:39 -0400 | [diff] [blame] | 32 | class LayerImplFreeRTOS : public LayerFreeRTOS |
Kevin Schoedel | 3a50501 | 2021-09-08 15:21:38 -0400 | [diff] [blame] | 33 | { |
| 34 | public: |
Jean-Francois Penven | b686463 | 2022-04-20 11:43:39 -0400 | [diff] [blame] | 35 | LayerImplFreeRTOS(); |
| 36 | ~LayerImplFreeRTOS() { VerifyOrDie(mLayerState.Destroy()); } |
Kevin Schoedel | 3a50501 | 2021-09-08 15:21:38 -0400 | [diff] [blame] | 37 | |
| 38 | // Layer overrides. |
| 39 | CHIP_ERROR Init() override; |
Michael Spang | 6387049 | 2022-06-28 08:41:08 -0400 | [diff] [blame] | 40 | void Shutdown() override; |
Kevin Schoedel | 3a50501 | 2021-09-08 15:21:38 -0400 | [diff] [blame] | 41 | bool IsInitialized() const override { return mLayerState.IsInitialized(); } |
Kevin Schoedel | ea1b443 | 2021-10-21 16:52:54 -0400 | [diff] [blame] | 42 | CHIP_ERROR StartTimer(Clock::Timeout delay, TimerCompleteCallback onComplete, void * appState) override; |
Junior Martinez | 803c5ae | 2023-06-21 13:27:33 -0400 | [diff] [blame] | 43 | CHIP_ERROR ExtendTimerTo(Clock::Timeout delay, TimerCompleteCallback onComplete, void * appState) override; |
| 44 | bool IsTimerActive(TimerCompleteCallback onComplete, void * appState) override; |
lpbeliveau-silabs | 3799c41 | 2024-02-26 10:11:48 -0500 | [diff] [blame] | 45 | Clock::Timeout GetRemainingTime(TimerCompleteCallback onComplete, void * appState) override; |
Kevin Schoedel | 3a50501 | 2021-09-08 15:21:38 -0400 | [diff] [blame] | 46 | void CancelTimer(TimerCompleteCallback onComplete, void * appState) override; |
| 47 | CHIP_ERROR ScheduleWork(TimerCompleteCallback onComplete, void * appState) override; |
| 48 | |
Kevin Schoedel | 3a50501 | 2021-09-08 15:21:38 -0400 | [diff] [blame] | 49 | public: |
| 50 | // Platform implementation. |
Kevin Schoedel | 3a50501 | 2021-09-08 15:21:38 -0400 | [diff] [blame] | 51 | CHIP_ERROR HandlePlatformTimer(void); |
| 52 | |
| 53 | private: |
| 54 | friend class PlatformEventing; |
| 55 | |
Kevin Schoedel | ea1b443 | 2021-10-21 16:52:54 -0400 | [diff] [blame] | 56 | CHIP_ERROR StartPlatformTimer(System::Clock::Timeout aDelay); |
Kevin Schoedel | 3a50501 | 2021-09-08 15:21:38 -0400 | [diff] [blame] | 57 | |
Kevin Schoedel | 51e5bfb | 2021-12-07 09:45:23 -0500 | [diff] [blame] | 58 | TimerPool<TimerList::Node> mTimerPool; |
| 59 | TimerList mTimerList; |
Kevin Schoedel | 3a50501 | 2021-09-08 15:21:38 -0400 | [diff] [blame] | 60 | bool mHandlingTimerComplete; // true while handling any timer completion |
Kevin Schoedel | 3a50501 | 2021-09-08 15:21:38 -0400 | [diff] [blame] | 61 | ObjectLifeCycle mLayerState; |
| 62 | }; |
| 63 | |
Jean-Francois Penven | b686463 | 2022-04-20 11:43:39 -0400 | [diff] [blame] | 64 | using LayerImpl = LayerImplFreeRTOS; |
Kevin Schoedel | 3a50501 | 2021-09-08 15:21:38 -0400 | [diff] [blame] | 65 | |
| 66 | } // namespace System |
| 67 | } // namespace chip |