led.c 924 B

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  1. /*
  2. * File : led.c
  3. * This file is part of RT-Thread RTOS
  4. * COPYRIGHT (C) 2014, RT-Thread Development Team
  5. *
  6. * The license and distribution terms for this file may be
  7. * found in the file LICENSE in this distribution or at
  8. * http://www.rt-thread.org/license/LICENSE
  9. *
  10. * Change Logs:
  11. * Date Author Notes
  12. * 2014-11-23 Bright first implementation
  13. */
  14. #include "led.h"
  15. /* RT_USING_COMPONENTS_INIT */
  16. #ifdef RT_USING_COMPONENTS_INIT
  17. #include <components.h>
  18. #endif
  19. /*
  20. LED: P3.6
  21. */
  22. #define LED_PORT P3
  23. #define LED_DATA(dat) (P36 = dat)
  24. #define LED_BIT BIT6
  25. /* Initial led gpio pin */
  26. int rt_hw_led_init(void)
  27. {
  28. /* Configure the GPIO_LED pin */
  29. GPIO_SetMode(LED_PORT, LED_BIT, GPIO_PMD_OUTPUT);
  30. return 0;
  31. }
  32. void rt_hw_led_on(void)
  33. {
  34. LED_DATA(0);
  35. }
  36. void rt_hw_led_off(void)
  37. {
  38. LED_DATA(1);
  39. }
  40. /* Initial components for device */
  41. INIT_DEVICE_EXPORT(rt_hw_led_init);