Program Listing for File PWM_DIVMODE.h

Program Listing for File PWM_DIVMODE.h#

Return to documentation for file (src/generated/enums/PWM_DIVMODE.h)

#pragma once
#ifndef RP2040_ENUMS_PWM_DIVMODE_H
#define RP2040_ENUMS_PWM_DIVMODE_H

#include "../ifgen/common.h"
#include <cstdint>
#include <cstring>

namespace RP2040
{

enum class PWM_DIVMODE : uint8_t
{
    div ,
    level = 1 ,
    rise = 2 ,
    fall = 3
};
static_assert(sizeof(PWM_DIVMODE) == 1);

inline const char *to_string(PWM_DIVMODE instance)
{
    const char *result = "UNKNOWN PWM_DIVMODE";

    switch (instance)
    {
    case PWM_DIVMODE::div:
        result = "div";
        break;
    case PWM_DIVMODE::level:
        result = "level";
        break;
    case PWM_DIVMODE::rise:
        result = "rise";
        break;
    case PWM_DIVMODE::fall:
        result = "fall";
        break;
    }

    return result;
}

inline std::ostream &operator<<(std::ostream &stream, PWM_DIVMODE instance)
{
    stream << to_string(instance);
    return stream;
}

inline bool from_string(const char *data, PWM_DIVMODE &output)
{
    bool result = false;

    if ((result = !strncmp(data, "div", 3)))
    {
        output = PWM_DIVMODE::div;
    }
    else if ((result = !strncmp(data, "level", 5)))
    {
        output = PWM_DIVMODE::level;
    }
    else if ((result = !strncmp(data, "rise", 4)))
    {
        output = PWM_DIVMODE::rise;
    }
    else if ((result = !strncmp(data, "fall", 4)))
    {
        output = PWM_DIVMODE::fall;
    }

    return result;
}

}; // namespace RP2040

#endif