Ver Fonte

Enabled received to idle interrupt for huart1

MIX\GarthS há 3 anos atrás
pai
commit
316be8bffd
1 ficheiros alterados com 54 adições e 34 exclusões
  1. 54 34
      APP/maincpp.cpp

+ 54 - 34
APP/maincpp.cpp

@@ -56,27 +56,28 @@ uint16_t numberofdigits = 0;
 uint8_t count = 0;
 
 //#include "STM_ENC28_J60.h"
-volatile uint16_t pwm1freq = 0;
-volatile uint16_t pwm1freqnew = 100;
-volatile uint16_t pwm2freq = 0;
-volatile uint16_t pwm2freqnew = 9999;
-volatile uint16_t val;
-volatile uint32_t pwm1counter;
-volatile uint32_t pwm1period;
+//volatile uint16_t pwm1freq = 0;
+//volatile uint16_t pwm1freqnew = 100;
+//volatile uint16_t pwm2freq = 0;
+//volatile uint16_t pwm2freqnew = 9999;
+//volatile uint16_t val;
+//volatile uint32_t pwm1counter;
+//volatile uint32_t pwm1period;
 void maincpp()
 {
-	numberofdigits = pwm2freqnew;
-	while(numberofdigits != 0) {
-		numberofdigits=numberofdigits/10;
-		count++;
-	}
+//	numberofdigits = pwm2freqnew;
+//	while(numberofdigits != 0) {
+//		numberofdigits=numberofdigits/10;
+//		count++;
+//	}
+	HAL_UARTEx_ReceiveToIdle_IT(&huart1, rxbuff, 64);
 	port1freq.Init(&htim1, TIM_CHANNEL_1);
 	port2freq.Init(&htim3, TIM_CHANNEL_4);
 	//	HAL_TIM_PWM_Start(&htim1, TIM_CHANNEL_1);
 	//	HAL_TIM_PWM_Start(&htim3, TIM_CHANNEL_4);
 
-	port1freq.setupoutput(10);
-	port2freq.setupoutput(10);
+	port1freq.setupoutput(50);
+	port2freq.setupoutput(50);
 
 //	port1freq.freq = (360000/10)-1;
 //	port1freq.duty = port1freq.freq/2;
@@ -114,26 +115,6 @@ void maincpp()
 	}
 }
 
-void HAL_TIM_PeriodElapsedCallback(TIM_HandleTypeDef *htim)
-{
-	/* Prevent unused argument(s) compilation warning */
-	if(htim->Instance == TIM17)
-	{
-		pwm1counter++;
-		if(pwm1counter >= pwm1period)
-		{
-			//		  HAL_GPIO_TogglePin(LED1_GPIO_Port, LED1_Pin);
-			pwm1counter = 0;
-		}
-
-	}
-
-
-	/* NOTE : This function should not be modified, when the callback is needed,
-            the HAL_TIM_PeriodElapsedCallback could be implemented in the user file
-	 */
-}
-
 void PWMOUT::Init(TIM_HandleTypeDef *port, uint32_t tchan) {
 	timport = *port;
 	timchan = tchan;
@@ -186,3 +167,42 @@ uint8_t chsum(uint8_t * data) {
 	}
 	return result;
 }
+
+void HAL_TIM_PeriodElapsedCallback(TIM_HandleTypeDef *htim)
+{
+	/* Prevent unused argument(s) compilation warning */
+//	if(htim->Instance == TIM17)
+//	{
+//		pwm1counter++;
+//		if(pwm1counter >= pwm1period)
+//		{
+//			//		  HAL_GPIO_TogglePin(LED1_GPIO_Port, LED1_Pin);
+//			pwm1counter = 0;
+//		}
+
+//	}
+
+}
+
+void HAL_UART_RxCpltCallback(UART_HandleTypeDef *huart)
+{
+  /* Prevent unused argument(s) compilation warning */
+  UNUSED(huart);
+  __NOP();
+
+  /* NOTE : This function should not be modified, when the callback is needed,
+            the HAL_UART_RxCpltCallback can be implemented in the user file.
+   */
+}
+
+void HAL_UARTEx_RxEventCallback(UART_HandleTypeDef *huart, uint16_t Size)
+{
+  /* Prevent unused argument(s) compilation warning */
+  UNUSED(huart);
+  UNUSED(Size);
+  __NOP();
+  HAL_UARTEx_ReceiveToIdle_IT(&huart1, rxbuff, 64);
+  /* NOTE : This function should not be modified, when the callback is needed,
+            the HAL_UARTEx_RxEventCallback can be implemented in the user file.
+   */
+}