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.
Latch_FET_Driver.h@5:7d1b124490ed, 2016-02-20 (annotated)
- Committer:
- sk398
- Date:
- Sat Feb 20 13:22:50 2016 +0000
- Revision:
- 5:7d1b124490ed
- Parent:
- 2:9059b675917e
- Child:
- 6:073ee2fd1245
- Child:
- 7:909d7e3822d8
Commented and operational
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
sk398 | 5:7d1b124490ed | 1 | /* ##################################################################### |
sk398 | 5:7d1b124490ed | 2 | |
sk398 | 5:7d1b124490ed | 3 | Latch_FET_Driver.h |
sk398 | 5:7d1b124490ed | 4 | ------------------ |
sk398 | 5:7d1b124490ed | 5 | |
sk398 | 5:7d1b124490ed | 6 | Written by: Steven Kay |
sk398 | 5:7d1b124490ed | 7 | |
sk398 | 5:7d1b124490ed | 8 | Date: February 2016 |
sk398 | 5:7d1b124490ed | 9 | |
sk398 | 5:7d1b124490ed | 10 | Function: This |
sk398 | 5:7d1b124490ed | 11 | |
sk398 | 5:7d1b124490ed | 12 | #####################################################################*/ |
sk398 | 5:7d1b124490ed | 13 | |
sk398 | 5:7d1b124490ed | 14 | /*########################################## |
sk398 | 5:7d1b124490ed | 15 | |
sk398 | 5:7d1b124490ed | 16 | Embedded Software, Assignment 1 |
sk398 | 5:7d1b124490ed | 17 | ------------------------------- |
sk398 | 5:7d1b124490ed | 18 | |
sk398 | 5:7d1b124490ed | 19 | Written by: Steven Kay |
sk398 | 5:7d1b124490ed | 20 | |
sk398 | 5:7d1b124490ed | 21 | Date: January 2016 |
sk398 | 5:7d1b124490ed | 22 | |
sk398 | 5:7d1b124490ed | 23 | Function: This program constructs and outputs a |
sk398 | 5:7d1b124490ed | 24 | pulse train on a given output pin based |
sk398 | 5:7d1b124490ed | 25 | on several input configurations generated |
sk398 | 5:7d1b124490ed | 26 | by using switches |
sk398 | 5:7d1b124490ed | 27 | |
sk398 | 5:7d1b124490ed | 28 | ##########################################*/ |
sk398 | 5:7d1b124490ed | 29 | |
sk398 | 5:7d1b124490ed | 30 | |
sk398 | 0:87f2d094bea3 | 31 | #include "mbed.h" |
sk398 | 0:87f2d094bea3 | 32 | |
sk398 | 0:87f2d094bea3 | 33 | #ifndef LATCH_FET_DRIVER |
sk398 | 0:87f2d094bea3 | 34 | #define LATCH_FET_DRIVER |
sk398 | 0:87f2d094bea3 | 35 | |
sk398 | 0:87f2d094bea3 | 36 | |
sk398 | 0:87f2d094bea3 | 37 | #define LOW 0 |
sk398 | 0:87f2d094bea3 | 38 | #define HIGH 1 |
sk398 | 0:87f2d094bea3 | 39 | |
sk398 | 5:7d1b124490ed | 40 | #define STATE_DELAY 10 |
sk398 | 5:7d1b124490ed | 41 | |
sk398 | 0:87f2d094bea3 | 42 | |
sk398 | 0:87f2d094bea3 | 43 | class Latch_FET_Driver |
sk398 | 0:87f2d094bea3 | 44 | { |
sk398 | 0:87f2d094bea3 | 45 | |
sk398 | 0:87f2d094bea3 | 46 | public: |
sk398 | 5:7d1b124490ed | 47 | /* ============================================================= |
sk398 | 5:7d1b124490ed | 48 | Latch_FET_Driver constructor |
sk398 | 5:7d1b124490ed | 49 | |
sk398 | 5:7d1b124490ed | 50 | Inputs |
sk398 | 5:7d1b124490ed | 51 | ------ |
sk398 | 5:7d1b124490ed | 52 | PinName D: Pin to create D input to D Latch |
sk398 | 5:7d1b124490ed | 53 | PinName CLK: Pin to create CLK input to D Latch |
sk398 | 5:7d1b124490ed | 54 | |
sk398 | 5:7d1b124490ed | 55 | Description |
sk398 | 5:7d1b124490ed | 56 | ----------- |
sk398 | 5:7d1b124490ed | 57 | |
sk398 | 5:7d1b124490ed | 58 | Once the new DigitalOut types are assigned, the D Latch at |
sk398 | 5:7d1b124490ed | 59 | the given Pins is initialised to an outputLow state, ensuring |
sk398 | 5:7d1b124490ed | 60 | that uopn setup, a known state is entered quickly. |
sk398 | 5:7d1b124490ed | 61 | |
sk398 | 5:7d1b124490ed | 62 | ============================================================= */ |
sk398 | 5:7d1b124490ed | 63 | Latch_FET_Driver(PinName D,PinName CLK); |
sk398 | 5:7d1b124490ed | 64 | |
sk398 | 5:7d1b124490ed | 65 | /* ============================================================= |
sk398 | 5:7d1b124490ed | 66 | outputHigh public method |
sk398 | 5:7d1b124490ed | 67 | |
sk398 | 5:7d1b124490ed | 68 | Inputs |
sk398 | 5:7d1b124490ed | 69 | ------ |
sk398 | 5:7d1b124490ed | 70 | No functionally passed parameters |
sk398 | 5:7d1b124490ed | 71 | The method acts upon the DigitalOut types; _D and _CLK |
sk398 | 5:7d1b124490ed | 72 | |
sk398 | 5:7d1b124490ed | 73 | Description |
sk398 | 5:7d1b124490ed | 74 | ----------- |
sk398 | 5:7d1b124490ed | 75 | Procedure to assert a HIGH state onto a D Latch attached to |
sk398 | 5:7d1b124490ed | 76 | PinName D and PinName CLK |
sk398 | 5:7d1b124490ed | 77 | ============================================================= */ |
sk398 | 2:9059b675917e | 78 | void outputHigh(); |
sk398 | 5:7d1b124490ed | 79 | |
sk398 | 5:7d1b124490ed | 80 | /* ============================================================= |
sk398 | 5:7d1b124490ed | 81 | outputLow public method |
sk398 | 5:7d1b124490ed | 82 | |
sk398 | 5:7d1b124490ed | 83 | Inputs |
sk398 | 5:7d1b124490ed | 84 | ------ |
sk398 | 5:7d1b124490ed | 85 | No functionally passed parameters |
sk398 | 5:7d1b124490ed | 86 | The method acts upon the DigitalOut types; _D and _CLK |
sk398 | 5:7d1b124490ed | 87 | |
sk398 | 5:7d1b124490ed | 88 | Description |
sk398 | 5:7d1b124490ed | 89 | ----------- |
sk398 | 5:7d1b124490ed | 90 | Procedure to assert a LOW state onto a D Latch attached to |
sk398 | 5:7d1b124490ed | 91 | PinName D and PinName CLK |
sk398 | 5:7d1b124490ed | 92 | ============================================================= */ |
sk398 | 2:9059b675917e | 93 | void outputLow(); |
sk398 | 5:7d1b124490ed | 94 | |
sk398 | 0:87f2d094bea3 | 95 | private: |
sk398 | 0:87f2d094bea3 | 96 | |
sk398 | 0:87f2d094bea3 | 97 | protected: |
sk398 | 5:7d1b124490ed | 98 | // DigitalOut types used for assignment of PinName data types |
sk398 | 5:7d1b124490ed | 99 | DigitalOut *_D; |
sk398 | 5:7d1b124490ed | 100 | DigitalOut *_CLK; |
sk398 | 0:87f2d094bea3 | 101 | }; |
sk398 | 0:87f2d094bea3 | 102 | |
sk398 | 0:87f2d094bea3 | 103 | #endif |