/** ****************************************************************************** * @file usart.c * @brief This file provides code for the configuration * of the USART instances. ****************************************************************************** * @attention * *

© Copyright (c) 2021 STMicroelectronics. * All rights reserved.

* * This software component is licensed by ST under BSD 3-Clause license, * the "License"; You may not use this file except in compliance with the * License. You may obtain a copy of the License at: * opensource.org/licenses/BSD-3-Clause * ****************************************************************************** */ /* Includes ------------------------------------------------------------------*/ #include "usart.h" #include "main.h" #include "my.h" #include "flash.h" UART_HandleTypeDef huart1; extern __IO UserData_TypeDef pardata; extern __IO uint16_t CorrWord[2][20]; extern __IO uint16_t AMP_STATUS; extern __IO uint16_t timerUPER; extern __IO uint16_t timerOP; extern __IO uint16_t timerKZ; uint8_t iobuf[256]; uint8_t tx[256]; __IO bool needClbr = false; __IO uint32_t faseClbr = 0; __IO bool clbr = false; uint8_t timeout; uint16_t lastbyte; uint8_t iolen = 0; uint8_t ioa; bool sendreq = false; bool setbaud = true; bool send = true; uint8_t rx = 0; __IO uint16_t delayREDE; __IO bool needSave = false; __IO bool needCorr = false; const int8_t inversely[] = {3, 1, -1,-3}; static const uint32_t BAUDRATE[] = {4800, 7200, 9600, 14400, 19200, 38400, 57600, 115200, 128000, 230400}; void MX_USART1_UART_Init(void) { huart1.Instance = USART1; huart1.Init.BaudRate = BAUDRATE[pardata.BAUD]; huart1.Init.WordLength = UART_WORDLENGTH_8B; huart1.Init.StopBits = UART_STOPBITS_1; switch(pardata.INFB) { case 0: //NONE huart1.Init.WordLength = UART_WORDLENGTH_8B; huart1.Init.Parity = UART_PARITY_NONE; break; case 1: //ODD huart1.Init.WordLength = UART_WORDLENGTH_9B; huart1.Init.Parity = UART_PARITY_ODD; break; case 2: //EVEN huart1.Init.WordLength = UART_WORDLENGTH_9B; huart1.Init.Parity = UART_PARITY_EVEN; break; } if(pardata.BAUD < 7) huart1.Init.OverSampling = UART_OVERSAMPLING_8; else huart1.Init.OverSampling = UART_OVERSAMPLING_16; huart1.Init.Mode = UART_MODE_TX_RX; huart1.Init.HwFlowCtl = UART_HWCONTROL_NONE; huart1.Init.OneBitSampling = UART_ONE_BIT_SAMPLE_DISABLE; huart1.AdvancedInit.AdvFeatureInit = UART_ADVFEATURE_NO_INIT; if(HAL_UART_Init(&huart1) != HAL_OK) { Error_Handler(); } if(__HAL_UART_GET_FLAG(&huart1, UART_FLAG_ORE)) __HAL_UART_CLEAR_FLAG(&huart1, UART_FLAG_ORE); if(__HAL_UART_GET_FLAG(&huart1, UART_FLAG_PE)) __HAL_UART_CLEAR_FLAG(&huart1, UART_FLAG_PE); if(__HAL_UART_GET_FLAG(&huart1, UART_FLAG_FE)) __HAL_UART_CLEAR_FLAG(&huart1, UART_FLAG_FE); if(__HAL_UART_GET_FLAG(&huart1, UART_FLAG_NE)) __HAL_UART_CLEAR_FLAG(&huart1, UART_FLAG_NE); HAL_GPIO_WritePin(RE_GPIO_Port, RE_Pin, GPIO_PIN_RESET); SET_BIT(huart1.Instance->CR1, USART_CR1_RXNEIE | USART_CR1_PEIE); } void MX_USART1_UART_DeInit(void) { if(HAL_UART_DeInit(&huart1) != HAL_OK) { Error_Handler(); } HAL_NVIC_DisableIRQ(USART1_IRQn); } void HAL_UART_MspInit(UART_HandleTypeDef* uartHandle) { GPIO_InitTypeDef GPIO_InitStruct = {0}; if(uartHandle->Instance==USART1) { __HAL_RCC_USART1_CLK_ENABLE(); __HAL_RCC_GPIOA_CLK_ENABLE(); /**USART1 GPIO Configuration PA9 ------> USART1_TX PA10 ------> USART1_RX */ GPIO_InitStruct.Pin = GPIO_PIN_9|GPIO_PIN_10; GPIO_InitStruct.Mode = GPIO_MODE_AF_PP; GPIO_InitStruct.Pull = GPIO_NOPULL; GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_VERY_HIGH; GPIO_InitStruct.Alternate = GPIO_AF4_USART1; HAL_GPIO_Init(GPIOA, &GPIO_InitStruct); /* USART1 interrupt Init */ HAL_NVIC_SetPriority(USART1_IRQn, 3, 0); HAL_NVIC_EnableIRQ(USART1_IRQn); } } void HAL_UART_MspDeInit(UART_HandleTypeDef* uartHandle) { if(uartHandle->Instance==USART1) { /* USER CODE BEGIN USART1_MspDeInit 0 */ /* USER CODE END USART1_MspDeInit 0 */ /* Peripheral clock disable */ __HAL_RCC_USART1_CLK_DISABLE(); /**USART1 GPIO Configuration PA9 ------> USART1_TX PA10 ------> USART1_RX */ HAL_GPIO_DeInit(GPIOA, GPIO_PIN_9|GPIO_PIN_10); /* USART1 interrupt Deinit */ HAL_NVIC_DisableIRQ(USART1_IRQn); /* USER CODE BEGIN USART1_MspDeInit 1 */ /* USER CODE END USART1_MspDeInit 1 */ } } /* USER CODE BEGIN 1 */ void USART1_IRQHandler(void) { if((__HAL_UART_GET_IT_SOURCE(&huart1, UART_IT_RXNE)) && (__HAL_UART_GET_FLAG(&huart1, UART_FLAG_RXNE))) { HAL_UART_RxCpltCallback(&huart1); } else { HAL_UART_IRQHandler(&huart1); } if(__HAL_UART_GET_FLAG(&huart1, UART_FLAG_ORE)) __HAL_UART_CLEAR_FLAG(&huart1, UART_FLAG_ORE); if(__HAL_UART_GET_FLAG(&huart1, UART_FLAG_PE)) __HAL_UART_CLEAR_FLAG(&huart1, UART_FLAG_PE); if(__HAL_UART_GET_FLAG(&huart1, UART_FLAG_FE)) __HAL_UART_CLEAR_FLAG(&huart1, UART_FLAG_FE); if(__HAL_UART_GET_FLAG(&huart1, UART_FLAG_NE)) __HAL_UART_CLEAR_FLAG(&huart1, UART_FLAG_NE); } /* USER CODE END 1 */ void strtOut(uint16_t n) { uint16_t crc; if(tx[0]) { lastbyte = n + 2; //���������� ������������ ������ crc = Crc16_TX(n); //���������� CRC16 tx[n] = lo(crc); //������ CRC16 tx[n + 1] = hi(crc); // � ��������� 2 ����� HAL_GPIO_WritePin(RE_GPIO_Port, RE_Pin, GPIO_PIN_SET); //����������� RS485 �� �������� ioa = 1; sendreq = true; } iolen = 0; } uint16_t Crc16(uint16_t len) { uint16_t i; uint16_t crc = 0xFFFF; for(i = 0; i < len; i++) { crc = (crc >> 8) ^ Crc16Table[(crc & 0xFF) ^ iobuf[i]]; } return crc; } uint16_t Crc16_TX(uint16_t len) { uint16_t i; uint16_t crc = 0xFFFF; for(i = 0; i < len; i++) { crc = (crc >> 8) ^ Crc16Table[(crc & 0xFF) ^ tx[i]]; } return crc; } void SetBaudRate() { timeout = time35[pardata.BAUD]; delayREDE = sendtime[pardata.BAUD]; MX_USART1_UART_DeInit(); MX_USART1_UART_Init(); } void HAL_UART_RxCpltCallback(UART_HandleTypeDef *huart) { uint8_t i, j; uint8_t *pch; usshort crc, addr, regs; usfloat f; uint8_t tmp, tmp1; uint16_t tmp16; float tmpf; timeout = time35[pardata.BAUD]; iobuf[iolen++] = (uint8_t) (USART1->RDR & 0xFF); if((iobuf[0] == pardata.OWN) || (!iobuf[0])) { if(iolen > 1) { if(iolen == 2) { switch(iobuf[1]) { case 0x03: lastbyte = 7; break; case 0x10: lastbyte = 6; break; default: lastbyte = 3; tx[0] = iobuf[0]; tx[1] = (iobuf[1] | 0x80); tx[2] = 0x03; strtOut(3); break; } } if(iolen > lastbyte) { switch(iobuf[1]) { //������ ��������� case 0x03: iolen = 0; crc.ch[0] = iobuf[6]; crc.ch[1] = iobuf[7]; if(crc.sh == Crc16(6)) // ïðè êîððåêòíîì çíà÷åíèè CRC { addr.ch[1] = iobuf[2]; //ñò áàéò àäðåñà ðåãèñòðà addr.ch[0] = iobuf[3]; // ìë áàéò àäðåñà ðåãèñòðà regs.ch[1] = iobuf[4]; // ñò áàéò êîë-âà ðåãèñòðîâ (ñëîâ) regs.ch[0] = iobuf[5]; // ìë áàéò êîë-âî ðåãèñòðîâ (ñëîâ) if(addr.sh == 1000) // ×òåíèå áàéòà ÏÅÐÅÃÐÓÇÊÈ { if(regs.ch[0] != 1) // åñëè çàïðîøåí íå ÎÄÈÍ ðåãèñòð { tx[0] = iobuf[0]; tx[1] = (iobuf[1] | 0x80); tx[2] = 0x03; strtOut(3); } else // { // iobuf[0] - àäðåñ, iobuf[1]=ÊÔ tx[0] = iobuf[0]; tx[1] = iobuf[1]; tx[2] = regs.ch[0] << 1; // êîë-âî áàéò tx[3] = 0; tx[4] = lo(AMP_STATUS); tx[5] = hi(AMP_STATUS); strtOut(3 + tx[2]); } // Ôëàã çàïðîñà ïåðåäà÷è } else switch(addr.sh) { case 5001: //IIN case 5002: //IFV case 5003: //IFN case 5004: //IKU case 5005: //IKE case 5006: //IKD case 5007: //IKS case 5008: //IPZ case 5009: //OPZ case 5010: //VAL if(regs.ch[0] > (5011 - addr.sh)) { tx[0] = iobuf[0]; tx[1] = (iobuf[1] | 0x80); tx[2] = 0x03; strtOut(3); } else { tx[0] = iobuf[0]; tx[1] = iobuf[1]; tx[2] = regs.ch[0] << 1; pch = (uint8_t *) &pardata.IIN + ((addr.sh - 5001) << 1); for(j = 0; j < tx[2]; j++) tx[j + 3] = *(pch + (j ^ 1)); strtOut(3 + tx[2]); } break; case 7002: // ×òåíèå Kcond ïî êîë-âó áàéò case 7501: // ×òåíèå Kcond ïî êîë-âó ñëîâ tmp = 3; tx[0] = iobuf[0]; tx[1] = iobuf[1]; tx[2] = regs.ch[0] << 2; // êîë-âî áàéò äàííûõ if(addr.sh == 7002) { tmp <<= 1; //tmp=6 tx[2] >>= 1; //êîë-âî ñëîâ äàííûõ } if(regs.ch[0] > tmp) { tx[0] = iobuf[0]; tx[1] = (iobuf[1] | 0x80); tx[2] = 0x03; strtOut(3); } else { f.fl = pardata.KCOND; tx[3] = f.ch[3]; tx[4] = f.ch[2]; tx[5] = f.ch[1]; tx[6] = f.ch[0]; strtOut(3 + tx[2]); } break; case 7004: // ×òåíèå Sens case 7502: tmp = 2; tx[0] = iobuf[0]; tx[1] = iobuf[1]; tx[2] = regs.ch[0] << 2; if(addr.sh == 7004) { tmp <<= 1; tx[2] >>= 1; } if(regs.ch[0] > tmp) { tx[0] = iobuf[0]; tx[1] = (iobuf[1] | 0x80); tx[2] = 0x03; strtOut(3); } else { f.fl = pardata.SENS; tx[3] = f.ch[3]; tx[4] = f.ch[2]; tx[5] = f.ch[1]; tx[6] = f.ch[0]; strtOut(3 + tx[2]); } break; case 7006: // ×òåíèå Accel case 7503: tmp = 1; tx[0] = iobuf[0]; tx[1] = iobuf[1]; tx[2] = regs.ch[0] << 2; if(addr.sh == 7006) { tmp <<= 1; tx[2] >>= 1; } if(regs.ch[0] > tmp) { tx[0] = iobuf[0]; tx[1] = (iobuf[1] | 0x80); tx[2] = 0x03; strtOut(3); } else { f.fl = pardata.ACCEL; tx[3] = f.ch[3]; tx[4] = f.ch[2]; tx[5] = f.ch[1]; tx[6] = f.ch[0]; strtOut(3 + tx[2]); } break; default: tx[0] = iobuf[0]; tx[1] = (iobuf[1] | 0x80); tx[2] = 0x02; strtOut(3); break; } } break; //-------------------------- // ЗАПИСЬ данных в устройство //-------------------------- case 0x10: addr.ch[1] = iobuf[2]; addr.ch[0] = iobuf[3]; regs.ch[1] = iobuf[4]; regs.ch[0] = iobuf[5]; switch(addr.sh) // Запись pardata { case 3000: //CALIBR_ON_OFF if((regs.ch[0] > 1) || (iobuf[6] != (regs.ch[0] << 1))) { tx[0] = iobuf[0]; tx[1] = (iobuf[1] | 0x80); tx[2] = 0x03; strtOut(3); } else { j = 8 + iobuf[6]; if(iolen > j) { iolen = 0; crc.ch[0] = iobuf[j - 1]; crc.ch[1] = iobuf[j]; if(crc.sh == Crc16(j - 1)) { if(!iobuf[8]) { faseClbr = 0; clbr = false; } else { needClbr = true; faseClbr = iobuf[8] - 1; } for(j = 0; j < 6; j++) { tx[j] = iobuf[j]; } strtOut(6); } } } break; case 3001: //CHARGE_0.1 case 3002: //CHARGE_0.2 case 3003: //CHARGE_0.5 case 3004: //CHARGE_1 case 3005: //CHARGE_2 case 3006: //CHARGE_5 case 3007: //CHARGE_10 case 3008: //CHARGE_20 case 3009: //CHARGE_50 case 3010: //CHARGE_100 case 3011: //CHARGE_200 case 3012: //CHARGE_500 case 3013: //CHARGE_1000 case 3014: //ICP_1 case 3015: //ICP_2 case 3016: //ICP_5 case 3017: //ICP_10 case 3018: //ICP_20 case 3019: //ICP_50 case 3020: //ICP_100 case 3021: //ICP_200 case 3022: //ICP_500 case 3023: //ICP_1000 if((regs.ch[0] > 1) || (iobuf[6] != (regs.ch[0] << 1))) { tx[0] = iobuf[0]; tx[1] = (iobuf[1] | 0x80); tx[2] = 0x03; strtOut(3); } else { j = 8 + iobuf[6]; if(iolen > j) { iolen = 0; crc.ch[0] = iobuf[j - 1]; crc.ch[1] = iobuf[j]; if(crc.sh == Crc16(j - 1)) { if(clbr) { switch(iobuf[8]) { case 0x01: //+1 if(CorrWord[pardata.IIN][pardata.IKU] < 4095) CorrWord[pardata.IIN][pardata.IKU]++; break; case 0x81: //-1 if(CorrWord[pardata.IIN][pardata.IKU] > 0) CorrWord[pardata.IIN][pardata.IKU]--; break; case 0x0A: //+10 if(CorrWord[pardata.IIN][pardata.IKU] < 4085) CorrWord[pardata.IIN][pardata.IKU] += 10; break; case 0x8A: //-10 if(CorrWord[pardata.IIN][pardata.IKU] > 10) CorrWord[pardata.IIN][pardata.IKU] -= 10; break; case 0x64: //+100 if(CorrWord[pardata.IIN][pardata.IKU] < 3995) CorrWord[pardata.IIN][pardata.IKU] += 100; break; case 0xE4: //-100 if(CorrWord[pardata.IIN][pardata.IKU] > 100) CorrWord[pardata.IIN][pardata.IKU] -= 100; break; } SetAndCorrect(); wrCorr(); } for(j = 0; j < 6; j++) { tx[j] = iobuf[j]; } strtOut(6); /*if(!iobuf[8]) { faseClbr = 0; clbr = false; } else { if(iobuf[8] <= 12) { needClbr = true; faseClbr = iobuf[8] - 1; } else { faseClbr = 0; clbr = false; } } for(j = 0; j < 6; j++) { tx[j] = iobuf[j]; } strtOut(6);*/ } } } break; case 5001: //IIN case 5002: //IFV case 5003: //IFN case 5004: //IKU case 5005: //IKE case 5006: //IKD case 5007: //IKS case 5008: //IPZ case 5009: //OPZ case 5010: //VAL if((regs.ch[0] > (5011 - addr.sh)) || (iobuf[6] != (regs.ch[0] << 1))) { tx[0] = iobuf[0]; tx[1] = (iobuf[1] | 0x80); tx[2] = 0x03; strtOut(3); } else { j = 8 + iobuf[6]; if(iolen > j) { iolen = 0; crc.ch[0] = iobuf[j - 1]; crc.ch[1] = iobuf[j]; if(crc.sh == Crc16(j - 1)) { pch = (uint8_t *) &pardata.IIN + ((addr.sh - 5001) << 1); for(j = 0; j < iobuf[6]; j++) *(pch + (j ^ 1)) = iobuf[j + 7]; if((pardata.IIN > ICP) || (pardata.IKU > Ku1000) || (pardata.IFV > Hp10) || (pardata.IFN > Lp100000) || (pardata.VAL > mV)) { rdCorr(); tx[0] = iobuf[0]; tx[1] = (iobuf[1] | 0x80); tx[2] = 0x03; strtOut(3); } else { needSave = true; if(iobuf[0]) { for(j = 0; j < 6; j++) { tx[j] = iobuf[j]; } strtOut(6); } } } } } break; case 7002: // Запись Kcond case 7501: tmp = 3; tmp1 = 2; if(addr.sh == 7002) { tmp <<= 1; tmp1 = 1; } if((regs.ch[0] > tmp) || (iobuf[6] != (regs.ch[0] << tmp1))) { tx[0] = iobuf[0]; tx[1] |= 0x80; //модификация кода функции на ошибку tx[2] = 0x03; //Адрес данных указанный в запросе не доступен strtOut(3); } else { j = 8 + iobuf[6]; if(iolen > j) { crc.ch[0] = iobuf[j - 1]; crc.ch[1] = iobuf[j]; if(crc.sh == Crc16(j - 1)) { if(iobuf[6] == 4) { for(j = 0; j < 4; j++) f.ch[3 - j] = iobuf[7 + j]; pardata.KCOND = f.fl; needSave = true; strtOut(6); } else if(iobuf[6] == 8) { for(j = 0; j < 4; j++) f.ch[3 - j] = iobuf[7 + j]; pardata.KCOND = f.fl; for(j = 0; j < 4; j++) f.ch[3 - j] = iobuf[11 + j]; pardata.SENS = f.fl; needSave = true; strtOut(6); } else if(iobuf[6] == 12) { for(j = 0; j < 4; j++) f.ch[3 - j] = iobuf[7 + j]; pardata.KCOND = f.fl; for(j = 0; j < 4; j++) f.ch[3 - j] = iobuf[11 + j]; pardata.SENS = f.fl; for(j = 0; j < 4; j++) f.ch[3 - j] = iobuf[15 + j]; pardata.ACCEL = f.fl; needSave = true; strtOut(6); } else { tx[0] = iobuf[0]; tx[1] |= 0x80; //модификация кода функции на ошибку tx[2] = 0x03; //Адрес данных указанный в запросе не доступен strtOut(3); } } } } break; case 7004: // Запись Sens case 7502: tmp = 2; tmp1 = 2; if(addr.sh == 7004) { tmp <<= 1; tmp1 = 1; } if((regs.ch[0] > tmp) || (iobuf[6] != (regs.ch[0] << tmp1))) { tx[0] = iobuf[0]; tx[1] |= 0x80; //модификация кода функции на ошибку tx[2] = 0x03; //Адрес данных указанный в запросе не доступен strtOut(3); } else { j = 8 + iobuf[6]; if(iolen > j) { crc.ch[0] = iobuf[j - 1]; crc.ch[1] = iobuf[j]; if(crc.sh == Crc16(j - 1)) { if(iobuf[6] == 4) { for(j = 0; j < 4; j++) f.ch[3 - j] = iobuf[7 + j]; pardata.SENS = f.fl; needSave = true; strtOut(6); } else if(iobuf[6] == 8) { /*for(j = 0; j < 4; j++) f.ch[3 - j] = iobuf[3 + j]; pardata.SENS = f.fl;*/ for(j = 0; j < 4; j++) f.ch[3 - j] = iobuf[7 + j]; pardata.ACCEL = f.fl; needSave = true; strtOut(6); } else { tx[0] = iobuf[0]; tx[1] |= 0x80; //модификация кода функции на ошибку tx[2] = 0x03; //Адрес данных указанный в запросе не доступен strtOut(3); } } } } break; case 7006: // Запись Accel case 7503: tmp = 1; tmp1 = 2; if(addr.sh == 7006) { tmp <<= 1; tmp1 = 1; } if((regs.ch[0] > tmp) || (iobuf[6] != (regs.ch[0] << tmp1))) { tx[0] = iobuf[0]; tx[1] |= 0x80; //модификация кода функции на ошибку tx[2] = 0x03; //Адрес данных указанный в запросе не доступен strtOut(3); } else { j = 8 + iobuf[6]; if(iolen > j) { crc.ch[0] = iobuf[j - 1]; crc.ch[1] = iobuf[j]; if(crc.sh == Crc16(j - 1)) { if(iobuf[6] == 4) { for(j = 0; j < 4; j++) f.ch[3 - j] = iobuf[3 + j]; pardata.ACCEL = f.fl; needSave = true; strtOut(6); } else { tx[0] = iobuf[0]; tx[1] |= 0x80; //модификация кода функции на ошибку tx[2] = 0x03; //Адрес данных указанный в запросе не доступен strtOut(3); } } } } break; default://Команда неопознана tx[0] = iobuf[0]; tx[1] |= 0x80; //модификация кода функции на ошибку tx[2] = 0x02; //Адрес данных указанный в запросе не доступен strtOut(3); break; } break; } } } } //iolen++; } void HAL_UART_TxCpltCallback(UART_HandleTypeDef *huart) { __IO uint16_t a; a = delayREDE; while(a) { a--; a++; a--; a++; a--; } if(setbaud) { setbaud = false; needSave = true; SetBaudRate(); } __HAL_UART_CLEAR_FLAG(&huart1, UART_FLAG_TC); HAL_GPIO_WritePin(RE_GPIO_Port, RE_Pin, GPIO_PIN_RESET); } void StartTransfer(void) { __IO uint16_t a; /*a = delayREDE; while(a) { a--; a++; a--; a++; a--; }*/ HAL_UART_Transmit_IT(&huart1, tx, lastbyte); } void HAL_GPIO_EXTI_Callback(uint16_t GPIO_Pin) { // if(GPIO_Pin == UPER_Pin) // Overdrive { // __HAL_GPIO_EXTI_CLEAR_FLAG(UPER_Pin); if(HAL_GPIO_ReadPin(GPIOA, UPER_Pin) == GPIO_PIN_SET) { timerUPER = 1000; HAL_GPIO_WritePin(GPIOA, PER_Pin, GPIO_PIN_SET); AMP_STATUS |= UPER_Pin; } else { if(timerUPER==0){ AMP_STATUS &= ~UPER_Pin; HAL_GPIO_WritePin(GPIOA, PER_Pin, GPIO_PIN_RESET); } } } // if(GPIO_Pin == OP_Pin) // OP { // __HAL_GPIO_EXTI_CLEAR_FLAG(OP_Pin); if(HAL_GPIO_ReadPin(GPIOA, OP_Pin) == GPIO_PIN_SET) { timerOP = 1000; AMP_STATUS |= OP_Pin; } else { if(timerOP==0){ AMP_STATUS &= ~OP_Pin; } } } // if(GPIO_Pin == KZ_Pin) // KZ { // __HAL_GPIO_EXTI_CLEAR_FLAG(KZ_Pin); if(HAL_GPIO_ReadPin(GPIOA, KZ_Pin) == GPIO_PIN_SET) { timerKZ = 1000; AMP_STATUS |= KZ_Pin; } else { if(timerKZ==0){ AMP_STATUS &= ~KZ_Pin; } } } } /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/