Internal_Datalogger but with USB support removed (for MAX40108 Demo board), proof of concept that MAX32625 can be used successfully with VDDB(USB) left unpowered, as long as the USB library is not used.
Dependencies: max32625pico CmdLine
Diff: DataLogger_Internal.cpp
- Revision:
- 18:1235c17b451e
- Parent:
- 17:9397ea3ea7e9
- Child:
- 19:5ff09c8e9daf
--- a/DataLogger_Internal.cpp Sat Apr 17 22:51:02 2021 -0700 +++ b/DataLogger_Internal.cpp Sun Apr 18 22:34:16 2021 -0700 @@ -450,6 +450,68 @@ +// support LEDs as digital pins 91 92 93; WIP button as digital pin 90 +// move definiton of USE_LEDS earlier than find_digitalInOutPin() +//-------------------------------------------------- +// Option to use LEDs to show status +#ifndef USE_LEDS +#define USE_LEDS 1 +#endif +#if USE_LEDS +#if defined(TARGET_MAX32630) +# define LED_ON 0 +# define LED_OFF 1 +//-------------------------------------------------- +#elif defined(TARGET_MAX32625MBED) +# define LED_ON 0 +# define LED_OFF 1 +#elif defined(TARGET_MAX32625PICO) +# define LED_ON 0 +# define LED_OFF 1 +//-------------------------------------------------- +// TODO1: TARGET=MAX32625MBED ARM Cortex-M4F 96MHz 512kB Flash 160kB SRAM +#elif defined(TARGET_LPC1768) +# define LED_ON 1 +# define LED_OFF 0 +#else // not defined(TARGET_LPC1768 etc.) +// USE_LEDS with some platform other than MAX32630, MAX32625MBED, LPC1768 +// bugfix for MAX32600MBED LED blink pattern: check if LED_ON/LED_OFF already defined +# ifndef LED_ON +# define LED_ON 0 +# endif +# ifndef LED_OFF +# define LED_OFF 1 +# endif +//# define LED_ON 1 +//# define LED_OFF 0 +#endif // target definition +// support LEDs as digital pins 91 92 93; WIP button as digital pin 90 +// support find_digitalInOutPin(91) return DigitalInOut of led1_RFailLED +// support find_digitalInOutPin(92) return DigitalInOut of led2_GPassLED +// support find_digitalInOutPin(93) return DigitalInOut of led3_BBusyLED +// change led1/2/3/4 from DigitalOut to DigitalInOut +DigitalInOut led1(LED1, PIN_INPUT, PullUp, LED_OFF); // MAX32630FTHR: LED1 = LED_RED +DigitalInOut led2(LED2, PIN_INPUT, PullUp, LED_OFF); // MAX32630FTHR: LED2 = LED_GREEN +DigitalInOut led3(LED3, PIN_INPUT, PullUp, LED_OFF); // MAX32630FTHR: LED3 = LED_BLUE +DigitalInOut led4(LED4, PIN_INPUT, PullUp, LED_OFF); +#else // USE_LEDS=0 +// issue #41 support Nucleo_F446RE +// there are no LED indicators on the board, LED1 interferes with SPI; +// but we still need placeholders led1 led2 led3 led4. +// Declare DigitalInOut led1 led2 led3 led4 targeting safe pins. +// PinName NC means NOT_CONNECTED; DigitalOut::is_connected() returns false +# define LED_ON 0 +# define LED_OFF 1 +// change led1/2/3/4 from DigitalOut to DigitalInOut +DigitalInOut led1(NC, PIN_INPUT, PullUp, LED_OFF); +DigitalInOut led2(NC, PIN_INPUT, PullUp, LED_OFF); +DigitalInOut led3(NC, PIN_INPUT, PullUp, LED_OFF); +DigitalInOut led4(NC, PIN_INPUT, PullUp, LED_OFF); +#endif // USE_LEDS +#define led1_RFailLED led1 +#define led2_GPassLED led2 +#define led3_BBusyLED led3 + // uncrustify-0.66.1 *INDENT-OFF* //-------------------------------------------------- // Declare the DigitalInOut GPIO pins @@ -1467,6 +1529,19 @@ #if HAS_digitalInOut17 serialStream.printf(" 17"); #endif +#if USE_LEDS +// support LEDs as digital pins 91 92 93; WIP button as digital pin 90 +// support list_digitalInOutPins() listing buttons and leds as pin numbers 90/91/92/93 +// TODO: support find_digitalInOutPin(90) return DigitalInOut of switch SW1/BUTTON1 + //~ serialStream.printf(" 90"); +// support find_digitalInOutPin(91) return DigitalInOut of led1_RFailLED + serialStream.printf(" 91"); +// support find_digitalInOutPin(92) return DigitalInOut of led2_GPassLED + serialStream.printf(" 92"); +// support find_digitalInOutPin(93) return DigitalInOut of led3_BBusyLED + serialStream.printf(" 93"); +#else // USE_LEDS +#endif // USE_LEDS } #endif @@ -1532,6 +1607,18 @@ #if HAS_digitalInOut17 case 'h': case 0x11: return digitalInOut17; #endif +// support LEDs as digital pins 91 92 93; WIP button as digital pin 90 +// TODO: support find_digitalInOutPin(90) return DigitalInOut of switch SW1/BUTTON1 + //~ case 90: return button1; +#if USE_LEDS +// support find_digitalInOutPin(91) return DigitalInOut of led1_RFailLED + case 91: return led1_RFailLED; +// support find_digitalInOutPin(92) return DigitalInOut of led2_GPassLED + case 92: return led2_GPassLED; +// support find_digitalInOutPin(93) return DigitalInOut of led3_BBusyLED + case 93: return led3_BBusyLED; +#else // USE_LEDS +#endif // USE_LEDS } } #endif @@ -1711,60 +1798,6 @@ //-------------------------------------------------- -// Option to use LEDs to show status -#ifndef USE_LEDS -#define USE_LEDS 1 -#endif -#if USE_LEDS -#if defined(TARGET_MAX32630) -# define LED_ON 0 -# define LED_OFF 1 -//-------------------------------------------------- -#elif defined(TARGET_MAX32625MBED) -# define LED_ON 0 -# define LED_OFF 1 -#elif defined(TARGET_MAX32625PICO) -# define LED_ON 0 -# define LED_OFF 1 -//-------------------------------------------------- -// TODO1: TARGET=MAX32625MBED ARM Cortex-M4F 96MHz 512kB Flash 160kB SRAM -#elif defined(TARGET_LPC1768) -# define LED_ON 1 -# define LED_OFF 0 -#else // not defined(TARGET_LPC1768 etc.) -// USE_LEDS with some platform other than MAX32630, MAX32625MBED, LPC1768 -// bugfix for MAX32600MBED LED blink pattern: check if LED_ON/LED_OFF already defined -# ifndef LED_ON -# define LED_ON 0 -# endif -# ifndef LED_OFF -# define LED_OFF 1 -# endif -//# define LED_ON 1 -//# define LED_OFF 0 -#endif // target definition -DigitalOut led1(LED1, LED_OFF); // MAX32630FTHR: LED1 = LED_RED -DigitalOut led2(LED2, LED_OFF); // MAX32630FTHR: LED2 = LED_GREEN -DigitalOut led3(LED3, LED_OFF); // MAX32630FTHR: LED3 = LED_BLUE -DigitalOut led4(LED4, LED_OFF); -#else // USE_LEDS=0 -// issue #41 support Nucleo_F446RE -// there are no LED indicators on the board, LED1 interferes with SPI; -// but we still need placeholders led1 led2 led3 led4. -// Declare DigitalOut led1 led2 led3 led4 targeting safe pins. -// PinName NC means NOT_CONNECTED; DigitalOut::is_connected() returns false -# define LED_ON 0 -# define LED_OFF 1 -DigitalOut led1(NC, LED_OFF); -DigitalOut led2(NC, LED_OFF); -DigitalOut led3(NC, LED_OFF); -DigitalOut led4(NC, LED_OFF); -#endif // USE_LEDS -#define led1_RFailLED led1 -#define led2_GPassLED led2 -#define led3_BBusyLED led3 - -//-------------------------------------------------- // TODO support CmdLine command menus (like on Serial_Tester) #ifndef USE_CMDLINE_MENUS #define USE_CMDLINE_MENUS 1 @@ -1865,32 +1898,43 @@ const double threshold_WE_0V5 = 0.5; const double threshold_WE_0V6 = 0.6; const double threshold_WE_0V7 = 0.7; -const int pin_LED_1 = 2; // WIP -const int pin_LED_2 = 3; // WIP +const int pin_LED_1 = 91; // support find_digitalInOutPin(91) return DigitalInOut of led1_RFailLED +const int pin_LED_2 = 92; // support find_digitalInOutPin(92) return DigitalInOut of led2_GPassLED +const int pin_LED_3 = 93; // support find_digitalInOutPin(93) return DigitalInOut of led3_BBusyLED #endif const int ACTION_TABLE_ROW_MAX = 20; #if MAX40108_DEMO bool Datalogger_action_table_enabled = true; -int Datalogger_action_table_row_count = 4; // assert (Datalogger_action_table_row_count <= ACTION_TABLE_ROW_MAX) +int Datalogger_action_table_row_count = 6; // assert (Datalogger_action_table_row_count <= ACTION_TABLE_ROW_MAX) #else // MAX40108_DEMO int Datalogger_action_table_row_count = 0; #endif // MAX40108_DEMO action_table_row_t Datalogger_action_table[ACTION_TABLE_ROW_MAX] = { #if MAX40108_DEMO - // LED indicator show (`Datalogger_Trigger` == `trigger_FreeRun`) - // {action_noop, 0, condition_always, 0, 0}, - // // LED indicator show (WE > 0.5V) - {action_digitalOutLow, pin_LED_1, condition_if_An_gt_threshold, channel_WE, threshold_WE_0V5}, + // L@0 act=1 pin=92 if=1 ch=2 x=0.500000 -- digitalOutLow D92 if A2 > 0.500000 + {action_digitalOutLow, pin_LED_2, condition_if_An_gt_threshold, channel_WE, threshold_WE_0V5}, // // LED indicator show (WE > 0.6V) - {action_digitalOutLow, pin_LED_2, condition_if_An_gt_threshold, channel_WE, threshold_WE_0V6}, + // L@1 act=1 pin=93 if=1 ch=2 x=0.600000 -- digitalOutLow D93 if A2 > 0.600000 + {action_digitalOutLow, pin_LED_3, condition_if_An_gt_threshold, channel_WE, threshold_WE_0V6}, // // switch to always-on mode `trigger_FreeRun` if (WE > 0.7V) + // L@2 act=4 if=1 ch=2 x=0.700000 -- trigger_FreeRun if A2 > 0.700000 {action_trigger_FreeRun, 0, condition_if_An_gt_threshold, channel_WE, threshold_WE_0V7}, // // switch to intermittent-sleep-mode `trigger_Timer` if (WE < 0.6V) + // L@3 act=5 if=2 ch=2 x=0.600000 -- trigger_Timer(10 x 500msec) if A2 < 0.600000 {action_trigger_Timer, 0, condition_if_An_lt_threshold, channel_WE, threshold_WE_0V6}, + // + // LED indicator show (`Datalogger_Trigger` == `trigger_FreeRun`) + // {action_noop, 0, condition_always, 0, 0}, + // L@4 act=1 pin=91 if=1 ch=2 x=0.700000 -- digitalOutLow D91 if A2 > 0.700000 + {action_digitalOutLow, pin_LED_1, condition_if_An_gt_threshold, channel_WE, threshold_WE_0V7}, + // + // L@5 act=2 pin=91 if=2 ch=2 x=0.600000 -- digitalOutHigh D91 if A2 < 0.600000 + {action_digitalOutHigh, pin_LED_1, condition_if_An_lt_threshold, channel_WE, threshold_WE_0V6}, + // #endif // MAX40108_DEMO // {action_noop, 0, condition_always, 0, 0},