[riot-users] Starting Riot

DangNhat PhamHuu phamhuudangnhat at gmail.com
Mon Oct 13 04:23:01 CEST 2014


Hi Marcio,
I’m not sure about Nodric uC but I think I can answer some of your
questions.

   1. Actually, riot will call main instead. When uC start from a reset
   (power-on-reset or software/hardware reset), it will do some initialization
   (which can be found in cpu/nRF51822/startup.c, i think). Then, in a
   bare-metal program, it will call main but in RIOT, kernel_init will be
   called instead. kernel_init will then create 2 threads, idle_thread and
   main_thread with our main program.
   2. In main, we can create other threads using thread_create function.
   APIs can be found here [1]
   3. Thread priority will be assigned when we create thread. [1]
   4. Not sure there any better manuals yet but we can found the APIs in
   [2]. Infomation about mutex, scheduling, threads, etc. are in kernel module.

I think a small example like this should work in the way you want. We’ll
have 2 tasks which print their names continuously.

#include <stdio.h>
#include "vtimer.h"#include "thread.h"
const int16_t led_toggling_stack_size = 1024;char
led_toggling_stack[led_toggling_stack_size];
int16_t led_toggling_pid;
void *led_toggling(void *arg)
{
    while (1) {
        printf("We're in %s\n", thread_getname(thread_getpid()));
        vtimer_usleep(1000000); // you can adjust this value for your uC
    }

    return NULL;
}
int main(void)
{
    int count;

    led_toggling_pid = thread_create(led_toggling_stack,
            led_toggling_stack_size,
            PRIORITY_MAIN - 1,
            0,
            led_toggling,
            NULL,
            "Led toggling thread");
    if (led_toggling_pid < 0) {
        printf("Can't create thread\n");
    }

    while (1) {
        printf("We're in %s\n", thread_getname(thread_getpid()));

        for (count = 0; count < 10000000; count++) { // you can adjust
this value for your uC
            ;
        }
    }

    return 0;
}

Cheers,
Nhat.

[1] http://riot-os.org/api/group__core__thread.html
[2] http://riot-os.org/api
​

/**
 * @Name: Phạm Hữu Đăng Nhật
 * @StudentID: 51002279
 * @Class: MT10KTTN
 * Ho Chi Minh University of Technology
 * @Mobile: 0164.968.2716
 */

On 13 October 2014 02:59, Satyan Raj <satyan at denarit.com> wrote:

> Hello Friends,
>
> I am using nrf51822 mcu on 2 projects. We are considering RIOT OS. But
> while looking at github commits, RIOT for nrf mcu is in very early stage.
>
> By when can we expect BLE and other peripherals lib like I2C, ADC, SPI and
> UART to be available.
>
> Fyi: Nordic just released s120 softdrive.
>
> Thanks and regards,
> Satyan Raj
>
>
>
>
>
> On 13 Oct 2014 01:14, "Marcio Segura" <marciopps at gmx.com> wrote:
> >
> > Hi friends, I am starting using RIOT (uC Nordic nRF51822, Board
> pca10000) but I have some issues I would like you could help me:
> > 1. I couldn't figure out when the OS takes control of the uC, because in
> some examples the "main(void)" procedure never calls Riot.
> > 2. I couldn't figure out how to make more than one independent task.
> Again in "main(void)" looks like a bare metal program.
> > 3. Solving the issue 2, when I put the priority on each task?
> > 4. Do you have some kind of manual or example telling the configuration
> of semaphores, mutex, events? There are some example with 2 or more simple
> tasks like a "blinking led" and "display writing" in same program?
> >
> > Thank you,
> >
> > Marcio Segura
> >
> >
> > _______________________________________________
> > users mailing list
> > users at riot-os.org
> > http://lists.riot-os.org/mailman/listinfo/users
> >
>
>
> _______________________________________________
> users mailing list
> users at riot-os.org
> http://lists.riot-os.org/mailman/listinfo/users
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.riot-os.org/pipermail/users/attachments/20141013/702c5def/attachment-0001.html>


More information about the users mailing list