Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // ***********************************************************
- // test.c
- // В проекте моргает быстро зелёный светодиод. По нажатию на кнопку
- // (детектирование фронта) моргание на секунду прекращается.
- // ***********************************************************
- #include "test.h"
- #include "../drivers.h"
- #include "../bsp.h"
- static uint32_t ForceTimeout = 0;
- static const TPin Button = {PA, 0};
- // 10 Гц
- static void test_onTimer(void)
- {
- static bool State = false;
- if(ForceTimeout) ForceTimeout--;
- if(State || ForceTimeout)
- {
- led_On(0);
- }
- else
- {
- led_Off(0);
- }
- State = !State;
- }
- // Нарастающий фронт на PA0
- static void test_onButtonClick(void)
- {
- ForceTimeout = 10;
- }
- // Инициализация
- void test_Init(void)
- {
- timer_AddFunction(10, &test_onTimer);
- exti_Listen(&Button, EDGE_RISING, &test_onButtonClick);
- }
- void test_Main(void)
- {
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement