![](/media/cache/img/default_profile.jpg.50x50_q85.jpg)
repo time
Dependencies: mbed MAX14720 MAX30205 USBDevice
e4a10ed6eb92/HSP/Devices/S25FS256/S25FS512_RPC.cpp@20:6d2af70c92ab, 2021-04-06 (annotated)
- Committer:
- darienf
- Date:
- Tue Apr 06 06:41:40 2021 +0000
- Revision:
- 20:6d2af70c92ab
another repo
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
darienf | 20:6d2af70c92ab | 1 | /******************************************************************************* |
darienf | 20:6d2af70c92ab | 2 | * Copyright (C) 2016 Maxim Integrated Products, Inc., All Rights Reserved. |
darienf | 20:6d2af70c92ab | 3 | * |
darienf | 20:6d2af70c92ab | 4 | * Permission is hereby granted, free of charge, to any person obtaining a |
darienf | 20:6d2af70c92ab | 5 | * copy of this software and associated documentation files (the "Software"), |
darienf | 20:6d2af70c92ab | 6 | * to deal in the Software without restriction, including without limitation |
darienf | 20:6d2af70c92ab | 7 | * the rights to use, copy, modify, merge, publish, distribute, sublicense, |
darienf | 20:6d2af70c92ab | 8 | * and/or sell copies of the Software, and to permit persons to whom the |
darienf | 20:6d2af70c92ab | 9 | * Software is furnished to do so, subject to the following conditions: |
darienf | 20:6d2af70c92ab | 10 | * |
darienf | 20:6d2af70c92ab | 11 | * The above copyright notice and this permission notice shall be included |
darienf | 20:6d2af70c92ab | 12 | * in all copies or substantial portions of the Software. |
darienf | 20:6d2af70c92ab | 13 | * |
darienf | 20:6d2af70c92ab | 14 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS |
darienf | 20:6d2af70c92ab | 15 | * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF |
darienf | 20:6d2af70c92ab | 16 | * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. |
darienf | 20:6d2af70c92ab | 17 | * IN NO EVENT SHALL MAXIM INTEGRATED BE LIABLE FOR ANY CLAIM, DAMAGES |
darienf | 20:6d2af70c92ab | 18 | * OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, |
darienf | 20:6d2af70c92ab | 19 | * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR |
darienf | 20:6d2af70c92ab | 20 | * OTHER DEALINGS IN THE SOFTWARE. |
darienf | 20:6d2af70c92ab | 21 | * |
darienf | 20:6d2af70c92ab | 22 | * Except as contained in this notice, the name of Maxim Integrated |
darienf | 20:6d2af70c92ab | 23 | * Products, Inc. shall not be used except as stated in the Maxim Integrated |
darienf | 20:6d2af70c92ab | 24 | * Products, Inc. Branding Policy. |
darienf | 20:6d2af70c92ab | 25 | * |
darienf | 20:6d2af70c92ab | 26 | * The mere transfer of this software does not imply any licenses |
darienf | 20:6d2af70c92ab | 27 | * of trade secrets, proprietary technology, copyrights, patents, |
darienf | 20:6d2af70c92ab | 28 | * trademarks, maskwork rights, or any other form of intellectual |
darienf | 20:6d2af70c92ab | 29 | * property whatsoever. Maxim Integrated Products, Inc. retains all |
darienf | 20:6d2af70c92ab | 30 | * ownership rights. |
darienf | 20:6d2af70c92ab | 31 | ******************************************************************************* |
darienf | 20:6d2af70c92ab | 32 | */ |
darienf | 20:6d2af70c92ab | 33 | |
darienf | 20:6d2af70c92ab | 34 | #include "S25FS512_RPC.h" |
darienf | 20:6d2af70c92ab | 35 | #include "S25FS512.h" |
darienf | 20:6d2af70c92ab | 36 | #include "StringInOut.h" |
darienf | 20:6d2af70c92ab | 37 | #include "StringHelper.h" |
darienf | 20:6d2af70c92ab | 38 | #include "Peripherals.h" |
darienf | 20:6d2af70c92ab | 39 | |
darienf | 20:6d2af70c92ab | 40 | int S25FS512_Reset(char argStrs[32][32], char replyStrs[32][32]) { |
darienf | 20:6d2af70c92ab | 41 | uint32_t reply[1]; |
darienf | 20:6d2af70c92ab | 42 | Peripherals::s25FS512()->reset(); |
darienf | 20:6d2af70c92ab | 43 | reply[0] = 0x80; |
darienf | 20:6d2af70c92ab | 44 | FormatReply32(reply, sizeof(reply) / sizeof(uint32_t), replyStrs); |
darienf | 20:6d2af70c92ab | 45 | return 0; |
darienf | 20:6d2af70c92ab | 46 | } |
darienf | 20:6d2af70c92ab | 47 | |
darienf | 20:6d2af70c92ab | 48 | int S25FS512_EnableHWReset(char argStrs[32][32], char replyStrs[32][32]) { |
darienf | 20:6d2af70c92ab | 49 | uint32_t reply[1]; |
darienf | 20:6d2af70c92ab | 50 | Peripherals::s25FS512()->enableHWReset(); |
darienf | 20:6d2af70c92ab | 51 | reply[0] = 0x80; |
darienf | 20:6d2af70c92ab | 52 | FormatReply32(reply, sizeof(reply) / sizeof(uint32_t), replyStrs); |
darienf | 20:6d2af70c92ab | 53 | return 0; |
darienf | 20:6d2af70c92ab | 54 | } |
darienf | 20:6d2af70c92ab | 55 | |
darienf | 20:6d2af70c92ab | 56 | int S25FS512_SpiWriteRead(char argStrs[32][32], char replyStrs[32][32]) { |
darienf | 20:6d2af70c92ab | 57 | uint8_t args[16]; |
darienf | 20:6d2af70c92ab | 58 | uint8_t reply[16]; |
darienf | 20:6d2af70c92ab | 59 | uint8_t writeNumber; |
darienf | 20:6d2af70c92ab | 60 | uint8_t readNumber; |
darienf | 20:6d2af70c92ab | 61 | // get the number of bytes to write |
darienf | 20:6d2af70c92ab | 62 | ProcessArgs(argStrs, args, 1); |
darienf | 20:6d2af70c92ab | 63 | writeNumber = args[0]; |
darienf | 20:6d2af70c92ab | 64 | ProcessArgs(argStrs, args, writeNumber + 2); |
darienf | 20:6d2af70c92ab | 65 | readNumber = args[writeNumber + 1]; |
darienf | 20:6d2af70c92ab | 66 | FormatReply(reply, readNumber, replyStrs); |
darienf | 20:6d2af70c92ab | 67 | return 0; |
darienf | 20:6d2af70c92ab | 68 | } |
darienf | 20:6d2af70c92ab | 69 | |
darienf | 20:6d2af70c92ab | 70 | int S25FS512_SpiWriteRead4Wire(char argStrs[32][32], char replyStrs[32][32]) { |
darienf | 20:6d2af70c92ab | 71 | uint8_t args[16]; |
darienf | 20:6d2af70c92ab | 72 | uint8_t reply[16]; |
darienf | 20:6d2af70c92ab | 73 | uint8_t writeNumber; |
darienf | 20:6d2af70c92ab | 74 | uint8_t readNumber; |
darienf | 20:6d2af70c92ab | 75 | // get the number of bytes to write |
darienf | 20:6d2af70c92ab | 76 | ProcessArgs(argStrs, args, 1); |
darienf | 20:6d2af70c92ab | 77 | writeNumber = args[0]; |
darienf | 20:6d2af70c92ab | 78 | ProcessArgs(argStrs, args, writeNumber + 2); |
darienf | 20:6d2af70c92ab | 79 | readNumber = args[writeNumber + 1]; |
darienf | 20:6d2af70c92ab | 80 | FormatReply(reply, readNumber, replyStrs); |
darienf | 20:6d2af70c92ab | 81 | return 0; |
darienf | 20:6d2af70c92ab | 82 | } |
darienf | 20:6d2af70c92ab | 83 | |
darienf | 20:6d2af70c92ab | 84 | int S25FS512_ReadPage(char argStrs[32][32], char replyStrs[32][32]) { |
darienf | 20:6d2af70c92ab | 85 | uint32_t args[2]; |
darienf | 20:6d2af70c92ab | 86 | uint32_t reply[1]; |
darienf | 20:6d2af70c92ab | 87 | ProcessArgs32(argStrs, args, sizeof(args) / sizeof(uint32_t)); |
darienf | 20:6d2af70c92ab | 88 | reply[0] = 0x80; |
darienf | 20:6d2af70c92ab | 89 | FormatReply32(reply, sizeof(reply) / sizeof(uint32_t), replyStrs); |
darienf | 20:6d2af70c92ab | 90 | return 0; |
darienf | 20:6d2af70c92ab | 91 | } |
darienf | 20:6d2af70c92ab | 92 | |
darienf | 20:6d2af70c92ab | 93 | int S25FS512_ReadPagesBinary(char argStrs[32][32], char replyStrs[32][32]) { |
darienf | 20:6d2af70c92ab | 94 | uint32_t args[2]; |
darienf | 20:6d2af70c92ab | 95 | uint32_t reply[1]; |
darienf | 20:6d2af70c92ab | 96 | uint8_t pageData[256]; |
darienf | 20:6d2af70c92ab | 97 | |
darienf | 20:6d2af70c92ab | 98 | uint32_t startPage; |
darienf | 20:6d2af70c92ab | 99 | uint32_t endPage; |
darienf | 20:6d2af70c92ab | 100 | uint32_t page; |
darienf | 20:6d2af70c92ab | 101 | |
darienf | 20:6d2af70c92ab | 102 | ProcessArgs32(argStrs, args, sizeof(args) / sizeof(uint32_t)); |
darienf | 20:6d2af70c92ab | 103 | startPage = args[0]; |
darienf | 20:6d2af70c92ab | 104 | endPage = args[1]; |
darienf | 20:6d2af70c92ab | 105 | for (page = startPage; page <= endPage; page++) { |
darienf | 20:6d2af70c92ab | 106 | Peripherals::s25FS512()->readPages_Helper(page, page, pageData, 0); |
darienf | 20:6d2af70c92ab | 107 | putBytes256Block(pageData, 1); |
darienf | 20:6d2af70c92ab | 108 | } |
darienf | 20:6d2af70c92ab | 109 | reply[0] = 0x80; |
darienf | 20:6d2af70c92ab | 110 | FormatReply32(reply, sizeof(reply) / sizeof(uint32_t), replyStrs); |
darienf | 20:6d2af70c92ab | 111 | return 0; |
darienf | 20:6d2af70c92ab | 112 | } |
darienf | 20:6d2af70c92ab | 113 | |
darienf | 20:6d2af70c92ab | 114 | int S25FS512_ReadId(char argStrs[32][32], char replyStrs[32][32]) { |
darienf | 20:6d2af70c92ab | 115 | char str[32]; |
darienf | 20:6d2af70c92ab | 116 | uint8_t data[128]; |
darienf | 20:6d2af70c92ab | 117 | Peripherals::s25FS512()->readIdentification(data, sizeof(data)); |
darienf | 20:6d2af70c92ab | 118 | Peripherals::s25FS512()->readIdentification(data, sizeof(data)); |
darienf | 20:6d2af70c92ab | 119 | sprintf(str, "%02X%02X%02X%02X", data[0], data[1], data[2], data[3]); |
darienf | 20:6d2af70c92ab | 120 | strcpy(replyStrs[0], str); |
darienf | 20:6d2af70c92ab | 121 | return 0; |
darienf | 20:6d2af70c92ab | 122 | } |