определены нужные функции и макросы для работы с MIK32
This commit is contained in:
parent
662770f2fd
commit
f68431f34d
@ -434,6 +434,9 @@ extern IRrecv IrReceiver;
|
||||
/*
|
||||
* The receiver interrupt handler for timer interrupt
|
||||
*/
|
||||
#if defined (MIK32V2)
|
||||
__attribute__((noinline, section(".ram_text"), optimize("O3")))
|
||||
# endif
|
||||
void IRReceiveTimerInterruptHandler();
|
||||
|
||||
/****************************************************
|
||||
|
||||
@ -314,6 +314,14 @@
|
||||
#define __digitalPinToBit(P) (((P) <= 7) ? (P) : (P) - 8 )
|
||||
# endif
|
||||
|
||||
#elif defined(MIK32V2)
|
||||
#include "wiring_LL.h"
|
||||
|
||||
#define pinModeFast(P, V) pinMode(P, V)
|
||||
#define digitalWriteFast(P, V) ((V==1) ? GPIO_SET_PIN(digitalPinToPort(P), digitalPinToBitMask(P)) : GPIO_CLEAR_PIN(digitalPinToPort(P), digitalPinToBitMask(P)))
|
||||
#define digitalReadFast(P) GPIO_READ_PIN(digitalPinToPort(P), digitalPinToBitMask(P))
|
||||
#define digitalToggleFast(P) GPIO_TOGGLE_PIN(digitalPinToPort(P), digitalPinToBitMask(P))
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
|
||||
@ -2018,6 +2018,60 @@ void timerConfigForSend(uint16_t aFrequencyKHz) {
|
||||
}
|
||||
# endif // defined(SEND_PWM_BY_TIMER)
|
||||
|
||||
|
||||
/***************************************
|
||||
* MIK32V2 based boards
|
||||
***************************************/
|
||||
#elif defined(MIK32V2)
|
||||
#include "mik32_hal_timer16.h"
|
||||
#include "mik32_hal_irq.h"
|
||||
#include "wiring_LL.h"
|
||||
|
||||
// -------------------------- receiving -------------------------- //
|
||||
#define MIK32_IR_REC_TIMER_PERIOD ((F_CPU / MICROS_IN_ONE_SECOND) * MICROS_PER_TICK)
|
||||
// use timer16_0
|
||||
Timer16_HandleTypeDef htimer16_0;
|
||||
|
||||
void timerConfigForReceive()
|
||||
{
|
||||
// init timer
|
||||
htimer16_0.Instance = TIMER16_0;
|
||||
htimer16_0.Clock.Source = TIMER16_SOURCE_INTERNAL_SYSTEM;
|
||||
htimer16_0.Clock.Prescaler = 0;
|
||||
htimer16_0.CountMode = TIMER16_COUNTMODE_INTERNAL;
|
||||
htimer16_0.ActiveEdge = TIMER16_ACTIVEEDGE_RISING;
|
||||
htimer16_0.Preload = TIMER16_PRELOAD_AFTERWRITE;
|
||||
htimer16_0.Trigger.Source = 0;
|
||||
htimer16_0.Trigger.ActiveEdge = TIMER16_TRIGGER_ACTIVEEDGE_SOFTWARE;
|
||||
htimer16_0.Trigger.TimeOut = TIMER16_TIMEOUT_DISABLE;
|
||||
htimer16_0.Filter.ExternalClock = TIMER16_FILTER_NONE;
|
||||
htimer16_0.Filter.Trigger = TIMER16_FILTER_NONE;
|
||||
htimer16_0.Waveform.Enable = TIMER16_WAVEFORM_GENERATION_DISABLE;
|
||||
htimer16_0.Waveform.Polarity = TIMER16_WAVEFORM_POLARITY_NONINVERTED;
|
||||
htimer16_0.EncoderMode = TIMER16_ENCODER_DISABLE;
|
||||
HAL_Timer16_Init(&htimer16_0);
|
||||
|
||||
HAL_EPIC_MaskLevelSet(HAL_EPIC_TIMER16_0_MASK);
|
||||
}
|
||||
|
||||
void timerEnableReceiveInterrupt()
|
||||
{
|
||||
HAL_Timer16_Counter_Start_IT(&htimer16_0, MIK32_IR_REC_TIMER_PERIOD);
|
||||
}
|
||||
|
||||
void timerDisableReceiveInterrupt()
|
||||
{
|
||||
HAL_Timer16_Stop_IT(&htimer16_0);
|
||||
}
|
||||
|
||||
extern "C" void __attribute__((noinline, section(".ram_text"), optimize("O3"))) IRremote_interrupt_handler(void)
|
||||
{
|
||||
if (TIM16_GET_ARRM_INT_STATUS(htimer16_0))
|
||||
IRReceiveTimerInterruptHandler(); // timer period has passed, call interrupt handler
|
||||
|
||||
TIM16_CLEAR_INT_MASK(htimer16_0, 0xFFFFFFFF); // reset timer interrupt flags
|
||||
}
|
||||
|
||||
/***************************************
|
||||
* Unknown CPU board
|
||||
***************************************/
|
||||
|
||||
Loading…
Reference in New Issue
Block a user