Created
May 15, 2019 17:14
-
-
Save ermacv/67f909b48faa4eee8dfbaf4d53337520 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <stdbool.h> | |
#include <stdint.h> | |
#define DELAY_INIT {0x0000, false} | |
typedef struct{ | |
uint16_t time; | |
bool set; | |
}delay_t; | |
void setDelay(volatile delay_t*, uint16_t); | |
bool isDelayCount(volatile delay_t*); | |
void handleDelayInterrupt(volatile delay_t*); | |
void setDelay(volatile delay_t* delay, uint16_t time){ | |
delay->set = false; | |
delay->time = time; | |
if (time) | |
delay->set = true; | |
} | |
bool isDelayCount(volatile delay_t* delay){ | |
return delay->set; | |
} | |
void handleDelayInterrupt(volatile delay_t* delay){ | |
if ((delay->set)&&(!(--delay->time))) | |
delay->set = false; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment