Advertisement
teplofizik

test.c

Mar 4th, 2013
175
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 1.26 KB | None | 0 0
  1. // ***********************************************************
  2. //  test.c
  3. //
  4. // ***********************************************************
  5.  
  6. #include "test.h"
  7. #include "../drivers.h"
  8. #include "../bsp.h"
  9.  
  10. static bool State = false;
  11. static int  Index = 0;
  12.  
  13. // Периодически вызываемая функция
  14. static void test_onTimer(void)
  15. {
  16.     if(State)
  17.     {
  18.         led_On(Index);
  19.     }
  20.     else
  21.     {
  22.         led_Off(Index);
  23.     }
  24.    
  25.     // Сменим состояние
  26.     State = !State;
  27. }
  28.  
  29. // Сменим номер светодиода по
  30. void test_onKey(uint8_t Button)
  31. {
  32.     // Погасим светодиод текущий, потом зажгём следующий
  33.     led_Off(Index);
  34.    
  35.     // Выберем следующий
  36.     Index++;
  37.     Index &= 0x03;
  38.    
  39.     // Пусть и следующую итерацию он светится
  40.     State = true;
  41.    
  42.     led_Off(Index);
  43. }
  44.  
  45. // Запуск тестовой программы
  46. void test_Init(void)
  47. {
  48.     // Функция test_onTimer будет вызываться с частотой 10 Гц
  49.     timer_AddFunction(10, &test_onTimer);
  50.    
  51.     // Обработчик нажатия на кнопку
  52.     button_SetHandler(&test_onKey);
  53. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement