Skip to content

Commit ecca541

Browse files
Task (thread) example with the stm32f429 board
1 parent c5111d1 commit ecca541

File tree

2 files changed

+96
-0
lines changed

2 files changed

+96
-0
lines changed
+58
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
export BOARD = stm32f429discovery
2+
ROOTDIR = $(CURDIR)/uC-sdk
3+
4+
ifeq ($(wildcard $(ROOTDIR)/uC-sdk.root),)
5+
ifneq ($(wildcard ../../../uC-sdk.root),)
6+
ROOTDIR = ../../..
7+
endif
8+
endif
9+
10+
TARGET = task.bin
11+
TARGET_SRCS = task.c
12+
13+
LIBDEPS = \
14+
$(ROOTDIR)/FreeRTOS/libFreeRTOS.a \
15+
$(ROOTDIR)/arch/libarch.a \
16+
$(ROOTDIR)/os/libos.a \
17+
$(ROOTDIR)/libc/libc.a \
18+
$(ROOTDIR)/libm/libm.a \
19+
$(ROOTDIR)/acorn/libacorn.a \
20+
$(ROOTDIR)/hardware/libhardware.a \
21+
22+
LIBS = -Wl,--start-group $(LIBDEPS) -Wl,--end-group
23+
TARGET_INCLUDES = include
24+
25+
include $(ROOTDIR)/common.mk
26+
27+
all: uC-sdk $(TARGET)
28+
29+
clean: clean-generic
30+
$(Q)$(MAKE) $(MAKE_OPTS) -C $(ROOTDIR) clean
31+
32+
.PHONY: uC-sdk
33+
34+
$(ROOTDIR)/FreeRTOS/libFreeRTOS.a: uC-sdk
35+
$(ROOTDIR)/arch/libarch.a: uC-sdk
36+
$(ROOTDIR)/os/libos.a: uC-sdk
37+
$(ROOTDIR)/libc/libc.a: uC-sdk
38+
$(ROOTDIR)/libm/libm.a: uC-sdk
39+
$(ROOTDIR)/acorn/libacorn.a: uC-sdk
40+
$(ROOTDIR)/hardware/libhardware.a: uC-sdk
41+
42+
uC-sdk:
43+
$(E) "[MAKE] Entering uC-sdk"
44+
$(Q)$(MAKE) $(MAKE_OPTS) -C $(ROOTDIR)
45+
46+
deps: ldeps
47+
$(E) "[DEPS] Creating dependency tree for uC-sdk"
48+
$(Q)$(MAKE) $(MAKE_OPTS) -C $(ROOTDIR) ldeps
49+
50+
include $(ROOTDIR)/FreeRTOS/config.mk
51+
include $(ROOTDIR)/arch/config.mk
52+
include $(ROOTDIR)/os/config.mk
53+
include $(ROOTDIR)/libc/config.mk
54+
include $(ROOTDIR)/libm/config.mk
55+
include $(ROOTDIR)/acorn/config.mk
56+
include $(ROOTDIR)/hardware/config.mk
57+
include $(ROOTDIR)/target-rules.mk
58+
+38
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
#include <gpio.h>
2+
#include <malloc.h>
3+
#include <FreeRTOS.h>
4+
#include <task.h>
5+
6+
void callback(void *parameter) {
7+
uint8_t status = 0;
8+
//Cast the parameter back to its origin type
9+
pin_t *pin = (pin_t *)parameter;
10+
while(1) {
11+
status ^= 1;
12+
gpio_set(*pin, status);
13+
vTaskDelay(1000);
14+
}
15+
}
16+
17+
int main() {
18+
//Initialize the pin_t structure with the pin port and number
19+
//On this board there is a LED on PG13
20+
pin_t *pin = malloc(sizeof(pin_t));
21+
*pin = make_pin(gpio_port_g, 13);
22+
23+
//configure the pin for output.
24+
gpio_config(*pin, pin_dir_write, pull_down);
25+
26+
//Create the task
27+
xTaskCreate(callback, //callback function
28+
(const signed char *)NULL, //task name
29+
configMINIMAL_STACK_SIZE, //stack size
30+
(void *)pin, //parameter (cast it to void *)
31+
tskIDLE_PRIORITY,
32+
NULL);
33+
34+
//Run the tasks
35+
vTaskStartScheduler();
36+
37+
return 0;
38+
}

0 commit comments

Comments
 (0)