forked from RIOT-OS/RIOT
-
Notifications
You must be signed in to change notification settings - Fork 1
Best Practice for RIOT Programming
PeterSchmerzl edited this page Apr 6, 2016
·
5 revisions
Some "Dos" and "Don'ts" for RIOT development:
- Use static memory. See also Static vs. Dynamic Memory.
- Select the priorities carefully.
- Minimize stack usage with
DEVELHELP
andCREATE_STACKTEST
. - Use threads to increase flexibility, modularity, and robustness by leveraging IPC.
- Don't use too many threads. Try not to use more than one thread per module. Don't create threads for one-time tasks.
- Don't use the POSIX wrapper if implementing something from scratch.
- Don't allocate big chunks of memory (for instance the IPC message queue) on the stack, but use rather static memory for that.
- Don't use enums for flags, because flags have a width in memory that is in most cases smaller than
sizeof(enum)
(most bitfields are 16 bits max, on most of our newer platforms,sizeof(enum)
is however 32 bits). This results in every assignment needed to be cast to eitheruint8_t
oruint16_t
. With macros you don't need to cast since they are typeless. Making the enum packed makes its width unpredictable in terms of alignment issues, when used in struct.
RIOT - The friendly Operating System for the Internet of Things
Homepage | [GitHub] (https://github.com/RIOT-OS/) | Developers Mailing List | Users Mailing List | Twitter @RIOT_OS
- Family: ARM
- Board: Airfy Beacon
- Board: Arduino Due
- Board: CC2538DK
- Board: CC2650STK
- Board: HikoB Fox
- Board: IoT LAB M3
- Board: LimiFrog-v1
- Board: mbed_lpc1768
- Board: MSB-IoT
- Board: MSBA2
- Board: Nucleo-L1
- Board: Nucleo-F334
- Board: Nucleo-F303
- Board: Nucleo-F091
- Board: Mulle
- Board: OpenMote
- Board: PCA1000x (nRF51822 Development Kit)
- Board: Phytec phyWAVE-KW22
- Board: RFduino
- Board: SAMR21-xpro
- Board: SAML21-xpro
- Board: Spark Core
- Board: STM32F0discovery
- Board: STM32F3discovery
- Board: STM32F4discovery
- Board: UDOO
- Board: yunjia-nrf51822
- Board: Zolertia remote
- Family: ATmega
- Board: Arduino Mega2560
- Family: MSP430
- Board: MSB-430H
- Board: TelosB
- Board: WSN430
- Board: Zolertia Z1
- Board: eZ430-Chronos
- Family: native
- Board: native
- Family: x86
- Board: Intel Galileo