Skip to content

Commit

Permalink
Correction for Issue #88
Browse files Browse the repository at this point in the history
  • Loading branch information
peterantypas committed Nov 3, 2021
1 parent fc63130 commit 11c84ba
Showing 1 changed file with 6 additions and 11 deletions.
17 changes: 6 additions & 11 deletions latest/Firmware/Transponder/Src/GPS.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -137,14 +137,14 @@ void GPS::onPPS()
if ( mUTC == 0 )
return;

++mUTC; // PPS := advance clock by one second!
++mUTC; // PPS := advance clock by one second, the actual time is sent afterwards
localtime_r (&mUTC, &mTime); // Now we know exactly what UTC second it is, with only microseconds of latency
if (!mStarted)

// To keep things simple, we only start the AIS slot timer if we're on an even second (it has a 37.5 Hz frequency)
if (!mStarted && (mTime.tm_sec & 1) == 0 )
{
// To keep things simple, we only start the AIS slot timer if we're on an even second (it has a 37.5 Hz frequency)
mSlotNumber = (mTime.tm_sec % 60) * 2250; // We know what AIS slot number we're in
if (!(mTime.tm_sec & 0x00000001))
startTimer ();
mSlotNumber = (mTime.tm_sec % 60) * 37.5; // We know what AIS slot number we're in
startTimer ();
}
else
{
Expand All @@ -153,24 +153,20 @@ void GPS::onPPS()
{
// On odd seconds, we expect the timer value to be half its period. Just correct it.
uint32_t nominalTimerValue = mPeriod / 2 - 1;
//TIM2->CNT = nominalTimerValue;
bsp_set_sotdma_timer_value(nominalTimerValue);
}
else
{
// On even seconds, things are a bit more tricky ...
//uint32_t currentTimerValue = TIM2->CNT;
uint32_t currentTimerValue = bsp_get_sotdma_timer_value();
if (currentTimerValue >= mPeriod / 2 - 1)
{
// The timer is a little behind, so kick it forward
//TIM2->CNT = mPeriod - 1;
bsp_set_sotdma_timer_value(mPeriod - 1);
}
else
{
// The timer is a little ahead, so pull it back
//TIM2->CNT = 0;
bsp_set_sotdma_timer_value(0);
}
}
Expand All @@ -188,7 +184,6 @@ void GPS::onPPS()
void GPS::processEvent(const Event &event)
{
processLine(event.nmeaBuffer.sentence);
ASSERT(event.rxPacket == nullptr);
}

void GPS::processLine(const char* buff)
Expand Down

0 comments on commit 11c84ba

Please sign in to comment.