led.c 666 B

1234567891011121314151617181920212223242526272829303132333435363738
  1. #include "LPC17xx.h"
  2. #include "led.h"
  3. void rt_hw_led_init(void)
  4. {
  5. LPC_GPIO2->FIODIR0 |= 1<<0; /* led0:P2.0 */
  6. LPC_GPIO2->FIODIR0 |= 1<<1; /* led1:P2.1 */
  7. }
  8. void rt_hw_led_on(rt_uint32_t led)
  9. {
  10. switch(led)
  11. {
  12. case 0: /* P2.0 = 1 */
  13. LPC_GPIO2->FIOSET0 = 1<<0;
  14. break;
  15. case 1: /* P2.1 = 1 */
  16. LPC_GPIO2->FIOSET0 = 1<<1;
  17. break;
  18. default:
  19. break;
  20. }
  21. }
  22. void rt_hw_led_off(rt_uint32_t led)
  23. {
  24. switch(led)
  25. {
  26. case 0: /* P2.0 = 0 */
  27. LPC_GPIO2->FIOCLR0 = 1<<0;
  28. break;
  29. case 1: /* P2.1 = 0 */
  30. LPC_GPIO2->FIOCLR0 = 1<<1;
  31. break;
  32. default:
  33. break;
  34. }
  35. }