-
Notifications
You must be signed in to change notification settings - Fork 0
/
Main.c
90 lines (71 loc) · 2.24 KB
/
Main.c
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
/************************************************************************
* Project : Multi Task Monitoring and Logger System
* Version : V1.0
* Date : 06/29/2011
* Author : Erfan Jazeb Nikoo
* Compiler: KEIL uVision V4.01
* Chip type : LPC2368 NXP ARM7
* Clock frequency : 12.000000 MHz
************************************************************************/
#include "initialization.h"
char hex_chars[16] = {'0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'A', 'B', 'C', 'D', 'E', 'F'};
int CounterFlag = 0;
FILE *f;
BOOL append=0;
char Temp[40];
U32 TimeTemp;
char fname[40];
char clock[30],date[30];
int year = 0;
int month = 0;
int day = 0;
int hour = 0;
int min = 0;
int sec = 0;
/*------------------------------------------------------------------------------
convert one byte to string in hexadecimal notation
*------------------------------------------------------------------------------*/
void Hex_Str (unsigned char hex, char *str) {
*str++ = '0';
*str++ = 'x';
*str++ = hex_chars[hex >> 4];
*str++ = hex_chars[hex & 0xF];
}
/////////////////////////////////////////////////////////////////////////////////
///////////////////////////// Interrupt /////////////////////////////////////////
void FlagCounter(void) __irq {
CounterFlag++;
T1IR = 0x01;
VICVectAddr = 0; /* Acknowledge Interrupt */
}
void ReadRTC(void) __irq{
//Clear Interrupt
RTC_ILR |= 1;
//Read Time registers
hour = (RTC_CTIME0 & 0x3F0000)>>16; //MASKHR:0x1f0000
min = (RTC_CTIME0 & 0X3F00)>>8;//MASKMIN:0X3F00
sec = (RTC_CTIME0 & 0X3F); // MASKSEC:0X3F
year = (RTC_CTIME1)>>16;
month = (RTC_CTIME1 & 0X3F00)>>8;
day = (RTC_CTIME1 & 0X3F);
sprintf(clock,"Time:%02d:%02d:%02d",hour,min,sec);
sprintf(date,"Date:%02d/%02d/%04d",month,day,year);
//updateing VIC
VICVectAddr = 0;
}
/*----------------------------------------------------------------------------
* Main:
*---------------------------------------------------------------------------*/
int main (void) {
main_init();
GLCD_ClearScreen();
Welcome();
for(;;){
Can_Rx();
Multi_Tasking();
Can_Tx (SendToCan());
}
}
/*----------------------------------------------------------------------------
* end of file
*---------------------------------------------------------------------------*/