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 bool State = false;
- static int Index = 0;
- // Периодически вызываемая функция
- static void test_onTimer(void)
- {
- if(State)
- {
- led_On(Index);
- }
- else
- {
- led_Off(Index);
- }
- // Сменим состояние
- State = !State;
- }
- // Сменим номер светодиода по
- void test_onKey(uint8_t Button)
- {
- // Погасим светодиод текущий, потом зажгём следующий
- led_Off(Index);
- // Выберем следующий
- Index++;
- Index &= 0x03;
- // Пусть и следующую итерацию он светится
- State = true;
- led_Off(Index);
- }
- // Запуск тестовой программы
- void test_Init(void)
- {
- // Функция test_onTimer будет вызываться с частотой 10 Гц
- timer_AddFunction(10, &test_onTimer);
- // Обработчик нажатия на кнопку
- button_SetHandler(&test_onKey);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement