Pages: [1]   Go Down
Author Topic: [FIXED][CapacitiveSensor] Can't compile with Due (port manipulation)  (Read 688 times)
0 Members and 1 Guest are viewing this topic.
Bologna, Italy
Offline Offline
Newbie
*
Karma: 0
Posts: 17
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Hi,
I'm using the CapacitiveSensor library from here: http://playground.arduino.cc//Main/CapacitiveSensor
It works great with my Leonardo (AVR), but it can't compile with Due and here are the errors explained:
  • portOutputRegister(PIN) and portInputRegister(PIN) were returning a uint8_t and now they return RwReg.
  • portModeRegister(PIN) isn't available on the Due. (Arduino.h code is commented out)

Now my question is:
I changed the uint8_t registers to RwReg (compiler doesn't complain) and I replaced the use of portModeRegister(PIN) with simple pinMode(PIN, MODE) calls (it's slower but it works).
  • Do the RwReg need to be handled in a different way? (the code works but I'm not an expert)
  • Is there a faster way than using pinMode(PIN, MODE) on Due?
  • Should I care about clock cycles since the old arduino was 16MHz and Due is 84MHz? smiley-razz

I'm waiting some feedback, then I'm going to rewrite the whole code to be Due-compatible and release a patch.
« Last Edit: February 06, 2013, 02:28:54 am by Liarco » Logged

Bologna, Italy
Offline Offline
Newbie
*
Karma: 0
Posts: 17
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

I finally released my own version of this library and it works on Arduino Due. smiley-lol

I made a pull request to the only repository that I found about this library: https://github.com/arduino-libraries/CapacitiveSensor/pull/1

I hope that someone can optimize it because I'm just a beginner with Arduino. smiley-red
Logged

Pages: [1]   Go Up
Jump to: