Jean Mercier / Mbed 2 deprecated jmSwitch

Dependencies:   mbed

Embed: (wiki syntax)

« Back to documentation index

Show/hide line numbers jmSwitch.h Source File

jmSwitch.h

00001 /*************************************************************************
00002  * @file    jmSwitch.h
00003  * @brief   Command Line Interface Module for reading switches
00004  *          Up to 8 switches can be defined on any digital mbed Pin.
00005  *          Provide debounce and edge detection
00006  * @version 1.0
00007  * @date    Feb 2, 2011
00008 
00009    Command Line Interface 
00010    Format: command name (arg info)min..max values [optional argument]
00011       swRead (Switch id)0..3  Return Message: GPPS0 id pin debounce state
00012       swInit (Switch id)0..7 (Pin number)0..432 (debounce interval)1..255
00013               Initialize a Limit Switch Process and return Message: GPPS0 id pin debounce state
00014       GPPS0  Return 8 Message: GPPS0 id pin debounce state
00015 
00016    Module Events
00017         On closing of switch, Return Message: GPPS0 id pin debounce state
00018         On Opening of switch, Return Message: GPPS0 id pin debounce state
00019 */
00020 
00021 #ifndef jmSwitchDef
00022    #define jmSwitchDef 1
00023    #include "stdint.h"
00024    #include "LPC17xx.h"
00025 
00026    #define switchQty 8 // max switch qty
00027 
00028     // Module Data Structure
00029      extern   struct StructSwitch{ 
00030            uint16_t pin;
00031            uint8_t debounce;   
00032            uint8_t state; 
00033            uint8_t eggTimer;  
00034            uint32_t bitValue;
00035            LPC_GPIO_TypeDef *port;
00036         }sSwitch[switchQty]; 
00037 #endif
00038 
00039 // Module Prototypes
00040 void SwitchEdgeDetect(void);
00041 void cli_SwitchInit(void);
00042 void cli_SwitchRead(void);
00043 void cli_GPPS0();
00044 void rGPPS0(unsigned int id);
00045 void SwitchModuleReset(void);
00046 
00047 //-------------------------- CLIG PLUGS --------------------
00048 // CLIG-INCLUDE
00049 /*
00050 #include "jmSwitch.h"
00051 
00052 */
00053 
00054 // CLIG-INIT
00055 /*
00056    SwitchModuleReset();   
00057 */
00058 
00059 // CLIG-TIMER
00060 /*
00061    // Module jmSwitch
00062    for(i=0;i<switchQty;i++)if(sSwitch[i].eggTimer>0)sSwitch[i].eggTimer--;
00063 */
00064 
00065 // CLIG-CMD
00066 /*
00067 swRead cli_SwitchRead();
00068 swInit cli_SwitchInit();
00069 GPPS0 cli_GPPS0();
00070 */
00071 
00072 // CLIG-SM
00073 /*
00074      SwitchEdgeDetect();
00075 */
00076 
00077 //-------------------------- END CLIG PLUGS --------------------