Jean Mercier
/
jmPulse
Generate up to 8 different digital waeforms from serial port
jmPulse.h@0:374d47623fab, 2011-02-12 (annotated)
- Committer:
- jm
- Date:
- Sat Feb 12 16:41:07 2011 +0000
- Revision:
- 0:374d47623fab
jmPulse Command Line Interface Module
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
jm | 0:374d47623fab | 1 | /************************************************************************* |
jm | 0:374d47623fab | 2 | * @file jmPulse.h |
jm | 0:374d47623fab | 3 | * @brief Control pulse duration and repetition on digital mbed pins |
jm | 0:374d47623fab | 4 | * Up to 8 pins can be controlled at the same time. |
jm | 0:374d47623fab | 5 | * Single pulse or PWM like waveforms can be generated. |
jm | 0:374d47623fab | 6 | * |
jm | 0:374d47623fab | 7 | * @version 1.1 |
jm | 0:374d47623fab | 8 | * @date Feb 12, 2011 |
jm | 0:374d47623fab | 9 | */ |
jm | 0:374d47623fab | 10 | |
jm | 0:374d47623fab | 11 | /* |
jm | 0:374d47623fab | 12 | * Module Command Line Interface |
jm | 0:374d47623fab | 13 | Format: command name (arg info)min..max values [optional argument] |
jm | 0:374d47623fab | 14 | |
jm | 0:374d47623fab | 15 | pulse (pulse number)0..3 (pin number)0..432 (tOn)0..255 (tOff)0..255 (Cycles)[1..65535] |
jm | 0:374d47623fab | 16 | Ex: pulse 0 118 5 10 20 Pulse Port1 Bit 18 High for 5 tick units, then Low for 10 ticks and repeat 20 times, |
jm | 0:374d47623fab | 17 | then Return Message: GPPP0 id pin tOn tOff status |
jm | 0:374d47623fab | 18 | |
jm | 0:374d47623fab | 19 | Ex: pulse 0 118 1 0 Set output Port1 Bit 18 High |
jm | 0:374d47623fab | 20 | Ex: pulse 0 118 0 1 Reset output Port1 Bit 18 Low |
jm | 0:374d47623fab | 21 | Ex: pulse 0 118 0 0 Toggle Port1 Bit 18 state |
jm | 0:374d47623fab | 22 | |
jm | 0:374d47623fab | 23 | * Module Events |
jm | 0:374d47623fab | 24 | On terminating pulse cycles, Return Message: GPPP0 id pin tOn tOff status |
jm | 0:374d47623fab | 25 | |
jm | 0:374d47623fab | 26 | * Module Feedback and Help messages may be enabled/disabled by Command Lines. |
jm | 0:374d47623fab | 27 | feedback (enable/disable)0..1 |
jm | 0:374d47623fab | 28 | help (enable/disable)0..1 |
jm | 0:374d47623fab | 29 | */ |
jm | 0:374d47623fab | 30 | |
jm | 0:374d47623fab | 31 | #ifndef Pulsedef |
jm | 0:374d47623fab | 32 | #define Pulsedef 1 |
jm | 0:374d47623fab | 33 | |
jm | 0:374d47623fab | 34 | #define pulseQty 8 // number of pins for pulse |
jm | 0:374d47623fab | 35 | |
jm | 0:374d47623fab | 36 | #include "LPC17xx.h" |
jm | 0:374d47623fab | 37 | |
jm | 0:374d47623fab | 38 | // Module Data Structure |
jm | 0:374d47623fab | 39 | extern struct StructPulse{ |
jm | 0:374d47623fab | 40 | uint16_t pin; |
jm | 0:374d47623fab | 41 | uint8_t tOff; |
jm | 0:374d47623fab | 42 | uint8_t tOn; |
jm | 0:374d47623fab | 43 | uint8_t output; |
jm | 0:374d47623fab | 44 | uint8_t state; |
jm | 0:374d47623fab | 45 | uint16_t eggTimer; |
jm | 0:374d47623fab | 46 | uint16_t cycles; |
jm | 0:374d47623fab | 47 | uint32_t bitValue; |
jm | 0:374d47623fab | 48 | LPC_GPIO_TypeDef * port; |
jm | 0:374d47623fab | 49 | }sPulse[pulseQty]; |
jm | 0:374d47623fab | 50 | |
jm | 0:374d47623fab | 51 | |
jm | 0:374d47623fab | 52 | #endif |
jm | 0:374d47623fab | 53 | |
jm | 0:374d47623fab | 54 | // Module Prototypes |
jm | 0:374d47623fab | 55 | void PulseInit(void); |
jm | 0:374d47623fab | 56 | void cli_Pulse(void); |
jm | 0:374d47623fab | 57 | void PulseSM(void); |
jm | 0:374d47623fab | 58 | void SetPulseParam(uint8_t pulseNum, uint16_t pin, uint8_t tOn, uint8_t tOff, uint16_t cycles); |
jm | 0:374d47623fab | 59 | void cli_GPPP0(void); |
jm | 0:374d47623fab | 60 | void rGPPP0(unsigned int id); |
jm | 0:374d47623fab | 61 | void cli_PulseStop(void); |
jm | 0:374d47623fab | 62 | |
jm | 0:374d47623fab | 63 | //-------------------------- CLIG PLUGS -------------------- |
jm | 0:374d47623fab | 64 | // CLIG-INCLUDE |
jm | 0:374d47623fab | 65 | /* |
jm | 0:374d47623fab | 66 | #include "jmPulse.h" |
jm | 0:374d47623fab | 67 | */ |
jm | 0:374d47623fab | 68 | |
jm | 0:374d47623fab | 69 | // CLIG-CMD |
jm | 0:374d47623fab | 70 | /* |
jm | 0:374d47623fab | 71 | pulse cli_Pulse(); |
jm | 0:374d47623fab | 72 | pulseInit PulseInit(); |
jm | 0:374d47623fab | 73 | pulseStop cli_PulseStop(); |
jm | 0:374d47623fab | 74 | GPPP0 cli_GPPP0(); |
jm | 0:374d47623fab | 75 | */ |
jm | 0:374d47623fab | 76 | |
jm | 0:374d47623fab | 77 | // CLIG-INIT |
jm | 0:374d47623fab | 78 | /* |
jm | 0:374d47623fab | 79 | PulseInit(); |
jm | 0:374d47623fab | 80 | */ |
jm | 0:374d47623fab | 81 | |
jm | 0:374d47623fab | 82 | // CLIG-TIMER |
jm | 0:374d47623fab | 83 | /* |
jm | 0:374d47623fab | 84 | // Module jmPulse |
jm | 0:374d47623fab | 85 | for(i=0;i<pulseQty;i++)if(sPulse[i].eggTimer>0)sPulse[i].eggTimer--; |
jm | 0:374d47623fab | 86 | */ |
jm | 0:374d47623fab | 87 | |
jm | 0:374d47623fab | 88 | // CLIG-SM |
jm | 0:374d47623fab | 89 | /* |
jm | 0:374d47623fab | 90 | PulseSM(); |
jm | 0:374d47623fab | 91 | */ |
jm | 0:374d47623fab | 92 |