summaryrefslogtreecommitdiff
path: root/src/memory
diff options
context:
space:
mode:
authorjacqueline <me@jacqueline.id.au>2023-04-03 14:06:30 +1000
committerjacqueline <me@jacqueline.id.au>2023-04-19 10:29:40 +1000
commit3836768bb8b95188e6657ab69027d1d9e4b13a77 (patch)
treee4330202da1375a6f49d959a7b839643adccd3ca /src/memory
parent7c6fd654f50e6665efa4226c6b927f9762734182 (diff)
downloadtangara-fw-3836768bb8b95188e6657ab69027d1d9e4b13a77.tar.gz
new pipeline working(?), but the dac eludes me
Diffstat (limited to 'src/memory')
-rw-r--r--src/memory/include/himem.hpp13
1 files changed, 9 insertions, 4 deletions
diff --git a/src/memory/include/himem.hpp b/src/memory/include/himem.hpp
index f71e912f..517ebfdf 100644
--- a/src/memory/include/himem.hpp
+++ b/src/memory/include/himem.hpp
@@ -57,21 +57,26 @@ class MappableRegion {
}
auto Get() -> cpp::span<std::byte> {
- if (bytes_ != nullptr) {
+ if (bytes_ == nullptr) {
return {};
}
return {bytes_, size};
}
auto Map(const HimemAlloc<size>& alloc) -> cpp::span<std::byte> {
- if (bytes_ != nullptr) {
- ESP_ERROR_CHECK(esp_himem_unmap(range_handle, bytes_, size));
- }
+ assert(bytes_ == nullptr);
ESP_ERROR_CHECK(esp_himem_map(alloc.handle, range_handle, 0, 0, size, 0,
reinterpret_cast<void**>(&bytes_)));
return Get();
}
+ auto Unmap() -> void {
+ if (bytes_ != nullptr) {
+ ESP_ERROR_CHECK(esp_himem_unmap(range_handle, bytes_, size));
+ bytes_ = nullptr;
+ }
+ }
+
// Not copyable or movable.
MappableRegion(const MappableRegion&) = delete;
MappableRegion& operator=(const MappableRegion&) = delete;