88 lines
2.1 KiB
C
88 lines
2.1 KiB
C
#include <zephyr/kernel.h>
|
|
#include <zephyr/drivers/gpio.h>
|
|
#include <zephyr/logging/log.h>
|
|
#include <zephyr/drivers/hwinfo.h>
|
|
#include <zephyr/init.h>
|
|
#include <zephyr/sys/printk.h>
|
|
#include <zephyr/logging/log_ctrl.h>
|
|
#include <zephyr/dfu/mcuboot.h>
|
|
#include <app_version.h>
|
|
#include <version.h>
|
|
#include <ncs_version.h>
|
|
|
|
#include <fs.h>
|
|
#include <audio.h>
|
|
#include <io.h>
|
|
#include <usb.h>
|
|
#include <utils.h>
|
|
|
|
LOG_MODULE_REGISTER(main, LOG_LEVEL_INF);
|
|
|
|
volatile static uint8_t reboot_code = 0;
|
|
|
|
int init_reboot_status()
|
|
{
|
|
reboot_code = get_reboot_status();
|
|
if (reboot_code != 0)
|
|
{
|
|
LOG_INF("Device rebooted with status code: 0x%02x", reboot_code);
|
|
}
|
|
return 0;
|
|
}
|
|
|
|
SYS_INIT(init_reboot_status, POST_KERNEL, 0);
|
|
|
|
int main(void)
|
|
{
|
|
LOG_INF("Starting Edi's Buzzer Application");
|
|
|
|
int rc;
|
|
|
|
rc = fs_init();
|
|
if (rc < 0)
|
|
{
|
|
LOG_ERR("Filesystem initialization failed: %d", rc);
|
|
return rc;
|
|
}
|
|
|
|
rc = audio_init();
|
|
if (rc < 0)
|
|
{
|
|
LOG_ERR("Audio initialization failed: %d", rc);
|
|
return rc;
|
|
}
|
|
|
|
rc = usb_cdc_acm_init();
|
|
if (rc < 0)
|
|
{
|
|
LOG_ERR("USB initialization failed: %d", rc);
|
|
return rc;
|
|
}
|
|
|
|
rc = io_init();
|
|
if (rc < 0)
|
|
{
|
|
LOG_ERR("I/O initialization failed: %d", rc);
|
|
return rc;
|
|
}
|
|
|
|
LOG_INF("All subsystems initialized. Starting application threads.");
|
|
audio_system_ready();
|
|
if (!boot_is_img_confirmed())
|
|
{
|
|
LOG_INF("Confirmation of firmware image pending. Inform user...");
|
|
audio_play("/lfs/sys/update");
|
|
}
|
|
else if (reboot_code == REBOOT_STATUS_FIRMWARE_CONFIRMED)
|
|
{
|
|
LOG_INF("Firmware was just confirmed in the last reboot.");
|
|
}
|
|
else
|
|
{
|
|
LOG_INF("Firmware image already confirmed. No need to confirm again.");
|
|
}
|
|
while (1)
|
|
{
|
|
k_sleep(K_FOREVER);
|
|
}
|
|
} |