Motoo Tanaka / Mbed 2 deprecated oscilloscope Featured

Dependencies:   SPI_STMPE610 UniGraphic mbed vt100

Embed: (wiki syntax)

« Back to documentation index

Show/hide line numbers main.h Source File

main.h

00001 /** mbed oscilloscope my implementation of a oscillo scope
00002  * Copyright (c) 2014, 2015 Motoo Tanaka @ Design Methodology Lab
00003  *
00004  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
00005  * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
00006  * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
00007  * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
00008  * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
00009  * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
00010  * THE SOFTWARE.
00011  */
00012 #ifndef _MAIN_H_
00013 #define _MAIN_H_ included
00014 
00015 #if defined (TARGET_KL25Z) 
00016 #define PIN_SCLK        PTD1
00017 #define PIN_MISO        PTD3 
00018 #define PIN_MOSI        PTD2
00019 #define PIN_CS_TFT      PTD0 
00020 #define PIN_DC_TFT      PTD5 
00021 #define PIN_CS_TSC      PTA13
00022 #define PIN_BL_TFT      PTA12
00023 #define PIN_CS_SD       PTA4 
00024 #define PIN_TSC_INTR    PTC9 /* place holder */
00025 #define PIN_RESET_TFT   PTB10 /* place holder */
00026 #define PIN_ADC_CH0     PTB0
00027 #define PIN_ADC_CH1     PTB2
00028 
00029 #elif defined (TARGET_KL46Z)
00030 #define PIN_SCLK        PTD5 
00031 #define PIN_MISO        PTD7 
00032 #define PIN_MOSI        PTD6
00033 #define PIN_CS_TFT      PTD4 
00034 #define PIN_DC_TFT      PTD2 
00035 #define PIN_CS_TSC      PTA13
00036 #define PIN_BL_TFT      PTC9 
00037 #define PIN_CS_SD       PTA4 
00038 #define PIN_TSC_INTR    PTC7 /* place holder */
00039 #define PIN_RESET_TFT   PTC6 /* place holder */
00040 #define PIN_ADC_CH0     PTB0
00041 #define PIN_ADC_CH1     PTB2
00042 
00043 #elif defined (TARGET_K64F)
00044 #define PIN_SCLK        PTD1
00045 #define PIN_MISO        PTD3
00046 #define PIN_MOSI        PTD2
00047 #define PIN_CS_TFT      PTD0
00048 #define PIN_DC_TFT      PTC4
00049 // for board rev E or later
00050 #define PIN_CS_TSC      PTC12
00051 // for earlier boards use following line
00052 // #define PIN_CS_TSC      PTA0
00053 #define PIN_BL_TFT      PTC3
00054 #define PIN_CS_SD       PTB23
00055 #define PIN_TSC_INTR    PTC0 /* place holder */
00056 #define PIN_RESET_TFT   PTC9 /* place holder */
00057 #define PIN_ADC_CH0     PTB2
00058 #define PIN_ADC_CH1     PTB10
00059 
00060 #elif defined (TARGET_K22F)
00061 #define PIN_SCLK        PTD5
00062 #define PIN_MISO        PTD7
00063 #define PIN_MOSI        PTD6
00064 #define PIN_CS_TFT      PTD4
00065 #define PIN_DC_TFT      PTA1
00066 #define PIN_CS_TSC      PTB19
00067 #define PIN_BL_TFT      PTC6 
00068 #define PIN_CS_SD       PTA4 
00069 #define PIN_TSC_INTR    PTC7 /* place holder */
00070 #define PIN_RESET_TFT   PTC9 /* place holder */
00071 #define PIN_ADC_CH0     PTB0
00072 #define PIN_ADC_CH1     PTC1
00073 
00074 #elif defined (TARGET_NUCLEO_F411RE)
00075 #define PIN_SCLK        PA_5
00076 #define PIN_MISO        PA_6
00077 #define PIN_MOSI        PA_7
00078 #define PIN_CS_TFT      PB_6
00079 #define PIN_DC_TFT      PC_7
00080 #define PIN_CS_TSC      PA_9
00081 #define PIN_BL_TFT      PA_8
00082 #define PIN_CS_SD       PB_5
00083 #define PIN_TSC_INTR    PA_8 /* place holder */
00084 #define PIN_RESET_TFT   PA_13 /* place holder */
00085 #define PIN_ADC_CH0     PA_0
00086 #define PIN_ADC_CH1     PA_4
00087 
00088 #elif defined (TARGET_K20D50M)
00089 #define PIN_SCLK        PTD1
00090 #define PIN_MISO        PTD3
00091 #define PIN_MOSI        PTD2
00092 #define PIN_CS_TFT      PTC2
00093 #define PIN_DC_TFT      PTA2 
00094 #define PIN_CS_TSC      PTA12
00095 #define PIN_BL_TFT      PTC4 
00096 #define PIN_CS_SD       PTC8 
00097 #define PIN_TSC_INTR    PTA4 /* place holder */
00098 #define PIN_RESET_TFT   PTC7 /* place holder */
00099 #define PIN_ADC_CH0     PTC0
00100 #define PIN_ADC_CH1     PTD6
00101 
00102 #elif defined (TARGET_RZ_A1H)
00103 #define PIN_SCLK        P10_12
00104 #define PIN_MISO        P10_15
00105 #define PIN_MOSI        P10_14
00106 #define PIN_CS_TFT      P10_13
00107 #define PIN_DC_TFT      P8_14 
00108 #define PIN_CS_TSC      P8_15
00109 #define PIN_BL_TFT      P8_11
00110 #define PIN_CS_SD       P4_5 
00111 #define PIN_TSC_INTR    P2_9 /* place holder */
00112 #define PIN_RESET_TFT   P2_10 /* place holder */
00113 #define PIN_ADC_CH0     P1_8
00114 #define PIN_ADC_CH1     P1_10
00115 #elif defined (TARGET_MAX32600MBED)
00116 /* I2C */
00117 #define PIN_SCL  P2_7
00118 #define PIN_SDA  P2_6
00119 /* SPI */
00120 #define PIN_SCLK  P2_0
00121 #define PIN_MISO P2_2
00122 #define PIN_MOSI P2_1
00123 #define PIN_CS0  P2_3
00124 /* Interrupt */
00125 #define PIN_INT0 P2_4
00126 #define PIN_INT1 P2_5
00127 #define PIN_INT2 P1_7
00128 #define PIN_INT3 P1_6
00129 #define PIN_INT4 P1_5
00130 #define PIN_INT5 P1_4
00131 /* Analog In */
00132 #define PIN_AN0  AIN_0P
00133 #define PIN_AN1  AIN_1P
00134 #define PIN_AN2  AIN_2P
00135 #define PIN_AN3  AIN_3P
00136 #define PIN_AN4  AIN_4P
00137 #define PIN_AN5  AIN_5P
00138 #define BOARD_NAME "MAX32600MBED"
00139 
00140 #define PIN_CS_TFT      P2_3 // D10 PTD0 
00141 #define PIN_DC_TFT      P2_4 // D9  PTD5 
00142 #define PIN_CS_TSC      P2_5 // D8  PTA13
00143 #define PIN_BL_TFT      P1_7 // D7   PTC9 
00144 #define PIN_CS_SD       P1_4 // D4   PTA4 
00145 #define PIN_TSC_INTR    P5_4 // PTC9 /* place holder */
00146 #define PIN_RESET_TFT   P5_5 /// PTB10 /* place holder */
00147 #define PIN_ADC_CH0     AIN_0P // A0 PTB0
00148 #define PIN_ADC_CH1     AIN_2P // A2 PTB2
00149 
00150 #else
00151  #error TARGET NOT DEFINED
00152 #define PIN_SCLK        D13 
00153 #define PIN_MISO        D12 
00154 #define PIN_MOSI        D11
00155 #define PIN_CS_TFT      D10 
00156 #define PIN_DC_TFT      D9 
00157 #define PIN_CS_TSC      D8
00158 #define PIN_BL_TFT      D7 
00159 #define PIN_CS_SD       D4 
00160 #define PIN_TSC_INTR    D5-inside /* place holder */
00161 #define PIN_RESET_TFT   D4-inside /* place holder */
00162 #define PIN_ADC_CH0     A0
00163 #define PIN_ADC_CH1     A2
00164 
00165 #endif
00166 
00167 #define CHART_LEN    198
00168 
00169 // NOTE: in case MIN_INTERVAL is too small
00170 // the program hangs during ADC and timer interrupt
00171 #if defined (TARGET_MAX32600MBED)
00172 #define MIN_INTERVAL   60
00173 #else
00174 #define MIN_INTERVAL   30
00175 #endif
00176 #define MAX_INTERVAL   20000
00177 #define NUM_MAX_MENU   20
00178 #define NUM_MAX_ANALOG_CH 2
00179 #define MODE_RUN 1 
00180 #define MODE_STOP 0
00181 
00182 extern vt100 tty ;
00183 extern AnalogIn *ach[] ;
00184 extern Ticker timer ;
00185 
00186 extern DigitalOut backlight ;
00187 extern ILI9341 TFT ;
00188 extern SPI_STMPE610 TSC ;
00189 extern TFTMenuItem *menu[] ;
00190 extern int numMenu ;
00191 
00192 extern float vref ; // input range 0 - 3.3V
00193 
00194 extern uint16_t udata[2][NUM_MAX_ANALOG_CH][CHART_LEN] ;
00195 extern int data_index ;
00196 extern uint16_t bor[2] ; // begin of ring buffer
00197 
00198 extern int numAnalogIn  ;
00199 extern int memLength  ;
00200 extern int us_interval ; // 20us = 50KHz
00201 extern bool frame_full  ;
00202 extern int page ; // 
00203 extern int prev_page  ;
00204 extern int mode  ;
00205 
00206 float u2v(uint16_t uvalue) ;
00207 uint16_t v2u(float voltage) ;
00208 float u2f(uint16_t value) ;
00209 
00210 void initADC(void) ;
00211 void envChanged(void) ;
00212 bool checkTrigger(void) ;
00213 void sampleAD(void) ;
00214 #endif /* _MAIN_H_ */