diff --git a/Core/Inc/canlog.h b/Core/Inc/canlog.h index e74f699..42655fe 100644 --- a/Core/Inc/canlog.h +++ b/Core/Inc/canlog.h @@ -27,8 +27,8 @@ extern osMessageQueueId_t xCAN1RxQueue; extern osMessageQueueId_t xCAN2RxQueue; -extern osSemaphoreId_t xLEDSemaphoreCAN1; -extern osSemaphoreId_t xLEDSemaphoreCAN2; +extern osSemaphoreId_t xSemaphoreCAN1; +extern osSemaphoreId_t xSemaphoreCAN2; /* USER CODE BEGIN PTD */ typedef struct { diff --git a/Core/Src/canlog.c b/Core/Src/canlog.c index 9071f58..2a73c6a 100644 --- a/Core/Src/canlog.c +++ b/Core/Src/canlog.c @@ -111,7 +111,7 @@ void vCANLoggerListen(void *argument) { if (osMessageQueueGet(queue, &message, NULL, osWaitForever) == osOK) { - osSemaphoreRelease( (hcan->Instance == CAN1) ? xSemaphoreCAN1 : xLEDSemaphoreCAN2 ); + osSemaphoreRelease( (hcan->Instance == CAN1) ? xSemaphoreCAN1 : xSemaphoreCAN2 ); // TODO: use this semaphore } @@ -129,16 +129,16 @@ void vCANLoggerListen(void *argument) void vLEDHeartbeat(void *argument) { /* CODE BEGIN */ - LEDContext *ctx = (LEDContext*)argument; + LEDContext *context = (LEDContext*)argument; - if (osSemaphoreAcquire(ctx->sem, 0U) == osOK) + if (osSemaphoreAcquire(context->semaphore, 0U) == osOK) { - HAL_GPIO_WritePin(ctx->led->port, ctx->led->pin, GPIO_PIN_SET); - osTimerStart(ctx->timer, 25U); + HAL_GPIO_WritePin(context->led->port, context->led->pin, GPIO_PIN_SET); + osTimerStart(context->timer, 25U); } else { - HAL_GPIO_WritePin(ctx->led->port, ctx->led->pin, GPIO_PIN_RESET); + HAL_GPIO_WritePin(context->led->port, context->led->pin, GPIO_PIN_RESET); } /* CODE END */ } diff --git a/Core/Src/main.c b/Core/Src/main.c index 6ad4786..ecaa284 100644 --- a/Core/Src/main.c +++ b/Core/Src/main.c @@ -56,7 +56,7 @@ LEDContext ledContextCAN1; LEDContext ledContextCAN2; osSemaphoreId_t xSemaphoreCAN1; -osSemaphoreId_t xLEDSemaphoreCAN2; +osSemaphoreId_t xSemaphoreCAN2; osTimerId_t xHeartbeatTimerCAN1; osTimerId_t xHeartbeatTimerCAN2; @@ -143,14 +143,14 @@ int main(void) /* USER CODE BEGIN RTOS_SEMAPHORES */ xSemaphoreCAN1 = osSemaphoreNew(10, 0, NULL); - xLEDSemaphoreCAN2 = osSemaphoreNew(10, 0, NULL); + xSemaphoreCAN2 = osSemaphoreNew(10, 0, NULL); - if (xSemaphoreCAN1 == NULL || xLEDSemaphoreCAN2 == NULL) Error_Handler(); + if (xSemaphoreCAN1 == NULL || xSemaphoreCAN2 == NULL) Error_Handler(); ledContextCAN1.led = &led_can1; ledContextCAN1.semaphore = xSemaphoreCAN1; ledContextCAN2.led = &led_can2; - ledContextCAN2.semaphore = xLEDSemaphoreCAN2; + ledContextCAN2.semaphore = xSemaphoreCAN2; /* USER CODE END RTOS_SEMAPHORES */ /* USER CODE BEGIN RTOS_TIMERS */ @@ -188,7 +188,7 @@ int main(void) ledContextCAN1.timer = xHeartbeatTimerCAN1; ledContextCAN2.led = &led_can2; - ledContextCAN2.semaphore = xLEDSemaphoreCAN2; + ledContextCAN2.semaphore = xSemaphoreCAN2; ledContextCAN2.timer = xHeartbeatTimerCAN2; /* USER CODE END 3 */