mirror of
https://github.com/Show-maket/IR-protocol.git
synced 2025-05-03 23:00:16 +00:00
HardwareTimer auto set support
This commit is contained in:
parent
6ba8fdffe4
commit
2d839d3ff8
@ -45,11 +45,11 @@ HardwareTimer* IR_Encoder::IR_Timer = nullptr;
|
||||
|
||||
inline HardwareTimer* IR_Encoder::get_IR_Timer(){return IR_Encoder::IR_Timer;}
|
||||
|
||||
void IR_Encoder::begin(HardwareTimer* timer, uint8_t channel, IRQn_Type IRQn, uint8_t priority){
|
||||
void IR_Encoder::begin(HardwareTimer* timer, uint8_t channel, IRQn_Type IRQn, uint8_t priority, void(*isrCallback)()){
|
||||
IR_Timer = timer;
|
||||
if(IR_Timer == nullptr) return;
|
||||
IR_Timer->setOverflow(carrierFrec * 2, HERTZ_FORMAT);
|
||||
IR_Timer->attachInterrupt(channel, IR_Encoder::isr);
|
||||
IR_Timer->attachInterrupt(channel, (isrCallback == nullptr ? IR_Encoder::isr : isrCallback));
|
||||
NVIC_SetPriority(IRQn, priority);
|
||||
IR_Timer->resume();
|
||||
}
|
||||
|
@ -21,7 +21,7 @@ public:
|
||||
/// @param decPair Приёмник, для которого отключается приём в момент передачи передатчиком
|
||||
IR_Encoder(uint8_t pin, uint16_t addr = 0, IR_DecoderRaw *decPair = nullptr, bool autoHandle = true);
|
||||
static void isr();
|
||||
static void begin(HardwareTimer* IR_Timer, uint8_t channel, IRQn_Type IRQn, uint8_t priority);
|
||||
static void begin(HardwareTimer* timer, uint8_t channel, IRQn_Type IRQn, uint8_t priority, void(*isrCallback)() = nullptr);
|
||||
static HardwareTimer* get_IR_Timer();
|
||||
|
||||
void enable();
|
||||
|
Loading…
x
Reference in New Issue
Block a user