Revision c3c5444e

View differences:

include/PKxxxExxx/v1/alld_PKxxxExxx_v1.h
35 35
/* CONSTANTS                                                                  */
36 36
/******************************************************************************/
37 37

  
38
/**
39
 * @brief   Specified frequency of the PKLCS1212E4001.
40
 */
41
#define PKxxxExxx_LLD_FREQUENCY_SPEC       4000
42

  
43
/**
44
 * @brief   Minimum frequency for the buzzer to sound.
45
 */
46
#define PKxxxExxx_LLD_FREQUENCY_MIN        2000
47

  
48
/**
49
 * @brief   Maximum frequency for the buzzer to sound.
50
 */
51
#define PKxxxExxx_LLD_FREQUENCY_MAX        6000
52

  
53 38
/******************************************************************************/
54 39
/* SETTINGS                                                                   */
55 40
/******************************************************************************/
......
58 43
/* CHECKS                                                                     */
59 44
/******************************************************************************/
60 45

  
46
#ifndef PKxxxExxx_LLD_FREQUENCY_SPEC
47
	#error "PKxxxExxx_LLD_FREQUENCY_SPEC not defined"
48
#elif !(PKxxxExxx_LLD_FREQUENCY_SPEC > 0)
49
	#error "PKxxxExxx_LLD_FREQUENCY_SPEC set to invalid value"
50
#endif
51

  
52
#ifndef PKxxxExxx_LLD_FREQUENCY_MIN
53
	#warning "PKxxxExxx_LLD_FREQUENCY_MIN not defined (recommended)"
54
#elif !(PKxxxExxx_LLD_FREQUENCY_MIN > 0)
55
	#error "PKxxxExxx_LLD_FREQUENCY_MIN set to invalid value"
56
#endif
57

  
58
#ifndef PKxxxExxx_LLD_FREQUENCY_MAX
59
	#warning "PKxxxExxx_LLD_FREQUENCY_MAX not defined (recommended)"
60
#elif !(PKxxxExxx_LLD_FREQUENCY_MAX > 0)
61
	#error "PKxxxExxx_LLD_FREQUENCY_MAX set to invalid value"
62
#endif
63

  
61 64
/******************************************************************************/
62 65
/* DATA STRUCTURES AND TYPES                                                  */
63 66
/******************************************************************************/
source/PKxxxExxx/v1/alld_PKxxxExxx_v1.c
67 67
  status |= apalPWMGetPeriod(pwm, &period);
68 68
  if (frequency / period == PKxxxExxx_LLD_FREQUENCY_SPEC) {
69 69
    status |= APAL_STATUS_OK;
70
  } else if (frequency / period >= PKxxxExxx_LLD_FREQUENCY_MIN &&
71
             frequency / period <= PKxxxExxx_LLD_FREQUENCY_MAX) {
70
  }
71
#if defined(PKxxxExxx_LLD_FREQUENCY_MIN) && !defined(PKxxxExxx_LLD_FREQUENCY_MAX)
72
  else if (frequency / period >= PKxxxExxx_LLD_FREQUENCY_MIN &&
73
           frequency / period <= PKxxxExxx_LLD_FREQUENCY_SPEC) {
72 74
    status |= APAL_STATUS_WARNING;
73
  } else {
75
  }
76
#elif !defined(PKxxxExxx_LLD_FREQUENCY_MIN) && defined(PKxxxExxx_LLD_FREQUENCY_MAX)
77
  else if (frequency / period >= PKxxxExxx_LLD_FREQUENCY_SPEC &&
78
           frequency / period <= PKxxxExxx_LLD_FREQUENCY_MAX) {
79
    status |= APAL_STATUS_WARNING;
80
  }
81
#elif defined(PKxxxExxx_LLD_FREQUENCY_MIN) && defined(PKxxxExxx_LLD_FREQUENCY_MAX)
82
  else if (frequency / period >= PKxxxExxx_LLD_FREQUENCY_MIN &&
83
           frequency / period <= PKxxxExxx_LLD_FREQUENCY_MAX) {
84
    status |= APAL_STATUS_WARNING;
85
  }
86
#endif
87
  else {
74 88
    status |= APAL_STATUS_INVALIDARGUMENTS;
75 89
  }
76 90

  

Also available in: Unified diff