Community
cancel
Showing results for 
Search instead for 
Did you mean: 
Yemaya_B_Intel
Employee
1,245 Views

CapacitiveSensor library support for Galileo

Jump to solution

I am trying to compile a project that requires the CapacitiveSensor library, which can be found here: https://github.com/PaulStoffregen/CapacitiveSensor GitHub - PaulStoffregen/CapacitiveSensor: Detect touch or proximity by capacitve sensing.

This seems to be a standard library for projects, however, I get the error:

CapacitiveSensor.h:239: error: 'IO_REG_TYPE' does not name a type

CapacitiveSensor.h:240: error: 'IO_REG_TYPE' does not name a type

CapacitiveSensor.h:241: error: 'IO_REG_TYPE' does not name a type

CapacitiveSensor.h:242: error: 'IO_REG_TYPE' does not name a type

This points to the below lines in the library file:

IO_REG_TYPE sBit; // send pin's ports and bitmask

volatile IO_REG_TYPE *sReg;

IO_REG_TYPE rBit; // receive pin's ports and bitmask

volatile IO_REG_TYPE *rReg;

Is there any support for Galileo? I'd like to compile this project: http://www.instructables.com/id/Capacitive-Touch-Arduino-Keyboard-Piano/?ALLSTEPS# step9 Capacitive-Touch Arduino Keyboard Piano - All

Thanks!


Accepted Solutions
idata
Community Manager
73 Views

Hi YB,

The OneWire library is not currently working for the Galileo board. The CapacitiveSensor library uses the OneWire.h and OneWire.cpp but the Arduino IDE uses the libraries for Arduino as default, you need to add the OneWire.h and OneWIre.cpp for Galileo into the same folder where the CapacitiveSensor library is located.(Please keep this in mind if in the future you add more third party libraries). The OneWire library haven't being updated in order to work with the Galileo.

OneWire library can be found on: C:\Users\\AppData\Local\Arduino15\packages\Intel\hardware\i586\1.6.2+1.0\libraries\CapacitiveSensor-...

This library checks the architecture with:

 

if defined(__AVR__)

...

 

# elif defined(__MK20DX128__)

 

 

else

 

# error "Please define I/O register types here"

The error you get is due that the Arduino IDE and the OneWire library can't identify the architecture successfully. My suggestion for this would be to create a custom library for your project in order to load all the requirements that the CapacitiveSensor needs. Another approach would be to modify the OneWire library and add the functionality for the Galileo Board.

Regards,

 

Charlie

View solution in original post

5 Replies
FTinetti
Honored Contributor I
73 Views

IO_REG_TYPE seems to be some platform-specific definition missing in Galileo...

Fernando.

Yemaya_B_Intel
Employee
73 Views

Thank you, Fernando! Any direction for resolving this?

idata
Community Manager
74 Views

Hi YB,

The OneWire library is not currently working for the Galileo board. The CapacitiveSensor library uses the OneWire.h and OneWire.cpp but the Arduino IDE uses the libraries for Arduino as default, you need to add the OneWire.h and OneWIre.cpp for Galileo into the same folder where the CapacitiveSensor library is located.(Please keep this in mind if in the future you add more third party libraries). The OneWire library haven't being updated in order to work with the Galileo.

OneWire library can be found on: C:\Users\\AppData\Local\Arduino15\packages\Intel\hardware\i586\1.6.2+1.0\libraries\CapacitiveSensor-...

This library checks the architecture with:

 

if defined(__AVR__)

...

 

# elif defined(__MK20DX128__)

 

 

else

 

# error "Please define I/O register types here"

The error you get is due that the Arduino IDE and the OneWire library can't identify the architecture successfully. My suggestion for this would be to create a custom library for your project in order to load all the requirements that the CapacitiveSensor needs. Another approach would be to modify the OneWire library and add the functionality for the Galileo Board.

Regards,

 

Charlie

View solution in original post

PStof1
Beginner
73 Views

I am the maintainer of the OneWire and CapacitiveSensor (and several other) Arduino libraries.

These libraries require rapid access to digital I/O pins, faster than can be achieved with the normal Arduino digitalWrite, digitalRead and pinMode functions. To accomplish this, these libraries write directly to the memory-mapped hardware registers which control the pins. Because different microcontrollers have different hardware registers, a small set of C preprocessor macros abstract the hardware.

I do not have a Galileo board, and even if I did have one, I probably would not have the time to study its hardware registers (if Intel even provides that level of technical detail?) Like most library authors, I depend on the open source community, or the companies who make these products, to contribute these small amounts of code which are required to make their products work.

If anyone wants to attempt this, the macros are fairly simple. You can see examples for most of the widely used Arduino compatible boards in OneWire.h or CapacitiveSensor.h. The assumption is the library must store a pointer to a set of hardware registers, and also a number (bitmask) to be used when reading or writing. The data type of that number is defined at IO_REG_TYPE. For example, on 8 bit AVR processors, the hardware registers are 8 bits, so IO_REG_TYPE is defined as uint8_t. On the SAM3X (32 bit ARM Cortex-M3) processor used on Arduino Due, the hardware registers are 32 bits. So for Due, IO_REG_TYPE is defined as uint32_t. The IO_REG_TYPE macro is used within the library code so the library automatically adapts for 8 bit registers on AVR, 32 bit registers on ARM, and possibly other types on other hardware.

Likewise, 2 macros allow converting Arduino pin numbers to the pointer and bitmask. Most boards have macros within their core libraries or variant header files, but there is little standardization. These macros allow the libraries to automatically use different code which adapts to whatever specific translations each board uses between pin numbers and actual hardware registers and bitmasks. Of course, there are also 5 macros for performing the fast I/O operations, which take the pointer and bitmask as inputs.

I would hope someone within Intel who supports these products has interest in making the very widely used Arduino libraries actually work. I have personally gone to quite a lot of trouble to make OneWire, CapacitiveSensor and other libraries as easy to adapt as possible. You only need to create these few simple macros.

This is the way open source works. If you want your Galileo product to work with OneWire or CapacitiveSensor, all you need to do is create these minimal hardware defines, test them on your board, and then submit a pull request on Github. It should go without saying, but I'll say it anyway, your edits should be confined to only this set of # define macros.

idata
Community Manager
73 Views

Hi Paul,

 

 

I have used the OneWire and CapacitiveSensor libraries before, and I thank you very much for your help and support with these libraries.

 

We also appreciate your suggestions for using these libraries; I already passed your suggestions to the proper team so we could see some improvements in the libraries for Arduino on the Galileo and Edison boards.

 

 

Thanks and best regards,

 

 

Charlie