/*
 * user_board.h
 *
 * For bronze board, see http://www.ini.uzh.ch/~tobi/wiki/doku.php?id=dig:start
 *
 *  Created on: Feb 28, 2013
 *      Author: Tobi
 */

#ifndef USER_BOARD_H_
#define USER_BOARD_H_


#include "compiler.h"


/*! \name Oscillator Definitions
 */
//! @{

// RCOsc has no custom calibration by default. Set the following definition to
// the appropriate value if a custom RCOsc calibration has been applied to your
// part.
//#define FRCOSC          AVR32_PM_RCOSC_FREQUENCY              //!< RCOsc frequency: Hz.

#define FOSC32          32768                                 //!< Osc32 frequency: Hz.
#define OSC32_STARTUP   AVR32_PM_OSCCTRL32_STARTUP_8192_RCOSC //!< Osc32 startup time: RCOsc periods.

#define FOSC0           12000000                              //!< Osc0 frequency: Hz.
#define OSC0_STARTUP    AVR32_PM_OSCCTRL0_STARTUP_2048_RCOSC  //!< Osc0 startup time: RCOsc periods.

// Osc1 crystal is not mounted by default. Set the following definitions to the
// appropriate values if a custom Osc1 crystal is mounted on your board.
//#define FOSC1           12000000                              //!< Osc1 frequency: Hz.
//#define OSC1_STARTUP    AVR32_PM_OSCCTRL1_STARTUP_2048_RCOSC  //!< Osc1 startup time: RCOsc periods.

//! @}


/*! \name USB Definitions
 */
//! @{

//! Multiplexed pin used for USB_ID: AVR32_USBB_USB_ID_x_x.
//! To be selected according to the AVR32_USBB_USB_ID_x_x_PIN and
//! AVR32_USBB_USB_ID_x_x_FUNCTION definitions from <avr32/uc3bxxxx.h>.
#define USB_ID                      AVR32_USBB_USB_ID_0_0

//! Multiplexed pin used for USB_VBOF: AVR32_USBB_USB_VBOF_x_x.
//! To be selected according to the AVR32_USBB_USB_VBOF_x_x_PIN and
//! AVR32_USBB_USB_VBOF_x_x_FUNCTION definitions from <avr32/uc3bxxxx.h>.
#define USB_VBOF                    AVR32_USBB_USB_VBOF_0_0

//! Active level of the USB_VBOF output pin.
#define USB_VBOF_ACTIVE_LEVEL       LOW

//! USB over-current detection pin.
#define USB_OVERCURRENT_DETECT_PIN  AVR32_PIN_PA20

//! @}


//! Number of LEDs.
#define LED_COUNT   3

/*! \name GPIO Connections of LEDs
 */
//! @{
#define LED0_GPIO   AVR32_PIN_PA08 // red
#define LED1_GPIO   AVR32_PIN_PA14 // green
#define LED2_GPIO   AVR32_PIN_PA15 // blue
#define LED_RED   AVR32_PIN_PA08 // red
#define LED_GREEN   AVR32_PIN_PA14 // green
#define LED_BLUE   AVR32_PIN_PA15 // blue
//! @}

/*! \name PWM Channels of LEDs
 */
//! @{
#define LED0_PWM    0
#define LED1_PWM    1
#define LED2_PWM    2
#define LED_RED_PWM    0
#define LED_GREEN_PWM    1
#define LED_BLUE_PWM    2
//! @}

/*! \name PWM Functions of LEDs
 */
//! @{
#define LED0_PWM_FUNCTION   AVR32_PWM_0_0_FUNCTION
#define LED1_PWM_FUNCTION   AVR32_PWM_1_0_FUNCTION
#define LED2_PWM_FUNCTION   AVR32_PWM_2_0_FUNCTION
//! @}


/*! \name GPIO Connections of Push Buttons
 */
//! @{
#define GPIO_PUSH_BUTTON_0            AVR32_PIN_PA13
#define GPIO_DFU_BUTTON            AVR32_PIN_PA13
#define GPIO_PUSH_BUTTON_0_PRESSED    0
#define GPIO_DFU_BUTTON_PRESSED    0
//! @}




/*! \name ADC Connection of the Light Sensor
 */
//! @{
#define ADC_LIGHT_CHANNEL           6
#define ADC_LIGHT_PIN               AVR32_ADC_AD_6_PIN
#define ADC_LIGHT_FUNCTION          AVR32_ADC_AD_6_FUNCTION
#define LDR_LIGHT_CHANNEL           6
#define LDR_LIGHT_PIN               AVR32_ADC_AD_6_PIN
#define LDR_LIGHT_FUNCTION          AVR32_ADC_AD_6_FUNCTION
//! @}

#define LDR_PIN AVR32_PIN_PA03

#endif /* USER_BOARD_H_ */
