Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/rambo/chibios_cpp
Trying to get OOP to ChibiOS (and if it works will probably become RuuviTracker firmware)
https://github.com/rambo/chibios_cpp
Last synced: 16 days ago
JSON representation
Trying to get OOP to ChibiOS (and if it works will probably become RuuviTracker firmware)
- Host: GitHub
- URL: https://github.com/rambo/chibios_cpp
- Owner: rambo
- Created: 2014-09-07T01:00:36.000Z (about 10 years ago)
- Default Branch: master
- Last Pushed: 2014-10-13T22:36:02.000Z (about 10 years ago)
- Last Synced: 2024-07-31T22:58:26.689Z (3 months ago)
- Language: C
- Size: 297 KB
- Stars: 0
- Watchers: 2
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# ChibiOS C++ experiments
This branch is currently **ChibiOS 2.6**, but see branches chibios_26 and chibios_30 for more.
Running on Ruuvitracker devel HW (and if this goes well I will suggest moving the main RT firmware to C++ as well).
Any other STM32F4 board ought to work too.
## Coding standards
### Indentation
Hard-tabs, 4 spaces. Logical blocks are always indented. for example
switch(foo)
{
case 0x1:
bar = 1;
break;
}Different conditions in same if-statement go on separate lines
if ( !shelltp
&& (SDU.config->usbp->state == USB_ACTIVE))
{
board_green_led(PAL_HIGH);
shelltp = shellCreate(&shell_cfg1, SHELL_WA_SIZE, NORMALPRIO);
}### Curly brackets go to their own line
Like so:
if (foo)
{
bar = 1;
}This also demonstrates that even simple ifs with single statements will have their curly braces.
### Ternary operator is forbidden
It *really* hurts code readibility and breaks the rules about indentation.
if (foo)
{
bar = 1;
}
else
{
bar = 2;
}### Naming
We use the underscore style. Not CamelCase or javaCase (I know ChibiOS uses Java style, we do not, this also serves
the purpose of easily distinguishing our own stuff from ChibiOS stuff).For thread classes add `_thd` to the end of the name. For shell commands add `cmd_` to the beginning of the name.
### Types
Use the smallest type that is suitable, use the correct `xxx_t` typedef. Especially do not use `char` when you mean signed 8-bit integer, use `int8_t`.
Specify unsigned type if you are not going to use negative numbers, even if you do ne need the extra range.
### Object-Oriented
Use classes, do not be afraid to use inheritance (for example the accelerometer class should inherit from a generic I2C device class the common helper methods that each device is going to need).
There are cases where a single procedural function is a better choice, but if you find that you're passing pointer to commond data around you are probably better served by OOP-approach.