| #include <app.h> |
| #include <app/zedmon/ina.h> |
| #include <dev/gpio.h> |
| #include <kernel/thread.h> |
| #include <lib/console.h> |
| #include <stdint.h> |
| #include <stdio.h> |
| #include <target/gpioconfig.h> |
| |
| |
| static void zedmon_init(const struct app_descriptor *app) { |
| ina_init(); |
| printf("zedmon app initialized\n"); |
| } |
| |
| static void zedmon_entry(const struct app_descriptor *app, void *args) |
| { |
| printf("zedmon app started\n"); |
| ina_loop(); |
| } |
| |
| static int cmd_relay(int argc, const cmd_args *argv) { |
| if (argc != 2) { |
| printf("usage: relay <bool>\n"); |
| return 1; |
| } |
| |
| #ifdef GPIO_POWER_ENABLE_J |
| gpio_set(GPIO_POWER_ENABLE_J, argv[1].b); |
| #else |
| printf("This device does not support power control.\n"); |
| #endif |
| |
| return 0; |
| } |
| |
| STATIC_COMMAND_START |
| STATIC_COMMAND("relay", "set relay state", &cmd_relay) |
| STATIC_COMMAND_END(relay); |
| |
| APP_START(zedmon) |
| .init = zedmon_init, |
| .entry = zedmon_entry, |
| APP_END |