chipKIT32 / chipKIT-core

Downloadable chipKIT core for use with Arduino 1.6 - 1.8+ IDE, PlatformIO, and UECIDE
http://chipkit.net/
Apache License 2.0
59 stars 53 forks source link

Add configuration and functions for CTMU to the core. RFC #360

Open majenkotech opened 7 years ago

majenkotech commented 7 years ago

Normally this kind of thing would be relegated to a library, but to make things simple for users I propose adding it as core functions and data.

const uint8_t   digital_pin_to_ctmu_PGM[] = {
    NOT_CTMU_PIN,
    7,
    3,
    NOT_CTMU_PIN,
    NOT_CTMU_PIN,
    NOT_CTMU_PIN,
    NOT_CTMU_PIN,
    NOT_CTMU_PIN,

    NOT_CTMU_PIN,
    NOT_CTMU_PIN,
    NOT_CTMU_PIN,
    NOT_CTMU_PIN,
    12,
    5,

    2,
    NOT_CTMU_PIN,
    NOT_CTMU_PIN,
    NOT_CTMU_PIN,
    13,
    NOT_CTMU_PIN,

    1,
    NOT_CTMU_PIN,
    NOT_CTMU_PIN,
    NOT_CTMU_PIN,
    NOT_CTMU_PIN,

    9,
    6,
    NOT_CTMU_PIN,

    4,
    10
};
extern const uint8_t    digital_pin_to_ctmu_PGM[];

#ifdef digitalPinToCTMU
#undef digialPinToCTMU
#endif
#define digitalPinToCTMU(P) ( digital_pin_to_ctmu_PGM[(P)] )

Since we would be needing to add the tables to the boards it may as well have the rest put in the core anyway rather than a library.

Comments? Go/No-go?

EmbeddedMan commented 7 years ago

Seems like a good idea to me - any centralization we can do of information like this is a good thing (if library authors use it).

*Brian

On Sat, Jul 15, 2017 at 5:32 PM, Majenko Technologies < notifications@github.com> wrote:

Normally this kind of thing would be relegated to a library, but to make things simple for users I propose adding it as core functions and data.

  • Add a table to each board that maps digital pins to CTMU channels, including a "NOT_CTMU_PIN" macro. For instance for the Lenny you would have:

const uint8_t digital_pin_to_ctmu_PGM[] = { NOT_CTMU_PIN, 7, 3, NOT_CTMU_PIN, NOT_CTMU_PIN, NOT_CTMU_PIN, NOT_CTMU_PIN, NOT_CTMU_PIN,

NOT_CTMU_PIN,
NOT_CTMU_PIN,
NOT_CTMU_PIN,
NOT_CTMU_PIN,
12,
5,

2,
NOT_CTMU_PIN,
NOT_CTMU_PIN,
NOT_CTMU_PIN,
13,
NOT_CTMU_PIN,

1,
NOT_CTMU_PIN,
NOT_CTMU_PIN,
NOT_CTMU_PIN,
NOT_CTMU_PIN,

9,
6,
NOT_CTMU_PIN,

4,
10

};

  • Add the stubs for functions to the defs file:

extern const uint8_t digital_pin_to_ctmu_PGM[];

ifdef digitalPinToCTMU

undef digialPinToCTMU

endif

define digitalPinToCTMU(P) ( digital_pin_to_ctmu_PGM[(P)] )

  • Write functions similar to analogRead(pin) etc for controlling and retrieving CTMU values (ctmuRead(pin) or analogReadCTMU(pin) or capSenseRead(pin) or something like that)

Since we would be needing to add the tables to the boards it may as well have the rest put in the core anyway rather than a library.

Comments? Go/No-go?

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/chipKIT32/chipKIT-core/issues/360, or mute the thread https://github.com/notifications/unsubscribe-auth/AAbeCBeK8tM_yHwW7OhNVh4b8J-Sk5dZks5sOT3fgaJpZM4OZJKC .