diff options
author | ThomasintAnker <thomasintanker1@gmail.com> | 2024-06-18 16:23:51 +0200 |
---|---|---|
committer | ThomasintAnker <thomasintanker1@gmail.com> | 2024-06-18 16:23:51 +0200 |
commit | a55d0bed6240c54f6173b1e38e80212c02c302de (patch) | |
tree | 07c15eebc8cd84e1071a3f72d3c74475017372f3 /main/init.c | |
parent | b45b5d04daa29fcdd456233a931dcbb5b287769f (diff) | |
parent | 245fde65808ce902064ab438296f04f691d007e7 (diff) |
Merge branch 'master' into wip/handover
Diffstat (limited to 'main/init.c')
-rw-r--r-- | main/init.c | 36 |
1 files changed, 16 insertions, 20 deletions
diff --git a/main/init.c b/main/init.c index 4ab373e..bd00c04 100644 --- a/main/init.c +++ b/main/init.c @@ -1,22 +1,20 @@ -#include "config.h" -#include "init.h" -#include "i2c.h" - #include <FreeRTOS.h> #include <task.h> -#include <event_groups.h> #include <pico/stdio.h> #include <pico/cyw43_arch.h> -EventGroupHandle_t init_complete; +#include "config.h" +#include "init.h" +#include "tasks.h" +#include "drv/rp2040/mod.h" static void init_stdio() { stdio_init_all(); } static void init_cyw34() { - if (cyw43_arch_init_with_country(CONF_NET_COUNTRY)) + if (cyw43_arch_init_with_country(CFG_NET_COUNTRY)) panic("cyw43_arch_init_with_country failed\n"); } @@ -24,30 +22,32 @@ static void init_wifi() { // enable 'station' mode (connect to an access point instead of acting like one) cyw43_arch_enable_sta_mode(); - /* WERKT GEWOON NIET MET DEZE LIJNEN CODE */ - if (cyw43_arch_wifi_connect_timeout_ms(CONF_NET_SSID, CONF_NET_PASS, CONF_NET_AUTH, CONF_NET_CONN_TIMEOUT)) + if (cyw43_arch_wifi_connect_timeout_ms(CFG_NET_SSID, CFG_NET_PASS, CFG_NET_AUTH, CFG_NET_CONN_TIMEOUT)) panic("cyw43_arch_wifi_connect failed\n"); - /* WERKT GEWOON NIET MET DEZE LIJNEN CODE */ - - printf("connected to Wi-Fi\n"); // TODO: announce hostname(?) } +static void init_i2c() { + gpio_set_function(CFG_SDA_PIN, GPIO_FUNC_I2C); + gpio_set_function(CFG_SCL_PIN, GPIO_FUNC_I2C); + + pbdrv_setup(); +} + static void async_init() { init_cyw34(); init_i2c(); +#ifndef CFG_NET_DISABLE init_wifi(); - - xEventGroupSetBits(init_complete, 1); +#endif + init_tasks(); // delete self vTaskDelete(NULL); } void init() { - init_complete = xEventGroupCreate(); - // used for debug `printf` and `panic` on errors init_stdio(); @@ -55,7 +55,3 @@ void init() { xTaskCreate((TaskFunction_t) async_init, "init", configMINIMAL_STACK_SIZE, NULL, tskIDLE_PRIORITY + 4, NULL); } -void await_init() { - xEventGroupWaitBits(init_complete, 1, pdFALSE, pdFALSE, portMAX_DELAY); -} - |