From ffec74c6de2f9ea03102a8768f5cb2d4f98f8049 Mon Sep 17 00:00:00 2001 From: Suikan <26223147+suikan4github@users.noreply.github.com> Date: Mon, 25 Nov 2024 15:10:31 +0900 Subject: [PATCH] Issue #25 : Add wider API support of RasPi Pico SDK hardware_pwm. --- src/sdk/mocksdkwrapper.hpp | 57 + src/sdk/pico_api_alternate_defs.hpp | 4 + src/sdk/pico_sdk_apistub.cpp | 1030 +++++++++++++++++ src/sdk/pico_sdk_headers.h | 37 +- src/sdk/scripts/api_dirs.txt | 1 + .../blocks/pico_api_alternate_defs.hpp | 4 + src/sdk/sdkwrapper.cpp | 253 ++++ src/sdk/sdkwrapper.hpp | 53 + test/test_sdkwrapper.cpp | 48 +- test/todo/test_sdkwrapper.md | 8 + 10 files changed, 1477 insertions(+), 18 deletions(-) diff --git a/src/sdk/mocksdkwrapper.hpp b/src/sdk/mocksdkwrapper.hpp index 4ee8ded..0a84060 100644 --- a/src/sdk/mocksdkwrapper.hpp +++ b/src/sdk/mocksdkwrapper.hpp @@ -475,6 +475,63 @@ class MockSdkWrapper : public SdkWrapper { MOCK_METHOD1(powman_timer_set_ms, void(uint64_t time_ms)); MOCK_METHOD0(powman_timer_start, void()); MOCK_METHOD0(powman_timer_stop, void()); + MOCK_METHOD1(pwm_advance_count, void(uint slice_num)); + MOCK_METHOD1(pwm_clear_irq, void(uint slice_num)); + MOCK_METHOD2(pwm_config_set_clkdiv, void(pwm_config* c, float div)); + MOCK_METHOD2(pwm_config_set_clkdiv_int, void(pwm_config* c, uint div)); + MOCK_METHOD3(pwm_config_set_clkdiv_int_frac, + void(pwm_config* c, uint8_t integer, uint8_t fract)); + MOCK_METHOD2(pwm_config_set_clkdiv_mode, + void(pwm_config* c, enum pwm_clkdiv_mode mode)); + MOCK_METHOD3(pwm_config_set_output_polarity, + void(pwm_config* c, bool a, bool b)); + MOCK_METHOD2(pwm_config_set_phase_correct, + void(pwm_config* c, bool phase_correct)); + MOCK_METHOD2(pwm_config_set_wrap, void(pwm_config* c, uint16_t wrap)); + MOCK_METHOD1(pwm_force_irq, void(uint slice_num)); + MOCK_METHOD1(pwm_force_irq0, void(uint slice_num)); + MOCK_METHOD1(pwm_force_irq1, void(uint slice_num)); + MOCK_METHOD1(pwm_get_counter, uint16_t(uint slice_num)); + MOCK_METHOD0(pwm_get_default_config, pwm_config()); + MOCK_METHOD1(pwm_get_dreq, uint(uint slice_num)); + MOCK_METHOD0(pwm_get_irq0_status_mask, uint32_t()); + MOCK_METHOD0(pwm_get_irq1_status_mask, uint32_t()); + MOCK_METHOD0(pwm_get_irq_status_mask, uint32_t()); + MOCK_METHOD1(pwm_gpio_to_channel, uint(uint gpio)); + MOCK_METHOD1(pwm_gpio_to_slice_num, uint(uint gpio)); + MOCK_METHOD3(pwm_init, void(uint slice_num, pwm_config* c, bool start)); + MOCK_METHOD2(pwm_irqn_force, void(uint irq_index, uint slice_num)); + MOCK_METHOD1(pwm_irqn_get_status_mask, uint32_t(uint irq_index)); + MOCK_METHOD3(pwm_irqn_set_slice_enabled, + void(uint irq_index, uint slice_num, bool enabled)); + MOCK_METHOD3(pwm_irqn_set_slice_mask_enabled, + void(uint irq_index, uint slice_mask, bool enabled)); + MOCK_METHOD1(pwm_retard_count, void(uint slice_num)); + MOCK_METHOD3(pwm_set_both_levels, + void(uint slice_num, uint16_t level_a, uint16_t level_b)); + MOCK_METHOD3(pwm_set_chan_level, + void(uint slice_num, uint chan, uint16_t level)); + MOCK_METHOD2(pwm_set_clkdiv, void(uint slice_num, float divider)); + MOCK_METHOD3(pwm_set_clkdiv_int_frac, + void(uint slice_num, uint8_t integer, uint8_t fract)); + MOCK_METHOD2(pwm_set_clkdiv_mode, + void(uint slice_num, enum pwm_clkdiv_mode mode)); + MOCK_METHOD2(pwm_set_counter, void(uint slice_num, uint16_t c)); + MOCK_METHOD2(pwm_set_enabled, void(uint slice_num, bool enabled)); + MOCK_METHOD2(pwm_set_gpio_level, void(uint gpio, uint16_t level)); + MOCK_METHOD2(pwm_set_irq0_enabled, void(uint slice_num, bool enabled)); + MOCK_METHOD2(pwm_set_irq0_mask_enabled, + void(uint32_t slice_mask, bool enabled)); + MOCK_METHOD2(pwm_set_irq1_enabled, void(uint slice_num, bool enabled)); + MOCK_METHOD2(pwm_set_irq1_mask_enabled, + void(uint32_t slice_mask, bool enabled)); + MOCK_METHOD2(pwm_set_irq_enabled, void(uint slice_num, bool enabled)); + MOCK_METHOD2(pwm_set_irq_mask_enabled, + void(uint32_t slice_mask, bool enabled)); + MOCK_METHOD1(pwm_set_mask_enabled, void(uint32_t mask)); + MOCK_METHOD3(pwm_set_output_polarity, void(uint slice_num, bool a, bool b)); + MOCK_METHOD2(pwm_set_phase_correct, void(uint slice_num, bool phase_correct)); + MOCK_METHOD2(pwm_set_wrap, void(uint slice_num, uint16_t wrap)); MOCK_METHOD2(gpio_acknowledge_irq, void(uint gpio, uint32_t event_mask)); MOCK_METHOD2(gpio_add_raw_irq_handler, void(uint gpio, irq_handler_t handler)); diff --git a/src/sdk/pico_api_alternate_defs.hpp b/src/sdk/pico_api_alternate_defs.hpp index 9f6ce0b..791d994 100644 --- a/src/sdk/pico_api_alternate_defs.hpp +++ b/src/sdk/pico_api_alternate_defs.hpp @@ -34,7 +34,11 @@ enum dma_channel_transfer_size { k, l }; enum riscv_vector_num { m, n }; /// @brief Alternate definition for Google Test build. enum powman_power_domains { o, p }; +/// @brief Alternate definition for Google Test build. +enum pwm_clkdiv_mode { q, r }; +//// @brief Alternate definition for Google Test build. +typedef int pwm_config; //// @brief Alternate definition for Google Test build. typedef int powman_power_state; //// @brief Alternate definition for Google Test build. diff --git a/src/sdk/pico_sdk_apistub.cpp b/src/sdk/pico_sdk_apistub.cpp index e726b93..170a6d4 100644 --- a/src/sdk/pico_sdk_apistub.cpp +++ b/src/sdk/pico_sdk_apistub.cpp @@ -7754,6 +7754,1036 @@ extern "C" void _weak_powman_timer_stop(void) #endif // _MSC_VER // -------------------------------------------------- #if defined(__GNUC__) || defined(__clang__) // Compiler detection +extern "C" void pwm_advance_count(uint slice_num); +__attribute__((weak)) void pwm_advance_count(uint slice_num) +#elif defined(_MSC_VER) // Microsoft Visual C +extern "C" void _weak_pwm_advance_count(uint slice_num) +#else // Other compilers are not supported +#error "Unknown compiler." +#endif // Compiler detection +{ + assert(false && + "Error : The hardware_pwm library is missing in the link phase."); +} +#if defined(_MSC_VER) // weak binding in MSVC must be after definition +#if defined(_M_IX86) // for x86 +#pragma comment(linker, \ + "/alternatename:_pwm_advance_count=__weak_pwm_advance_count") +#elif defined(_M_AMD64) // for AMD64 +#pragma comment(linker, \ + "/alternatename:pwm_advance_count=_weak_pwm_advance_count") +#endif // x86 or amd64 +#endif // _MSC_VER +// -------------------------------------------------- +#if defined(__GNUC__) || defined(__clang__) // Compiler detection +extern "C" void pwm_clear_irq(uint slice_num); +__attribute__((weak)) void pwm_clear_irq(uint slice_num) +#elif defined(_MSC_VER) // Microsoft Visual C +extern "C" void _weak_pwm_clear_irq(uint slice_num) +#else // Other compilers are not supported +#error "Unknown compiler." +#endif // Compiler detection +{ + assert(false && + "Error : The hardware_pwm library is missing in the link phase."); +} +#if defined(_MSC_VER) // weak binding in MSVC must be after definition +#if defined(_M_IX86) // for x86 +#pragma comment(linker, "/alternatename:_pwm_clear_irq=__weak_pwm_clear_irq") +#elif defined(_M_AMD64) // for AMD64 +#pragma comment(linker, "/alternatename:pwm_clear_irq=_weak_pwm_clear_irq") +#endif // x86 or amd64 +#endif // _MSC_VER +// -------------------------------------------------- +#if defined(__GNUC__) || defined(__clang__) // Compiler detection +extern "C" void pwm_config_set_clkdiv(pwm_config* c, float div); +__attribute__((weak)) void pwm_config_set_clkdiv(pwm_config* c, float div) +#elif defined(_MSC_VER) // Microsoft Visual C +extern "C" void _weak_pwm_config_set_clkdiv(pwm_config* c, float div) +#else // Other compilers are not supported +#error "Unknown compiler." +#endif // Compiler detection +{ + assert(false && + "Error : The hardware_pwm library is missing in the link phase."); +} +#if defined(_MSC_VER) // weak binding in MSVC must be after definition +#if defined(_M_IX86) // for x86 +#pragma comment( \ + linker, \ + "/alternatename:_pwm_config_set_clkdiv=__weak_pwm_config_set_clkdiv") +#elif defined(_M_AMD64) // for AMD64 +#pragma comment( \ + linker, \ + "/alternatename:pwm_config_set_clkdiv=_weak_pwm_config_set_clkdiv") +#endif // x86 or amd64 +#endif // _MSC_VER +// -------------------------------------------------- +#if defined(__GNUC__) || defined(__clang__) // Compiler detection +extern "C" void pwm_config_set_clkdiv_int(pwm_config* c, uint div); +__attribute__((weak)) void pwm_config_set_clkdiv_int(pwm_config* c, uint div) +#elif defined(_MSC_VER) // Microsoft Visual C +extern "C" void _weak_pwm_config_set_clkdiv_int(pwm_config* c, uint div) +#else // Other compilers are not supported +#error "Unknown compiler." +#endif // Compiler detection +{ + assert(false && + "Error : The hardware_pwm library is missing in the link phase."); +} +#if defined(_MSC_VER) // weak binding in MSVC must be after definition +#if defined(_M_IX86) // for x86 +#pragma comment( \ + linker, \ + "/alternatename:_pwm_config_set_clkdiv_int=__weak_pwm_config_set_clkdiv_int") +#elif defined(_M_AMD64) // for AMD64 +#pragma comment( \ + linker, \ + "/alternatename:pwm_config_set_clkdiv_int=_weak_pwm_config_set_clkdiv_int") +#endif // x86 or amd64 +#endif // _MSC_VER +// -------------------------------------------------- +#if defined(__GNUC__) || defined(__clang__) // Compiler detection +extern "C" void pwm_config_set_clkdiv_int_frac(pwm_config* c, uint8_t integer, + uint8_t fract); +__attribute__((weak)) void pwm_config_set_clkdiv_int_frac(pwm_config* c, + uint8_t integer, + uint8_t fract) +#elif defined(_MSC_VER) // Microsoft Visual C +extern "C" void _weak_pwm_config_set_clkdiv_int_frac(pwm_config* c, + uint8_t integer, + uint8_t fract) +#else // Other compilers are not supported +#error "Unknown compiler." +#endif // Compiler detection +{ + assert(false && + "Error : The hardware_pwm library is missing in the link phase."); +} +#if defined(_MSC_VER) // weak binding in MSVC must be after definition +#if defined(_M_IX86) // for x86 +#pragma comment( \ + linker, \ + "/alternatename:_pwm_config_set_clkdiv_int_frac=__weak_pwm_config_set_clkdiv_int_frac") +#elif defined(_M_AMD64) // for AMD64 +#pragma comment( \ + linker, \ + "/alternatename:pwm_config_set_clkdiv_int_frac=_weak_pwm_config_set_clkdiv_int_frac") +#endif // x86 or amd64 +#endif // _MSC_VER +// -------------------------------------------------- +#if defined(__GNUC__) || defined(__clang__) // Compiler detection +extern "C" void pwm_config_set_clkdiv_mode(pwm_config* c, + enum pwm_clkdiv_mode mode); +__attribute__((weak)) void pwm_config_set_clkdiv_mode(pwm_config* c, + enum pwm_clkdiv_mode mode) +#elif defined(_MSC_VER) // Microsoft Visual C +extern "C" void _weak_pwm_config_set_clkdiv_mode(pwm_config* c, + enum pwm_clkdiv_mode mode) +#else // Other compilers are not supported +#error "Unknown compiler." +#endif // Compiler detection +{ + assert(false && + "Error : The hardware_pwm library is missing in the link phase."); +} +#if defined(_MSC_VER) // weak binding in MSVC must be after definition +#if defined(_M_IX86) // for x86 +#pragma comment( \ + linker, \ + "/alternatename:_pwm_config_set_clkdiv_mode=__weak_pwm_config_set_clkdiv_mode") +#elif defined(_M_AMD64) // for AMD64 +#pragma comment( \ + linker, \ + "/alternatename:pwm_config_set_clkdiv_mode=_weak_pwm_config_set_clkdiv_mode") +#endif // x86 or amd64 +#endif // _MSC_VER +// -------------------------------------------------- +#if defined(__GNUC__) || defined(__clang__) // Compiler detection +extern "C" void pwm_config_set_output_polarity(pwm_config* c, bool a, bool b); +__attribute__((weak)) void pwm_config_set_output_polarity(pwm_config* c, bool a, + bool b) +#elif defined(_MSC_VER) // Microsoft Visual C +extern "C" void _weak_pwm_config_set_output_polarity(pwm_config* c, bool a, + bool b) +#else // Other compilers are not supported +#error "Unknown compiler." +#endif // Compiler detection +{ + assert(false && + "Error : The hardware_pwm library is missing in the link phase."); +} +#if defined(_MSC_VER) // weak binding in MSVC must be after definition +#if defined(_M_IX86) // for x86 +#pragma comment( \ + linker, \ + "/alternatename:_pwm_config_set_output_polarity=__weak_pwm_config_set_output_polarity") +#elif defined(_M_AMD64) // for AMD64 +#pragma comment( \ + linker, \ + "/alternatename:pwm_config_set_output_polarity=_weak_pwm_config_set_output_polarity") +#endif // x86 or amd64 +#endif // _MSC_VER +// -------------------------------------------------- +#if defined(__GNUC__) || defined(__clang__) // Compiler detection +extern "C" void pwm_config_set_phase_correct(pwm_config* c, bool phase_correct); +__attribute__((weak)) void pwm_config_set_phase_correct(pwm_config* c, + bool phase_correct) +#elif defined(_MSC_VER) // Microsoft Visual C +extern "C" void _weak_pwm_config_set_phase_correct(pwm_config* c, + bool phase_correct) +#else // Other compilers are not supported +#error "Unknown compiler." +#endif // Compiler detection +{ + assert(false && + "Error : The hardware_pwm library is missing in the link phase."); +} +#if defined(_MSC_VER) // weak binding in MSVC must be after definition +#if defined(_M_IX86) // for x86 +#pragma comment( \ + linker, \ + "/alternatename:_pwm_config_set_phase_correct=__weak_pwm_config_set_phase_correct") +#elif defined(_M_AMD64) // for AMD64 +#pragma comment( \ + linker, \ + "/alternatename:pwm_config_set_phase_correct=_weak_pwm_config_set_phase_correct") +#endif // x86 or amd64 +#endif // _MSC_VER +// -------------------------------------------------- +#if defined(__GNUC__) || defined(__clang__) // Compiler detection +extern "C" void pwm_config_set_wrap(pwm_config* c, uint16_t wrap); +__attribute__((weak)) void pwm_config_set_wrap(pwm_config* c, uint16_t wrap) +#elif defined(_MSC_VER) // Microsoft Visual C +extern "C" void _weak_pwm_config_set_wrap(pwm_config* c, uint16_t wrap) +#else // Other compilers are not supported +#error "Unknown compiler." +#endif // Compiler detection +{ + assert(false && + "Error : The hardware_pwm library is missing in the link phase."); +} +#if defined(_MSC_VER) // weak binding in MSVC must be after definition +#if defined(_M_IX86) // for x86 +#pragma comment( \ + linker, "/alternatename:_pwm_config_set_wrap=__weak_pwm_config_set_wrap") +#elif defined(_M_AMD64) // for AMD64 +#pragma comment( \ + linker, "/alternatename:pwm_config_set_wrap=_weak_pwm_config_set_wrap") +#endif // x86 or amd64 +#endif // _MSC_VER +// -------------------------------------------------- +#if defined(__GNUC__) || defined(__clang__) // Compiler detection +extern "C" void pwm_force_irq(uint slice_num); +__attribute__((weak)) void pwm_force_irq(uint slice_num) +#elif defined(_MSC_VER) // Microsoft Visual C +extern "C" void _weak_pwm_force_irq(uint slice_num) +#else // Other compilers are not supported +#error "Unknown compiler." +#endif // Compiler detection +{ + assert(false && + "Error : The hardware_pwm library is missing in the link phase."); +} +#if defined(_MSC_VER) // weak binding in MSVC must be after definition +#if defined(_M_IX86) // for x86 +#pragma comment(linker, "/alternatename:_pwm_force_irq=__weak_pwm_force_irq") +#elif defined(_M_AMD64) // for AMD64 +#pragma comment(linker, "/alternatename:pwm_force_irq=_weak_pwm_force_irq") +#endif // x86 or amd64 +#endif // _MSC_VER +// -------------------------------------------------- +#if defined(__GNUC__) || defined(__clang__) // Compiler detection +extern "C" void pwm_force_irq0(uint slice_num); +__attribute__((weak)) void pwm_force_irq0(uint slice_num) +#elif defined(_MSC_VER) // Microsoft Visual C +extern "C" void _weak_pwm_force_irq0(uint slice_num) +#else // Other compilers are not supported +#error "Unknown compiler." +#endif // Compiler detection +{ + assert(false && + "Error : The hardware_pwm library is missing in the link phase."); +} +#if defined(_MSC_VER) // weak binding in MSVC must be after definition +#if defined(_M_IX86) // for x86 +#pragma comment(linker, "/alternatename:_pwm_force_irq0=__weak_pwm_force_irq0") +#elif defined(_M_AMD64) // for AMD64 +#pragma comment(linker, "/alternatename:pwm_force_irq0=_weak_pwm_force_irq0") +#endif // x86 or amd64 +#endif // _MSC_VER +// -------------------------------------------------- +#if defined(__GNUC__) || defined(__clang__) // Compiler detection +extern "C" void pwm_force_irq1(uint slice_num); +__attribute__((weak)) void pwm_force_irq1(uint slice_num) +#elif defined(_MSC_VER) // Microsoft Visual C +extern "C" void _weak_pwm_force_irq1(uint slice_num) +#else // Other compilers are not supported +#error "Unknown compiler." +#endif // Compiler detection +{ + assert(false && + "Error : The hardware_pwm library is missing in the link phase."); +} +#if defined(_MSC_VER) // weak binding in MSVC must be after definition +#if defined(_M_IX86) // for x86 +#pragma comment(linker, "/alternatename:_pwm_force_irq1=__weak_pwm_force_irq1") +#elif defined(_M_AMD64) // for AMD64 +#pragma comment(linker, "/alternatename:pwm_force_irq1=_weak_pwm_force_irq1") +#endif // x86 or amd64 +#endif // _MSC_VER +// -------------------------------------------------- +#if defined(__GNUC__) || defined(__clang__) // Compiler detection +extern "C" uint16_t pwm_get_counter(uint slice_num); +__attribute__((weak)) uint16_t pwm_get_counter(uint slice_num) +#elif defined(_MSC_VER) // Microsoft Visual C +extern "C" uint16_t _weak_pwm_get_counter(uint slice_num) +#else // Other compilers are not supported +#error "Unknown compiler." +#endif // Compiler detection +{ + assert(false && + "Error : The hardware_pwm library is missing in the link phase."); +} +#if defined(_MSC_VER) // weak binding in MSVC must be after definition +#if defined(_M_IX86) // for x86 +#pragma comment(linker, \ + "/alternatename:_pwm_get_counter=__weak_pwm_get_counter") +#elif defined(_M_AMD64) // for AMD64 +#pragma comment(linker, "/alternatename:pwm_get_counter=_weak_pwm_get_counter") +#endif // x86 or amd64 +#endif // _MSC_VER +// -------------------------------------------------- +#if defined(__GNUC__) || defined(__clang__) // Compiler detection +extern "C" pwm_config pwm_get_default_config(void); +__attribute__((weak)) pwm_config pwm_get_default_config(void) +#elif defined(_MSC_VER) // Microsoft Visual C +extern "C" pwm_config _weak_pwm_get_default_config(void) +#else // Other compilers are not supported +#error "Unknown compiler." +#endif // Compiler detection +{ + assert(false && + "Error : The hardware_pwm library is missing in the link phase."); +} +#if defined(_MSC_VER) // weak binding in MSVC must be after definition +#if defined(_M_IX86) // for x86 +#pragma comment( \ + linker, \ + "/alternatename:_pwm_get_default_config=__weak_pwm_get_default_config") +#elif defined(_M_AMD64) // for AMD64 +#pragma comment( \ + linker, \ + "/alternatename:pwm_get_default_config=_weak_pwm_get_default_config") +#endif // x86 or amd64 +#endif // _MSC_VER +// -------------------------------------------------- +#if defined(__GNUC__) || defined(__clang__) // Compiler detection +extern "C" uint pwm_get_dreq(uint slice_num); +__attribute__((weak)) uint pwm_get_dreq(uint slice_num) +#elif defined(_MSC_VER) // Microsoft Visual C +extern "C" uint _weak_pwm_get_dreq(uint slice_num) +#else // Other compilers are not supported +#error "Unknown compiler." +#endif // Compiler detection +{ + assert(false && + "Error : The hardware_pwm library is missing in the link phase."); +} +#if defined(_MSC_VER) // weak binding in MSVC must be after definition +#if defined(_M_IX86) // for x86 +#pragma comment(linker, "/alternatename:_pwm_get_dreq=__weak_pwm_get_dreq") +#elif defined(_M_AMD64) // for AMD64 +#pragma comment(linker, "/alternatename:pwm_get_dreq=_weak_pwm_get_dreq") +#endif // x86 or amd64 +#endif // _MSC_VER +// -------------------------------------------------- +#if defined(__GNUC__) || defined(__clang__) // Compiler detection +extern "C" uint32_t pwm_get_irq0_status_mask(void); +__attribute__((weak)) uint32_t pwm_get_irq0_status_mask(void) +#elif defined(_MSC_VER) // Microsoft Visual C +extern "C" uint32_t _weak_pwm_get_irq0_status_mask(void) +#else // Other compilers are not supported +#error "Unknown compiler." +#endif // Compiler detection +{ + assert(false && + "Error : The hardware_pwm library is missing in the link phase."); +} +#if defined(_MSC_VER) // weak binding in MSVC must be after definition +#if defined(_M_IX86) // for x86 +#pragma comment( \ + linker, \ + "/alternatename:_pwm_get_irq0_status_mask=__weak_pwm_get_irq0_status_mask") +#elif defined(_M_AMD64) // for AMD64 +#pragma comment( \ + linker, \ + "/alternatename:pwm_get_irq0_status_mask=_weak_pwm_get_irq0_status_mask") +#endif // x86 or amd64 +#endif // _MSC_VER +// -------------------------------------------------- +#if defined(__GNUC__) || defined(__clang__) // Compiler detection +extern "C" uint32_t pwm_get_irq1_status_mask(void); +__attribute__((weak)) uint32_t pwm_get_irq1_status_mask(void) +#elif defined(_MSC_VER) // Microsoft Visual C +extern "C" uint32_t _weak_pwm_get_irq1_status_mask(void) +#else // Other compilers are not supported +#error "Unknown compiler." +#endif // Compiler detection +{ + assert(false && + "Error : The hardware_pwm library is missing in the link phase."); +} +#if defined(_MSC_VER) // weak binding in MSVC must be after definition +#if defined(_M_IX86) // for x86 +#pragma comment( \ + linker, \ + "/alternatename:_pwm_get_irq1_status_mask=__weak_pwm_get_irq1_status_mask") +#elif defined(_M_AMD64) // for AMD64 +#pragma comment( \ + linker, \ + "/alternatename:pwm_get_irq1_status_mask=_weak_pwm_get_irq1_status_mask") +#endif // x86 or amd64 +#endif // _MSC_VER +// -------------------------------------------------- +#if defined(__GNUC__) || defined(__clang__) // Compiler detection +extern "C" uint32_t pwm_get_irq_status_mask(void); +__attribute__((weak)) uint32_t pwm_get_irq_status_mask(void) +#elif defined(_MSC_VER) // Microsoft Visual C +extern "C" uint32_t _weak_pwm_get_irq_status_mask(void) +#else // Other compilers are not supported +#error "Unknown compiler." +#endif // Compiler detection +{ + assert(false && + "Error : The hardware_pwm library is missing in the link phase."); +} +#if defined(_MSC_VER) // weak binding in MSVC must be after definition +#if defined(_M_IX86) // for x86 +#pragma comment( \ + linker, \ + "/alternatename:_pwm_get_irq_status_mask=__weak_pwm_get_irq_status_mask") +#elif defined(_M_AMD64) // for AMD64 +#pragma comment( \ + linker, \ + "/alternatename:pwm_get_irq_status_mask=_weak_pwm_get_irq_status_mask") +#endif // x86 or amd64 +#endif // _MSC_VER +// -------------------------------------------------- +#if defined(__GNUC__) || defined(__clang__) // Compiler detection +extern "C" uint pwm_gpio_to_channel(uint gpio); +__attribute__((weak)) uint pwm_gpio_to_channel(uint gpio) +#elif defined(_MSC_VER) // Microsoft Visual C +extern "C" uint _weak_pwm_gpio_to_channel(uint gpio) +#else // Other compilers are not supported +#error "Unknown compiler." +#endif // Compiler detection +{ + assert(false && + "Error : The hardware_pwm library is missing in the link phase."); +} +#if defined(_MSC_VER) // weak binding in MSVC must be after definition +#if defined(_M_IX86) // for x86 +#pragma comment( \ + linker, "/alternatename:_pwm_gpio_to_channel=__weak_pwm_gpio_to_channel") +#elif defined(_M_AMD64) // for AMD64 +#pragma comment( \ + linker, "/alternatename:pwm_gpio_to_channel=_weak_pwm_gpio_to_channel") +#endif // x86 or amd64 +#endif // _MSC_VER +// -------------------------------------------------- +#if defined(__GNUC__) || defined(__clang__) // Compiler detection +extern "C" uint pwm_gpio_to_slice_num(uint gpio); +__attribute__((weak)) uint pwm_gpio_to_slice_num(uint gpio) +#elif defined(_MSC_VER) // Microsoft Visual C +extern "C" uint _weak_pwm_gpio_to_slice_num(uint gpio) +#else // Other compilers are not supported +#error "Unknown compiler." +#endif // Compiler detection +{ + assert(false && + "Error : The hardware_pwm library is missing in the link phase."); +} +#if defined(_MSC_VER) // weak binding in MSVC must be after definition +#if defined(_M_IX86) // for x86 +#pragma comment( \ + linker, \ + "/alternatename:_pwm_gpio_to_slice_num=__weak_pwm_gpio_to_slice_num") +#elif defined(_M_AMD64) // for AMD64 +#pragma comment( \ + linker, \ + "/alternatename:pwm_gpio_to_slice_num=_weak_pwm_gpio_to_slice_num") +#endif // x86 or amd64 +#endif // _MSC_VER +// -------------------------------------------------- +#if defined(__GNUC__) || defined(__clang__) // Compiler detection +extern "C" void pwm_init(uint slice_num, pwm_config* c, bool start); +__attribute__((weak)) void pwm_init(uint slice_num, pwm_config* c, bool start) +#elif defined(_MSC_VER) // Microsoft Visual C +extern "C" void _weak_pwm_init(uint slice_num, pwm_config* c, bool start) +#else // Other compilers are not supported +#error "Unknown compiler." +#endif // Compiler detection +{ + assert(false && + "Error : The hardware_pwm library is missing in the link phase."); +} +#if defined(_MSC_VER) // weak binding in MSVC must be after definition +#if defined(_M_IX86) // for x86 +#pragma comment(linker, "/alternatename:_pwm_init=__weak_pwm_init") +#elif defined(_M_AMD64) // for AMD64 +#pragma comment(linker, "/alternatename:pwm_init=_weak_pwm_init") +#endif // x86 or amd64 +#endif // _MSC_VER +// -------------------------------------------------- +#if defined(__GNUC__) || defined(__clang__) // Compiler detection +extern "C" void pwm_irqn_force(uint irq_index, uint slice_num); +__attribute__((weak)) void pwm_irqn_force(uint irq_index, uint slice_num) +#elif defined(_MSC_VER) // Microsoft Visual C +extern "C" void _weak_pwm_irqn_force(uint irq_index, uint slice_num) +#else // Other compilers are not supported +#error "Unknown compiler." +#endif // Compiler detection +{ + assert(false && + "Error : The hardware_pwm library is missing in the link phase."); +} +#if defined(_MSC_VER) // weak binding in MSVC must be after definition +#if defined(_M_IX86) // for x86 +#pragma comment(linker, "/alternatename:_pwm_irqn_force=__weak_pwm_irqn_force") +#elif defined(_M_AMD64) // for AMD64 +#pragma comment(linker, "/alternatename:pwm_irqn_force=_weak_pwm_irqn_force") +#endif // x86 or amd64 +#endif // _MSC_VER +// -------------------------------------------------- +#if defined(__GNUC__) || defined(__clang__) // Compiler detection +extern "C" uint32_t pwm_irqn_get_status_mask(uint irq_index); +__attribute__((weak)) uint32_t pwm_irqn_get_status_mask(uint irq_index) +#elif defined(_MSC_VER) // Microsoft Visual C +extern "C" uint32_t _weak_pwm_irqn_get_status_mask(uint irq_index) +#else // Other compilers are not supported +#error "Unknown compiler." +#endif // Compiler detection +{ + assert(false && + "Error : The hardware_pwm library is missing in the link phase."); +} +#if defined(_MSC_VER) // weak binding in MSVC must be after definition +#if defined(_M_IX86) // for x86 +#pragma comment( \ + linker, \ + "/alternatename:_pwm_irqn_get_status_mask=__weak_pwm_irqn_get_status_mask") +#elif defined(_M_AMD64) // for AMD64 +#pragma comment( \ + linker, \ + "/alternatename:pwm_irqn_get_status_mask=_weak_pwm_irqn_get_status_mask") +#endif // x86 or amd64 +#endif // _MSC_VER +// -------------------------------------------------- +#if defined(__GNUC__) || defined(__clang__) // Compiler detection +extern "C" void pwm_irqn_set_slice_enabled(uint irq_index, uint slice_num, + bool enabled); +__attribute__((weak)) void pwm_irqn_set_slice_enabled(uint irq_index, + uint slice_num, + bool enabled) +#elif defined(_MSC_VER) // Microsoft Visual C +extern "C" void _weak_pwm_irqn_set_slice_enabled(uint irq_index, uint slice_num, + bool enabled) +#else // Other compilers are not supported +#error "Unknown compiler." +#endif // Compiler detection +{ + assert(false && + "Error : The hardware_pwm library is missing in the link phase."); +} +#if defined(_MSC_VER) // weak binding in MSVC must be after definition +#if defined(_M_IX86) // for x86 +#pragma comment( \ + linker, \ + "/alternatename:_pwm_irqn_set_slice_enabled=__weak_pwm_irqn_set_slice_enabled") +#elif defined(_M_AMD64) // for AMD64 +#pragma comment( \ + linker, \ + "/alternatename:pwm_irqn_set_slice_enabled=_weak_pwm_irqn_set_slice_enabled") +#endif // x86 or amd64 +#endif // _MSC_VER +// -------------------------------------------------- +#if defined(__GNUC__) || defined(__clang__) // Compiler detection +extern "C" void pwm_irqn_set_slice_mask_enabled(uint irq_index, uint slice_mask, + bool enabled); +__attribute__((weak)) void pwm_irqn_set_slice_mask_enabled(uint irq_index, + uint slice_mask, + bool enabled) +#elif defined(_MSC_VER) // Microsoft Visual C +extern "C" void _weak_pwm_irqn_set_slice_mask_enabled(uint irq_index, + uint slice_mask, + bool enabled) +#else // Other compilers are not supported +#error "Unknown compiler." +#endif // Compiler detection +{ + assert(false && + "Error : The hardware_pwm library is missing in the link phase."); +} +#if defined(_MSC_VER) // weak binding in MSVC must be after definition +#if defined(_M_IX86) // for x86 +#pragma comment( \ + linker, \ + "/alternatename:_pwm_irqn_set_slice_mask_enabled=__weak_pwm_irqn_set_slice_mask_enabled") +#elif defined(_M_AMD64) // for AMD64 +#pragma comment( \ + linker, \ + "/alternatename:pwm_irqn_set_slice_mask_enabled=_weak_pwm_irqn_set_slice_mask_enabled") +#endif // x86 or amd64 +#endif // _MSC_VER +// -------------------------------------------------- +#if defined(__GNUC__) || defined(__clang__) // Compiler detection +extern "C" void pwm_retard_count(uint slice_num); +__attribute__((weak)) void pwm_retard_count(uint slice_num) +#elif defined(_MSC_VER) // Microsoft Visual C +extern "C" void _weak_pwm_retard_count(uint slice_num) +#else // Other compilers are not supported +#error "Unknown compiler." +#endif // Compiler detection +{ + assert(false && + "Error : The hardware_pwm library is missing in the link phase."); +} +#if defined(_MSC_VER) // weak binding in MSVC must be after definition +#if defined(_M_IX86) // for x86 +#pragma comment(linker, \ + "/alternatename:_pwm_retard_count=__weak_pwm_retard_count") +#elif defined(_M_AMD64) // for AMD64 +#pragma comment(linker, \ + "/alternatename:pwm_retard_count=_weak_pwm_retard_count") +#endif // x86 or amd64 +#endif // _MSC_VER +// -------------------------------------------------- +#if defined(__GNUC__) || defined(__clang__) // Compiler detection +extern "C" void pwm_set_both_levels(uint slice_num, uint16_t level_a, + uint16_t level_b); +__attribute__((weak)) void pwm_set_both_levels(uint slice_num, uint16_t level_a, + uint16_t level_b) +#elif defined(_MSC_VER) // Microsoft Visual C +extern "C" void _weak_pwm_set_both_levels(uint slice_num, uint16_t level_a, + uint16_t level_b) +#else // Other compilers are not supported +#error "Unknown compiler." +#endif // Compiler detection +{ + assert(false && + "Error : The hardware_pwm library is missing in the link phase."); +} +#if defined(_MSC_VER) // weak binding in MSVC must be after definition +#if defined(_M_IX86) // for x86 +#pragma comment( \ + linker, "/alternatename:_pwm_set_both_levels=__weak_pwm_set_both_levels") +#elif defined(_M_AMD64) // for AMD64 +#pragma comment( \ + linker, "/alternatename:pwm_set_both_levels=_weak_pwm_set_both_levels") +#endif // x86 or amd64 +#endif // _MSC_VER +// -------------------------------------------------- +#if defined(__GNUC__) || defined(__clang__) // Compiler detection +extern "C" void pwm_set_chan_level(uint slice_num, uint chan, uint16_t level); +__attribute__((weak)) void pwm_set_chan_level(uint slice_num, uint chan, + uint16_t level) +#elif defined(_MSC_VER) // Microsoft Visual C +extern "C" void _weak_pwm_set_chan_level(uint slice_num, uint chan, + uint16_t level) +#else // Other compilers are not supported +#error "Unknown compiler." +#endif // Compiler detection +{ + assert(false && + "Error : The hardware_pwm library is missing in the link phase."); +} +#if defined(_MSC_VER) // weak binding in MSVC must be after definition +#if defined(_M_IX86) // for x86 +#pragma comment( \ + linker, "/alternatename:_pwm_set_chan_level=__weak_pwm_set_chan_level") +#elif defined(_M_AMD64) // for AMD64 +#pragma comment(linker, \ + "/alternatename:pwm_set_chan_level=_weak_pwm_set_chan_level") +#endif // x86 or amd64 +#endif // _MSC_VER +// -------------------------------------------------- +#if defined(__GNUC__) || defined(__clang__) // Compiler detection +extern "C" void pwm_set_clkdiv(uint slice_num, float divider); +__attribute__((weak)) void pwm_set_clkdiv(uint slice_num, float divider) +#elif defined(_MSC_VER) // Microsoft Visual C +extern "C" void _weak_pwm_set_clkdiv(uint slice_num, float divider) +#else // Other compilers are not supported +#error "Unknown compiler." +#endif // Compiler detection +{ + assert(false && + "Error : The hardware_pwm library is missing in the link phase."); +} +#if defined(_MSC_VER) // weak binding in MSVC must be after definition +#if defined(_M_IX86) // for x86 +#pragma comment(linker, "/alternatename:_pwm_set_clkdiv=__weak_pwm_set_clkdiv") +#elif defined(_M_AMD64) // for AMD64 +#pragma comment(linker, "/alternatename:pwm_set_clkdiv=_weak_pwm_set_clkdiv") +#endif // x86 or amd64 +#endif // _MSC_VER +// -------------------------------------------------- +#if defined(__GNUC__) || defined(__clang__) // Compiler detection +extern "C" void pwm_set_clkdiv_int_frac(uint slice_num, uint8_t integer, + uint8_t fract); +__attribute__((weak)) void pwm_set_clkdiv_int_frac(uint slice_num, + uint8_t integer, + uint8_t fract) +#elif defined(_MSC_VER) // Microsoft Visual C +extern "C" void _weak_pwm_set_clkdiv_int_frac(uint slice_num, uint8_t integer, + uint8_t fract) +#else // Other compilers are not supported +#error "Unknown compiler." +#endif // Compiler detection +{ + assert(false && + "Error : The hardware_pwm library is missing in the link phase."); +} +#if defined(_MSC_VER) // weak binding in MSVC must be after definition +#if defined(_M_IX86) // for x86 +#pragma comment( \ + linker, \ + "/alternatename:_pwm_set_clkdiv_int_frac=__weak_pwm_set_clkdiv_int_frac") +#elif defined(_M_AMD64) // for AMD64 +#pragma comment( \ + linker, \ + "/alternatename:pwm_set_clkdiv_int_frac=_weak_pwm_set_clkdiv_int_frac") +#endif // x86 or amd64 +#endif // _MSC_VER +// -------------------------------------------------- +#if defined(__GNUC__) || defined(__clang__) // Compiler detection +extern "C" void pwm_set_clkdiv_mode(uint slice_num, enum pwm_clkdiv_mode mode); +__attribute__((weak)) void pwm_set_clkdiv_mode(uint slice_num, + enum pwm_clkdiv_mode mode) +#elif defined(_MSC_VER) // Microsoft Visual C +extern "C" void _weak_pwm_set_clkdiv_mode(uint slice_num, + enum pwm_clkdiv_mode mode) +#else // Other compilers are not supported +#error "Unknown compiler." +#endif // Compiler detection +{ + assert(false && + "Error : The hardware_pwm library is missing in the link phase."); +} +#if defined(_MSC_VER) // weak binding in MSVC must be after definition +#if defined(_M_IX86) // for x86 +#pragma comment( \ + linker, "/alternatename:_pwm_set_clkdiv_mode=__weak_pwm_set_clkdiv_mode") +#elif defined(_M_AMD64) // for AMD64 +#pragma comment( \ + linker, "/alternatename:pwm_set_clkdiv_mode=_weak_pwm_set_clkdiv_mode") +#endif // x86 or amd64 +#endif // _MSC_VER +// -------------------------------------------------- +#if defined(__GNUC__) || defined(__clang__) // Compiler detection +extern "C" void pwm_set_counter(uint slice_num, uint16_t c); +__attribute__((weak)) void pwm_set_counter(uint slice_num, uint16_t c) +#elif defined(_MSC_VER) // Microsoft Visual C +extern "C" void _weak_pwm_set_counter(uint slice_num, uint16_t c) +#else // Other compilers are not supported +#error "Unknown compiler." +#endif // Compiler detection +{ + assert(false && + "Error : The hardware_pwm library is missing in the link phase."); +} +#if defined(_MSC_VER) // weak binding in MSVC must be after definition +#if defined(_M_IX86) // for x86 +#pragma comment(linker, \ + "/alternatename:_pwm_set_counter=__weak_pwm_set_counter") +#elif defined(_M_AMD64) // for AMD64 +#pragma comment(linker, "/alternatename:pwm_set_counter=_weak_pwm_set_counter") +#endif // x86 or amd64 +#endif // _MSC_VER +// -------------------------------------------------- +#if defined(__GNUC__) || defined(__clang__) // Compiler detection +extern "C" void pwm_set_enabled(uint slice_num, bool enabled); +__attribute__((weak)) void pwm_set_enabled(uint slice_num, bool enabled) +#elif defined(_MSC_VER) // Microsoft Visual C +extern "C" void _weak_pwm_set_enabled(uint slice_num, bool enabled) +#else // Other compilers are not supported +#error "Unknown compiler." +#endif // Compiler detection +{ + assert(false && + "Error : The hardware_pwm library is missing in the link phase."); +} +#if defined(_MSC_VER) // weak binding in MSVC must be after definition +#if defined(_M_IX86) // for x86 +#pragma comment(linker, \ + "/alternatename:_pwm_set_enabled=__weak_pwm_set_enabled") +#elif defined(_M_AMD64) // for AMD64 +#pragma comment(linker, "/alternatename:pwm_set_enabled=_weak_pwm_set_enabled") +#endif // x86 or amd64 +#endif // _MSC_VER +// -------------------------------------------------- +#if defined(__GNUC__) || defined(__clang__) // Compiler detection +extern "C" void pwm_set_gpio_level(uint gpio, uint16_t level); +__attribute__((weak)) void pwm_set_gpio_level(uint gpio, uint16_t level) +#elif defined(_MSC_VER) // Microsoft Visual C +extern "C" void _weak_pwm_set_gpio_level(uint gpio, uint16_t level) +#else // Other compilers are not supported +#error "Unknown compiler." +#endif // Compiler detection +{ + assert(false && + "Error : The hardware_pwm library is missing in the link phase."); +} +#if defined(_MSC_VER) // weak binding in MSVC must be after definition +#if defined(_M_IX86) // for x86 +#pragma comment( \ + linker, "/alternatename:_pwm_set_gpio_level=__weak_pwm_set_gpio_level") +#elif defined(_M_AMD64) // for AMD64 +#pragma comment(linker, \ + "/alternatename:pwm_set_gpio_level=_weak_pwm_set_gpio_level") +#endif // x86 or amd64 +#endif // _MSC_VER +// -------------------------------------------------- +#if defined(__GNUC__) || defined(__clang__) // Compiler detection +extern "C" void pwm_set_irq0_enabled(uint slice_num, bool enabled); +__attribute__((weak)) void pwm_set_irq0_enabled(uint slice_num, bool enabled) +#elif defined(_MSC_VER) // Microsoft Visual C +extern "C" void _weak_pwm_set_irq0_enabled(uint slice_num, bool enabled) +#else // Other compilers are not supported +#error "Unknown compiler." +#endif // Compiler detection +{ + assert(false && + "Error : The hardware_pwm library is missing in the link phase."); +} +#if defined(_MSC_VER) // weak binding in MSVC must be after definition +#if defined(_M_IX86) // for x86 +#pragma comment( \ + linker, \ + "/alternatename:_pwm_set_irq0_enabled=__weak_pwm_set_irq0_enabled") +#elif defined(_M_AMD64) // for AMD64 +#pragma comment( \ + linker, "/alternatename:pwm_set_irq0_enabled=_weak_pwm_set_irq0_enabled") +#endif // x86 or amd64 +#endif // _MSC_VER +// -------------------------------------------------- +#if defined(__GNUC__) || defined(__clang__) // Compiler detection +extern "C" void pwm_set_irq0_mask_enabled(uint32_t slice_mask, bool enabled); +__attribute__((weak)) void pwm_set_irq0_mask_enabled(uint32_t slice_mask, + bool enabled) +#elif defined(_MSC_VER) // Microsoft Visual C +extern "C" void _weak_pwm_set_irq0_mask_enabled(uint32_t slice_mask, + bool enabled) +#else // Other compilers are not supported +#error "Unknown compiler." +#endif // Compiler detection +{ + assert(false && + "Error : The hardware_pwm library is missing in the link phase."); +} +#if defined(_MSC_VER) // weak binding in MSVC must be after definition +#if defined(_M_IX86) // for x86 +#pragma comment( \ + linker, \ + "/alternatename:_pwm_set_irq0_mask_enabled=__weak_pwm_set_irq0_mask_enabled") +#elif defined(_M_AMD64) // for AMD64 +#pragma comment( \ + linker, \ + "/alternatename:pwm_set_irq0_mask_enabled=_weak_pwm_set_irq0_mask_enabled") +#endif // x86 or amd64 +#endif // _MSC_VER +// -------------------------------------------------- +#if defined(__GNUC__) || defined(__clang__) // Compiler detection +extern "C" void pwm_set_irq1_enabled(uint slice_num, bool enabled); +__attribute__((weak)) void pwm_set_irq1_enabled(uint slice_num, bool enabled) +#elif defined(_MSC_VER) // Microsoft Visual C +extern "C" void _weak_pwm_set_irq1_enabled(uint slice_num, bool enabled) +#else // Other compilers are not supported +#error "Unknown compiler." +#endif // Compiler detection +{ + assert(false && + "Error : The hardware_pwm library is missing in the link phase."); +} +#if defined(_MSC_VER) // weak binding in MSVC must be after definition +#if defined(_M_IX86) // for x86 +#pragma comment( \ + linker, \ + "/alternatename:_pwm_set_irq1_enabled=__weak_pwm_set_irq1_enabled") +#elif defined(_M_AMD64) // for AMD64 +#pragma comment( \ + linker, "/alternatename:pwm_set_irq1_enabled=_weak_pwm_set_irq1_enabled") +#endif // x86 or amd64 +#endif // _MSC_VER +// -------------------------------------------------- +#if defined(__GNUC__) || defined(__clang__) // Compiler detection +extern "C" void pwm_set_irq1_mask_enabled(uint32_t slice_mask, bool enabled); +__attribute__((weak)) void pwm_set_irq1_mask_enabled(uint32_t slice_mask, + bool enabled) +#elif defined(_MSC_VER) // Microsoft Visual C +extern "C" void _weak_pwm_set_irq1_mask_enabled(uint32_t slice_mask, + bool enabled) +#else // Other compilers are not supported +#error "Unknown compiler." +#endif // Compiler detection +{ + assert(false && + "Error : The hardware_pwm library is missing in the link phase."); +} +#if defined(_MSC_VER) // weak binding in MSVC must be after definition +#if defined(_M_IX86) // for x86 +#pragma comment( \ + linker, \ + "/alternatename:_pwm_set_irq1_mask_enabled=__weak_pwm_set_irq1_mask_enabled") +#elif defined(_M_AMD64) // for AMD64 +#pragma comment( \ + linker, \ + "/alternatename:pwm_set_irq1_mask_enabled=_weak_pwm_set_irq1_mask_enabled") +#endif // x86 or amd64 +#endif // _MSC_VER +// -------------------------------------------------- +#if defined(__GNUC__) || defined(__clang__) // Compiler detection +extern "C" void pwm_set_irq_enabled(uint slice_num, bool enabled); +__attribute__((weak)) void pwm_set_irq_enabled(uint slice_num, bool enabled) +#elif defined(_MSC_VER) // Microsoft Visual C +extern "C" void _weak_pwm_set_irq_enabled(uint slice_num, bool enabled) +#else // Other compilers are not supported +#error "Unknown compiler." +#endif // Compiler detection +{ + assert(false && + "Error : The hardware_pwm library is missing in the link phase."); +} +#if defined(_MSC_VER) // weak binding in MSVC must be after definition +#if defined(_M_IX86) // for x86 +#pragma comment( \ + linker, "/alternatename:_pwm_set_irq_enabled=__weak_pwm_set_irq_enabled") +#elif defined(_M_AMD64) // for AMD64 +#pragma comment( \ + linker, "/alternatename:pwm_set_irq_enabled=_weak_pwm_set_irq_enabled") +#endif // x86 or amd64 +#endif // _MSC_VER +// -------------------------------------------------- +#if defined(__GNUC__) || defined(__clang__) // Compiler detection +extern "C" void pwm_set_irq_mask_enabled(uint32_t slice_mask, bool enabled); +__attribute__((weak)) void pwm_set_irq_mask_enabled(uint32_t slice_mask, + bool enabled) +#elif defined(_MSC_VER) // Microsoft Visual C +extern "C" void _weak_pwm_set_irq_mask_enabled(uint32_t slice_mask, + bool enabled) +#else // Other compilers are not supported +#error "Unknown compiler." +#endif // Compiler detection +{ + assert(false && + "Error : The hardware_pwm library is missing in the link phase."); +} +#if defined(_MSC_VER) // weak binding in MSVC must be after definition +#if defined(_M_IX86) // for x86 +#pragma comment( \ + linker, \ + "/alternatename:_pwm_set_irq_mask_enabled=__weak_pwm_set_irq_mask_enabled") +#elif defined(_M_AMD64) // for AMD64 +#pragma comment( \ + linker, \ + "/alternatename:pwm_set_irq_mask_enabled=_weak_pwm_set_irq_mask_enabled") +#endif // x86 or amd64 +#endif // _MSC_VER +// -------------------------------------------------- +#if defined(__GNUC__) || defined(__clang__) // Compiler detection +extern "C" void pwm_set_mask_enabled(uint32_t mask); +__attribute__((weak)) void pwm_set_mask_enabled(uint32_t mask) +#elif defined(_MSC_VER) // Microsoft Visual C +extern "C" void _weak_pwm_set_mask_enabled(uint32_t mask) +#else // Other compilers are not supported +#error "Unknown compiler." +#endif // Compiler detection +{ + assert(false && + "Error : The hardware_pwm library is missing in the link phase."); +} +#if defined(_MSC_VER) // weak binding in MSVC must be after definition +#if defined(_M_IX86) // for x86 +#pragma comment( \ + linker, \ + "/alternatename:_pwm_set_mask_enabled=__weak_pwm_set_mask_enabled") +#elif defined(_M_AMD64) // for AMD64 +#pragma comment( \ + linker, "/alternatename:pwm_set_mask_enabled=_weak_pwm_set_mask_enabled") +#endif // x86 or amd64 +#endif // _MSC_VER +// -------------------------------------------------- +#if defined(__GNUC__) || defined(__clang__) // Compiler detection +extern "C" void pwm_set_output_polarity(uint slice_num, bool a, bool b); +__attribute__((weak)) void pwm_set_output_polarity(uint slice_num, bool a, + bool b) +#elif defined(_MSC_VER) // Microsoft Visual C +extern "C" void _weak_pwm_set_output_polarity(uint slice_num, bool a, bool b) +#else // Other compilers are not supported +#error "Unknown compiler." +#endif // Compiler detection +{ + assert(false && + "Error : The hardware_pwm library is missing in the link phase."); +} +#if defined(_MSC_VER) // weak binding in MSVC must be after definition +#if defined(_M_IX86) // for x86 +#pragma comment( \ + linker, \ + "/alternatename:_pwm_set_output_polarity=__weak_pwm_set_output_polarity") +#elif defined(_M_AMD64) // for AMD64 +#pragma comment( \ + linker, \ + "/alternatename:pwm_set_output_polarity=_weak_pwm_set_output_polarity") +#endif // x86 or amd64 +#endif // _MSC_VER +// -------------------------------------------------- +#if defined(__GNUC__) || defined(__clang__) // Compiler detection +extern "C" void pwm_set_phase_correct(uint slice_num, bool phase_correct); +__attribute__((weak)) void pwm_set_phase_correct(uint slice_num, + bool phase_correct) +#elif defined(_MSC_VER) // Microsoft Visual C +extern "C" void _weak_pwm_set_phase_correct(uint slice_num, bool phase_correct) +#else // Other compilers are not supported +#error "Unknown compiler." +#endif // Compiler detection +{ + assert(false && + "Error : The hardware_pwm library is missing in the link phase."); +} +#if defined(_MSC_VER) // weak binding in MSVC must be after definition +#if defined(_M_IX86) // for x86 +#pragma comment( \ + linker, \ + "/alternatename:_pwm_set_phase_correct=__weak_pwm_set_phase_correct") +#elif defined(_M_AMD64) // for AMD64 +#pragma comment( \ + linker, \ + "/alternatename:pwm_set_phase_correct=_weak_pwm_set_phase_correct") +#endif // x86 or amd64 +#endif // _MSC_VER +// -------------------------------------------------- +#if defined(__GNUC__) || defined(__clang__) // Compiler detection +extern "C" void pwm_set_wrap(uint slice_num, uint16_t wrap); +__attribute__((weak)) void pwm_set_wrap(uint slice_num, uint16_t wrap) +#elif defined(_MSC_VER) // Microsoft Visual C +extern "C" void _weak_pwm_set_wrap(uint slice_num, uint16_t wrap) +#else // Other compilers are not supported +#error "Unknown compiler." +#endif // Compiler detection +{ + assert(false && + "Error : The hardware_pwm library is missing in the link phase."); +} +#if defined(_MSC_VER) // weak binding in MSVC must be after definition +#if defined(_M_IX86) // for x86 +#pragma comment(linker, "/alternatename:_pwm_set_wrap=__weak_pwm_set_wrap") +#elif defined(_M_AMD64) // for AMD64 +#pragma comment(linker, "/alternatename:pwm_set_wrap=_weak_pwm_set_wrap") +#endif // x86 or amd64 +#endif // _MSC_VER +// -------------------------------------------------- +#if defined(__GNUC__) || defined(__clang__) // Compiler detection extern "C" void gpio_acknowledge_irq(uint gpio, uint32_t event_mask); __attribute__((weak)) void gpio_acknowledge_irq(uint gpio, uint32_t event_mask) #elif defined(_MSC_VER) // Microsoft Visual C diff --git a/src/sdk/pico_sdk_headers.h b/src/sdk/pico_sdk_headers.h index 7103f7e..0c7ae7d 100644 --- a/src/sdk/pico_sdk_headers.h +++ b/src/sdk/pico_sdk_headers.h @@ -8,62 +8,65 @@ */ #if __has_include() || __has_include() #include -#endif // __has_include() || __has_include() +#endif // __has_include() || __has_include() #if __has_include() || __has_include() #include -#endif // __has_include() || - // __has_include() +#endif // __has_include() || __has_include() #if __has_include() || __has_include() #include -#endif // __has_include() || __has_include() +#endif // __has_include() || __has_include() #if __has_include() || __has_include() #include -#endif // __has_include() || - // __has_include() +#endif // __has_include() || __has_include() #if __has_include() || __has_include() #include -#endif // __has_include() || __has_include() +#endif // __has_include() || __has_include() #if __has_include() || __has_include() #include -#endif // __has_include() || __has_include() +#endif // __has_include() || __has_include() #if __has_include() || __has_include() #include -#endif // __has_include() || __has_include() +#endif // __has_include() || __has_include() #if __has_include() || __has_include() #include -#endif // __has_include() || __has_include() +#endif // __has_include() || __has_include() #if __has_include() || __has_include() #include -#endif // __has_include() || __has_include() +#endif // __has_include() || __has_include() #if __has_include() || __has_include() #include -#endif // __has_include() || __has_include() +#endif // __has_include() || __has_include() #if __has_include() || __has_include() #include -#endif // __has_include() || __has_include() +#endif // __has_include() || __has_include() + +#if __has_include() || __has_include() +#include +#endif // __has_include() || __has_include() #if __has_include() || __has_include() #include -#endif // __has_include() || __has_include() +#endif // __has_include() || __has_include() #if __has_include() || __has_include() #include -#endif // __has_include() || __has_include() +#endif // __has_include() || __has_include() #if __has_include() || __has_include() #include -#endif // __has_include() || __has_include() +#endif // __has_include() || __has_include() #if __has_include() || __has_include() #include -#endif // __has_include() || __has_include() +#endif // __has_include() || __has_include() + diff --git a/src/sdk/scripts/api_dirs.txt b/src/sdk/scripts/api_dirs.txt index fce9ac7..413717e 100644 --- a/src/sdk/scripts/api_dirs.txt +++ b/src/sdk/scripts/api_dirs.txt @@ -9,6 +9,7 @@ hardware irq hardware pll hardware pio hardware powman +hardware pwm hardware gpio hardware clocks pico time diff --git a/src/sdk/scripts/blocks/pico_api_alternate_defs.hpp b/src/sdk/scripts/blocks/pico_api_alternate_defs.hpp index 9f6ce0b..791d994 100644 --- a/src/sdk/scripts/blocks/pico_api_alternate_defs.hpp +++ b/src/sdk/scripts/blocks/pico_api_alternate_defs.hpp @@ -34,7 +34,11 @@ enum dma_channel_transfer_size { k, l }; enum riscv_vector_num { m, n }; /// @brief Alternate definition for Google Test build. enum powman_power_domains { o, p }; +/// @brief Alternate definition for Google Test build. +enum pwm_clkdiv_mode { q, r }; +//// @brief Alternate definition for Google Test build. +typedef int pwm_config; //// @brief Alternate definition for Google Test build. typedef int powman_power_state; //// @brief Alternate definition for Google Test build. diff --git a/src/sdk/sdkwrapper.cpp b/src/sdk/sdkwrapper.cpp index c78c40d..a3e7003 100644 --- a/src/sdk/sdkwrapper.cpp +++ b/src/sdk/sdkwrapper.cpp @@ -1929,6 +1929,259 @@ extern "C" void powman_timer_stop(void); void rpp_driver::SdkWrapper::powman_timer_stop(void) { ::powman_timer_stop(); } #endif // __has_include() || __has_include() +#if __has_include() || __has_include() +// -------------------------------------------------- +extern "C" void pwm_advance_count(uint slice_num); +void rpp_driver::SdkWrapper::pwm_advance_count(uint slice_num) { + ::pwm_advance_count(slice_num); +} +// -------------------------------------------------- +extern "C" void pwm_clear_irq(uint slice_num); +void rpp_driver::SdkWrapper::pwm_clear_irq(uint slice_num) { + ::pwm_clear_irq(slice_num); +} +// -------------------------------------------------- +extern "C" void pwm_config_set_clkdiv(pwm_config* c, float div); +void rpp_driver::SdkWrapper::pwm_config_set_clkdiv(pwm_config* c, float div) { + ::pwm_config_set_clkdiv(c, div); +} +// -------------------------------------------------- +extern "C" void pwm_config_set_clkdiv_int(pwm_config* c, uint div); +void rpp_driver::SdkWrapper::pwm_config_set_clkdiv_int(pwm_config* c, + uint div) { + ::pwm_config_set_clkdiv_int(c, div); +} +// -------------------------------------------------- +extern "C" void pwm_config_set_clkdiv_int_frac(pwm_config* c, uint8_t integer, + uint8_t fract); +void rpp_driver::SdkWrapper::pwm_config_set_clkdiv_int_frac(pwm_config* c, + uint8_t integer, + uint8_t fract) { + ::pwm_config_set_clkdiv_int_frac(c, integer, fract); +} +// -------------------------------------------------- +extern "C" void pwm_config_set_clkdiv_mode(pwm_config* c, + enum pwm_clkdiv_mode mode); +void rpp_driver::SdkWrapper::pwm_config_set_clkdiv_mode( + pwm_config* c, enum pwm_clkdiv_mode mode) { + ::pwm_config_set_clkdiv_mode(c, mode); +} +// -------------------------------------------------- +extern "C" void pwm_config_set_output_polarity(pwm_config* c, bool a, bool b); +void rpp_driver::SdkWrapper::pwm_config_set_output_polarity(pwm_config* c, + bool a, bool b) { + ::pwm_config_set_output_polarity(c, a, b); +} +// -------------------------------------------------- +extern "C" void pwm_config_set_phase_correct(pwm_config* c, bool phase_correct); +void rpp_driver::SdkWrapper::pwm_config_set_phase_correct(pwm_config* c, + bool phase_correct) { + ::pwm_config_set_phase_correct(c, phase_correct); +} +// -------------------------------------------------- +extern "C" void pwm_config_set_wrap(pwm_config* c, uint16_t wrap); +void rpp_driver::SdkWrapper::pwm_config_set_wrap(pwm_config* c, uint16_t wrap) { + ::pwm_config_set_wrap(c, wrap); +} +// -------------------------------------------------- +extern "C" void pwm_force_irq(uint slice_num); +void rpp_driver::SdkWrapper::pwm_force_irq(uint slice_num) { + ::pwm_force_irq(slice_num); +} +// -------------------------------------------------- +extern "C" void pwm_force_irq0(uint slice_num); +void rpp_driver::SdkWrapper::pwm_force_irq0(uint slice_num) { + ::pwm_force_irq0(slice_num); +} +// -------------------------------------------------- +extern "C" void pwm_force_irq1(uint slice_num); +void rpp_driver::SdkWrapper::pwm_force_irq1(uint slice_num) { + ::pwm_force_irq1(slice_num); +} +// -------------------------------------------------- +extern "C" uint16_t pwm_get_counter(uint slice_num); +uint16_t rpp_driver::SdkWrapper::pwm_get_counter(uint slice_num) { + return ::pwm_get_counter(slice_num); +} +// -------------------------------------------------- +extern "C" pwm_config pwm_get_default_config(void); +pwm_config rpp_driver::SdkWrapper::pwm_get_default_config(void) { + return ::pwm_get_default_config(); +} +// -------------------------------------------------- +extern "C" uint pwm_get_dreq(uint slice_num); +uint rpp_driver::SdkWrapper::pwm_get_dreq(uint slice_num) { + return ::pwm_get_dreq(slice_num); +} +// -------------------------------------------------- +extern "C" uint32_t pwm_get_irq0_status_mask(void); +uint32_t rpp_driver::SdkWrapper::pwm_get_irq0_status_mask(void) { + return ::pwm_get_irq0_status_mask(); +} +// -------------------------------------------------- +extern "C" uint32_t pwm_get_irq1_status_mask(void); +uint32_t rpp_driver::SdkWrapper::pwm_get_irq1_status_mask(void) { + return ::pwm_get_irq1_status_mask(); +} +// -------------------------------------------------- +extern "C" uint32_t pwm_get_irq_status_mask(void); +uint32_t rpp_driver::SdkWrapper::pwm_get_irq_status_mask(void) { + return ::pwm_get_irq_status_mask(); +} +// -------------------------------------------------- +extern "C" uint pwm_gpio_to_channel(uint gpio); +uint rpp_driver::SdkWrapper::pwm_gpio_to_channel(uint gpio) { + return ::pwm_gpio_to_channel(gpio); +} +// -------------------------------------------------- +extern "C" uint pwm_gpio_to_slice_num(uint gpio); +uint rpp_driver::SdkWrapper::pwm_gpio_to_slice_num(uint gpio) { + return ::pwm_gpio_to_slice_num(gpio); +} +// -------------------------------------------------- +extern "C" void pwm_init(uint slice_num, pwm_config* c, bool start); +void rpp_driver::SdkWrapper::pwm_init(uint slice_num, pwm_config* c, + bool start) { + ::pwm_init(slice_num, c, start); +} +// -------------------------------------------------- +extern "C" void pwm_irqn_force(uint irq_index, uint slice_num); +void rpp_driver::SdkWrapper::pwm_irqn_force(uint irq_index, uint slice_num) { + ::pwm_irqn_force(irq_index, slice_num); +} +// -------------------------------------------------- +extern "C" uint32_t pwm_irqn_get_status_mask(uint irq_index); +uint32_t rpp_driver::SdkWrapper::pwm_irqn_get_status_mask(uint irq_index) { + return ::pwm_irqn_get_status_mask(irq_index); +} +// -------------------------------------------------- +extern "C" void pwm_irqn_set_slice_enabled(uint irq_index, uint slice_num, + bool enabled); +void rpp_driver::SdkWrapper::pwm_irqn_set_slice_enabled(uint irq_index, + uint slice_num, + bool enabled) { + ::pwm_irqn_set_slice_enabled(irq_index, slice_num, enabled); +} +// -------------------------------------------------- +extern "C" void pwm_irqn_set_slice_mask_enabled(uint irq_index, uint slice_mask, + bool enabled); +void rpp_driver::SdkWrapper::pwm_irqn_set_slice_mask_enabled(uint irq_index, + uint slice_mask, + bool enabled) { + ::pwm_irqn_set_slice_mask_enabled(irq_index, slice_mask, enabled); +} +// -------------------------------------------------- +extern "C" void pwm_retard_count(uint slice_num); +void rpp_driver::SdkWrapper::pwm_retard_count(uint slice_num) { + ::pwm_retard_count(slice_num); +} +// -------------------------------------------------- +extern "C" void pwm_set_both_levels(uint slice_num, uint16_t level_a, + uint16_t level_b); +void rpp_driver::SdkWrapper::pwm_set_both_levels(uint slice_num, + uint16_t level_a, + uint16_t level_b) { + ::pwm_set_both_levels(slice_num, level_a, level_b); +} +// -------------------------------------------------- +extern "C" void pwm_set_chan_level(uint slice_num, uint chan, uint16_t level); +void rpp_driver::SdkWrapper::pwm_set_chan_level(uint slice_num, uint chan, + uint16_t level) { + ::pwm_set_chan_level(slice_num, chan, level); +} +// -------------------------------------------------- +extern "C" void pwm_set_clkdiv(uint slice_num, float divider); +void rpp_driver::SdkWrapper::pwm_set_clkdiv(uint slice_num, float divider) { + ::pwm_set_clkdiv(slice_num, divider); +} +// -------------------------------------------------- +extern "C" void pwm_set_clkdiv_int_frac(uint slice_num, uint8_t integer, + uint8_t fract); +void rpp_driver::SdkWrapper::pwm_set_clkdiv_int_frac(uint slice_num, + uint8_t integer, + uint8_t fract) { + ::pwm_set_clkdiv_int_frac(slice_num, integer, fract); +} +// -------------------------------------------------- +extern "C" void pwm_set_clkdiv_mode(uint slice_num, enum pwm_clkdiv_mode mode); +void rpp_driver::SdkWrapper::pwm_set_clkdiv_mode(uint slice_num, + enum pwm_clkdiv_mode mode) { + ::pwm_set_clkdiv_mode(slice_num, mode); +} +// -------------------------------------------------- +extern "C" void pwm_set_counter(uint slice_num, uint16_t c); +void rpp_driver::SdkWrapper::pwm_set_counter(uint slice_num, uint16_t c) { + ::pwm_set_counter(slice_num, c); +} +// -------------------------------------------------- +extern "C" void pwm_set_enabled(uint slice_num, bool enabled); +void rpp_driver::SdkWrapper::pwm_set_enabled(uint slice_num, bool enabled) { + ::pwm_set_enabled(slice_num, enabled); +} +// -------------------------------------------------- +extern "C" void pwm_set_gpio_level(uint gpio, uint16_t level); +void rpp_driver::SdkWrapper::pwm_set_gpio_level(uint gpio, uint16_t level) { + ::pwm_set_gpio_level(gpio, level); +} +// -------------------------------------------------- +extern "C" void pwm_set_irq0_enabled(uint slice_num, bool enabled); +void rpp_driver::SdkWrapper::pwm_set_irq0_enabled(uint slice_num, + bool enabled) { + ::pwm_set_irq0_enabled(slice_num, enabled); +} +// -------------------------------------------------- +extern "C" void pwm_set_irq0_mask_enabled(uint32_t slice_mask, bool enabled); +void rpp_driver::SdkWrapper::pwm_set_irq0_mask_enabled(uint32_t slice_mask, + bool enabled) { + ::pwm_set_irq0_mask_enabled(slice_mask, enabled); +} +// -------------------------------------------------- +extern "C" void pwm_set_irq1_enabled(uint slice_num, bool enabled); +void rpp_driver::SdkWrapper::pwm_set_irq1_enabled(uint slice_num, + bool enabled) { + ::pwm_set_irq1_enabled(slice_num, enabled); +} +// -------------------------------------------------- +extern "C" void pwm_set_irq1_mask_enabled(uint32_t slice_mask, bool enabled); +void rpp_driver::SdkWrapper::pwm_set_irq1_mask_enabled(uint32_t slice_mask, + bool enabled) { + ::pwm_set_irq1_mask_enabled(slice_mask, enabled); +} +// -------------------------------------------------- +extern "C" void pwm_set_irq_enabled(uint slice_num, bool enabled); +void rpp_driver::SdkWrapper::pwm_set_irq_enabled(uint slice_num, bool enabled) { + ::pwm_set_irq_enabled(slice_num, enabled); +} +// -------------------------------------------------- +extern "C" void pwm_set_irq_mask_enabled(uint32_t slice_mask, bool enabled); +void rpp_driver::SdkWrapper::pwm_set_irq_mask_enabled(uint32_t slice_mask, + bool enabled) { + ::pwm_set_irq_mask_enabled(slice_mask, enabled); +} +// -------------------------------------------------- +extern "C" void pwm_set_mask_enabled(uint32_t mask); +void rpp_driver::SdkWrapper::pwm_set_mask_enabled(uint32_t mask) { + ::pwm_set_mask_enabled(mask); +} +// -------------------------------------------------- +extern "C" void pwm_set_output_polarity(uint slice_num, bool a, bool b); +void rpp_driver::SdkWrapper::pwm_set_output_polarity(uint slice_num, bool a, + bool b) { + ::pwm_set_output_polarity(slice_num, a, b); +} +// -------------------------------------------------- +extern "C" void pwm_set_phase_correct(uint slice_num, bool phase_correct); +void rpp_driver::SdkWrapper::pwm_set_phase_correct(uint slice_num, + bool phase_correct) { + ::pwm_set_phase_correct(slice_num, phase_correct); +} +// -------------------------------------------------- +extern "C" void pwm_set_wrap(uint slice_num, uint16_t wrap); +void rpp_driver::SdkWrapper::pwm_set_wrap(uint slice_num, uint16_t wrap) { + ::pwm_set_wrap(slice_num, wrap); +} +#endif // __has_include() || __has_include() + #if __has_include() || __has_include() // -------------------------------------------------- extern "C" void gpio_acknowledge_irq(uint gpio, uint32_t event_mask); diff --git a/src/sdk/sdkwrapper.hpp b/src/sdk/sdkwrapper.hpp index 0605d3e..651a178 100644 --- a/src/sdk/sdkwrapper.hpp +++ b/src/sdk/sdkwrapper.hpp @@ -540,6 +540,59 @@ class SdkWrapper { virtual void powman_timer_stop(void); #endif // __has_include() || __has_include() +#if __has_include() || __has_include() + virtual void pwm_advance_count(uint slice_num); + virtual void pwm_clear_irq(uint slice_num); + virtual void pwm_config_set_clkdiv(pwm_config* c, float div); + virtual void pwm_config_set_clkdiv_int(pwm_config* c, uint div); + virtual void pwm_config_set_clkdiv_int_frac(pwm_config* c, uint8_t integer, + uint8_t fract); + virtual void pwm_config_set_clkdiv_mode(pwm_config* c, + enum pwm_clkdiv_mode mode); + virtual void pwm_config_set_output_polarity(pwm_config* c, bool a, bool b); + virtual void pwm_config_set_phase_correct(pwm_config* c, bool phase_correct); + virtual void pwm_config_set_wrap(pwm_config* c, uint16_t wrap); + virtual void pwm_force_irq(uint slice_num); + virtual void pwm_force_irq0(uint slice_num); + virtual void pwm_force_irq1(uint slice_num); + virtual uint16_t pwm_get_counter(uint slice_num); + virtual pwm_config pwm_get_default_config(void); + virtual uint pwm_get_dreq(uint slice_num); + virtual uint32_t pwm_get_irq0_status_mask(void); + virtual uint32_t pwm_get_irq1_status_mask(void); + virtual uint32_t pwm_get_irq_status_mask(void); + virtual uint pwm_gpio_to_channel(uint gpio); + virtual uint pwm_gpio_to_slice_num(uint gpio); + virtual void pwm_init(uint slice_num, pwm_config* c, bool start); + virtual void pwm_irqn_force(uint irq_index, uint slice_num); + virtual uint32_t pwm_irqn_get_status_mask(uint irq_index); + virtual void pwm_irqn_set_slice_enabled(uint irq_index, uint slice_num, + bool enabled); + virtual void pwm_irqn_set_slice_mask_enabled(uint irq_index, uint slice_mask, + bool enabled); + virtual void pwm_retard_count(uint slice_num); + virtual void pwm_set_both_levels(uint slice_num, uint16_t level_a, + uint16_t level_b); + virtual void pwm_set_chan_level(uint slice_num, uint chan, uint16_t level); + virtual void pwm_set_clkdiv(uint slice_num, float divider); + virtual void pwm_set_clkdiv_int_frac(uint slice_num, uint8_t integer, + uint8_t fract); + virtual void pwm_set_clkdiv_mode(uint slice_num, enum pwm_clkdiv_mode mode); + virtual void pwm_set_counter(uint slice_num, uint16_t c); + virtual void pwm_set_enabled(uint slice_num, bool enabled); + virtual void pwm_set_gpio_level(uint gpio, uint16_t level); + virtual void pwm_set_irq0_enabled(uint slice_num, bool enabled); + virtual void pwm_set_irq0_mask_enabled(uint32_t slice_mask, bool enabled); + virtual void pwm_set_irq1_enabled(uint slice_num, bool enabled); + virtual void pwm_set_irq1_mask_enabled(uint32_t slice_mask, bool enabled); + virtual void pwm_set_irq_enabled(uint slice_num, bool enabled); + virtual void pwm_set_irq_mask_enabled(uint32_t slice_mask, bool enabled); + virtual void pwm_set_mask_enabled(uint32_t mask); + virtual void pwm_set_output_polarity(uint slice_num, bool a, bool b); + virtual void pwm_set_phase_correct(uint slice_num, bool phase_correct); + virtual void pwm_set_wrap(uint slice_num, uint16_t wrap); +#endif // __has_include() || __has_include() + #if __has_include() || __has_include() virtual void gpio_acknowledge_irq(uint gpio, uint32_t event_mask); virtual void gpio_add_raw_irq_handler(uint gpio, irq_handler_t handler); diff --git a/test/test_sdkwrapper.cpp b/test/test_sdkwrapper.cpp index 188765f..0a726ad 100644 --- a/test/test_sdkwrapper.cpp +++ b/test/test_sdkwrapper.cpp @@ -75,6 +75,7 @@ FAKE_VALUE_FUNC(uint, interp_index, interp_hw_t *); FAKE_VALUE_FUNC(bool, irq_is_enabled, uint); FAKE_VOID_FUNC(pll_deinit, PLL); FAKE_VALUE_FUNC(int, powman_set_power_state, powman_power_state); +FAKE_VALUE_FUNC(uint, pwm_gpio_to_channel, uint); } // The cpp file of the library to test. #include "../src/sdk/sdkwrapper.cpp" @@ -1796,4 +1797,49 @@ TEST(SdkWrapper, powman_set_power_state) { index++; } RESET_FAKE(powman_set_power_state); -} // TEST(SdkWrapper, irq_is_enabled) \ No newline at end of file +} // TEST(SdkWrapper, irq_is_enabled) + +// ----------------------------------------------------------- +// +// hardware_powerman +// virtual uint pwm_gpio_to_channel(uint gpio); +// +// ----------------------------------------------------------- + +TEST(SdkWrapper, pwm_gpio_to_channel) { + std::random_device rng; + ::rpp_driver::SdkWrapper pico; + + std::uniform_int_distribution param_dist(0, UINT_MAX); + uint param_array0[] = {param_dist(rng), param_dist(rng)}; + + std::uniform_int_distribution retval_dist(0, UINT_MAX); + uint retval_array[std::size(param_array0)] = {retval_dist(rng), + retval_dist(rng)}; + + FFF_RESET_HISTORY(); + RESET_FAKE(pwm_gpio_to_channel); + + SET_RETURN_SEQ(pwm_gpio_to_channel, retval_array, std::size(retval_array)); + + // Check whether return values are correctly passed to wrapper. + int index = 0; + for (auto &¶m0 : param_array0) { + ASSERT_EQ(pico.pwm_gpio_to_channel(param0), retval_array[index]); + index++; + } + + // Check the data from test spy. How many time called? + ASSERT_EQ(pwm_gpio_to_channel_fake.call_count, std::size(retval_array)); + + // Check whether parameters were correctly passed from wrapper. + index = 0; + for (auto &¶m0 : param_array0) { + // Check the data from test spy. Call order. + ASSERT_EQ(fff.call_history[index], (void *)pwm_gpio_to_channel); + // Check the data from test spy. : Parameters. + ASSERT_EQ(pwm_gpio_to_channel_fake.arg0_history[index], param0); + index++; + } + RESET_FAKE(pwm_gpio_to_channel); +} // TEST(SdkWrapper, pwm_gpio_to_channel) \ No newline at end of file diff --git a/test/todo/test_sdkwrapper.md b/test/todo/test_sdkwrapper.md index a398bd8..98e569a 100644 --- a/test/todo/test_sdkwrapper.md +++ b/test/todo/test_sdkwrapper.md @@ -1,5 +1,13 @@ # test_SdkWrapper TDD + + +## SdkWrapper::pwm_gpio_to_channel() +- [x] Implement member function . +- [x] Create test case to fail. +- [x] Make it success. +- [x] Remove the duplication. + ## SdkWrapper::powman_set_power_state() - [x] Implement member function . - [x] Create test case to fail.