-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.c
112 lines (91 loc) · 3.23 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
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
/**
* @file template.c
* @purpose A simple template for GNU example
* @version x.x
* @date dd. mm. yy
* @author xxxx
*----------------------------------------------------------------------------
* Software that is described herein is for illustrative purposes only
* which provides customers with programming information regarding the
* products. This software is supplied "AS IS" without any warranties.
* NXP Semiconductors assumes no responsibility or liability for the
* use of the software, conveys no license or title under any patent,
* copyright, or mask work right to the product. NXP Semiconductors
* reserves the right to make changes in the software without
* notification. NXP Semiconductors also make no representation or
* warranty that such application will be suitable for the specified
* use without further testing or modification.
**********************************************************************/
/* Include files */
/* <<add include files here>> */
#include "Defines.h"
#include "modem.h"
#include "gprs.h"
#include "crypto.h"
/**
* @brief Main program body
*/
CAN_Status Channel; // Ïåðåìåííàÿ, îïðåäåëÿþùàÿ èíòåðôåéñ, ïî êîòîðîìó ðàáîòàåò
//======== Ïîäïðîãðàììà âûâîäà áóôåðà data_wr_UART ===================
void Write_Buffer(void) { // Âûâîä áóôåðà ñ îòâåòîì ÝÊËÇ â êàññó
uint32_t len; // Äëèíà ñîîáùåíèÿ èç 2-ãî áàéòà áóôåðà
uint32_t count; // Íîìåð áàéòà â áóôåðå äëÿ âûâîäà
uint32_t tmp;
len = 9;
count = 0;
while (len) {
UART_SendByte(UART0, data_wr_UART[count]);
tmp = 20000;
while(tmp--);
count++;
len--;
}
}
//=============================================================================
int c_entry(void)
{
Init_Uart_Default(); //Çàãðóçêà íà÷àëüíûõ ïàðàìåòðîâ èíòåðôåéñîâ UART
Init_Timer0(); // Òåïåðü ìîæíî ïîëüçîâàòüñÿ òàéìåðîì è çàäåðæêàìè
Init_Timer1();
Init_GPIO(); // Èíèöèàëèçàöèÿ ïîðòîâ
Wait(1000); // Ïàóçà 1 ñåêóíäà
Init_Uart0(); // Èíèöèàëèçàöèÿ è âêëþ÷åíèå UART0
time_out = 50;
Timer_Init();
Init_SPI();
Int_UART0_Enable(); // Ðàçðåøåíèå ïðåðûâàíèÿ îò UART0
Init_SPI();
FPO_check(); // Ïðîâåðÿåì, íå íàäî ëè îòäàòü FPO
UART_refresh();
while(1)
{
if(UART_DONE==0xff)
{
SendRcvdCmd(); //îòïðàâëÿåì â êðèïòî âñå, ÷òî ïðèøëî íà UART
UART_refresh(); //ñáðàñûâàåì ôëàãè UART
Write_Buffer();
}
}
return 1;
}
/* Support required entry point for other toolchain */
int main (void)
{
return c_entry();
}
#ifdef DEBUG
/*******************************************************************************
* @brief Reports the name of the source file and the source line number
* where the CHECK_PARAM error has occurred.
* @param[in] file Pointer to the source file name
* @param[in] line assert_param error line source number
* @return None
*******************************************************************************/
void check_failed(uint8_t *file, uint32_t line)
{
/* User can add his own implementation to report the file name and line number,
ex: printf("Wrong parameters value: file %s on line %d\r\n", file, line) */
/* Infinite loop */
while(1);
}
#endif