<commit_before>#pragma once

#include <avr/io.h>

typedef volatile uint8_t mmio8_type;

enum PortId {
	A,
	B
};

template <PortId P>
class Port {
public:
	static mmio8_type& port();
	static mmio8_type& pin();
	static mmio8_type& ddr();
};

#if defined(PORTA)
template <>
inline mmio8_type& Port<A>::port()
{
	return PORTA;
}

template <>
inline mmio8_type& Port<A>::pin()
{
	return PINA;
}

template <>
inline mmio8_type& Port<A>::ddr()
{
	return DDRA;
}
#endif // defined(PORTA)

#if defined(PORTB)
template <>
inline mmio8_type& Port<B>::port()
{
	return PORTB;
}

template <>
inline mmio8_type& Port<B>::pin()
{
	return PINB;
}

template <>
inline mmio8_type& Port<B>::ddr()
{
	return DDRB;
}
#endif // defined(PORTB)

enum PinMode {
	INPUT,
	OUTPUT
};

template <class Port_t, int pin_n>
class Pin {
public:
	typedef Port_t Port;
	constexpr static int pin = pin_n;

	// reads PIN
	static char value() {
		return Port::pin() & _BV(pin);
	}

	// set high
	static void set() {
		Port::port() |= _BV(pin);
	}

	// set low
	static void clear() {<commit_msg>port.hpp: supporting PORTC and PORTD<commit_after>#pragma once

#include <avr/io.h>

typedef volatile uint8_t mmio8_type;

enum PortId {
	A,
	B,
	C,
	D,
};

template <PortId P>
class Port {
public:
	static mmio8_type& port();
	static mmio8_type& pin();
	static mmio8_type& ddr();
};

#if defined(PORTA)
template <>
inline mmio8_type& Port<A>::port()
{
	return PORTA;
}

template <>
inline mmio8_type& Port<A>::pin()
{
	return PINA;
}

template <>
inline mmio8_type& Port<A>::ddr()
{
	return DDRA;
}
#endif // defined(PORTA)

#if defined(PORTB)
template <>
inline mmio8_type& Port<B>::port()
{
	return PORTB;
}

template <>
inline mmio8_type& Port<B>::pin()
{
	return PINB;
}

template <>
inline mmio8_type& Port<B>::ddr()
{
	return DDRB;
}
#endif // defined(PORTB)

#if defined(PORTC)
template <>
inline mmio8_type& Port<C>::port()
{
	return PORTC;
}

template <>
inline mmio8_type& Port<C>::pin()
{
	return PINC;
}

template <>
inline mmio8_type& Port<C>::ddr()
{
	return DDRC;
}
#endif // defined(PORTC)

#if defined(PORTD)
template <>
inline mmio8_type& Port<D>::port()
{
	return PORTD;
}

template <>
inline mmio8_type& Port<D>::pin()
{
	return PIND;
}

template <>
inline mmio8_type& Port<D>::ddr()
{
	return DDRD;
}
#endif // defined(PORTD)

enum PinMode {
	INPUT,
	OUTPUT
};

template <class Port_t, int pin_n>
class Pin {
public:
	typedef Port_t Port;
	constexpr static int pin = pin_n;

	// reads PIN
	static char value() {
		return Port::pin() & _BV(pin);
	}

	// set high
	static void set() {
		Port::port() |= _BV(pin);
	}

	// set low
	static void clear() {
{'fraction_non_alphanumeric': 0.16184310738766183, 'fraction_numerical': 0.010662604722010662, 'mean_word_length': 4.317813765182186, 'pattern_counts': {'":': 0, '<': 45, '<?xml version=': 0, '>': 45, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4517464', 'n_tokens_mistral': 1136, 'n_tokens_neox': 1084, 'n_words': 272}