/**
 * Programa para detector de metales del tipo PI (Pulse Induction)
 * CHIP: AT32UC3C264C  (32 bits)
 * Autor: José Emilio Ledo Galano
 */

#ifndef _MAIN_H_
#define _MAIN_H_

#include <asf.h>
#include <math.h>
#include <string.h>
#include <stdio.h>
#include "conf_board.h"
#include "conf_clock.h"
#include "config/conf_usb.h"
#include "tmrs.h"
#include "rs485.h"
#include "intc.h"
#include "flashc.h"
#include "globales.h"
#include "delay.h"
#include "lcd.h"
#include "eic.h"

int16_t VBuffer[250];
int16_t IBuffer[250];
//int16_t ABuffer[1000];
uint16_t a_buffer_index;
uint8_t v_buffer_index;
uint16_t i_buffer_index;
int16_t adc_ntc;
int16_t adc_I;
int16_t adc_V;
float V;
int16_t I;
float T;
int16_t iArea;
int16_t offset;
PARAMETROS Params;
FLAGS flags;




void chip_init(void);
void Muestreo_analogicas(void);
int16_t CalculoI(void);
float CalculoT(int16_t adc_value);
void cmd_decode(void);
void usb_tx(void);
void Read_flash_params(void);
void Set_default(void);
void params_save(void);
void external_interrupt_init(void);
void initEIC(void);
int16_t Area(void);
void LeerV(void);
extern void Read_adc_values(int16_t * adc_values[]);
extern void adc_init(uint8_t gain);
extern int8_t adc_offset(void);
extern void dac_init(void);
extern void dac_set_value(uint16_t value);
extern void dac1_set_value(uint16_t value);
extern void sinus(uint8_t volumen,uint8_t signal);
//extern void pwmInicio (void);
extern void sound_update(int16_t signal_level);
#endif // _MAIN_H_
