![](/media/cache/img/default_profile.jpg.50x50_q85.jpg)
This is a mbed 5.2 Release
Fork of mbed-os-test by
Embed:
(wiki syntax)
Show/hide line numbers
Logging.cpp
00001 /******************************************************************************* 00002 * Copyright (C) 2016 Maxim Integrated Products, Inc., All Rights Reserved. 00003 * 00004 * Permission is hereby granted, free of charge, to any person obtaining a 00005 * copy of this software and associated documentation files (the "Software"), 00006 * to deal in the Software without restriction, including without limitation 00007 * the rights to use, copy, modify, merge, publish, distribute, sublicense, 00008 * and/or sell copies of the Software, and to permit persons to whom the 00009 * Software is furnished to do so, subject to the following conditions: 00010 * 00011 * The above copyright notice and this permission notice shall be included 00012 * in all copies or substantial portions of the Software. 00013 * 00014 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS 00015 * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 00016 * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. 00017 * IN NO EVENT SHALL MAXIM INTEGRATED BE LIABLE FOR ANY CLAIM, DAMAGES 00018 * OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, 00019 * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR 00020 * OTHER DEALINGS IN THE SOFTWARE. 00021 * 00022 * Except as contained in this notice, the name of Maxim Integrated 00023 * Products, Inc. shall not be used except as stated in the Maxim Integrated 00024 * Products, Inc. Branding Policy. 00025 * 00026 * The mere transfer of this software does not imply any licenses 00027 * of trade secrets, proprietary technology, copyrights, patents, 00028 * trademarks, maskwork rights, or any other form of intellectual 00029 * property whatsoever. Maxim Integrated Products, Inc. retains all 00030 * ownership rights. 00031 ******************************************************************************* 00032 */ 00033 #include "mbed.h" 00034 #include "RpcServer.h" 00035 #include "Logging.h" 00036 #include "S25FS512.h" 00037 #include "Peripherals.h" 00038 00039 /// length of flash page as dictated by the device 00040 #define LENGTH_OF_FLASH_PAGE 256 // length of flash page in bytes 00041 /// size in bytes of the external flash device on the HSP platform 00042 #define SIZE_OF_EXTERNAL_FLASH \ 00043 (16777216 / 2) // length of external flash in bytes 00044 /// start page of where the mission is defined 00045 #define MISSION_DEFINITION_START_PAGE 0x00 00046 /// end page of the mission 00047 #define MISSION_DEFINITION_END_PAGE 0x0F 00048 /// page of where the logging data starts 00049 #define LOGGING_START_PAGE 0x12 00050 /// the last logging page 00051 #define LOGGING_END_PAGE (SIZE_OF_EXTERNAL_FLASH / LENGTH_OF_FLASH_PAGE) 00052 00053 /// static flag to know if logging was started via RPC 00054 static bool startLoggingViaRpc = false; 00055 00056 /** 00057 * @brief This will read the mission location and if there is something valid, 00058 * then run the Logging_ProcessMissionCmds() 00059 * @param cmdBuffer buffer 00060 */ 00061 uint32_t Logging_IsMissionDefined(uint8_t *cmdBuffer) { 00062 uint32_t valid = 1; 00063 if ((cmdBuffer[0] == 0xFF) || (cmdBuffer[0] == 0x0)) 00064 valid = 0; 00065 return valid; 00066 } 00067 00068 /** 00069 * @brief Read the mission from flash and place in buffer 00070 * @param buffer pointer to byte array that will contain the read results 00071 */ 00072 int8_t Logging_ReadMissionFromFlash(uint8_t *buffer) { 00073 return Peripherals::s25FS512()->readPages_Helper( 00074 MISSION_DEFINITION_START_PAGE, MISSION_DEFINITION_END_PAGE, buffer, 0); 00075 } 00076 00077 //****************************************************************************** 00078 // return the page where mission is defined, Mission specific 00079 uint32_t Logging_GetMissionStartPage(void) { 00080 return MISSION_DEFINITION_START_PAGE; 00081 } 00082 00083 //****************************************************************************** 00084 // return the page where the mission definition ends, Mission specific 00085 uint32_t Logging_GetMissionEndPage(void) { return MISSION_DEFINITION_END_PAGE; } 00086 00087 //****************************************************************************** 00088 // Returns the location where the Writing can start from, for data logging... 00089 uint32_t Logging_GetLoggingStartPage(void) { return LOGGING_START_PAGE; } 00090 00091 //****************************************************************************** 00092 // Returns the end location available where the Flash ends essentially.... for 00093 // data logging. 00094 uint32_t Logging_GetLoggingEndPage(void) { return LOGGING_END_PAGE; } 00095 00096 //****************************************************************************** 00097 void Logging_SetStart(bool state) { startLoggingViaRpc = state; } 00098 00099 //****************************************************************************** 00100 bool Logging_GetStart(void) { return startLoggingViaRpc; } 00101 00102 //****************************************************************************** 00103 // for debugging... always say that usb is not connected... for easy bench 00104 // testing 00105 uint32_t Usb_IsConnected(void) { return 0; }
Generated on Wed Jul 13 2022 17:00:35 by
![doxygen](doxygen.png)