X-Git-Url: http://rtime.felk.cvut.cz/gitweb/pes-rpp/rpp-lib.git/blobdiff_plain/8cb35be97c53b739761ace2e47c8f35b6d854019..573021795371f41a23ed0fe0b5171f38bb96d86e:/rpp/include/rpp/sdr.h diff --git a/rpp/include/rpp/sdr.h b/rpp/include/rpp/sdr.h index 48c6b1c..8e96078 100644 --- a/rpp/include/rpp/sdr.h +++ b/rpp/include/rpp/sdr.h @@ -1,7 +1,7 @@ /** * SD-RAN logging RPP API header file. * - * @file rpp_sdr.h + * @file sdr.h * * @copyright Copyright (C) 2013 Czech Technical University in Prague * @@ -12,15 +12,119 @@ #ifndef __RPP_SDR_H #define __RPP_SDR_H +/** + * SDRAM start address on RPP board. + * + * @note See RPP_SDR_ADDR_END for memory size. + */ +#define RPP_SDR_ADDR_START 0x80000000U + +/** + * SDRAM end address on RPP board. + * + * @note 0x83FFFFFF − 0x80000000 + 1 = 67108864 addresses.\n + * One address per byte.\n + * 67108864 bytes = 65536 Kbytes = 64 Mbytes. + */ +#define RPP_SDR_ADDR_END 0x83FFFFFFU + + /** * SDR module initialization. + * * Call this method before using this module. * - * @return SUCCESS if initialization successful. - * FAIL is module already initialized. + * @return SUCCESS if initialization successful.\n + * FAILURE if module already initialized. */ -void rpp_sdr_init(); +int8_t rpp_sdr_init(); -#endif /* __RPP_SDR_H */ +/** + * Configure SD-RAM logging. + * + * This function will enable or disable logging on application. Note that when + * logging is enabled a command processor task which uses the SCI for user I/O + * is spawned. This command processor might conflict with user application if it + * also uses the SCI for user I/O. + * + * @param[in] enable Enable/Disable logging on application. + * + * @return SUCCESS if logging was successfully enabled or disabled.\n + * FAILURE if trying to disable disabled (or enable enabled) + * logging, SDR module have not being initialized or not + * enough memory to allocate tasks. + */ +int8_t rpp_sdr_setup(boolean_t enable); + + +/** + * Query for the amount of space free on the SD-RAM. + * + * This funtion will calculate the amount of free space left (not used by logs) + * on the SD-RAM. + * + * @return Number of bytes free in the SD-RAM.\n + * For 64MB SD-RAM value is between [0-67108864] + */ +uint32_t rpp_sdr_available(); + +/** + * Store a formatted user string on the log, if logging is enabled. + * + * Implementation uses vsnprintf() from stdio.h using a fixed MAX_BUFFER_LEN + * bytes buffer. + * + * @param[in] format C string that contains a format string that follows the + * same specifications as format in printf (see stdio.h's + * printf for details). + * @param[in] ... (additional arguments) Depending on the format string, + * the function may expect a sequence of additional + * arguments, each containing a value to be used to replace + * a format specifier in the format string (or a pointer to + * a storage location). + * There should be at least as many of these arguments as + * the number of values specified in the format specifiers. + * Additional arguments are ignored by the function. + * + * @return The number of characters that would have been written if the buffer + * had been sufficiently large, not counting the terminating null + * character. + * If logging is disabled, an encoding error occurs or the log file is + * full a negative number is returned. + * Please note that only when this returned value is non-negative and + * less than the buffer size, the string has been completely written. + */ +int32_t rpp_sdr_printf(const char *format, ...); + + +/** + * Clear log. + * + * This function will clear all the data from the log. This will also stop the + * show task if it's currently flushing the log. + * + * @return SUCCESS if log was cleared.\n + * FAILURE if logging is disabled or log was already empty. + */ +int8_t rpp_sdr_clear(); + + +/** + * Start/Stop the task that sends the log to the SCI. + * + * This function will start the task that reads the log and prints it to the + * SCI in a similar way the 'dmesg' command work on Linux. + * + * @param[in] start TRUE to request the log to be sent to the SCI. + * FALSE to stop the log file from being send to the SCI. + * + * @return SUCCESS if log was cleared.\n + * FAILURE if logging is disabled or trying to stop an stopped task + * (or start an already started task). + */ +int8_t rpp_sdr_show(boolean_t start); + + +#endif /* __RPP_SDR_H */