Wilson Tang
/
HSP_RPC_GUI
Fork of the offical HSP_RPC_GUI firmware
Fork of MAXREFDES100 firmware for MAX32620HSP
HSP/Devices/MAX14720/MAX14720_RPC.cpp@4:18155622d30a, 2020-01-28 (annotated)
- Committer:
- wt8008
- Date:
- Tue Jan 28 20:22:16 2020 +0000
- Revision:
- 4:18155622d30a
- Parent:
- 1:9490836294ea
Update Maxim's USBDevice project to the latest version
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
jbradshaw | 0:e4a10ed6eb92 | 1 | /******************************************************************************* |
jbradshaw | 0:e4a10ed6eb92 | 2 | * Copyright (C) 2016 Maxim Integrated Products, Inc., All Rights Reserved. |
jbradshaw | 0:e4a10ed6eb92 | 3 | * |
jbradshaw | 0:e4a10ed6eb92 | 4 | * Permission is hereby granted, free of charge, to any person obtaining a |
jbradshaw | 0:e4a10ed6eb92 | 5 | * copy of this software and associated documentation files (the "Software"), |
jbradshaw | 0:e4a10ed6eb92 | 6 | * to deal in the Software without restriction, including without limitation |
jbradshaw | 0:e4a10ed6eb92 | 7 | * the rights to use, copy, modify, merge, publish, distribute, sublicense, |
jbradshaw | 0:e4a10ed6eb92 | 8 | * and/or sell copies of the Software, and to permit persons to whom the |
jbradshaw | 0:e4a10ed6eb92 | 9 | * Software is furnished to do so, subject to the following conditions: |
jbradshaw | 0:e4a10ed6eb92 | 10 | * |
jbradshaw | 0:e4a10ed6eb92 | 11 | * The above copyright notice and this permission notice shall be included |
jbradshaw | 0:e4a10ed6eb92 | 12 | * in all copies or substantial portions of the Software. |
jbradshaw | 0:e4a10ed6eb92 | 13 | * |
jbradshaw | 0:e4a10ed6eb92 | 14 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS |
jbradshaw | 0:e4a10ed6eb92 | 15 | * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF |
jbradshaw | 0:e4a10ed6eb92 | 16 | * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. |
jbradshaw | 0:e4a10ed6eb92 | 17 | * IN NO EVENT SHALL MAXIM INTEGRATED BE LIABLE FOR ANY CLAIM, DAMAGES |
jbradshaw | 0:e4a10ed6eb92 | 18 | * OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, |
jbradshaw | 0:e4a10ed6eb92 | 19 | * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR |
jbradshaw | 0:e4a10ed6eb92 | 20 | * OTHER DEALINGS IN THE SOFTWARE. |
jbradshaw | 0:e4a10ed6eb92 | 21 | * |
jbradshaw | 0:e4a10ed6eb92 | 22 | * Except as contained in this notice, the name of Maxim Integrated |
jbradshaw | 0:e4a10ed6eb92 | 23 | * Products, Inc. shall not be used except as stated in the Maxim Integrated |
jbradshaw | 0:e4a10ed6eb92 | 24 | * Products, Inc. Branding Policy. |
jbradshaw | 0:e4a10ed6eb92 | 25 | * |
jbradshaw | 0:e4a10ed6eb92 | 26 | * The mere transfer of this software does not imply any licenses |
jbradshaw | 0:e4a10ed6eb92 | 27 | * of trade secrets, proprietary technology, copyrights, patents, |
jbradshaw | 0:e4a10ed6eb92 | 28 | * trademarks, maskwork rights, or any other form of intellectual |
jbradshaw | 0:e4a10ed6eb92 | 29 | * property whatsoever. Maxim Integrated Products, Inc. retains all |
jbradshaw | 0:e4a10ed6eb92 | 30 | * ownership rights. |
jbradshaw | 0:e4a10ed6eb92 | 31 | ******************************************************************************* |
jbradshaw | 0:e4a10ed6eb92 | 32 | */ |
jbradshaw | 0:e4a10ed6eb92 | 33 | |
jbradshaw | 0:e4a10ed6eb92 | 34 | #include "MAX14720_RPC.h" |
jbradshaw | 0:e4a10ed6eb92 | 35 | #include "MAX14720.h" |
jbradshaw | 0:e4a10ed6eb92 | 36 | #include "StringHelper.h" |
jbradshaw | 0:e4a10ed6eb92 | 37 | #include "Peripherals.h" |
jbradshaw | 0:e4a10ed6eb92 | 38 | #include "Device_Logging.h" |
jbradshaw | 0:e4a10ed6eb92 | 39 | |
jbradshaw | 0:e4a10ed6eb92 | 40 | /** |
jbradshaw | 0:e4a10ed6eb92 | 41 | * @brief Read the identification of the s25fs512 using quad spi |
jbradshaw | 0:e4a10ed6eb92 | 42 | * @param argStrs incoming rpc argument strings |
jbradshaw | 0:e4a10ed6eb92 | 43 | * OUTPUT: |
jbradshaw | 0:e4a10ed6eb92 | 44 | * replyStrs: strings that get returned to the rpc caller |
jbradshaw | 0:e4a10ed6eb92 | 45 | * @return 0 if successful, -1 if error |
jbradshaw | 0:e4a10ed6eb92 | 46 | */ |
jbradshaw | 0:e4a10ed6eb92 | 47 | int MAX14720_ReadBoostVSet(char argStrs[32][32], char replyStrs[32][32]) { |
jbradshaw | 0:e4a10ed6eb92 | 48 | uint8_t args[1]; |
jbradshaw | 0:e4a10ed6eb92 | 49 | uint8_t reply[1]; |
jbradshaw | 0:e4a10ed6eb92 | 50 | //MAX14720::BoostVSet_Values value; |
jbradshaw | 0:e4a10ed6eb92 | 51 | |
jbradshaw | 0:e4a10ed6eb92 | 52 | ProcessArgs(argStrs, args, sizeof(args)); |
jbradshaw | 0:e4a10ed6eb92 | 53 | //Peripherals::max14720()->readBoostVSet(&value); |
jbradshaw | 0:e4a10ed6eb92 | 54 | //reply[0] = (char)value; |
jbradshaw | 0:e4a10ed6eb92 | 55 | FormatReply(reply, sizeof(reply), replyStrs); |
jbradshaw | 0:e4a10ed6eb92 | 56 | return 0; |
jbradshaw | 0:e4a10ed6eb92 | 57 | } |
jbradshaw | 0:e4a10ed6eb92 | 58 | |
jbradshaw | 0:e4a10ed6eb92 | 59 | /** |
jbradshaw | 0:e4a10ed6eb92 | 60 | * @brief Read the identification of the s25fs512 using quad spi |
jbradshaw | 0:e4a10ed6eb92 | 61 | * @param argStrs incoming rpc argument strings |
jbradshaw | 0:e4a10ed6eb92 | 62 | * OUTPUT: |
jbradshaw | 0:e4a10ed6eb92 | 63 | * replyStrs: strings that get returned to the rpc caller |
jbradshaw | 0:e4a10ed6eb92 | 64 | * @return 0 if successful, -1 if error |
jbradshaw | 0:e4a10ed6eb92 | 65 | */ |
jbradshaw | 0:e4a10ed6eb92 | 66 | int MAX14720_WriteBoostVSet(char argStrs[32][32], char replyStrs[32][32]) { |
jbradshaw | 0:e4a10ed6eb92 | 67 | uint8_t args[1]; |
jbradshaw | 0:e4a10ed6eb92 | 68 | uint8_t reply[1]; |
jbradshaw | 0:e4a10ed6eb92 | 69 | |
jbradshaw | 0:e4a10ed6eb92 | 70 | ProcessArgs(argStrs, args, sizeof(args)); |
jbradshaw | 0:e4a10ed6eb92 | 71 | // Peripherals::max14720()->boostEn(MAX14720::BoostEn_Disable); |
jbradshaw | 0:e4a10ed6eb92 | 72 | // Peripherals::max14720()->boostVSet((MAX14720::BoostVSet_Values)args[0]); |
jbradshaw | 0:e4a10ed6eb92 | 73 | // Peripherals::max14720()->boostEn(MAX14720::BoostEn_Enable); |
jbradshaw | 0:e4a10ed6eb92 | 74 | reply[0] = 0x80; |
jbradshaw | 0:e4a10ed6eb92 | 75 | FormatReply(reply, sizeof(reply), replyStrs); |
jbradshaw | 0:e4a10ed6eb92 | 76 | return 0; |
jbradshaw | 0:e4a10ed6eb92 | 77 | } |
jbradshaw | 0:e4a10ed6eb92 | 78 | |
jbradshaw | 0:e4a10ed6eb92 | 79 | /** |
jbradshaw | 0:e4a10ed6eb92 | 80 | * @brief Read the identification of the s25fs512 using quad spi |
jbradshaw | 0:e4a10ed6eb92 | 81 | * @param argStrs incoming rpc argument strings |
jbradshaw | 0:e4a10ed6eb92 | 82 | * OUTPUT: |
jbradshaw | 0:e4a10ed6eb92 | 83 | * replyStrs: strings that get returned to the rpc caller |
jbradshaw | 0:e4a10ed6eb92 | 84 | * @return 0 if successful, -1 if error |
jbradshaw | 0:e4a10ed6eb92 | 85 | */ |
jbradshaw | 0:e4a10ed6eb92 | 86 | int MAX14720_ReadReg(char argStrs[32][32], char replyStrs[32][32]) { |
jbradshaw | 0:e4a10ed6eb92 | 87 | uint8_t args[1]; |
jbradshaw | 0:e4a10ed6eb92 | 88 | uint8_t reply[1]; |
jbradshaw | 0:e4a10ed6eb92 | 89 | ProcessArgs(argStrs, args, sizeof(args)); |
jbradshaw | 0:e4a10ed6eb92 | 90 | // Peripherals::max14720()->readReg((MAX14720::MAX14720_REG_map_t)address,&value); |
jbradshaw | 1:9490836294ea | 91 | reply[0] = 0; |
jbradshaw | 0:e4a10ed6eb92 | 92 | FormatReply(reply, sizeof(reply), replyStrs); |
jbradshaw | 0:e4a10ed6eb92 | 93 | return 0; |
jbradshaw | 0:e4a10ed6eb92 | 94 | } |
jbradshaw | 0:e4a10ed6eb92 | 95 | |
jbradshaw | 0:e4a10ed6eb92 | 96 | /** |
jbradshaw | 0:e4a10ed6eb92 | 97 | * @brief Read the identification of the s25fs512 using quad spi |
jbradshaw | 0:e4a10ed6eb92 | 98 | * @param argStrs incoming rpc argument strings |
jbradshaw | 0:e4a10ed6eb92 | 99 | * OUTPUT: |
jbradshaw | 0:e4a10ed6eb92 | 100 | * replyStrs: strings that get returned to the rpc caller |
jbradshaw | 0:e4a10ed6eb92 | 101 | * @return 0 if successful, -1 if error |
jbradshaw | 0:e4a10ed6eb92 | 102 | */ |
jbradshaw | 0:e4a10ed6eb92 | 103 | int MAX14720_WriteReg(char argStrs[32][32], char replyStrs[32][32]) { |
jbradshaw | 0:e4a10ed6eb92 | 104 | uint8_t args[2]; |
jbradshaw | 0:e4a10ed6eb92 | 105 | uint8_t reply[1]; |
jbradshaw | 0:e4a10ed6eb92 | 106 | |
jbradshaw | 0:e4a10ed6eb92 | 107 | ProcessArgs(argStrs, args, sizeof(args)); |
jbradshaw | 0:e4a10ed6eb92 | 108 | reply[0] = 0x80; |
jbradshaw | 0:e4a10ed6eb92 | 109 | FormatReply(reply, sizeof(reply), replyStrs); |
jbradshaw | 0:e4a10ed6eb92 | 110 | return 0; |
jbradshaw | 0:e4a10ed6eb92 | 111 | } |