mirror of
https://github.com/peterantypas/maiana.git
synced 2025-05-29 05:40:15 -07:00
Checkpoint
This commit is contained in:
parent
63e7c8cda4
commit
a7f1524689
@ -905,6 +905,8 @@
|
|||||||
|
|
||||||
</option>
|
</option>
|
||||||
|
|
||||||
|
<option id="ilg.gnuarmeclipse.managedbuild.cross.option.c.compiler.asmlisting.1148532259" name="Generate assembler listing (-Wa,-adhlns="$@.lst")" superClass="ilg.gnuarmeclipse.managedbuild.cross.option.c.compiler.asmlisting" useByScannerDiscovery="false" value="true" valueType="boolean"/>
|
||||||
|
|
||||||
<inputType id="ilg.gnuarmeclipse.managedbuild.cross.tool.c.compiler.input.434150746" superClass="ilg.gnuarmeclipse.managedbuild.cross.tool.c.compiler.input"/>
|
<inputType id="ilg.gnuarmeclipse.managedbuild.cross.tool.c.compiler.input.434150746" superClass="ilg.gnuarmeclipse.managedbuild.cross.tool.c.compiler.input"/>
|
||||||
|
|
||||||
</tool>
|
</tool>
|
||||||
@ -943,6 +945,8 @@
|
|||||||
|
|
||||||
</option>
|
</option>
|
||||||
|
|
||||||
|
<option id="ilg.gnuarmeclipse.managedbuild.cross.option.cpp.compiler.asmlisting.1222462616" name="Generate assembler listing (-Wa,-adhlns="$@.lst")" superClass="ilg.gnuarmeclipse.managedbuild.cross.option.cpp.compiler.asmlisting" useByScannerDiscovery="false" value="true" valueType="boolean"/>
|
||||||
|
|
||||||
<inputType id="ilg.gnuarmeclipse.managedbuild.cross.tool.cpp.compiler.input.2090799641" superClass="ilg.gnuarmeclipse.managedbuild.cross.tool.cpp.compiler.input"/>
|
<inputType id="ilg.gnuarmeclipse.managedbuild.cross.tool.cpp.compiler.input.2090799641" superClass="ilg.gnuarmeclipse.managedbuild.cross.tool.cpp.compiler.input"/>
|
||||||
|
|
||||||
</tool>
|
</tool>
|
||||||
@ -969,6 +973,8 @@
|
|||||||
|
|
||||||
<option id="ilg.gnuarmeclipse.managedbuild.cross.option.cpp.linker.useprintffloat.1665988968" name="Use float with nano printf (-u _printf_float)" superClass="ilg.gnuarmeclipse.managedbuild.cross.option.cpp.linker.useprintffloat" useByScannerDiscovery="false" value="false" valueType="boolean"/>
|
<option id="ilg.gnuarmeclipse.managedbuild.cross.option.cpp.linker.useprintffloat.1665988968" name="Use float with nano printf (-u _printf_float)" superClass="ilg.gnuarmeclipse.managedbuild.cross.option.cpp.linker.useprintffloat" useByScannerDiscovery="false" value="false" valueType="boolean"/>
|
||||||
|
|
||||||
|
<option id="ilg.gnuarmeclipse.managedbuild.cross.option.cpp.linker.printmap.1943968052" name="Print link map (-Xlinker --print-map)" superClass="ilg.gnuarmeclipse.managedbuild.cross.option.cpp.linker.printmap" useByScannerDiscovery="false" value="true" valueType="boolean"/>
|
||||||
|
|
||||||
<inputType id="ilg.gnuarmeclipse.managedbuild.cross.tool.cpp.linker.input.166504373" superClass="ilg.gnuarmeclipse.managedbuild.cross.tool.cpp.linker.input">
|
<inputType id="ilg.gnuarmeclipse.managedbuild.cross.tool.cpp.linker.input.166504373" superClass="ilg.gnuarmeclipse.managedbuild.cross.tool.cpp.linker.input">
|
||||||
|
|
||||||
<additionalInput kind="additionalinputdependency" paths="$(USER_OBJS)"/>
|
<additionalInput kind="additionalinputdependency" paths="$(USER_OBJS)"/>
|
||||||
@ -1241,6 +1247,8 @@
|
|||||||
|
|
||||||
</option>
|
</option>
|
||||||
|
|
||||||
|
<option id="ilg.gnuarmeclipse.managedbuild.cross.option.c.compiler.asmlisting.1637376777" name="Generate assembler listing (-Wa,-adhlns="$@.lst")" superClass="ilg.gnuarmeclipse.managedbuild.cross.option.c.compiler.asmlisting" useByScannerDiscovery="false" value="true" valueType="boolean"/>
|
||||||
|
|
||||||
<inputType id="ilg.gnuarmeclipse.managedbuild.cross.tool.c.compiler.input.2109805397" superClass="ilg.gnuarmeclipse.managedbuild.cross.tool.c.compiler.input"/>
|
<inputType id="ilg.gnuarmeclipse.managedbuild.cross.tool.c.compiler.input.2109805397" superClass="ilg.gnuarmeclipse.managedbuild.cross.tool.c.compiler.input"/>
|
||||||
|
|
||||||
</tool>
|
</tool>
|
||||||
@ -1279,6 +1287,8 @@
|
|||||||
|
|
||||||
</option>
|
</option>
|
||||||
|
|
||||||
|
<option id="ilg.gnuarmeclipse.managedbuild.cross.option.cpp.compiler.asmlisting.2078718100" name="Generate assembler listing (-Wa,-adhlns="$@.lst")" superClass="ilg.gnuarmeclipse.managedbuild.cross.option.cpp.compiler.asmlisting" useByScannerDiscovery="false" value="true" valueType="boolean"/>
|
||||||
|
|
||||||
<inputType id="ilg.gnuarmeclipse.managedbuild.cross.tool.cpp.compiler.input.1022917461" superClass="ilg.gnuarmeclipse.managedbuild.cross.tool.cpp.compiler.input"/>
|
<inputType id="ilg.gnuarmeclipse.managedbuild.cross.tool.cpp.compiler.input.1022917461" superClass="ilg.gnuarmeclipse.managedbuild.cross.tool.cpp.compiler.input"/>
|
||||||
|
|
||||||
</tool>
|
</tool>
|
||||||
@ -1311,6 +1321,8 @@
|
|||||||
|
|
||||||
<option id="ilg.gnuarmeclipse.managedbuild.cross.option.cpp.linker.strip.1180354308" name="Omit all symbol information (-s)" superClass="ilg.gnuarmeclipse.managedbuild.cross.option.cpp.linker.strip" useByScannerDiscovery="false" value="true" valueType="boolean"/>
|
<option id="ilg.gnuarmeclipse.managedbuild.cross.option.cpp.linker.strip.1180354308" name="Omit all symbol information (-s)" superClass="ilg.gnuarmeclipse.managedbuild.cross.option.cpp.linker.strip" useByScannerDiscovery="false" value="true" valueType="boolean"/>
|
||||||
|
|
||||||
|
<option id="ilg.gnuarmeclipse.managedbuild.cross.option.cpp.linker.printmap.1618924265" name="Print link map (-Xlinker --print-map)" superClass="ilg.gnuarmeclipse.managedbuild.cross.option.cpp.linker.printmap" useByScannerDiscovery="false" value="false" valueType="boolean"/>
|
||||||
|
|
||||||
<inputType id="ilg.gnuarmeclipse.managedbuild.cross.tool.cpp.linker.input.317754509" superClass="ilg.gnuarmeclipse.managedbuild.cross.tool.cpp.linker.input">
|
<inputType id="ilg.gnuarmeclipse.managedbuild.cross.tool.cpp.linker.input.317754509" superClass="ilg.gnuarmeclipse.managedbuild.cross.tool.cpp.linker.input">
|
||||||
|
|
||||||
<additionalInput kind="additionalinputdependency" paths="$(USER_OBJS)"/>
|
<additionalInput kind="additionalinputdependency" paths="$(USER_OBJS)"/>
|
||||||
|
@ -57,8 +57,10 @@ public:
|
|||||||
void dispatch();
|
void dispatch();
|
||||||
private:
|
private:
|
||||||
EventQueue();
|
EventQueue();
|
||||||
QueueHandle_t mQueueHandle;
|
//QueueHandle_t mQueueHandle;
|
||||||
StaticQueue_t mQueue;
|
//StaticQueue_t mQueue;
|
||||||
|
CircularQueue<Event*> mISRQueue;
|
||||||
|
CircularQueue<Event*> mTaskQueue;
|
||||||
map<EventConsumer *, uint32_t> mConsumers;
|
map<EventConsumer *, uint32_t> mConsumers;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -15,7 +15,7 @@
|
|||||||
|
|
||||||
You should have received a copy of the GNU General Public License
|
You should have received a copy of the GNU General Public License
|
||||||
along with this program. If not, see <https://www.gnu.org/licenses/>
|
along with this program. If not, see <https://www.gnu.org/licenses/>
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
|
||||||
#ifndef RXPACKET_HPP_
|
#ifndef RXPACKET_HPP_
|
||||||
@ -70,15 +70,19 @@ private:
|
|||||||
void addBit(uint8_t bit);
|
void addBit(uint8_t bit);
|
||||||
void addBitCRC(uint8_t bit);
|
void addBitCRC(uint8_t bit);
|
||||||
private:
|
private:
|
||||||
uint8_t mPacket[MAX_AIS_RX_PACKET_SIZE/8+1];
|
struct
|
||||||
uint16_t mSize;
|
{
|
||||||
uint16_t mCRC;
|
uint8_t mPacket[MAX_AIS_RX_PACKET_SIZE/8+1];
|
||||||
mutable uint8_t mType;
|
uint16_t mSize;
|
||||||
mutable uint8_t mRI;
|
uint16_t mCRC;
|
||||||
mutable uint32_t mMMSI;
|
mutable uint8_t mType;
|
||||||
uint32_t mSlot;
|
mutable uint8_t mRI;
|
||||||
VHFChannel mChannel;
|
mutable uint32_t mMMSI;
|
||||||
uint8_t mRSSI;
|
uint32_t mSlot;
|
||||||
|
VHFChannel mChannel;
|
||||||
|
uint8_t mRSSI;
|
||||||
|
}
|
||||||
|
mState;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif /* RXPACKET_HPP_ */
|
#endif /* RXPACKET_HPP_ */
|
||||||
|
@ -49,7 +49,6 @@ public:
|
|||||||
void transmitCW(VHFChannel channel);
|
void transmitCW(VHFChannel channel);
|
||||||
VHFChannel alternateChannel(VHFChannel channel);
|
VHFChannel alternateChannel(VHFChannel channel);
|
||||||
|
|
||||||
void noiseFloorUpdated(VHFChannel channel, uint8_t rssi);
|
|
||||||
|
|
||||||
private:
|
private:
|
||||||
RadioManager();
|
RadioManager();
|
||||||
|
@ -47,9 +47,9 @@ public:
|
|||||||
virtual void startReceiving(VHFChannel channel);
|
virtual void startReceiving(VHFChannel channel);
|
||||||
virtual void onBitClock();
|
virtual void onBitClock();
|
||||||
virtual void timeSlotStarted(uint32_t slot);
|
virtual void timeSlotStarted(uint32_t slot);
|
||||||
void startListening(VHFChannel channel);
|
|
||||||
void switchToChannel(VHFChannel channel);
|
void switchToChannel(VHFChannel channel);
|
||||||
private:
|
protected:
|
||||||
|
void startListening(VHFChannel channel);
|
||||||
bool addBit(uint8_t bit);
|
bool addBit(uint8_t bit);
|
||||||
void resetBitScanner();
|
void resetBitScanner();
|
||||||
uint8_t reportRSSI();
|
uint8_t reportRSSI();
|
||||||
|
@ -47,7 +47,6 @@ public:
|
|||||||
void startListening(VHFChannel channel);
|
void startListening(VHFChannel channel);
|
||||||
void transmitCW(VHFChannel channel);
|
void transmitCW(VHFChannel channel);
|
||||||
void processEvent(const Event &);
|
void processEvent(const Event &);
|
||||||
void noiseFloorUpdated(VHFChannel channel, uint8_t rssi);
|
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
void configure();
|
void configure();
|
||||||
@ -61,7 +60,7 @@ private:
|
|||||||
TXPacket *mTXPacket;
|
TXPacket *mTXPacket;
|
||||||
time_t mUTC;
|
time_t mUTC;
|
||||||
time_t mLastTXTime;
|
time_t mLastTXTime;
|
||||||
map<VHFChannel, uint8_t> mNoiseFloorCache;
|
//map<VHFChannel, uint8_t> mNoiseFloorCache;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif /* TRANSCEIVER_HPP_ */
|
#endif /* TRANSCEIVER_HPP_ */
|
||||||
|
@ -31,7 +31,7 @@
|
|||||||
|
|
||||||
#define EVENT_QUEUE_SIZE 50
|
#define EVENT_QUEUE_SIZE 50
|
||||||
|
|
||||||
static Event* __queue[EVENT_QUEUE_SIZE];
|
//static Event* __queue[EVENT_QUEUE_SIZE];
|
||||||
|
|
||||||
EventQueue &EventQueue::instance()
|
EventQueue &EventQueue::instance()
|
||||||
{
|
{
|
||||||
@ -40,26 +40,29 @@ EventQueue &EventQueue::instance()
|
|||||||
}
|
}
|
||||||
|
|
||||||
EventQueue::EventQueue()
|
EventQueue::EventQueue()
|
||||||
|
: mISRQueue(25), mTaskQueue(10)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
void EventQueue::init()
|
void EventQueue::init()
|
||||||
{
|
{
|
||||||
mQueueHandle = xQueueCreateStatic(EVENT_QUEUE_SIZE, sizeof(Event*), (uint8_t*)&__queue[0], &mQueue);
|
//mQueueHandle = xQueueCreateStatic(EVENT_QUEUE_SIZE, sizeof(Event*), (uint8_t*)&__queue[0], &mQueue);
|
||||||
configASSERT(mQueueHandle);
|
//configASSERT(mQueueHandle);
|
||||||
}
|
}
|
||||||
|
|
||||||
void EventQueue::push(Event *e)
|
void EventQueue::push(Event *e)
|
||||||
{
|
{
|
||||||
if ( xTaskGetSchedulerState() != taskSCHEDULER_RUNNING )
|
//if ( xTaskGetSchedulerState() != taskSCHEDULER_RUNNING )
|
||||||
return;
|
//return;
|
||||||
|
|
||||||
BaseType_t xHighPriorityTaskWoken = pdTRUE;
|
//BaseType_t xHighPriorityTaskWoken = pdTRUE;
|
||||||
if ( Utils::inISR() )
|
if ( Utils::inISR() )
|
||||||
{
|
{
|
||||||
//bsp_signal_high();
|
//bsp_signal_high();
|
||||||
xQueueSendFromISR(mQueueHandle, &e, &xHighPriorityTaskWoken);
|
//xQueueSendFromISR(mQueueHandle, &e, &xHighPriorityTaskWoken);
|
||||||
//bsp_signal_low();
|
//bsp_signal_low();
|
||||||
|
if ( !mISRQueue.push(e) )
|
||||||
|
EventPool::instance().deleteEvent(e);
|
||||||
#if 0
|
#if 0
|
||||||
if ( xHighPriorityTaskWoken )
|
if ( xHighPriorityTaskWoken )
|
||||||
portYIELD_FROM_ISR(xHighPriorityTaskWoken);
|
portYIELD_FROM_ISR(xHighPriorityTaskWoken);
|
||||||
@ -67,7 +70,9 @@ void EventQueue::push(Event *e)
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
xQueueSend(mQueueHandle, &e, 0);
|
//xQueueSend(mQueueHandle, &e, 0);
|
||||||
|
if ( !mTaskQueue.push(e) )
|
||||||
|
EventPool::instance().deleteEvent(e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -89,7 +94,21 @@ void EventQueue::dispatch()
|
|||||||
{
|
{
|
||||||
Event *e = nullptr;
|
Event *e = nullptr;
|
||||||
|
|
||||||
while ( xQueueReceive(mQueueHandle, &e, 10) == pdTRUE )
|
//while ( xQueueReceive(mQueueHandle, &e, 10) == pdTRUE )
|
||||||
|
while (mISRQueue.pop(e))
|
||||||
|
{
|
||||||
|
for ( map<EventConsumer*, uint32_t>::iterator c = mConsumers.begin(); c != mConsumers.end(); ++c )
|
||||||
|
{
|
||||||
|
if ( c->second & e->type )
|
||||||
|
{
|
||||||
|
c->first->processEvent(*e);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
EventPool::instance().deleteEvent(e);
|
||||||
|
}
|
||||||
|
|
||||||
|
while (mTaskQueue.pop(e))
|
||||||
{
|
{
|
||||||
for ( map<EventConsumer*, uint32_t>::iterator c = mConsumers.begin(); c != mConsumers.end(); ++c )
|
for ( map<EventConsumer*, uint32_t>::iterator c = mConsumers.begin(); c != mConsumers.end(); ++c )
|
||||||
{
|
{
|
||||||
|
@ -214,12 +214,11 @@ void GPS::parseSentence(const char *buff)
|
|||||||
#ifdef MULTIPLEXED_OUTPUT
|
#ifdef MULTIPLEXED_OUTPUT
|
||||||
DataTerminal::instance ().write ("NMEA", buff);
|
DataTerminal::instance ().write ("NMEA", buff);
|
||||||
#else
|
#else
|
||||||
//
|
DataTerminal::instance().write(buff);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
if (sentence.code ().find ("RMC") == 2)
|
if (sentence.code ().find ("RMC") == 2)
|
||||||
{
|
{
|
||||||
DataTerminal::instance().write(buff);
|
|
||||||
const vector<string> &fields = sentence.fields ();
|
const vector<string> &fields = sentence.fields ();
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
@ -15,13 +15,15 @@
|
|||||||
|
|
||||||
You should have received a copy of the GNU General Public License
|
You should have received a copy of the GNU General Public License
|
||||||
along with this program. If not, see <https://www.gnu.org/licenses/>
|
along with this program. If not, see <https://www.gnu.org/licenses/>
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
|
||||||
#include <cassert>
|
#include <cassert>
|
||||||
#include <cstring>
|
#include <cstring>
|
||||||
#include "RXPacket.hpp"
|
#include "RXPacket.hpp"
|
||||||
|
|
||||||
|
//#define memcpy my_on_steroids_memcpy
|
||||||
|
|
||||||
|
|
||||||
RXPacket::RXPacket ()
|
RXPacket::RXPacket ()
|
||||||
{
|
{
|
||||||
@ -34,16 +36,18 @@ RXPacket::~RXPacket ()
|
|||||||
|
|
||||||
void RXPacket::setChannel(VHFChannel channel)
|
void RXPacket::setChannel(VHFChannel channel)
|
||||||
{
|
{
|
||||||
mChannel = channel;
|
mState.mChannel = channel;
|
||||||
}
|
}
|
||||||
|
|
||||||
VHFChannel RXPacket::channel() const
|
VHFChannel RXPacket::channel() const
|
||||||
{
|
{
|
||||||
return mChannel;
|
return mState.mChannel;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#if 1
|
||||||
RXPacket::RXPacket(const RXPacket ©)
|
RXPacket::RXPacket(const RXPacket ©)
|
||||||
{
|
{
|
||||||
|
#if 0
|
||||||
memcpy(mPacket, copy.mPacket, sizeof mPacket);
|
memcpy(mPacket, copy.mPacket, sizeof mPacket);
|
||||||
mSize = copy.mSize;
|
mSize = copy.mSize;
|
||||||
mCRC = copy.mCRC;
|
mCRC = copy.mCRC;
|
||||||
@ -53,10 +57,13 @@ RXPacket::RXPacket(const RXPacket ©)
|
|||||||
mMMSI = copy.mMMSI;
|
mMMSI = copy.mMMSI;
|
||||||
mSlot = copy.mSlot;
|
mSlot = copy.mSlot;
|
||||||
mChannel = copy.mChannel;
|
mChannel = copy.mChannel;
|
||||||
|
#endif
|
||||||
|
memcpy(&mState, ©.mState, sizeof mState);
|
||||||
}
|
}
|
||||||
|
|
||||||
RXPacket &RXPacket::operator =(const RXPacket ©)
|
RXPacket &RXPacket::operator =(const RXPacket ©)
|
||||||
{
|
{
|
||||||
|
#if 0
|
||||||
memcpy(mPacket, copy.mPacket, sizeof mPacket);
|
memcpy(mPacket, copy.mPacket, sizeof mPacket);
|
||||||
mSize = copy.mSize;
|
mSize = copy.mSize;
|
||||||
mCRC = copy.mCRC;
|
mCRC = copy.mCRC;
|
||||||
@ -66,11 +73,16 @@ RXPacket &RXPacket::operator =(const RXPacket ©)
|
|||||||
mMMSI = copy.mMMSI;
|
mMMSI = copy.mMMSI;
|
||||||
mChannel = copy.mChannel;
|
mChannel = copy.mChannel;
|
||||||
mSlot = copy.mSlot;
|
mSlot = copy.mSlot;
|
||||||
|
#endif
|
||||||
|
memcpy(&mState, ©.mState, sizeof mState);
|
||||||
return *this;
|
return *this;
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
void RXPacket::reset()
|
void RXPacket::reset()
|
||||||
{
|
{
|
||||||
|
mState = {{0}, 0, 0xffff, 0, 0, 0, 0xffffffff, CH_18, 0};
|
||||||
|
#if 0
|
||||||
mType = 0;
|
mType = 0;
|
||||||
mRI = 0;
|
mRI = 0;
|
||||||
mMMSI = 0;
|
mMMSI = 0;
|
||||||
@ -79,52 +91,53 @@ void RXPacket::reset()
|
|||||||
mSlot = 0xffffffff;
|
mSlot = 0xffffffff;
|
||||||
mRSSI = 0;
|
mRSSI = 0;
|
||||||
memset(mPacket, 0, sizeof mPacket);
|
memset(mPacket, 0, sizeof mPacket);
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
void RXPacket::setSlot(uint32_t slot)
|
void RXPacket::setSlot(uint32_t slot)
|
||||||
{
|
{
|
||||||
mSlot = slot;
|
mState.mSlot = slot;
|
||||||
}
|
}
|
||||||
|
|
||||||
uint32_t RXPacket::slot() const
|
uint32_t RXPacket::slot() const
|
||||||
{
|
{
|
||||||
return mSlot;
|
return mState.mSlot;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void RXPacket::setRSSI(uint8_t rssi)
|
void RXPacket::setRSSI(uint8_t rssi)
|
||||||
{
|
{
|
||||||
mRSSI = rssi;
|
mState.mRSSI = rssi;
|
||||||
}
|
}
|
||||||
|
|
||||||
uint8_t RXPacket::rssi() const
|
uint8_t RXPacket::rssi() const
|
||||||
{
|
{
|
||||||
return mRSSI;
|
return mState.mRSSI;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void RXPacket::addBit(uint8_t bit)
|
void RXPacket::addBit(uint8_t bit)
|
||||||
{
|
{
|
||||||
ASSERT(mSize < MAX_AIS_RX_PACKET_SIZE);
|
//ASSERT(mSize < MAX_AIS_RX_PACKET_SIZE);
|
||||||
|
|
||||||
uint16_t index = mSize / 8;
|
uint16_t index = mState.mSize / 8;
|
||||||
uint8_t offset = mSize % 8;
|
uint8_t offset = mState.mSize % 8;
|
||||||
|
|
||||||
if ( bit )
|
if ( bit )
|
||||||
mPacket[index] |= ( 1 << offset );
|
mState.mPacket[index] |= ( 1 << offset );
|
||||||
else
|
else
|
||||||
mPacket[index] &= ~( 1 << offset );
|
mState.mPacket[index] &= ~( 1 << offset );
|
||||||
|
|
||||||
++mSize;
|
++mState.mSize;
|
||||||
}
|
}
|
||||||
|
|
||||||
uint8_t RXPacket::bit(uint16_t pos) const
|
uint8_t RXPacket::bit(uint16_t pos) const
|
||||||
{
|
{
|
||||||
if ( pos < mSize ) {
|
if ( pos < mState.mSize ) {
|
||||||
uint16_t index = pos / 8;
|
uint16_t index = pos / 8;
|
||||||
uint8_t offset = pos % 8;
|
uint8_t offset = pos % 8;
|
||||||
|
|
||||||
return (mPacket[index] & (1 << offset)) != 0;
|
return (mState.mPacket[index] & (1 << offset)) != 0;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
return 0;
|
return 0;
|
||||||
@ -145,17 +158,17 @@ uint32_t RXPacket::bits(uint16_t pos, uint8_t count) const
|
|||||||
|
|
||||||
void RXPacket::addBitCRC(uint8_t data)
|
void RXPacket::addBitCRC(uint8_t data)
|
||||||
{
|
{
|
||||||
if ( (data ^ mCRC) & 0x0001 )
|
if ( (data ^ mState.mCRC) & 0x0001 )
|
||||||
mCRC = (mCRC >> 1) ^ 0x8408;
|
mState.mCRC = (mState.mCRC >> 1) ^ 0x8408;
|
||||||
else
|
else
|
||||||
mCRC >>= 1;
|
mState.mCRC >>= 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
void RXPacket::addByte(uint8_t byte)
|
void RXPacket::addByte(uint8_t byte)
|
||||||
{
|
{
|
||||||
// The payload is LSB (inverted MSB bytes). This brings it back into MSB format
|
// The payload is LSB (inverted MSB bytes). This brings it back into MSB format
|
||||||
|
|
||||||
addBit(byte & 0x01);
|
addBit(byte & 0x01);
|
||||||
addBit(byte & 0x02);
|
addBit(byte & 0x02);
|
||||||
addBit(byte & 0x04);
|
addBit(byte & 0x04);
|
||||||
addBit(byte & 0x08);
|
addBit(byte & 0x08);
|
||||||
@ -179,7 +192,7 @@ void RXPacket::addByte(uint8_t byte)
|
|||||||
|
|
||||||
uint16_t RXPacket::size() const
|
uint16_t RXPacket::size() const
|
||||||
{
|
{
|
||||||
return mSize;
|
return mState.mSize;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -190,26 +203,26 @@ bool RXPacket::isBad() const
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
//return mSize < 184;
|
//return mSize < 184;
|
||||||
return mSize < 32;
|
return mState.mSize < 32;
|
||||||
}
|
}
|
||||||
|
|
||||||
uint16_t RXPacket::crc() const
|
uint16_t RXPacket::crc() const
|
||||||
{
|
{
|
||||||
return mCRC;
|
return mState.mCRC;
|
||||||
}
|
}
|
||||||
|
|
||||||
void RXPacket::discardCRC()
|
void RXPacket::discardCRC()
|
||||||
{
|
{
|
||||||
if ( mCRC == 0xffff )
|
if ( mState.mCRC == 0xffff )
|
||||||
return;
|
return;
|
||||||
mSize -= 16;
|
mState.mSize -= 16;
|
||||||
mCRC = 0xffff;
|
mState.mCRC = 0xffff;
|
||||||
|
|
||||||
// Explicitly set those bits to zero, no matter how they align
|
// Explicitly set those bits to zero, no matter how they align
|
||||||
for ( uint8_t i = 0; i < 16; ++i )
|
for ( uint8_t i = 0; i < 16; ++i )
|
||||||
addBit(0);
|
addBit(0);
|
||||||
|
|
||||||
mSize -= 16;
|
mState.mSize -= 16;
|
||||||
}
|
}
|
||||||
|
|
||||||
void RXPacket::addFillBits(uint8_t numBits)
|
void RXPacket::addFillBits(uint8_t numBits)
|
||||||
@ -224,43 +237,43 @@ bool RXPacket::checkCRC() const
|
|||||||
{
|
{
|
||||||
//uint16_t rcrc = ((mCRC & 0xff00) >> 8) | ((mCRC & 0x00ff) << 8);
|
//uint16_t rcrc = ((mCRC & 0xff00) >> 8) | ((mCRC & 0x00ff) << 8);
|
||||||
//trace_printf("%.4x %.4x %.4x\n", mCRC, ~(mCRC), ~(rcrc));
|
//trace_printf("%.4x %.4x %.4x\n", mCRC, ~(mCRC), ~(rcrc));
|
||||||
return mCRC == 0xf0b8;
|
return mState.mCRC == 0xf0b8;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
uint8_t RXPacket::messageType() const
|
uint8_t RXPacket::messageType() const
|
||||||
{
|
{
|
||||||
if ( mType )
|
if ( mState.mType )
|
||||||
return mType;
|
return mState.mType;
|
||||||
|
|
||||||
for ( int i = 0; i < 6; ++i ) {
|
for ( int i = 0; i < 6; ++i ) {
|
||||||
mType <<= 1;
|
mState.mType <<= 1;
|
||||||
mType |= bit(i);
|
mState.mType |= bit(i);
|
||||||
}
|
}
|
||||||
|
|
||||||
return mType;
|
return mState.mType;
|
||||||
}
|
}
|
||||||
|
|
||||||
uint8_t RXPacket::repeatIndicator() const
|
uint8_t RXPacket::repeatIndicator() const
|
||||||
{
|
{
|
||||||
if ( mRI )
|
if ( mState.mRI )
|
||||||
return mRI;
|
return mState.mRI;
|
||||||
|
|
||||||
mRI = bit(6) << 1 | bit(7);
|
mState.mRI = bit(6) << 1 | bit(7);
|
||||||
return mRI;
|
return mState.mRI;
|
||||||
}
|
}
|
||||||
|
|
||||||
uint32_t RXPacket::mmsi() const
|
uint32_t RXPacket::mmsi() const
|
||||||
{
|
{
|
||||||
if ( mMMSI )
|
if ( mState.mMMSI )
|
||||||
return mMMSI;
|
return mState.mMMSI;
|
||||||
|
|
||||||
for ( int i = 8; i < 38; ++i ) {
|
for ( int i = 8; i < 38; ++i ) {
|
||||||
mMMSI <<= 1;
|
mState.mMMSI <<= 1;
|
||||||
mMMSI |= bit(i);
|
mState.mMMSI |= bit(i);
|
||||||
}
|
}
|
||||||
|
|
||||||
return mMMSI;
|
return mState.mMMSI;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -180,14 +180,6 @@ void RadioManager::sendTestPacketNow(TXPacket *packet)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void RadioManager::noiseFloorUpdated(VHFChannel channel, uint8_t rssi)
|
|
||||||
{
|
|
||||||
if ( mTransceiverIC )
|
|
||||||
{
|
|
||||||
mTransceiverIC->noiseFloorUpdated(channel, rssi);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void rxClockCB()
|
void rxClockCB()
|
||||||
{
|
{
|
||||||
RadioManager::instance().onBitClock(2);
|
RadioManager::instance().onBitClock(2);
|
||||||
|
@ -56,6 +56,8 @@ bool Receiver::init()
|
|||||||
//DBG("Configuring IC\r\n");
|
//DBG("Configuring IC\r\n");
|
||||||
configure();
|
configure();
|
||||||
resetBitScanner();
|
resetBitScanner();
|
||||||
|
//configureGPIOsForRX();
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -72,6 +74,7 @@ void Receiver::switchToChannel(VHFChannel channel)
|
|||||||
mSwitchToChannel = channel;
|
mSwitchToChannel = channel;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// TODO: This is a really, really long operation - over 150us !!!
|
||||||
void Receiver::startListening(VHFChannel channel)
|
void Receiver::startListening(VHFChannel channel)
|
||||||
{
|
{
|
||||||
configureGPIOsForRX();
|
configureGPIOsForRX();
|
||||||
@ -106,6 +109,7 @@ void Receiver::onBitClock()
|
|||||||
if ( gRadioState == RADIO_TRANSMITTING )
|
if ( gRadioState == RADIO_TRANSMITTING )
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
bsp_signal_high();
|
||||||
|
|
||||||
uint8_t bit = HAL_GPIO_ReadPin(mDataPort, mDataPin);
|
uint8_t bit = HAL_GPIO_ReadPin(mDataPort, mDataPin);
|
||||||
processNRZIBit(bit);
|
processNRZIBit(bit);
|
||||||
@ -118,6 +122,7 @@ void Receiver::onBitClock()
|
|||||||
#else
|
#else
|
||||||
++mSlotBitNumber;
|
++mSlotBitNumber;
|
||||||
#endif
|
#endif
|
||||||
|
bsp_signal_low();
|
||||||
}
|
}
|
||||||
|
|
||||||
void Receiver::timeSlotStarted(uint32_t slot)
|
void Receiver::timeSlotStarted(uint32_t slot)
|
||||||
@ -245,61 +250,36 @@ bool Receiver::addBit(uint8_t bit)
|
|||||||
|
|
||||||
void Receiver::pushPacket()
|
void Receiver::pushPacket()
|
||||||
{
|
{
|
||||||
//bsp_signal_high();
|
|
||||||
#ifndef TX_TEST_MODE
|
|
||||||
Event *p = EventPool::instance().newEvent(AIS_PACKET_EVENT);
|
Event *p = EventPool::instance().newEvent(AIS_PACKET_EVENT);
|
||||||
if ( p )
|
if ( p )
|
||||||
{
|
{
|
||||||
|
bsp_signal_high();
|
||||||
p->rxPacket = mRXPacket;
|
p->rxPacket = mRXPacket;
|
||||||
|
bsp_signal_low();
|
||||||
EventQueue::instance().push(p);
|
EventQueue::instance().push(p);
|
||||||
}
|
}
|
||||||
mRXPacket.reset();
|
mRXPacket.reset();
|
||||||
#else
|
|
||||||
mRXPacket.reset();
|
|
||||||
#endif
|
|
||||||
//bsp_signal_low();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
uint8_t Receiver::reportRSSI()
|
uint8_t Receiver::reportRSSI()
|
||||||
{
|
{
|
||||||
uint8_t rssi = readRSSI();
|
uint8_t rssi = readRSSI();
|
||||||
|
|
||||||
#if 0
|
|
||||||
Event e(RSSI_SAMPLE_EVENT);
|
|
||||||
e.rssiSample.channel = mChannel;
|
|
||||||
e.rssiSample.rssi = rssi;
|
|
||||||
EventQueue::instance().push(e);
|
|
||||||
#endif
|
|
||||||
|
|
||||||
|
|
||||||
char channel = AIS_CHANNELS[mChannel].designation;
|
char channel = AIS_CHANNELS[mChannel].designation;
|
||||||
NoiseFloorDetector::instance().report(channel, rssi);
|
NoiseFloorDetector::instance().report(channel, rssi);
|
||||||
|
|
||||||
return rssi;
|
return rssi;
|
||||||
}
|
}
|
||||||
|
|
||||||
void Receiver::configureGPIOsForRX()
|
void Receiver::configureGPIOsForRX()
|
||||||
{
|
{
|
||||||
/*
|
|
||||||
* Configure radio GPIOs for RX:
|
|
||||||
* GPIO 0: Don't care
|
|
||||||
* GPIO 1: RX_DATA
|
|
||||||
* GPIO 2: Don't care
|
|
||||||
* GPIO 3: RX_TX_DATA_CLK
|
|
||||||
* NIRQ : SYNC_WORD_DETECT
|
|
||||||
*/
|
|
||||||
|
|
||||||
GPIO_PIN_CFG_PARAMS gpiocfg;
|
GPIO_PIN_CFG_PARAMS gpiocfg;
|
||||||
gpiocfg.GPIO0 = 0x00; // No change
|
gpiocfg.GPIO0 = 0x00; // No change
|
||||||
gpiocfg.GPIO1 = 0x14; // RX data bits
|
gpiocfg.GPIO1 = 0x14; // RX data bits
|
||||||
gpiocfg.GPIO2 = 0x00; // No change
|
gpiocfg.GPIO2 = 0x00; // No change
|
||||||
gpiocfg.GPIO3 = 0x1F; // RX/TX data clock
|
gpiocfg.GPIO3 = 0x1F; // RX/TX data clock
|
||||||
gpiocfg.NIRQ = 0x1A; // Sync word detect
|
gpiocfg.NIRQ = 0x00; // Nothing
|
||||||
gpiocfg.SDO = 0x00; // No change
|
gpiocfg.SDO = 0x00; // No change
|
||||||
gpiocfg.GENCFG = 0x00; // No change
|
gpiocfg.GENCFG = 0x00; // No change
|
||||||
sendCmd(GPIO_PIN_CFG, &gpiocfg, sizeof gpiocfg, &gpiocfg, sizeof gpiocfg);
|
sendCmd(GPIO_PIN_CFG, &gpiocfg, sizeof gpiocfg, &gpiocfg, sizeof gpiocfg);
|
||||||
|
|
||||||
bsp_set_rx_mode();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -88,11 +88,6 @@ void Transceiver::processEvent(const Event &e)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void Transceiver::noiseFloorUpdated(VHFChannel channel, uint8_t rssi)
|
|
||||||
{
|
|
||||||
mNoiseFloorCache[channel] = rssi;
|
|
||||||
}
|
|
||||||
|
|
||||||
void Transceiver::transmitCW(VHFChannel channel)
|
void Transceiver::transmitCW(VHFChannel channel)
|
||||||
{
|
{
|
||||||
startReceiving(channel);
|
startReceiving(channel);
|
||||||
@ -147,15 +142,6 @@ void Transceiver::configureGPIOsForTX(tx_power_level powerLevel)
|
|||||||
{
|
{
|
||||||
bsp_set_tx_mode();
|
bsp_set_tx_mode();
|
||||||
|
|
||||||
/*
|
|
||||||
* Configure radio GPIOs for TX:
|
|
||||||
* GPIO 0: Don't care
|
|
||||||
* GPIO 1: INPUT of TX bits
|
|
||||||
* GPIO 2: Don't care
|
|
||||||
* GPIO 3: RX_TX_DATA_CLK
|
|
||||||
* NIRQ : SYNC_WORD_DETECT
|
|
||||||
*/
|
|
||||||
|
|
||||||
GPIO_PIN_CFG_PARAMS gpiocfg;
|
GPIO_PIN_CFG_PARAMS gpiocfg;
|
||||||
gpiocfg.GPIO0 = 0x20; // TX_STATE; low during RX and high during TX
|
gpiocfg.GPIO0 = 0x20; // TX_STATE; low during RX and high during TX
|
||||||
gpiocfg.GPIO1 = 0x04; // Input
|
gpiocfg.GPIO1 = 0x04; // Input
|
||||||
@ -329,21 +315,12 @@ void Transceiver::configureGPIOsForRX()
|
|||||||
{
|
{
|
||||||
bsp_set_rx_mode();
|
bsp_set_rx_mode();
|
||||||
|
|
||||||
/*
|
|
||||||
* Configure radio GPIOs for RX:
|
|
||||||
* GPIO 0: TX_STATE
|
|
||||||
* GPIO 1: RX_DATA
|
|
||||||
* GPIO 2: RX_TX_DATA_CLK
|
|
||||||
* GPIO 3: RX_STATE
|
|
||||||
* NIRQ : SYNC_WORD_DETECT
|
|
||||||
*/
|
|
||||||
|
|
||||||
GPIO_PIN_CFG_PARAMS gpiocfg;
|
GPIO_PIN_CFG_PARAMS gpiocfg;
|
||||||
gpiocfg.GPIO0 = 0x20; // TX_STATE; low during RX and high during TX
|
gpiocfg.GPIO0 = 0x20; // TX_STATE; low during RX and high during TX
|
||||||
gpiocfg.GPIO1 = 0x14; // RX data bits
|
gpiocfg.GPIO1 = 0x14; // RX data bits
|
||||||
gpiocfg.GPIO2 = 0x1F; // RX/TX data clock
|
gpiocfg.GPIO2 = 0x1F; // RX/TX data clock
|
||||||
gpiocfg.GPIO3 = 0x21; // RX_STATE; high during RX and low during TX
|
gpiocfg.GPIO3 = 0x21; // RX_STATE; high during RX and low during TX
|
||||||
gpiocfg.NIRQ = 0x1A; // Sync word detect
|
gpiocfg.NIRQ = 0x00; // Nothing
|
||||||
gpiocfg.SDO = 0x00; // No change
|
gpiocfg.SDO = 0x00; // No change
|
||||||
gpiocfg.GENCFG = 0x00; // No change
|
gpiocfg.GENCFG = 0x00; // No change
|
||||||
sendCmd(GPIO_PIN_CFG, &gpiocfg, sizeof gpiocfg, &gpiocfg, sizeof gpiocfg);
|
sendCmd(GPIO_PIN_CFG, &gpiocfg, sizeof gpiocfg, &gpiocfg, sizeof gpiocfg);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user