ADD: tim3_semaphore and blink LED2 every 200us
This commit is contained in:
parent
5269d17699
commit
d1b0ed0858
5 changed files with 20 additions and 7 deletions
|
@ -88,7 +88,9 @@ void Error_Handler(void);
|
|||
#define spi1_cs_Pin LL_GPIO_PIN_2
|
||||
#define spi1_cs_GPIO_Port GPIOD
|
||||
/* USER CODE BEGIN Private defines */
|
||||
|
||||
typedef int bool;
|
||||
#define true 1
|
||||
#define false 0
|
||||
/* USER CODE END Private defines */
|
||||
|
||||
#ifdef __cplusplus
|
||||
|
|
|
@ -33,7 +33,7 @@ extern "C" {
|
|||
/* USER CODE END Includes */
|
||||
|
||||
extern TIM_HandleTypeDef htim3;
|
||||
|
||||
extern volatile bool tim3_semaphore;
|
||||
/* USER CODE BEGIN Private defines */
|
||||
|
||||
/* USER CODE END Private defines */
|
||||
|
|
|
@ -114,7 +114,11 @@ int main(void)
|
|||
while (1)
|
||||
{
|
||||
/* USER CODE END WHILE */
|
||||
|
||||
if (tim3_semaphore)
|
||||
{
|
||||
tim3_semaphore = false;
|
||||
HAL_GPIO_TogglePin(LED2_GPIO_Port, LED2_Pin);
|
||||
}
|
||||
/* USER CODE BEGIN 3 */
|
||||
}
|
||||
/* USER CODE END 3 */
|
||||
|
|
|
@ -56,7 +56,7 @@
|
|||
|
||||
/* External variables --------------------------------------------------------*/
|
||||
extern TIM_HandleTypeDef htim3;
|
||||
extern int tim3_semaphore;
|
||||
extern bool tim3_semaphore;
|
||||
/* USER CODE BEGIN EV */
|
||||
|
||||
/* USER CODE END EV */
|
||||
|
@ -261,8 +261,15 @@ void TIM3_IRQHandler(void)
|
|||
/* USER CODE BEGIN TIM3_IRQn 0 */
|
||||
// BLink Led1
|
||||
|
||||
HAL_GPIO_TogglePin(LED1_GPIO_Port, LED1_Pin);
|
||||
/* USER CODE END TIM3_IRQn 0 */
|
||||
HAL_GPIO_TogglePin(LED1_GPIO_Port, LED1_Pin);
|
||||
if (__HAL_TIM_GET_FLAG(&htim3, TIM_FLAG_UPDATE) != RESET)
|
||||
{
|
||||
if (__HAL_TIM_GET_IT_SOURCE(&htim3, TIM_IT_UPDATE) != RESET)
|
||||
{
|
||||
__HAL_TIM_CLEAR_IT(&htim3, TIM_IT_UPDATE);
|
||||
tim3_semaphore = true;
|
||||
}
|
||||
}
|
||||
HAL_TIM_IRQHandler(&htim3);
|
||||
/* USER CODE BEGIN TIM3_IRQn 1 */
|
||||
|
||||
|
|
|
@ -25,7 +25,7 @@
|
|||
/* USER CODE END 0 */
|
||||
|
||||
TIM_HandleTypeDef htim3;
|
||||
|
||||
volatile bool tim3_semaphore;
|
||||
/* TIM1 init function */
|
||||
void MX_TIM1_Init(void)
|
||||
{
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue