Advertisement
miguel747

Secret-KnockLock.c

Dec 16th, 2013
82
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 1.79 KB | None | 0 0
  1. /*
  2.  * secret_knock_lib.h
  3.  *
  4.  *  Created on: 03/12/2013
  5.  *      Author: Filipe Ribeiro
  6.  */
  7.  
  8. #ifndef SECRET_KNOCK_LIB_H_
  9. #define SECRET_KNOCK_LIB_H_
  10.  
  11. #include "msp430g2553.h"
  12.  
  13. //  DEFINITIONS
  14. #define TIMER_A_0   1
  15. #define TIMER_A_1   2
  16.  
  17. #define RECORD_MODE_ON      1
  18. #define RECORD_MODE_OFF     2
  19. //  knock configuration
  20. #define KNOCK_TOLERANCE     2000        //  max error tolerance
  21. #define TOTAL_TOLERANCE     10000       //  max error tolerance
  22. #define KNOCK_MAX_SEQ       20          //  max number of knocks
  23. #define KNOCK_ELAPSE_TIME   3000        //  max knock interval in ms
  24. #define KNOCK_NORM_INTERVAL 10000       //  normalized max knock interval
  25. #define KNOCK_OK            1
  26. #define KNOCK_NOT_OK        2
  27.  
  28. #define     PORT1_DIR           BIT6+BIT4+BIT0
  29. #define     PORT2_DIR           0
  30.  
  31. #define     GREEN_LED_ON        (P1OUT |= BIT6)
  32. #define     YELLOW_LED_ON       (P1OUT |= BIT4)
  33. #define     RED_LED_ON          (P1OUT |= BIT0)
  34.  
  35. #define     GREEN_LED_OFF       (P1OUT &= ~BIT6)
  36. #define     YELLOW_LED_OFF      (P1OUT &= ~BIT4)
  37. #define     RED_LED_OFF         (P1OUT &= ~BIT0)
  38.  
  39. #define     GREEN_LED_TOGGLE    (P1OUT ^= BIT6)
  40.  
  41. #define     PUSH_BUTTON         (BIT3)
  42. #define     CHECK_PUSH_BUTTON   (P1IN & BIT3)
  43.  
  44. #define     PIEZO_PIN           BIT5
  45. #define     CHECK_PIEZO_PIN     (P1IN & BIT5)
  46.  
  47. #define     MOTOR_ON            (P2OUT |= BIT3)
  48. #define     MOTOR_OFF           (P2OUT &= ~BIT3)
  49.  
  50. //  GLOBAL VARIABLES
  51. extern unsigned char recordMode;
  52. extern unsigned char stupidUser;
  53. extern unsigned long int elapseTime;
  54. extern unsigned long int knockBuffer[KNOCK_MAX_SEQ];
  55. extern unsigned long int passwordBuffer[KNOCK_MAX_SEQ];
  56. extern unsigned char passwordLength;
  57. extern unsigned char knockIndex;
  58.  
  59. //  FUNCTION PROTOTYPES
  60. void portInit(void);
  61. void timerAInit(unsigned char timerAMask);
  62. unsigned char passwordCheck(void);
  63. void passwordRecord(void);
  64. void knockNormalize(void);
  65. void knockReset(void);
  66. void knockInit(void);
  67.  
  68.  
  69. #endif /* SECRET_KNOCK_LIB_H_ */
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement