Firmware enhancements for HSP_RPC_GUI 3.0.1
Fork of HSP_RPC_GUI by
This command can be used to import the project to your local environment
Quote:
mbed import http://mbed.org/users/jbradshaw/code/HSP_RPC_GUI_3_0_1/
This command can be used to compile the code and produce the HSP_RPC_GUI_3_0_1.bin
Quote:
mbed compile -t GCC_ARM -m MAX32620HSP
This link may be used to install the mbed command-line-interface (cli) if needed
HSP/Interfaces/I2C_RPC.cpp@3:8e9b9f5818aa, 2017-04-25 (annotated)
- Committer:
- jbradshaw
- Date:
- Tue Apr 25 10:47:10 2017 -0500
- Revision:
- 3:8e9b9f5818aa
- Parent:
- 1:9490836294ea
Removed Bulk Erasing, instead a small number of bytes are sampled from each and every page to determine if sector is "dirty", if so sector is erased
Prevents device from sleeping when the firmware detects a series of binary flash page RPC transfers, this increases flash page transfers by %450
when 200mS elapse with the last flash page transfer, normal sleep behaviour is resumed
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 | #include <stdint.h> |
jbradshaw | 0:e4a10ed6eb92 | 34 | #include "StringHelper.h" |
jbradshaw | 0:e4a10ed6eb92 | 35 | #include "I2C_RPC.h" |
jbradshaw | 0:e4a10ed6eb92 | 36 | #include "Peripherals.h" |
jbradshaw | 0:e4a10ed6eb92 | 37 | |
jbradshaw | 0:e4a10ed6eb92 | 38 | //****************************************************************************** |
jbradshaw | 0:e4a10ed6eb92 | 39 | // input |
jbradshaw | 0:e4a10ed6eb92 | 40 | // [instance] [slaveAddress] [writeNumber] [](data to write) [readNumber] |
jbradshaw | 0:e4a10ed6eb92 | 41 | // output data to read |
jbradshaw | 0:e4a10ed6eb92 | 42 | int I2C_WriteRead(char argStrs[32][32], char replyStrs[32][32]) { |
jbradshaw | 0:e4a10ed6eb92 | 43 | uint8_t args[16]; |
jbradshaw | 0:e4a10ed6eb92 | 44 | uint8_t reply[16]; |
jbradshaw | 0:e4a10ed6eb92 | 45 | uint8_t writeNumber; |
jbradshaw | 0:e4a10ed6eb92 | 46 | uint8_t readNumber; |
jbradshaw | 0:e4a10ed6eb92 | 47 | uint8_t instance; |
jbradshaw | 0:e4a10ed6eb92 | 48 | uint8_t slaveAddress; |
jbradshaw | 0:e4a10ed6eb92 | 49 | int ret1; |
jbradshaw | 0:e4a10ed6eb92 | 50 | int ret2; |
jbradshaw | 0:e4a10ed6eb92 | 51 | I2C *i2c; |
jbradshaw | 0:e4a10ed6eb92 | 52 | // get the number of bytes to write |
jbradshaw | 0:e4a10ed6eb92 | 53 | ProcessArgs(argStrs, args, 3); // parse [instance] [slaveAddress] [writeNumber] |
jbradshaw | 0:e4a10ed6eb92 | 54 | instance = args[0]; |
jbradshaw | 0:e4a10ed6eb92 | 55 | slaveAddress = args[1]; |
jbradshaw | 0:e4a10ed6eb92 | 56 | writeNumber = args[2]; |
jbradshaw | 0:e4a10ed6eb92 | 57 | // parse [instance] [slaveAddress] [writeNumber] [](data to write) |
jbradshaw | 0:e4a10ed6eb92 | 58 | // [readNumber] |
jbradshaw | 0:e4a10ed6eb92 | 59 | ProcessArgs(argStrs, args, writeNumber + 4); |
jbradshaw | 0:e4a10ed6eb92 | 60 | readNumber = args[writeNumber + 3]; |
jbradshaw | 0:e4a10ed6eb92 | 61 | |
jbradshaw | 1:9490836294ea | 62 | i2c = Peripherals::i2c1(); |
jbradshaw | 0:e4a10ed6eb92 | 63 | if (instance == 2) { |
jbradshaw | 0:e4a10ed6eb92 | 64 | i2c = Peripherals::i2c2(); |
jbradshaw | 0:e4a10ed6eb92 | 65 | } |
jbradshaw | 0:e4a10ed6eb92 | 66 | ret1 = 0; |
jbradshaw | 0:e4a10ed6eb92 | 67 | ret2 = 0; |
jbradshaw | 0:e4a10ed6eb92 | 68 | |
jbradshaw | 0:e4a10ed6eb92 | 69 | if (writeNumber != 0) { |
jbradshaw | 0:e4a10ed6eb92 | 70 | ret1 = i2c->write((int)slaveAddress, (char *)&args[3], (int)writeNumber); |
jbradshaw | 0:e4a10ed6eb92 | 71 | } |
jbradshaw | 0:e4a10ed6eb92 | 72 | if (readNumber != 0) { |
jbradshaw | 0:e4a10ed6eb92 | 73 | ret2 = i2c->read((int)slaveAddress, (char *)reply, (int)readNumber); |
jbradshaw | 0:e4a10ed6eb92 | 74 | } |
jbradshaw | 0:e4a10ed6eb92 | 75 | |
jbradshaw | 0:e4a10ed6eb92 | 76 | if (ret1 != 0) reply[0] = 0xFF; |
jbradshaw | 0:e4a10ed6eb92 | 77 | if (ret2 != 0) reply[0] = 0xFF; |
jbradshaw | 0:e4a10ed6eb92 | 78 | |
jbradshaw | 0:e4a10ed6eb92 | 79 | |
jbradshaw | 0:e4a10ed6eb92 | 80 | // reply[0] = 0x80; |
jbradshaw | 0:e4a10ed6eb92 | 81 | FormatReply(reply, readNumber, replyStrs); |
jbradshaw | 0:e4a10ed6eb92 | 82 | return 0; |
jbradshaw | 0:e4a10ed6eb92 | 83 | } |