board_led.c 2.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104
  1. /*
  2. * File : drv_gpio_led.c
  3. * This file is part of RT-Thread RTOS
  4. * COPYRIGHT (C) 2008 - 2012, RT-Thread Development Team
  5. *
  6. * This program is free software; you can redistribute it and/or modify
  7. * it under the terms of the GNU General Public License as published by
  8. * the Free Software Foundation; either version 2 of the License, or
  9. * (at your option) any later version.
  10. *
  11. * This program is distributed in the hope that it will be useful,
  12. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  13. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  14. * GNU General Public License for more details.
  15. *
  16. * You should have received a copy of the GNU General Public License along
  17. * with this program; if not, write to the Free Software Foundation, Inc.,
  18. * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
  19. *
  20. * Change Logs:
  21. * Date Author Notes
  22. * 2016/05/13 Urey the first version
  23. */
  24. #include <rthw.h>
  25. #include <rtthread.h>
  26. #include <rtdevice.h>
  27. #include "board.h"
  28. #include "drv_gpio.h"
  29. #if 0
  30. #include "board_led.h"
  31. #if defined(BOARD_CANNA)
  32. #define MAX_LED_NBR 3
  33. struct led_io_def led_io_tbl[MAX_LED_NBR] =
  34. {
  35. //LED_POWER
  36. {
  37. GPIO_PORT_C,
  38. GPIO_Pin_24
  39. },
  40. //LED_WIFI
  41. {
  42. GPIO_PORT_D,
  43. GPIO_Pin_5
  44. },
  45. //LED_CHARGING
  46. {
  47. GPIO_PORT_A,
  48. GPIO_Pin_0
  49. },
  50. };
  51. #else
  52. #define MAX_LED_NBR 0
  53. struct led_io_def led_io_tbl[] =
  54. {
  55. //LED_POWER
  56. {
  57. GPIO_PORT_B,
  58. GPIO_Pin_6
  59. },
  60. };
  61. #endif
  62. void rt_hw_led_on(int led)
  63. {
  64. if((led >= LED_LAST) || (led > MAX_LED_NBR))
  65. return;
  66. gpio_set_value(led_io_tbl[led].port,led_io_tbl[led].pin,0);
  67. }
  68. void rt_hw_led_off(int led)
  69. {
  70. if((led >= LED_LAST) || (led > MAX_LED_NBR))
  71. return;
  72. gpio_set_value(led_io_tbl[led].port,led_io_tbl[led].pin,1);
  73. }
  74. int rt_hw_led_init(void)
  75. {
  76. rt_uint8_t i;
  77. /* Init all IO for keyboard */
  78. for (i = 0; i < MAX_LED_NBR; ++i)
  79. {
  80. gpio_set_func(led_io_tbl[i].port,led_io_tbl[i].pin,GPIO_OUTPUT1);
  81. }
  82. return 0;
  83. }
  84. INIT_DEVICE_EXPORT(rt_hw_led_init);
  85. #endif