Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Dependencies: mbed SDFileSystemFilinfo AriSnProtocol NetServicesMin AriSnComm MODSERIAL PowerControlClkPatch DS1820OW
Revision 125:ce4045184366, committed 2019-06-05
- Comitter:
- uci1
- Date:
- Wed Jun 05 17:29:31 2019 +0000
- Parent:
- 124:4637a6546cad
- Commit message:
- Added SnRateListner proto-class, publishing this version of the code in order to enable exporting of most recent features.
Changed in this revision
--- a/SnConstants.h Wed Oct 17 20:14:53 2018 +0000
+++ b/SnConstants.h Wed Jun 05 17:29:31 2019 +0000
@@ -75,6 +75,7 @@
static const uint8_t kLTC2657Adrs[] = { 0x73u << 1 }; // slave address that every LTC2657 DAC chip will respond to
static const uint8_t kUpdateDacCmd = 0x3u; // LTC2657 DAC chip command bits that write to & update DAC value
static const uint8_t kMaxDacSetTries = 3u; // how many times to retry setting a dac in case no ACK is received from the DAC chip
+static const uint8_t kMaxRateReadTries = 3u; // how many times to retry reading a single-channel rate from FPGA if no ACK is receiv
#elif (CHIPBOARD==SST4CH512) || (CHIPBOARD==SST4CH512_1GHz)
static const uint8_t kNchans = kNchansFourAnt;
static const uint16_t kNsamps = kNsampsSst512;
@@ -85,6 +86,7 @@
static const uint8_t kLTC2657Adrs[] = { 0x73u << 1 }; // slave address that every LTC2657 DAC chip will respond to
static const uint8_t kUpdateDacCmd = 0x3u; // LTC2657 DAC chip command bits that write to & update DAC value
static const uint8_t kMaxDacSetTries = 3u; // how many times to retry setting a dac in case no ACK is received from the DAC chip
+static const uint8_t kMaxRateReadTries = 3u; // how many times to retry reading a single-channel rate from FPGA if no ACK is receiv
#elif (CHIPBOARD==SST8CH) || (CHIPBOARD==SST8CH_1GHz)
static const uint8_t kNchans = kNchansEightAnt;
static const uint16_t kNsamps = kNsampsSst;
@@ -95,6 +97,7 @@
static const uint8_t kLTC2657Adrs[] = { 0x41u << 1, 0x32u << 1 }; // Adr[0]=1000001 (flt-flt-flt), Adr[2]=0110010 (flt-gnd-flt)
static const uint8_t kUpdateDacCmd = 0x3u; // LTC2657 DAC chip command bits that write to & update DAC value
static const uint8_t kMaxDacSetTries = 3u; // how many times to retry setting a dac in case no ACK is received from the DAC chip
+static const uint8_t kMaxRateReadTries = 3u; // how many times to retry reading a single-channel rate from FPGA if no ACK is receiv
#endif
static const uint8_t kNcomms = 2u; // must match the number of comms enabled in SnPreCompOptions
static const uint16_t kNvoltsAve = 500u; // must be greater than ~10 (but value is not checked, so <2 will result in a divide by 0)
--- a/SnPreCompOptions.h Wed Oct 17 20:14:53 2018 +0000 +++ b/SnPreCompOptions.h Wed Jun 05 17:29:31 2019 +0000 @@ -22,7 +22,7 @@ // sorry for the double negative, but.. normally this is NOT DEFINED // uncommenting this will allow any values to be specified in a configuration // leaving it commented out is safer -//#define DISABLE_CONFIG_SAFETYNETS +#define DISABLE_CONFIG_SAFETYNETS // choose which communication peripherals will be used in the comms loop // for now, twitter is completely not working. @@ -59,15 +59,15 @@ // which chip/board combination to build this firmware for //#define CHIPBOARD ATWD4CH //#define CHIPBOARD SST4CH -//#define CHIPBOARD SST4CH_1GHz +#define CHIPBOARD SST4CH_1GHz //#define CHIPBOARD SST4CH512 // warning: 4*512 samples may fill up the 32kB of RAM. it may be necessary to comment out ENABLE_AFAR_COMM in order to free up RAM //#define CHIPBOARD SST4CH512_1GHz // warning: 4*512 samples may fill up the 32kB of RAM. it may be necessary to comment out ENABLE_AFAR_COMM in order to free up RAM //#define CHIPBOARD SST8CH // warning: 8*256 samples may fill up the 32kB of RAM. it may be necessary to comment out ENABLE_AFAR_COMM in order to free up RAM -#define CHIPBOARD SST8CH_1GHz // warning: 8*256 samples may fill up the 32kB of RAM. it may be necessary to comment out ENABLE_AFAR_COMM in order to free up RAM +//#define CHIPBOARD SST8CH_1GHz // warning: 8*256 samples may fill up the 32kB of RAM. it may be necessary to comment out ENABLE_AFAR_COMM in order to free up RAM // how many bits the DACs use -//#define DAC_BITS 12 // use for 4ch atwd/sst boards -#define DAC_BITS 16 // use for 8ch sst boards (2017-18) +#define DAC_BITS 12 // use for 4ch atwd/sst boards +//#define DAC_BITS 16 // use for 8ch sst boards (2017-18) // whether or not to use the flash memory on the mbed board, to call // the mbed provided function that gets the MAC address, etc. @@ -76,22 +76,22 @@ // forever and never return, resulting in a "brain dead" station. // therefore, this should almost certainly be disabled (commented out) // for stations installed in the ice. -//#define USE_INTERFACE_CHIP +#define USE_INTERFACE_CHIP // if defined, try to read the default config from the SD card // instead of the interface chip -#define LOAD_DEFAULT_CONFIG_FROM_SD +//#define LOAD_DEFAULT_CONFIG_FROM_SD // if defined, will start with both AFAR and SBD powered up during the // first comm win after boot up. otherwise, only SBD will be powered -//#define AFAR_ON_FIRST_COMM_HARDCONF +#define AFAR_ON_FIRST_COMM_HARDCONF // whether or not to try to load the default config (wherever it's // located -- SD card or interface_chip) immediately -- that is, before // even the first communication. Be careful! It's possible this can fail // and prevent any communications, possibly resulting in a "brain dead" // station? Safer to leave this commented out. -//#define LOAD_DEFAULT_CONFIG_IMMEDIATELY +#define LOAD_DEFAULT_CONFIG_IMMEDIATELY // whether or not to use the lookup tables to speed up the FFTs #define USE_DFFT_LUTS
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/SnRateListener.cpp Wed Jun 05 17:29:31 2019 +0000
@@ -0,0 +1,37 @@
+#include "SnRateListener.h"
+#include "SnBitUtils.h"
+
+float SnRateListener::getRate()
+{
+ char results[2];
+ //Pins 9 and 10 on the LPC1768 correspond to one of two i2c buses.
+ I2C linkToFpga(p9,p10); //declaring this locally?
+ for(uint8_t tries=0;(tries<kMaxRateReadTries)&&(getLastAck()==false);++tries)
+ {
+ I2C i2c(p9,p10);
+ setLastAck(!i2c.read(getMMFCAddress(),results,2)); //think about sizeof(uint8_t)*2 here
+ }
+ setMSBs(results[0]);
+ setLSBs(results[1]);
+ return 0.0; //add interpretation here tomorrow, June 5th, 2019 (JCH)
+}
+void SnRateListener::setMSBs(uint8_t a)
+{
+ rateMSBs = a;
+}
+void SnRateListener::setLSBs(uint8_t a)
+{
+ rateLSBs = a;
+}
+uint8_t SnRateListener::getMMFCAddress()
+{
+ return MMFC_address;
+}
+void SnRateListener::setLastAck(bool a)
+{
+ lastAcknowledge = a;
+}
+bool SnRateListener::getLastAck()
+{
+ return lastAcknowledge;
+}
\ No newline at end of file
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/SnRateListener.h Wed Jun 05 17:29:31 2019 +0000
@@ -0,0 +1,36 @@
+//Class created by J. C. Hanson
+//3 June 2019
+//Purpose: to obtain rate information directly from FPGA
+
+#ifndef SN_SnRateListener
+#define SN_SnRateListener
+
+#include "mbed.h"
+#include "SnConstants.h"
+
+class SnRateListener
+{
+ public:
+ SnRateListener() :
+ rateMSBs(0),
+ rateLSBs(0),
+ lastAcknowledge(false),
+ MMFC_address(0x47 << 1)
+ {};
+ float getRate(); //Single channel rate (4-in. OR), units: MHz
+ ~SnRateListener(){};
+ protected:
+ uint8_t rateMSBs;
+ uint8_t rateLSBs;
+ bool lastAcknowledge; //True means successfully reading from MMFC.
+ void setMSBs(uint8_t);
+ void setLSBs(uint8_t);
+ void setLastAck(bool);
+ bool getLastAck();
+ uint8_t getMMFCAddress();
+ private:
+ //i2c address are left-shifted by 1 bit in mbed os 2.
+ uint8_t MMFC_address;
+};
+
+#endif
\ No newline at end of file