// C++/WinRT v2.0.250303.1 // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT License. #pragma once #ifndef WINRT_Windows_Devices_Spi_Provider_H #define WINRT_Windows_Devices_Spi_Provider_H #include "winrt/base.h" static_assert(winrt::check_version(CPPWINRT_VERSION, "2.0.250303.1"), "Mismatched C++/WinRT headers."); #define CPPWINRT_VERSION "2.0.250303.1" #include "winrt/Windows.Devices.Spi.h" #include "winrt/impl/Windows.Foundation.2.h" #include "winrt/impl/Windows.Foundation.Collections.2.h" #include "winrt/impl/Windows.Devices.Spi.Provider.2.h" namespace winrt::impl { template auto consume_Windows_Devices_Spi_Provider_IProviderSpiConnectionSettings::ChipSelectLine() const { int32_t value{}; if constexpr (!std::is_same_v) { winrt::hresult _winrt_cast_result_code; auto const _winrt_casted_result = impl::try_as_with_reason(static_cast(this), _winrt_cast_result_code); check_hresult(_winrt_cast_result_code); auto const _winrt_abi_type = *(abi_t**)&_winrt_casted_result; check_hresult(_winrt_abi_type->get_ChipSelectLine(&value)); } else { auto const _winrt_abi_type = *(abi_t**)this; check_hresult(_winrt_abi_type->get_ChipSelectLine(&value)); } return value; } template auto consume_Windows_Devices_Spi_Provider_IProviderSpiConnectionSettings::ChipSelectLine(int32_t value) const { if constexpr (!std::is_same_v) { winrt::hresult _winrt_cast_result_code; auto const _winrt_casted_result = impl::try_as_with_reason(static_cast(this), _winrt_cast_result_code); check_hresult(_winrt_cast_result_code); auto const _winrt_abi_type = *(abi_t**)&_winrt_casted_result; check_hresult(_winrt_abi_type->put_ChipSelectLine(value)); } else { auto const _winrt_abi_type = *(abi_t**)this; check_hresult(_winrt_abi_type->put_ChipSelectLine(value)); } } template auto consume_Windows_Devices_Spi_Provider_IProviderSpiConnectionSettings::Mode() const { winrt::Windows::Devices::Spi::Provider::ProviderSpiMode value{}; if constexpr (!std::is_same_v) { winrt::hresult _winrt_cast_result_code; auto const _winrt_casted_result = impl::try_as_with_reason(static_cast(this), _winrt_cast_result_code); check_hresult(_winrt_cast_result_code); auto const _winrt_abi_type = *(abi_t**)&_winrt_casted_result; check_hresult(_winrt_abi_type->get_Mode(reinterpret_cast(&value))); } else { auto const _winrt_abi_type = *(abi_t**)this; check_hresult(_winrt_abi_type->get_Mode(reinterpret_cast(&value))); } return value; } template auto consume_Windows_Devices_Spi_Provider_IProviderSpiConnectionSettings::Mode(winrt::Windows::Devices::Spi::Provider::ProviderSpiMode const& value) const { if constexpr (!std::is_same_v) { winrt::hresult _winrt_cast_result_code; auto const _winrt_casted_result = impl::try_as_with_reason(static_cast(this), _winrt_cast_result_code); check_hresult(_winrt_cast_result_code); auto const _winrt_abi_type = *(abi_t**)&_winrt_casted_result; check_hresult(_winrt_abi_type->put_Mode(static_cast(value))); } else { auto const _winrt_abi_type = *(abi_t**)this; check_hresult(_winrt_abi_type->put_Mode(static_cast(value))); } } template auto consume_Windows_Devices_Spi_Provider_IProviderSpiConnectionSettings::DataBitLength() const { int32_t value{}; if constexpr (!std::is_same_v) { winrt::hresult _winrt_cast_result_code; auto const _winrt_casted_result = impl::try_as_with_reason(static_cast(this), _winrt_cast_result_code); check_hresult(_winrt_cast_result_code); auto const _winrt_abi_type = *(abi_t**)&_winrt_casted_result; check_hresult(_winrt_abi_type->get_DataBitLength(&value)); } else { auto const _winrt_abi_type = *(abi_t**)this; check_hresult(_winrt_abi_type->get_DataBitLength(&value)); } return value; } template auto consume_Windows_Devices_Spi_Provider_IProviderSpiConnectionSettings::DataBitLength(int32_t value) const { if constexpr (!std::is_same_v) { winrt::hresult _winrt_cast_result_code; auto const _winrt_casted_result = impl::try_as_with_reason(static_cast(this), _winrt_cast_result_code); check_hresult(_winrt_cast_result_code); auto const _winrt_abi_type = *(abi_t**)&_winrt_casted_result; check_hresult(_winrt_abi_type->put_DataBitLength(value)); } else { auto const _winrt_abi_type = *(abi_t**)this; check_hresult(_winrt_abi_type->put_DataBitLength(value)); } } template auto consume_Windows_Devices_Spi_Provider_IProviderSpiConnectionSettings::ClockFrequency() const { int32_t value{}; if constexpr (!std::is_same_v) { winrt::hresult _winrt_cast_result_code; auto const _winrt_casted_result = impl::try_as_with_reason(static_cast(this), _winrt_cast_result_code); check_hresult(_winrt_cast_result_code); auto const _winrt_abi_type = *(abi_t**)&_winrt_casted_result; check_hresult(_winrt_abi_type->get_ClockFrequency(&value)); } else { auto const _winrt_abi_type = *(abi_t**)this; check_hresult(_winrt_abi_type->get_ClockFrequency(&value)); } return value; } template auto consume_Windows_Devices_Spi_Provider_IProviderSpiConnectionSettings::ClockFrequency(int32_t value) const { if constexpr (!std::is_same_v) { winrt::hresult _winrt_cast_result_code; auto const _winrt_casted_result = impl::try_as_with_reason(static_cast(this), _winrt_cast_result_code); check_hresult(_winrt_cast_result_code); auto const _winrt_abi_type = *(abi_t**)&_winrt_casted_result; check_hresult(_winrt_abi_type->put_ClockFrequency(value)); } else { auto const _winrt_abi_type = *(abi_t**)this; check_hresult(_winrt_abi_type->put_ClockFrequency(value)); } } template auto consume_Windows_Devices_Spi_Provider_IProviderSpiConnectionSettings::SharingMode() const { winrt::Windows::Devices::Spi::Provider::ProviderSpiSharingMode value{}; if constexpr (!std::is_same_v) { winrt::hresult _winrt_cast_result_code; auto const _winrt_casted_result = impl::try_as_with_reason(static_cast(this), _winrt_cast_result_code); check_hresult(_winrt_cast_result_code); auto const _winrt_abi_type = *(abi_t**)&_winrt_casted_result; check_hresult(_winrt_abi_type->get_SharingMode(reinterpret_cast(&value))); } else { auto const _winrt_abi_type = *(abi_t**)this; check_hresult(_winrt_abi_type->get_SharingMode(reinterpret_cast(&value))); } return value; } template auto consume_Windows_Devices_Spi_Provider_IProviderSpiConnectionSettings::SharingMode(winrt::Windows::Devices::Spi::Provider::ProviderSpiSharingMode const& value) const { if constexpr (!std::is_same_v) { winrt::hresult _winrt_cast_result_code; auto const _winrt_casted_result = impl::try_as_with_reason(static_cast(this), _winrt_cast_result_code); check_hresult(_winrt_cast_result_code); auto const _winrt_abi_type = *(abi_t**)&_winrt_casted_result; check_hresult(_winrt_abi_type->put_SharingMode(static_cast(value))); } else { auto const _winrt_abi_type = *(abi_t**)this; check_hresult(_winrt_abi_type->put_SharingMode(static_cast(value))); } } template auto consume_Windows_Devices_Spi_Provider_IProviderSpiConnectionSettingsFactory::Create(int32_t chipSelectLine) const { void* value{}; if constexpr (!std::is_same_v) { winrt::hresult _winrt_cast_result_code; auto const _winrt_casted_result = impl::try_as_with_reason(static_cast(this), _winrt_cast_result_code); check_hresult(_winrt_cast_result_code); auto const _winrt_abi_type = *(abi_t**)&_winrt_casted_result; check_hresult(_winrt_abi_type->Create(chipSelectLine, &value)); } else { auto const _winrt_abi_type = *(abi_t**)this; check_hresult(_winrt_abi_type->Create(chipSelectLine, &value)); } return winrt::Windows::Devices::Spi::Provider::ProviderSpiConnectionSettings{ value, take_ownership_from_abi }; } template auto consume_Windows_Devices_Spi_Provider_ISpiControllerProvider::GetDeviceProvider(winrt::Windows::Devices::Spi::Provider::ProviderSpiConnectionSettings const& settings) const { void* result{}; if constexpr (!std::is_same_v) { winrt::hresult _winrt_cast_result_code; auto const _winrt_casted_result = impl::try_as_with_reason(static_cast(this), _winrt_cast_result_code); check_hresult(_winrt_cast_result_code); auto const _winrt_abi_type = *(abi_t**)&_winrt_casted_result; check_hresult(_winrt_abi_type->GetDeviceProvider(*(void**)(&settings), &result)); } else { auto const _winrt_abi_type = *(abi_t**)this; check_hresult(_winrt_abi_type->GetDeviceProvider(*(void**)(&settings), &result)); } return winrt::Windows::Devices::Spi::Provider::ISpiDeviceProvider{ result, take_ownership_from_abi }; } template auto consume_Windows_Devices_Spi_Provider_ISpiDeviceProvider::DeviceId() const { void* value{}; if constexpr (!std::is_same_v) { winrt::hresult _winrt_cast_result_code; auto const _winrt_casted_result = impl::try_as_with_reason(static_cast(this), _winrt_cast_result_code); check_hresult(_winrt_cast_result_code); auto const _winrt_abi_type = *(abi_t**)&_winrt_casted_result; check_hresult(_winrt_abi_type->get_DeviceId(&value)); } else { auto const _winrt_abi_type = *(abi_t**)this; check_hresult(_winrt_abi_type->get_DeviceId(&value)); } return hstring{ value, take_ownership_from_abi }; } template auto consume_Windows_Devices_Spi_Provider_ISpiDeviceProvider::ConnectionSettings() const { void* value{}; if constexpr (!std::is_same_v) { winrt::hresult _winrt_cast_result_code; auto const _winrt_casted_result = impl::try_as_with_reason(static_cast(this), _winrt_cast_result_code); check_hresult(_winrt_cast_result_code); auto const _winrt_abi_type = *(abi_t**)&_winrt_casted_result; check_hresult(_winrt_abi_type->get_ConnectionSettings(&value)); } else { auto const _winrt_abi_type = *(abi_t**)this; check_hresult(_winrt_abi_type->get_ConnectionSettings(&value)); } return winrt::Windows::Devices::Spi::Provider::ProviderSpiConnectionSettings{ value, take_ownership_from_abi }; } template auto consume_Windows_Devices_Spi_Provider_ISpiDeviceProvider::Write(array_view buffer) const { if constexpr (!std::is_same_v) { winrt::hresult _winrt_cast_result_code; auto const _winrt_casted_result = impl::try_as_with_reason(static_cast(this), _winrt_cast_result_code); check_hresult(_winrt_cast_result_code); auto const _winrt_abi_type = *(abi_t**)&_winrt_casted_result; check_hresult(_winrt_abi_type->Write(buffer.size(), get_abi(buffer))); } else { auto const _winrt_abi_type = *(abi_t**)this; check_hresult(_winrt_abi_type->Write(buffer.size(), get_abi(buffer))); } } template auto consume_Windows_Devices_Spi_Provider_ISpiDeviceProvider::Read(array_view buffer) const { if constexpr (!std::is_same_v) { winrt::hresult _winrt_cast_result_code; auto const _winrt_casted_result = impl::try_as_with_reason(static_cast(this), _winrt_cast_result_code); check_hresult(_winrt_cast_result_code); auto const _winrt_abi_type = *(abi_t**)&_winrt_casted_result; check_hresult(_winrt_abi_type->Read(buffer.size(), put_abi(buffer))); } else { auto const _winrt_abi_type = *(abi_t**)this; check_hresult(_winrt_abi_type->Read(buffer.size(), put_abi(buffer))); } } template auto consume_Windows_Devices_Spi_Provider_ISpiDeviceProvider::TransferSequential(array_view writeBuffer, array_view readBuffer) const { if constexpr (!std::is_same_v) { winrt::hresult _winrt_cast_result_code; auto const _winrt_casted_result = impl::try_as_with_reason(static_cast(this), _winrt_cast_result_code); check_hresult(_winrt_cast_result_code); auto const _winrt_abi_type = *(abi_t**)&_winrt_casted_result; check_hresult(_winrt_abi_type->TransferSequential(writeBuffer.size(), get_abi(writeBuffer), readBuffer.size(), put_abi(readBuffer))); } else { auto const _winrt_abi_type = *(abi_t**)this; check_hresult(_winrt_abi_type->TransferSequential(writeBuffer.size(), get_abi(writeBuffer), readBuffer.size(), put_abi(readBuffer))); } } template auto consume_Windows_Devices_Spi_Provider_ISpiDeviceProvider::TransferFullDuplex(array_view writeBuffer, array_view readBuffer) const { if constexpr (!std::is_same_v) { winrt::hresult _winrt_cast_result_code; auto const _winrt_casted_result = impl::try_as_with_reason(static_cast(this), _winrt_cast_result_code); check_hresult(_winrt_cast_result_code); auto const _winrt_abi_type = *(abi_t**)&_winrt_casted_result; check_hresult(_winrt_abi_type->TransferFullDuplex(writeBuffer.size(), get_abi(writeBuffer), readBuffer.size(), put_abi(readBuffer))); } else { auto const _winrt_abi_type = *(abi_t**)this; check_hresult(_winrt_abi_type->TransferFullDuplex(writeBuffer.size(), get_abi(writeBuffer), readBuffer.size(), put_abi(readBuffer))); } } template auto consume_Windows_Devices_Spi_Provider_ISpiProvider::GetControllersAsync() const { void* result{}; if constexpr (!std::is_same_v) { winrt::hresult _winrt_cast_result_code; auto const _winrt_casted_result = impl::try_as_with_reason(static_cast(this), _winrt_cast_result_code); check_hresult(_winrt_cast_result_code); auto const _winrt_abi_type = *(abi_t**)&_winrt_casted_result; check_hresult(_winrt_abi_type->GetControllersAsync(&result)); } else { auto const _winrt_abi_type = *(abi_t**)this; check_hresult(_winrt_abi_type->GetControllersAsync(&result)); } return winrt::Windows::Foundation::IAsyncOperation>{ result, take_ownership_from_abi }; } #ifndef WINRT_LEAN_AND_MEAN template struct produce : produce_base { int32_t __stdcall get_ChipSelectLine(int32_t* value) noexcept final try { typename D::abi_guard guard(this->shim()); *value = detach_from(this->shim().ChipSelectLine()); return 0; } catch (...) { return to_hresult(); } int32_t __stdcall put_ChipSelectLine(int32_t value) noexcept final try { typename D::abi_guard guard(this->shim()); this->shim().ChipSelectLine(value); return 0; } catch (...) { return to_hresult(); } int32_t __stdcall get_Mode(int32_t* value) noexcept final try { typename D::abi_guard guard(this->shim()); *value = detach_from(this->shim().Mode()); return 0; } catch (...) { return to_hresult(); } int32_t __stdcall put_Mode(int32_t value) noexcept final try { typename D::abi_guard guard(this->shim()); this->shim().Mode(*reinterpret_cast(&value)); return 0; } catch (...) { return to_hresult(); } int32_t __stdcall get_DataBitLength(int32_t* value) noexcept final try { typename D::abi_guard guard(this->shim()); *value = detach_from(this->shim().DataBitLength()); return 0; } catch (...) { return to_hresult(); } int32_t __stdcall put_DataBitLength(int32_t value) noexcept final try { typename D::abi_guard guard(this->shim()); this->shim().DataBitLength(value); return 0; } catch (...) { return to_hresult(); } int32_t __stdcall get_ClockFrequency(int32_t* value) noexcept final try { typename D::abi_guard guard(this->shim()); *value = detach_from(this->shim().ClockFrequency()); return 0; } catch (...) { return to_hresult(); } int32_t __stdcall put_ClockFrequency(int32_t value) noexcept final try { typename D::abi_guard guard(this->shim()); this->shim().ClockFrequency(value); return 0; } catch (...) { return to_hresult(); } int32_t __stdcall get_SharingMode(int32_t* value) noexcept final try { typename D::abi_guard guard(this->shim()); *value = detach_from(this->shim().SharingMode()); return 0; } catch (...) { return to_hresult(); } int32_t __stdcall put_SharingMode(int32_t value) noexcept final try { typename D::abi_guard guard(this->shim()); this->shim().SharingMode(*reinterpret_cast(&value)); return 0; } catch (...) { return to_hresult(); } }; #endif #ifndef WINRT_LEAN_AND_MEAN template struct produce : produce_base { int32_t __stdcall Create(int32_t chipSelectLine, void** value) noexcept final try { clear_abi(value); typename D::abi_guard guard(this->shim()); *value = detach_from(this->shim().Create(chipSelectLine)); return 0; } catch (...) { return to_hresult(); } }; #endif template struct produce : produce_base { int32_t __stdcall GetDeviceProvider(void* settings, void** result) noexcept final try { clear_abi(result); typename D::abi_guard guard(this->shim()); *result = detach_from(this->shim().GetDeviceProvider(*reinterpret_cast(&settings))); return 0; } catch (...) { return to_hresult(); } }; template struct produce : produce_base { int32_t __stdcall get_DeviceId(void** value) noexcept final try { clear_abi(value); typename D::abi_guard guard(this->shim()); *value = detach_from(this->shim().DeviceId()); return 0; } catch (...) { return to_hresult(); } int32_t __stdcall get_ConnectionSettings(void** value) noexcept final try { clear_abi(value); typename D::abi_guard guard(this->shim()); *value = detach_from(this->shim().ConnectionSettings()); return 0; } catch (...) { return to_hresult(); } int32_t __stdcall Write(uint32_t __bufferSize, uint8_t* buffer) noexcept final try { typename D::abi_guard guard(this->shim()); this->shim().Write(array_view(reinterpret_cast(buffer), reinterpret_cast(buffer) + __bufferSize)); return 0; } catch (...) { return to_hresult(); } int32_t __stdcall Read(uint32_t __bufferSize, uint8_t* buffer) noexcept final try { typename D::abi_guard guard(this->shim()); this->shim().Read(array_view(reinterpret_cast(buffer), reinterpret_cast(buffer) + __bufferSize)); return 0; } catch (...) { return to_hresult(); } int32_t __stdcall TransferSequential(uint32_t __writeBufferSize, uint8_t* writeBuffer, uint32_t __readBufferSize, uint8_t* readBuffer) noexcept final try { typename D::abi_guard guard(this->shim()); this->shim().TransferSequential(array_view(reinterpret_cast(writeBuffer), reinterpret_cast(writeBuffer) + __writeBufferSize), array_view(reinterpret_cast(readBuffer), reinterpret_cast(readBuffer) + __readBufferSize)); return 0; } catch (...) { return to_hresult(); } int32_t __stdcall TransferFullDuplex(uint32_t __writeBufferSize, uint8_t* writeBuffer, uint32_t __readBufferSize, uint8_t* readBuffer) noexcept final try { typename D::abi_guard guard(this->shim()); this->shim().TransferFullDuplex(array_view(reinterpret_cast(writeBuffer), reinterpret_cast(writeBuffer) + __writeBufferSize), array_view(reinterpret_cast(readBuffer), reinterpret_cast(readBuffer) + __readBufferSize)); return 0; } catch (...) { return to_hresult(); } }; template struct produce : produce_base { int32_t __stdcall GetControllersAsync(void** result) noexcept final try { clear_abi(result); typename D::abi_guard guard(this->shim()); *result = detach_from>>(this->shim().GetControllersAsync()); return 0; } catch (...) { return to_hresult(); } }; } WINRT_EXPORT namespace winrt::Windows::Devices::Spi::Provider { inline ProviderSpiConnectionSettings::ProviderSpiConnectionSettings(int32_t chipSelectLine) : ProviderSpiConnectionSettings(impl::call_factory([&](IProviderSpiConnectionSettingsFactory const& f) { return f.Create(chipSelectLine); })) { } } namespace std { #ifndef WINRT_LEAN_AND_MEAN template<> struct hash : winrt::impl::hash_base {}; template<> struct hash : winrt::impl::hash_base {}; template<> struct hash : winrt::impl::hash_base {}; template<> struct hash : winrt::impl::hash_base {}; template<> struct hash : winrt::impl::hash_base {}; template<> struct hash : winrt::impl::hash_base {}; #endif #ifdef __cpp_lib_format #endif } #endif