PROGRAMA FINAL
PROCESSOR EXPERT
/*
###################################################################
** Filename
: ProcessorExpert.c
** Project
: ProcessorExpert
** Processor
: MKL25Z128VLK4
** Version
: Driver 01.01
** Compiler
: GNU C Compiler
** Date/Time
: 2013-09-10, 12:55, # CodeGen: 0
** Abstract
:
** Main module.
** This module contains user's
application code.
** Settings
:
** Contents
:
** No public methods
**
** ###################################################################*/
/*!
** @file ProcessorExpert.c
** @version 01.01
** @brief
** Main module.
** This module contains user's
application code.
*/
/*!
** @addtogroup ProcessorExpert_module
ProcessorExpert module documentation
** @{
*/
/* MODULE ProcessorExpert */
/* Including needed modules to
compile this module/procedure */
#include "Cpu.h"
#include "Events.h"
#include "led_1.h"
#include "BitIoLdd1.h"
#include "AS1.h"
#include "ASerialLdd1.h"
#include "led_2.h"
#include "BitIoLdd2.h"
#include "led_3.h"
#include "BitIoLdd3.h"
#include "led_4.h"
#include "BitIoLdd4.h"
#include "led_5.h"
#include "BitIoLdd5.h"
#include "led_6.h"
#include "BitIoLdd6.h"
#include "timer.h"
#include "TimerIntLdd1.h"
#include "TU1.h"
/* Including shared modules,
which are used for whole project */
#include "PE_Types.h"
#include "PE_Error.h"
#include "PE_Const.h"
#include "IO_Map.h"
void inicio(void);
void f_p_inicio(void);
void f_p_llenado(void);
void f_p_llenado2(void);
void f_p_lavado(void);
void f_p_lavado2(void);
void f_p_enjuague(void);
void f_p_enjuague2(void);
void f_p_secado(void);
void f_p_secado2(void);
void f_p_fin(void);
void f_p_espera1(void);
void f_p_espera2(void);
void f_indicador(void);
#define T_P1_INI 30
#define T_P2_LLEN 50
#define T_P3_LAV 50
#define T_P4_ENJ 50
#define T_P5_SEC 50
#define T_P6_FIN 30
#define T_P7_ESP 80
#define T_P0_AP 15
enum procesos{p_inicio,p_llenado,p_lavado,p_enjuague,p_secado,p_fin,p_espera1,p_espera2};
extern int timer;
int sig_proceso,ind=0;
byte men_01[]="\nEncendido\n\r";
byte men_02[]="\nInicio llenado\n\r";
byte men_03[]="Fin llenado\n\r\n Inicio lavado\n\r";
byte men_04[]="Fin Lavado\n\r\n Inicio Enjuague\n\r";
byte men_05[]="Fin Enjuague\n\r\n Inicio Secado\n\r";
byte men_06[]="Fin Secado\n\r\n Fin del proceso\n\r";
byte men_10[]="Fin del Proceso\n\r\nEn Espera \n\r";
byte men_12[]="APAGADO\n\r";
byte men_11[]=" Pronto se reiniciara
el proceso nuevamente\n\r";
byte men_13[]="\nPresione la tecla ENTER para detener
el reinicio el Proceso\n\r";
extern AS1_TComData ch_copia;
byte *ap_men;
/* User includes (#include
below this line is not maintained by Processor Expert) */
/*lint -save -e970 Disable MISRA rule (6.3) checking. */
int main(void)
/*lint -restore Enable MISRA
rule (6.3) checking. */
{
/* Write your local
* variable definition here */
/*** Processor Expert internal initialization.
DON'T REMOVE THIS CODE!!! ***/
PE_low_level_init();
/*** End of Processor Expert internal initialization. ***/
/* Write your code here */
/* For example: for(;;) { } */
inicio();
for(;;)
{
while(timer)
{
}
switch (sig_proceso)
{
case p_inicio:
f_p_inicio();
break;
case p_llenado:
f_p_llenado();
break;
case p_lavado:
f_p_lavado();
break;
case p_enjuague:
f_p_enjuague();
break;
case p_secado:
f_p_secado();
break;
case p_fin:
f_p_fin();
break;
case p_espera1:
f_p_espera1();
break;
case p_espera2:
f_p_espera2();
break;
}
}
/*** Don't write any code pass this
line, or it will be deleted during code generation. ***/
/*** RTOS startup code. Macro
PEX_RTOS_START is defined by the RTOS component. DON'T MODIFY THIS CODE!!! ***/
#ifdef PEX_RTOS_START
PEX_RTOS_START(); /* Startup of the selected RTOS.
Macro is defined by the RTOS component. */
#endif
/*** End of RTOS startup code. ***/
/*** Processor Expert end of main
routine. DON'T MODIFY THIS CODE!!! ***/
for(;;){}
/*** Processor Expert end of main
routine. DON'T WRITE CODE BELOW!!! ***/
} /*** End of main routine. DO NOT MODIFY THIS TEXT!!! ***/
/* END ProcessorExpert */
/*!
** @}
*/
/*
**
###################################################################
**
** This file was created by Processor Expert
10.2 [05.06]
** for the Freescale Kinetis
series of microcontrollers.
**
**
###################################################################
*/
void inicio(void)
{
sig_proceso=0;
timer=0;
}
void f_p_inicio(void)
{
ap_men=men_01;
AS1_SendChar(*ap_men);
led_1_SetVal();
led_6_ClrVal();
timer=T_P1_INI;
sig_proceso=p_llenado;
}
void f_p_llenado(void)
{
ap_men=men_02;
AS1_SendChar(*ap_men);
led_2_SetVal();
timer=T_P2_LLEN;
sig_proceso=p_lavado;
}
void f_p_lavado(void)
{
timer=T_P3_LAV;
led_3_SetVal();
led_2_ClrVal();
ap_men=men_03;
AS1_SendChar(*ap_men);
sig_proceso=p_enjuague;
}
void f_p_enjuague(void)
{
timer=T_P4_ENJ;
led_4_SetVal();
led_3_ClrVal();
ap_men=men_04;
AS1_SendChar(*ap_men);
sig_proceso=p_secado;
}
void f_p_secado(void)
{
timer=T_P5_SEC;
led_5_SetVal();
led_4_ClrVal();
ap_men=men_05;
AS1_SendChar(*ap_men);
sig_proceso=p_fin;
}
void f_p_fin(void)
{
timer=T_P6_FIN;
led_6_SetVal();
led_5_ClrVal();
ap_men=men_10;
AS1_SendChar(*ap_men);
sig_proceso=p_espera1;
}
void f_p_espera1(void)
{
timer=T_P6_FIN;
ap_men=men_13;
AS1_SendChar(*ap_men);
sig_proceso=p_espera2;
}
void f_p_espera2(void)
{
if(ind==0)
{
timer=T_P7_ESP;
ap_men=men_11;
AS1_SendChar(*ap_men);
if(ch_copia=='\r')
{
led_6_ClrVal();
ap_men=men_12;
AS1_SendChar(*ap_men);
led_1_ClrVal();
ind=1;
}
else
sig_proceso=p_inicio;
}
}
EVENT C
/* ###################################################################
** Filename
: Events.c
** Project
: ProcessorExpert
** Processor
: MKL25Z128VLK4
** Component
: Events
** Version
: Driver 01.00
** Compiler
: GNU C Compiler
** Date/Time
: 2013-09-10, 12:55, # CodeGen: 0
** Abstract
:
** This is user's event module.
** Put your event handler code here.
** Settings
:
** Contents
:
** Cpu_OnNMIINT - void Cpu_OnNMIINT(void);
**
**
###################################################################*/
/*!
** @file Events.c
** @version 01.00
** @brief
** This is user's event module.
** Put your event handler code here.
*/
/*!
** @addtogroup Events_module Events
module documentation
** @{
*/
/* MODULE Events */
#include "Cpu.h"
#include "Events.h"
#ifdef __cplusplus
extern "C" {
#endif
int timer;
AS1_TComData ch_copia;
// TComData type is defined in the AS1.h
header file
extern byte *ap_men;
/* User includes (#include
below this line is not maintained by Processor Expert) */
/*
**
===================================================================
** Event
: Cpu_OnNMIINT (module Events)
**
** Component
: Cpu [MKL25Z128LK4]
** Description :
** This event is called when the Non maskable
interrupt had
** occurred. This event is automatically
enabled when the <NMI
** interrupt> property is set to
'Enabled'.
** Parameters
: None
** Returns
: Nothing
**
===================================================================
*/
void Cpu_OnNMIINT(void)
{
/* Write your code here ... */
}
/*
** ===================================================================
** Event
: AS1_OnError (module Events)
**
** Component
: AS1 [AsynchroSerial]
** Description :
** This event is called when a channel
error (not the error
** returned by a given method) occurs. The
errors can be read
** using <GetError> method.
** The event is available only when the
<Interrupt
** service/event> property is enabled.
** Parameters
: None
** Returns
: Nothing
**
===================================================================
*/
void AS1_OnError(void)
{
/* Write your code here ... */
}
/*
**
===================================================================
** Event
: AS1_OnRxChar (module Events)
**
** Component
: AS1 [AsynchroSerial]
** Description :
** This event is called after a correct
character is received.
** The event is available only when the
<Interrupt
** service/event> property is enabled
and either the <Receiver>
** property is enabled or the <SCI
output mode> property (if
** supported) is set to Single-wire mode.
** Parameters
: None
** Returns
: Nothing
**
===================================================================
*/
void AS1_OnRxChar(void)
{
/* Write your code here ... */
{
AS1_TComData ch; // TComData type is defined in the AS1.h header file
//Read
received character and send it if no error is detected
if(AS1_RecvChar(&ch) == ERR_OK)
AS1_SendChar(ch);
ch_copia=ch;
}
}
/*
**
===================================================================
** Event
: AS1_OnTxChar (module Events)
**
** Component
: AS1 [AsynchroSerial]
** Description :
** This event is called after a character
is transmitted.
** Parameters
: None
** Returns
: Nothing
**
===================================================================
*/
void AS1_OnTxChar(void)
{
/* Write your code here ... */
++
ap_men;
if(*ap_men)
AS1_SendChar(*ap_men);
}
/*
**
===================================================================
** Event
: timer_OnInterrupt (module
Events)
**
** Component
: timer [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 timer_OnInterrupt(void)
{
if(timer>0)
{
timer --;
/* Write your code
here ... */
} /* Write your code here ... */
}
/* END Events */
#ifdef __cplusplus
} /* extern "C" */
#endif
/*!
** @}
*/
/*
**
###################################################################
**
** This file was created by Processor Expert
10.2 [05.06]
** for the Freescale Kinetis
series of microcontrollers.
**
**
###################################################################
*/
No hay comentarios:
Publicar un comentario