
Test program running on MAX32625MBED. Control through USB Serial commands using a terminal emulator such as teraterm or putty.
Dependencies: MaximTinyTester CmdLine MAX541 USBDevice
Revision 68:ffee1e54d3fe, committed 2020-02-20
- Comitter:
- whismanoid
- Date:
- Thu Feb 20 10:21:21 2020 +0000
- Parent:
- 67:5b8a495dda1c
- Child:
- 69:989e392cf635
- Commit message:
- digitalInOut menu %H %L %?
Changed in this revision
MAX11043/MAX11043.h | Show annotated file Show diff for this revision Revisions of this file |
Test_Main_MAX11043.cpp | Show annotated file Show diff for this revision Revisions of this file |
--- a/MAX11043/MAX11043.h Thu Feb 20 01:16:25 2020 +0000 +++ b/MAX11043/MAX11043.h Thu Feb 20 10:21:21 2020 +0000 @@ -183,17 +183,17 @@ * * // example code declare SPI interface * #if defined(TARGET_MAX32625MBED) - * // TODO1: support SPI hardware-controlled CS instead of GPIO CS (mbed) - * // 2020-02-19 attempting to improve SPI CS timing. - * // Currently CS envelope is 23us (11.4us before SCLK and 8.6us after SCLK). - * // MAX11043 slowest EOC rate is 9us. - * // Trying to use SPI-controlled CS configuration. Not working yet. + * // SPI spi(SPI1_MOSI, SPI1_MISO, SPI1_SCK); // mosi, miso, sclk spi1 TARGET_MAX32625MBED: P1_1 P1_2 P1_0 Arduino 10-pin header D11 D12 D13 D10 + * // DigitalOut spi_cs(SPI1_SS); // TARGET_MAX32625MBED: not connected + * // Support SPI hardware-controlled CS instead of GPIO CS (mbed) + * // 2020-02-19 MAX32625MBED GPIO CS envelope is 23us (11.4us before SCLK and 8.6us after SCLK). + * // 2020-02-19 MAX32625MBED SPI controlled CS envelope 4 channel read reduced to 4.2us (24MHz SCLK), 1.2us setup, 0us hold. + * // 2020-02-19 MAX11043 slowest EOC rate is 9us. * SPI spi(SPI1_MOSI, SPI1_MISO, SPI1_SCK, SPI1_SS); // mosi, miso, sclk spi1 TARGET_MAX32625MBED: P1_1 P1_2 P1_0 Arduino 10-pin header D11 D12 D13 D10 * DigitalOut spi_cs(NC); // TARGET_MAX32625MBED: not connected * // PinName NC means NOT_CONNECTED; DigitalOut::is_connected() returns false - * // compile/link but runtime error Assertion failed: obj->name != (PinName)NC - * // so something is incorrectly trying to drive the CS pin, which is illegal since it's NC - * // TODO: add m_cs_pin.is_connected() guard before writing m_cs_pin = m_SPI_cs_state + * // add m_cs_pin.is_connected() guard before writing m_cs_pin = m_SPI_cs_state + * // to avoid runtime error Assertion failed: obj->name != (PinName)NC * #elif defined(TARGET_MAX32600MBED) * SPI spi(SPI2_MOSI, SPI2_MISO, SPI2_SCK); // mosi, miso, sclk spi1 TARGET_MAX32600MBED: Arduino 10-pin header D11 D12 D13 * DigitalOut spi_cs(SPI2_SS); // Generic: Arduino 10-pin header D10
--- a/Test_Main_MAX11043.cpp Thu Feb 20 01:16:25 2020 +0000 +++ b/Test_Main_MAX11043.cpp Thu Feb 20 10:21:21 2020 +0000 @@ -505,6 +505,460 @@ #endif +// uncrustify-0.66.1 *INDENT-OFF* +//-------------------------------------------------- +// Declare the DigitalInOut GPIO pins +// Optional digitalInOut support. If there is only one it should be digitalInOut1. +// D) Digital High/Low/Input Pin +#if defined(TARGET_MAX32630) +// +-------------[microUSB]-------------+ +// | J1 MAX32630FTHR J2 | +// | [ ] RST GND [ ] | +// | [ ] 3V3 BAT+[ ] | +// | [ ] 1V8 reset SW1 | +// | [ ] GND J4 J3 | +// | [ ] AIN_0 1.2Vfs (bat) SYS [ ] | +// | [ ] AIN_1 1.2Vfs PWR [ ] | +// | [ ] AIN_2 1.2Vfs +5V VBUS [ ] | +// | [ ] AIN_3 1.2Vfs 1-WIRE P4_0 [ ] | dig9 +// dig10 | [x] P5_7 SDA2 SRN P5_6 [ ] | dig8 +// dig11 | [x] P6_0 SCL2 SDIO3 P5_5 [ ] | dig7 +// dig12 | [x] P5_0 SCLK SDIO2 P5_4 [ ] | dig6 +// dig13 | [x] P5_1 MOSI SSEL P5_3 [x] | dig5 +// dig14 | [ ] P5_2 MISO RTS P3_3 [ ] | dig4 +// dig15 | [ ] P3_0 RX CTS P3_2 [ ] | dig3 +// dig0 | [ ] P3_1 TX SCL P3_5 [x] | dig2 +// | [ ] GND SDA P3_4 [x] | dig1 +// +------------------------------------+ + #define HAS_digitalInOut0 1 // P3_1 TARGET_MAX32630 J1.15 + #define HAS_digitalInOut1 1 // P3_4 TARGET_MAX32630 J3.12 + #define HAS_digitalInOut2 1 // P3_5 TARGET_MAX32630 J3.11 + #define HAS_digitalInOut3 1 // P3_2 TARGET_MAX32630 J3.10 + #define HAS_digitalInOut4 1 // P3_3 TARGET_MAX32630 J3.9 + #define HAS_digitalInOut5 1 // P5_3 TARGET_MAX32630 J3.8 + #define HAS_digitalInOut6 1 // P5_4 TARGET_MAX32630 J3.7 + #define HAS_digitalInOut7 1 // P5_5 TARGET_MAX32630 J3.6 + #define HAS_digitalInOut8 1 // P5_6 TARGET_MAX32630 J3.5 + #define HAS_digitalInOut9 1 // P4_0 TARGET_MAX32630 J3.4 +#if HAS_I2C +// avoid resource conflict between P5_7, P6_0 I2C and DigitalInOut + #define HAS_digitalInOut10 0 // P5_7 TARGET_MAX32630 J1.9 + #define HAS_digitalInOut11 0 // P6_0 TARGET_MAX32630 J1.10 +#else // HAS_I2C + #define HAS_digitalInOut10 1 // P5_7 TARGET_MAX32630 J1.9 + #define HAS_digitalInOut11 1 // P6_0 TARGET_MAX32630 J1.10 +#endif // HAS_I2C +#if HAS_SPI +// avoid resource conflict between P5_0, P5_1, P5_2 SPI and DigitalInOut + #define HAS_digitalInOut12 0 // P5_0 TARGET_MAX32630 J1.11 + #define HAS_digitalInOut13 0 // P5_1 TARGET_MAX32630 J1.12 + #define HAS_digitalInOut14 0 // P5_2 TARGET_MAX32630 J1.13 + #define HAS_digitalInOut15 0 // P3_0 TARGET_MAX32630 J1.14 +#else // HAS_SPI + #define HAS_digitalInOut12 1 // P5_0 TARGET_MAX32630 J1.11 + #define HAS_digitalInOut13 1 // P5_1 TARGET_MAX32630 J1.12 + #define HAS_digitalInOut14 1 // P5_2 TARGET_MAX32630 J1.13 + #define HAS_digitalInOut15 1 // P3_0 TARGET_MAX32630 J1.14 +#endif // HAS_SPI +#if HAS_digitalInOut0 + DigitalInOut digitalInOut0(P3_1, PIN_INPUT, PullUp, 1); // P3_1 TARGET_MAX32630 J1.15 +#endif +#if HAS_digitalInOut1 + DigitalInOut digitalInOut1(P3_4, PIN_INPUT, PullUp, 1); // P3_4 TARGET_MAX32630 J3.12 +#endif +#if HAS_digitalInOut2 + DigitalInOut digitalInOut2(P3_5, PIN_INPUT, PullUp, 1); // P3_5 TARGET_MAX32630 J3.11 +#endif +#if HAS_digitalInOut3 + DigitalInOut digitalInOut3(P3_2, PIN_INPUT, PullUp, 1); // P3_2 TARGET_MAX32630 J3.10 +#endif +#if HAS_digitalInOut4 + DigitalInOut digitalInOut4(P3_3, PIN_INPUT, PullUp, 1); // P3_3 TARGET_MAX32630 J3.9 +#endif +#if HAS_digitalInOut5 + DigitalInOut digitalInOut5(P5_3, PIN_INPUT, PullUp, 1); // P5_3 TARGET_MAX32630 J3.8 +#endif +#if HAS_digitalInOut6 + DigitalInOut digitalInOut6(P5_4, PIN_INPUT, PullUp, 1); // P5_4 TARGET_MAX32630 J3.7 +#endif +#if HAS_digitalInOut7 + DigitalInOut digitalInOut7(P5_5, PIN_INPUT, PullUp, 1); // P5_5 TARGET_MAX32630 J3.6 +#endif +#if HAS_digitalInOut8 + DigitalInOut digitalInOut8(P5_6, PIN_INPUT, PullUp, 1); // P5_6 TARGET_MAX32630 J3.5 +#endif +#if HAS_digitalInOut9 + DigitalInOut digitalInOut9(P4_0, PIN_INPUT, PullUp, 1); // P4_0 TARGET_MAX32630 J3.4 +#endif +#if HAS_digitalInOut10 + DigitalInOut digitalInOut10(P5_7, PIN_INPUT, PullUp, 1); // P5_7 TARGET_MAX32630 J1.9 +#endif +#if HAS_digitalInOut11 + DigitalInOut digitalInOut11(P6_0, PIN_INPUT, PullUp, 1); // P6_0 TARGET_MAX32630 J1.10 +#endif +#if HAS_digitalInOut12 + DigitalInOut digitalInOut12(P5_0, PIN_INPUT, PullUp, 1); // P5_0 TARGET_MAX32630 J1.11 +#endif +#if HAS_digitalInOut13 + DigitalInOut digitalInOut13(P5_1, PIN_INPUT, PullUp, 1); // P5_1 TARGET_MAX32630 J1.12 +#endif +#if HAS_digitalInOut14 + DigitalInOut digitalInOut14(P5_2, PIN_INPUT, PullUp, 1); // P5_2 TARGET_MAX32630 J1.13 +#endif +#if HAS_digitalInOut15 + DigitalInOut digitalInOut15(P3_0, PIN_INPUT, PullUp, 1); // P3_0 TARGET_MAX32630 J1.14 +#endif +//-------------------------------------------------- +#elif defined(TARGET_MAX32625MBED) +// TARGET=MAX32625MBED ARM Cortex-M4F 96MHz 512kB Flash 160kB SRAM +// +-------------------------------------+ +// | MAX32625MBED Arduino UNO header | +// | | +// | A5/SCL[ ] | P1_7 dig15 +// | A4/SDA[ ] | P1_6 dig14 +// | AREF=N/C[ ] | +// | GND[ ] | +// | [ ]N/C SCK/13[ ] | P1_0 dig13 +// | [ ]IOREF=3V3 MISO/12[ ] | P1_2 dig12 +// | [ ]RST MOSI/11[ ]~| P1_1 dig11 +// | [ ]3V3 CS/10[ ]~| P1_3 dig10 +// | [ ]5V0 9[ ]~| P1_5 dig9 +// | [ ]GND 8[ ] | P1_4 dig8 +// | [ ]GND | +// | [ ]Vin 7[ ] | P0_7 dig7 +// | 6[ ]~| P0_6 dig6 +// AIN_0 | [ ]A0 5[ ]~| P0_5 dig5 +// AIN_1 | [ ]A1 4[ ] | P0_4 dig4 +// AIN_2 | [ ]A2 INT1/3[ ]~| P0_3 dig3 +// AIN_3 | [ ]A3 INT0/2[ ] | P0_2 dig2 +// dig16 P3_4 | [ ]A4/SDA RST SCK MISO TX>1[ ] | P0_1 dig1 +// dig17 P3_5 | [ ]A5/SCL [ ] [ ] [ ] RX<0[ ] | P0_0 dig0 +// | [ ] [ ] [ ] | +// | UNO_R3 GND MOSI 5V ____________/ +// \_______________________/ +// + #define HAS_digitalInOut0 1 // P0_0 TARGET_MAX32625MBED D0 + #define HAS_digitalInOut1 1 // P0_1 TARGET_MAX32625MBED D1 +#if APPLICATION_MAX11131 + #define HAS_digitalInOut2 0 // P0_2 TARGET_MAX32625MBED D2 -- MAX11131 EOC DigitalIn +#else + #define HAS_digitalInOut2 1 // P0_2 TARGET_MAX32625MBED D2 +#endif + #define HAS_digitalInOut3 1 // P0_3 TARGET_MAX32625MBED D3 + #define HAS_digitalInOut4 1 // P0_4 TARGET_MAX32625MBED D4 + #define HAS_digitalInOut5 1 // P0_5 TARGET_MAX32625MBED D5 + #define HAS_digitalInOut6 1 // P0_6 TARGET_MAX32625MBED D6 + #define HAS_digitalInOut7 1 // P0_7 TARGET_MAX32625MBED D7 + #define HAS_digitalInOut8 1 // P1_4 TARGET_MAX32625MBED D8 +#if APPLICATION_MAX11131 + #define HAS_digitalInOut9 0 // P1_5 TARGET_MAX32625MBED D9 -- MAX11131 CNVST DigitalOut +#else + #define HAS_digitalInOut9 1 // P1_5 TARGET_MAX32625MBED D9 +#endif +#if HAS_SPI +// avoid resource conflict between P5_0, P5_1, P5_2 SPI and DigitalInOut + #define HAS_digitalInOut10 0 // P1_3 TARGET_MAX32635MBED CS/10 + #define HAS_digitalInOut11 0 // P1_1 TARGET_MAX32635MBED MOSI/11 + #define HAS_digitalInOut12 0 // P1_2 TARGET_MAX32635MBED MISO/12 + #define HAS_digitalInOut13 0 // P1_0 TARGET_MAX32635MBED SCK/13 +#else // HAS_SPI + #define HAS_digitalInOut10 1 // P1_3 TARGET_MAX32635MBED CS/10 + #define HAS_digitalInOut11 1 // P1_1 TARGET_MAX32635MBED MOSI/11 + #define HAS_digitalInOut12 1 // P1_2 TARGET_MAX32635MBED MISO/12 + #define HAS_digitalInOut13 1 // P1_0 TARGET_MAX32635MBED SCK/13 +#endif // HAS_SPI +#if HAS_I2C +// avoid resource conflict between P5_7, P6_0 I2C and DigitalInOut + #define HAS_digitalInOut14 0 // P1_6 TARGET_MAX32635MBED A4/SDA (10pin digital connector) + #define HAS_digitalInOut15 0 // P1_7 TARGET_MAX32635MBED A5/SCL (10pin digital connector) + #define HAS_digitalInOut16 0 // P3_4 TARGET_MAX32635MBED A4/SDA (6pin analog connector) + #define HAS_digitalInOut17 0 // P3_5 TARGET_MAX32635MBED A5/SCL (6pin analog connector) +#else // HAS_I2C + #define HAS_digitalInOut14 1 // P1_6 TARGET_MAX32635MBED A4/SDA (10pin digital connector) + #define HAS_digitalInOut15 1 // P1_7 TARGET_MAX32635MBED A5/SCL (10pin digital connector) + #define HAS_digitalInOut16 1 // P3_4 TARGET_MAX32635MBED A4/SDA (6pin analog connector) + #define HAS_digitalInOut17 1 // P3_5 TARGET_MAX32635MBED A5/SCL (6pin analog connector) +#endif // HAS_I2C +#if HAS_digitalInOut0 + DigitalInOut digitalInOut0(P0_0, PIN_INPUT, PullUp, 1); // P0_0 TARGET_MAX32625MBED D0 +#endif +#if HAS_digitalInOut1 + DigitalInOut digitalInOut1(P0_1, PIN_INPUT, PullUp, 1); // P0_1 TARGET_MAX32625MBED D1 +#endif +#if HAS_digitalInOut2 + DigitalInOut digitalInOut2(P0_2, PIN_INPUT, PullUp, 1); // P0_2 TARGET_MAX32625MBED D2 +#endif +#if HAS_digitalInOut3 + DigitalInOut digitalInOut3(P0_3, PIN_INPUT, PullUp, 1); // P0_3 TARGET_MAX32625MBED D3 +#endif +#if HAS_digitalInOut4 + DigitalInOut digitalInOut4(P0_4, PIN_INPUT, PullUp, 1); // P0_4 TARGET_MAX32625MBED D4 +#endif +#if HAS_digitalInOut5 + DigitalInOut digitalInOut5(P0_5, PIN_INPUT, PullUp, 1); // P0_5 TARGET_MAX32625MBED D5 +#endif +#if HAS_digitalInOut6 + DigitalInOut digitalInOut6(P0_6, PIN_INPUT, PullUp, 1); // P0_6 TARGET_MAX32625MBED D6 +#endif +#if HAS_digitalInOut7 + DigitalInOut digitalInOut7(P0_7, PIN_INPUT, PullUp, 1); // P0_7 TARGET_MAX32625MBED D7 +#endif +#if HAS_digitalInOut8 + DigitalInOut digitalInOut8(P1_4, PIN_INPUT, PullUp, 1); // P1_4 TARGET_MAX32625MBED D8 +#endif +#if HAS_digitalInOut9 + DigitalInOut digitalInOut9(P1_5, PIN_INPUT, PullUp, 1); // P1_5 TARGET_MAX32625MBED D9 +#endif +#if HAS_digitalInOut10 + DigitalInOut digitalInOut10(P1_3, PIN_INPUT, PullUp, 1); // P1_3 TARGET_MAX32635MBED CS/10 +#endif +#if HAS_digitalInOut11 + DigitalInOut digitalInOut11(P1_1, PIN_INPUT, PullUp, 1); // P1_1 TARGET_MAX32635MBED MOSI/11 +#endif +#if HAS_digitalInOut12 + DigitalInOut digitalInOut12(P1_2, PIN_INPUT, PullUp, 1); // P1_2 TARGET_MAX32635MBED MISO/12 +#endif +#if HAS_digitalInOut13 + DigitalInOut digitalInOut13(P1_0, PIN_INPUT, PullUp, 1); // P1_0 TARGET_MAX32635MBED SCK/13 +#endif +#if HAS_digitalInOut14 + // Ensure that the unused I2C pins do not interfere with analog inputs A4 and A5 + // DigitalInOut mode can be one of PullUp, PullDown, PullNone, OpenDrain + DigitalInOut digitalInOut14(P1_6, PIN_INPUT, OpenDrain, 1); // P1_6 TARGET_MAX32635MBED A4/SDA (10pin digital connector) +#endif +#if HAS_digitalInOut15 + // Ensure that the unused I2C pins do not interfere with analog inputs A4 and A5 + DigitalInOut digitalInOut15(P1_7, PIN_INPUT, OpenDrain, 1); // P1_7 TARGET_MAX32635MBED A5/SCL (10pin digital connector) +#endif +#if HAS_digitalInOut16 + // Ensure that the unused I2C pins do not interfere with analog inputs A4 and A5 + // DigitalInOut mode can be one of PullUp, PullDown, PullNone, OpenDrain + // PullUp-->3.4V, PullDown-->1.7V, PullNone-->3.5V, OpenDrain-->0.00V + DigitalInOut digitalInOut16(P3_4, PIN_INPUT, OpenDrain, 0); // P3_4 TARGET_MAX32635MBED A4/SDA (6pin analog connector) +#endif +#if HAS_digitalInOut17 + // Ensure that the unused I2C pins do not interfere with analog inputs A4 and A5 + DigitalInOut digitalInOut17(P3_5, PIN_INPUT, OpenDrain, 0); // P3_5 TARGET_MAX32635MBED A5/SCL (6pin analog connector) +#endif +//-------------------------------------------------- +#elif defined(TARGET_NUCLEO_F446RE) || defined(TARGET_NUCLEO_F401RE) + #define HAS_digitalInOut0 0 // P0_0 TARGET_MAX32625MBED D0 + #define HAS_digitalInOut1 0 // P0_1 TARGET_MAX32625MBED D1 +#if APPLICATION_MAX11131 + #define HAS_digitalInOut2 0 // P0_2 TARGET_MAX32625MBED D2 -- MAX11131 EOC DigitalIn +#else + #define HAS_digitalInOut2 1 // P0_2 TARGET_MAX32625MBED D2 +#endif + #define HAS_digitalInOut3 1 // P0_3 TARGET_MAX32625MBED D3 + #define HAS_digitalInOut4 1 // P0_4 TARGET_MAX32625MBED D4 + #define HAS_digitalInOut5 1 // P0_5 TARGET_MAX32625MBED D5 + #define HAS_digitalInOut6 1 // P0_6 TARGET_MAX32625MBED D6 + #define HAS_digitalInOut7 1 // P0_7 TARGET_MAX32625MBED D7 +#if APPLICATION_MAX5715 + #define HAS_digitalInOut8 0 // P1_4 TARGET_MAX32625MBED D8 -- MAX5715 CLRb DigitalOut +#else + #define HAS_digitalInOut8 1 // P1_4 TARGET_MAX32625MBED D8 +#endif +#if APPLICATION_MAX5715 + #define HAS_digitalInOut9 0 // P1_5 TARGET_MAX32625MBED D9 -- MAX5715 LDACb DigitalOut +#elif APPLICATION_MAX11131 + #define HAS_digitalInOut9 0 // P1_5 TARGET_MAX32625MBED D9 -- MAX11131 CNVST DigitalOut +#else + #define HAS_digitalInOut9 1 // P1_5 TARGET_MAX32625MBED D9 +#endif +#if HAS_SPI +// avoid resource conflict between P5_0, P5_1, P5_2 SPI and DigitalInOut + // Arduino digital pin D10 SPI function is CS/10 + // Arduino digital pin D11 SPI function is MOSI/11 + // Arduino digital pin D12 SPI function is MISO/12 + // Arduino digital pin D13 SPI function is SCK/13 + #define HAS_digitalInOut10 0 + #define HAS_digitalInOut11 0 + #define HAS_digitalInOut12 0 + #define HAS_digitalInOut13 0 +#else // HAS_SPI + #define HAS_digitalInOut10 1 + #define HAS_digitalInOut11 1 + #define HAS_digitalInOut12 1 + #define HAS_digitalInOut13 1 +#endif // HAS_SPI +#if HAS_I2C +// avoid resource conflict between P5_7, P6_0 I2C and DigitalInOut + // Arduino digital pin D14 I2C function is A4/SDA (10pin digital connector) + // Arduino digital pin D15 I2C function is A5/SCL (10pin digital connector) + // Arduino digital pin D16 I2C function is A4/SDA (6pin analog connector) + // Arduino digital pin D17 I2C function is A5/SCL (6pin analog connector) + #define HAS_digitalInOut14 0 + #define HAS_digitalInOut15 0 + #define HAS_digitalInOut16 0 + #define HAS_digitalInOut17 0 +#else // HAS_I2C + #define HAS_digitalInOut14 1 + #define HAS_digitalInOut15 1 + #define HAS_digitalInOut16 0 + #define HAS_digitalInOut17 0 +#endif // HAS_I2C +#if HAS_digitalInOut0 + DigitalInOut digitalInOut0(D0, PIN_INPUT, PullUp, 1); +#endif +#if HAS_digitalInOut1 + DigitalInOut digitalInOut1(D1, PIN_INPUT, PullUp, 1); +#endif +#if HAS_digitalInOut2 + DigitalInOut digitalInOut2(D2, PIN_INPUT, PullUp, 1); +#endif +#if HAS_digitalInOut3 + DigitalInOut digitalInOut3(D3, PIN_INPUT, PullUp, 1); +#endif +#if HAS_digitalInOut4 + DigitalInOut digitalInOut4(D4, PIN_INPUT, PullUp, 1); +#endif +#if HAS_digitalInOut5 + DigitalInOut digitalInOut5(D5, PIN_INPUT, PullUp, 1); +#endif +#if HAS_digitalInOut6 + DigitalInOut digitalInOut6(D6, PIN_INPUT, PullUp, 1); +#endif +#if HAS_digitalInOut7 + DigitalInOut digitalInOut7(D7, PIN_INPUT, PullUp, 1); +#endif +#if HAS_digitalInOut8 + DigitalInOut digitalInOut8(D8, PIN_INPUT, PullUp, 1); +#endif +#if HAS_digitalInOut9 + DigitalInOut digitalInOut9(D9, PIN_INPUT, PullUp, 1); +#endif +#if HAS_digitalInOut10 + // Arduino digital pin D10 SPI function is CS/10 + DigitalInOut digitalInOut10(D10, PIN_INPUT, PullUp, 1); +#endif +#if HAS_digitalInOut11 + // Arduino digital pin D11 SPI function is MOSI/11 + DigitalInOut digitalInOut11(D11, PIN_INPUT, PullUp, 1); +#endif +#if HAS_digitalInOut12 + // Arduino digital pin D12 SPI function is MISO/12 + DigitalInOut digitalInOut12(D12, PIN_INPUT, PullUp, 1); +#endif +#if HAS_digitalInOut13 + // Arduino digital pin D13 SPI function is SCK/13 + DigitalInOut digitalInOut13(D13, PIN_INPUT, PullUp, 1); +#endif +#if HAS_digitalInOut14 + // Arduino digital pin D14 I2C function is A4/SDA (10pin digital connector) + DigitalInOut digitalInOut14(D14, PIN_INPUT, PullUp, 1); +#endif +#if HAS_digitalInOut15 + // Arduino digital pin D15 I2C function is A5/SCL (10pin digital connector) + DigitalInOut digitalInOut15(D15, PIN_INPUT, PullUp, 1); +#endif +#if HAS_digitalInOut16 + // Arduino digital pin D16 I2C function is A4/SDA (6pin analog connector) + DigitalInOut digitalInOut16(D16, PIN_INPUT, PullUp, 1); +#endif +#if HAS_digitalInOut17 + // Arduino digital pin D17 I2C function is A5/SCL (6pin analog connector) + DigitalInOut digitalInOut17(D17, PIN_INPUT, PullUp, 1); +#endif +//-------------------------------------------------- +#elif defined(TARGET_LPC1768) + #define HAS_digitalInOut0 1 + #define HAS_digitalInOut1 1 + #define HAS_digitalInOut2 1 + #define HAS_digitalInOut3 1 + #define HAS_digitalInOut4 1 + #define HAS_digitalInOut5 1 + #define HAS_digitalInOut6 1 + #define HAS_digitalInOut7 1 + #define HAS_digitalInOut8 1 + #define HAS_digitalInOut9 1 +// #define HAS_digitalInOut10 1 +// #define HAS_digitalInOut11 1 +// #define HAS_digitalInOut12 1 +// #define HAS_digitalInOut13 1 +// #define HAS_digitalInOut14 1 +// #define HAS_digitalInOut15 1 +#if HAS_digitalInOut0 + DigitalInOut digitalInOut0(p5, PIN_INPUT, PullUp, 1); // TARGET_LPC1768 P0.9/I2STX_SDA/MOSI1/MAT2.3 +#endif +#if HAS_digitalInOut1 + DigitalInOut digitalInOut1(p6, PIN_INPUT, PullUp, 1); // TARGET_LPC1768 P0.8/I2STX_WS/MISO1/MAT2.2 +#endif +#if HAS_digitalInOut2 + DigitalInOut digitalInOut2(p7, PIN_INPUT, PullUp, 1); // TARGET_LPC1768 P0.7/I2STX_CLK/SCK1/MAT2.1 +#endif +#if HAS_digitalInOut3 + DigitalInOut digitalInOut3(p8, PIN_INPUT, PullUp, 1); // TARGET_LPC1768 P0.6/I2SRX_SDA/SSEL1/MAT2.0 +#endif +#if HAS_digitalInOut4 + DigitalInOut digitalInOut4(p9, PIN_INPUT, PullUp, 1); // TARGET_LPC1768 P0.0/CAN_RX1/TXD3/SDA1 +#endif +#if HAS_digitalInOut5 + DigitalInOut digitalInOut5(p10, PIN_INPUT, PullUp, 1); // TARGET_LPC1768 P0.1/CAN_TX1/RXD3/SCL1 +#endif +#if HAS_digitalInOut6 + DigitalInOut digitalInOut6(p11, PIN_INPUT, PullUp, 1); // TARGET_LPC1768 P0.18/DCD1/MOSI0/MOSI1 +#endif +#if HAS_digitalInOut7 + DigitalInOut digitalInOut7(p12, PIN_INPUT, PullUp, 1); // TARGET_LPC1768 P0.17/CTS1/MISO0/MISO +#endif +#if HAS_digitalInOut8 + DigitalInOut digitalInOut8(p13, PIN_INPUT, PullUp, 1); // TARGET_LPC1768 P0.15/TXD1/SCK0/SCK +#endif +#if HAS_digitalInOut9 + DigitalInOut digitalInOut9(p14, PIN_INPUT, PullUp, 1); // TARGET_LPC1768 P0.16/RXD1/SSEL0/SSEL +#endif + // + // these pins support analog input analogIn0 .. analogIn5 + //DigitalInOut digitalInOut_(p15, PIN_INPUT, PullUp, 1); // TARGET_LPC1768 P0.23/AD0.0/I2SRX_CLK/CAP3.0 + //DigitalInOut digitalInOut_(p16, PIN_INPUT, PullUp, 1); // TARGET_LPC1768 P0.24/AD0.1/I2SRX_WS/CAP3.1 + //DigitalInOut digitalInOut_(p17, PIN_INPUT, PullUp, 1); // TARGET_LPC1768 P0.25/AD0.2/I2SRX_SDA/TXD3 + //DigitalInOut digitalInOut_(p18, PIN_INPUT, PullUp, 1); // TARGET_LPC1768 P0.26/AD0.3/AOUT/RXD3 + //DigitalInOut digitalInOut_(p19, PIN_INPUT, PullUp, 1); // TARGET_LPC1768 P1.30/VBUS/AD0.4 + //DigitalInOut digitalInOut_(p20, PIN_INPUT, PullUp, 1); // TARGET_LPC1768 P1.31/SCK1/AD0.5 + // + // these pins support PWM pwmDriver1 .. pwmDriver6 + //DigitalInOut digitalInOut_(p21, PIN_INPUT, PullUp, 1); // TARGET_LPC1768 P2.5/PWM1.6/DTR1/TRACEDATA0 + //DigitalInOut digitalInOut_(p22, PIN_INPUT, PullUp, 1); // TARGET_LPC1768 P2.4/PWM1.5/DSR1/TRACEDATA1 + //DigitalInOut digitalInOut_(p23, PIN_INPUT, PullUp, 1); // TARGET_LPC1768 P2.3/PWM1.4/DCD1/TRACEDATA2 + //DigitalInOut digitalInOut_(p24, PIN_INPUT, PullUp, 1); // TARGET_LPC1768 P2.2/PWM1.3/CTS1/TRACEDATA3 + //DigitalInOut digitalInOut_(p25, PIN_INPUT, PullUp, 1); // TARGET_LPC1768 P2.1/PWM1.2/RXD1 + //DigitalInOut digitalInOut_(p26, PIN_INPUT, PullUp, 1); // TARGET_LPC1768 P2.0/PWM1.1/TXD1/TRACECLK + // + // these could be additional digitalInOut pins +#if HAS_digitalInOut10 + DigitalInOut digitalInOut10(p27, PIN_INPUT, PullUp, 1); // TARGET_LPC1768 P0.11/RXD2/SCL2/MAT3.1 +#endif +#if HAS_digitalInOut11 + DigitalInOut digitalInOut11(p28, PIN_INPUT, PullUp, 1); // TARGET_LPC1768 P0.10/TXD2/SDA2/MAT3.0 +#endif +#if HAS_digitalInOut12 + DigitalInOut digitalInOut12(p29, PIN_INPUT, PullUp, 1); // TARGET_LPC1768 P0.5/I2SRX_WS/CAN_TX2/CAP2.1 +#endif +#if HAS_digitalInOut13 + DigitalInOut digitalInOut13(p30, PIN_INPUT, PullUp, 1); // TARGET_LPC1768 P0.4/I2SRX_CLK/CAN_RX2/CAP2.0 +#endif +#if HAS_digitalInOut14 + DigitalInOut digitalInOut14(___, PIN_INPUT, PullUp, 1); +#endif +#if HAS_digitalInOut15 + DigitalInOut digitalInOut15(___, PIN_INPUT, PullUp, 1); +#endif +#else + // unknown target +#endif +// uncrustify-0.66.1 *INDENT-ON* +#if HAS_digitalInOut0 || HAS_digitalInOut1 \ + || HAS_digitalInOut2 || HAS_digitalInOut3 \ + || HAS_digitalInOut4 || HAS_digitalInOut5 \ + || HAS_digitalInOut6 || HAS_digitalInOut7 \ + || HAS_digitalInOut8 || HAS_digitalInOut9 \ + || HAS_digitalInOut10 || HAS_digitalInOut11 \ + || HAS_digitalInOut12 || HAS_digitalInOut13 \ + || HAS_digitalInOut14 || HAS_digitalInOut15 \ + || HAS_digitalInOut16 || HAS_digitalInOut17 +#define HAS_digitalInOuts 1 +#endif // uncrustify-0.66.1 *INDENT-OFF* //-------------------------------------------------- @@ -856,6 +1310,132 @@ #define HAS_analogIns 1 #endif +// DigitalInOut pin resource: print the pin index names to serial +#if HAS_digitalInOuts +void list_digitalInOutPins(Stream& serialStream) +{ +#if HAS_digitalInOut0 + serialStream.printf(" 0"); +#endif +#if HAS_digitalInOut1 + serialStream.printf(" 1"); +#endif +#if HAS_digitalInOut2 + serialStream.printf(" 2"); +#endif +#if HAS_digitalInOut3 + serialStream.printf(" 3"); +#endif +#if HAS_digitalInOut4 + serialStream.printf(" 4"); +#endif +#if HAS_digitalInOut5 + serialStream.printf(" 5"); +#endif +#if HAS_digitalInOut6 + serialStream.printf(" 6"); +#endif +#if HAS_digitalInOut7 + serialStream.printf(" 7"); +#endif +#if HAS_digitalInOut8 + serialStream.printf(" 8"); +#endif +#if HAS_digitalInOut9 + serialStream.printf(" 9"); +#endif +#if HAS_digitalInOut10 + serialStream.printf(" 10"); +#endif +#if HAS_digitalInOut11 + serialStream.printf(" 11"); +#endif +#if HAS_digitalInOut12 + serialStream.printf(" 12"); +#endif +#if HAS_digitalInOut13 + serialStream.printf(" 13"); +#endif +#if HAS_digitalInOut14 + serialStream.printf(" 14"); +#endif +#if HAS_digitalInOut15 + serialStream.printf(" 15"); +#endif +#if HAS_digitalInOut16 + serialStream.printf(" 16"); +#endif +#if HAS_digitalInOut17 + serialStream.printf(" 17"); +#endif +} +#endif + + +// DigitalInOut pin resource: search index +#if HAS_digitalInOuts +DigitalInOut& find_digitalInOutPin(int cPinIndex) +{ + switch (cPinIndex) + { + default: // default to the first defined digitalInOut pin +#if HAS_digitalInOut0 + case '0': case 0x00: return digitalInOut0; +#endif +#if HAS_digitalInOut1 + case '1': case 0x01: return digitalInOut1; +#endif +#if HAS_digitalInOut2 + case '2': case 0x02: return digitalInOut2; +#endif +#if HAS_digitalInOut3 + case '3': case 0x03: return digitalInOut3; +#endif +#if HAS_digitalInOut4 + case '4': case 0x04: return digitalInOut4; +#endif +#if HAS_digitalInOut5 + case '5': case 0x05: return digitalInOut5; +#endif +#if HAS_digitalInOut6 + case '6': case 0x06: return digitalInOut6; +#endif +#if HAS_digitalInOut7 + case '7': case 0x07: return digitalInOut7; +#endif +#if HAS_digitalInOut8 + case '8': case 0x08: return digitalInOut8; +#endif +#if HAS_digitalInOut9 + case '9': case 0x09: return digitalInOut9; +#endif +#if HAS_digitalInOut10 + case 'a': case 0x0a: return digitalInOut10; +#endif +#if HAS_digitalInOut11 + case 'b': case 0x0b: return digitalInOut11; +#endif +#if HAS_digitalInOut12 + case 'c': case 0x0c: return digitalInOut12; +#endif +#if HAS_digitalInOut13 + case 'd': case 0x0d: return digitalInOut13; +#endif +#if HAS_digitalInOut14 + case 'e': case 0x0e: return digitalInOut14; +#endif +#if HAS_digitalInOut15 + case 'f': case 0x0f: return digitalInOut15; +#endif +#if HAS_digitalInOut16 + case 'g': case 0x10: return digitalInOut16; +#endif +#if HAS_digitalInOut17 + case 'h': case 0x11: return digitalInOut17; +#endif + } +} +#endif // AnalogIn pin resource: search index @@ -1115,17 +1695,17 @@ // example code declare SPI interface #if defined(TARGET_MAX32625MBED) -// TODO1: support SPI hardware-controlled CS instead of GPIO CS (mbed) -// 2020-02-19 attempting to improve SPI CS timing. -// Currently CS envelope is 23us (11.4us before SCLK and 8.6us after SCLK). -// MAX11043 slowest EOC rate is 9us. -// Trying to use SPI-controlled CS configuration. Not working yet. +// SPI spi(SPI1_MOSI, SPI1_MISO, SPI1_SCK); // mosi, miso, sclk spi1 TARGET_MAX32625MBED: P1_1 P1_2 P1_0 Arduino 10-pin header D11 D12 D13 D10 +// DigitalOut spi_cs(SPI1_SS); // TARGET_MAX32625MBED: not connected +// Support SPI hardware-controlled CS instead of GPIO CS (mbed) +// 2020-02-19 MAX32625MBED GPIO CS envelope is 23us (11.4us before SCLK and 8.6us after SCLK). +// 2020-02-19 MAX32625MBED SPI controlled CS envelope 4 channel read reduced to 4.2us (24MHz SCLK), 1.2us setup, 0us hold. +// 2020-02-19 MAX11043 slowest EOC rate is 9us. SPI spi(SPI1_MOSI, SPI1_MISO, SPI1_SCK, SPI1_SS); // mosi, miso, sclk spi1 TARGET_MAX32625MBED: P1_1 P1_2 P1_0 Arduino 10-pin header D11 D12 D13 D10 DigitalOut spi_cs(NC); // TARGET_MAX32625MBED: not connected // PinName NC means NOT_CONNECTED; DigitalOut::is_connected() returns false -// compile/link but runtime error Assertion failed: obj->name != (PinName)NC -// so something is incorrectly trying to drive the CS pin, which is illegal since it's NC -// TODO: add m_cs_pin.is_connected() guard before writing m_cs_pin = m_SPI_cs_state +// add m_cs_pin.is_connected() guard before writing m_cs_pin = m_SPI_cs_state +// to avoid runtime error Assertion failed: obj->name != (PinName)NC #elif defined(TARGET_MAX32600MBED) SPI spi(SPI2_MOSI, SPI2_MISO, SPI2_SCK); // mosi, miso, sclk spi1 TARGET_MAX32600MBED: Arduino 10-pin header D11 D12 D13 DigitalOut spi_cs(SPI2_SS); // Generic: Arduino 10-pin header D10