-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- single_level.cpp successfully goes from the throw site to the catch block.
- Loading branch information
Showing
17 changed files
with
429 additions
and
229 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
# Copyright 2024 Khalil Estell | ||
# | ||
# 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 | ||
# | ||
# http://www.apache.org/licenses/LICENSE-2.0 | ||
# | ||
# 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. | ||
|
||
cmake_minimum_required(VERSION 3.15) | ||
|
||
project(demos LANGUAGES CXX) | ||
|
||
libhal_build_demos( | ||
DEMOS | ||
single_level | ||
|
||
PACKAGES | ||
libhal-exceptions | ||
|
||
LINK_LIBRARIES | ||
libhal::exceptions | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
// Copyright 2024 Khalil Estell | ||
// | ||
// 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 | ||
// | ||
// http://www.apache.org/licenses/LICENSE-2.0 | ||
// | ||
// 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. | ||
|
||
#include "../resource_list.hpp" | ||
|
||
int volatile value = 5; | ||
|
||
resource_list* resources; | ||
|
||
struct error | ||
{ | ||
int data = 0; | ||
}; | ||
|
||
std::uint64_t start = 0; | ||
std::uint64_t end = 0; | ||
|
||
void foo() | ||
{ | ||
if (value) { | ||
start = resources->clock->uptime(); | ||
throw error{ .data = value }; | ||
} | ||
} | ||
|
||
void application(resource_list& p_resources) | ||
{ | ||
resources = &p_resources; | ||
try { | ||
foo(); | ||
} catch (error const& p_error) { | ||
end = resources->clock->uptime(); | ||
while (true) { | ||
continue; | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
# Copyright 2024 Khalil Estell | ||
# | ||
# 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 | ||
# | ||
# http://www.apache.org/licenses/LICENSE-2.0 | ||
# | ||
# 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. | ||
|
||
from conan import ConanFile | ||
|
||
|
||
class demos(ConanFile): | ||
python_requires = "libhal-bootstrap/[^2.0.0]" | ||
python_requires_extend = "libhal-bootstrap.demo" | ||
|
||
def requirements(self): | ||
bootstrap = self.python_requires["libhal-bootstrap"] | ||
bootstrap.module.add_demo_requirements(self) | ||
self.requires("libhal-exceptions/[latest || ^1.0.0]") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
#include <libhal-exceptions/control.hpp> | ||
|
||
#include "resource_list.hpp" | ||
|
||
void terminate_handler() | ||
{ | ||
while (true) { | ||
continue; | ||
} | ||
} | ||
|
||
int main() | ||
{ | ||
hal::set_terminate(terminate_handler); | ||
auto resources = initialize_platform(); | ||
application(resources); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
#include "lpc4078.cpp" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
// Copyright 2024 Khalil Estell | ||
// | ||
// 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 | ||
// | ||
// http://www.apache.org/licenses/LICENSE-2.0 | ||
// | ||
// 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. | ||
|
||
#include <libhal-armcortex/dwt_counter.hpp> | ||
#include <libhal-stm32f1/clock.hpp> | ||
|
||
#include "../resource_list.hpp" | ||
|
||
resource_list initialize_platform() | ||
{ | ||
using namespace hal::literals; | ||
hal::stm32f1::maximum_speed_using_internal_oscillator(); | ||
|
||
auto cpu_frequency = hal::stm32f1::frequency(hal::stm32f1::peripheral::cpu); | ||
static hal::cortex_m::dwt_counter dwt_steady_clock(cpu_frequency); | ||
|
||
return { | ||
.clock = &dwt_steady_clock, | ||
}; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
#pragma once | ||
|
||
#include <libhal/steady_clock.hpp> | ||
|
||
struct resource_list | ||
{ | ||
hal::steady_clock* clock; | ||
}; | ||
|
||
resource_list initialize_platform(); | ||
void application(resource_list& p_resource_list); |
Oops, something went wrong.