37
GPRS - MEF v.1.0 Reference Manual Lic. Antonio Pavanetto Wed Apr 18 16:54:40 2007

GPRS_MEF_1

Embed Size (px)

Citation preview

Page 1: GPRS_MEF_1

GPRS - MEF v.1.0 Reference ManualLic. Antonio Pavanetto

Wed Apr 18 16:54:40 2007

Page 2: GPRS_MEF_1
Page 3: GPRS_MEF_1

Contents

1 GPRS - MEF v.1.0 Main Page 1

2 GPRS - MEF v.1.0 File Index 3

2.1 GPRS - MEF v.1.0 File List . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3

3 GPRS - MEF v.1.0 Page Index 5

3.1 GPRS - MEF v.1.0 Related Pages . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5

4 GPRS - MEF v.1.0 File Documentation 7

4.1 aplicacion.c File Reference . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7

4.2 drivers.c File Reference . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 18

4.3 main.c File Reference . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 24

4.4 mcu.c File Reference . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 26

4.5 utiles.c File Reference . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 32

5 GPRS - MEF v.1.0 Page Documentation 35

5.1 Todo List . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 35

Lic. Antonio Pavanetto

Page 4: GPRS_MEF_1
Page 5: GPRS_MEF_1

Chapter 1

GPRS - MEF v.1.0 Main Page

GPRS TCP/IP

• Módulo G20 de Motorola(R)

• Microcontrolador MC9S08GT32

• Propiedad confidencial del Lic. Antonio Pavanetto

Author:

Lic. Antonio Pavanetto - Cursos ([email protected])FAE - Electrocomponentes S.A. (www.electrocomponentes.com)

Version:

0.1

Date:

Abril 2007

El trabajo fue realizado con CodeWarrior 5.0 SE

Lic. Antonio Pavanetto

Page 6: GPRS_MEF_1

2 GPRS - MEF v.1.0 Main Page

Lenguage C para uC

Page 7: GPRS_MEF_1

Chapter 2

GPRS - MEF v.1.0 File Index

2.1 GPRS - MEF v.1.0 File List

Here is a list of all files with brief descriptions:

aplicacion.c (Funciones de la Máquina de Estado Finito ) . . . . . . . . . . . . . . . . . . . . . 7drivers.c (Funciones de bajo nivel para la MEF ) . . . . . . . . . . . . . . . . . . . . . . . . . . 18main.c (Máquina de Estado Finito ) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 24mcu.c . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 26utiles.c . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 32

Lic. Antonio Pavanetto

Page 8: GPRS_MEF_1

4 GPRS - MEF v.1.0 File Index

Lenguage C para uC

Page 9: GPRS_MEF_1

Chapter 3

GPRS - MEF v.1.0 Page Index

3.1 GPRS - MEF v.1.0 Related Pages

Here is a list of all related documentation pages:

Todo List . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 35

Lic. Antonio Pavanetto

Page 10: GPRS_MEF_1

6 GPRS - MEF v.1.0 Page Index

Lenguage C para uC

Page 11: GPRS_MEF_1

Chapter 4

GPRS - MEF v.1.0 File Documentation

4.1 aplicacion.c File Reference

Funciones de la Máquina de Estado Finito.

#include "aplicacion.h"

#include "drivers.h"

#include "main.h"

#include "utiles.h"

Include dependency graph for aplicacion.c:

aplicacion.c

aplicacion.h

drivers.h

main.h

utiles.h

Functions

• void CB_tim1 (void)• byte f_idle1 (void)

Atento al teclado.

• byte f_rx1 (void)

Maneja buffer RX1.

• byte f_lex1 (void)

Interpreta el buffer 1.

• byte f_tx2 (void)

Envía el buffer 1 a TX2.

Lic. Antonio Pavanetto

Page 12: GPRS_MEF_1

8 GPRS - MEF v.1.0 File Documentation

• byte f_idle2 (void)

Atento al G20.

• byte f_rx2 (void)

Maneja buffer RX2.

• byte f_lex2 (void)

Interpreta el buffer 2.

• byte f_tx1 (void)

Envía el buffer 2 a TX1.

• byte f_start (void)• byte f_g20on (void)

Variables

• byte ReceivedByte1• byte ReceivedByte2• byte RXbuf1 [MAXBUF]• byte RXbuf2 [MAXBUF]• byte(∗const [ ]) f1 (void)• byte(∗const [ ]) f2 (void)

4.1.1 Detailed Description

Funciones de la Máquina de Estado Finito.

Author:

Lic. Antonio Pavanetto - Cursos ([email protected])FAE - Electrocomponentes S.A. (www.electrocomponentes.com)

Version:

0.1

Date:

Febrero 11 2007

Warning:

This file is in progress

History: 0.1 First documented Version Copyright (c) 2007

Definition in file aplicacion.c.

Lenguage C para uC

Page 13: GPRS_MEF_1

4.1 aplicacion.c File Reference 9

4.1.2 Function Documentation

4.1.2.1 void CB_tim1 (void)

Definition at line 276 of file aplicacion.c.

Referenced by isrVtpm1ovf().

277 {278 SEMAFORO2 = 0x01;279 }

Here is the caller graph for this function:

CB_tim1 isrVtpm1ovf

4.1.2.2 byte f_idle1 (void)

Atento al teclado.

Author:

Lic. Antonio Pavanetto ([email protected])

Parameters:

void

Returns:

{RX1|IDLE1}

Todo

Warning:

In progress

Definition at line 75 of file aplicacion.c.

References ReceivedByte1.

76 {77 if(ReceivedByte1 != ’\0’ ) /*Recibio dato?*/78 {79 return RX1;80 }81 else82 return IDLE1;83 }

Lic. Antonio Pavanetto

Page 14: GPRS_MEF_1

10 GPRS - MEF v.1.0 File Documentation

4.1.2.3 byte f_rx1 (void)

Maneja buffer RX1.

Author:

Lic. Antonio Pavanetto ([email protected])

Parameters:

void

Returns:

{RX1}

Todo

Warning:

In progress

Definition at line 94 of file aplicacion.c.

References ReceivedByte1, and RXbuf1.

95 {96 static byte pos = 0; /*Indice del buffer*/97 if( (ReceivedByte1 == ’\r’)) /*Recibe final de comando*/98 {99 RXbuf1[pos++] = ReceivedByte1; /*Pone final de cadena*/100 RXbuf1[pos++] = ’\n’; /*Pone final de cadena*/101 RXbuf1[pos] = ’\0’; /*Pone final de cadena*/102 ReceivedByte1 = 0x00; /*Limpia ReceivedByte1 */103 }104 else105 {106 if(pos < (MAXBUF - 3)) /*Max Indice - 1 (para el ’\0’)*/107 {108 RXbuf1[pos++] = ReceivedByte1; /*Guarda el byte y posiciona sig.*/109 ReceivedByte1 = 0; /*Limpia el caracter recibido*/110 return IDLE1; /*Busca siguiente byte*/111 }112 else113 { /*Supero dimension, finaliza*/114 RXbuf1[pos++] = ’\r’; /*Pone final de cadena*/115 RXbuf1[pos++] = ’\n’; /*Pone final de cadena*/116 RXbuf1[pos] = ’\0’; /*Pone final de cadena*/117 ReceivedByte1 = 0x00; /*Limpia ReceivedByte1 */118 }119120 }121122 pos = 0; /*Indice en 0*/123 return LEX1; /*Va a analizar la entrada*/124 }

4.1.2.4 byte f_lex1 (void)

Interpreta el buffer 1.

Lenguage C para uC

Page 15: GPRS_MEF_1

4.1 aplicacion.c File Reference 11

Author:

Lic. Antonio Pavanetto ([email protected])

Parameters:

void

Returns:

{RX1|IDLE1}

Todo

Hacer el intérprete, por ahora saca los datos por TX2

Warning:

In progress

Definition at line 133 of file aplicacion.c.

134 {135 return TX2;136 }

4.1.2.5 byte f_tx2 (void)

Envía el buffer 1 a TX2.

Author:

Lic. Antonio Pavanetto ([email protected])

Parameters:

void

Returns:

{IDLE}

Todo

Hacer el intérprete, por ahora saca los datos por TX1

Warning:

In progress

Definition at line 146 of file aplicacion.c.

References f_dtx2(), and RXbuf1.

147 {148 static byte pos = 0;149 if(RXbuf1[pos] == ’\0’) /* Fin de envío */150 {

Lic. Antonio Pavanetto

Page 16: GPRS_MEF_1

12 GPRS - MEF v.1.0 File Documentation

151 pos = 0;152 RXbuf1[0] = ’\0’;153 return IDLE1;154 }155 else156 {157 if(f_dtx2(RXbuf1[pos]))158 {159 pos++; /* No se queda a esperar la transmisión */160 }161 return TX2;162 }163 }

Here is the call graph for this function:

f_tx2 f_dtx2

4.1.2.6 byte f_idle2 (void)

Atento al G20.

Author:

Lic. Antonio Pavanetto ([email protected])

Parameters:

void

Returns:

{RX2|IDLE}

Todo

Warning:

In progress

Definition at line 176 of file aplicacion.c.

References ReceivedByte2.

177 {178 if(ReceivedByte2 != ’\0’ ) /*Recibio dato?*/179 {180 return RX2;181 }182 else183 return IDLE2;184 }

Lenguage C para uC

Page 17: GPRS_MEF_1

4.1 aplicacion.c File Reference 13

4.1.2.7 byte f_rx2 (void)

Maneja buffer RX2.

Author:

Lic. Antonio Pavanetto ([email protected])

Parameters:

void

Returns:

{RX2|IDLE}

Todo

Warning:

In progress

Definition at line 194 of file aplicacion.c.

References ReceivedByte2, and RXbuf2.

195 {196 static byte pos = 0; /*Indice del buffer*/197 if( (ReceivedByte2 == ’\r’)) /*Recibe final de comando*/198 {199 RXbuf2[pos++] = ReceivedByte2; /*Pone final de cadena*/200 RXbuf2[pos++] = ’\n’; /*Pone final de cadena*/201 RXbuf2[pos] = ’\0’; /*Pone final de cadena*/202 ReceivedByte2 = 0x00; /*Limpia ReceivedByte2 */203 }204 else205 {206 if(pos < (MAXBUF - 2)) /*Max Indice - 1 (para el ’\0’)*/207 {208 RXbuf2[pos++] = ReceivedByte2; /*Guarda el byte y posiciona sig.*/209 ReceivedByte2 = 0x00; /*Limpia el caracter recibido*/210 return IDLE2; /*Busca siguiente byte*/211 }212 else213 RXbuf2[pos] = ’\0’; /*Supero dimension, finaliza*/214 }215216 pos = 0; /*Indice en 0*/217 return LEX2; /*Va a analizar la entrada*/218 }

4.1.2.8 byte f_lex2 (void)

Interpreta el buffer 2.

Author:

Lic. Antonio Pavanetto ([email protected])

Lic. Antonio Pavanetto

Page 18: GPRS_MEF_1

14 GPRS - MEF v.1.0 File Documentation

Parameters:

void

Returns:

{RX2|IDLE}

Todo

Hacer el intérprete, por ahora saca los datos por TX1

Warning:

In progress

Definition at line 228 of file aplicacion.c.

229 {230231 return TX1;232 }

4.1.2.9 byte f_tx1 (void)

Envía el buffer 2 a TX1.

Author:

Lic. Antonio Pavanetto ([email protected])

Parameters:

void

Returns:

{IDLE}

Todo

Hacer el intérprete, por ahora saca los datos por TX1

Warning:

In progress

Definition at line 242 of file aplicacion.c.

References f_dtx1(), and RXbuf2.

243 {244 static byte pos = 0;245 if(RXbuf2[pos] == ’\0’) /* Fin de envío */246 {247 pos = 0;248 RXbuf2[0] = ’\0’;249 return IDLE2;

Lenguage C para uC

Page 19: GPRS_MEF_1

4.1 aplicacion.c File Reference 15

250 }251 else252 {253 if(f_dtx1(RXbuf2[pos]))254 {255 pos++; /* No se queda a esperar la transmisión */256 }257 return TX1;258 }259 }

Here is the call graph for this function:

f_tx1 f_dtx1

4.1.2.10 byte f_start (void)

Definition at line 260 of file aplicacion.c.

References f_dg20off(), and f_dtim1().

261 {262 f_dg20off();263 f_dtim1(1000);264 SEMAFORO2 = 0x00;265 return G20ON;266 }

Here is the call graph for this function:

f_start

f_dg20off

f_dtim1

4.1.2.11 byte f_g20on (void)

Definition at line 268 of file aplicacion.c.

References f_dg20on(), and f_dtim1().

269 {270 f_dg20on();271 f_dtim1(1000);272 SEMAFORO2 = 0x00;273 return IDLE2;274 }

Here is the call graph for this function:

f_g20on

f_dg20on

f_dtim1

Lic. Antonio Pavanetto

Page 20: GPRS_MEF_1

16 GPRS - MEF v.1.0 File Documentation

4.1.3 Variable Documentation

4.1.3.1 byte ReceivedByte1

Definition at line 44 of file aplicacion.c.

Referenced by f_idle1(), f_rx1(), and isrVsci1rx().

4.1.3.2 byte ReceivedByte2

Definition at line 44 of file aplicacion.c.

Referenced by f_idle2(), f_rx2(), and isrVsci2rx().

4.1.3.3 byte RXbuf1[MAXBUF]

Definition at line 45 of file aplicacion.c.

Referenced by f_rx1(), and f_tx2().

4.1.3.4 byte RXbuf2[MAXBUF]

Definition at line 45 of file aplicacion.c.

Referenced by f_rx2(), and f_tx1().

4.1.3.5 byte(∗ const[ ]) f1(void)

Initial value:

{f_idle1,f_rx1,f_lex1,f_tx2}

Definition at line 47 of file aplicacion.c.

Referenced by main().

4.1.3.6 byte(∗ const[ ]) f2(void)

Initial value:

{f_idle2,f_rx2,f_lex2,f_tx1,f_start,f_g20on}

Lenguage C para uC

Page 21: GPRS_MEF_1

4.1 aplicacion.c File Reference 17

Definition at line 55 of file aplicacion.c.

Referenced by main().

Lic. Antonio Pavanetto

Page 22: GPRS_MEF_1

18 GPRS - MEF v.1.0 File Documentation

4.2 drivers.c File Reference

Funciones de bajo nivel para la MEF.

#include <MC9S08GT32.h>

#include "aplicacion.h"

#include "drivers.h"

Include dependency graph for drivers.c:

drivers.c

MC9S08GT32.h

aplicacion.h

drivers.h

Functions

• byte f_dtx1 (byte dtx)

Envía caracter por SCI1.

• byte f_dtx2 (byte dtx)

Envía caracter por SCI2.

• void f_dg20off (void)

Apaga G20.

• void f_dg20on (void)

Enciende G20.

• void f_dtim1 (unsigned int delay)

Enciende timer 1.

Variables

• unsigned int count1• unsigned int count2

4.2.1 Detailed Description

Funciones de bajo nivel para la MEF.

Author:

Lic. Antonio Pavanetto - Cursos ([email protected])FAE - Electrocomponentes S.A. (www.electrocomponentes.com)

Lenguage C para uC

Page 23: GPRS_MEF_1

4.2 drivers.c File Reference 19

Version:

0.1

Date:

Abril 2007

Warning:

This file is in progress

History: 0.1 First documented Version Copyright (c) 2007

Definition in file drivers.c.

4.2.2 Function Documentation

4.2.2.1 byte f_dtx1 (byte dtx)

Envía caracter por SCI1.

Author:

Lic. Antonio Pavanetto ([email protected])

Parameters:

unsigned char

Returns:

void

Warning:

In progress

Definition at line 35 of file drivers.c.

Referenced by f_tx1().

36 {37 if (SCI1S1_TDRE) /* Espera que se vacie TX*/38 {39 PTDD_PTDD0 = 1;40 SCI1D = dtx; /* Envía dato */41 return 1;42 }43 else44 {45 PTDD_PTDD0 = 0;46 return 0;47 }48 }

Here is the caller graph for this function:

f_dtx1 f_tx1

Lic. Antonio Pavanetto

Page 24: GPRS_MEF_1

20 GPRS - MEF v.1.0 File Documentation

4.2.2.2 byte f_dtx2 (byte dtx)

Envía caracter por SCI2.

Author:

Lic. Antonio Pavanetto ([email protected])

Parameters:

unsigned char

Returns:

void

Warning:

In progress

Definition at line 56 of file drivers.c.

Referenced by f_tx2().

57 {58 if (SCI2S1_TDRE) /* Espera que se vacie TX*/59 {60 PTDD_PTDD0 = 1;61 SCI2D = dtx; /* Envía dato */62 return 1;63 }64 else65 {66 PTDD_PTDD0 = 0;67 return 0;68 }69 }

Here is the caller graph for this function:

f_dtx2 f_tx2

4.2.2.3 void f_dg20off (void)

Apaga G20.

Author:

Lic. Antonio Pavanetto ([email protected])

Parameters:

void

Returns:

void

Lenguage C para uC

Page 25: GPRS_MEF_1

4.2 drivers.c File Reference 21

Warning:

In progress

Definition at line 78 of file drivers.c.

Referenced by f_start().

79 {80 PTDD_PTDD0 = 1;81 PTCD_PTCD5 = 0;82 PTDD_PTDD4 = 1;83 }

Here is the caller graph for this function:

f_dg20off f_start

4.2.2.4 void f_dg20on (void)

Enciende G20.

Author:

Lic. Antonio Pavanetto ([email protected])

Parameters:

void

Returns:

void

Warning:

In progress

Definition at line 91 of file drivers.c.

Referenced by f_g20on().

92 {93 PTDD_PTDD0 = 0;94 PTCD_PTCD5 = 1;95 PTDD_PTDD4 = 0;96 }

Here is the caller graph for this function:

f_dg20on f_g20on

Lic. Antonio Pavanetto

Page 26: GPRS_MEF_1

22 GPRS - MEF v.1.0 File Documentation

4.2.2.5 void f_dtim1 (unsigned int delay)

Enciende timer 1.

Author:

Lic. Antonio Pavanetto ([email protected])

Parameters:

delay ms

Returns:

void

Warning:

In progress

Definition at line 104 of file drivers.c.

References count1.

Referenced by f_g20on(), and f_start().

105 {106 count1 = delay;107 TPM1SC = 0x4D;108 }

Here is the caller graph for this function:

f_dtim1

f_g20on

f_start

4.2.3 Variable Documentation

4.2.3.1 unsigned int count1

Definition at line 26 of file drivers.c.

Referenced by f_dtim1(), and isrVtpm1ovf().

4.2.3.2 unsigned int count2

Definition at line 26 of file drivers.c.

Lenguage C para uC

Page 27: GPRS_MEF_1

4.3 main.c File Reference 23

4.3 main.c File Reference

Máquina de Estado Finito.

#include "aplicacion.h"

#include "mcu.h"

#include "main.h"

Include dependency graph for main.c:

main.c

aplicacion.h

mcu.h

main.h

Functions

• void main (void)

Variables

• SEMAFORO semaforo

4.3.1 Detailed Description

Máquina de Estado Finito.

Author:

Lic. Antonio Pavanetto - Cursos ([email protected])FAE - Electrocomponentes S.A. (www.electrocomponentes.com)

Version:

0.1

Date:

Abril 2007

Warning:

This file is in progress

History: 0.1 First documented Version Copyright (c) 2007 Propiedad confidencial del Dpto. IngenieríaElectrocomponentes S.A.

Definition in file main.c.

Lic. Antonio Pavanetto

Page 28: GPRS_MEF_1

24 GPRS - MEF v.1.0 File Documentation

4.3.2 Function Documentation

4.3.2.1 void main (void)

Definition at line 92 of file main.c.

References f1, f2, and MCU_init().

93 {94 byte status1 = IDLE1 , status2 = START;95 MCU_init();96 SEMAFORO1 = SEMAFORO2 = 0x01;97 for(;;)98 {99 if(SEMAFORO1)100 status1 = f1[status1](); /*Usuario*/101 if(SEMAFORO2)102 status2 = f2[status2](); /*G20*/103 }104 }

Here is the call graph for this function:

main MCU_init

4.3.3 Variable Documentation

4.3.3.1 SEMAFORO semaforo

Definition at line 89 of file main.c.

Lenguage C para uC

Page 29: GPRS_MEF_1

4.4 mcu.c File Reference 25

4.4 mcu.c File Reference

#include <MC9S08GT60.h>

Include dependency graph for mcu.c:

mcu.c MC9S08GT60.h

Defines

• #define UNASSIGNED_ISR 0xFFFF

Functions

• void MCU_init (void)• __interrupt void isrVsci2tx (void)• __interrupt void isrVsci2rx (void)• __interrupt void isrVsci2err (void)• __interrupt void isrVsci1tx (void)• __interrupt void isrVsci1rx (void)• __interrupt void isrVsci1err (void)• __interrupt void isrVtpm1ovf (void)• __interrupt void isrVicg (void)• void _Startup (void)

Variables

• const volatile unsigned char NVPROT_INIT x0000FFBD = 0xFF• const volatile unsigned char NVOPT_INIT x0000FFBF = 0x7E• void(∗const _vect [ ])()

4.4.1 Define Documentation

4.4.1.1 #define UNASSIGNED_ISR 0xFFFF

Definition at line 289 of file mcu.c.

4.4.2 Function Documentation

4.4.2.1 void MCU_init (void)

Definition at line 36 of file mcu.c.

Referenced by main().

37 {38 /* ### MC9S08GT60_44 "Cpu" init code ... */39 /* PE initialization code after reset */40 /* System clock initialization */

Lic. Antonio Pavanetto

Page 30: GPRS_MEF_1

26 GPRS - MEF v.1.0 File Documentation

41 /* SOPT: COPE=0,COPT=1,STOPE=0,BKGDPE=1 */42 SOPT = 0x53;43 /* SPMSC1: LVDF=0,LVDACK=0,LVDIE=0,LVDRE=1,LVDSE=1,LVDE=1 */44 SPMSC1 = 0x1C;45 /* SPMSC2: LVWF=0,LVWACK=0,LVDV=0,LVWV=0,PPDF=0,PPDACK=0,PDC=0,PPDC=0 */46 SPMSC2 = 0x00;47 /* ICGC1: RANGE=1,REFS=1,CLKS1=0,CLKS0=1,OSCSTEN=1 */48 ICGC1 = 0x6C;49 /* ICGC2: LOLRE=0,MFD2=1,MFD1=1,MFD0=1,LOCRE=0,RFD2=0,RFD1=0,RFD0=0 */50 ICGC2 = 0x70;51 ICGTRM = *(unsigned char*far)0xFFBE; /* Initialize ICGTRM register from a non volatile memory */52 while(!ICGS1_LOCK) { /* Wait */53 }54 /* Common initialization of the write once registers */5556 /* Common initialization of the CPU registers */57 /* PTASE: PTASE7=0,PTASE6=0,PTASE5=0,PTASE4=0,PTASE3=0,PTASE2=0,PTASE1=0,PTASE0=0 */58 PTASE = 0x00;59 /* PTBSE: PTBSE7=0,PTBSE6=0,PTBSE5=0,PTBSE4=0,PTBSE3=0,PTBSE2=0,PTBSE1=0,PTBSE0=0 */60 PTBSE = 0x00;61 /* PTCSE: PTCSE6=0,PTCSE5=0,PTCSE4=0,PTCSE3=0,PTCSE2=0,PTCSE1=0,PTCSE0=0 */62 PTCSE &= (unsigned char)~0x7F;63 /* PTDSE: PTDSE4=0,PTDSE3=0,PTDSE1=0,PTDSE0=0 */64 PTDSE &= (unsigned char)~0x1B;65 /* PTESE: PTESE5=0,PTESE4=0,PTESE3=0,PTESE2=0,PTESE1=0,PTESE0=0 */66 PTESE &= (unsigned char)~0x3F;67 /* PTGSE: PTGSE2=0,PTGSE1=0,PTGSE0=0 */68 PTGSE &= (unsigned char)~0x07;69 /* ### Init_SCI init code */70 /* SCI1BD: SBR12=0,SBR11=0,SBR10=0,SBR9=0,SBR8=0,SBR7=1,SBR6=0,SBR5=0,SBR4=0,SBR3=0,SBR2=0,SBR1=1,SBR0=0 */71 SCI1BD = 0x82;72 /* SCI1C1: LOOPS=0,SCISWAI=0,RSRC=0,M=0,WAKE=0,ILT=0,PE=0,PT=0 */73 SCI1C1 = 0x00;74 /* SCI1C2: TIE=0,TCIE=0,RIE=1,ILIE=0,TE=1,RE=1,RWU=0,SBK=0 */75 SCI1C2 = 0x2C;76 /* SCI1C3: R8=0,T8=0,TXDIR=0,ORIE=0,NEIE=0,FEIE=0,PEIE=0 */77 SCI1C3 = 0x00;78 /* ### Init_SCI init code */79 /* SCI2BD: SBR12=0,SBR11=0,SBR10=0,SBR9=0,SBR8=0,SBR7=1,SBR6=0,SBR5=0,SBR4=0,SBR3=0,SBR2=0,SBR1=1,SBR0=0 */80 SCI2BD = 0x82;81 /* SCI2C1: LOOPS=0,SCISWAI=0,RSRC=0,M=0,WAKE=0,ILT=0,PE=0,PT=0 */82 SCI2C1 = 0x00;83 /* SCI2C2: TIE=0,TCIE=0,RIE=1,ILIE=0,TE=1,RE=1,RWU=0,SBK=0 */84 SCI2C2 = 0x2C;85 /* SCI2C3: R8=0,T8=0,TXDIR=0,ORIE=0,NEIE=0,FEIE=0,PEIE=0 */86 SCI2C3 = 0x00;87 /* ### Init_COP init code */88 SRS = 0xFF; /* Clear WatchDog counter */8990 /* ### Init_GPIO init code */91 /* PTADD: PTADD7=1,PTADD6=1,PTADD5=1,PTADD4=1,PTADD3=1,PTADD2=1,PTADD1=1,PTADD0=1 */92 PTADD = 0xFF;93 /* ### Init_GPIO init code */94 /* PTBD: PTBD7=0,PTBD6=0,PTBD5=0,PTBD4=0,PTBD3=0,PTBD2=0,PTBD1=0,PTBD0=0 */95 PTBD = 0x00;96 /* PTBDD: PTBDD7=1,PTBDD6=1,PTBDD5=1,PTBDD4=1,PTBDD3=1,PTBDD2=1,PTBDD1=0,PTBDD0=0 */97 PTBDD = 0xFC;98 /* ### Init_GPIO init code */99 /* PTCD: PTCD6=0,PTCD5=0,PTCD4=0,PTCD3=0,PTCD2=0 */100 PTCD &= (unsigned char)~0x7C;101 /* PTCDD: PTCDD6=1,PTCDD5=1,PTCDD4=0,PTCDD3=0,PTCDD2=1 */102 PTCDD = (PTCDD & (unsigned char)~0x18) | (unsigned char)0x64;103 /* ### Init_GPIO init code */104 /* PTDD: PTDD4=0,PTDD3=0,PTDD1=0,PTDD0=0 */105 PTDD &= (unsigned char)~0x1B;106 /* PTDDD: PTDDD4=1,PTDDD3=1,PTDDD1=0,PTDDD0=1 */107 PTDDD = (PTDDD & (unsigned char)~0x02) | (unsigned char)0x19;

Lenguage C para uC

Page 31: GPRS_MEF_1

4.4 mcu.c File Reference 27

108 /* ### Init_GPIO init code */109 /* PTEPE: PTEPE5=0,PTEPE4=0,PTEPE3=0,PTEPE2=0 */110 PTEPE &= (unsigned char)~0x3C;111 /* PTEDD: PTEDD5=1,PTEDD4=1,PTEDD3=1,PTEDD2=1 */112 PTEDD |= (unsigned char)0x3C;113 /* ### Init_TPM init code */114 TPM1MOD = 0x0270;115 /* TPM1SC: TOF=0,TOIE=1,CPWMS=0,CLKSB=0,CLKSA=1,PS2=1,PS1=0,PS0=1 */116 TPM1SC = 0x4D;117 /* ### */118 asm CLI; /* Enable interrupts */119 } /*MCU_init*/

Here is the caller graph for this function:

MCU_init main

4.4.2.2 __interrupt void isrVsci2tx (void)

Definition at line 132 of file mcu.c.

133 {134 /* Write your interrupt code here ... */135136 }

4.4.2.3 __interrupt void isrVsci2rx (void)

Definition at line 150 of file mcu.c.

References ReceivedByte2.

151 {152 extern unsigned char ReceivedByte2;153 (void)SCI2S1; /* Acknowledge Receiver Full Flag*/154 ReceivedByte2 = SCI2D;155 }

4.4.2.4 __interrupt void isrVsci2err (void)

Definition at line 169 of file mcu.c.

170 {171 /* Write your interrupt code here ... */172173 }

4.4.2.5 __interrupt void isrVsci1tx (void)

Definition at line 187 of file mcu.c.

Lic. Antonio Pavanetto

Page 32: GPRS_MEF_1

28 GPRS - MEF v.1.0 File Documentation

188 {189 /* Write your interrupt code here ... */190191 }

4.4.2.6 __interrupt void isrVsci1rx (void)

Definition at line 205 of file mcu.c.

References ReceivedByte1.

206 {207 extern unsigned char ReceivedByte1;208 (void)SCI1S1; /* Acknowledge Receiver Full Flag*/209 ReceivedByte1 = SCI1D;210 }

4.4.2.7 __interrupt void isrVsci1err (void)

Definition at line 224 of file mcu.c.

225 {226 /* Write your interrupt code here ... */227228 }

4.4.2.8 __interrupt void isrVtpm1ovf (void)

Definition at line 242 of file mcu.c.

References CB_tim1(), and count1.

243 {244 extern void CB_tim1(void);245 extern unsigned int count1;246 (void) TPM1SC;247 TPM1SC_TOF = 0;248 if(!count1--)249 {250 TPM1SC_TOIE = 0x00;251 CB_tim1();252 }253 }

Here is the call graph for this function:

isrVtpm1ovf CB_tim1

Lenguage C para uC

Page 33: GPRS_MEF_1

4.4 mcu.c File Reference 29

4.4.2.9 __interrupt void isrVicg (void)

Definition at line 267 of file mcu.c.

268 {269 /* Write your interrupt code here ... */270271 }

4.4.2.10 void _Startup (void)

4.4.3 Variable Documentation

4.4.3.1 const volatile unsigned char NVPROT_INIT x0000FFBD = 0xFF

Definition at line 279 of file mcu.c.

4.4.3.2 const volatile unsigned char NVOPT_INIT x0000FFBF = 0x7E

Definition at line 282 of file mcu.c.

4.4.3.3 void(∗ const _vect[ ])()

Definition at line 291 of file mcu.c.

291 { /* Interrupt vector table */292 UNASSIGNED_ISR, /* Int.no. 25 Vrti (at FFCC) Unassigned */293 UNASSIGNED_ISR, /* Int.no. 24 Viic1 (at FFCE) Unassigned */294 UNASSIGNED_ISR, /* Int.no. 23 Vatd1 (at FFD0) Unassigned */295 UNASSIGNED_ISR, /* Int.no. 22 Vkeyboard1 (at FFD2) Unassigned */296 isrVsci2tx, /* Int.no. 21 Vsci2tx (at FFD4) Used */297 isrVsci2rx, /* Int.no. 20 Vsci2rx (at FFD6) Used */298 isrVsci2err, /* Int.no. 19 Vsci2err (at FFD8) Used */299 isrVsci1tx, /* Int.no. 18 Vsci1tx (at FFDA) Used */300 isrVsci1rx, /* Int.no. 17 Vsci1rx (at FFDC) Used */301 isrVsci1err, /* Int.no. 16 Vsci1err (at FFDE) Used */302 UNASSIGNED_ISR, /* Int.no. 15 Vspi1 (at FFE0) Unassigned */303 UNASSIGNED_ISR, /* Int.no. 14 Vtpm2ovf (at FFE2) Unassigned */304 UNASSIGNED_ISR, /* Int.no. 13 Reserved12 (at FFE4) Unassigned */305 UNASSIGNED_ISR, /* Int.no. 12 Reserved13 (at FFE6) Unassigned */306 UNASSIGNED_ISR, /* Int.no. 11 Reserved14 (at FFE8) Unassigned */307 UNASSIGNED_ISR, /* Int.no. 10 Vtpm2ch1 (at FFEA) Unassigned */308 UNASSIGNED_ISR, /* Int.no. 9 Vtpm2ch0 (at FFEC) Unassigned */309 isrVtpm1ovf, /* Int.no. 8 Vtpm1ovf (at FFEE) Used */310 UNASSIGNED_ISR, /* Int.no. 7 Reserved18 (at FFF0) Unassigned */311 UNASSIGNED_ISR, /* Int.no. 6 Vtpm1ch1 (at FFF2) Unassigned */312 UNASSIGNED_ISR, /* Int.no. 5 Vtpm1ch0 (at FFF4) Unassigned */313 isrVicg, /* Int.no. 4 Vicg (at FFF6) Used */314 UNASSIGNED_ISR, /* Int.no. 3 Vlvd (at FFF8) Unassigned */315 UNASSIGNED_ISR, /* Int.no. 2 Virq (at FFFA) Unassigned */316 UNASSIGNED_ISR, /* Int.no. 1 Vswi (at FFFC) Unassigned */317 _Startup /* Int.no. 0 Vreset (at FFFE) Reset vector */318 };

Lic. Antonio Pavanetto

Page 34: GPRS_MEF_1

30 GPRS - MEF v.1.0 File Documentation

4.5 utiles.c File Reference

#include "utiles.h"

Include dependency graph for utiles.c:

utiles.c utiles.h

Functions

• void Text2Hex (char ∗D, char ∗O)

• void Hex2Text (char ∗D, char ∗O)

4.5.1 Function Documentation

4.5.1.1 void Text2Hex (char ∗ D, char ∗ O)

Definition at line 5 of file utiles.c.

6 {7 int i;8 int j;9 unsigned char k;1011 j=0;12 for (i=0;i<strlen(O);i++)13 {14 k=O[i];15 k=k>>4;16 k&=0x0f;17 if(k>9)18 {19 k-=10;20 k+=0x41;21 }22 else23 {24 k+=0x30;25 }26 D[j++]=k;27 k=O[i];28 k&=0x0f;29 if(k>9)30 {31 k-=10;32 k+=0x41;33 }34 else35 {36 k+=0x30;37 }38 D[j++]=k;39 }40 D[j]=0;41 }

Lenguage C para uC

Page 35: GPRS_MEF_1

4.5 utiles.c File Reference 31

4.5.1.2 void Hex2Text (char ∗ D, char ∗ O)

Definition at line 46 of file utiles.c.

47 {48 char i, j, l;49 unsigned char k;50 const char Tabla[]={0,1,2,3,4,5,6,7,8,9,0,0,0,0,0,0,0,10,11,12,13,14,15};515253 l=0;54 for (i=0;i<strlen(O);i+=2)55 {56 k=O[i];57 k-=0x30;58 j=Tabla[k];59 j=j<<4;60 k=O[i+1];61 k-=0x30;62 j=j+Tabla[k];63 D[l++]=j;64 }65 D[l]=0;66 }

Lic. Antonio Pavanetto

Page 36: GPRS_MEF_1

32 GPRS - MEF v.1.0 File Documentation

Lenguage C para uC

Page 37: GPRS_MEF_1

Chapter 5

GPRS - MEF v.1.0 Page Documentation

5.1 Todo List

Global f_idle1

Global f_rx1

Global f_lex1 Hacer el intérprete, por ahora saca los datos por TX2

Global f_tx2 Hacer el intérprete, por ahora saca los datos por TX1

Global f_idle2

Global f_rx2

Global f_lex2 Hacer el intérprete, por ahora saca los datos por TX1

Global f_tx1 Hacer el intérprete, por ahora saca los datos por TX1

Lic. Antonio Pavanetto