Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /** ###################################################################
- ** Filename : Events.c
- ** Project : jogo_pong
- ** Processor : MC9S12C32CFU16
- ** Component : Events
- ** Version : Driver 01.04
- ** Compiler : CodeWarrior HC12 C Compiler
- ** Date/Time : 14/06/2018, 15:08
- ** Abstract :
- ** This is user's event module.
- ** Put your event handler code here.
- ** Settings :
- ** Contents :
- ** No public methods
- **
- ** ###################################################################*/
- /* MODULE Events */
- #include "Cpu.h"
- #include "Events.h"
- /* User includes (#include below this line is not maintained by Processor Expert) */
- #pragma CODE_SEG DEFAULT
- /*
- ** ===================================================================
- ** Event : TI1_OnInterrupt (module Events)
- **
- ** Component : TI1 [TimerInt]
- ** Description :
- ** When a timer interrupt occurs this event is called (only
- ** when the component is enabled - <Enable> and the events are
- ** enabled - <EnableEvent>). This event is enabled only if a
- ** <interrupt service/event> is enabled.
- ** Parameters : None
- ** Returns : Nothing
- ** ===================================================================
- */
- unsigned int a=0,b=0,c=0,d=0,somatotal=0,somatotal2=0, cont1,cont2;
- unsigned int e=0,f=0,g=0,h=0;
- unsigned int acionador1,acionador2, jogador1=0,jogador2=0;
- void TI1_OnInterrupt(void)
- {
- /* Write your code here ... */
- //ACIONADOR 1
- if(!(SW2_GetVal())){
- acionador1=1;
- }
- if(acionador1==1){
- LED04_ClrVal();
- a=a+10;
- if(a>1000)
- {
- a=1500;
- LED04_SetVal();
- LED03_ClrVal();
- }
- b=b+10;
- if(b>2000)
- {
- b=2500;
- LED03_SetVal();
- LED02_ClrVal();
- }
- c=c+10;
- if(c>3000)
- {
- c=3500;
- LED02_SetVal();
- LED01_ClrVal();
- }
- d=d+10;
- if(d>4000)
- {
- d=4500;
- LED01_SetVal();
- }
- }
- somatotal=a+b+c+d;
- if(somatotal>=12000)
- {
- acionador1=0;
- a=0;
- b=0;
- c=0;
- d=0;
- }
- }
- /*
- ** ===================================================================
- ** Event : TI2_OnInterrupt (module Events)
- **
- ** Component : TI2 [TimerInt]
- ** Description :
- ** When a timer interrupt occurs this event is called (only
- ** when the component is enabled - <Enable> and the events are
- ** enabled - <EnableEvent>). This event is enabled only if a
- ** <interrupt service/event> is enabled.
- ** Parameters : None
- ** Returns : Nothing
- ** ===================================================================
- */
- void TI2_OnInterrupt(void)
- {
- //ACIONADOR 2
- if(!(SW1_GetVal())){
- acionador2=1;
- }
- if(acionador2==1){
- LED01_ClrVal();
- e=e+10;
- if(e>1000)
- {
- e=1500;
- LED01_SetVal();
- LED02_ClrVal();
- }
- f=f+10;
- if(f>2000)
- {
- f=2500;
- LED02_SetVal();
- LED03_ClrVal();
- }
- g=g+10;
- if(g>3000)
- {
- g=3500;
- LED03_SetVal();
- LED04_ClrVal();
- }
- h=h+10;
- if(h>4000)
- {
- h=4500;
- LED04_SetVal();
- }
- }
- somatotal2=e+f+g+h;
- if(somatotal2>=12000)
- {
- acionador2=0;
- e=0;
- f=0;
- g=0;
- h=0;
- }
- }
- /*
- ** ===================================================================
- ** Event : TI3_OnInterrupt (module Events)
- **
- ** Component : TI3 [TimerInt]
- ** Description :
- ** When a timer interrupt occurs this event is called (only
- ** when the component is enabled - <Enable> and the events are
- ** enabled - <EnableEvent>). This event is enabled only if a
- ** <interrupt service/event> is enabled.
- ** Parameters : None
- ** Returns : Nothing
- ** ===================================================================
- */
- void TI3_OnInterrupt(void)
- {
- //CONTAGEM JOGADOR 1
- cont1=0;
- if(acionador2==1){ //colocar accionador
- cont1=-1;
- }
- if(somatotal==12000){
- jogador1=jogador1+1+cont1;
- }
- //CONTAGEM JOGADOR 2
- cont2=0;
- if(acionador1==1){ //colocar accionador
- cont2=-1;
- }
- if(somatotal2==12000){
- jogador2=jogador2+1+cont2;
- }
- //PLACAR 1
- if(jogador1==3)
- {
- LED01_ClrVal();
- LED02_ClrVal();
- LED03_ClrVal();
- LED04_ClrVal();
- }
- //PLACAR 2
- if(jogador2==3)
- {
- LED01_ClrVal();
- LED02_ClrVal();
- LED03_ClrVal();
- LED04_ClrVal();
- }
- }
- /* END Events */
- /*
- ** ###################################################################
- **
- ** This file was created by Processor Expert 3.02 [04.44]
- ** for the Freescale HCS12 series of microcontrollers.
- **
- ** ###################################################################
- */
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement