Skip to content

Commit

Permalink
Added 64bit timer TCK64
Browse files Browse the repository at this point in the history
  • Loading branch information
lunOptics committed Aug 2, 2020
1 parent 98f3a18 commit dc22a01
Show file tree
Hide file tree
Showing 13 changed files with 210 additions and 111 deletions.
5 changes: 3 additions & 2 deletions src/ErrorHandling/error_codes.h
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,11 @@ namespace TeensyTimerTool
callback= 101,
reload= 102,
noFreeModule = 103,
noFreeChannel = 104,
notImplemented= 105,
noFreeChannel = 104, // requested module has no free channel
notImplemented= 105, // timer does not support this feature
notInitialized= 106,


// GTP Errors
GTP_err = 200,
GTP_err2 = 201,
Expand Down
5 changes: 4 additions & 1 deletion src/ErrorHandling/error_handler.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,9 @@ namespace TeensyTimerTool
case errorCode::periodOverflow:
txt = "Period overflow, set to maximum";
break;
case errorCode::wrongType:
txt = "Wrong parameter type";
break;

// general errors
case errorCode::reload:
Expand All @@ -35,7 +38,7 @@ namespace TeensyTimerTool
txt = "Timer pool contains no free timer";
break;
case errorCode::notImplemented:
txt = "Function not implemented";
txt = "Function not implemented for this timer";
break;
case errorCode::notInitialized:
txt = "Timer not initialized or available";
Expand Down
5 changes: 3 additions & 2 deletions src/ITimerChannel.h
Original file line number Diff line number Diff line change
Expand Up @@ -11,14 +11,15 @@ namespace TeensyTimerTool
virtual errorCode begin(callback_t callback, float period, bool oneShot) { return postError(errorCode::wrongType); };
virtual errorCode trigger(uint32_t delay) = 0;
virtual errorCode trigger(float delay) { return postError(errorCode::wrongType); }
virtual errorCode setPrescaler(int psc) { return postError(errorCode::notImplemented); }

virtual float getMaxPeriod(){ postError(errorCode::notImplemented); return 0;};
virtual float getMaxPeriod(){ postError(errorCode::notImplemented); return 0.0f;};

virtual errorCode setPeriod(uint32_t microSeconds) { return postError(errorCode::notImplemented); };
virtual errorCode setCurrentPeriod(uint32_t microSeconds) { return postError(errorCode::notImplemented); };
virtual errorCode setNextPeriod(uint32_t microSeconds) { return postError(errorCode::notImplemented); };

virtual uint32_t getPeriod() { return 0; }
virtual uint32_t getPeriod() { return 0; }

virtual errorCode start() { return postError(errorCode::notInitialized); };
virtual errorCode stop() { return postError(errorCode::notImplemented); }
Expand Down
2 changes: 1 addition & 1 deletion src/Teensy/TCK/TCK.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
namespace TeensyTimerTool
{
bool TCK_t::isInitialized = false;
TckChannel* TCK_t::channels[NR_OF_TCK_TIMERS];
TckChannelBase* TCK_t::channels[NR_OF_TCK_TIMERS];
}

//----------------------------------------------------------------------
Expand Down
12 changes: 7 additions & 5 deletions src/Teensy/TCK/TCK.h
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
#pragma once

//#include "TckChannelBase.h"
#include "TckChannel.h"
#include "core_pins.h"

Expand All @@ -10,17 +11,18 @@ namespace TeensyTimerTool
class TCK_t
{
public:
static inline ITimerChannel* getTimer();
static inline void removeTimer(TckChannel*);
template<typename counterType> static inline ITimerChannel* getTimer();
static inline void removeTimer(TckChannelBase*);
static inline void tick();

protected:
static bool isInitialized;
static TckChannel* channels[NR_OF_TCK_TIMERS];
static TckChannelBase* channels[NR_OF_TCK_TIMERS];
};

// IMPLEMENTATION ==================================================================

template<typename counterType>
ITimerChannel* TCK_t::getTimer()
{
if (!isInitialized)
Expand All @@ -46,15 +48,15 @@ namespace TeensyTimerTool
{
if (channels[chNr] == nullptr)
{
channels[chNr] = new TckChannel();
channels[chNr] = new TckChannel<counterType>();
return channels[chNr];
}
}

return nullptr;
}

void TCK_t::removeTimer(TckChannel* channel)
void TCK_t::removeTimer(TckChannelBase* channel)
{
for (unsigned chNr = 0; chNr < NR_OF_TCK_TIMERS; chNr++)
{
Expand Down
Loading

0 comments on commit dc22a01

Please sign in to comment.