diff --git a/eagle/logic3.1.brd b/eagle/logic.brd similarity index 98% rename from eagle/logic3.1.brd rename to eagle/logic.brd index ddcedf6..0192312 100644 --- a/eagle/logic3.1.brd +++ b/eagle/logic.brd @@ -22,8 +22,8 @@ - - + + @@ -146,7 +146,7 @@ - + 5V GND 5V @@ -160,9 +160,10 @@ 3V 3V 3V -AIS Logic State -Rev 3.1 +AIS Logic Stage +Rev 3.2 (c) 2016 Peter Antypas + @@ -1256,6 +1257,8 @@ design rules under a new name. + + @@ -1370,7 +1373,7 @@ design rules under a new name. - + @@ -1497,7 +1500,8 @@ design rules under a new name. - + + @@ -1513,6 +1517,11 @@ design rules under a new name. + + + + + @@ -1914,10 +1923,14 @@ design rules under a new name. - + + + + + @@ -1931,6 +1944,9 @@ design rules under a new name. + + + diff --git a/eagle/logic.brd.pdf b/eagle/logic.brd.pdf new file mode 100644 index 0000000..db55f66 Binary files /dev/null and b/eagle/logic.brd.pdf differ diff --git a/eagle/logic3.1.sch b/eagle/logic.sch similarity index 99% rename from eagle/logic3.1.sch rename to eagle/logic.sch index 7c6fb62..97360d1 100644 --- a/eagle/logic3.1.sch +++ b/eagle/logic.sch @@ -4656,6 +4656,9 @@ Please use FRAME-LEDGER/FRAME-LETTER for schematics now. + + + @@ -4867,6 +4870,11 @@ Please use FRAME-LEDGER/FRAME-LETTER for schematics now. + + + + + @@ -5209,6 +5217,15 @@ Please use FRAME-LEDGER/FRAME-LETTER for schematics now. + + + + + + + + + @@ -5505,8 +5522,11 @@ Please use FRAME-LEDGER/FRAME-LETTER for schematics now. - + @@ -5518,7 +5538,10 @@ Please use FRAME-LEDGER/FRAME-LETTER for schematics now. diff --git a/eagle/logic.sch.pdf b/eagle/logic.sch.pdf new file mode 100644 index 0000000..5ccac06 Binary files /dev/null and b/eagle/logic.sch.pdf differ diff --git a/eagle/logic3.1.brd.pdf b/eagle/logic3.1.brd.pdf deleted file mode 100644 index 639e7e1..0000000 Binary files a/eagle/logic3.1.brd.pdf and /dev/null differ diff --git a/eagle/logic3.1.sch.pdf b/eagle/logic3.1.sch.pdf deleted file mode 100644 index 6eb547f..0000000 Binary files a/eagle/logic3.1.sch.pdf and /dev/null differ diff --git a/eagle/rf9.1.brd b/eagle/rf.brd similarity index 100% rename from eagle/rf9.1.brd rename to eagle/rf.brd diff --git a/eagle/rf9.1.brd.pdf b/eagle/rf.brd.pdf similarity index 100% rename from eagle/rf9.1.brd.pdf rename to eagle/rf.brd.pdf diff --git a/eagle/rf9.1.sch b/eagle/rf.sch similarity index 100% rename from eagle/rf9.1.sch rename to eagle/rf.sch diff --git a/eagle/rf9.1.sch.pdf b/eagle/rf.sch.pdf similarity index 100% rename from eagle/rf9.1.sch.pdf rename to eagle/rf.sch.pdf diff --git a/src/RFIC.hpp b/src/RFIC.hpp index d745880..087296b 100644 --- a/src/RFIC.hpp +++ b/src/RFIC.hpp @@ -47,7 +47,7 @@ private: void spiOn(); void spiOff(); protected: - SPI_TypeDef *mSPI ; // The SPI bus we use + SPI_TypeDef *mSPI; // The SPI bus we use GPIO_TypeDef *mSDNP; // The MCU GPIO assigned to SDN for this IC (GPIOA, GPIOB or GPIOC) GPIO_TypeDef *mCSP; // The MCU GPIO assigned to CS for SPI GPIO_TypeDef *mGPIO1P; // The MCU GPIO assigned to GPIO1 of the IC diff --git a/src/Transceiver.cpp b/src/Transceiver.cpp index b819d44..5209cbb 100644 --- a/src/Transceiver.cpp +++ b/src/Transceiver.cpp @@ -85,6 +85,20 @@ void Transceiver::transmitCW(VHFChannel channel) } +void Transceiver::setTXPower(tx_power_level powerLevel) +{ + const pa_params &pwr = POWER_TABLE[powerLevel]; + SET_PROPERTY_PARAMS p; + p.Group = 0x22; + p.NumProperties = 3; + p.StartProperty = 0x00; + p.Data[0] = pwr.pa_mode; + p.Data[1] = pwr.pa_level; + p.Data[2] = pwr.pa_bias_clkduty; + sendCmd(SET_PROPERTY, &p, 6, NULL, 0); +} + + void Transceiver::configureForTX(tx_power_level powerLevel) { /* @@ -117,17 +131,9 @@ void Transceiver::configureForTX(tx_power_level powerLevel) gpiocfg.GENCFG = 0x00; // No change sendCmd(GPIO_PIN_CFG, &gpiocfg, sizeof gpiocfg, &gpiocfg, sizeof gpiocfg); - const pa_params &pwr = POWER_TABLE[powerLevel]; - SET_PROPERTY_PARAMS p; - p.Group = 0x22; - p.NumProperties = 3; - p.StartProperty = 0x00; - p.Data[0] = pwr.pa_mode; - p.Data[1] = pwr.pa_level; - p.Data[2] = pwr.pa_bias_clkduty; - sendCmd(SET_PROPERTY, &p, 6, NULL, 0); + setTXPower(powerLevel); - // BYP setting is in table + const pa_params &pwr = POWER_TABLE[powerLevel]; if ( pwr.bypass ) GPIO_SetBits(mBYPPort, mBYPPin); else @@ -155,7 +161,8 @@ void Transceiver::onBitClock() // If we have an assigned packet and we're on the correct channel, at the right bit of the time slot, // and the RSSI is within 6dB of the noise floor for this channel, then fire!!! - if ( mSlotBitNumber == CCA_SLOT_BIT+1 && mTXPacket && mTXPacket->channel() == mChannel && mRXPacket->rssi() < NoiseFloorDetector::instance().getNoiseFloor(mChannel) + 12 ) { + uint8_t noiseFloor = NoiseFloorDetector::instance().getNoiseFloor(mChannel); + if ( mSlotBitNumber == CCA_SLOT_BIT+1 && mTXPacket && mTXPacket->channel() == mChannel && mRXPacket->rssi() < noiseFloor + 12 ) { startTransmitting(); } } diff --git a/src/Transceiver.hpp b/src/Transceiver.hpp index eaca5cb..4272999 100644 --- a/src/Transceiver.hpp +++ b/src/Transceiver.hpp @@ -37,10 +37,10 @@ public: void transmitCW(VHFChannel channel); protected: void configure(); - private: void startTransmitting(); void configureForTX(tx_power_level pwr); + void setTXPower(tx_power_level pwr); private: TXPacket *mTXPacket; GPIO_TypeDef *mCTXPort; diff --git a/src/globals.h b/src/globals.h index 793c762..235a259 100644 --- a/src/globals.h +++ b/src/globals.h @@ -70,31 +70,12 @@ // Default interval for message 24 A&B (static data report) #define MSG_24_TX_INTERVAL 180 -#define CCA_SLOT_BIT 8 +// The spec calls for Class B transmitters to listen for the first 20 bits of each frame before transmitting. +// It takes the Si4463 a few bits' time to switch from RX to TX, so I arbitrarily picked the 12th bit. +#define CCA_SLOT_BIT 11 // Extra debugging using halting assertions #define DEV_MODE 1 - - -/* - * Ideally, these should come from some non-volatile storage on board, but for now - * we just define them here. - * - * NOTE: It is against US Coast Guard regulations to transmit AIS messages with an invalid MMSI. Consider yourself warned. - * That said, just about everyone developing AIS equipment does this at some point, typically in lab environments. - * - * Also, manufacturers of AIS transmitters must program the MMSI, station name and other metadata on behalf of - * their customers prior to shipping to a US address, as users are prohibited from altering those. - * - * Of course, regulations were written at a time when none would design and build their own AIS equipment in - * an open-source fashion, so they are (as usual) at least a decade behind the technology curve. - */ - -//#define STATION_MMSI 987654321 -//#define STATION_NAME "TEST STATION 01" -//#define STATION_CALLSIGN "N0NNNN" - - #endif /* GLOBALS_H_ */