#include <avr/io.h>

#include <stdint.h>

// PORTB
uint8_t const pin_adir  = 1U << 0;

#define portb_use pin_adir
#define portb_out pin_adir

// PORTC
uint8_t const pin_xend  = 1U << 3;
uint8_t const pin_yend  = 1U << 2;
uint8_t const pin_zend  = 1U << 1;
uint8_t const pin_aend  = 1U << 0;
uint8_t const pin_enab  = 1U << 5;

#define portc_use (pin_xend | pin_yend | pin_zend | pin_aend | pin_enab)
#define portc_out pin_enab

// PORTD
uint8_t const pin_xstep = 1U << 4;		// temporarily D4
uint8_t const pin_xdir  = 1U << 1;
uint8_t const pin_ystep = 1U << 2;
uint8_t const pin_ydir  = 1U << 3;
uint8_t const pin_zstep = 1U << 5;
uint8_t const pin_zdir  = 1U << 6;
uint8_t const pin_astep = 1U << 7;

#define portd_use (pin_xstep | pin_xdir | pin_ystep | pin_ydir | \
	pin_zstep | pin_zdir | pin_astep)
#define portd_out (pin_xstep | pin_xdir | pin_ystep | pin_ydir | \
	pin_zstep | pin_zdir | pin_astep)

void setup()
{
	// pins are low active, set outputs high
	PORTB = (PORTB & ~portb_use) | portb_out;
	PORTC = (PORTC & ~portc_use) | portc_out;
	PORTD = (PORTD & ~portd_use) | portd_out;

	// set up inputs and outputs
	DDRB = (DDRB & ~portb_use) | portb_out;
	DDRC = (DDRC & ~portc_use) | portc_out;
	DDRD = (DDRD & ~portd_use) | portd_out;
}

void loop()
{
}

int main(void)
{
	setup();
	for(;;)
		loop();
}