hal in Arduino

ChibiOS public support forum for all topics not covered by a specific support forum.

Moderators: RoccoMarco, lbednarz, tfAteba

Post Reply
matteo_malosio
Posts: 1
Joined: Fri Apr 18, 2014 10:04 am

hal in Arduino

Post by matteo_malosio »

Dear all,

I'd like to access to hal functionalities (e.g. RTT2US, halGetCounterFrequency(), ...) but I cannot.

I noticed that in the file

Code: Select all

hal.h

there is

Code: Select all

#ifndef _HAL_H_
#define _HAL_H_

#include "ch.h"

#if 0  // WHG
#include "board.h"
#include "halconf.h"
....................
.....................



It is not clear to me why

Code: Select all

#if 0  // WHG


Do you have any suggestion?
Thank you in advance!

Matteo
User avatar
Tectu
Posts: 1225
Joined: Thu May 10, 2012 9:50 am

Re: hal in Arduino

Post by Tectu »

matteo_malosio wrote:It is not clear to me why

Code: Select all

#if 0  // WHG

I couldn't find that one in my /os/hal/include/hal.h, where did you find that? Which ChibiOS/RT version are you using?

Anyway, to answer your question: Many developers do wrap code around an #if 0 macro to exclude code. When the 0 is toggled to a 1 it will be included again. This is pretty much like when you would comment out the whole code block using /* ... */ but this one is simpler to re-enable again.
Another (important) reason why this technique is used is because you cannot have nested multi-line comments. This post explains it pretty well.


~ Tectu
User avatar
Giovanni
Site Admin
Posts: 14895
Joined: Wed May 27, 2009 8:48 am
Has thanked: 1202 times
Been thanked: 997 times

Re: hal in Arduino

Post by Giovanni »

That must be a customization because in the ChibiOS code there are no "#if 0".

halGetCounterFrequency() is an optional API, the AVR HAL does not implement it.

Giovanni
Post Reply