Skip to content
main.c 908 B
Newer Older
Papy's avatar
Papy committed
#include <device/class/gpio.h>
#include <device/class/timer.h>

#include <arch/stm32/pin.h>

#define FIRST STM32_PE8
#define LAST  STM32_PE15

static struct device_gpio_s  gpio;
static struct device_timer_s timer;

static dev_timer_delay_t     msec;

static uint8_t brain_gpio_init_mask[] = { 0x55, 0x55 };

void main()
{
    printk("bmaaa: brain firmware started!\n");

    ensure(!device_get_accessor_by_path(&gpio.base, NULL, "/gpio", DRIVER_CLASS_GPIO));
    ensure(!device_get_accessor_by_path(&timer.base, NULL, "/timer4", DRIVER_CLASS_TIMER));

    ensure(!dev_timer_init_sec(&timer, &msec, 0, 1, 1000));

    DEVICE_OP(&gpio, set_output, FIRST, LAST, brain_gpio_init_mask, dev_gpio_mask0);
    DEVICE_OP(&gpio, set_mode, FIRST, LAST, dev_gpio_mask1, DEV_PIN_PUSHPULL);
    dev_timer_wait_delay(&timer, msec * 100, 0);
    DEVICE_OP(&gpio, set_output, FIRST, LAST, dev_gpio_mask0, dev_gpio_mask0);
}