n-miyamoto / k210-nuttx

Nuttx port for k210 RISC-V AI chip http://nuttx.org/
Other
4 stars 2 forks source link

implement led #7

Closed n-miyamoto closed 5 years ago

n-miyamoto commented 5 years ago

proting guide led support

http://www.nuttx.org/Documentation/NuttxPortingGuide.html#ledsupport

n-miyamoto commented 5 years ago

led sample for maix-bit

    if(fpioa_set_function(number, FUNC_GPIO3) < 0){
        return 0;
    }
    gpio_init();
    gpio_set_drive_mode(3, GPIO_DM_OUTPUT);
    gpio_pin_value_t value = GPIO_PV_HIGH;
    gpio_set_pin(3, value);
    printf("try led fin %d \n", number);
    while (1)
    {
        gpio_set_pin(3, value = !value);
        sleep(1);
    }

number should be

n-miyamoto commented 5 years ago
int core1_function(void *ctx){
    unt64_t core = current_coreid();
    printf("Core %ld Hello world\n", core);

    //for(int i=4;i<=63;i++)
    //    try_led(i);

    fpioa_set_function(12, FUNC_GPIO1);
    fpioa_set_function(13, FUNC_GPIO2);
    fpioa_set_function(14, FUNC_GPIO3);

    gpio_init();
    int r,g,b;
    r=1;g=2;b=3;
    gpio_set_drive_mode(r, GPIO_DM_OUTPUT);
    gpio_set_drive_mode(g, GPIO_DM_OUTPUT);
    gpio_set_drive_mode(b, GPIO_DM_OUTPUT);
    gpio_pin_value_t value = GPIO_PV_HIGH;
    gpio_set_pin(r, value);
    gpio_set_pin(g, value);
    gpio_set_pin(b, value);
    int count = 0;

    while (1)
    {
        count ++;
        sleep(1);
        gpio_set_pin(r, (count>>0)&1 );
        gpio_set_pin(g, (count>>1)&1);
        gpio_set_pin(b, (count>>2)&1);
    }
}
n-miyamoto commented 5 years ago

merged