* permit persons to whom the Software is furnished to do so, subject to
* the following conditions:
*
- * 1. The above copyright notice and this permission notice shall be
+ * 1. The above copyright notice and this permission notice shall be
* included in all copies or substantial portions of the Software.
*
- * 2. If the Software is incorporated into a build system that allows
+ * 2. If the Software is incorporated into a build system that allows
* selection among a list of target devices, then similar target
* devices manufactured by PJRC.COM must be included in the list of
* target devices and selectable in the same manner.
// Default 1-indexed key mappings
static uint8_t DefaultMap_Lookup[] = {
0, // 0x00
- KEY_1, // 0x01
- KEY_Q, // 0x02
- KEY_A, // 0x03
- KEY_2, // 0x04
- KEY_Z, // 0x05
- KEY_W, // 0x06
- KEY_S, // 0x07
- KEY_3, // 0x08
- KEY_X, // 0x09
- KEY_E, // 0x0A
- KEY_D, // 0x0B
- KEY_4, // 0x0C
- KEY_C, // 0x0D
- KEY_R, // 0x0E
- KEY_F, // 0x0F
- KEY_5, // 0x10
- KEY_V, // 0x11
- KEY_T, // 0x12
- KEY_G, // 0x13
- KEY_6, // 0x14
- KEY_B, // 0x15
- KEY_Y, // 0x16
- KEY_H, // 0x17
- KEY_7, // 0x18
- KEY_N, // 0x19
- KEY_U, // 0x1A
- KEY_J, // 0x1B
- KEY_8, // 0x1C
- KEY_M, // 0x1D
- KEY_I, // 0x1E
- KEY_K, // 0x1F
- KEY_9, // 0x20
- KEY_COMMA, // 0x21
- KEY_O, // 0x22
- KEY_L, // 0x23
- KEY_0, // 0x24
- KEY_PERIOD, // 0x25
- KEY_P, // 0x26
- KEY_SEMICOLON, // 0x27
- KEY_MINUS, // 0x28
- KEY_SLASH, // 0x29
- KEY_LEFT_BRACE, // 0x2A (1/4)
- KEY_QUOTE, // 0x2B
- KEY_EQUAL, // 0x2C
- KEY_RIGHT_BRACE, // 0x2D
- 0, // 0x2E
- 0, // 0x2F
- KEY_TILDE, // 0x30
- KEY_TAB, // 0x31
- 0, // 0x32
- 0, // 0x33
- KEY_SHIFT, // 0x34
- KEY_ENTER, // 0x35
- KEY_BACKSPACE, // 0x36
- KEY_DELETE, // 0x37
- KEY_CTRL, // 0x38 (MAR LEFT)
- KEY_SPACE, // 0x39
- KEY_ALT, // 0x3A (EXPRESS / MAR RIGHT)
- 0, // 0x3B
- 0, // 0x3C
- KEY_ESC, // 0x3D (MAR REL)
- 0, // 0x3E (STORE)
- 0, // 0x3F (RECALL)
- KEY_GUI, // 0x40 (CODE)
- 0, // 0x41
- 0, // 0x42
- 0, // 0x43
- 0, // 0x44
- 0, // 0x45
- 0, // 0x46
- 0, // 0x47
- 0, // 0x48 (DEC TAB)
- 0, // 0x49 (SET TAB)
- 0, // 0x4A (TAB CLEAR)
- 0, // 0x4B (INDEX)
- 0, // 0x4C (RELOC)
- 0, // 0x4D
- 0, // 0x4E
- 0, // 0x4F
- 0, // 0x50 (REV INDEX)
- 0, // 0x51
- 0, // 0x52
- 0, // 0x53
- 0, // 0x54
- 0, // 0x55
+ 0, // 0x01
+ 0, // 0x02
+ 0, // 0x03
+ 0, // 0x04
};
// ----- Function Declarations -----
-void cliFunc_echo( char* args );
+void cliFunc_dac ( char* args );
+void cliFunc_dacVref( char* args );
+void cliFunc_echo ( char* args );
// Scan Module command dictionary
char* scanCLIDictName = "ADC Test Module Commands";
CLIDictItem scanCLIDict[] = {
- { "echo", "Example command, echos the arguments.", cliFunc_echo },
+#if defined(_mk20dx256_) // DAC is only supported on Teensy 3.1
+ { "dac", "Set DAC output value, from 0 to 4095 (1/4096 Vref to Vref).", cliFunc_dac },
+ { "dacVref", "Set DAC Vref. 0 is 1.2V. 1 is 3.3V.", cliFunc_dacVref },
+#endif
+ { "echo", "Example command, echos the arguments.", cliFunc_echo },
{ 0, 0, 0 } // Null entry for dictionary end
};
{
// Register Scan CLI dictionary
CLI_registerDictionary( scanCLIDict, scanCLIDictName );
+
+#if defined(_mk20dx256_) // DAC is only supported on Teensy 3.1
+ // DAC Setup
+ SIM_SCGC2 |= SIM_SCGC2_DAC0;
+ DAC0_C0 = DAC_C0_DACEN | DAC_C0_DACRFS; // 3.3V VDDA is DACREF_2
+#endif
}
#endif
}
}
+void cliFunc_dac( char* args )
+{
+#if defined(_mk20dx256_) // DAC is only supported on Teensy 3.1
+ // Parse code from argument
+ // NOTE: Only first argument is used
+ char* arg1Ptr;
+ char* arg2Ptr;
+ CLI_argumentIsolation( args, &arg1Ptr, &arg2Ptr );
+
+ int dacOut = decToInt( arg1Ptr );
+
+ // Make sure the value is between 0 and 4096, otherwise ignore
+ if ( dacOut >= 0 && dacOut <= 4095 )
+ {
+ *(int16_t *) &(DAC0_DAT0L) = dacOut;
+ }
+#endif
+}
+
+void cliFunc_dacVref( char* args )
+{
+#if defined(_mk20dx256_) // DAC is only supported on Teensy 3.1
+ // Parse code from argument
+ // NOTE: Only first argument is used
+ char* arg1Ptr;
+ char* arg2Ptr;
+ CLI_argumentIsolation( args, &arg1Ptr, &arg2Ptr );
+
+ switch ( decToInt( arg1Ptr ) )
+ {
+ case 0:
+ // XXX Doesn't seem to work...
+ DAC0_C0 = DAC_C0_DACEN; // 1.2V ref is DACREF_1
+ break;
+ case 1:
+ DAC0_C0 = DAC_C0_DACEN | DAC_C0_DACRFS; // 3.3V VDDA is DACREF_2
+ break;
+ }
+#endif
+}
+