src/main.cpp

changeset 48
fc55f6eaa8bc
parent 44
b3c3d54d2c7c
child 49
c146d19101a3
equal deleted inserted replaced
47:11c57010e4f9 48:fc55f6eaa8bc
16 #elif defined TARGET_HP34970_FP_F303RD 16 #elif defined TARGET_HP34970_FP_F303RD
17 #include "def_hp34970_fp.h" 17 #include "def_hp34970_fp.h"
18 #endif 18 #endif
19 19
20 #include "platform/CircularBuffer.h" 20 #include "platform/CircularBuffer.h"
21
22 // cannot make it work...
23 // #include <USBSerial.h>
24 // USBSerial usbcdc(false);
21 25
22 26
23 Display *dsp; 27 Display *dsp;
24 volatile bool splashscreen; 28 volatile bool splashscreen;
25 HPSerial *hp; 29 HPSerial *hp;
153 } 157 }
154 #endif 158 #endif
155 159
156 160
157 void setup() { 161 void setup() {
158 #if defined(HAVE_PC)
159 /*
160 #if defined(TARGET_HP34970_FP_F303RD)
161 pc.init();
162 pc.connect();
163 #endif
164 */
165 #endif
166
167 printf("\n\nSETUP\n"); 162 printf("\n\nSETUP\n");
168 printf(" System Core Clock = %ld MHZ\r\n", SystemCoreClock/1000000); 163 printf(" System Core Clock = %ld MHZ\r\n", SystemCoreClock/1000000);
169
170 /*
171 #if defined(HAS_LED)
172 printf("Attaching Led 1: %d\n", LED1);
173 blinker.attach(callback(timeout_h), 0.5f);
174 #endif
175 */
176 164
177 hp = NULL; 165 hp = NULL;
178 #if defined(TARGET_NUCLEO_F446RE) 166 #if defined(TARGET_NUCLEO_F446RE)
179 printf("Serial communication pins\r\n"); 167 printf("Serial communication pins\r\n");
180 printf(" USBRX=%d\r\n", USBRX); 168 printf(" USBRX=%d\r\n", USBRX);
181 printf(" USBTX=%d\r\n", USBTX); 169 printf(" USBTX=%d\r\n", USBTX);
182 #endif 170 #endif
183 #if defined(TARGET_HP34970_FP_F303RD) 171 #if defined(TARGET_HP34970_FP_F303RD)
184 printf("Serial communication via USB\r\n"); 172 printf("Serial communication via UART4\r\n");
185 #endif 173 #endif
186 174
187 printf("Setup HP communication pins\r\n"); 175 printf("Setup HP communication pins\r\n");
188 printf(" HP_RX=%d\r\n", HP_RX); 176 //printf(" HP_RX=%d\r\n", HP_RX);
189 DigitalIn(HP_RX).mode(PullDown); 177 DigitalIn(HP_RX).mode(PullDown);
190 printf(" HP_TX=%d\r\n", HP_TX); 178 //printf(" HP_TX=%d\r\n", HP_TX);
191 DigitalOut(HP_TX).write(1); 179 DigitalOut(HP_TX).write(1);
192 printf(" HP_RST=%d\r\n", HP_RST); 180 //printf(" HP_RST=%d\r\n", HP_RST);
193 DigitalIn(HP_RST).mode(PullDown); 181 DigitalIn(HP_RST).mode(PullDown);
194 182
195 printf(" setup QEI pins\r\n"); 183 printf(" setup QEI pins\r\n");
196 printf(" ENC1=%d\r\n", KP_ENC1); 184 //printf(" ENC1=%d\r\n", KP_ENC1);
197 DigitalIn(KP_ENC1).mode(PullDown); 185 DigitalIn(KP_ENC1).mode(PullDown);
198 printf(" ENC2=%d\r\n", KP_ENC2); 186 //printf(" ENC2=%d\r\n", KP_ENC2);
199 DigitalIn(KP_ENC2).mode(PullDown); 187 DigitalIn(KP_ENC2).mode(PullDown);
200 qenc.attach(&qei_cb); 188 qenc.attach(&qei_cb);
201 189
202 printf(" setup Keypad\r\n"); 190 printf(" setup Keypad\r\n");
203 191
210 printf(" start Keypad\r\n"); 198 printf(" start Keypad\r\n");
211 kpad->start(); 199 kpad->start();
212 200
213 printf("Setup OLED display\r\n"); 201 printf("Setup OLED display\r\n");
214 // init the LCD 202 // init the LCD
203 /*
215 printf(" DSP_MOSI=%d\r\n", DSP_MOSI); 204 printf(" DSP_MOSI=%d\r\n", DSP_MOSI);
216 printf(" DSP_MISO=%d\r\n", DSP_MISO); 205 printf(" DSP_MISO=%d\r\n", DSP_MISO);
217 printf(" DSP_SCLK=%d\r\n", DSP_SCLK); 206 printf(" DSP_SCLK=%d\r\n", DSP_SCLK);
218 printf(" DSP_CS=%d\r\n", DSP_CS); 207 printf(" DSP_CS=%d\r\n", DSP_CS);
219 printf(" DSP_RST=%d\r\n", DSP_RST); 208 printf(" DSP_RST=%d\r\n", DSP_RST);
220 printf(" DSP_DC=%d\r\n", DSP_DC); 209 printf(" DSP_DC=%d\r\n", DSP_DC);
210 */
221 dsp = new Display(20000000, DSP_MOSI, DSP_MISO, DSP_SCLK, DSP_CS, 211 dsp = new Display(20000000, DSP_MOSI, DSP_MISO, DSP_SCLK, DSP_CS,
222 DSP_RST, DSP_DC, "SSD1322"); 212 DSP_RST, DSP_DC, "SSD1322");
223 213
224 //curcmd = 0xFF;
225 curchar = 0; 214 curchar = 0;
226 nchars = 0; 215 nchars = 0;
227 216
228 for (uint8_t i=0; i<sizeof(table)/sizeof(table[0]); ++i) 217 for (uint8_t i=0; i<sizeof(table)/sizeof(table[0]); ++i)
229 memset(table[i].buffer, 0, MAX_BUFF+1); 218 memset(table[i].buffer, 0, MAX_BUFF+1);
234 printf("Starting LCD thread\r\n"); 223 printf("Starting LCD thread\r\n");
235 // does not compile... 224 // does not compile...
236 // dsp_refresh.attach(callback(dsp, &Display::copy_to_lcd), 50ms); 225 // dsp_refresh.attach(callback(dsp, &Display::copy_to_lcd), 50ms);
237 tdsp.start(&refresh_display); 226 tdsp.start(&refresh_display);
238 227
239 printf("Attaching timers\r\n"); 228 printf("Attach timers\r\n");
240 splashscreen = true; 229 splashscreen = true;
241 splashscreen_timer.attach(callback(&end_splashscreen), 2ms); 230 splashscreen_timer.attach(callback(&end_splashscreen), 2ms);
242 rst.fall(&reset_irq); 231 rst.fall(&reset_irq);
243 232
244 printf("SETUP DONE\r\n"); 233 printf("SETUP DONE\r\n");

mercurial