Zweite Task angelegt um per Message den Task zu triggern

This commit is contained in:
2024-04-21 12:35:25 +02:00
parent 3231565b55
commit 92efd9a290
7 changed files with 36 additions and 11 deletions

View File

@@ -9,13 +9,17 @@
#include "stm32g0xx_ll_gpio.h"
#include "tx_api.h"
extern TX_QUEUE q_LED;
void LED(ULONG thread_input)
{
(void)thread_input;
uintptr_t *msg;
while(true)
{
tx_thread_sleep(500U);
// tx_thread_sleep(500U);
tx_queue_receive(&q_LED, &msg, 500UL);
LL_GPIO_TogglePin(GPIOA, LL_GPIO_PIN_10);
}

View File

@@ -21,6 +21,7 @@
/* Private includes ----------------------------------------------------------*/
/* USER CODE BEGIN Includes */
#include <stdbool.h>
#include "tx_api.h"
/* USER CODE END Includes */
@@ -147,14 +148,35 @@ __NO_RETURN int main(void)
__BKPT(0);
}
void thread(ULONG thread_input);
extern void LED(ULONG thread_input);
TX_THREAD tx_LED;
ULONG stack_LED[64];
ULONG stack_LED[256];
TX_THREAD tx_thread;
ULONG stack_thread[256];
TX_QUEUE q_LED;
uintptr_t aq_LED[10];
void tx_application_define(void *first_unused_memory)
{
(void)first_unused_memory;
tx_thread_create(&tx_LED, "LED", LED, 0UL, stack_LED, sizeof(stack_LED), 1U, 1U, TX_NO_TIME_SLICE, TX_AUTO_START);
tx_thread_create(&tx_thread, "Thread", thread, 0UL, stack_thread, sizeof(stack_thread), 1U, 1U, TX_NO_TIME_SLICE, TX_AUTO_START);
/* Die Nachrichtengröße wird in 32-Bit-Words angegeben -> für Pointer
* auf eine Datenstruktur ist die größe von eins daher ausriechend. */
tx_queue_create(&q_LED, "LED", 1U, aq_LED, sizeof(aq_LED));
}
void thread(ULONG thread_input)
{
while(true)
{
tx_thread_sleep(1000U);
tx_queue_send(&q_LED, &thread_input, TX_NO_WAIT);
}
}
/* USER CODE END 4 */