You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 

41 lines
651 B

  1. #include "config.h"
  2. #include "led.h"
  3. #include "timer.h"
  4. int16_t __led_pattern;
  5. /* Debug LED */
  6. void TISR_HANDLER(6)
  7. {
  8. timer_clear_txif(6);
  9. if (__led_pattern == -1)
  10. return;
  11. __led_pattern <<= 1;
  12. if (__led_pattern & 0x100) {
  13. PORTBbits.RB13 = 0; /* on */
  14. __led_pattern |= 1;
  15. } else {
  16. PORTBbits.RB13 = 1; /* off */
  17. }
  18. __led_pattern &= 0xff;
  19. }
  20. void led_init(void)
  21. {
  22. TRISBbits.TRISB13 = 0;
  23. PORTBbits.RB13 = 1;
  24. __led_pattern = -1;
  25. timer_setup_16bit(6, LED_BLINK_RATE, 1);
  26. timer_set_priority(6, 1); /* low priority */
  27. }
  28. /* Set a pattern (8-bit binary pattern). */
  29. void led_pattern(uint8_t pattern)
  30. {
  31. __led_pattern = pattern;
  32. }