#include <SoftPwmTimer.h>
#include "Timers.h"
#include <MainCommands.h>
#include <SoftPwmOutputPin.h>
#include <driverlib/timer.h>
#include <driverlib/sysctl.h>
#include <driverlib/interrupt.h>
#include <inc/hw_ints.h>
#include <inc/hw_timer.h>
//volatile uint32_t SoftPwmTimer::pwmLedInterruptCount = 0;
void
SoftPwmTimer::disableSoftPwmInterrupts() {
TimerIntDisable(
SoftPwmTimerBase,
SoftPwmTimerTimeout ); };
void
SoftPwmTimer::enableSoftPwmInterrupts() {
TimerIntEnable(
SoftPwmTimerBase,
SoftPwmTimerTimeout ); };
void
SoftPwmTimer::startSoftPwmTimerInterrupts( uint32_t hz ) {
TimerLoadSet(
SoftPwmTimerBase,
SoftPwmTimerLoad,
Timers::frequencyToPeriod( hz ) );
TimerIntRegister(
SoftPwmTimerBase,
SoftPwmTimerLoad,
SoftPwmTimer::SoftPwmTimerInterruptHandler );
// INT_TIMER0B = 36 - PRI9 36..39
#ifdef PART_TM4C1294NCPDT // IntPrioritySet not working for this µP
HWREG( NVIC_PRI9 ) &= ~NVIC_PRI9_INT36_M;
HWREG( NVIC_PRI9 ) |= SoftPwmTimerPriorityLevel << NVIC_PRI9_INT36_S;
#elif defined( PART_LM4F120H5QR )
IntPrioritySet(
SoftPwmTimerInt,
SoftPwmTimerPriorityLevel );
#endif
SoftPwmTimer::enableSoftPwmInterrupts();
TimerEnable(
SoftPwmTimerBase,
SoftPwmTimerLoad ); };
void
SoftPwmTimer::SoftPwmTimerInterruptHandler( void ) {
TimerIntClear(
SoftPwmTimerBase,
SoftPwmTimerTimeout );
// Timers::setD4LED( ++SoftPwmTimer::pwmLedInterruptCount >> 14 );
SoftPwmOutputPin::pwmInterrupt(); };