forkd

Dependencies:   mbed

Fork of LGstaandart by Dmitry Kovalev

Committer:
Kovalev_D
Date:
Wed Feb 10 14:06:57 2016 +0000
Revision:
47:d902ef6f7564
Parent:
38:716472a4492e
Child:
91:a2bb81eaa183
??????? ???? ?????????? ????

Who changed what in which revision?

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