PageRenderTime 26ms CodeModel.GetById 16ms RepoModel.GetById 0ms app.codeStats 0ms

/configs/nucleo-l476rg/src/stm32_autoleds.c

https://bitbucket.org/hg42/nuttx
C | 96 lines | 31 code | 15 blank | 50 comment | 4 complexity | 898c2c08b2412b55d88f924245980f29 MD5 | raw file
Possible License(s): 0BSD
  1. /****************************************************************************
  2. * configs/nucleo-l476rg/src/stm32l4_autoleds.c
  3. *
  4. * Copyright (C) 2014-2015 Gregory Nutt. All rights reserved.
  5. * Author: Gregory Nutt <gnutt@nuttx.org>
  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
  15. * the documentation and/or other materials provided with the
  16. * distribution.
  17. * 3. Neither the name NuttX nor the names of its contributors may be
  18. * used to endorse or promote products derived from this software
  19. * without specific prior written permission.
  20. *
  21. * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
  22. * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
  23. * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
  24. * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
  25. * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
  26. * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
  27. * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
  28. * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
  29. * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
  30. * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
  31. * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
  32. * POSSIBILITY OF SUCH DAMAGE.
  33. *
  34. ****************************************************************************/
  35. /****************************************************************************
  36. * Included Files
  37. ****************************************************************************/
  38. #include <nuttx/config.h>
  39. #include <stdint.h>
  40. #include <stdbool.h>
  41. #include <debug.h>
  42. #include <nuttx/board.h>
  43. #include <arch/board/board.h>
  44. #include "chip.h"
  45. #include "up_arch.h"
  46. #include "up_internal.h"
  47. #include "stm32l4.h"
  48. #include "nucleo-l476rg.h"
  49. #ifdef CONFIG_ARCH_LEDS
  50. /****************************************************************************
  51. * Public Functions
  52. ****************************************************************************/
  53. /****************************************************************************
  54. * Name: board_autoled_initialize
  55. ****************************************************************************/
  56. void board_autoled_initialize(void)
  57. {
  58. /* Configure LD2 GPIO for output */
  59. stm32l4_configgpio(GPIO_LD2);
  60. }
  61. /****************************************************************************
  62. * Name: board_autoled_on
  63. ****************************************************************************/
  64. void board_autoled_on(int led)
  65. {
  66. if (led == 1)
  67. {
  68. stm32l4_gpiowrite(GPIO_LD2, true);
  69. }
  70. }
  71. /****************************************************************************
  72. * Name: board_autoled_off
  73. ****************************************************************************/
  74. void board_autoled_off(int led)
  75. {
  76. if (led == 1)
  77. {
  78. stm32l4_gpiowrite(GPIO_LD2, false);
  79. }
  80. }
  81. #endif /* CONFIG_ARCH_LEDS */