sipeed / M0S_BL616_example

M0S BL616 example (M0S dock)
Apache License 2.0
30 stars 8 forks source link

Add blinking led as helloworld #2

Open hndrbrm opened 1 year ago

hndrbrm commented 1 year ago

Could you please add this blinking led as helloworld example. I copy the code from twitter @eMbeddedHome Its helpful for me to getting started the board.

#include "bflb_gpio.h"
#include "board.h"

struct bflb_device_s *gpio;

int main(void)
{
    board_init();

    gpio = bflb_device_get_by_name("gpio");
    printf("gpio output\r\n");
    bflb_gpio_init(gpio, GPIO_PIN_27, GPIO_OUTPUT | GPIO_PULLUP | GPIO_SMT_EN | GPIO_DRV_0);
    bflb_gpio_init(gpio, GPIO_PIN_28, GPIO_OUTPUT | GPIO_PULLUP | GPIO_SMT_EN | GPIO_DRV_0);

    while (1) {
        bflb_gpio_set(gpio, GPIO_PIN_27);
        bflb_gpio_reset(gpio, GPIO_PIN_28);
        bflb_mtimer_delay_ms(500);

        bflb_gpio_reset(gpio, GPIO_PIN_27);
        bflb_gpio_set(gpio, GPIO_PIN_28);
        bflb_mtimer_delay_ms(500);
    }
}
hndrbrm commented 1 year ago

I create getting started gist

https://gist.github.com/hndrbrm/73713e2c33fb193685863ecde3440df7

brainstorm commented 1 year ago

@hndrbrm Just do a PR, mate: https://github.com/bouffalolab/bl_mcu_sdk/pull/90 ;)