/**
 * \file
 *
 * \brief User board initialization template
 *
 */
/*
 * Support and FAQ: visit <a href="http://www.atmel.com/design-support/">Atmel Support</a>
 */

#include <asf.h>
#include <board.h>
#include <conf_board.h>

void board_init(void)
{
	/** USB VBus monitoring pin definition. */
	#define PIN_USB_VBUS    {PIO_PB3, PIOB, ID_PIOB, PIO_INPUT, PIO_PULLUP}
	#define USB_VBUS_FLAGS    (PIO_INPUT | PIO_DEBOUNCE | PIO_IT_EDGE)
	#define USB_VBUS_PIN_IRQn (PIOB_IRQn)
	#define USB_VBUS_PIN      (PIO_PB3_IDX)
	#define USB_VBUS_PIO_ID   (ID_PIOB)
	#define USB_VBUS_PIO_MASK (PIO_PB3)

	/** PWM Out pin definitions. */
	#define PIN_PWM_L_GPIO     PIO_PD24_IDX
	#define PIN_PWM_L_FLAGS    (IOPORT_MODE_MUX_A)
	#define PIN_PWM_L_CHANNEL  PWM_CHANNEL_0
	#define PIN_PWM_H_GPIO     PIO_PD20_IDX
	#define PIN_PWM_H_FLAGS    (IOPORT_MODE_MUX_A)
	#define PIN_PWM_H_CHANNEL  PWM_CHANNEL_0

	/** Rotary Encoder Pins. */
	#define ENCODER_A         PIO_PD26_IDX
	#define ENCODER_B         PIO_PD27_IDX
	#define ENCODER_PUSH      PIO_PD28_IDX
	pio_set_input(PIOD,(1<<28),PIO_INPUT | PIO_PULLUP);
	
	pio_set_output(PIOD,(1<<31),0,0,0);
}
