![](/media/cache/img/default_profile.jpg.50x50_q85.jpg)
forkd
Fork of LG2 by
host/Source/App/uart_m.c@23:12e6183f04d4, 2016-02-03 (annotated)
- Committer:
- Kovalev_D
- Date:
- Wed Feb 03 10:44:42 2016 +0300
- Revision:
- 23:12e6183f04d4
[thyz
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
Kovalev_D |
23:12e6183f04d4 | 1 | /****************************************Copyright (c)**************************************************** |
Kovalev_D |
23:12e6183f04d4 | 2 | ** http://www.PowerAVR.com |
Kovalev_D |
23:12e6183f04d4 | 3 | ** http://www.PowerMCU.com |
Kovalev_D |
23:12e6183f04d4 | 4 | **--------------File Info--------------------------------------------------------------------------------- |
Kovalev_D |
23:12e6183f04d4 | 5 | ** File name: uart.c |
Kovalev_D |
23:12e6183f04d4 | 6 | ** Last modified Date: 2010-05-12 |
Kovalev_D |
23:12e6183f04d4 | 7 | ** Last Version: V1.00 |
Kovalev_D |
23:12e6183f04d4 | 8 | ** Descriptions: |
Kovalev_D |
23:12e6183f04d4 | 9 | ** |
Kovalev_D |
23:12e6183f04d4 | 10 | **-------------------------------------------------------------------------------------------------------- |
Kovalev_D |
23:12e6183f04d4 | 11 | ** Created by: PowerAVR |
Kovalev_D |
23:12e6183f04d4 | 12 | ** Created date: 2010-05-10 |
Kovalev_D |
23:12e6183f04d4 | 13 | ** Version: V1.00 |
Kovalev_D |
23:12e6183f04d4 | 14 | ** Descriptions: ±àдʾÀý´úÂë |
Kovalev_D |
23:12e6183f04d4 | 15 | ** |
Kovalev_D |
23:12e6183f04d4 | 16 | *-------------------------------------------------------------------------------------------------------- YJVTHF |
Kovalev_D |
23:12e6183f04d4 | 17 | |
Kovalev_D |
23:12e6183f04d4 | 18 | *********************************************************************************************************/ |
Kovalev_D |
23:12e6183f04d4 | 19 | |
Kovalev_D |
23:12e6183f04d4 | 20 | #include "lpc17xx.h" /* LPC17xx definitions */ |
Kovalev_D |
23:12e6183f04d4 | 21 | #include "uart_m.h" |
Kovalev_D |
23:12e6183f04d4 | 22 | //#include "global.h" |
Kovalev_D |
23:12e6183f04d4 | 23 | |
Kovalev_D |
23:12e6183f04d4 | 24 | |
Kovalev_D |
23:12e6183f04d4 | 25 | //#define FPCLK (100000000) //ñ pll |
Kovalev_D |
23:12e6183f04d4 | 26 | //#define FPCLK (12000000) //ñ pll |
Kovalev_D |
23:12e6183f04d4 | 27 | #define FOSC 12000000 /* Õñµ´Æ÷ƵÂÊ */ |
Kovalev_D |
23:12e6183f04d4 | 28 | #define FCCLK (FOSC * 8) /* Ö÷ʱÖÓƵÂÊ<=100Mhz */ |
Kovalev_D |
23:12e6183f04d4 | 29 | /* FOSCµÄÕûÊý±¶ */ |
Kovalev_D |
23:12e6183f04d4 | 30 | #define FCCO (FCCLK * 3) /* PLLƵÂÊ(275Mhz~550Mhz) */ |
Kovalev_D |
23:12e6183f04d4 | 31 | |
Kovalev_D |
23:12e6183f04d4 | 32 | //#define FPCLK (FCCLK / 4) //ñ pll |
Kovalev_D |
23:12e6183f04d4 | 33 | |
Kovalev_D |
23:12e6183f04d4 | 34 | |
Kovalev_D |
23:12e6183f04d4 | 35 | #define FPCLK (100000000 / 4) //ñ pll |
Kovalev_D |
23:12e6183f04d4 | 36 | |
Kovalev_D |
23:12e6183f04d4 | 37 | //#define FPCLK (25000000) //ñ pll |
Kovalev_D |
23:12e6183f04d4 | 38 | |
Kovalev_D |
23:12e6183f04d4 | 39 | |
Kovalev_D |
23:12e6183f04d4 | 40 | |
Kovalev_D |
23:12e6183f04d4 | 41 | |
Kovalev_D |
23:12e6183f04d4 | 42 | int UART0_BPS = 9600 ; /* ´®¿Ú0ͨÐŲ¨ÌØÂÊ */ |
Kovalev_D |
23:12e6183f04d4 | 43 | int UART1_BPS = 4800; /* ´®¿Ú0ͨÐŲ¨ÌØÂÊ */ |
Kovalev_D |
23:12e6183f04d4 | 44 | int UART2_BPS = 9600 ; /* ´®¿Ú0ͨÐŲ¨ÌØÂÊ */ |
Kovalev_D |
23:12e6183f04d4 | 45 | int UART3_BPS = 19200 ; /* ´®¿Ú0ͨÐŲ¨ÌØÂÊ */ |
Kovalev_D |
23:12e6183f04d4 | 46 | |
Kovalev_D |
23:12e6183f04d4 | 47 | #define UART_LCR_ODD 0x0b |
Kovalev_D |
23:12e6183f04d4 | 48 | #define UART_LCR_EVEN 0x1b |
Kovalev_D |
23:12e6183f04d4 | 49 | |
Kovalev_D |
23:12e6183f04d4 | 50 | int UART_LCR = UART_LCR_EVEN ; |
Kovalev_D |
23:12e6183f04d4 | 51 | |
Kovalev_D |
23:12e6183f04d4 | 52 | char InCon[1024]; |
Kovalev_D |
23:12e6183f04d4 | 53 | char OutCon[1024]; |
Kovalev_D |
23:12e6183f04d4 | 54 | |
Kovalev_D |
23:12e6183f04d4 | 55 | unsigned int ConInPnt = 0; |
Kovalev_D |
23:12e6183f04d4 | 56 | unsigned int ConInCur = 0; |
Kovalev_D |
23:12e6183f04d4 | 57 | unsigned int ConOutPnt = 0; |
Kovalev_D |
23:12e6183f04d4 | 58 | unsigned int ConOutCur = 0; |
Kovalev_D |
23:12e6183f04d4 | 59 | |
Kovalev_D |
23:12e6183f04d4 | 60 | |
Kovalev_D |
23:12e6183f04d4 | 61 | char InCon1[1024]; |
Kovalev_D |
23:12e6183f04d4 | 62 | char OutCon1[1024]; |
Kovalev_D |
23:12e6183f04d4 | 63 | |
Kovalev_D |
23:12e6183f04d4 | 64 | unsigned int ConInPnt1 = 0; |
Kovalev_D |
23:12e6183f04d4 | 65 | unsigned int ConInCur1 = 0; |
Kovalev_D |
23:12e6183f04d4 | 66 | unsigned int ConOutPnt1 = 0; |
Kovalev_D |
23:12e6183f04d4 | 67 | unsigned int ConOutCur1 = 0; |
Kovalev_D |
23:12e6183f04d4 | 68 | |
Kovalev_D |
23:12e6183f04d4 | 69 | |
Kovalev_D |
23:12e6183f04d4 | 70 | char InCon2[1024]; |
Kovalev_D |
23:12e6183f04d4 | 71 | char OutCon2[1024]; |
Kovalev_D |
23:12e6183f04d4 | 72 | |
Kovalev_D |
23:12e6183f04d4 | 73 | unsigned int ConInPnt2 = 0; |
Kovalev_D |
23:12e6183f04d4 | 74 | unsigned int ConInCur2 = 0; |
Kovalev_D |
23:12e6183f04d4 | 75 | unsigned int ConOutPnt2 = 0; |
Kovalev_D |
23:12e6183f04d4 | 76 | unsigned int ConOutCur2 = 0; |
Kovalev_D |
23:12e6183f04d4 | 77 | |
Kovalev_D |
23:12e6183f04d4 | 78 | char InCon3[1024]; |
Kovalev_D |
23:12e6183f04d4 | 79 | char OutCon3[1024]; |
Kovalev_D |
23:12e6183f04d4 | 80 | |
Kovalev_D |
23:12e6183f04d4 | 81 | unsigned int ConInPnt3 = 0; |
Kovalev_D |
23:12e6183f04d4 | 82 | unsigned int ConInCur3 = 0; |
Kovalev_D |
23:12e6183f04d4 | 83 | unsigned int ConOutPnt3 = 0; |
Kovalev_D |
23:12e6183f04d4 | 84 | unsigned int ConOutCur3 = 0; |
Kovalev_D |
23:12e6183f04d4 | 85 | |
Kovalev_D |
23:12e6183f04d4 | 86 | |
Kovalev_D |
23:12e6183f04d4 | 87 | |
Kovalev_D |
23:12e6183f04d4 | 88 | unsigned int InCon2M[16]; |
Kovalev_D |
23:12e6183f04d4 | 89 | unsigned int OutCon2M[16]; |
Kovalev_D |
23:12e6183f04d4 | 90 | |
Kovalev_D |
23:12e6183f04d4 | 91 | unsigned int ConInPnt2M = 0; |
Kovalev_D |
23:12e6183f04d4 | 92 | unsigned int ConInCur2M = 0; |
Kovalev_D |
23:12e6183f04d4 | 93 | unsigned int ConOutPnt2M = 0; |
Kovalev_D |
23:12e6183f04d4 | 94 | unsigned int ConOutCur2M = 0; |
Kovalev_D |
23:12e6183f04d4 | 95 | |
Kovalev_D |
23:12e6183f04d4 | 96 | unsigned int InCon3M[16]; |
Kovalev_D |
23:12e6183f04d4 | 97 | unsigned int OutCon3M[16]; |
Kovalev_D |
23:12e6183f04d4 | 98 | |
Kovalev_D |
23:12e6183f04d4 | 99 | unsigned int ConInPnt3M = 0; |
Kovalev_D |
23:12e6183f04d4 | 100 | unsigned int ConInCur3M = 0; |
Kovalev_D |
23:12e6183f04d4 | 101 | unsigned int ConOutPnt3M = 0; |
Kovalev_D |
23:12e6183f04d4 | 102 | unsigned int ConOutCur3M = 0; |
Kovalev_D |
23:12e6183f04d4 | 103 | |
Kovalev_D |
23:12e6183f04d4 | 104 | |
Kovalev_D |
23:12e6183f04d4 | 105 | |
Kovalev_D |
23:12e6183f04d4 | 106 | |
Kovalev_D |
23:12e6183f04d4 | 107 | |
Kovalev_D |
23:12e6183f04d4 | 108 | unsigned int OutBufConCount = 0; |
Kovalev_D |
23:12e6183f04d4 | 109 | unsigned int OutBufCon1Count = 0; |
Kovalev_D |
23:12e6183f04d4 | 110 | unsigned int OutBufCon2Count = 0; |
Kovalev_D |
23:12e6183f04d4 | 111 | unsigned int OutBufCon3Count = 0; |
Kovalev_D |
23:12e6183f04d4 | 112 | |
Kovalev_D |
23:12e6183f04d4 | 113 | |
Kovalev_D |
23:12e6183f04d4 | 114 | |
Kovalev_D |
23:12e6183f04d4 | 115 | /********************************************************************************************************* |
Kovalev_D |
23:12e6183f04d4 | 116 | ** Function name: UART0_Init |
Kovalev_D |
23:12e6183f04d4 | 117 | ** Descriptions: °´Ä¬ÈÏÖµ³õʼ»¯´®¿Ú0µÄÒý½ÅºÍͨѶ²ÎÊý¡£ÉèÖÃΪ8λÊý¾Ý룬1λֹͣ룬ÎÞÆæżУÑé |
Kovalev_D |
23:12e6183f04d4 | 118 | ** input parameters: ÎÞ |
Kovalev_D |
23:12e6183f04d4 | 119 | ** output parameters: ÎÞ |
Kovalev_D |
23:12e6183f04d4 | 120 | ** Returned value: ÎÞ |
Kovalev_D |
23:12e6183f04d4 | 121 | *********************************************************************************************************/ |
Kovalev_D |
23:12e6183f04d4 | 122 | void UART0_Init (void) |
Kovalev_D |
23:12e6183f04d4 | 123 | { |
Kovalev_D |
23:12e6183f04d4 | 124 | uint16_t usFdiv; |
Kovalev_D |
23:12e6183f04d4 | 125 | LPC_PINCON->PINSEL0 |= (1 << 4); /* Pin P0.2 used as TXD0 (Com0) */ |
Kovalev_D |
23:12e6183f04d4 | 126 | LPC_PINCON->PINSEL0 |= (1 << 6); /* Pin P0.3 used as RXD0 (Com0) */ |
Kovalev_D |
23:12e6183f04d4 | 127 | LPC_UART0->LCR = 0x83; /* ÔÊÐíÉèÖò¨ÌØÂÊ */ |
Kovalev_D |
23:12e6183f04d4 | 128 | |
Kovalev_D |
23:12e6183f04d4 | 129 | // LPC_UART0->FDR = 0x00000085; // cñì ïäô LPC17xx-User-Manual_0[1].05 íà ñòð 311 |
Kovalev_D |
23:12e6183f04d4 | 130 | //óìíîæèòåëü íà 8 äåëèòåëü íà 5 |
Kovalev_D |
23:12e6183f04d4 | 131 | // usFdiv = 4; |
Kovalev_D |
23:12e6183f04d4 | 132 | usFdiv = (FPCLK / 16) / UART0_BPS; /* ÉèÖò¨ÌØÂÊ */ |
Kovalev_D |
23:12e6183f04d4 | 133 | LPC_UART0->DLM = usFdiv / 256; |
Kovalev_D |
23:12e6183f04d4 | 134 | LPC_UART0->DLL = usFdiv % 256; |
Kovalev_D |
23:12e6183f04d4 | 135 | LPC_UART0->LCR = 0x03; /* Ëø¶¨²¨ÌØÂÊ */ |
Kovalev_D |
23:12e6183f04d4 | 136 | LPC_UART0->FCR = 0x07; |
Kovalev_D |
23:12e6183f04d4 | 137 | } |
Kovalev_D |
23:12e6183f04d4 | 138 | void UART1_Init_temp (void) |
Kovalev_D |
23:12e6183f04d4 | 139 | { |
Kovalev_D |
23:12e6183f04d4 | 140 | uint16_t usFdiv; |
Kovalev_D |
23:12e6183f04d4 | 141 | LPC_PINCON->PINSEL4 |= (2 << 0); /* Pin P2.0 used as TXD0 (Com0) */ |
Kovalev_D |
23:12e6183f04d4 | 142 | LPC_PINCON->PINSEL4 |= (2 << 2); /* Pin P2.1 used as RXD0 (Com0) */ |
Kovalev_D |
23:12e6183f04d4 | 143 | LPC_UART1->LCR = 0x83; /* ÔÊÐíÉèÖò¨ÌØÂÊ */ |
Kovalev_D |
23:12e6183f04d4 | 144 | usFdiv = (FPCLK / 16) / UART1_BPS; /* ÉèÖò¨ÌØÂÊ */ |
Kovalev_D |
23:12e6183f04d4 | 145 | LPC_UART1->DLM = usFdiv / 256; |
Kovalev_D |
23:12e6183f04d4 | 146 | LPC_UART1->DLL = usFdiv % 256; |
Kovalev_D |
23:12e6183f04d4 | 147 | LPC_UART1->LCR = 0x03; /* Ëø¶¨²¨ÌØÂÊ */ |
Kovalev_D |
23:12e6183f04d4 | 148 | LPC_UART1->FCR = 0x07; |
Kovalev_D |
23:12e6183f04d4 | 149 | } |
Kovalev_D |
23:12e6183f04d4 | 150 | |
Kovalev_D |
23:12e6183f04d4 | 151 | void UART2_Init (void) |
Kovalev_D |
23:12e6183f04d4 | 152 | { |
Kovalev_D |
23:12e6183f04d4 | 153 | uint16_t usFdiv; |
Kovalev_D |
23:12e6183f04d4 | 154 | LPC_PINCON->PINSEL0 |= (1 << 20); /* Pin P0.10 used as TXD2 (Com2) */ |
Kovalev_D |
23:12e6183f04d4 | 155 | LPC_PINCON->PINSEL0 |= (1 << 22); /* Pin P0.11 used as RXD2 (Com2) */ |
Kovalev_D |
23:12e6183f04d4 | 156 | LPC_SC->PCONP = LPC_SC->PCONP|(1<<24); /*´ò¿ªUART2µçÔ´¿ØÖÆλ */ |
Kovalev_D |
23:12e6183f04d4 | 157 | |
Kovalev_D |
23:12e6183f04d4 | 158 | LPC_UART2->LCR = 0x83; /* ÔÊÐíÉèÖò¨ÌØÂÊ */ |
Kovalev_D |
23:12e6183f04d4 | 159 | usFdiv = (FPCLK / 16) / 9600; /* ÉèÖò¨ÌØÂÊ */ |
Kovalev_D |
23:12e6183f04d4 | 160 | LPC_UART2->DLM = usFdiv / 256; |
Kovalev_D |
23:12e6183f04d4 | 161 | LPC_UART2->DLL = usFdiv % 256; |
Kovalev_D |
23:12e6183f04d4 | 162 | LPC_UART2->LCR = 0x03; /* Ëø¶¨²¨ÌØÂÊ */ |
Kovalev_D |
23:12e6183f04d4 | 163 | LPC_UART2->FCR = 0x07; |
Kovalev_D |
23:12e6183f04d4 | 164 | } |
Kovalev_D |
23:12e6183f04d4 | 165 | |
Kovalev_D |
23:12e6183f04d4 | 166 | |
Kovalev_D |
23:12e6183f04d4 | 167 | void UART3_Init (void) |
Kovalev_D |
23:12e6183f04d4 | 168 | { |
Kovalev_D |
23:12e6183f04d4 | 169 | uint16_t usFdiv; |
Kovalev_D |
23:12e6183f04d4 | 170 | /* UART0 */ |
Kovalev_D |
23:12e6183f04d4 | 171 | LPC_PINCON->PINSEL1 |= (3 << 18); /* Pin P0.25 used as TXD0 (Com0) */ |
Kovalev_D |
23:12e6183f04d4 | 172 | LPC_PINCON->PINSEL1 |= (3 << 20); /* Pin P0.26 used as RXD0 (Com0) */ |
Kovalev_D |
23:12e6183f04d4 | 173 | LPC_SC->PCONP = LPC_SC->PCONP|(1<<25); /*´ò¿ªUART2µçÔ´¿ØÖÆλ */ |
Kovalev_D |
23:12e6183f04d4 | 174 | |
Kovalev_D |
23:12e6183f04d4 | 175 | LPC_UART3->LCR = 0x83; /* ÔÊÐíÉèÖò¨ÌØÂÊ */ |
Kovalev_D |
23:12e6183f04d4 | 176 | usFdiv = (FPCLK / 16) / UART3_BPS; /* ÉèÖò¨ÌØÂÊ */ |
Kovalev_D |
23:12e6183f04d4 | 177 | LPC_UART3->DLM = usFdiv / 256; |
Kovalev_D |
23:12e6183f04d4 | 178 | LPC_UART3->DLL = usFdiv % 256; |
Kovalev_D |
23:12e6183f04d4 | 179 | LPC_UART3->LCR = UART_LCR; |
Kovalev_D |
23:12e6183f04d4 | 180 | LPC_UART3->FCR = 0x07; |
Kovalev_D |
23:12e6183f04d4 | 181 | } |
Kovalev_D |
23:12e6183f04d4 | 182 | |
Kovalev_D |
23:12e6183f04d4 | 183 | void UART2_InitSet (unsigned int speed, unsigned int SetLsr) |
Kovalev_D |
23:12e6183f04d4 | 184 | { |
Kovalev_D |
23:12e6183f04d4 | 185 | uint16_t usFdiv; |
Kovalev_D |
23:12e6183f04d4 | 186 | |
Kovalev_D |
23:12e6183f04d4 | 187 | LPC_PINCON->PINSEL0 |= (1 << 20); /* Pin P0.10 used as TXD2 (Com2) */ |
Kovalev_D |
23:12e6183f04d4 | 188 | LPC_PINCON->PINSEL0 |= (1 << 22); /* Pin P0.11 used as RXD2 (Com2) */ |
Kovalev_D |
23:12e6183f04d4 | 189 | |
Kovalev_D |
23:12e6183f04d4 | 190 | LPC_SC->PCONP = LPC_SC->PCONP|(1<<24); /*´ò¿ªUART2µçÔ´¿ØÖÆλ */ |
Kovalev_D |
23:12e6183f04d4 | 191 | |
Kovalev_D |
23:12e6183f04d4 | 192 | LPC_UART2->LCR = 0x83; /* ÔÊÐíÉèÖò¨ÌØÂÊ */ |
Kovalev_D |
23:12e6183f04d4 | 193 | usFdiv = (FPCLK / 16) / speed; /* ÉèÖò¨ÌØÂÊ */ |
Kovalev_D |
23:12e6183f04d4 | 194 | LPC_UART2->DLM = usFdiv / 256; |
Kovalev_D |
23:12e6183f04d4 | 195 | LPC_UART2->DLL = usFdiv % 256; |
Kovalev_D |
23:12e6183f04d4 | 196 | LPC_UART2->LCR = SetLsr; /* Ëø¶¨²¨ÌØÂÊ */ |
Kovalev_D |
23:12e6183f04d4 | 197 | LPC_UART2->FCR = 0x07; |
Kovalev_D |
23:12e6183f04d4 | 198 | |
Kovalev_D |
23:12e6183f04d4 | 199 | } |
Kovalev_D |
23:12e6183f04d4 | 200 | |
Kovalev_D |
23:12e6183f04d4 | 201 | |
Kovalev_D |
23:12e6183f04d4 | 202 | void UART3_InitSet (unsigned int speed, unsigned int SetLsr) |
Kovalev_D |
23:12e6183f04d4 | 203 | { |
Kovalev_D |
23:12e6183f04d4 | 204 | uint16_t usFdiv; |
Kovalev_D |
23:12e6183f04d4 | 205 | /* UART0 */ |
Kovalev_D |
23:12e6183f04d4 | 206 | LPC_PINCON->PINSEL1 |= (3 << 18); /* Pin P0.25 used as TXD0 (Com0) */ |
Kovalev_D |
23:12e6183f04d4 | 207 | LPC_PINCON->PINSEL1 |= (3 << 20); /* Pin P0.26 used as RXD0 (Com0) */ |
Kovalev_D |
23:12e6183f04d4 | 208 | |
Kovalev_D |
23:12e6183f04d4 | 209 | LPC_SC->PCONP = LPC_SC->PCONP|(1<<25); /*´ò¿ªUART2µçÔ´¿ØÖÆλ */ |
Kovalev_D |
23:12e6183f04d4 | 210 | LPC_UART3->LCR = 0x83; /* ÔÊÐíÉèÖò¨ÌØÂÊ */ |
Kovalev_D |
23:12e6183f04d4 | 211 | usFdiv = (FPCLK / 16) / speed; /* ÉèÖò¨ÌØÂÊ */ |
Kovalev_D |
23:12e6183f04d4 | 212 | LPC_UART3->DLM = usFdiv / 256; |
Kovalev_D |
23:12e6183f04d4 | 213 | LPC_UART3->DLL = usFdiv % 256; |
Kovalev_D |
23:12e6183f04d4 | 214 | LPC_UART3->LCR = SetLsr; |
Kovalev_D |
23:12e6183f04d4 | 215 | LPC_UART3->FCR = 0x07; |
Kovalev_D |
23:12e6183f04d4 | 216 | } |
Kovalev_D |
23:12e6183f04d4 | 217 | |
Kovalev_D |
23:12e6183f04d4 | 218 | void UART_InitSet (unsigned int Num,unsigned int Speed, unsigned int SetLsr) |
Kovalev_D |
23:12e6183f04d4 | 219 | { |
Kovalev_D |
23:12e6183f04d4 | 220 | uint16_t usFdiv; |
Kovalev_D |
23:12e6183f04d4 | 221 | |
Kovalev_D |
23:12e6183f04d4 | 222 | // usFdiv = ((FPCLK / 16) / Speed) +1; |
Kovalev_D |
23:12e6183f04d4 | 223 | usFdiv = ((FPCLK / 4) / Speed) + 1 ; |
Kovalev_D |
23:12e6183f04d4 | 224 | |
Kovalev_D |
23:12e6183f04d4 | 225 | if (Num == 0) |
Kovalev_D |
23:12e6183f04d4 | 226 | { |
Kovalev_D |
23:12e6183f04d4 | 227 | LPC_PINCON->PINSEL0 |= (1 << 4); /* Pin P0.2 used as TXD0 (Com0) */ |
Kovalev_D |
23:12e6183f04d4 | 228 | LPC_PINCON->PINSEL0 |= (1 << 6); /* Pin P0.3 used as RXD0 (Com0) */ |
Kovalev_D |
23:12e6183f04d4 | 229 | LPC_UART0->LCR = 0x83; /* ÔÊÐíÉèÖò¨ÌØÂÊ */ |
Kovalev_D |
23:12e6183f04d4 | 230 | // LPC_UART0->FDR = 0x00000085; // cñì ïäô LPC17xx-User-Manual_0[1].05 íà ñòð 311 |
Kovalev_D |
23:12e6183f04d4 | 231 | //óìíîæèòåëü íà 8 äåëèòåëü íà 5 |
Kovalev_D |
23:12e6183f04d4 | 232 | // usFdiv = 4; |
Kovalev_D |
23:12e6183f04d4 | 233 | LPC_UART0->DLM = usFdiv / 256; |
Kovalev_D |
23:12e6183f04d4 | 234 | LPC_UART0->DLL = usFdiv % 256; |
Kovalev_D |
23:12e6183f04d4 | 235 | LPC_UART0->LCR = SetLsr; /* Ëø¶¨²¨ÌØÂÊ */ |
Kovalev_D |
23:12e6183f04d4 | 236 | LPC_UART0->FCR = 0x07; |
Kovalev_D |
23:12e6183f04d4 | 237 | } |
Kovalev_D |
23:12e6183f04d4 | 238 | if (Num == 1) |
Kovalev_D |
23:12e6183f04d4 | 239 | { |
Kovalev_D |
23:12e6183f04d4 | 240 | LPC_PINCON->PINSEL4 |= (2 << 0); /* Pin P2.0 used as TXD0 (Com0) */ |
Kovalev_D |
23:12e6183f04d4 | 241 | LPC_PINCON->PINSEL4 |= (2 << 2); /* Pin P2.1 used as RXD0 (Com0) */ |
Kovalev_D |
23:12e6183f04d4 | 242 | |
Kovalev_D |
23:12e6183f04d4 | 243 | LPC_UART1->LCR = 0x83; /* ÔÊÐíÉèÖò¨ÌØÂÊ */ |
Kovalev_D |
23:12e6183f04d4 | 244 | LPC_UART1->DLM = usFdiv / 256; |
Kovalev_D |
23:12e6183f04d4 | 245 | LPC_UART1->DLL = usFdiv % 256; |
Kovalev_D |
23:12e6183f04d4 | 246 | LPC_UART1->LCR = SetLsr; /* Ëø¶¨²¨ÌØÂÊ */ |
Kovalev_D |
23:12e6183f04d4 | 247 | LPC_UART1->FCR = 0x07; |
Kovalev_D |
23:12e6183f04d4 | 248 | } |
Kovalev_D |
23:12e6183f04d4 | 249 | if (Num == 2) |
Kovalev_D |
23:12e6183f04d4 | 250 | { |
Kovalev_D |
23:12e6183f04d4 | 251 | LPC_PINCON->PINSEL0 |= (1 << 20); /* Pin P0.10 used as TXD2 (Com2) */ |
Kovalev_D |
23:12e6183f04d4 | 252 | LPC_PINCON->PINSEL0 |= (1 << 22); /* Pin P0.11 used as RXD2 (Com2) */ |
Kovalev_D |
23:12e6183f04d4 | 253 | LPC_SC->PCONP = LPC_SC->PCONP|(1<<24); /*´ò¿ªUART2µçÔ´¿ØÖÆλ */ |
Kovalev_D |
23:12e6183f04d4 | 254 | LPC_UART2->LCR = 0x83; /* ÔÊÐíÉèÖò¨ÌØÂÊ */ |
Kovalev_D |
23:12e6183f04d4 | 255 | LPC_UART2->DLM = usFdiv / 256; |
Kovalev_D |
23:12e6183f04d4 | 256 | LPC_UART2->DLL = usFdiv % 256; |
Kovalev_D |
23:12e6183f04d4 | 257 | LPC_UART2->LCR = SetLsr; /* Ëø¶¨²¨ÌØÂÊ */ |
Kovalev_D |
23:12e6183f04d4 | 258 | LPC_UART2->FCR = 0x07; |
Kovalev_D |
23:12e6183f04d4 | 259 | } |
Kovalev_D |
23:12e6183f04d4 | 260 | if (Num == 3) |
Kovalev_D |
23:12e6183f04d4 | 261 | { |
Kovalev_D |
23:12e6183f04d4 | 262 | LPC_PINCON->PINSEL1 |= (3 << 18); /* Pin P0.25 used as TXD0 (Com0) */ |
Kovalev_D |
23:12e6183f04d4 | 263 | LPC_PINCON->PINSEL1 |= (3 << 20); /* Pin P0.26 used as RXD0 (Com0) */ |
Kovalev_D |
23:12e6183f04d4 | 264 | LPC_SC->PCONP = LPC_SC->PCONP|(1<<25); /*´ò¿ªUART2µçÔ´¿ØÖÆλ */ |
Kovalev_D |
23:12e6183f04d4 | 265 | LPC_UART3->LCR = 0x83; /* ÔÊÐíÉèÖò¨ÌØÂÊ */ |
Kovalev_D |
23:12e6183f04d4 | 266 | LPC_UART3->DLM = usFdiv / 256; |
Kovalev_D |
23:12e6183f04d4 | 267 | LPC_UART3->DLL = usFdiv % 256; |
Kovalev_D |
23:12e6183f04d4 | 268 | LPC_UART3->LCR = SetLsr; /* Ëø¶¨²¨ÌØÂÊ */ |
Kovalev_D |
23:12e6183f04d4 | 269 | LPC_UART3->FCR = 0x07; |
Kovalev_D |
23:12e6183f04d4 | 270 | } |
Kovalev_D |
23:12e6183f04d4 | 271 | } |
Kovalev_D |
23:12e6183f04d4 | 272 | |
Kovalev_D |
23:12e6183f04d4 | 273 | |
Kovalev_D |
23:12e6183f04d4 | 274 | |
Kovalev_D |
23:12e6183f04d4 | 275 | |
Kovalev_D |
23:12e6183f04d4 | 276 | |
Kovalev_D |
23:12e6183f04d4 | 277 | |
Kovalev_D |
23:12e6183f04d4 | 278 | |
Kovalev_D |
23:12e6183f04d4 | 279 | |
Kovalev_D |
23:12e6183f04d4 | 280 | |
Kovalev_D |
23:12e6183f04d4 | 281 | |
Kovalev_D |
23:12e6183f04d4 | 282 | |
Kovalev_D |
23:12e6183f04d4 | 283 | |
Kovalev_D |
23:12e6183f04d4 | 284 | |
Kovalev_D |
23:12e6183f04d4 | 285 | |
Kovalev_D |
23:12e6183f04d4 | 286 | |
Kovalev_D |
23:12e6183f04d4 | 287 | |
Kovalev_D |
23:12e6183f04d4 | 288 | |
Kovalev_D |
23:12e6183f04d4 | 289 | |
Kovalev_D |
23:12e6183f04d4 | 290 | |
Kovalev_D |
23:12e6183f04d4 | 291 | |
Kovalev_D |
23:12e6183f04d4 | 292 | |
Kovalev_D |
23:12e6183f04d4 | 293 | |
Kovalev_D |
23:12e6183f04d4 | 294 | |
Kovalev_D |
23:12e6183f04d4 | 295 | |
Kovalev_D |
23:12e6183f04d4 | 296 | /********************************************************************************************************* |
Kovalev_D |
23:12e6183f04d4 | 297 | ** Function name: UART0_SendByte |
Kovalev_D |
23:12e6183f04d4 | 298 | ** Descriptions: ´Ó´®¿Ú0·¢ËÍÊý¾Ý |
Kovalev_D |
23:12e6183f04d4 | 299 | ** input parameters: data: ·¢Ë͵ÄÊý¾Ý |
Kovalev_D |
23:12e6183f04d4 | 300 | ** output parameters: ÎÞ |
Kovalev_D |
23:12e6183f04d4 | 301 | ** Returned value: ÎÞ |
Kovalev_D |
23:12e6183f04d4 | 302 | *********************************************************************************************************/ |
Kovalev_D |
23:12e6183f04d4 | 303 | int UART0_SendByte (int ucData) |
Kovalev_D |
23:12e6183f04d4 | 304 | { |
Kovalev_D |
23:12e6183f04d4 | 305 | while (!(LPC_UART0->LSR & 0x20)); |
Kovalev_D |
23:12e6183f04d4 | 306 | return (LPC_UART0->THR = ucData); |
Kovalev_D |
23:12e6183f04d4 | 307 | |
Kovalev_D |
23:12e6183f04d4 | 308 | } |
Kovalev_D |
23:12e6183f04d4 | 309 | |
Kovalev_D |
23:12e6183f04d4 | 310 | |
Kovalev_D |
23:12e6183f04d4 | 311 | |
Kovalev_D |
23:12e6183f04d4 | 312 | |
Kovalev_D |
23:12e6183f04d4 | 313 | |
Kovalev_D |
23:12e6183f04d4 | 314 | |
Kovalev_D |
23:12e6183f04d4 | 315 | /*---------------------------------------------------------------------------- |
Kovalev_D |
23:12e6183f04d4 | 316 | Read character from Serial Port (blocking read) |
Kovalev_D |
23:12e6183f04d4 | 317 | *----------------------------------------------------------------------------*/ |
Kovalev_D |
23:12e6183f04d4 | 318 | int UART0_GetChar (void) |
Kovalev_D |
23:12e6183f04d4 | 319 | { |
Kovalev_D |
23:12e6183f04d4 | 320 | while (!(LPC_UART0->LSR & 0x01)); |
Kovalev_D |
23:12e6183f04d4 | 321 | return (LPC_UART0->RBR); |
Kovalev_D |
23:12e6183f04d4 | 322 | } |
Kovalev_D |
23:12e6183f04d4 | 323 | /*---------------------------------------------------------------------------- |
Kovalev_D |
23:12e6183f04d4 | 324 | Read character from Serial Port (blocking read) |
Kovalev_D |
23:12e6183f04d4 | 325 | *----------------------------------------------------------------------------*/ |
Kovalev_D |
23:12e6183f04d4 | 326 | int UART1_GetChar (void) |
Kovalev_D |
23:12e6183f04d4 | 327 | { |
Kovalev_D |
23:12e6183f04d4 | 328 | while (!(LPC_UART1->LSR & 0x01)); |
Kovalev_D |
23:12e6183f04d4 | 329 | return (LPC_UART1->RBR); |
Kovalev_D |
23:12e6183f04d4 | 330 | } |
Kovalev_D |
23:12e6183f04d4 | 331 | |
Kovalev_D |
23:12e6183f04d4 | 332 | /*---------------------------------------------------------------------------- |
Kovalev_D |
23:12e6183f04d4 | 333 | Read character from Serial Port (blocking read) |
Kovalev_D |
23:12e6183f04d4 | 334 | *----------------------------------------------------------------------------*/ |
Kovalev_D |
23:12e6183f04d4 | 335 | int UART2_GetChar (void) |
Kovalev_D |
23:12e6183f04d4 | 336 | { |
Kovalev_D |
23:12e6183f04d4 | 337 | while (!(LPC_UART2->LSR & 0x01)); |
Kovalev_D |
23:12e6183f04d4 | 338 | return (LPC_UART2->RBR); |
Kovalev_D |
23:12e6183f04d4 | 339 | } |
Kovalev_D |
23:12e6183f04d4 | 340 | /*---------------------------------------------------------------------------- |
Kovalev_D |
23:12e6183f04d4 | 341 | Read character from Serial Port (blocking read) |
Kovalev_D |
23:12e6183f04d4 | 342 | *----------------------------------------------------------------------------*/ |
Kovalev_D |
23:12e6183f04d4 | 343 | int UART3_GetChar (void) |
Kovalev_D |
23:12e6183f04d4 | 344 | { |
Kovalev_D |
23:12e6183f04d4 | 345 | while (!(LPC_UART3->LSR & 0x01)); |
Kovalev_D |
23:12e6183f04d4 | 346 | return (LPC_UART3->RBR); |
Kovalev_D |
23:12e6183f04d4 | 347 | } |
Kovalev_D |
23:12e6183f04d4 | 348 | |
Kovalev_D |
23:12e6183f04d4 | 349 | int UART0_Chek (void) |
Kovalev_D |
23:12e6183f04d4 | 350 | { |
Kovalev_D |
23:12e6183f04d4 | 351 | if (LPC_UART0->LSR & 0x01) return 1; else return 0; |
Kovalev_D |
23:12e6183f04d4 | 352 | } |
Kovalev_D |
23:12e6183f04d4 | 353 | |
Kovalev_D |
23:12e6183f04d4 | 354 | int UART1_Chek (void) |
Kovalev_D |
23:12e6183f04d4 | 355 | { |
Kovalev_D |
23:12e6183f04d4 | 356 | if (LPC_UART1->LSR & 0x01)return 1; else return 0; |
Kovalev_D |
23:12e6183f04d4 | 357 | } |
Kovalev_D |
23:12e6183f04d4 | 358 | |
Kovalev_D |
23:12e6183f04d4 | 359 | |
Kovalev_D |
23:12e6183f04d4 | 360 | int UART2_Chek (void) |
Kovalev_D |
23:12e6183f04d4 | 361 | { |
Kovalev_D |
23:12e6183f04d4 | 362 | |
Kovalev_D |
23:12e6183f04d4 | 363 | if (LPC_UART2->LSR & 0x01)return 1; else return 0; |
Kovalev_D |
23:12e6183f04d4 | 364 | } |
Kovalev_D |
23:12e6183f04d4 | 365 | |
Kovalev_D |
23:12e6183f04d4 | 366 | int UART3_Chek (void) |
Kovalev_D |
23:12e6183f04d4 | 367 | { |
Kovalev_D |
23:12e6183f04d4 | 368 | if (LPC_UART3->LSR & 0x01)return 1; else return 0; |
Kovalev_D |
23:12e6183f04d4 | 369 | |
Kovalev_D |
23:12e6183f04d4 | 370 | } |
Kovalev_D |
23:12e6183f04d4 | 371 | |
Kovalev_D |
23:12e6183f04d4 | 372 | |
Kovalev_D |
23:12e6183f04d4 | 373 | |
Kovalev_D |
23:12e6183f04d4 | 374 | |
Kovalev_D |
23:12e6183f04d4 | 375 | |
Kovalev_D |
23:12e6183f04d4 | 376 | |
Kovalev_D |
23:12e6183f04d4 | 377 | void UART0_SendString (char *s) |
Kovalev_D |
23:12e6183f04d4 | 378 | { |
Kovalev_D |
23:12e6183f04d4 | 379 | while (*s != 0) |
Kovalev_D |
23:12e6183f04d4 | 380 | { |
Kovalev_D |
23:12e6183f04d4 | 381 | UART0_SendByte(*s++); |
Kovalev_D |
23:12e6183f04d4 | 382 | } |
Kovalev_D |
23:12e6183f04d4 | 383 | } |
Kovalev_D |
23:12e6183f04d4 | 384 | |
Kovalev_D |
23:12e6183f04d4 | 385 | |
Kovalev_D |
23:12e6183f04d4 | 386 | |
Kovalev_D |
23:12e6183f04d4 | 387 | |
Kovalev_D |
23:12e6183f04d4 | 388 | |
Kovalev_D |
23:12e6183f04d4 | 389 | int UART2_SendByte (int ucData) |
Kovalev_D |
23:12e6183f04d4 | 390 | { |
Kovalev_D |
23:12e6183f04d4 | 391 | while (!(LPC_UART2->LSR & 0x20)); |
Kovalev_D |
23:12e6183f04d4 | 392 | return (LPC_UART2->THR = ucData); |
Kovalev_D |
23:12e6183f04d4 | 393 | } |
Kovalev_D |
23:12e6183f04d4 | 394 | |
Kovalev_D |
23:12e6183f04d4 | 395 | |
Kovalev_D |
23:12e6183f04d4 | 396 | |
Kovalev_D |
23:12e6183f04d4 | 397 | void UART0_SendChar(uint16_t disp) |
Kovalev_D |
23:12e6183f04d4 | 398 | { |
Kovalev_D |
23:12e6183f04d4 | 399 | uint16_t dispbuf[4]; |
Kovalev_D |
23:12e6183f04d4 | 400 | uint8_t i; |
Kovalev_D |
23:12e6183f04d4 | 401 | |
Kovalev_D |
23:12e6183f04d4 | 402 | dispbuf[3] = disp%10 + '0'; |
Kovalev_D |
23:12e6183f04d4 | 403 | dispbuf[2] = disp/10%10 + '0'; |
Kovalev_D |
23:12e6183f04d4 | 404 | dispbuf[1] = disp/10/10%10 + '0'; |
Kovalev_D |
23:12e6183f04d4 | 405 | dispbuf[0] = disp/10/10/10%10 + '0'; |
Kovalev_D |
23:12e6183f04d4 | 406 | for(i=0;i<4;i++) |
Kovalev_D |
23:12e6183f04d4 | 407 | UART0_SendByte(dispbuf[i]); |
Kovalev_D |
23:12e6183f04d4 | 408 | } |
Kovalev_D |
23:12e6183f04d4 | 409 | |
Kovalev_D |
23:12e6183f04d4 | 410 | |
Kovalev_D |
23:12e6183f04d4 | 411 | |
Kovalev_D |
23:12e6183f04d4 | 412 | void Concol (void ) |
Kovalev_D |
23:12e6183f04d4 | 413 | { |
Kovalev_D |
23:12e6183f04d4 | 414 | if (OutBufConCount == 0) |
Kovalev_D |
23:12e6183f04d4 | 415 | { |
Kovalev_D |
23:12e6183f04d4 | 416 | |
Kovalev_D |
23:12e6183f04d4 | 417 | if (ConOutPnt != ConOutCur) |
Kovalev_D |
23:12e6183f04d4 | 418 | if (LPC_UART0->LSR & 0x20) |
Kovalev_D |
23:12e6183f04d4 | 419 | { |
Kovalev_D |
23:12e6183f04d4 | 420 | ConOutCur++; |
Kovalev_D |
23:12e6183f04d4 | 421 | ConOutCur = ConOutCur & 0x3ff; |
Kovalev_D |
23:12e6183f04d4 | 422 | SetDeUART0 (); |
Kovalev_D |
23:12e6183f04d4 | 423 | LPC_UART0->THR = OutCon[ConOutCur]; |
Kovalev_D |
23:12e6183f04d4 | 424 | } |
Kovalev_D |
23:12e6183f04d4 | 425 | } |
Kovalev_D |
23:12e6183f04d4 | 426 | if (LPC_UART0->LSR & 0x01) |
Kovalev_D |
23:12e6183f04d4 | 427 | { |
Kovalev_D |
23:12e6183f04d4 | 428 | ConInCur++; |
Kovalev_D |
23:12e6183f04d4 | 429 | ConInCur = ConInCur & 0x3ff; |
Kovalev_D |
23:12e6183f04d4 | 430 | InCon[ConInCur] = (LPC_UART0->RBR); |
Kovalev_D |
23:12e6183f04d4 | 431 | } |
Kovalev_D |
23:12e6183f04d4 | 432 | |
Kovalev_D |
23:12e6183f04d4 | 433 | if (!(LPC_UART0->LSR & 0x40)) SetDeUART0 (); else ClrDeUART0() ; //óïðàâëåíèå 485 |
Kovalev_D |
23:12e6183f04d4 | 434 | |
Kovalev_D |
23:12e6183f04d4 | 435 | } |
Kovalev_D |
23:12e6183f04d4 | 436 | |
Kovalev_D |
23:12e6183f04d4 | 437 | |
Kovalev_D |
23:12e6183f04d4 | 438 | void Concol1 (void ) |
Kovalev_D |
23:12e6183f04d4 | 439 | { |
Kovalev_D |
23:12e6183f04d4 | 440 | if (OutBufCon1Count == 0) |
Kovalev_D |
23:12e6183f04d4 | 441 | { |
Kovalev_D |
23:12e6183f04d4 | 442 | if (ConOutPnt1 != ConOutCur1) |
Kovalev_D |
23:12e6183f04d4 | 443 | if (LPC_UART1->LSR & 0x20) |
Kovalev_D |
23:12e6183f04d4 | 444 | { |
Kovalev_D |
23:12e6183f04d4 | 445 | ConOutCur1++; |
Kovalev_D |
23:12e6183f04d4 | 446 | ConOutCur1 = ConOutCur1 & 0x3ff; |
Kovalev_D |
23:12e6183f04d4 | 447 | LPC_UART1->THR = OutCon1[ConOutCur1]; |
Kovalev_D |
23:12e6183f04d4 | 448 | } |
Kovalev_D |
23:12e6183f04d4 | 449 | } |
Kovalev_D |
23:12e6183f04d4 | 450 | if (LPC_UART1->LSR & 0x01) |
Kovalev_D |
23:12e6183f04d4 | 451 | { |
Kovalev_D |
23:12e6183f04d4 | 452 | ConInCur1++; |
Kovalev_D |
23:12e6183f04d4 | 453 | ConInCur1 = ConInCur1 & 0x3ff; |
Kovalev_D |
23:12e6183f04d4 | 454 | InCon1[ConInCur1] = (LPC_UART1->RBR); |
Kovalev_D |
23:12e6183f04d4 | 455 | } |
Kovalev_D |
23:12e6183f04d4 | 456 | |
Kovalev_D |
23:12e6183f04d4 | 457 | //if (!(LPC_UART1->LSR & 0x40)) SetDeUART1 (); else ClrDeUART1() ; //óïðàâëåíèå 485 |
Kovalev_D |
23:12e6183f04d4 | 458 | } |
Kovalev_D |
23:12e6183f04d4 | 459 | |
Kovalev_D |
23:12e6183f04d4 | 460 | void Concol1Fast (void ) |
Kovalev_D |
23:12e6183f04d4 | 461 | { |
Kovalev_D |
23:12e6183f04d4 | 462 | if (OutBufCon1Count == 0) |
Kovalev_D |
23:12e6183f04d4 | 463 | { |
Kovalev_D |
23:12e6183f04d4 | 464 | while((ConOutPnt1 != ConOutCur1) && (LPC_UART1->LSR & 0x20)) |
Kovalev_D |
23:12e6183f04d4 | 465 | { |
Kovalev_D |
23:12e6183f04d4 | 466 | ConOutCur1++; |
Kovalev_D |
23:12e6183f04d4 | 467 | ConOutCur1 = ConOutCur1 & 0x3ff; |
Kovalev_D |
23:12e6183f04d4 | 468 | SetDeUART1 (); |
Kovalev_D |
23:12e6183f04d4 | 469 | LPC_UART1->THR = OutCon1[ConOutCur1]; |
Kovalev_D |
23:12e6183f04d4 | 470 | } |
Kovalev_D |
23:12e6183f04d4 | 471 | } |
Kovalev_D |
23:12e6183f04d4 | 472 | while (LPC_UART1->LSR & 0x01) |
Kovalev_D |
23:12e6183f04d4 | 473 | { |
Kovalev_D |
23:12e6183f04d4 | 474 | ConInCur1++; |
Kovalev_D |
23:12e6183f04d4 | 475 | ConInCur1 = ConInCur1 & 0x3ff; |
Kovalev_D |
23:12e6183f04d4 | 476 | InCon1[ConInCur1] = (LPC_UART1->RBR); |
Kovalev_D |
23:12e6183f04d4 | 477 | } |
Kovalev_D |
23:12e6183f04d4 | 478 | if (!(LPC_UART1->LSR & 0x40)) SetDeUART1 (); else ClrDeUART1() ; //óïðàâëåíèå 485 |
Kovalev_D |
23:12e6183f04d4 | 479 | } |
Kovalev_D |
23:12e6183f04d4 | 480 | |
Kovalev_D |
23:12e6183f04d4 | 481 | |
Kovalev_D |
23:12e6183f04d4 | 482 | |
Kovalev_D |
23:12e6183f04d4 | 483 | |
Kovalev_D |
23:12e6183f04d4 | 484 | void Concol2 (void ) |
Kovalev_D |
23:12e6183f04d4 | 485 | { |
Kovalev_D |
23:12e6183f04d4 | 486 | if (OutBufCon2Count == 0) |
Kovalev_D |
23:12e6183f04d4 | 487 | { |
Kovalev_D |
23:12e6183f04d4 | 488 | if (ConOutPnt2 != ConOutCur2) |
Kovalev_D |
23:12e6183f04d4 | 489 | if (LPC_UART2->LSR & 0x20) |
Kovalev_D |
23:12e6183f04d4 | 490 | { |
Kovalev_D |
23:12e6183f04d4 | 491 | ConOutCur2++; |
Kovalev_D |
23:12e6183f04d4 | 492 | ConOutCur2 = ConOutCur2 & 0x3ff; |
Kovalev_D |
23:12e6183f04d4 | 493 | SetDeUART2 (); |
Kovalev_D |
23:12e6183f04d4 | 494 | LPC_UART2->THR = OutCon2[ConOutCur2]; |
Kovalev_D |
23:12e6183f04d4 | 495 | } |
Kovalev_D |
23:12e6183f04d4 | 496 | } |
Kovalev_D |
23:12e6183f04d4 | 497 | if (LPC_UART2->LSR & 0x01) |
Kovalev_D |
23:12e6183f04d4 | 498 | { |
Kovalev_D |
23:12e6183f04d4 | 499 | ConInCur2++; |
Kovalev_D |
23:12e6183f04d4 | 500 | ConInCur2 = ConInCur2 & 0x3ff; |
Kovalev_D |
23:12e6183f04d4 | 501 | InCon2[ConInCur2] = (LPC_UART2->RBR); |
Kovalev_D |
23:12e6183f04d4 | 502 | } |
Kovalev_D |
23:12e6183f04d4 | 503 | if (!(LPC_UART2->LSR & 0x40)) SetDeUART2 (); else ClrDeUART2() ; //óïðàâëåíèå 485 |
Kovalev_D |
23:12e6183f04d4 | 504 | } |
Kovalev_D |
23:12e6183f04d4 | 505 | |
Kovalev_D |
23:12e6183f04d4 | 506 | |
Kovalev_D |
23:12e6183f04d4 | 507 | |
Kovalev_D |
23:12e6183f04d4 | 508 | |
Kovalev_D |
23:12e6183f04d4 | 509 | |
Kovalev_D |
23:12e6183f04d4 | 510 | void Concol3 (void ) |
Kovalev_D |
23:12e6183f04d4 | 511 | { |
Kovalev_D |
23:12e6183f04d4 | 512 | if (OutBufCon3Count == 0) |
Kovalev_D |
23:12e6183f04d4 | 513 | { |
Kovalev_D |
23:12e6183f04d4 | 514 | if (ConOutPnt3 != ConOutCur3) |
Kovalev_D |
23:12e6183f04d4 | 515 | if (LPC_UART3->LSR & 0x20) |
Kovalev_D |
23:12e6183f04d4 | 516 | { |
Kovalev_D |
23:12e6183f04d4 | 517 | ConOutCur3++; |
Kovalev_D |
23:12e6183f04d4 | 518 | ConOutCur3 = ConOutCur3 & 0x3ff; |
Kovalev_D |
23:12e6183f04d4 | 519 | SetDeUART3 (); |
Kovalev_D |
23:12e6183f04d4 | 520 | LPC_UART3->THR = OutCon3[ConOutCur3]; |
Kovalev_D |
23:12e6183f04d4 | 521 | } |
Kovalev_D |
23:12e6183f04d4 | 522 | } |
Kovalev_D |
23:12e6183f04d4 | 523 | if (LPC_UART3->LSR & 0x01) |
Kovalev_D |
23:12e6183f04d4 | 524 | { |
Kovalev_D |
23:12e6183f04d4 | 525 | ConInCur3++; |
Kovalev_D |
23:12e6183f04d4 | 526 | ConInCur3 = ConInCur3 & 0x3ff; |
Kovalev_D |
23:12e6183f04d4 | 527 | InCon3[ConInCur3] = (LPC_UART3->RBR); |
Kovalev_D |
23:12e6183f04d4 | 528 | } |
Kovalev_D |
23:12e6183f04d4 | 529 | |
Kovalev_D |
23:12e6183f04d4 | 530 | if (!(LPC_UART3->LSR & 0x40)) SetDeUART3 (); else ClrDeUART3() ; //óïðàâëåíèå 485 |
Kovalev_D |
23:12e6183f04d4 | 531 | } |
Kovalev_D |
23:12e6183f04d4 | 532 | |
Kovalev_D |
23:12e6183f04d4 | 533 | |
Kovalev_D |
23:12e6183f04d4 | 534 | |
Kovalev_D |
23:12e6183f04d4 | 535 | void Concol2M (void ) |
Kovalev_D |
23:12e6183f04d4 | 536 | { |
Kovalev_D |
23:12e6183f04d4 | 537 | if (OutBufCon2Count == 0) |
Kovalev_D |
23:12e6183f04d4 | 538 | { |
Kovalev_D |
23:12e6183f04d4 | 539 | if (ConOutPnt2M != ConOutCur2M) |
Kovalev_D |
23:12e6183f04d4 | 540 | if (LPC_UART2->LSR & 0x20) |
Kovalev_D |
23:12e6183f04d4 | 541 | { |
Kovalev_D |
23:12e6183f04d4 | 542 | ConOutCur2++; |
Kovalev_D |
23:12e6183f04d4 | 543 | ConOutCur2 = ConOutCur2 & 0x3ff; |
Kovalev_D |
23:12e6183f04d4 | 544 | SetDeUART2 (); |
Kovalev_D |
23:12e6183f04d4 | 545 | LPC_UART2->THR = OutCon2[ConOutCur2]; |
Kovalev_D |
23:12e6183f04d4 | 546 | } |
Kovalev_D |
23:12e6183f04d4 | 547 | } |
Kovalev_D |
23:12e6183f04d4 | 548 | if (LPC_UART2->LSR & 0x01) |
Kovalev_D |
23:12e6183f04d4 | 549 | { |
Kovalev_D |
23:12e6183f04d4 | 550 | ConInCur2++; |
Kovalev_D |
23:12e6183f04d4 | 551 | ConInCur2 = ConInCur2 & 0x3ff; |
Kovalev_D |
23:12e6183f04d4 | 552 | InCon2[ConInCur2] = (LPC_UART2->RBR); |
Kovalev_D |
23:12e6183f04d4 | 553 | } |
Kovalev_D |
23:12e6183f04d4 | 554 | if (!(LPC_UART2->LSR & 0x40)) SetDeUART2 (); else ClrDeUART2() ; //óïðàâëåíèå 485 |
Kovalev_D |
23:12e6183f04d4 | 555 | } |
Kovalev_D |
23:12e6183f04d4 | 556 | |
Kovalev_D |
23:12e6183f04d4 | 557 | |
Kovalev_D |
23:12e6183f04d4 | 558 | |
Kovalev_D |
23:12e6183f04d4 | 559 | |
Kovalev_D |
23:12e6183f04d4 | 560 | |
Kovalev_D |
23:12e6183f04d4 | 561 | |
Kovalev_D |
23:12e6183f04d4 | 562 | void WriteCon (char *s) |
Kovalev_D |
23:12e6183f04d4 | 563 | { |
Kovalev_D |
23:12e6183f04d4 | 564 | OutBufConCount = 0; |
Kovalev_D |
23:12e6183f04d4 | 565 | while (*s != 0) |
Kovalev_D |
23:12e6183f04d4 | 566 | { |
Kovalev_D |
23:12e6183f04d4 | 567 | ConOutPnt++; |
Kovalev_D |
23:12e6183f04d4 | 568 | ConOutPnt = ConOutPnt & 0x3ff; |
Kovalev_D |
23:12e6183f04d4 | 569 | OutCon[ConOutPnt] = (*s++); |
Kovalev_D |
23:12e6183f04d4 | 570 | } |
Kovalev_D |
23:12e6183f04d4 | 571 | } |
Kovalev_D |
23:12e6183f04d4 | 572 | |
Kovalev_D |
23:12e6183f04d4 | 573 | void WriteCon1 (char *s) |
Kovalev_D |
23:12e6183f04d4 | 574 | { |
Kovalev_D |
23:12e6183f04d4 | 575 | OutBufCon1Count = 0; |
Kovalev_D |
23:12e6183f04d4 | 576 | while (*s != 0) |
Kovalev_D |
23:12e6183f04d4 | 577 | { |
Kovalev_D |
23:12e6183f04d4 | 578 | ConOutPnt1++; |
Kovalev_D |
23:12e6183f04d4 | 579 | ConOutPnt1 = ConOutPnt1 & 0x3ff; |
Kovalev_D |
23:12e6183f04d4 | 580 | OutCon1[ConOutPnt1] = (*s++); |
Kovalev_D |
23:12e6183f04d4 | 581 | } |
Kovalev_D |
23:12e6183f04d4 | 582 | } |
Kovalev_D |
23:12e6183f04d4 | 583 | |
Kovalev_D |
23:12e6183f04d4 | 584 | void WriteConN (char *s, unsigned int N) |
Kovalev_D |
23:12e6183f04d4 | 585 | { |
Kovalev_D |
23:12e6183f04d4 | 586 | OutBufConCount = 0; |
Kovalev_D |
23:12e6183f04d4 | 587 | while (N != 0) |
Kovalev_D |
23:12e6183f04d4 | 588 | { |
Kovalev_D |
23:12e6183f04d4 | 589 | N--; |
Kovalev_D |
23:12e6183f04d4 | 590 | ConOutPnt++; |
Kovalev_D |
23:12e6183f04d4 | 591 | ConOutPnt = ConOutPnt & 0x3ff; |
Kovalev_D |
23:12e6183f04d4 | 592 | OutCon[ConOutPnt] = (*s++); |
Kovalev_D |
23:12e6183f04d4 | 593 | } |
Kovalev_D |
23:12e6183f04d4 | 594 | } |
Kovalev_D |
23:12e6183f04d4 | 595 | |
Kovalev_D |
23:12e6183f04d4 | 596 | |
Kovalev_D |
23:12e6183f04d4 | 597 | void WriteCon2 (char *s) |
Kovalev_D |
23:12e6183f04d4 | 598 | { |
Kovalev_D |
23:12e6183f04d4 | 599 | OutBufCon2Count = 0; |
Kovalev_D |
23:12e6183f04d4 | 600 | while (*s != 0) |
Kovalev_D |
23:12e6183f04d4 | 601 | { |
Kovalev_D |
23:12e6183f04d4 | 602 | ConOutPnt2++; |
Kovalev_D |
23:12e6183f04d4 | 603 | ConOutPnt2 = ConOutPnt2 & 0x3ff; |
Kovalev_D |
23:12e6183f04d4 | 604 | OutCon2[ConOutPnt2] = (*s++); |
Kovalev_D |
23:12e6183f04d4 | 605 | } |
Kovalev_D |
23:12e6183f04d4 | 606 | } |
Kovalev_D |
23:12e6183f04d4 | 607 | void WriteCon3 (char *s) |
Kovalev_D |
23:12e6183f04d4 | 608 | { |
Kovalev_D |
23:12e6183f04d4 | 609 | OutBufCon3Count = 0; |
Kovalev_D |
23:12e6183f04d4 | 610 | while (*s != 0) |
Kovalev_D |
23:12e6183f04d4 | 611 | { |
Kovalev_D |
23:12e6183f04d4 | 612 | ConOutPnt3++; |
Kovalev_D |
23:12e6183f04d4 | 613 | ConOutPnt3 = ConOutPnt3 & 0x3ff; |
Kovalev_D |
23:12e6183f04d4 | 614 | OutCon3[ConOutPnt3] = (*s++); |
Kovalev_D |
23:12e6183f04d4 | 615 | } |
Kovalev_D |
23:12e6183f04d4 | 616 | } |
Kovalev_D |
23:12e6183f04d4 | 617 | |
Kovalev_D |
23:12e6183f04d4 | 618 | |
Kovalev_D |
23:12e6183f04d4 | 619 | |
Kovalev_D |
23:12e6183f04d4 | 620 | |
Kovalev_D |
23:12e6183f04d4 | 621 | void WriteConF (char *s, unsigned int Num) |
Kovalev_D |
23:12e6183f04d4 | 622 | { |
Kovalev_D |
23:12e6183f04d4 | 623 | if (Num == 0) WriteCon(s); |
Kovalev_D |
23:12e6183f04d4 | 624 | if (Num == 1) WriteCon1(s); |
Kovalev_D |
23:12e6183f04d4 | 625 | if (Num == 2) WriteCon2(s); |
Kovalev_D |
23:12e6183f04d4 | 626 | if (Num == 2) WriteCon3(s); |
Kovalev_D |
23:12e6183f04d4 | 627 | |
Kovalev_D |
23:12e6183f04d4 | 628 | } |
Kovalev_D |
23:12e6183f04d4 | 629 | |
Kovalev_D |
23:12e6183f04d4 | 630 | |
Kovalev_D |
23:12e6183f04d4 | 631 | |
Kovalev_D |
23:12e6183f04d4 | 632 | |
Kovalev_D |
23:12e6183f04d4 | 633 | void WriteConByte (unsigned int In) |
Kovalev_D |
23:12e6183f04d4 | 634 | { |
Kovalev_D |
23:12e6183f04d4 | 635 | ConOutPnt++; |
Kovalev_D |
23:12e6183f04d4 | 636 | ConOutPnt = ConOutPnt & 0x3ff; |
Kovalev_D |
23:12e6183f04d4 | 637 | OutCon[ConOutPnt] = In; |
Kovalev_D |
23:12e6183f04d4 | 638 | } |
Kovalev_D |
23:12e6183f04d4 | 639 | |
Kovalev_D |
23:12e6183f04d4 | 640 | void WriteCon1Byte (unsigned int In) |
Kovalev_D |
23:12e6183f04d4 | 641 | { |
Kovalev_D |
23:12e6183f04d4 | 642 | ConOutPnt1++; |
Kovalev_D |
23:12e6183f04d4 | 643 | ConOutPnt1 = ConOutPnt1 & 0x3ff; |
Kovalev_D |
23:12e6183f04d4 | 644 | OutCon1[ConOutPnt1] = In; |
Kovalev_D |
23:12e6183f04d4 | 645 | } |
Kovalev_D |
23:12e6183f04d4 | 646 | |
Kovalev_D |
23:12e6183f04d4 | 647 | |
Kovalev_D |
23:12e6183f04d4 | 648 | void WriteCon2Byte (unsigned int temp) |
Kovalev_D |
23:12e6183f04d4 | 649 | { |
Kovalev_D |
23:12e6183f04d4 | 650 | ConOutPnt2++; |
Kovalev_D |
23:12e6183f04d4 | 651 | ConOutPnt2 = ConOutPnt2 & 0x3ff; |
Kovalev_D |
23:12e6183f04d4 | 652 | OutCon2[ConOutPnt2] = temp; |
Kovalev_D |
23:12e6183f04d4 | 653 | } |
Kovalev_D |
23:12e6183f04d4 | 654 | |
Kovalev_D |
23:12e6183f04d4 | 655 | void WriteCon3Byte (unsigned int temp) |
Kovalev_D |
23:12e6183f04d4 | 656 | { |
Kovalev_D |
23:12e6183f04d4 | 657 | ConOutPnt3++; |
Kovalev_D |
23:12e6183f04d4 | 658 | ConOutPnt3 = ConOutPnt3 & 0x3ff; |
Kovalev_D |
23:12e6183f04d4 | 659 | OutCon3[ConOutPnt3] = temp; |
Kovalev_D |
23:12e6183f04d4 | 660 | } |
Kovalev_D |
23:12e6183f04d4 | 661 | |
Kovalev_D |
23:12e6183f04d4 | 662 | |
Kovalev_D |
23:12e6183f04d4 | 663 | |
Kovalev_D |
23:12e6183f04d4 | 664 | |
Kovalev_D |
23:12e6183f04d4 | 665 | |
Kovalev_D |
23:12e6183f04d4 | 666 | void WriteConByteF (unsigned int In,unsigned int Num ) |
Kovalev_D |
23:12e6183f04d4 | 667 | { |
Kovalev_D |
23:12e6183f04d4 | 668 | if (Num == 0) WriteConByte(In); |
Kovalev_D |
23:12e6183f04d4 | 669 | if (Num == 1) WriteCon1Byte(In); |
Kovalev_D |
23:12e6183f04d4 | 670 | if (Num == 2) WriteCon2Byte(In); |
Kovalev_D |
23:12e6183f04d4 | 671 | if (Num == 3) WriteCon3Byte(In); |
Kovalev_D |
23:12e6183f04d4 | 672 | |
Kovalev_D |
23:12e6183f04d4 | 673 | } |
Kovalev_D |
23:12e6183f04d4 | 674 | |
Kovalev_D |
23:12e6183f04d4 | 675 | |
Kovalev_D |
23:12e6183f04d4 | 676 | |
Kovalev_D |
23:12e6183f04d4 | 677 | |
Kovalev_D |
23:12e6183f04d4 | 678 | |
Kovalev_D |
23:12e6183f04d4 | 679 | |
Kovalev_D |
23:12e6183f04d4 | 680 | |
Kovalev_D |
23:12e6183f04d4 | 681 | |
Kovalev_D |
23:12e6183f04d4 | 682 | |
Kovalev_D |
23:12e6183f04d4 | 683 | int ReadCon (char *s) |
Kovalev_D |
23:12e6183f04d4 | 684 | { |
Kovalev_D |
23:12e6183f04d4 | 685 | int i = 0; |
Kovalev_D |
23:12e6183f04d4 | 686 | while (ConInPnt != ConInCur) |
Kovalev_D |
23:12e6183f04d4 | 687 | { |
Kovalev_D |
23:12e6183f04d4 | 688 | i++; |
Kovalev_D |
23:12e6183f04d4 | 689 | ConInPnt++; |
Kovalev_D |
23:12e6183f04d4 | 690 | ConInPnt = ConInPnt & 0x3ff; |
Kovalev_D |
23:12e6183f04d4 | 691 | (*s++) = InCon[ConInPnt] ; |
Kovalev_D |
23:12e6183f04d4 | 692 | } |
Kovalev_D |
23:12e6183f04d4 | 693 | (*s++) = 0; |
Kovalev_D |
23:12e6183f04d4 | 694 | return i; |
Kovalev_D |
23:12e6183f04d4 | 695 | } |
Kovalev_D |
23:12e6183f04d4 | 696 | |
Kovalev_D |
23:12e6183f04d4 | 697 | int ReadCon1 (char *s) |
Kovalev_D |
23:12e6183f04d4 | 698 | { |
Kovalev_D |
23:12e6183f04d4 | 699 | int i = 0; |
Kovalev_D |
23:12e6183f04d4 | 700 | while (ConInPnt1 != ConInCur1) |
Kovalev_D |
23:12e6183f04d4 | 701 | { |
Kovalev_D |
23:12e6183f04d4 | 702 | i++; |
Kovalev_D |
23:12e6183f04d4 | 703 | ConInPnt1++; |
Kovalev_D |
23:12e6183f04d4 | 704 | ConInPnt1 = ConInPnt1 & 0x3ff; |
Kovalev_D |
23:12e6183f04d4 | 705 | (*s++) = InCon1[ConInPnt1] ; |
Kovalev_D |
23:12e6183f04d4 | 706 | } |
Kovalev_D |
23:12e6183f04d4 | 707 | (*s++) = 0; |
Kovalev_D |
23:12e6183f04d4 | 708 | return i; |
Kovalev_D |
23:12e6183f04d4 | 709 | } |
Kovalev_D |
23:12e6183f04d4 | 710 | |
Kovalev_D |
23:12e6183f04d4 | 711 | int ReadCon2 (char *s) |
Kovalev_D |
23:12e6183f04d4 | 712 | { |
Kovalev_D |
23:12e6183f04d4 | 713 | int i = 0; |
Kovalev_D |
23:12e6183f04d4 | 714 | while (ConInPnt2 != ConInCur2) |
Kovalev_D |
23:12e6183f04d4 | 715 | { |
Kovalev_D |
23:12e6183f04d4 | 716 | i++; |
Kovalev_D |
23:12e6183f04d4 | 717 | ConInPnt2++; |
Kovalev_D |
23:12e6183f04d4 | 718 | ConInPnt2 = ConInPnt2 & 0x3ff; |
Kovalev_D |
23:12e6183f04d4 | 719 | (*s++) = InCon2[ConInPnt2] ; |
Kovalev_D |
23:12e6183f04d4 | 720 | } |
Kovalev_D |
23:12e6183f04d4 | 721 | (*s++) = 0; |
Kovalev_D |
23:12e6183f04d4 | 722 | return i; |
Kovalev_D |
23:12e6183f04d4 | 723 | |
Kovalev_D |
23:12e6183f04d4 | 724 | } |
Kovalev_D |
23:12e6183f04d4 | 725 | |
Kovalev_D |
23:12e6183f04d4 | 726 | |
Kovalev_D |
23:12e6183f04d4 | 727 | int ReadCon3 (char *s) |
Kovalev_D |
23:12e6183f04d4 | 728 | { |
Kovalev_D |
23:12e6183f04d4 | 729 | int i = 0; |
Kovalev_D |
23:12e6183f04d4 | 730 | while (ConInPnt3 != ConInCur3) |
Kovalev_D |
23:12e6183f04d4 | 731 | { |
Kovalev_D |
23:12e6183f04d4 | 732 | i++; |
Kovalev_D |
23:12e6183f04d4 | 733 | ConInPnt3++; |
Kovalev_D |
23:12e6183f04d4 | 734 | ConInPnt3 = ConInPnt3 & 0x3ff; |
Kovalev_D |
23:12e6183f04d4 | 735 | (*s++) = InCon3[ConInPnt3] ; |
Kovalev_D |
23:12e6183f04d4 | 736 | } |
Kovalev_D |
23:12e6183f04d4 | 737 | (*s++) = 0; |
Kovalev_D |
23:12e6183f04d4 | 738 | return i; |
Kovalev_D |
23:12e6183f04d4 | 739 | |
Kovalev_D |
23:12e6183f04d4 | 740 | } |
Kovalev_D |
23:12e6183f04d4 | 741 | |
Kovalev_D |
23:12e6183f04d4 | 742 | |
Kovalev_D |
23:12e6183f04d4 | 743 | |
Kovalev_D |
23:12e6183f04d4 | 744 | |
Kovalev_D |
23:12e6183f04d4 | 745 | |
Kovalev_D |
23:12e6183f04d4 | 746 | int ReadChekCon (char *s) |
Kovalev_D |
23:12e6183f04d4 | 747 | { |
Kovalev_D |
23:12e6183f04d4 | 748 | int i = 0; |
Kovalev_D |
23:12e6183f04d4 | 749 | int ConInPntTemp = ConInPnt; |
Kovalev_D |
23:12e6183f04d4 | 750 | while (ConInPntTemp != ConInCur) |
Kovalev_D |
23:12e6183f04d4 | 751 | { |
Kovalev_D |
23:12e6183f04d4 | 752 | i++; |
Kovalev_D |
23:12e6183f04d4 | 753 | ConInPntTemp++; |
Kovalev_D |
23:12e6183f04d4 | 754 | ConInPntTemp = ConInPntTemp & 0x3ff; |
Kovalev_D |
23:12e6183f04d4 | 755 | (*s++) = InCon[ConInPntTemp] ; |
Kovalev_D |
23:12e6183f04d4 | 756 | } |
Kovalev_D |
23:12e6183f04d4 | 757 | (*s++) = 0; |
Kovalev_D |
23:12e6183f04d4 | 758 | return i; |
Kovalev_D |
23:12e6183f04d4 | 759 | } |
Kovalev_D |
23:12e6183f04d4 | 760 | |
Kovalev_D |
23:12e6183f04d4 | 761 | int ReadChekCon1 (char *s) |
Kovalev_D |
23:12e6183f04d4 | 762 | { |
Kovalev_D |
23:12e6183f04d4 | 763 | int i = 0; |
Kovalev_D |
23:12e6183f04d4 | 764 | int ConInPntTemp = ConInPnt1; |
Kovalev_D |
23:12e6183f04d4 | 765 | while (ConInPntTemp != ConInCur1) |
Kovalev_D |
23:12e6183f04d4 | 766 | { |
Kovalev_D |
23:12e6183f04d4 | 767 | i++; |
Kovalev_D |
23:12e6183f04d4 | 768 | ConInPntTemp++; |
Kovalev_D |
23:12e6183f04d4 | 769 | ConInPntTemp = ConInPntTemp & 0x3ff; |
Kovalev_D |
23:12e6183f04d4 | 770 | (*s++) = InCon1[ConInPntTemp] ; |
Kovalev_D |
23:12e6183f04d4 | 771 | } |
Kovalev_D |
23:12e6183f04d4 | 772 | (*s++) = 0; |
Kovalev_D |
23:12e6183f04d4 | 773 | return i; |
Kovalev_D |
23:12e6183f04d4 | 774 | } |
Kovalev_D |
23:12e6183f04d4 | 775 | |
Kovalev_D |
23:12e6183f04d4 | 776 | |
Kovalev_D |
23:12e6183f04d4 | 777 | |
Kovalev_D |
23:12e6183f04d4 | 778 | |
Kovalev_D |
23:12e6183f04d4 | 779 | int ReadChekCon2 (char *s) |
Kovalev_D |
23:12e6183f04d4 | 780 | { |
Kovalev_D |
23:12e6183f04d4 | 781 | int i = 0; |
Kovalev_D |
23:12e6183f04d4 | 782 | int ConInPntTemp = ConInPnt2; |
Kovalev_D |
23:12e6183f04d4 | 783 | while (ConInPntTemp != ConInCur2) |
Kovalev_D |
23:12e6183f04d4 | 784 | { |
Kovalev_D |
23:12e6183f04d4 | 785 | i++; |
Kovalev_D |
23:12e6183f04d4 | 786 | ConInPntTemp++; |
Kovalev_D |
23:12e6183f04d4 | 787 | ConInPntTemp = ConInPntTemp & 0x3ff; |
Kovalev_D |
23:12e6183f04d4 | 788 | (*s++) = InCon2[ConInPntTemp] ; |
Kovalev_D |
23:12e6183f04d4 | 789 | } |
Kovalev_D |
23:12e6183f04d4 | 790 | (*s++) = 0; |
Kovalev_D |
23:12e6183f04d4 | 791 | return i; |
Kovalev_D |
23:12e6183f04d4 | 792 | } |
Kovalev_D |
23:12e6183f04d4 | 793 | |
Kovalev_D |
23:12e6183f04d4 | 794 | |
Kovalev_D |
23:12e6183f04d4 | 795 | int ReadChekCon3 (char *s) |
Kovalev_D |
23:12e6183f04d4 | 796 | { |
Kovalev_D |
23:12e6183f04d4 | 797 | int i = 0; |
Kovalev_D |
23:12e6183f04d4 | 798 | int ConInPntTemp = ConInPnt3; |
Kovalev_D |
23:12e6183f04d4 | 799 | while (ConInPntTemp != ConInCur3) |
Kovalev_D |
23:12e6183f04d4 | 800 | { |
Kovalev_D |
23:12e6183f04d4 | 801 | i++; |
Kovalev_D |
23:12e6183f04d4 | 802 | ConInPntTemp++; |
Kovalev_D |
23:12e6183f04d4 | 803 | ConInPntTemp = ConInPntTemp & 0x3ff; |
Kovalev_D |
23:12e6183f04d4 | 804 | (*s++) = InCon3[ConInPntTemp] ; |
Kovalev_D |
23:12e6183f04d4 | 805 | } |
Kovalev_D |
23:12e6183f04d4 | 806 | (*s++) = 0; |
Kovalev_D |
23:12e6183f04d4 | 807 | return i; |
Kovalev_D |
23:12e6183f04d4 | 808 | } |
Kovalev_D |
23:12e6183f04d4 | 809 | |
Kovalev_D |
23:12e6183f04d4 | 810 | |
Kovalev_D |
23:12e6183f04d4 | 811 | |
Kovalev_D |
23:12e6183f04d4 | 812 | |
Kovalev_D |
23:12e6183f04d4 | 813 | |
Kovalev_D |
23:12e6183f04d4 | 814 | |
Kovalev_D |
23:12e6183f04d4 | 815 | int ChekInCon ( void ) {if (ConInPnt != ConInCur) return 1; else return 0;} |
Kovalev_D |
23:12e6183f04d4 | 816 | int ChekInCon1 ( void ) {if (ConInPnt1 != ConInCur1) return 1; else return 0;} |
Kovalev_D |
23:12e6183f04d4 | 817 | int ChekInCon2 ( void ) {if (ConInPnt2 != ConInCur2) return 1; else return 0;} |
Kovalev_D |
23:12e6183f04d4 | 818 | int ChekInCon3 ( void ) {if (ConInPnt3 != ConInCur3) return 1; else return 0;} |
Kovalev_D |
23:12e6183f04d4 | 819 | |
Kovalev_D |
23:12e6183f04d4 | 820 | int ChekOutCon ( void ) {if (!(LPC_UART0->LSR & 0x40)) return 1; else return 0;} |
Kovalev_D |
23:12e6183f04d4 | 821 | int ChekOutCon1 ( void ) {if (!(LPC_UART1->LSR & 0x40)) return 1; else return 0;} |
Kovalev_D |
23:12e6183f04d4 | 822 | int ChekOutCon2 ( void ) {if (!(LPC_UART2->LSR & 0x40)) return 1; else return 0;} |
Kovalev_D |
23:12e6183f04d4 | 823 | int ChekOutCon3 ( void ) {if (!(LPC_UART3->LSR & 0x40)) return 1; else return 0;} |
Kovalev_D |
23:12e6183f04d4 | 824 | |
Kovalev_D |
23:12e6183f04d4 | 825 | |
Kovalev_D |
23:12e6183f04d4 | 826 | |
Kovalev_D |
23:12e6183f04d4 | 827 | |
Kovalev_D |
23:12e6183f04d4 | 828 | void Delay(int t) |
Kovalev_D |
23:12e6183f04d4 | 829 | { |
Kovalev_D |
23:12e6183f04d4 | 830 | } |
Kovalev_D |
23:12e6183f04d4 | 831 | |
Kovalev_D |
23:12e6183f04d4 | 832 | |
Kovalev_D |
23:12e6183f04d4 | 833 | void SetDeUART0 (void) {if ((PortEUART0 & (PinEUART0)) == 0) {PortEUART0 |= (PinEUART0); Delay(10);} } |
Kovalev_D |
23:12e6183f04d4 | 834 | void ClrDeUART0 (void) {if ((PortEUART0 & (PinEUART0))) { Delay(10); PortEUART0 &= (~(PinEUART0));}} |
Kovalev_D |
23:12e6183f04d4 | 835 | |
Kovalev_D |
23:12e6183f04d4 | 836 | void SetDeUART1 (void) {if ((PortEUART1 & (PinEUART1)) == 0) {PortEUART1 |= (PinEUART1); Delay(10);} } |
Kovalev_D |
23:12e6183f04d4 | 837 | void ClrDeUART1 (void) {if ((PortEUART1 & (PinEUART1))) { Delay(10); PortEUART1 &= (~(PinEUART1));}} |
Kovalev_D |
23:12e6183f04d4 | 838 | |
Kovalev_D |
23:12e6183f04d4 | 839 | |
Kovalev_D |
23:12e6183f04d4 | 840 | |
Kovalev_D |
23:12e6183f04d4 | 841 | void SetDeUART2 (void) {if ((PortEUART2 & (PinEUART2)) == 0) {PortEUART2 |= (PinEUART2); Delay(10);}} |
Kovalev_D |
23:12e6183f04d4 | 842 | void ClrDeUART2 (void) {if ((PortEUART2 & (PinEUART2))) {Delay(10); PortEUART2 &= (~(PinEUART2));}} |
Kovalev_D |
23:12e6183f04d4 | 843 | |
Kovalev_D |
23:12e6183f04d4 | 844 | |
Kovalev_D |
23:12e6183f04d4 | 845 | void SetDeUART3 (void) {if ((PortEUART3 & (PinEUART3)) == 0) {PortEUART3 |= (PinEUART3); Delay(10);}} |
Kovalev_D |
23:12e6183f04d4 | 846 | void ClrDeUART3 (void) {if ((PortEUART3 & (PinEUART3))) {Delay(10);PortEUART3 &= (~(PinEUART3));}} |
Kovalev_D |
23:12e6183f04d4 | 847 | |
Kovalev_D |
23:12e6183f04d4 | 848 | |
Kovalev_D |
23:12e6183f04d4 | 849 | |
Kovalev_D |
23:12e6183f04d4 | 850 |