led.h 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111
  1. #ifndef _LED_H_
  2. #define _LED_H_
  3. /*
  4. * Copyright (C) 2009 by Rittal GmbH & Co. KG,
  5. * Ulrich Prinz <prinz.u@rittal.de> All rights reserved.
  6. *
  7. * Redistribution and use in source and binary forms, with or without
  8. * modification, are permitted provided that the following conditions
  9. * are met:
  10. *
  11. * 1. Redistributions of source code must retain the above copyright
  12. * notice, this list of conditions and the following disclaimer.
  13. * 2. Redistributions in binary form must reproduce the above copyright
  14. * notice, this list of conditions and the following disclaimer in the
  15. * documentation and/or other materials provided with the distribution.
  16. * 3. Neither the name of the copyright holders nor the names of
  17. * contributors may be used to endorse or promote products derived
  18. * from this software without specific prior written permission.
  19. *
  20. * THIS SOFTWARE IS PROVIDED BY EMBEDDED IT AND CONTRIBUTORS
  21. * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
  22. * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
  23. * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL EMBEDDED IT
  24. * OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
  25. * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
  26. * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
  27. * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
  28. * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
  29. * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
  30. * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  31. *
  32. * For additional information see http://www.ethernut.de/
  33. *
  34. */
  35. /*
  36. * $Log$
  37. *
  38. * Revision 0.2 2009/04/13 ulrichprinz
  39. * First checkin, led driver with extra functionality and variable io-access
  40. * (currently SAM7X256 is tested only)
  41. *
  42. */
  43. /*!
  44. * \file dev/led.h
  45. * \brief LED handler definitions.
  46. */
  47. /*!
  48. * \addtogroup xgDevLED
  49. */
  50. /*@{*/
  51. #include <stdint.h>
  52. /*!
  53. * \brief LED action definitions.
  54. *
  55. * The LED modifies the LED according to these tokens when calling
  56. * NutSetLed().
  57. *
  58. */
  59. /*!
  60. * \brief Switch LED off.
  61. *
  62. * The LED will be switched off immediately.
  63. * If a timOff parameter of not 0 is given, the LED will be switched off
  64. * for the given time in ms an then return to on state.
  65. */
  66. #define LED_OFF 0
  67. /*!
  68. * \brief Switch LED on.
  69. *
  70. * The LED will be switched on immediately.
  71. * If a timOff parameter of not 0 is given, the LED will be switched on
  72. * for the given time in ms an then return off state.
  73. */
  74. #define LED_ON 1
  75. /*!
  76. * \brief Flip the LED state (toggle).
  77. *
  78. * Toggle the LED from its actual state the the other.
  79. * Timing parameters are not supported.
  80. */
  81. #define LED_FLIP 2
  82. /*!
  83. * \brief Let the LED blink continuously.
  84. *
  85. * The parameter timOn specifies the on-time and parameter timOff the off-time.
  86. * Together with higher timer settings a software dimming can as well be
  87. * established as a simple blink effect or short / long flash effects.
  88. * Be adviced that high timer rates can decrease overall system speed.
  89. * Therefore you have to modify the timer rate in the led.c directly. Standard
  90. * setting is 10ms cycle time.
  91. */
  92. #define LED_BLINK 4
  93. /*@}*/
  94. extern void NutSetLed( HANDLE ledh, uint_fast8_t fxin, uint32_t timOn, uint32_t timOff);
  95. extern void SetLedEvent( uint8_t led, uint32_t interval, uint32_t duration );
  96. extern int NutRegisterLed( HANDLE * ledh, int port, int pin);
  97. #endif