Advertisement
teplofizik

test.c (exti)

May 30th, 2013
227
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 1.08 KB | None | 0 0
  1. // ***********************************************************
  2. // test.c
  3. // В проекте моргает быстро зелёный светодиод. По нажатию на кнопку
  4. // (детектирование фронта) моргание на секунду прекращается.
  5. // ***********************************************************
  6.  
  7. #include "test.h"
  8. #include "../drivers.h"
  9. #include "../bsp.h"
  10.  
  11. static uint32_t ForceTimeout = 0;
  12. static const TPin Button = {PA, 0};
  13.  
  14. // 10 Гц
  15. static void test_onTimer(void)
  16. {
  17.     static bool State = false;
  18.    
  19.     if(ForceTimeout) ForceTimeout--;
  20.    
  21.     if(State || ForceTimeout)
  22.     {
  23.         led_On(0);
  24.     }
  25.     else
  26.     {
  27.         led_Off(0);
  28.     }
  29.    
  30.     State = !State;
  31. }
  32.  
  33. // Нарастающий фронт на PA0
  34. static void test_onButtonClick(void)
  35. {
  36.     ForceTimeout = 10;
  37. }
  38.  
  39. // Инициализация
  40. void test_Init(void)
  41. {
  42.     timer_AddFunction(10, &test_onTimer);
  43.    
  44.     exti_Listen(&Button, EDGE_RISING, &test_onButtonClick);
  45. }
  46.  
  47. void test_Main(void)
  48. {
  49.    
  50. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement