/*
 * waves.h
 *
 * Created: 08/11/2016 13:26:28
 *  Author: Ledo
 */ 


#ifndef WAVES_H_
#define WAVES_H_

#include <avr32/io.h>
#include "pwm4.h"
#include "scif_uc3c.h"
#include <stdbool.h>
#include "gpio.h"
#include "sysclk.h"
#include "globales.h"

// pwm 0 es usado para atacar el mosfet
//pwm 1 es usado para generar la salida de audio, atraves del Dac0
#  define PWM_L_PIN             AVR32_PWM_PWML_0_2_PIN
#  define PWM_L_FUNCTION        AVR32_PWM_PWML_0_0_FUNCTION
#  define PWM_H_PIN             AVR32_PWM_PWMH_0_0_PIN
#  define PWM_H_FUNCTION        AVR32_PWM_PWMH_0_0_FUNCTION
#  define PWM_CHANNEL_ID        0

#define SOUND_PER_MIN           2000L
#define SOUND_PER_MAX           20000L


  pwm_opt_t pwm_opt;                // PWM option config.
  avr32_pwm_channel_t pwm_channel = {{0}, // cmr
  {0}, // cdty
  {0}, // cdtyupd
  {0}, // cprd
  {0}, // cprdupd
  {0}, // ccnt
  {0}, // dt
  {0}};// dtupd  ;  One channel config.
	  
  avr32_pwm_channel_t pwm_channel1;	  
  unsigned int channel_id;

 //prototipos 
 void  waves_init(void);
 void Mosfet_gate_pulse_update(void);
 void sinusInit(void);
 __attribute__((__interrupt__))
 static void pwm_int_handler(void);
extern void dac_set_value(uint16_t value);
extern void sinus(uint8_t volume, uint8_t signal);
extern void LeerV(void);

#endif /* WAVES_H_ */