From 5ad87315393fd4c9a2df0a8c8a73aea9b84b169f Mon Sep 17 00:00:00 2001 From: ksmabcd135 Date: Mon, 20 May 2019 19:19:24 +0900 Subject: [PATCH] =?UTF-8?q?=EB=9D=BC=EC=9D=B4=ED=8C=8C=EC=9D=B4=20?= =?UTF-8?q?=EC=B5=9C=EC=A2=85=20=ED=86=B5=EC=8B=A0=20=EC=BD=94=EB=93=9C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Src/main.c | 42 +++++++++++++++++++++++++----------------- 1 file changed, 25 insertions(+), 17 deletions(-) diff --git a/Src/main.c b/Src/main.c index ace28e5..68371a1 100644 --- a/Src/main.c +++ b/Src/main.c @@ -49,8 +49,10 @@ void SystemClock_Config(void); //LI-FI data -uint8_t rx3_data; -uint8_t tx_data[5]="hello"; +uint8_t rx3_data[7]; +uint8_t tx_data[21]="i can speak english\n"; +char ack_data[5]; +int index,ack=0; int main(void) { @@ -70,15 +72,20 @@ int main(void) printf("$ "); while(1) { - - -/////////////LI-FI////////////////////////// -//send "HELLO from huart5 to huart3" -/* - HAL_UART_Transmit(&huart5,tx_data,5,1000); - HAL_Delay(1000); -*/ -//////////////Li-FI///////////////////////// + index=index%sizeof(tx_data); + + HAL_UART_Transmit(&huart5,&tx_data[index++],1,1); + HAL_Delay(10); + HAL_UART_Receive_IT(&huart5,rx3_data,1); + if(flag) + { + + + HAL_UART_Transmit(&huart3,rx3_data,sizeof(rx3_data),1); + + flag=0; + continue; + } __disable_interrupt(); tag = task_delete(&task); @@ -95,16 +102,17 @@ int main(void) */ //LI-FI callback function - /* - void HAL_UART_RxCpltCallback(UART_HandleTypeDef *huart) + +void HAL_UART_RxCpltCallback(UART_HandleTypeDef *huart) { - if(huart->Instance ==USART3) + + if(huart->Instance == UART5) { - HAL_UART_Receive_IT(&huart3,&rx3_data,5); - HAL_UART_Transmit(&huart3,&rx3_data,5,10); + flag = 1; + HAL_UART_Receive_IT(&huart5,rx3_data,1); } } -*/ + void SystemClock_Config(void) { RCC_OscInitTypeDef RCC_OscInitStruct = {0};