Skip to content

Tutorial: How to port a radio module driver to RIOT OS

Nenaco edited this page Jul 27, 2016 · 24 revisions

Table of Contents

Attention: Work in progress (content is coming step by step / feel free and make corrections and add your experience)

How to port/develop a driver for a new radio module to RIOT-OS (for Netdev2)

The intention for this page is just to give RIOT newbies a guide to develop or port a driver for their prefered radio module. In fact there are actually many boards supported by RIOT OS but only a few radio modules. Maybe this page can help to change the situation.

Prerequisites:

  • First: You need two pieces of hardware - at least one microcontroller board (well known to work with RIOT) and the Radio Module for which you want to write the software driver. Blind programming (without having the hardware) maybe interesting, but doesn't really make sense....
  • Be shure you have all the documents of the module (which provides you information about connecting the module to the big wide world) and also from the silicon (chip datasheet, manual, application notes which can provide you information about protocols, timings, register-sets and so on...)
  • You need a working toolchain and a working programming environment / IDE (e.g. Eclipse)
  • You need a hardware emulation probe which provides you the possibily to programm your firmware onto the microcontroller-board and which provides you the possibility to trace through the code....
  • And last, but not least you probably need an oscilloscope for measuring the traffic which is going on between the microcontroller board and the radio module (or should I say - "which should go on between....")
?## Hints about "How to Start"
  • Take a look into the code of software-drivers which could be used as a blue-print for your own driver. In the case of a **netdev2-radio-driver** this could be the code for the Atmel at86rf2xx family. The datasheet for this piece of silicon would be also helpful to understand what's going in in this driver - if not all parts are described in this tutorial ;-)
  • Stick together your hardware parts (microcontroller-board and radio-module). Most of the radio modules are using an SPI-Interface as the communication pipeline between the microcontroller and the radio-module. But don't forget the other necessary signals (chip-select(s), reset-line, interrupt-line(s), wake/sleep e.g.) and Last but not least the power-supply (VCC, GND).




    1. Preview:
      1. Which directories have to be created?
We have to create a directory unter the /drivers path which has the name of the later create driver and under this an include directory mkdir ~/RIOT/drivers/<driver-name> mkdir ~/RIOT/drivers/&lt;driver&#45;name&gt;&lt;/driver&#45;name&gt&lt;/include

&gt;</driver-name>Which files have to be created?

The following file have to be created or copied from another driver

~/RIOT/drivers/&amp;lt&#59;driver&amp;&#35;45&#59;name&amp;gt&#59;/&amp;lt&#59;driver&amp;&#35;45&#59;name&amp;gt&#59;_internal.c

~/RIOT/drivers/&amp;lt&#59;driver&amp;&#35;45&#59;name&amp;gt&#59;/&amp;lt&#59;driver&amp;&#35;45&#59;name&amp;gt&#59;_getset.c

~/RIOT/drivers/&amp;lt&#59;driver&amp;&#35;45&#59;name&amp;gt&#59;/&amp;lt&#59;driver&amp;&#35;45&#59;name&amp;gt&#59;_netdev.c

~/RIOT/drivers/&amp;lt&#59;driver&amp;&#35;45&#59;name&amp;gt&#59;/include/&amp;lt&#59;driver&amp;&#35;45&#59;name&amp;gt&#59;_registers.h

~/RIOT/drivers/&amp;lt&#59;driver&amp;&#35;45&#59;name&amp;gt&#59;/include/&amp;lt&#59;driver&amp;&#35;45&#59;name&amp;gt&#59;_params.h

~/RIOT/drivers/&amp;lt&#59;driver&amp;&#35;45&#59;name&amp;gt&#59;/include/&amp;lt&#59;driver&amp;&#35;45&#59;name&amp;gt&#59;_internal.c

~/RIOT/drivers/&amp;lt&#59;driver&amp;&#35;45&#59;name&amp;gt&#59;/include/&amp;lt&#59;driver&amp;&#35;45&#59;name&amp;gt&#59;_netdev.h

~/RIOT/drivers/include/&amp;lt&#59;driver&amp;&#35;45&#59;name&amp;gt&#59;.h

Which files have to be altered?

~/RIOT/drivers/Makefile.dep

~/RIOT/drivers/Makefile.include

Clone this wiki locally