//!
//! @file config.h,v
//!
//! Copyright (c) 2007 Atmel.
//!
//! @brief Firmware Configuration
//!
//! @version 1.14
//!

//_____  I N C L U D E S ___________________________________________________



#ifdef __GNUC__
 #include "gcc_compiler.h"
 #include <avr/io.h>
 #include <avr/pgmspace.h>
 #include <avr/interrupt.h>

 #define putchar(c) uart_putchar(c)
 #define getchar(c) uart_getchar(c)

 #define Uchar U8
 #define Uint32 U32
 #define Enable_interrupt() __enable_interrupt
 #define Disable_interrupt() __disable_interrupt
 #define code PROGMEM
// #define code
 #define MSB(u16)        (((U8* )&u16)[1])
 #define LSB(u16)        (((U8* )&u16)[0])
 #define HIGH(v) MSB(v)
 #define LOW(v) LSB(v)

 #define ADASCR 4
 #define AMP1ND 0
 #define AMP1PD 1
 #define ACMP1D 2
 #define PLLOCK 0

/* AMP0CSR  */
#define    AMP0EN    7
#define    AMP0IS    6
#define    AMP0G1    5
#define    AMP0G0    4
#define    AMP0TS2   2
#define    AMP0TS1   1
#define    AMP0TS0   0

/* AMP1CSR  */
#define    AMP1EN    7
#define    AMP1IS    6
#define    AMP1G1    5
#define    AMP1G0    4
#define    AMP1TS2   2
#define    AMP1TS1   1
#define    AMP1TS0   0


#else
 #include "compiler.h"
// #include "mcu.h"
 #include "inavr.h"
 #include "ioavr.h"
#endif


#include "config_motor.h"


#ifndef _CONFIG_H_
#define _CONFIG_H_
#endif


#define BOARD_ID 1 /* 0:unknown, 1 : MC100, 2 : MC200 */
#define SOFT_ID 1 /* 0:unknown, 1:bldc sensor, 2:bldc sinus, 3:bldc sensorless */
#define REV_ID 1

/*-------------- UART LIB CONFIGURATION ---------------*/
//#define DB101
#define BAUDRATE      38400
#define FOSC          16000

#define uart_putchar putchar

//! @defgroup ADC_defines_configuration_values ADC Defines Configuration Values
//! Defines allowing to init the ADC with the wanted configuration
//! @{
#define USE_ADC

#define ADC_RIGHT_ADJUST_RESULT                 0 //!< 0: Result left adjusted  1: Result right adjusted
#define ADC_HIGH_SPEED_MODE                     1 //
#define ADC_INTERNAL_VREF                       1 //!< 0: External Vref         1: Internal Vref  2: Vref is connected to Vcc
#define ADC_IT                                  1 //!< 0: No ADC End of Conv IT 1: ADC End of conversion generates an IT
#define ADC_PRESCALER                           4 //!< 2, 4, 8, 16, 32, 64, 128  : The input ADC frequency is the system clock frequency divided by the const value

//! @defgroup DAC_defines_configuration_values DAC Defines Configuration Values
//! Defines allowing to init the DAC with the wanted configuration
//! @{
#define USE_DAC

#define DAC_INPUT_RIGHT_ADJUST                  0 //!< 0: Result left adjusted  1: Result right adjusted
#define DAC_INTERNAL_VREF                       1 //!<
#define DAC_OUTPUT_DRIVER                       1 //!<


//! @defgroup COMPARATORs_defines_configuration_values COMPARATORs Defines Configuration Values
//! Defines allowing to init the COMPARATORs with the wanted configuration
//! @{
#define USE_COMP0
#define COMPARATOR0_IT                          1 //!< 0: Disable Comparator Interrupt    1: Enable Comparator Interrupt
#define COMPARATOR0_IT_EVENT                    0 //!< Comparator Interrupt on outut => 0: toggle     2: falling edge     3: rising edge
#define COMPARATOR0_NEGATIVE_INPUT              4 //!< Comparator negative input selection => 0: vref/6.40  1: vref/3.20  2: vref/2.13  3: vref/1.60  4: ACMPM  5: DAC result

#define USE_COMP1
#define COMPARATOR1_IT                          1 //!< 0: Disable Comparator Interrupt    1: Enable Comparator Interrupt
#define COMPARATOR1_IT_EVENT                    0 //!< Comparator Interrupt on outut => 0: toggle     2: falling edge     3: rising edge
#define COMPARATOR1_NEGATIVE_INPUT              4 //!< Comparator negative input selection => 0: vref/6.40  1: vref/3.20  2: vref/2.13  3: vref/1.60  4: ACMPM  5: DAC result

#define USE_COMP2
#define COMPARATOR2_IT                          1 //!< 0: Disable Comparator Interrupt    1: Enable Comparator Interrupt
#define COMPARATOR2_IT_EVENT                    0 //!< Comparator Interrupt on outut => 0: toggle     2: falling edge     3: rising edge
#define COMPARATOR2_NEGATIVE_INPUT              4 //!< Comparator negative input selection => 0: vref/6.40  1: vref/3.20  2: vref/2.13  3: vref/1.60  4: ACMPM  5: DAC result

