![](/media/cache/profiles/0f0ee3310223fe38a989b2c818709393.50x50_q85.jpg)
Control up to 4 steppers axis with limit switch logic from serial port
jmSwitch.h@0:3e676fcd9c71, 2011-02-12 (annotated)
- Committer:
- jm
- Date:
- Sat Feb 12 16:49:03 2011 +0000
- Revision:
- 0:3e676fcd9c71
jmStepperAxis Command Line Interface Module
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
jm | 0:3e676fcd9c71 | 1 | /************************************************************************* |
jm | 0:3e676fcd9c71 | 2 | * @file jmSwitch.h |
jm | 0:3e676fcd9c71 | 3 | * @brief Command Line Interface Module for reading switches |
jm | 0:3e676fcd9c71 | 4 | * Up to 8 switches can be defined on any digital mbed Pin. |
jm | 0:3e676fcd9c71 | 5 | * Provide debounce and edge detection |
jm | 0:3e676fcd9c71 | 6 | * @version 1.0 |
jm | 0:3e676fcd9c71 | 7 | * @date Feb 2, 2011 |
jm | 0:3e676fcd9c71 | 8 | |
jm | 0:3e676fcd9c71 | 9 | Command Line Interface |
jm | 0:3e676fcd9c71 | 10 | Format: command name (arg info)min..max values [optional argument] |
jm | 0:3e676fcd9c71 | 11 | swRead (Switch id)0..3 Return Message: GPPS0 id pin debounce state |
jm | 0:3e676fcd9c71 | 12 | swInit (Switch id)0..7 (Pin number)0..432 (debounce interval)1..255 |
jm | 0:3e676fcd9c71 | 13 | Initialize a Limit Switch Process and return Message: GPPS0 id pin debounce state |
jm | 0:3e676fcd9c71 | 14 | GPPS0 Return 8 Message: GPPS0 id pin debounce state |
jm | 0:3e676fcd9c71 | 15 | |
jm | 0:3e676fcd9c71 | 16 | Module Events |
jm | 0:3e676fcd9c71 | 17 | On closing of switch, Return Message: GPPS0 id pin debounce state |
jm | 0:3e676fcd9c71 | 18 | On Opening of switch, Return Message: GPPS0 id pin debounce state |
jm | 0:3e676fcd9c71 | 19 | */ |
jm | 0:3e676fcd9c71 | 20 | |
jm | 0:3e676fcd9c71 | 21 | #ifndef jmSwitchDef |
jm | 0:3e676fcd9c71 | 22 | #define jmSwitchDef 1 |
jm | 0:3e676fcd9c71 | 23 | #include "stdint.h" |
jm | 0:3e676fcd9c71 | 24 | #include "LPC17xx.h" |
jm | 0:3e676fcd9c71 | 25 | |
jm | 0:3e676fcd9c71 | 26 | #define switchQty 8 // max switch qty |
jm | 0:3e676fcd9c71 | 27 | |
jm | 0:3e676fcd9c71 | 28 | // Module Data Structure |
jm | 0:3e676fcd9c71 | 29 | extern struct StructSwitch{ |
jm | 0:3e676fcd9c71 | 30 | uint16_t pin; |
jm | 0:3e676fcd9c71 | 31 | uint8_t debounce; |
jm | 0:3e676fcd9c71 | 32 | uint8_t state; |
jm | 0:3e676fcd9c71 | 33 | uint8_t eggTimer; |
jm | 0:3e676fcd9c71 | 34 | uint32_t bitValue; |
jm | 0:3e676fcd9c71 | 35 | LPC_GPIO_TypeDef *port; |
jm | 0:3e676fcd9c71 | 36 | }sSwitch[switchQty]; |
jm | 0:3e676fcd9c71 | 37 | #endif |
jm | 0:3e676fcd9c71 | 38 | |
jm | 0:3e676fcd9c71 | 39 | // Module Prototypes |
jm | 0:3e676fcd9c71 | 40 | void SwitchEdgeDetect(void); |
jm | 0:3e676fcd9c71 | 41 | void cli_SwitchInit(void); |
jm | 0:3e676fcd9c71 | 42 | void cli_SwitchRead(void); |
jm | 0:3e676fcd9c71 | 43 | void cli_GPPS0(); |
jm | 0:3e676fcd9c71 | 44 | void rGPPS0(unsigned int id); |
jm | 0:3e676fcd9c71 | 45 | void SwitchModuleReset(void); |
jm | 0:3e676fcd9c71 | 46 | |
jm | 0:3e676fcd9c71 | 47 | //-------------------------- CLIG PLUGS -------------------- |
jm | 0:3e676fcd9c71 | 48 | // CLIG-INCLUDE |
jm | 0:3e676fcd9c71 | 49 | /* |
jm | 0:3e676fcd9c71 | 50 | #include "jmSwitch.h" |
jm | 0:3e676fcd9c71 | 51 | |
jm | 0:3e676fcd9c71 | 52 | */ |
jm | 0:3e676fcd9c71 | 53 | |
jm | 0:3e676fcd9c71 | 54 | // CLIG-INIT |
jm | 0:3e676fcd9c71 | 55 | /* |
jm | 0:3e676fcd9c71 | 56 | SwitchModuleReset(); |
jm | 0:3e676fcd9c71 | 57 | */ |
jm | 0:3e676fcd9c71 | 58 | |
jm | 0:3e676fcd9c71 | 59 | // CLIG-TIMER |
jm | 0:3e676fcd9c71 | 60 | /* |
jm | 0:3e676fcd9c71 | 61 | // Module jmSwitch |
jm | 0:3e676fcd9c71 | 62 | for(i=0;i<switchQty;i++)if(sSwitch[i].eggTimer>0)sSwitch[i].eggTimer--; |
jm | 0:3e676fcd9c71 | 63 | */ |
jm | 0:3e676fcd9c71 | 64 | |
jm | 0:3e676fcd9c71 | 65 | // CLIG-CMD |
jm | 0:3e676fcd9c71 | 66 | /* |
jm | 0:3e676fcd9c71 | 67 | swRead cli_SwitchRead(); |
jm | 0:3e676fcd9c71 | 68 | swInit cli_SwitchInit(); |
jm | 0:3e676fcd9c71 | 69 | GPPS0 cli_GPPS0(); |
jm | 0:3e676fcd9c71 | 70 | */ |
jm | 0:3e676fcd9c71 | 71 | |
jm | 0:3e676fcd9c71 | 72 | // CLIG-SM |
jm | 0:3e676fcd9c71 | 73 | /* |
jm | 0:3e676fcd9c71 | 74 | SwitchEdgeDetect(); |
jm | 0:3e676fcd9c71 | 75 | */ |
jm | 0:3e676fcd9c71 | 76 | |
jm | 0:3e676fcd9c71 | 77 | //-------------------------- END CLIG PLUGS -------------------- |