RIOT icon indicating copy to clipboard operation
RIOT copied to clipboard

Define a standard API for radio transceivers' drivers

Open rousselk opened this issue 12 years ago • 3 comments

It seems to me that having a standard API (i.e. an interface, or more precisely--since we're using C language--a struct of function pointers) that all drivers for radio transceivers have to comply to, would be a welcome addition.

It would considerably ease the task of developing MAC/RDC protocols, that actually need to control directly radio transceivers for acceptable efficiency.

It should also simplify the interface with the 'transceiver' module, which currently uses message passing for control. The message passing method is elegant and flexible, but is quite RAM-hungry; on low-end devices (like MSP430, which only have some Kbytes of RAM) this could quickly become an issue, if we want to develop heavyweight applications (e.g. with many threads and especially their stack space) along with advanced radio communication (with MAC, routing and so on).

Most of these drivers already have a very similar set of "public" functions, so the adaptation shouldn't be long nor hard.

rousselk avatar Mar 25 '14 13:03 rousselk

see #752

miri64 avatar Mar 25 '14 15:03 miri64

Actually, I thought about something much simpler, and specific to radio drivers. Something like:

#include <stdbool.h>

...

typedef void (* receive_callback_t)(void *buf, unsigned len);

typedef enum {
    TX_OK,
    TX_COLLISION,
    TX_NOACK,
    TX_ERROR,
} tx_status_t;

typedef struct {
    void (* on)(void);
    void (* off)(void);
    tx_status_t (* send)(void *buf, unsigned len);
    void (* set_receive)(receive_callback_t recv_func);
    void (* set_channel)(unsigned chan);
    unsigned (* get_channel)(void);
    void (* set_address)(uint16_t addr);
    uint16_t (* get_address)(void);
    void (* set_long_address)(uint64_t addr);
    uint64_t (* get_long_address)(void);
    void (* set_pan_id)(uint16_t pan);
    uint16_t (* get_pan_id)(void);
    bool (* channel_clear)(void);
} ieee802154_radio_driver_t;

Maybe should I actually go on and propose a PR with an API proposal?...

rousselk avatar Mar 25 '14 16:03 rousselk

Done, my proposition is in #925.

rousselk avatar Mar 26 '14 10:03 rousselk