LP Transmitter Wakeup

Dependencies:   max32630fthr USBDevice

Files at this revision

API Documentation at this revision

Comitter:
tlyp
Date:
Fri Sep 04 16:59:21 2020 +0000
Parent:
1:8834bc22c2e7
Child:
3:b0579a51fd46
Commit message:
initial commit

Changed in this revision

ForwardErrCorr.cpp Show annotated file Show diff for this revision Revisions of this file
ForwardErrCorr.h Show annotated file Show diff for this revision Revisions of this file
MAX30208.cpp Show annotated file Show diff for this revision Revisions of this file
MAX30208.h Show annotated file Show diff for this revision Revisions of this file
USBDevice.lib Show annotated file Show diff for this revision Revisions of this file
main.cpp Show annotated file Show diff for this revision Revisions of this file
mbed-dev.lib Show annotated file Show diff for this revision Revisions of this file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/ForwardErrCorr.cpp	Fri Sep 04 16:59:21 2020 +0000
@@ -0,0 +1,145 @@
+/*******************************************************************************
+* Copyright (C) Maxim Integrated Products, Inc., All Rights Reserved.
+*
+* Permission is hereby granted, free of charge, to any person obtaining a
+* copy of this software and associated documentation files (the "Software"),
+* to deal in the Software without restriction, including without limitation
+* the rights to use, copy, modify, merge, publish, distribute, sublicense,
+* and/or sell copies of the Software, and to permit persons to whom the
+* Software is furnished to do so, subject to the following conditions:
+*
+* The above copyright notice and this permission notice shall be included
+* in all copies or substantial portions of the Software.
+*
+* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+* OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
+* IN NO EVENT SHALL MAXIM INTEGRATED BE LIABLE FOR ANY CLAIM, DAMAGES
+* OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
+* ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
+* OTHER DEALINGS IN THE SOFTWARE.
+*
+* Except as contained in this notice, the name of Maxim Integrated
+* Products, Inc. shall not be used except as stated in the Maxim Integrated
+* Products, Inc. Branding Policy.
+*
+* The mere transfer of this software does not imply any licenses
+* of trade secrets, proprietary technology, copyrights, patents,
+* trademarks, maskwork rights, or any other form of intellectual
+* property whatsoever. Maxim Integrated Products, Inc. retains all
+* ownership rights.
+*******************************************************************************
+*/
+
+#include "ForwardErrCorr.h"
+
+Translator::Translator(char *SymmetricKey, char *TransTable): 
+m_SymmetricKey(SymmetricKey),m_TransTable(TransTable)
+{
+}
+
+//******************************************************************************
+Translator::~Translator(void){
+}
+
+//******************************************************************************
+uint32_t Translator::Decrypt(char *tes, uint16_t *Output){
+    int8_t ValOut,ValIn;
+    int key = 0;
+    Output[0] = 0;
+    printf("Recieved Data -> Decrypted Data:\r\n");
+    for(int i = 2;i<10;i++){
+        ValIn = tes[i];
+        ValIn = ValIn ^ m_SymmetricKey[key];      //Unencrypt data
+        printf("%c -> %i\r\n",ValIn,tes[i]);
+        key++;
+        ValOut = 5;
+        for (int j=0;j<4;j++){
+            if (ValIn == m_TransTable[j]){
+                ValOut = j;
+            }
+        }
+        if (ValOut == 5){
+            ValOut = ChkHam(ValIn);    
+        }
+        if (ValOut == 4){
+            printf("Transmission error -- Hamming Distance Collision\r\n");
+            return (1);
+        }
+        Output[0] = (Output[0] << 2) + ValOut;
+        printf("Output: %d\r\n",Output[0]);
+    }
+    return(0);
+}
+
+//******************************************************************************
+int Translator::ChkHam(char ChkVal){
+    char trial = ChkVal & 0x1F;
+    bool dupe = 0; 
+    int index, temp;
+    int min = 5;
+    for (int k = 0; k<4;k++){
+        temp = HamDist(trial,m_TransTable[k]);
+        if (temp == 1){
+            return (k);
+        }
+        else if (temp < min){
+            min = temp;
+            index = k;
+            dupe = 0;
+        }
+        else if (temp == min){
+            dupe = 1;
+        }
+    }
+    if (dupe == 1){
+        return(4);
+    }
+    else{
+        return (index);
+    }
+}
+
+//******************************************************************************
+int Translator::HamDist(char ChkVal, char TableVal){
+    int count=0;
+    char tes1,tes2;
+    for (int j =0;j<5;j++){
+        tes1 = ChkVal >> j;
+        tes2 = TableVal >> j;
+        char temp = tes1 ^ tes2;
+        count += temp&1;
+    }
+    return (count);
+}
+
+//******************************************************************************
+uint32_t Translator::Encrypt(uint16_t tempData,char *EncryptedData){
+    char data;
+    int z=0;
+    printf("FEC Encoded Data:\r\n");
+    for (int i=14;i>=0;i-=2){
+        data = ((tempData >> i)&0x03);
+        data = m_TransTable[data];
+        printf("%d  ",data);
+        data = (data ^ m_SymmetricKey[z]);
+        EncryptedData[z]=data;
+        z++;
+    }
+    printf("\r\n");
+    return(0);
+}
+
+//******************************************************************************
+uint32_t Translator::Encrypt(char tempData, char *EncryptedData){
+    char data;
+    int z =0;
+    for (int i=6;i>=0;i-=2){
+        data = ((tempData >> i)&0x03);
+        data = m_TransTable[data];
+        data = (data ^ m_SymmetricKey[z]);
+        EncryptedData[z] = data;
+        z++;
+    }
+    return(0);
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/ForwardErrCorr.h	Fri Sep 04 16:59:21 2020 +0000
@@ -0,0 +1,122 @@
+/*******************************************************************************
+* Copyright (C) Maxim Integrated Products, Inc., All Rights Reserved.
+*
+* Permission is hereby granted, free of charge, to any person obtaining a
+* copy of this software and associated documentation files (the "Software"),
+* to deal in the Software without restriction, including without limitation
+* the rights to use, copy, modify, merge, publish, distribute, sublicense,
+* and/or sell copies of the Software, and to permit persons to whom the
+* Software is furnished to do so, subject to the following conditions:
+*
+* The above copyright notice and this permission notice shall be included
+* in all copies or substantial portions of the Software.
+*
+* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+* OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
+* IN NO EVENT SHALL MAXIM INTEGRATED BE LIABLE FOR ANY CLAIM, DAMAGES
+* OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
+* ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
+* OTHER DEALINGS IN THE SOFTWARE.
+*
+* Except as contained in this notice, the name of Maxim Integrated
+* Products, Inc. shall not be used except as stated in the Maxim Integrated
+* Products, Inc. Branding Policy.
+*
+* The mere transfer of this software does not imply any licenses
+* of trade secrets, proprietary technology, copyrights, patents,
+* trademarks, maskwork rights, or any other form of intellectual
+* property whatsoever. Maxim Integrated Products, Inc. retains all
+* ownership rights.
+*******************************************************************************
+*/
+
+/**
+ * @brief Library for the MAX30208\n
+ *
+ * @code
+ * #include "mbed.h"
+ * #include "max32630fthr.h"
+ * #include "ForwardErrCorr.h"
+ * 
+ * MAX32630FTHR pegasus(MAX32630FTHR::VIO_3V3);
+ *
+ * #define SymmetricKey "PaSsWoRd"
+ * char  TransTable[] = {0x1F,0x18,0x06,0x01};
+ *
+ * //Create translator instance
+ * Translator transTx(SymmetricKey, TransTable); //Constructor takes 7-bit slave adrs
+ *
+ * int main(void) 
+ * {
+ *     //use Encoder
+ * }
+ * @endcode
+ */
+
+#ifndef __FORWARDERRCORR_H_
+#define __FORWARDERRCORR_H_
+
+#include "mbed.h"
+
+class Translator{
+    
+public:
+
+    /**
+    * @brief  Constructor using reference to Symmetric key for encryption and FEC translation table
+    * @param SymmetricKey - Symmetric Key used by tranmsitter and reciever to encrypt/decrypt transmitted messages
+    * @param TransTable - Translation table used for Forward Error Correction code
+    */
+    Translator(char *SymmetricKey, char *TransTable);
+
+    /**
+    * @brief  De-constructor
+    */
+    ~Translator(void);
+
+    /**
+    * @brief  Takes 2 byte data packet, converts to FEC 8 byte packet, and encrypts each byte
+    * @param tempData[IN] - 2 byte data that needs to be prepared for transmission
+    * @param EncryptedData[OUT] - Pointer to array where encrypted data will be stored, ready to send
+    * @return 0 on success, 1 on failure
+    */
+    uint32_t Encrypt(uint16_t tempData,char *EncryptedData);
+    
+    /**
+    * @brief  Takes 1 byte data packet, converts to FEC 8 byte packet, and encrypts each byte
+    * @param tempData[IN] - 2 byte data that needs to be prepared for transmission
+    * @param EncryptedData[OUT] - Pointer to array where encrypted data will be stroed, ready to send
+    * @return 0 on success, 1 on failure
+    */
+    uint32_t Encrypt(char tempData, char*EncryptedData);
+
+    /**
+    * @brief  Calculates the hamming disatnce between 2 bytes
+    * @param ChkVal[IN] -   Byte to use in hamming distance check
+    * @param TableVal[IN] - Byte to use in hamming distance check
+    * @return Hamming distance between the two provided bytes (range of 0-8)
+    */
+    int HamDist(char ChkVal, char TableVal);
+
+    /**
+    * @brief  Converts 1 byte of FEC code back to original 2 bit data
+    * @param ChkVal - 1 byte of encoded data that needs to be decoded
+    * @return 0,1,2,3 to indicate correctly decoded table index, 4 on transmission error
+    */
+    int ChkHam(char ChkVal);
+
+    /**
+    * @brief Function that takes encrypted FEC data and converts it back to 2 byte data
+    * @param[IN] EncryptedData - Array of the encrypted data
+    * @param[OUT] Output - 16 bit data returned after decryption
+    * @return   0 on sucess, 1 on failure
+    */
+    uint32_t Decrypt(char *EncryptedData, uint16_t *Output);
+    
+private:
+    
+    char *m_TransTable, *m_SymmetricKey;
+};
+
+#endif /* __ForwardErrCorr_H_*/
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/MAX30208.cpp	Fri Sep 04 16:59:21 2020 +0000
@@ -0,0 +1,239 @@
+/*******************************************************************************
+* Copyright (C) Maxim Integrated Products, Inc., All Rights Reserved.
+*
+* Permission is hereby granted, free of charge, to any person obtaining a
+* copy of this software and associated documentation files (the "Software"),
+* to deal in the Software without restriction, including without limitation
+* the rights to use, copy, modify, merge, publish, distribute, sublicense,
+* and/or sell copies of the Software, and to permit persons to whom the
+* Software is furnished to do so, subject to the following conditions:
+*
+* The above copyright notice and this permission notice shall be included
+* in all copies or substantial portions of the Software.
+*
+* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+* OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
+* IN NO EVENT SHALL MAXIM INTEGRATED BE LIABLE FOR ANY CLAIM, DAMAGES
+* OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
+* ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
+* OTHER DEALINGS IN THE SOFTWARE.
+*
+* Except as contained in this notice, the name of Maxim Integrated
+* Products, Inc. shall not be used except as stated in the Maxim Integrated
+* Products, Inc. Branding Policy.
+*
+* The mere transfer of this software does not imply any licenses
+* of trade secrets, proprietary technology, copyrights, patents,
+* trademarks, maskwork rights, or any other form of intellectual
+* property whatsoever. Maxim Integrated Products, Inc. retains all
+* ownership rights.
+*******************************************************************************
+* @file          MAX30208.cpp
+* @brief         This is the C++ file used for the MAX30208 human body temperature sensor library.
+* @version       1.0
+* @notes         This file needs to be imported along with MAX30208.h for the program to work properly. This is library containing basic functions to be used in conjunction with the MAX30208. This library does not support any other devices. This is an MBed tested library. 
+*****************************************************************************/
+ 
+ 
+#include "MAX30208.h"
+
+
+//******************************************************************************
+MAX30208::MAX30208(I2C &i2c, uint8_t slaveAddress): 
+m_i2c(i2c), m_writeAddress(slaveAddress << 1), 
+m_readAddress((slaveAddress << 1) | 1)
+{
+}
+
+
+//******************************************************************************
+MAX30208::~MAX30208(void) {
+  //empty block
+}
+
+//******************************************************************************
+    int32_t MAX30208::writeInterruptRegister(Configuration_InterruptEnable config) {
+        return(writeRegister(MAX30208::Interrupt_Enable,(config.all << 8),2));
+    }
+    
+//******************************************************************************
+    int32_t MAX30208::readInterruptRegister(Configuration_InterruptEnable &config) {
+        uint16_t data;
+        int32_t status;
+        status = readRegister(MAX30208::Interrupt_Enable, data, 1);
+        if(status == 0) {
+            config.all = data;
+        }
+        return(status);
+    }
+
+//****************************************************************************** 
+    int32_t MAX30208::readStatus(uint16_t &value) {
+        return(readRegister(MAX30208::Status,value, 1));
+    }
+    
+//******************************************************************************
+    int32_t MAX30208::readWritePointer(uint16_t &value) {
+        return (readRegister(MAX30208::FIFO_Write_Pointer,value, 1));
+    }
+    
+//******************************************************************************
+    int32_t MAX30208::readReadPointer(uint16_t &value) {
+        return (readRegister(MAX30208::FIFO_Read_Pointer,value,1));
+    }
+    
+//******************************************************************************
+    int32_t MAX30208::writeReadPointer(uint8_t config) {
+        return(writeRegister(MAX30208::FIFO_Read_Pointer, (config << 8),2));
+    }
+    
+//******************************************************************************
+    int32_t MAX30208::readOverflow(uint16_t &value) {
+        return(readRegister(MAX30208::FIFO_Overflow_Counter,value, 1));
+    }
+    
+//******************************************************************************
+    int32_t MAX30208::readDataCounter(uint16_t &value) {
+        return(readRegister(MAX30208::FIFO_Data_Counter,value, 1));  
+    }
+    
+//******************************************************************************
+   int32_t MAX30208::readData(uint16_t &value) {
+        return(readRegister(MAX30208::FIFO_Data,value, 2));
+    }
+    
+//******************************************************************************
+   int32_t MAX30208::takeDataMeasurment() {
+        return(writeRegister(MAX30208::Temp_Sensor_Setup,0xFF00,2));
+    }
+    
+//******************************************************************************
+    int32_t MAX30208::readFIFOConfig1(uint16_t &value) {
+        return (readRegister(MAX30208::FIFO_Config1,value, 1));
+    }
+    
+//******************************************************************************
+    int32_t MAX30208::writeFIFOConfig1(uint8_t config) { 
+        return(writeRegister(MAX30208::FIFO_Config1,(config << 8),2));
+    }
+    
+//******************************************************************************
+    int32_t MAX30208::readFIFOConfig2(Configuration_FIFOConfig2 &config) {
+        uint16_t data;
+        int32_t status;
+        status = readRegister(MAX30208::FIFO_Config2, data, 1);
+        if(status == 0){
+            config.all = data;
+        }
+        return(status);
+    }
+    
+//******************************************************************************
+    int32_t MAX30208::writeFIFOConfig2(Configuration_FIFOConfig2 config) {
+        return(writeRegister(MAX30208::FIFO_Config2,(config.all << 8),2));
+    }
+    
+//******************************************************************************
+    int32_t MAX30208::resetDevice() {
+        return(writeRegister(MAX30208::System_Control,(0x01 << 8),2));
+    }
+
+//******************************************************************************
+   int32_t MAX30208::readAlarmHigh(uint16_t &temp) {
+        return readRegister(MAX30208::Alarm_High_MSB,temp, 2);
+    }
+       
+//******************************************************************************
+    int32_t MAX30208::writeAlarmHigh(uint16_t temp) {
+        return(writeRegister(MAX30208::Alarm_High_MSB, temp, 3));
+    }
+    
+//******************************************************************************
+    int32_t MAX30208::readAlarmLow(uint16_t &value) {
+        return (readRegister(MAX30208::Alarm_Low_MSB,value, 2));
+    }
+    
+//******************************************************************************
+   int32_t MAX30208::writeAlarmLow(uint16_t temp) {
+        return(writeRegister(MAX30208::Alarm_Low_MSB,temp,3));
+    }
+    
+//******************************************************************************
+    int32_t MAX30208::readGPIOSetup(Configuration_GPIOSetup &config) {
+        uint16_t data;
+        int32_t status;
+        status = readRegister(MAX30208::GPIO_Setup, data, 1);
+        if(status == 0) {
+            config.all = data;
+        }
+        return(status);
+    }
+
+//******************************************************************************
+    int32_t MAX30208::writeGPIOSetup(Configuration_GPIOSetup config) {
+        return(writeRegister(MAX30208::GPIO_Setup,(config.all << 8),2));
+    }
+    
+//******************************************************************************
+    int32_t MAX30208::readGPIOControl(Configuration_GPIOControl &config) {
+        uint16_t data;
+        int32_t status;
+        status = readRegister(MAX30208::GPIO_Control, data, 1);
+        if(status == 0) {
+            config.all = data;
+        }
+        return(status);
+    }
+
+//******************************************************************************
+    int32_t MAX30208::writeGPIOControl(Configuration_GPIOControl config) {
+        return(writeRegister(MAX30208::GPIO_Control,(config.all << 8),2));
+    }
+    
+//******************************************************************************
+    float MAX30208::toCelsius(uint16_t rawTemp) {
+        float celsius;
+        celsius = 0.005*rawTemp;
+        return celsius;    
+    }
+    
+//******************************************************************************
+    float MAX30208::toFahrenheit(float temperatureC) {
+         float temperatureF;
+         temperatureF = (temperatureC * 1.8F) + 32.0f;
+         return temperatureF;   
+    }
+    
+//******************************************************************************
+int32_t MAX30208::writeRegister(Registers_e reg, uint16_t value, int bytesWritten) {
+  
+  int32_t ret;
+  
+  uint8_t hi = ((value >> 8) & 0xFF);
+  uint8_t lo = (value & 0xFF);
+  char val[3] = {reg, hi, lo};
+  
+  ret = m_i2c.write(m_writeAddress, val, bytesWritten, false); 
+  return (ret);
+}
+
+//******************************************************************************
+int32_t MAX30208::readRegister(Registers_e reg, uint16_t &value, int bytesRead) {
+    
+    int32_t ret;
+    char cmdata[1] = {reg};
+    char dataRead[2];
+        
+    ret = m_i2c.write(m_readAddress,cmdata,1,true);
+    if (ret == 0) {
+        ret = m_i2c.read(m_readAddress,dataRead,bytesRead,false);
+        if(ret == 0 && bytesRead == 2){
+            value = ((dataRead[0]<<8)+ dataRead[1]);
+        }
+        else if (ret == 0 && bytesRead == 1){
+            value = dataRead[0];    
+        }
+    }
+    return(ret);
+}
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/MAX30208.h	Fri Sep 04 16:59:21 2020 +0000
@@ -0,0 +1,344 @@
+/*******************************************************************************
+* Copyright (C) Maxim Integrated Products, Inc., All Rights Reserved.
+*
+* Permission is hereby granted, free of charge, to any person obtaining a
+* copy of this software and associated documentation files (the "Software"),
+* to deal in the Software without restriction, including without limitation
+* the rights to use, copy, modify, merge, publish, distribute, sublicense,
+* and/or sell copies of the Software, and to permit persons to whom the
+* Software is furnished to do so, subject to the following conditions:
+*
+* The above copyright notice and this permission notice shall be included
+* in all copies or substantial portions of the Software.
+*
+* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+* OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
+* IN NO EVENT SHALL MAXIM INTEGRATED BE LIABLE FOR ANY CLAIM, DAMAGES
+* OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
+* ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
+* OTHER DEALINGS IN THE SOFTWARE.
+*
+* Except as contained in this notice, the name of Maxim Integrated
+* Products, Inc. shall not be used except as stated in the Maxim Integrated
+* Products, Inc. Branding Policy.
+*
+* The mere transfer of this software does not imply any licenses
+* of trade secrets, proprietary technology, copyrights, patents,
+* trademarks, maskwork rights, or any other form of intellectual
+* property whatsoever. Maxim Integrated Products, Inc. retains all
+* ownership rights.
+*******************************************************************************
+* @file          MAX30208.h
+* @brief         This is the header file used for the MAX30208 human body temperature sensor library.
+* @version       1.0
+* @notes         This file needs to be imported along with MAX30208.cpp for the program to work properly. This is library containing basic functions to be used in conjunction with the MAX30208. This library does not support any other devices. This is an MBed tested library. 
+*****************************************************************************/
+
+#ifndef __MAX30208_H_
+#define __MAX30208_H_
+
+#include "mbed.h"
+
+/**
+ * @brief Library for the MAX30208
+ *
+ * @code
+ * #include "mbed.h"
+ * #include "max32630fthr.h"
+ * #include "MAX30208.h"
+ * 
+ * MAX32630FTHR pegasus(MAX32630FTHR::VIO_3V3);
+ *
+ * //Get I2C instance
+ * I2C i2cBus(I2C1_SDA, I2C1_SCL);
+ *
+ * //Get temp sensor instance
+ * MAX30208 BodyTempSensor(i2cBus, 0x50); //Constructor takes 7-bit slave adress. 0x50 is default slave address for MAX30208 Ev-Kit
+ *
+ * int main(void) 
+ * {
+ *     //use sensor
+ * }
+ * @endcode
+ */
+
+class MAX30208
+{
+    
+public:
+    /// MAX30208 Register Addresses
+    enum Registers_e {
+        Status = 0x00,
+        Interrupt_Enable = 0x01,
+        FIFO_Write_Pointer = 0x04,
+        FIFO_Read_Pointer = 0x05,
+        FIFO_Overflow_Counter = 0x06,
+        FIFO_Data_Counter = 0x07,
+        FIFO_Data = 0x08,
+        FIFO_Config1 = 0x09,
+        FIFO_Config2 = 0x0A,
+        System_Control = 0x0C,
+        Alarm_High_MSB = 0x10,
+        Alarm_Low_MSB = 0x12,
+        Temp_Sensor_Setup = 0x14,
+        GPIO_Setup = 0x20,
+        GPIO_Control = 0x21
+    };
+    
+    //Intterupt Register Config
+    union Configuration_InterruptEnable{
+        uint8_t all;
+        struct BitField_s{
+            uint8_t TEMP_RDY_EN : 1;
+            uint8_t TEMP_HI_EN  : 1;
+            uint8_t TEMP_LO_EN  : 1;
+            uint8_t             : 4;    //unused bits
+            uint8_t A_FULL_EN   : 1;
+        }config;
+    };
+    
+    //FIFO Config 2 Register
+    union Configuration_FIFOConfig2{
+        uint8_t all;
+        struct BitField_s{
+            uint8_t               : 1;    //unused bit
+            uint8_t FIFO_RO       : 1;
+            uint8_t A_FULL_TYPE   : 1;
+            uint8_t FIFO_STAT_CLR : 1;
+            uint8_t FLUSH_FIFO    : 1;
+            uint8_t               : 0;    //unused bits
+        }config;
+    };
+    
+    //GPIO Setup Register
+    union Configuration_GPIOSetup{
+        uint8_t all;
+        struct BitField_s{
+            uint8_t GPIO0_MODE     : 2;
+            uint8_t                : 4;    //unused bits
+            uint8_t GPIO1_MODE     : 2;
+        }config;
+    };
+    
+    //GPIO Control Register
+    union Configuration_GPIOControl{
+        uint8_t all;
+        struct BitField_s{
+            uint8_t GPIO0_LL   : 1;
+            uint8_t            : 2;    //unused bits
+            uint8_t GPIO1_LL   : 1;
+            uint8_t            : 0;    //unused bits
+        }config;
+    };
+
+    /**
+    * @brief  Constructor using reference to I2C object
+    * @param i2c - Reference to I2C object
+    * @param slaveAddress - 7-bit I2C address
+    */
+    MAX30208(I2C &i2c, uint8_t slaveAddress);
+
+    /** @brief Destructor */
+    ~MAX30208(void);
+    
+    /**
+    * @brief  Write Interrupt Register
+    * @param config - Reference to Configuration type, config.all is written upon succesful register write
+    * @return 0 on success, non-zero on failure
+    */
+    int32_t writeInterruptRegister(Configuration_InterruptEnable config);    
+    
+    /**
+    * @brief  Read Interrupt Register Configuration
+    * @param config - Reference to Configuration type, config.all is updated upon succesful register read
+    * @return 0 on success, non-zero on failure
+    */
+    int32_t readInterruptRegister(Configuration_InterruptEnable &config);
+    
+    /**
+    * @brief  Read Status Register
+    * @param[out] value - Status Register Value on succesful read
+    * @return 0 on success, non-zero on failure
+    */
+    int32_t readStatus(uint16_t &value);
+    
+    /**
+    * @brief  Read FIFO Write Pointer Value
+    * @param[out] value - FIFO Write Pointer value on succesful read
+    * @return 0 on success, non-zero on failure
+    */
+    int32_t readWritePointer(uint16_t &value);
+    
+    /**
+    * @brief  Read FIFO Read Pointer Value
+    * @param[out] value - FIFO Read Pointer value on succesful read
+    * @return 0 on success, non-zero on failure
+    */
+    int32_t readReadPointer(uint16_t &value);
+    
+    /**
+    * @brief  Write FIFO Read Pointer Value
+    * @param config - New FIFO Read Pointer value on succesful write
+    * @return 0 on success, non-zero on failure
+    */
+    int32_t writeReadPointer(uint8_t config);
+    
+    /**
+    * @brief Read FIFO Overflow Register
+    * @param[out] value - Overflow Counter value on succesful read
+    * @return 0 on success, non-zero on failure
+    */
+    int32_t readOverflow(uint16_t &value);
+    
+    /**
+    * @brief Read Data Counter Register
+    * @param[out] value - Data Count register value on succesful read
+    * @return 0 on success, non-zero on failure
+    */
+    int32_t readDataCounter(uint16_t &value);
+    
+    /**
+    * @brief  Read FIFO Data at FIFO Read Pointer
+    * @param[out] value - Temperature value from FIFO data register on succesful read 
+    * @return 0 on success, non-zero on failure
+    */
+    int32_t readData(uint16_t &value);
+    
+    /**
+    * @brief Take a new temperature reading
+    * @return 0 on success, non-zero on failure
+    */
+    int32_t takeDataMeasurment();
+    
+    /**
+    * @brief  Read FIFO Config1 Register
+    * @param[out] value - FIFO Config1 value on succesful read 
+    * @return 0 on success, non-zero on failure
+    */
+    int32_t readFIFOConfig1(uint16_t &value);
+    
+    /**
+    * @brief Write FIFO Config1 register
+    * @param config - FIFO Config1 register data to write 
+    * @return 0 on success, non-zero on failure
+    */
+    int32_t writeFIFOConfig1(uint8_t config);
+    
+    /**
+    * @brief Read FIFO Config2 register
+    * @param[out] config - Reference to Configuration type, config.all is updated upon succesful register read
+    * @return 0 on success, non-zero on failure
+    */
+    int32_t readFIFOConfig2(Configuration_FIFOConfig2 &config);
+    
+    /**
+    * @brief Read FIFO Config2 register
+    * @param config - Reference to Configuration type, config.all is written upon succesful register write
+    * @return 0 on success, non-zero on failure
+    */
+    int32_t writeFIFOConfig2(Configuration_FIFOConfig2 config);
+    
+    /**
+    * @brief Reset Device to factory default
+    * @return 0 on success, non-zero on failure
+    */
+    int32_t resetDevice(); //set bit 0 in system register to 1 to factory reset
+
+    /**
+    * @brief Read High Temperature Alarm Value
+    * @param[out] temp - High Temperature Alarm Value
+    * @return 0 on success, non-zero on failure
+    */
+    int32_t readAlarmHigh(uint16_t &temp);
+    
+    /**
+    * @brief Write High Temperature Alarm Value
+    * @param temp - 16-bit High Temperature Value to Write
+    * @return 0 on success, non-zero on failure
+    */    
+    int32_t writeAlarmHigh(uint16_t temp);
+    
+    /**
+    * @brief Read Low Temperature Alarm Value
+    * @param[out] temp - Low Temperature Alarm Value
+    * @return 0 on success, non-zero on failure
+    */
+    int32_t readAlarmLow(uint16_t &value);
+    
+    /**
+    * @brief Write Low Temperature Alarm Value
+    * @param temp - 16-bit Low Temperature Value to Write
+    * @return 0 on success, non-zero on failure
+    */
+    int32_t writeAlarmLow(uint16_t temp);
+    
+    /**
+    * @brief Read GPIO Setup register
+    * @param config - Reference to Configuration type, config.all is updated upon succesful register read
+    * @return 0 on success, non-zero on failure
+    */
+    int32_t readGPIOSetup(Configuration_GPIOSetup &config);
+    
+    /**
+    * @brief Write GPIO Setup register
+    * @param config - Reference to Configuration type, config.all is written to register upon succesful register write
+    * @return 0 on success, non-zero on failure
+    */
+    int32_t writeGPIOSetup(Configuration_GPIOSetup config);
+    
+    /**
+    * @brief Read GPIO Control register
+    * @param config - Reference to Configuration type, config.all is updated upon succesful register read
+    * @return 0 on success, non-zero on failure
+    */
+    int32_t readGPIOControl(Configuration_GPIOControl &config);
+    
+    /**
+    * @brief Write GPIO Control register
+    * @param config - Reference to Configuration type, config.all is written to register upon succesful register write
+    * @return 0 on success, non-zero on failure
+    */
+    int32_t writeGPIOControl(Configuration_GPIOControl config);
+    
+    /**
+    * @brief Convert Raw Sensor Data to degrees Celisus
+    * @param rawTemp - 16 bit raw temperature data
+    * @return Returns the converted Celsius Temperature
+    */
+    float toCelsius(uint16_t rawTemp);
+    
+    /**
+    * @brief Convert Celsius Temperature to Fahrenheit
+    * @param temperatureC - Temperature in degrees Celsius that will be converted
+    * @return Returns the converted Fahrenheit temperature
+    */
+    float toFahrenheit(float temperatureC);
+    
+protected:
+
+    /** 
+    * @brief Write register of device at slave address
+    * @param reg - char array that contains address of register and write value
+    * @param value - Data written to register on sucessful write
+    * @param bytesWritten - Number of bytes to write
+    * @return 0 on success, non-zero on failure
+    */
+    int32_t writeRegister(Registers_e reg, uint16_t value, int bytesWritten);
+    /**
+    * @brief  Read register of device at slave address
+    * @param reg - Register address
+    * @param[out] value - Read data on successful read
+    * @param bytesRead - Number of bytes to read
+    * @return 0 on success, non-zero on failure
+    */
+    int32_t readRegister(Registers_e reg, uint16_t &value, int bytesRead);
+
+private:
+    /// I2C object
+    I2C & m_i2c;
+    /// Device slave addresses
+    uint8_t m_writeAddress, m_readAddress;
+};
+
+#endif /* __MAX30208_H_ */
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/USBDevice.lib	Fri Sep 04 16:59:21 2020 +0000
@@ -0,0 +1,1 @@
+https://developer.mbed.org/teams/MaximIntegrated/code/USBDevice/#17ac7abb27a7
--- a/main.cpp	Wed Jan 24 01:15:14 2018 +0000
+++ b/main.cpp	Fri Sep 04 16:59:21 2020 +0000
@@ -1,3 +1,61 @@
+/*******************************************************************************
+* Copyright (C) Maxim Integrated Products, Inc., All Rights Reserved.
+*
+* Permission is hereby granted, free of charge, to any person obtaining a
+* copy of this software and associated documentation files (the "Software"),
+* to deal in the Software without restriction, including without limitation
+* the rights to use, copy, modify, merge, publish, distribute, sublicense,
+* and/or sell copies of the Software, and to permit persons to whom the
+* Software is furnished to do so, subject to the following conditions:
+*
+* The above copyright notice and this permission notice shall be included
+* in all copies or substantial portions of the Software.
+*
+* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+* OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
+* IN NO EVENT SHALL MAXIM INTEGRATED BE LIABLE FOR ANY CLAIM, DAMAGES
+* OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
+* ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
+* OTHER DEALINGS IN THE SOFTWARE.
+*
+* Except as contained in this notice, the name of Maxim Integrated
+* Products, Inc. shall not be used except as stated in the Maxim Integrated
+* Products, Inc. Branding Policy.
+*
+* The mere transfer of this software does not imply any licenses
+* of trade secrets, proprietary technology, copyrights, patents,
+* trademarks, maskwork rights, or any other form of intellectual
+* property whatsoever. Maxim Integrated Products, Inc. retains all
+* ownership rights.
+*******************************************************************************
+
+This is code for the MAX1472 RF Transmitter EV-Kit. This program will record a 
+temperature fom the MAX30208 EV-Kit, encrypt the data using the user-generated
+Symmetric key, apply forward error correction (FEC) encoding, and then send the
+message via the MAX1472 transmitter. When the MAX1472 is not sending data, it will
+go into a power saving sleep mode.
+
+  Hardware Setup and connections:
+
+    MAX32630FTHR->  MAX1472 Ev-Kit
+    
+    3.3V        ->  VDD
+    GND         ->  VSS
+    P3_1        ->  Data_In
+    P5_1        ->  ENABLE
+    
+*******************************************************************************
+    MAX32630FTHR->  MAX30208 Ev-Kit
+    
+    1.8V        ->  VIN
+    GND         ->  GND
+    P3_4        ->  SDA
+    P3_5        ->  SCL
+    
+*******************************************************************************
+*/
+
 #include "mbed.h"
 #include "max32630fthr.h"
 #include "mxc_config.h"
@@ -5,65 +63,151 @@
 #include "gpio.h"
 #include "rtc.h"
 #include "MAX14690.h"
+#include "USBSerial.h"
+#include "MAX30208.h"
+#include "ForwardErrCorr.h"
+
+MAX32630FTHR pegasus(MAX32630FTHR::VIO_3V3);
+
+I2C i2c(P3_4, P3_5);  //sda,scl
+
+RawSerial uart(P3_1,P3_0);//tx,rx
+MAX30208 TempSensor(i2c, 0x50); //Constructor takes 7-bit slave adrs
+
+#define SymmetricKey "RfIsCoOl"   //Set Private Key here -- Make sure it is identical to receiver
+char  TransTable[] = {0x1F,0x18,0x06,0x01}; //Used to translate data for FEC -- Make sure it is identical to receiver
+Translator transTx(SymmetricKey, TransTable); //Initialize Encoder
+
+#define SendDelay   5   //Number of seconds between sending data
+char DEVICETYPE = 'T';  //'T' for Temperature Sensor
+char DEVICEID = 0x01;   //Set the Device ID
+
+USBSerial microUSB;         //microUSB connection that can be used for printing
 
 DigitalOut rLED(LED1);
 DigitalOut gLED(LED2);
 DigitalOut bLED(LED3);
 
-DigitalIn sw1(SW1);
+DigitalIn sw1(SW1);             //Used on start-up to stay in active mode for re-programming
+DigitalOut TXEnable(P5_1);      //Used to Enable Transmitter
 
 // *****************************************************************************
+/*
+* @brief  Configures the RTC to tick every second so it can be compared to during sleep intterupt
+*/
 void RTC_Setup()
 {
     rtc_cfg_t RTCconfig;
-    
-    RTCconfig.compareCount[0] = 1;//1 second timer
-    RTCconfig.compareCount[1] = 10;//10 second timer
-    RTCconfig.prescaler = RTC_PRESCALE_DIV_2_12; //1Hz clock
-    RTCconfig.prescalerMask = RTC_PRESCALE_DIV_2_12;//used for prescaler compare
+    RTCconfig.prescaler = RTC_PRESCALE_DIV_2_12; //Set tick frequency to 1 second
+    RTCconfig.prescalerMask = RTC_PRESCALE_DIV_2_12; //1 second frequency
     RTCconfig.snoozeCount = 0;
     RTCconfig.snoozeMode = RTC_SNOOZE_DISABLE;
-
     RTC_Init(&RTCconfig);
-
     RTC_Start();
 }
 
-/******************************************************************************/
+//****************************************************************************
+/**
+* @brief  Record and read temperature from MAX30208
+* @param TempSensor - Refrence to MAX30208 temp sensor object
+* @param &value[OUT]- Address to store read temperature at
+* @return   0 on success, 1 on failure due to improper data record or read 
+*/
+uint16_t ReadData(MAX30208 TempSensor, uint16_t &value){
+    if (TempSensor.takeDataMeasurment() != 0){
+        microUSB.printf("Error Taking data Meaurment\r\n");
+        return(1);
+    }
+    wait_ms(50);    //max temp read is 50ms
+    if (TempSensor.readData(value) !=0){
+        microUSB.printf("Error reading temperature Data\r\n");    
+        return(1);
+    }
+    return(0);
+}
+
+//*****************************************************************************
+/*
+* @brief  Begin Communication with warm up bytes and device type/id
+*/
+void comInit(){
+    uart.putc(0xFF);
+    uart.putc(0xFF);
+    uart.putc(0x00);
+    uart.putc('b');
+    uart.putc(DEVICETYPE);
+    uart.putc(DEVICEID);
+}
+
+//*****************************************************************************
+/**
+* @brief  Send data and end transmission
+* @param EncryptedData[IN]  - 8 bytes of encryted data to send via UART connection
+*/
+void comData(char *EncryptedData){
+    for(int i=0;i<8;i++){
+        uart.putc(EncryptedData[i]);    //Send all of the encrypted data
+    }
+    uart.putc('c'); //End of packet character
+    uart.send_break();
+}
+
+//*****************************************************************************
+
 int main(void)
 {
+    //initialize PMIC
     MAX32630FTHR pegasus(MAX32630FTHR::VIO_3V3);
+    uart.baud(9600);    //Set baud rate for 9600
     
     //check if starting at main because of LP0 wake-up
     if(LP_IsLP0WakeUp()) {
-        
+        //empty
     }
+    
     else {
         //We did not wake up from sleep and this is first power-on
         //Only configure RTC the first time around 
         RTC_Setup();
     }
-
+    
+    //Set LEDs on to show device is awake
     gLED = LED_ON;
     rLED = LED_ON;
     bLED = LED_ON;
-
+    
+    //Main loop
     while(1) {
-        
         //hold down switch 1 to prevent the microcontroller from going into LP0
         while(sw1 == 0);
         
-        //keep LED on long enough to see it!
-        wait_ms(100);
+        uint16_t tempData;
+        if(ReadData(TempSensor,tempData) !=0){
+                printf("Error reading data!\r\n");
+            }
+            
+            //Encrypt Temperature Data
+            char EncryptedData[8];
+            transTx.Encrypt(tempData,EncryptedData); 
+
+        TXEnable = 1;       //Turn on Transmitter
+        wait_us(450);       //Wake-up time for transmitter
         
-        gLED = LED_OFF;
-        rLED = LED_OFF;
-        bLED = LED_OFF;
-
-        //disable unused PMIC rails to minimize power consumption
-        pegasus.max14690.ldo2SetMode(MAX14690::LDO_DISABLED);
-        pegasus.max14690.ldo3SetMode(MAX14690::LDO_DISABLED);
-
+        //Start a timer for sending data
+        Timer timer;
+        timer.start();
+        
+        //Send the data for 1 sec
+        while(timer.read_ms() < 1000) {
+        
+        //Send Data continuously
+        comInit();
+        comData(EncryptedData);
+        }//while
+        
+        TXEnable = 0;   //Turn off Transmitter
+        timer.stop();   //Stop send timer
+        
         //Clear existing wake-up config
         LP_ClearWakeUpConfig();
 
@@ -71,18 +215,28 @@
         LP_ClearWakeUpFlags();
 
         //configure wake-up on RTC compare 0
-        //LP_ConfigRTCWakeUp(enable compare 0, enable compare 1, set prescale, set rollover)
+        //LP_ConfigRTCWakeUp(enable compare0, enable compare1, set prescale, set rollover)
         LP_ConfigRTCWakeUp(1, 0, 0, 0);
         
-        //read the current RTC timer and add 5 seconds to it
-        uint32_t cmp = RTC_GetCount() + 5;
+        //disable unused PMIC rails to minimize power consumption
+        pegasus.max14690.ldo2SetMode(MAX14690::LDO_DISABLED);
+        pegasus.max14690.ldo3SetMode(MAX14690::LDO_DISABLED);
         
-        //set RTC to generate an interrupt 5 seconds from current value
-        RTC_SetCompare(0,cmp);
+        //Turn off LEDs to show low power mode
+        gLED = LED_OFF;
+        rLED = LED_OFF;
+        bLED = LED_OFF;
+        
+        //Reset the RTC back to 0 ticks
+        RTC_SetCount(0);
+        
+        //set RTC to generate an interrupt every SendDelay seconds (User defined value at top of program)
+        RTC_SetCompare(0,SendDelay);      //(Compare index, Compare Value in ticks)
         
         //clear comparison flag in the RTC registers
         RTC_ClearFlags(MXC_F_RTC_FLAGS_COMP0);
 
+        //Enter Deep Sleep Mode
         LP_EnterLP0();
 
         //firmware will reset with no prior knowledge on wake-up
--- a/mbed-dev.lib	Wed Jan 24 01:15:14 2018 +0000
+++ b/mbed-dev.lib	Fri Sep 04 16:59:21 2020 +0000
@@ -1,1 +1,1 @@
-http://mbed.org/users/mbed_official/code/mbed-dev/#b0033dcd6934
+https://os.mbed.com/users/tlyp/code/mbed-dev2/#42198b2ed71b