Bryan and Naved Debub monitor

Dependencies:   mbed

Embed: (wiki syntax)

« Back to documentation index

Show/hide line numbers shared.h Source File

shared.h

Go to the documentation of this file.
00001 /**-----------------------------------------------------------------------------
00002       \file shared.h
00003 --                                                                           --
00004 --              ECEN 5803 Mastering Embedded System Architecture             --
00005 --                  Project 1 Module 4                                       --
00006 --                Microcontroller Firmware                                   --
00007 --                      shared.h                                             --
00008 --                                                                           --
00009 -------------------------------------------------------------------------------
00010 --
00011 --  Designed for:  University of Colorado at Boulder
00012 --               
00013 --                
00014 --  Designed by:  Tim Scherr
00015 --  Revised by:  Naved Maududi and Bryan Cisneros
00016 -- 
00017 -- Version: 2.1
00018 -- Date of current revision:  2017-09-25   
00019 -- Target Microcontroller: Freescale MKL25ZVMT4 
00020 -- Tools used:  ARM mbed compiler
00021 --              ARM mbed SDK
00022 --              Freescale FRDM-KL25Z Freedom Board
00023 --               
00024 -- 
00025 -- Functional Description:  Header file for all globals
00026 --
00027 --      Copyright (c) 2015, 2016 Tim Scherr  All rights reserved.
00028 --
00029 */                    
00030                           
00031 #include "mbed.h"  
00032  
00033  /*****************************************************************************
00034 * #defines available to all modules included here
00035 ******************************************************************************/ 
00036 #define OFF 0                       /* used for readability */
00037 #define ON 1                        /* used for readability */
00038 #define NO 0                        /* used for readability */
00039 #define YES 1                       /* used for readability */
00040 #define TEN 10
00041 
00042 #define TIMER0 TMR0
00043 #define SEC 10000           /* 10000 timer0 interrupts per second (100 usec.) */
00044 #define SAMPLES_SECOND 1/SEC  /* # of seoconds between sample used in frequency detection (100 usec.) */
00045                    
00046 #define T100MS 0.1*SEC
00047 #define T2S    2*SEC
00048                               
00049 #define LED_FLASH_PERIOD .5   /* in seconds */
00050  
00051 #define CLOCK_FREQUENCY_MHZ 8
00052 #define CODE_VERSION "2.0 2016/09/29"   /*   YYYY/MM/DD  */
00053 #define COPYRIGHT "Copyright (c) University of Colorado" 
00054      
00055  enum boolean { FALSE, TRUE };           /// \enum boolean  
00056  enum dmode {QUIET, NORMAL, DEBUG, VERSION}; 
00057  
00058  typedef unsigned char UCHAR;       
00059  typedef unsigned char bit;
00060  typedef unsigned int uint32_t;
00061  typedef unsigned short uint16_t;
00062  typedef signed short int16_t;
00063  
00064 #ifdef __cplusplus 
00065 extern "C" {
00066 #endif
00067  
00068 /************************************************************************/
00069 /*             Global Variable declarations                             */
00070 /************************************************************************/
00071  
00072  extern unsigned char Error_status;          // Variable for debugging use
00073  extern UCHAR  display_timer;  // \var 1 second software timer for display   
00074  extern UCHAR  display_flag;   // flag between timer interrupt and monitor.c, 
00075  extern UCHAR  LED_timer_flag;   // flag between timer interrupt and main.c,
00076                         // like a binary semaphore
00077  extern UCHAR tx_in_progress;                        
00078  extern UCHAR *rx_in_ptr; /* pointer to the receive in data */
00079  extern UCHAR *rx_out_ptr; /* pointer to the receive out data*/
00080  extern UCHAR *tx_in_ptr; /* pointer to the transmit in data*/
00081  extern UCHAR *tx_out_ptr; /*pointer to the transmit out */    
00082  extern uint16_t ADC_buffer;    // value that ADC will read in, need to be external so that flow function can read in
00083  extern uint16_t temperature; // value that will be external to all variable. stores the value of temperature
00084  extern uint16_t Vtemp; // value in mV of the temperature calculated
00085  extern uint16_t freq_value; // value that will store the frequency detected. Need it to be availaible to all functions
00086  extern uint16_t flow; // value that will store the flow that is determine
00087  extern uint16_t ADC_vortex_frequency_input; // value of the ADC_vortex_frequency_input
00088  extern uint16_t Vrefl; // value of the ADC_vortex_frequency_input
00089 
00090 #define RX_BUF_SIZE 10            /* size of receive buffer in bytes */
00091 #define TX_BUF_SIZE 10          /* size of transmit buffer in bytes */
00092                                                                     
00093 /******************************************************************************
00094 * Some variable definitions are done in the module main.c and are externed in 
00095 * all other modules.  The following section is visible to main.c only.
00096 ******************************************************************************/
00097 #ifdef MAIN
00098 
00099  enum dmode display_mode = QUIET;
00100  
00101  UCHAR serial_flag = 0;
00102  
00103  UCHAR tx_in_progress; 
00104  UCHAR *rx_in_ptr; /* pointer to the receive in data */
00105  UCHAR *rx_out_ptr; /* pointer to the receive out data*/
00106  UCHAR *tx_in_ptr; /* pointer to the transmit in data*/
00107  UCHAR *tx_out_ptr; /*pointer to the transmit out */        
00108     
00109  UCHAR  rx_buf[RX_BUF_SIZE];      /* define the storage */
00110  UCHAR  tx_buf[TX_BUF_SIZE];      /* define the storage */
00111 
00112 #define MSG_BUF_SIZE 10
00113  UCHAR msg_buf[MSG_BUF_SIZE]; // define the storage for UART received messages
00114  UCHAR msg_buf_idx = 0;    // index into the received message buffer       
00115 
00116 /******************************************************************************
00117 * Some variable definitions are done in the module main.c and are externed in 
00118 * all other modules.  The following section is visible to all modules EXCEPT 
00119 * main.c.
00120 *******************************************************************************/
00121 #else
00122 
00123 /**********************/   
00124 /*   Declarations     */
00125 /**********************/
00126 
00127    extern volatile     UCHAR swtimer0;
00128    extern volatile     UCHAR swtimer1;
00129    extern volatile     UCHAR swtimer2;
00130    extern volatile     UCHAR swtimer3; 
00131    extern volatile     UCHAR swtimer4;    
00132    extern volatile     UCHAR swtimer5;    
00133    extern volatile     UCHAR swtimer6;    
00134    extern volatile     UCHAR swtimer7;    
00135   
00136   extern UCHAR serial_flag;
00137     
00138   extern enum dmode display_mode;
00139   
00140   
00141   extern UCHAR  rx_buf[];      /* declare the storage */
00142   extern UCHAR  tx_buf[];      /* declare the storage */
00143 
00144 #define MSG_BUF_SIZE 10    
00145   extern  UCHAR msg_buf[MSG_BUF_SIZE]; // declare the storage for UART received messages
00146   extern  UCHAR msg_buf_idx;         // index into the received message buffer
00147 
00148 #endif
00149 
00150 /*******************************************************************************
00151 * All function prototypes are externed in all the modules.
00152 *******************************************************************************/
00153 extern void monitor(void);  /* located in module monitor.c */
00154 extern void timer0(void);   /* located in module timer0.c */
00155 extern void serial(void);   /* located in module UART_poll.c */
00156 
00157 extern void UART_put(UCHAR);                 /* located in module UART_poll.c */
00158 extern UCHAR UART_get(void);                 /* located in module UART_poll.c */
00159 extern UCHAR UART_input(void);               /* located in module UART_poll.c */
00160 extern void UART_direct_msg_put(const char *);
00161                                              /* located in module UART_poll.c */
00162 extern void UART_msg_put(const char *); 
00163                                              /* located in module UART_poll.c */
00164 extern void UART_direct_hex_put(UCHAR);      /* located in module UART_poll.c */
00165 extern void UART_direct_put(UCHAR);          /* located in module UART_poll.c */
00166 extern void UART_hex_put(UCHAR);             /* located in module UART_poll.c */
00167 extern void UART_low_nibble_put(UCHAR);      /* located in module UART_poll.c */
00168 extern void UART_high_nibble_put(UCHAR);     /* located in module UART_poll.c */
00169 extern void chk_UART_msg(void);              /* located in module monitor.c */
00170 extern void UART_msg_process(void);          /* located in module monitors.c */
00171 extern void status_report(void);             /* located in module monitor.c */  
00172 extern void set_display_mode(void);          /* located in module monitor.c */
00173 extern void UART_direct_hex_put_word(uint32_t); /* located in module monitor.c */
00174 extern float calculateViscosity(int16_t); /* located in module Calculate_flow.c */
00175 extern float calculateDensity(int16_t); /* located in module Calculate_flow.c */
00176 extern float calculateReynoldsNumber(float, float, float); /* located in module Calculate_flow.c */
00177 extern float calculateStrouhalNumber(float); /* located in module Calculate_flow.c */
00178 extern float calculateVelocity(uint16_t, float); /* located in module Calculate_flow.c */
00179 extern float convertVelocityMetersToInches(float); /* located in module Calculate_flow.c */
00180 extern void calculateFlow(void); /* located in module Calculate_flow.c */
00181 extern void read_ADC(uint8_t);
00182 extern void frequency_detect(void);
00183 extern void adc_calibration(void);
00184 extern void PwmOutputs_flowmeter(void);
00185 extern void Pulse_Output_Frequency(void);
00186 extern void LCD_Display(void);
00187 
00188 #ifdef __cplusplus
00189 }
00190 
00191 #endif
00192 
00193