Bryan and Naved Debub monitor

Dependencies:   mbed

Embed: (wiki syntax)

« Back to documentation index

Show/hide line numbers SPI_Outputs.cpp Source File

SPI_Outputs.cpp

00001 /**----------------------------------------------------------------------------
00002  *
00003  *            \file frequency_detector.cpp
00004 --                                                                           --
00005 --              ECEN 5803 Mastering Embedded System Architecture             --
00006 --                  Project 1 Module 4                                       --
00007 --                Microcontroller Firmware                                   --
00008 --                      frequency_detector.cpp                                           --
00009 --                                                                           --
00010 -------------------------------------------------------------------------------
00011 --
00012 --  Designed for:  University of Colorado at Boulder
00013 --                
00014 --                
00015 --  Designed by:  Tim Scherr
00016 --  Revised by:  Naved Maududi and Bryan Cisneros 
00017 -- 
00018 -- Version: 2.1
00019 -- Date of current revision:  2017-09-25   
00020 -- Target Microcontroller: Freescale MKL25ZVMT4 
00021 -- Tools used:  ARM mbed compiler
00022 --              ARM mbed SDK
00023 --              Freescale FRDM-KL25Z Freedom Board
00024 --               
00025 --               
00026    Functional Description:  
00027    This file contains code that takes in quasi-sine wave ADC inputs from the flow meter
00028      From the ADC inputs, it calculates the frequency of that sine wave. The frequency is 
00029      important in determining the flow rate and velocity for the flowmeter that are outputed
00030      to the display. 
00031 -- 
00032 --      Copyright (c) 2015 Tim Scherr  All rights reserved.
00033 */
00034 
00035 
00036 #include "shared.h" 
00037 #include "MKL25Z4.h"
00038 #define SPI_bit_length 16 // bit length for the spi port
00039 #define SPI_mode 0 // clock is set to trigger at high and in phase
00040 
00041 
00042 
00043 /**********************/
00044 
00045 PinName const SPI_MOSI = PTC6;  // channel 0 (PTB0) to A/D pin VREFL
00046 PinName const SPI_MISO = PTC7; // channel 1 (PTB1) to J10_4 a virtual vortex frequency input,
00047 PinName const SPI_SCK = PTC5; // channel 2 (PTB2) to an actual internal TempSensor
00048 
00049 
00050 void LCD_Display(void){
00051     
00052 SPI LCD(SPI_MOSI, SPI_MISO, SPI_SCK);
00053 LCD.lock(); // Acquire exclusive access to this SPI bus.
00054 LCD.format(SPI_bit_length, SPI_mode); // select correct mode and bits to transfer to the LDC monitor
00055 LCD.write(flow); // write the value of flow to slave device, which is the peripheral LCD display
00056 LCD.write(freq_value); //    write the value of frequency to slave device, which is the peripheral LCD display
00057 LCD.write(temperature); //  write the value of temperature to slave device, which is the peripheral LCD display
00058 }
00059 
00060