Generates a test signal on an AnalogOut and monitors a signal on an AnalogIn, plotting the test signal or the actual signal depending on a conditional compile. The wait() and wait_ms() library calls for this board are highly inaccurate so a new function is provided to wait for X number of milliseconds -- which is not very accurate.

Dependencies:   LCD_DISCO_F429ZI mbed TS_DISCO_F429ZI mbed-os BSP_DISCO_F429ZI

Committer:
Damotclese
Date:
Fri Jun 14 21:11:31 2019 +0000
Revision:
1:b9d4b9b8884c
Parent:
0:1ebe7d222470
Child:
2:cbcf2695a4a1
Threat timing is very bad, a thread will average waking up once a millisecond when asked but there is a lot of slop. Instead of launching threads I instead call the "threads" from main() now.;

Who changed what in which revision?

UserRevisionLine numberNew contents of line
Damotclese 0:1ebe7d222470 1
Damotclese 0:1ebe7d222470 2 // ----------------------------------------------------------------------
Damotclese 0:1ebe7d222470 3 // LaserMon-Main.cpp
Damotclese 0:1ebe7d222470 4 //
Damotclese 0:1ebe7d222470 5 // Fredric L. Rice, June 2019
Damotclese 0:1ebe7d222470 6 //
Damotclese 0:1ebe7d222470 7 // ----------------------------------------------------------------------
Damotclese 0:1ebe7d222470 8
Damotclese 0:1ebe7d222470 9 #include "mbed.h" // The mbed operating system
Damotclese 0:1ebe7d222470 10 #include "LCD_DISCO_F429ZI.h" // For controlling the LCD
Damotclese 0:1ebe7d222470 11 #include "TS_DISCO_F429ZI.h" // For controlling the touch screen
Damotclese 0:1ebe7d222470 12 #include "LaserMon-TestOutput.h" // For generating test output signal
Damotclese 0:1ebe7d222470 13 #include "LaserMon-ScanInput.h" // For monitoring laser power pin
Damotclese 0:1ebe7d222470 14 #include "LaserMon-Main.h" // Always include ourself
Damotclese 0:1ebe7d222470 15
Damotclese 0:1ebe7d222470 16 // ----------------------------------------------------------------------
Damotclese 0:1ebe7d222470 17 // Local data storage
Damotclese 0:1ebe7d222470 18 //
Damotclese 0:1ebe7d222470 19 // ----------------------------------------------------------------------
Damotclese 0:1ebe7d222470 20
Damotclese 0:1ebe7d222470 21 const char * pch_firstMessage = "Test signal on PA_5";
Damotclese 0:1ebe7d222470 22 const char * pch_secondMessage = "Laser Scan on PC_1";
Damotclese 0:1ebe7d222470 23
Damotclese 0:1ebe7d222470 24 // ----------------------------------------------------------------------
Damotclese 0:1ebe7d222470 25 // Define global data storage which we will export
Damotclese 0:1ebe7d222470 26 //
Damotclese 0:1ebe7d222470 27 // ----------------------------------------------------------------------
Damotclese 0:1ebe7d222470 28
Damotclese 0:1ebe7d222470 29 // We will be using the LCD so instantiate an object locally
Damotclese 0:1ebe7d222470 30 LCD_DISCO_F429ZI st_lcd;
Damotclese 0:1ebe7d222470 31
Damotclese 0:1ebe7d222470 32 // We will be using the touch screen so instantiate an object
Damotclese 0:1ebe7d222470 33 TS_DISCO_F429ZI st_touchScreen;
Damotclese 0:1ebe7d222470 34
Damotclese 0:1ebe7d222470 35 // ----------------------------------------------------------------------
Damotclese 0:1ebe7d222470 36 // MainInit()
Damotclese 0:1ebe7d222470 37 //
Damotclese 0:1ebe7d222470 38 // ----------------------------------------------------------------------
Damotclese 0:1ebe7d222470 39 static void MainInit(void)
Damotclese 0:1ebe7d222470 40 {
Damotclese 0:1ebe7d222470 41 // Bring the LCD up
Damotclese 0:1ebe7d222470 42 st_lcd.Clear(LCD_COLOR_WHITE);
Damotclese 0:1ebe7d222470 43
Damotclese 0:1ebe7d222470 44 // Set the default text color
Damotclese 0:1ebe7d222470 45 st_lcd.SetTextColor(LCD_COLOR_BLUE);
Damotclese 0:1ebe7d222470 46
Damotclese 0:1ebe7d222470 47 // Set the background color
Damotclese 0:1ebe7d222470 48 st_lcd.SetBackColor(LCD_COLOR_WHITE);
Damotclese 0:1ebe7d222470 49
Damotclese 0:1ebe7d222470 50 // Set the default font size
Damotclese 0:1ebe7d222470 51 BSP_LCD_SetFont(&Font16);
Damotclese 0:1ebe7d222470 52 }
Damotclese 0:1ebe7d222470 53
Damotclese 0:1ebe7d222470 54 // ----------------------------------------------------------------------
Damotclese 0:1ebe7d222470 55 // main()
Damotclese 0:1ebe7d222470 56 //
Damotclese 0:1ebe7d222470 57 //
Damotclese 0:1ebe7d222470 58 // ----------------------------------------------------------------------
Damotclese 0:1ebe7d222470 59 int main(void)
Damotclese 0:1ebe7d222470 60 {
Damotclese 0:1ebe7d222470 61 // Perform local module initialization, if any
Damotclese 0:1ebe7d222470 62 MainInit();
Damotclese 0:1ebe7d222470 63
Damotclese 0:1ebe7d222470 64 // Start generating the putput test signal
Damotclese 0:1ebe7d222470 65 TestOutputInit();
Damotclese 0:1ebe7d222470 66
Damotclese 0:1ebe7d222470 67 // Start scanning the laser drive power
Damotclese 0:1ebe7d222470 68 ScanInputInit();
Damotclese 0:1ebe7d222470 69
Damotclese 0:1ebe7d222470 70 // Display information about what signal pigs have what
Damotclese 0:1ebe7d222470 71 st_lcd.DisplayStringAt(1, LINE(1), (uint8_t *)pch_firstMessage, LEFT_MODE);
Damotclese 0:1ebe7d222470 72 st_lcd.DisplayStringAt(1, LINE(2), (uint8_t *)pch_secondMessage, LEFT_MODE);
Damotclese 0:1ebe7d222470 73
Damotclese 0:1ebe7d222470 74 // Go in to a forever loop for the main thread which does nothing
Damotclese 0:1ebe7d222470 75 while(true)
Damotclese 0:1ebe7d222470 76 {
Damotclese 1:b9d4b9b8884c 77 // Wait for 1 millisecond
Damotclese 1:b9d4b9b8884c 78 wait_us(899);
Damotclese 1:b9d4b9b8884c 79 TestOutputThread();
Damotclese 1:b9d4b9b8884c 80 ScanInputThread();
Damotclese 0:1ebe7d222470 81 }
Damotclese 0:1ebe7d222470 82 }
Damotclese 0:1ebe7d222470 83
Damotclese 0:1ebe7d222470 84 // End of file
Damotclese 0:1ebe7d222470 85