-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathesp430ce1a.h
92 lines (80 loc) · 2.29 KB
/
esp430ce1a.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
#ifndef ESP430CE1A_H_
#define ESP430CE1A_H_
#include <msp430.h>
#include "IQmathLib.h"
#include "QmathLib.h"
#include "parametros.h"
/***** Definición de tipos y constantes *****/
union t_u_long_word{
unsigned int w[2];
unsigned long l;
};
union t_s_long_word{
unsigned int w[2];
signed long l;
};
struct t_parametros_esp{
int parESP430_CTRL0;
int parEVENT;
int parPHASECORR1;
int parPHASECORR2;
int parV1OFFSET;
int parI1OFFSET;
int parI2OFFSET;
unsigned int parADAPTI1;
unsigned int parADAPTI2;
unsigned int parGAINCORR1;
unsigned int parGAINCORR2;
union t_s_long_word parPOFFSET1;
union t_s_long_word parPOFFSET2;
union t_u_long_word parINTRPTLEVL;
unsigned int parCALCYCLCNT;
union t_u_long_word parSTARTCURR;
unsigned int parNOMFREQ;
unsigned int parVDROPCYCLS;
unsigned int parRATIOTAMP;
unsigned int parITAMP;
unsigned int parVDROPLEVEL;
unsigned int parVPEAKLEVEL;
unsigned int parIPEAKLEVEL;
unsigned int parDCREMPER;
};
struct t_resultados_esp{
unsigned int retESP430_STAT0;
unsigned int retESP430_STAT1;
int retWAVEFSV1;
int retWAVEFSI1;
int retWAVEFSI2;
union t_s_long_word retACTENERGY1;
union t_s_long_word retACTENERGY2;
union t_s_long_word retREACTENERGY;
union t_s_long_word retAPPENERGY;
union t_s_long_word retACTENSPER1;
union t_s_long_word retACTENSPER2;
unsigned int retPOWERFCT;
// int retCAPIND; // No es usado en el MSP430FE427A, para hallar phi se usa POWERFCT y el signo de la energía reactiva
unsigned int retMAINSPERIOD;
unsigned int retV1RMS;
union t_u_long_word retIRMS;
unsigned int retVPEAK;
unsigned int retIPEAK;
union t_u_long_word retLINECYCLCNT;
union t_u_long_word retNMBMEAS;
};
struct t_constantes_esp{ // Estructuras para las constantes del medidor en punto fijo de 32 bits
_iq16 kV1_PF32;
_iq16 kI1_PF32;
_iq16 kI2_PF32;
_iq16 kE_PF32;
_iq10 Cz_PF32;
};
/***** Declaración de funciones *****/
void init_AFE (void);
void init_ESP (unsigned char flashvar);
void init_parametros_ESP (unsigned char flashvar);
void obtener_resultados (void);
void setear_parametro (unsigned int parametro, unsigned int dato);
unsigned int leer_parametro (unsigned int parametro);
void comenzar_medicion (void);
void detener_medicion (void);
#endif /* ESP430CE1A_H_ */