KurtE
Senior Member+
I was taking a look through the new Wire library (WireKinetis.cpp/h) and noticed that the new library is not supporting all of the valid SCL/SDA pins that the previous version was.
In particular it is only supporting those pins that have mux(2)...
If you look at the removed code, in this case: for the main Wire Object.
You will see there are casws for Mux 5 and Mux 7 which are not built into your new tables.
Looks like the table code should support it as you have pin number and mux numbers in the table.
If desired I can take a pass and add, and do Pull request.
In particular it is only supporting those pins that have mux(2)...
If you look at the removed code, in this case: for the main Wire Object.
Code:
-void TwoWire::setSDA(uint8_t pin)
-{
- if (pin == sda_pin_num) return;
- if ((SIM_SCGC4 & SIM_SCGC4_I2C0)) {
- if (sda_pin_num == 18) {
- CORE_PIN18_CONFIG = 0;
- } else if (sda_pin_num == 17) {
- CORE_PIN17_CONFIG = 0;
-#if defined(__MK64FX512__) || defined(__MK66FX1M0__)
- } else if (sda_pin_num == 34) {
- CORE_PIN34_CONFIG = 0;
- } else if (sda_pin_num == 8) {
- CORE_PIN8_CONFIG = 0;
- } else if (sda_pin_num == 48) {
- CORE_PIN48_CONFIG = 0;
-#endif
- }
-
- if (pin == 18) {
- CORE_PIN18_CONFIG = PORT_PCR_MUX(2)|PORT_PCR_ODE|PORT_PCR_SRE|PORT_PCR_DSE;
- } else if (pin == 17) {
- CORE_PIN17_CONFIG = PORT_PCR_MUX(2)|PORT_PCR_ODE|PORT_PCR_SRE|PORT_PCR_DSE;
-#if defined(__MK64FX512__) || defined(__MK66FX1M0__)
- } else if (pin == 34) {
- CORE_PIN34_CONFIG = PORT_PCR_MUX(5)|PORT_PCR_ODE|PORT_PCR_SRE|PORT_PCR_DSE;
- } else if (pin == 8) {
- CORE_PIN8_CONFIG = PORT_PCR_MUX(7)|PORT_PCR_ODE|PORT_PCR_SRE|PORT_PCR_DSE;
- } else if (pin == 48) {
- CORE_PIN48_CONFIG = PORT_PCR_MUX(2)|PORT_PCR_ODE|PORT_PCR_SRE|PORT_PCR_DSE;
-#endif
- }
- }
- sda_pin_num = pin;
-}
-
-void TwoWire::setSCL(uint8_t pin)
-{
- if (pin == scl_pin_num) return;
- if ((SIM_SCGC4 & SIM_SCGC4_I2C0)) {
- if (scl_pin_num == 19) {
- CORE_PIN19_CONFIG = 0;
- } else if (scl_pin_num == 16) {
- CORE_PIN16_CONFIG = 0;
-#if defined(__MK64FX512__) || defined(__MK66FX1M0__)
- } else if (scl_pin_num == 33) {
- CORE_PIN33_CONFIG = 0;
- } else if (scl_pin_num == 7) {
- CORE_PIN7_CONFIG = 0;
- } else if (scl_pin_num == 47) {
- CORE_PIN47_CONFIG = 0;
-#endif
- }
-
- if (pin == 19) {
- CORE_PIN19_CONFIG = PORT_PCR_MUX(2)|PORT_PCR_ODE|PORT_PCR_SRE|PORT_PCR_DSE;
- } else if (pin == 16) {
- CORE_PIN16_CONFIG = PORT_PCR_MUX(2)|PORT_PCR_ODE|PORT_PCR_SRE|PORT_PCR_DSE;
-#if defined(__MK64FX512__) || defined(__MK66FX1M0__)
- } else if (pin == 33) {
- CORE_PIN33_CONFIG = PORT_PCR_MUX(5)|PORT_PCR_ODE|PORT_PCR_SRE|PORT_PCR_DSE;
- } else if (pin == 7) {
- CORE_PIN7_CONFIG = PORT_PCR_MUX(7)|PORT_PCR_ODE|PORT_PCR_SRE|PORT_PCR_DSE;
- } else if (pin == 47) {
- CORE_PIN47_CONFIG = PORT_PCR_MUX(2)|PORT_PCR_ODE|PORT_PCR_SRE|PORT_PCR_DSE;
-#endif
- }
- }
- scl_pin_num = pin;
-}
You will see there are casws for Mux 5 and Mux 7 which are not built into your new tables.
Looks like the table code should support it as you have pin number and mux numbers in the table.
If desired I can take a pass and add, and do Pull request.