I'm using the CapacitiveSensor library from here: Arduino Playground - HomePage
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?
I'm waiting some feedback, then I'm going to rewrite the whole code to be Due-compatible and release a patch.