Example for using the MAX1472 RF Transmitter for low power data transmission.

Dependencies:   mbed-dev2 max32630fthr USBDevice

Committer:
tlyp
Date:
Fri Sep 04 20:41:34 2020 +0000
Revision:
4:2e3db197b7e2
Parent:
2:33b3b46a9c0d
Cleaned up header

Who changed what in which revision?

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