This is a low power example of the MAX1473 RF Receiver using the MAX32630FTHR.

Dependencies:   MAX30208 mbed-dev max32630fthr USBDevice

Committer:
tlyp
Date:
Fri Sep 04 20:45:01 2020 +0000
Revision:
4:7320d2a40b92
Parent:
2:e4fcc385e824
Added Comments for clearer execution

Who changed what in which revision?

UserRevisionLine numberNew contents of line
tlyp 2:e4fcc385e824 1 /*******************************************************************************
tlyp 2:e4fcc385e824 2 * Copyright (C) Maxim Integrated Products, Inc., All Rights Reserved.
tlyp 2:e4fcc385e824 3 *
tlyp 2:e4fcc385e824 4 * Permission is hereby granted, free of charge, to any person obtaining a
tlyp 2:e4fcc385e824 5 * copy of this software and associated documentation files (the "Software"),
tlyp 2:e4fcc385e824 6 * to deal in the Software without restriction, including without limitation
tlyp 2:e4fcc385e824 7 * the rights to use, copy, modify, merge, publish, distribute, sublicense,
tlyp 2:e4fcc385e824 8 * and/or sell copies of the Software, and to permit persons to whom the
tlyp 2:e4fcc385e824 9 * Software is furnished to do so, subject to the following conditions:
tlyp 2:e4fcc385e824 10 *
tlyp 2:e4fcc385e824 11 * The above copyright notice and this permission notice shall be included
tlyp 2:e4fcc385e824 12 * in all copies or substantial portions of the Software.
tlyp 2:e4fcc385e824 13 *
tlyp 2:e4fcc385e824 14 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
tlyp 2:e4fcc385e824 15 * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
tlyp 2:e4fcc385e824 16 * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
tlyp 2:e4fcc385e824 17 * IN NO EVENT SHALL MAXIM INTEGRATED BE LIABLE FOR ANY CLAIM, DAMAGES
tlyp 2:e4fcc385e824 18 * OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
tlyp 2:e4fcc385e824 19 * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
tlyp 2:e4fcc385e824 20 * OTHER DEALINGS IN THE SOFTWARE.
tlyp 2:e4fcc385e824 21 *
tlyp 2:e4fcc385e824 22 * Except as contained in this notice, the name of Maxim Integrated
tlyp 2:e4fcc385e824 23 * Products, Inc. shall not be used except as stated in the Maxim Integrated
tlyp 2:e4fcc385e824 24 * Products, Inc. Branding Policy.
tlyp 2:e4fcc385e824 25 *
tlyp 2:e4fcc385e824 26 * The mere transfer of this software does not imply any licenses
tlyp 2:e4fcc385e824 27 * of trade secrets, proprietary technology, copyrights, patents,
tlyp 2:e4fcc385e824 28 * trademarks, maskwork rights, or any other form of intellectual
tlyp 2:e4fcc385e824 29 * property whatsoever. Maxim Integrated Products, Inc. retains all
tlyp 2:e4fcc385e824 30 * ownership rights.
tlyp 2:e4fcc385e824 31 *******************************************************************************
tlyp 2:e4fcc385e824 32 */
tlyp 2:e4fcc385e824 33
tlyp 2:e4fcc385e824 34 /**
tlyp 2:e4fcc385e824 35 * @brief Library for the MAX30208\n
tlyp 2:e4fcc385e824 36 *
tlyp 2:e4fcc385e824 37 * @code
tlyp 2:e4fcc385e824 38 * #include "mbed.h"
tlyp 2:e4fcc385e824 39 * #include "max32630fthr.h"
tlyp 2:e4fcc385e824 40 * #include "ForwardErrCorr.h"
tlyp 2:e4fcc385e824 41 *
tlyp 2:e4fcc385e824 42 * MAX32630FTHR pegasus(MAX32630FTHR::VIO_3V3);
tlyp 2:e4fcc385e824 43 *
tlyp 2:e4fcc385e824 44 * #define SymmetricKey "PaSsWoRd"
tlyp 2:e4fcc385e824 45 * char TransTable[] = {0x1F,0x18,0x06,0x01};
tlyp 2:e4fcc385e824 46 *
tlyp 2:e4fcc385e824 47 * //Create translator instance
tlyp 2:e4fcc385e824 48 * Translator transTx(SymmetricKey, TransTable); //Constructor takes 7-bit slave adrs
tlyp 2:e4fcc385e824 49 *
tlyp 2:e4fcc385e824 50 * int main(void)
tlyp 2:e4fcc385e824 51 * {
tlyp 2:e4fcc385e824 52 * //use Encoder
tlyp 2:e4fcc385e824 53 * }
tlyp 2:e4fcc385e824 54 * @endcode
tlyp 2:e4fcc385e824 55 */
tlyp 2:e4fcc385e824 56
tlyp 2:e4fcc385e824 57 #ifndef __FORWARDERRCORR_H_
tlyp 2:e4fcc385e824 58 #define __FORWARDERRCORR_H_
tlyp 2:e4fcc385e824 59
tlyp 2:e4fcc385e824 60 #include "mbed.h"
tlyp 2:e4fcc385e824 61
tlyp 2:e4fcc385e824 62 class Translator{
tlyp 2:e4fcc385e824 63
tlyp 2:e4fcc385e824 64 public:
tlyp 2:e4fcc385e824 65
tlyp 2:e4fcc385e824 66 /**
tlyp 2:e4fcc385e824 67 * @brief Constructor using reference to Symmetric key for encryption and FEC translation table
tlyp 2:e4fcc385e824 68 * @param SymmetricKey - Symmetric Key used by tranmsitter and reciever to encrypt/decrypt transmitted messages
tlyp 2:e4fcc385e824 69 * @param TransTable - Translation table used for Forward Error Correction code
tlyp 2:e4fcc385e824 70 */
tlyp 2:e4fcc385e824 71 Translator(char *SymmetricKey, char *TransTable);
tlyp 2:e4fcc385e824 72
tlyp 2:e4fcc385e824 73 /**
tlyp 2:e4fcc385e824 74 * @brief De-constructor
tlyp 2:e4fcc385e824 75 */
tlyp 2:e4fcc385e824 76 ~Translator(void);
tlyp 2:e4fcc385e824 77
tlyp 2:e4fcc385e824 78 /**
tlyp 2:e4fcc385e824 79 * @brief Takes 2 byte data packet, converts to FEC 8 byte packet, and encrypts each byte
tlyp 2:e4fcc385e824 80 * @param tempData[IN] - 2 byte data that needs to be prepared for transmission
tlyp 2:e4fcc385e824 81 * @param EncryptedData[OUT] - Pointer to array where encrypted data will be stored, ready to send
tlyp 2:e4fcc385e824 82 * @return 0 on success, 1 on failure
tlyp 2:e4fcc385e824 83 */
tlyp 2:e4fcc385e824 84 uint32_t Encrypt(uint16_t tempData,char *EncryptedData);
tlyp 2:e4fcc385e824 85
tlyp 2:e4fcc385e824 86 /**
tlyp 2:e4fcc385e824 87 * @brief Takes 1 byte data packet, converts to FEC 8 byte packet, and encrypts each byte
tlyp 2:e4fcc385e824 88 * @param tempData[IN] - 2 byte data that needs to be prepared for transmission
tlyp 2:e4fcc385e824 89 * @param EncryptedData[OUT] - Pointer to array where encrypted data will be stroed, ready to send
tlyp 2:e4fcc385e824 90 * @return 0 on success, 1 on failure
tlyp 2:e4fcc385e824 91 */
tlyp 2:e4fcc385e824 92 uint32_t Encrypt(char tempData, char*EncryptedData);
tlyp 2:e4fcc385e824 93
tlyp 2:e4fcc385e824 94 /**
tlyp 2:e4fcc385e824 95 * @brief Calculates the hamming disatnce between 2 bytes
tlyp 2:e4fcc385e824 96 * @param ChkVal[IN] - Byte to use in hamming distance check
tlyp 2:e4fcc385e824 97 * @param TableVal[IN] - Byte to use in hamming distance check
tlyp 2:e4fcc385e824 98 * @return Hamming distance between the two provided bytes (range of 0-8)
tlyp 2:e4fcc385e824 99 */
tlyp 2:e4fcc385e824 100 int HamDist(char ChkVal, char TableVal);
tlyp 2:e4fcc385e824 101
tlyp 2:e4fcc385e824 102 /**
tlyp 2:e4fcc385e824 103 * @brief Converts 1 byte of FEC code back to original 2 bit data
tlyp 2:e4fcc385e824 104 * @param ChkVal - 1 byte of encoded data that needs to be decoded
tlyp 2:e4fcc385e824 105 * @return 0,1,2,3 to indicate correctly decoded table index, 4 on transmission error
tlyp 2:e4fcc385e824 106 */
tlyp 2:e4fcc385e824 107 int ChkHam(char ChkVal);
tlyp 2:e4fcc385e824 108
tlyp 2:e4fcc385e824 109 /**
tlyp 2:e4fcc385e824 110 * @brief Function that takes encrypted FEC data and converts it back to 2 byte data
tlyp 2:e4fcc385e824 111 * @param[IN] EncryptedData - Array of the encrypted data
tlyp 2:e4fcc385e824 112 * @param[OUT] Output - 16 bit data returned after decryption
tlyp 2:e4fcc385e824 113 * @return 0 on sucess, 1 on failure
tlyp 2:e4fcc385e824 114 */
tlyp 2:e4fcc385e824 115 uint32_t Decrypt(char *EncryptedData, uint16_t *Output);
tlyp 2:e4fcc385e824 116
tlyp 2:e4fcc385e824 117 private:
tlyp 2:e4fcc385e824 118
tlyp 2:e4fcc385e824 119 char *m_TransTable, *m_SymmetricKey;
tlyp 2:e4fcc385e824 120 };
tlyp 2:e4fcc385e824 121
tlyp 2:e4fcc385e824 122 #endif /* __ForwardErrCorr_H_*/