diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000000000000000000000000000000000000..25014894473fc33cbc90fb452124728282a023ff --- /dev/null +++ b/.gitignore @@ -0,0 +1 @@ +**/bin diff --git a/tasks/task1/Makefile b/tasks/task1/Makefile new file mode 100644 index 0000000000000000000000000000000000000000..b2764780bb877f881ae2b96ce2a85a78ba40e2af --- /dev/null +++ b/tasks/task1/Makefile @@ -0,0 +1,25 @@ +# name of your application +APPLICATION = blinky + +# If no BOARD is found in the environment, use this default: +BOARD ?= nucleo-f401re + +# This has to be the absolute path to the RIOT base directory: +RIOTBASE ?= $(CURDIR)/../../deps/RIOT + +# Comment this out to disable code in RIOT that does safety checking +# which is not needed in a production environment but helps in the +# development process: +DEVELHELP ?= 1 + +# Change this to 0 show compiler invocation lines by default: +QUIET ?= 1 + +# Use a peripheral timer for the delay, if available +FEATURES_REQUIRED += periph_timer +FEATURES_REQUIRED += periph_gpio_irq +USEMODULE += ztimer +USEMODULE += ztimer_usec +USEMODULE += periph_gpio + +include $(RIOTBASE)/Makefile.include diff --git a/tasks/task1/main.c b/tasks/task1/main.c new file mode 100644 index 0000000000000000000000000000000000000000..a72496f61091ad6adafbe38f5df1a6a864b8b748 --- /dev/null +++ b/tasks/task1/main.c @@ -0,0 +1,31 @@ +#include <stdio.h> +#include "board.h" +#include "periph/gpio.h" +#include "ztimer.h" + +void timer_cb (void *arg) { + (void)arg; + gpio_toggle(LED0_PIN); + gpio_irq_enable(BTN0_PIN); +} + +void button_irq_handler(void *arg) { + (void)arg; + static ztimer_t timer_handler = { + .callback = timer_cb, + .arg = NULL + }; + gpio_irq_disable(BTN0_PIN); + ztimer_set(ZTIMER_USEC, &timer_handler, 300 * US_PER_MS); +} + +int main(void) { + gpio_init(LED0_PIN, GPIO_OUT); + gpio_init(BTN0_PIN, GPIO_IN_PU); + gpio_init_int(BTN0_PIN, GPIO_IN_PU, GPIO_BOTH, button_irq_handler, NULL); + + for (;;) { + ztimer_sleep(ZTIMER_USEC, US_PER_SEC); + } +} + diff --git a/tasks/task1/main.c.1 b/tasks/task1/main.c.1 new file mode 100644 index 0000000000000000000000000000000000000000..4f3c73440522fb0ad05eae22cc76d920afe35857 --- /dev/null +++ b/tasks/task1/main.c.1 @@ -0,0 +1,17 @@ +#include <stdio.h> + +#include "board.h" +#include "periph/gpio.h" +#include "ztimer.h" + +int main(void) { + gpio_t led = LED0_PIN;// GPIO_PIN(0, 2); + gpio_init(led, GPIO_OUT); + while (1) { + gpio_toggle(led); + LED0_TOGGLE; + puts("Blink! (No LED present or configured...)"); + ztimer_sleep(ZTIMER_USEC, 1 * US_PER_SEC); + } + return 0; +}