[개인 Homework] Tx에서 진동을 감지하여 Rx로 송신하기#4
Open
hepheir wants to merge 6 commits intosmu-202115064:mainfrom
Open
Conversation
hepheir
commented
Oct 29, 2024
Comment on lines
+49
to
+69
| int didVibrate = 0; | ||
|
|
||
| /* USER CODE END PV */ | ||
|
|
||
| /* Private function prototypes -----------------------------------------------*/ | ||
| void SystemClock_Config(void); | ||
| static void MX_GPIO_Init(void); | ||
| static void MX_USART2_UART_Init(void); | ||
| static void MX_TIM2_Init(void); | ||
| /* USER CODE BEGIN PFP */ | ||
| int __io_putchar(int ch) | ||
| { | ||
| HAL_UART_Transmit(&huart2, (uint8_t *)&ch, 1, HAL_MAX_DELAY); | ||
| return ch; | ||
| } | ||
|
|
||
| void HAL_TIM_PeriodElapsedCallback(TIM_HandleTypeDef *htim) | ||
| { | ||
| printf("Vib : %d \n\r", didVibrate); | ||
| didVibrate = 0; | ||
| } |
Member
Author
There was a problem hiding this comment.
타이머 인터럽트(1초 주기)에서 didVibrate값을 읽어와 출력한다.
didVibrate는 마지막 출력 이후로 부터 1번이라도 진동이 감지되었으면 1로 set되어있다.
출력을 마친 후에는 didVibrate의 값을 clear한다.
Comment on lines
+115
to
+125
| /* Infinite loop */ | ||
| /* USER CODE BEGIN WHILE */ | ||
| while (1) | ||
| { | ||
| /* USER CODE END WHILE */ | ||
|
|
||
| /* Infinite loop */ | ||
| /* USER CODE BEGIN WHILE */ | ||
| while (1) | ||
| { | ||
| /* USER CODE END WHILE */ | ||
| didVibrate |= HAL_GPIO_ReadPin(vibrtion_transducer_GPIO_Port, vibrtion_transducer_Pin); | ||
|
|
||
| /* USER CODE BEGIN 3 */ | ||
| } | ||
| /* USER CODE END 3 */ | ||
| /* USER CODE BEGIN 3 */ | ||
| } | ||
| /* USER CODE END 3 */ |
Member
Author
There was a problem hiding this comment.
메인 루프에서는 딜레이 없는 Polling 방식으로 진동 센서로 부터 진동이 감지되었는지를 검사한다.
진동이 감지되면 didVibrate를 1로 set한다.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
No description provided.