ELEC2645 Sensor Project Andrew Ruffley 200887845

Dependencies:   SDFileSystem SRF02 mbed

Committer:
Ruffley
Date:
Thu May 05 11:31:50 2016 +0000
Revision:
0:71f4b2285994
Final Code

Who changed what in which revision?

UserRevisionLine numberNew contents of line
Ruffley 0:71f4b2285994 1 /**
Ruffley 0:71f4b2285994 2 @file main.h
Ruffley 0:71f4b2285994 3 @brief Header file for functions, defines and global variables.
Ruffley 0:71f4b2285994 4
Ruffley 0:71f4b2285994 5 @author Andrew Ruffley 200887845
Ruffley 0:71f4b2285994 6 @brief University of Leeds ELEC2645 Project
Ruffley 0:71f4b2285994 7 @date May 2015
Ruffley 0:71f4b2285994 8 */
Ruffley 0:71f4b2285994 9
Ruffley 0:71f4b2285994 10 #ifndef MAIN_H
Ruffley 0:71f4b2285994 11 #define MAIN_H
Ruffley 0:71f4b2285994 12
Ruffley 0:71f4b2285994 13 #include "mbed.h"
Ruffley 0:71f4b2285994 14 #include "SRF02.h"
Ruffley 0:71f4b2285994 15 #include "N5110.h"
Ruffley 0:71f4b2285994 16 #include "SDFileSystem.h"
Ruffley 0:71f4b2285994 17
Ruffley 0:71f4b2285994 18
Ruffley 0:71f4b2285994 19 // --------------- INPUT PERIPHERALS --------------
Ruffley 0:71f4b2285994 20
Ruffley 0:71f4b2285994 21
Ruffley 0:71f4b2285994 22 /**
Ruffley 0:71f4b2285994 23 @namespace sensor
Ruffley 0:71f4b2285994 24 @brief Ultra-Sonic distance sensor requires SDA and SCL lines
Ruffley 0:71f4b2285994 25 */
Ruffley 0:71f4b2285994 26 SRF02 sensor(PTE25, PTE24);
Ruffley 0:71f4b2285994 27
Ruffley 0:71f4b2285994 28 /**
Ruffley 0:71f4b2285994 29 @namespace Sw1
Ruffley 0:71f4b2285994 30 @brief Digital input button that is used to select program
Ruffley 0:71f4b2285994 31 */
Ruffley 0:71f4b2285994 32 DigitalIn Sw1(PTB19);
Ruffley 0:71f4b2285994 33
Ruffley 0:71f4b2285994 34 /**
Ruffley 0:71f4b2285994 35 @namespace Sw2
Ruffley 0:71f4b2285994 36 @brief Digital input button that is used to select program
Ruffley 0:71f4b2285994 37 */
Ruffley 0:71f4b2285994 38 DigitalIn Sw2(PTB18);
Ruffley 0:71f4b2285994 39
Ruffley 0:71f4b2285994 40
Ruffley 0:71f4b2285994 41 // -------------- OUTPUT PERIPHERALS --------------
Ruffley 0:71f4b2285994 42
Ruffley 0:71f4b2285994 43 /**
Ruffley 0:71f4b2285994 44 @namespace lcd
Ruffley 0:71f4b2285994 45 @brief Outputs for the N5110 lcd display, lcd (VCC,SCE,RST,D/C,MOSI,SCLK,LED)
Ruffley 0:71f4b2285994 46 */
Ruffley 0:71f4b2285994 47 N5110 lcd(PTE26 , PTA0 , PTC4 , PTD0 , PTD2 , PTD1 , PTC3);
Ruffley 0:71f4b2285994 48
Ruffley 0:71f4b2285994 49 /**
Ruffley 0:71f4b2285994 50 @namespace sd
Ruffley 0:71f4b2285994 51 @brief Outputs for the sd card, sd(PTE3, PTE1, PTE2, PTE4, "sd")
Ruffley 0:71f4b2285994 52 */
Ruffley 0:71f4b2285994 53 SDFileSystem sd(PTE3, PTE1, PTE2, PTE4, "sd"); // MOSI, MISO, SCK, CS, SD Card Connections
Ruffley 0:71f4b2285994 54
Ruffley 0:71f4b2285994 55 /**
Ruffley 0:71f4b2285994 56 @namespace Buzzer
Ruffley 0:71f4b2285994 57 @brief A buzzer that can produce different notes dependant on the frquency of the signal inputted to it. Used as an auditory alert
Ruffley 0:71f4b2285994 58 */
Ruffley 0:71f4b2285994 59 PwmOut buzzer(PTA2);
Ruffley 0:71f4b2285994 60
Ruffley 0:71f4b2285994 61 /**
Ruffley 0:71f4b2285994 62 @namespace led_Yellow
Ruffley 0:71f4b2285994 63 @brief Yellow indicator LED
Ruffley 0:71f4b2285994 64 */
Ruffley 0:71f4b2285994 65 DigitalOut LEDY(PTC5);
Ruffley 0:71f4b2285994 66
Ruffley 0:71f4b2285994 67 /**
Ruffley 0:71f4b2285994 68 @namespace led_Green
Ruffley 0:71f4b2285994 69 @brief Green indicator LED
Ruffley 0:71f4b2285994 70 */
Ruffley 0:71f4b2285994 71 DigitalOut LEDG(PTC7);
Ruffley 0:71f4b2285994 72
Ruffley 0:71f4b2285994 73 /**
Ruffley 0:71f4b2285994 74 @namespace r_led
Ruffley 0:71f4b2285994 75 @brief K64F on-board LED
Ruffley 0:71f4b2285994 76 */
Ruffley 0:71f4b2285994 77 DigitalOut r_led(LED_RED);
Ruffley 0:71f4b2285994 78
Ruffley 0:71f4b2285994 79 /**
Ruffley 0:71f4b2285994 80 @namespace g_led
Ruffley 0:71f4b2285994 81 @brief K64F on-board LED
Ruffley 0:71f4b2285994 82 */
Ruffley 0:71f4b2285994 83 DigitalOut g_led(LED_GREEN);
Ruffley 0:71f4b2285994 84
Ruffley 0:71f4b2285994 85 /**
Ruffley 0:71f4b2285994 86 @namespace b_led
Ruffley 0:71f4b2285994 87 @brief K64F on-board LED
Ruffley 0:71f4b2285994 88 */
Ruffley 0:71f4b2285994 89 DigitalOut b_led(LED_BLUE);
Ruffley 0:71f4b2285994 90
Ruffley 0:71f4b2285994 91
Ruffley 0:71f4b2285994 92 // -------------- VARIABLES --------------
Ruffley 0:71f4b2285994 93
Ruffley 0:71f4b2285994 94 int Array[5]; /*!<Creates an array */
Ruffley 0:71f4b2285994 95 int Total = 0; /*!<Creates and set a variable */
Ruffley 0:71f4b2285994 96 int count = 0; /*!<Creates and set a variable */
Ruffley 0:71f4b2285994 97 int Distance; /*!<Creates a variable */
Ruffley 0:71f4b2285994 98 int T; /*!<Creates variable */
Ruffley 0:71f4b2285994 99 int Time = T; /*!<Creates Variable and sets to T */
Ruffley 0:71f4b2285994 100
Ruffley 0:71f4b2285994 101
Ruffley 0:71f4b2285994 102 // -------------- Functions --------------
Ruffley 0:71f4b2285994 103
Ruffley 0:71f4b2285994 104 /**
Ruffley 0:71f4b2285994 105 @namespace Parking_Sensor
Ruffley 0:71f4b2285994 106 @brief Parking Sensor Program
Ruffley 0:71f4b2285994 107 @brief Calculates average distance and creates graphic reprisentation
Ruffley 0:71f4b2285994 108 @brief Turns on buzzer if distance drops below 30cm
Ruffley 0:71f4b2285994 109 */
Ruffley 0:71f4b2285994 110 void Parking_Sensor();
Ruffley 0:71f4b2285994 111
Ruffley 0:71f4b2285994 112 /**
Ruffley 0:71f4b2285994 113 @namespace D_Sensor
Ruffley 0:71f4b2285994 114 @brief Timer and Sensor Function
Ruffley 0:71f4b2285994 115 @brief Creates timer and reads distance
Ruffley 0:71f4b2285994 116 @brief If distance drops below 50cm saves time to sd
Ruffley 0:71f4b2285994 117 */
Ruffley 0:71f4b2285994 118 void D_Sensor();
Ruffley 0:71f4b2285994 119
Ruffley 0:71f4b2285994 120 /**
Ruffley 0:71f4b2285994 121 @namespace delete_file
Ruffley 0:71f4b2285994 122 @brief Delete Save file
Ruffley 0:71f4b2285994 123 */
Ruffley 0:71f4b2285994 124 void delete_file(char filename[]);
Ruffley 0:71f4b2285994 125
Ruffley 0:71f4b2285994 126 /**
Ruffley 0:71f4b2285994 127 @namespace init_K64F
Ruffley 0:71f4b2285994 128 @brief set-up the on-board LEDs and switches
Ruffley 0:71f4b2285994 129 */
Ruffley 0:71f4b2285994 130 void init_K64F();
Ruffley 0:71f4b2285994 131
Ruffley 0:71f4b2285994 132 /**
Ruffley 0:71f4b2285994 133 @namespace Buzzer
Ruffley 0:71f4b2285994 134 @brief Buzzer control
Ruffley 0:71f4b2285994 135 */
Ruffley 0:71f4b2285994 136 void Buzzer(); //Buzzer
Ruffley 0:71f4b2285994 137
Ruffley 0:71f4b2285994 138 #endif