Driver to control a peripheral circuit being controlled by the operation of a FET. Inbetween the mbed and FET is a single D type latch, used to latch a signal to the driver.
Revision 5:7d1b124490ed, committed 2016-02-20
- Comitter:
- sk398
- Date:
- Sat Feb 20 13:22:50 2016 +0000
- Parent:
- 4:6b3722251fd7
- Child:
- 6:073ee2fd1245
- Child:
- 7:909d7e3822d8
- Commit message:
- Commented and operational
Changed in this revision
| Latch_FET_Driver.cpp | Show annotated file Show diff for this revision Revisions of this file |
| Latch_FET_Driver.h | Show annotated file Show diff for this revision Revisions of this file |
--- a/Latch_FET_Driver.cpp Sun Feb 07 18:22:35 2016 +0000
+++ b/Latch_FET_Driver.cpp Sat Feb 20 13:22:50 2016 +0000
@@ -1,42 +1,86 @@
#include "mbed.h"
#include "Latch_FET_Driver.h"
-Latch_FET_Driver::Latch_FET_Driver(PinName set,PinName reset)
+
+/* =============================================================
+ Latch_FET_Driver constructor
+
+ Inputs
+ ------
+ PinName D: Pin to create D input to D Latch
+ PinName CLK: Pin to create CLK input to D Latch
+
+ Description
+ -----------
+
+ Once the new DigitalOut types are assigned, the D Latch at
+ the given Pins is initialised to an outputLow state, ensuring
+ that uopn setup, a known state is entered quickly.
+
+ ============================================================= */
+Latch_FET_Driver::Latch_FET_Driver(PinName D,PinName CLK)
{
- SetPin = new DigitalOut(set);
- ResetPin = new DigitalOut(reset);
- // Ensure that SR latch does not enter unknown state
- Latch_FET_Driver::initialState();
-}
-
-void Latch_FET_Driver::initialState()
-{
- SetPin -> write(LOW);
- ResetPin ->write(HIGH);
-}
-
-void Latch_FET_Driver::outputHigh()
-{
- ResetPin -> write(LOW);
- SetPin -> write(HIGH);
+ // Assign passed in Pin Names as new DigitalOut data types
+ _D = new DigitalOut(D);
+ _CLK = new DigitalOut(CLK);
+
+ // Ensure that D latch does not enter unknown state
+ // Initialise is the same as the outputLow method
+ Latch_FET_Driver::outputLow();
}
-void Latch_FET_Driver::outputLow()
+/* ================================================================
+ outputHigh is a public method to set a HIGH output on the given
+ D Latch.
+
+ The procedure to set Q into a HIGH condition is as follows;
+
+ 1. Ensure CLK is low
+ 2. Set D high
+ 3. wait STATE_DELAY us
+ 4. Set CLK high
+ 5. wait 10*STATE_DELAY us
+ 6. Set CLK low
+ 7. wait STATE_DELAY us
+ 8. set D low
+ 9. return void
+ ================================================================ */
+void Latch_FET_Driver::outputHigh()
{
- SetPin -> write(LOW);
- ResetPin -> write(HIGH);
-
+ _CLK -> write(LOW);
+ _D -> write(HIGH);
+ wait_us(STATE_DELAY);
+ _CLK -> write(HIGH);
+ wait_us(10*STATE_DELAY);
+ _CLK -> write(LOW);
+ wait_us(STATE_DELAY);
+ _D -> write(LOW);
}
-//int Latch_FET_Driver::setOutput()
-//{
-// ResetPin = LOW;
-//
-// return 0;
-//}
-//
-//int Latch_FET_Driver::resetOutput()
-//{
-//
-//}
+/* ================================================================
+ outputLow is a public method to set a HIGH output on the given
+ D Latch.
+
+ The procedure to set Q into a LOW condition is as follows;
+
+ 1. Ensure CLK is low
+ 2. Set D low
+ 3. wait STATE_DELAY us
+ 4. Set CLK high
+ 5. wait 10*STATE_DELAY us
+ 6. Set CLK low
+ 7. wait STATE_DELAY us
+ 8. return void
+ ================================================================ */
+void Latch_FET_Driver::outputLow()
+{
+ _CLK -> write(LOW);
+ _D -> write(LOW);
+ wait_us(STATE_DELAY);
+ _CLK -> write(HIGH);
+ wait_us(10*STATE_DELAY);
+ _CLK -> write(LOW);
+ wait_us(STATE_DELAY);
+}
+
--- a/Latch_FET_Driver.h Sun Feb 07 18:22:35 2016 +0000
+++ b/Latch_FET_Driver.h Sat Feb 20 13:22:50 2016 +0000
@@ -1,3 +1,33 @@
+/* #####################################################################
+
+ Latch_FET_Driver.h
+ ------------------
+
+ Written by: Steven Kay
+
+ Date: February 2016
+
+ Function: This
+
+ #####################################################################*/
+
+ /*##########################################
+
+ Embedded Software, Assignment 1
+ -------------------------------
+
+Written by: Steven Kay
+
+Date: January 2016
+
+Function: This program constructs and outputs a
+ pulse train on a given output pin based
+ on several input configurations generated
+ by using switches
+
+##########################################*/
+
+
#include "mbed.h"
#ifndef LATCH_FET_DRIVER
@@ -7,23 +37,67 @@
#define LOW 0
#define HIGH 1
+#define STATE_DELAY 10
+
class Latch_FET_Driver
{
public:
- Latch_FET_Driver(PinName set,PinName reset);
+ /* =============================================================
+ Latch_FET_Driver constructor
+
+ Inputs
+ ------
+ PinName D: Pin to create D input to D Latch
+ PinName CLK: Pin to create CLK input to D Latch
+
+ Description
+ -----------
+
+ Once the new DigitalOut types are assigned, the D Latch at
+ the given Pins is initialised to an outputLow state, ensuring
+ that uopn setup, a known state is entered quickly.
+
+ ============================================================= */
+ Latch_FET_Driver(PinName D,PinName CLK);
+
+ /* =============================================================
+ outputHigh public method
+
+ Inputs
+ ------
+ No functionally passed parameters
+ The method acts upon the DigitalOut types; _D and _CLK
+
+ Description
+ -----------
+ Procedure to assert a HIGH state onto a D Latch attached to
+ PinName D and PinName CLK
+ ============================================================= */
void outputHigh();
+
+ /* =============================================================
+ outputLow public method
+
+ Inputs
+ ------
+ No functionally passed parameters
+ The method acts upon the DigitalOut types; _D and _CLK
+
+ Description
+ -----------
+ Procedure to assert a LOW state onto a D Latch attached to
+ PinName D and PinName CLK
+ ============================================================= */
void outputLow();
-// int setOutput();
-// int resetOutput();
+
private:
- void initialState();
-
protected:
- DigitalOut *SetPin;
- DigitalOut *ResetPin;
+ // DigitalOut types used for assignment of PinName data types
+ DigitalOut *_D;
+ DigitalOut *_CLK;
};
#endif
\ No newline at end of file