programa creado en CodeWarrior para crear un piano musical mediante el uso de la tarjeta kl46z.

Dependencies:   mbed

main.cpp

Committer:
ErickDDD
Date:
2019-05-31
Revision:
0:48bf0a15417a

File content as of revision 0:48bf0a15417a:

/* ###########################################################################
**    Archivo        : main.c
**    Proyecto       : FRDM-KL46Z_Plantilla
**    Procesador     : MKL46Z256VLL4
**    Herramienta    : CodeWarrior
**    Version        : Driver 01.01
**    Compilador     : GNU C Compiler
**    Fecha/Hora     : 14-07-2015, 11:48, # CodeGen: 0
**    Descripción    :
**         Este proyecto crea un piano capaz de tocar diferentes octavas 
**         musicales y piezas musicales enteras con la implementacion de la tarjeta
**         KL46Z .
**         This module contains user's application code.
**   Componentes     : Bocina, transistor 2N2222, Membrana de teclado.
**   Configuraciones : Includes, Stacks y Drivers externos
**   Autores         : Garcia Chavez Erick Fabian
**         ATEAM Development Group:
**          - Antulio Morgado Valle
**
**   Versión        : Beta
**   Revisión       : A
**   Release        : 0
**   Bugs & Fixes   :
**   Date           : 18/05/2019
**                    Added support for Led_RGB
**                    22/09/2018 
**                    Added LCD Menu, Beta version (with bugs)
**
* ###########################################################################/
/*
::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
:  Includes
::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
*/

#include "Cpu.h"
#include "Events.h"
#include "R1.h"
#include "BitIoLdd1.h"
#include "R2.h"
#include "BitIoLdd2.h"
#include "R3.h"
#include "BitIoLdd3.h"
#include "R4.h"
#include "BitIoLdd4.h"
#include "C1.h"
#include "BitIoLdd5.h"
#include "C2.h"
#include "BitIoLdd6.h"
#include "C3.h"
#include "BitIoLdd7.h"
#include "C4.h"
#include "BitIoLdd8.h"
#include "PTA.h"
#include "PPG1.h"
#include "PpgLdd1.h"
#include "WAIT1.h"
#include "MCUC1.h"
#include "PE_Types.h"
#include "PE_Error.h"
#include "PE_Const.h"
#include "IO_Map.h"
int i;
float r;
int main(void)
{
  i=880;
  r=1.059463;
  PE_low_level_init();
  
  for(;;){
      R1_ClrVal();
      R2_SetVal();
      R3_SetVal();
      R4_SetVal();
      if(C1_GetVal()==0){
          
      PPG1_SetFreqHz(i/(r*r*r*r*r*r*r*r*r));
      }
      else if(C2_GetVal()==0){
      PPG1_SetFreqHz(i/(r*r*r*r*r*r*r*r));
      }  
      else if(C3_GetVal()==0){
      PPG1_SetFreqHz(i/(r*r*r*r*r*r*r));
      }  
      else if(C4_GetVal()==0){
      PPG1_SetFreqHz(i/(r*r*r*r*r*r));
      }  
      R1_SetVal();
          R2_ClrVal();
          R3_SetVal();
          R4_SetVal();
          if(C1_GetVal()==0){
              
          PPG1_SetFreqHz(i/(r*r*r*r*r));
          }
          else if(C2_GetVal()==0){
          PPG1_SetFreqHz(i/(r*r*r*r));
          }  
          else if(C3_GetVal()==0){
          PPG1_SetFreqHz(i/(r*r*r));
          }  
          else if(C4_GetVal()==0){
          PPG1_SetFreqHz(i/(r*r));
          }  
          
        R1_SetVal();
                  R2_SetVal();
                  R3_ClrVal();
                  R4_SetVal();
                  if(C1_GetVal()==0){
                      
                  PPG1_SetFreqHz(i/r);
                  }
                  else if(C2_GetVal()==0){
                  PPG1_SetFreqHz(i);
                  }  
                  else if(C3_GetVal()==0){
                  PPG1_SetFreqHz(i*r);
                  }  
                  else if(C4_GetVal()==0){
                  PPG1_SetFreqHz(i*r*r);
                  }  
        
                 R1_SetVal();
                 R2_SetVal();
                R3_SetVal();
                R4_ClrVal();
                if(C1_GetVal()==0){
                PPG1_SetFreqHz(i*r*r*r);
                }
                else if(C4_GetVal()==0){
                    PPG1_SetFreqHz(146.832);
                    WAIT1_Waitms(250);
                PPG1_SetFreqHz(440);
                WAIT1_Waitms(500);
              PPG1_SetFreqHz(164.814);
              WAIT1_Waitms(175);
            PPG1_SetFreqHz(329.628);
            WAIT1_Waitms(175);
            PPG1_SetFreqHz(493.833);
            WAIT1_Waitms(500);
PPG1_SetFreqHz(174.614);
    WAIT1_Waitms(250);
                        
                            PPG1_SetFreqHz(523.251);
                            WAIT1_Waitms(500);
                        PPG1_SetFreqHz(164.814);
                                      WAIT1_Waitms(175);
                                    PPG1_SetFreqHz(329.628);
                                    WAIT1_Waitms(175);
                                    PPG1_SetFreqHz(493.833);
                                    WAIT1_Waitms(500);
                    
                                    
                                    
                                PPG1_SetFreqHz(146.832);
                                                WAIT1_Waitms(250);
                                                PPG1_SetFreqHz(440);
                                                WAIT1_Waitms(500);
                                          PPG1_SetFreqHz(164.814);
                                          WAIT1_Waitms(175);
                                        PPG1_SetFreqHz(329.628);
                                        WAIT1_Waitms(175);
                                        PPG1_SetFreqHz(493.833);
                                        WAIT1_Waitms(500);
                            PPG1_SetFreqHz(174.614);
                                WAIT1_Waitms(250);
                                                        PPG1_SetFreqHz(523.251);
                                                            WAIT1_Waitms(500);
                                                    PPG1_SetFreqHz(164.814);
                                                                  WAIT1_Waitms(175);
                                                                PPG1_SetFreqHz(329.628);
                                                                WAIT1_Waitms(175);
                                                                PPG1_SetFreqHz(493.833);
                                                                WAIT1_Waitms(500);
                                                                
                                                        PPG1_SetFreqHz(587.330);
                                                            WAIT1_Waitms(175);
                                                            PPG1_SetFreqHz(698.456);
                                                    WAIT1_Waitms(175);
                                                    PPG1_SetFreqHz(1174.66);
                                                WAIT1_Waitms(500);
                                                PPG1_SetFreqHz(587.330);
                                                    WAIT1_Waitms(175);
                                                    PPG1_SetFreqHz(698.456);
                                            WAIT1_Waitms(175);
                                            PPG1_SetFreqHz(1174.66);
                                        WAIT1_Waitms(500);
                                    PPG1_SetFreqHz(1318.514);
                                        WAIT1_Waitms(350);
                                    PPG1_SetFreqHz(1396.91);
                                        WAIT1_Waitms(175);
                                    PPG1_SetFreqHz(11318.514);
                                        WAIT1_Waitms(200);
                                    PPG1_SetFreqHz(1396.91);
                                        WAIT1_Waitms(200);
                                    PPG1_SetFreqHz(1318.514);
                                        WAIT1_Waitms(200);
                                    PPG1_SetFreqHz(1046.50);
                                             WAIT1_Waitms(175); 
                                        PPG1_SetFreqHz(880);
                                        WAIT1_Waitms(500);
                                        
                                    PPG1_SetFreqHz(880);
                                                                WAIT1_Waitms(150);
                                                            PPG1_SetFreqHz(587.330);
                                                                          WAIT1_Waitms(175);
                                                                        PPG1_SetFreqHz(698.456);
                                                                        WAIT1_Waitms(250);
                                                                        PPG1_SetFreqHz(783.991);
                                                                        WAIT1_Waitms(250);
                                                                        PPG1_SetFreqHz(880);
                                                                    WAIT1_Waitms(500);
                                                                    
                                                                    
                                                                    PPG1_SetFreqHz(880);
                                                                    WAIT1_Waitms(150);
                                                                PPG1_SetFreqHz(587.330);
                                                                              WAIT1_Waitms(175);
                                                                            PPG1_SetFreqHz(698.456);
                                                                            WAIT1_Waitms(250);
                                                                            PPG1_SetFreqHz(783.991);
                                                                            WAIT1_Waitms(250);
                                                                            PPG1_SetFreqHz(659.255);
                                                                        WAIT1_Waitms(500);PPG1_SetFreqHz(587.330);
                                                                        WAIT1_Waitms(175);
                                                                        PPG1_SetFreqHz(698.456);
                                                                WAIT1_Waitms(175);
                                                                PPG1_SetFreqHz(1174.66);
                                                            WAIT1_Waitms(500);
                                                            PPG1_SetFreqHz(587.330);
                                                                WAIT1_Waitms(175);
                                                                PPG1_SetFreqHz(698.456);
                                                        WAIT1_Waitms(175);
                                                        PPG1_SetFreqHz(1174.66);
                                                    WAIT1_Waitms(500);
                                                PPG1_SetFreqHz(1318.514);
                                                    WAIT1_Waitms(350);
                                                PPG1_SetFreqHz(1396.91);
                                                    WAIT1_Waitms(175);
                                                PPG1_SetFreqHz(11318.514);
                                                    WAIT1_Waitms(200);
                                                PPG1_SetFreqHz(1396.91);
                                                    WAIT1_Waitms(200);
                                                PPG1_SetFreqHz(1318.514);
                                                    WAIT1_Waitms(200);
                                                PPG1_SetFreqHz(1046.50);
                                                         WAIT1_Waitms(175); 
                                                    PPG1_SetFreqHz(880);
                                                    WAIT1_Waitms(500);
                                                    
                                                PPG1_SetFreqHz(880);
                                                                            WAIT1_Waitms(150);
                                                                        PPG1_SetFreqHz(587.330);
                                                                                      WAIT1_Waitms(175);
                                                                                    PPG1_SetFreqHz(698.456);
                                                                                    WAIT1_Waitms(250);
                                                                                    PPG1_SetFreqHz(783.991);
                                                                                    WAIT1_Waitms(250);
                                                                                    PPG1_SetFreqHz(880);
                                                                                WAIT1_Waitms(500);
                                                                                
                                                                                
                                                                                PPG1_SetFreqHz(880);
                                                                                WAIT1_Waitms(150);
                                                                            PPG1_SetFreqHz(587.330);
                                                                                          WAIT1_Waitms(175);
                                                                                        PPG1_SetFreqHz(698.456);
                                                                                        WAIT1_Waitms(250);
                                                                                        PPG1_SetFreqHz(783.991);
                                                                                        WAIT1_Waitms(250);
                                                                                        PPG1_SetFreqHz(659.255);
                                                                                    WAIT1_Waitms(500);
                    
                                                                        

                                                
                    
                }
                                  

  }

  #ifdef PEX_RTOS_START
    PEX_RTOS_START();              
  #endif
 } 

    }
}