/**
 * \file
 *
 * \brief SAM D21 Xplained Pro board configuration.
 *
 * Copyright (c) 2013-2018 Microchip Technology Inc. and its subsidiaries.
 *
 * \asf_license_start
 *
 * \page License
 *
 * Subject to your compliance with these terms, you may use Microchip
 * software and any derivatives exclusively with Microchip products.
 * It is your responsibility to comply with third party license terms applicable
 * to your use of third party software (including open source software) that
 * may accompany Microchip software.
 *
 * THIS SOFTWARE IS SUPPLIED BY MICROCHIP "AS IS". NO WARRANTIES,
 * WHETHER EXPRESS, IMPLIED OR STATUTORY, APPLY TO THIS SOFTWARE,
 * INCLUDING ANY IMPLIED WARRANTIES OF NON-INFRINGEMENT, MERCHANTABILITY,
 * AND FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT WILL MICROCHIP BE
 * LIABLE FOR ANY INDIRECT, SPECIAL, PUNITIVE, INCIDENTAL OR CONSEQUENTIAL
 * LOSS, DAMAGE, COST OR EXPENSE OF ANY KIND WHATSOEVER RELATED TO THE
 * SOFTWARE, HOWEVER CAUSED, EVEN IF MICROCHIP HAS BEEN ADVISED OF THE
 * POSSIBILITY OR THE DAMAGES ARE FORESEEABLE.  TO THE FULLEST EXTENT
 * ALLOWED BY LAW, MICROCHIP'S TOTAL LIABILITY ON ALL CLAIMS IN ANY WAY
 * RELATED TO THIS SOFTWARE WILL NOT EXCEED THE AMOUNT OF FEES, IF ANY,
 * THAT YOU HAVE PAID DIRECTLY TO MICROCHIP FOR THIS SOFTWARE.
 *
 * \asf_license_stop
 *
 */
/*
 * Support and FAQ: visit <a href="https://www.microchip.com/support/">Microchip Support</a>
 */

#ifndef CONF_BOARD_H_INCLUDED
#define CONF_BOARD_H_INCLUDED

#include "conf_boaty_testbed.h"

#ifdef DEBUG
	#define P_DEBUG_USART_MODULE			SERCOM3
	#define P_DEBUG_USART_PINMUX_PAD0		PINMUX_PA22C_SERCOM3_PAD0
	#define P_DEBUG_USART_PINMUX_PAD1		PINMUX_PA23C_SERCOM3_PAD1
	#define P_DEBUG_USART_PINMUX_PAD2		PINMUX_UNUSED
	#define P_DEBUG_USART_PINMUX_PAD3		PINMUX_UNUSED
	#define P_DEBUG_USART_MUX_SETTING		USART_RX_1_TX_0_XCK_1
	#define P_DEBUG_USART_BAUDRATE			115200
#endif

// Buttons
// Forward button -- switches us to go forward!
#define P_IO_FORWARD_BTN_PIN				PIN_PA10
#define P_IO_FORWARD_BTN_EIC_PIN			PIN_PA10A_EIC_EXTINT10
#define P_IO_FORWARD_BTN_EIC_MUX			MUX_PA10A_EIC_EXTINT10
#define P_IO_FORWARD_BTN_EIC_PINMUX			PINMUX_PA10A_EIC_EXTINT10
#define P_IO_FORWARD_BTN_EIC_LINE			10
#define P_IO_FORWARD_BTN_DET				EXTINT_DETECT_RISING
#define P_IO_FORWARD_BTN_PULL				EXTINT_PULL_NONE			// We have external pulldowns

// Reverse button -- switches us to go in reverse
#define P_IO_REVERSE_BTN_PIN				PIN_PA11
#define P_IO_REVERSE_BTN_EIC_PIN			PIN_PA11A_EIC_EXTINT11
#define P_IO_REVERSE_BTN_EIC_MUX			MUX_PA11A_EIC_EXTINT11
#define P_IO_REVERSE_BTN_EIC_PINMUX			PINMUX_PA11A_EIC_EXTINT11
#define P_IO_REVERSE_BTN_EIC_LINE			11
#define P_IO_REVERSE_BTN_DET				EXTINT_DETECT_RISING
#define P_IO_REVERSE_BTN_PULL				EXTINT_PULL_NONE			// We have external pulldowns

// Stop button -- stops the motor
#define P_IO_STOP_BTN_PIN					PIN_PA12
#define P_IO_STOP_BTN_EIC_PIN				PIN_PA12A_EIC_EXTINT12
#define P_IO_STOP_BTN_EIC_MUX				MUX_PA12A_EIC_EXTINT12
#define P_IO_STOP_BTN_EIC_PINMUX			PINMUX_PA12A_EIC_EXTINT12
#define P_IO_STOP_BTN_EIC_LINE				12
#define P_IO_STOP_BTN_DET					EXTINT_DETECT_RISING
#define P_IO_STOP_BTN_PULL					EXTINT_PULL_NONE			// We have external pulldowns

// Motor Control Pin
// This will eventually be used as a tcc pin
#define P_MOTOR_CTRL_PIN					PIN_PA04

// ADC Config
											//pa02
#define P_FORWARD_POT_POSITIVE_INPUT_PIN	ADC_POSITIVE_INPUT_PIN0
											// pa05
#define P_REVERSE_POT_POSITIVE_INPUT_PIN	ADC_POSITIVE_INPUT_PIN5

#define P_ADC_RESOLUTION					ADC_RESOLUTION_12BIT
#define P_ADC_GAIN_FACTOR					ADC_GAIN_FACTOR_1X
#define P_ADC_NEGATIVE_INPUT_PIN			ADC_NEGATIVE_INPUT_GND
#define P_ADC_CLOCK_PRESCALER				ADC_CLOCK_PRESCALER_DIV4
#define P_ADC_REFERENCE						ADC_REFERENCE_INTVCC0
#define P_ADC_VREF_VAL						(2.2297f)





#endif /* CONF_BOARD_H_INCLUDED */
