### Introduction `ramt` is a simple memory (RAM) testing module for the C language. It defines multiple memory testing modes and structures representing memory. Meanwhile, it provides a series of function interfaces such as initializing the memory testing structure, starting the test, stopping the test, obtaining the historical test results and the latest test results, etc. It's convenient for developers to conduct tests on simulated memory in different modes and for different durations in C language projects and view the corresponding test situations. ### Interfaces #### Functions ##### `ramt_init` Function ```c int ramt_init(RAMT *ramt); ``` **Function Description**: It is used to initialize the `RAMT` structure, preparing for the subsequent memory testing-related processes. For example, it may involve basic setup work such as memory space allocation and initialization of related variables. **Parameter Introduction**: - `ramt`: A pointer to the `RAMT` structure. This structure is used to describe the information related to the memory to be tested. By passing its pointer, the function can perform initialization operations on the members inside the structure. ##### `ramt_start` Function ```c int ramt_start(RAMT *ramt, uint32_t mode, uint32_t duration); ``` **Function Description**: It starts the memory testing process and executes the corresponding memory testing tasks according to the specified testing mode and duration. Different testing modes correspond to different testing strategies and operations, such as read/write verification, boundary checking, etc. The duration determines the time range for the test to run. **Parameter Introduction**: - `ramt`: A pointer to the `RAMT` structure, which provides the basic information of the memory to be tested. The function determines key information such as the target memory area for testing based on this structure. - `mode`: Represents the memory testing mode, and its value is taken from predefined testing mode macros (such as `RAMT_MODE_NORMAL`, `RAMT_MODE_BOUNDARY`, etc.). Different macros correspond to different types of testing logic. For example, `RAMT_MODE_NORMAL` represents the normal read/write test, which verifies whether the memory functions properly by performing read and write operations on it. - `duration`: Specifies the duration of the memory test. The specific meaning of the unit, etc. depends on the actual setting. When the value is `0xFFFFFFFF`, it means continuous and uninterrupted operation. Developers can set an appropriate duration according to their needs to control the test cycle. ##### `ramt_stop` Function ```c int ramt_stop(RAMT *ramt); ``` **Function Description**: It is used to stop the ongoing memory testing operation, ensuring that relevant test resources can be released reasonably and the test state ends correctly, avoiding abnormal situations such as resource occupation. **Parameter Introduction**: - `ramt`: A pointer to the `RAMT` structure. Based on the structure pointed to by this pointer, it determines which memory testing task to stop, finds the corresponding test resources and states, and performs the corresponding stop processing. ##### `ramt_result` Function ```c uint32_t ramt_result(RAMT *ramt); ``` **Function Description**: It is used to obtain the historical result information of the memory test. By querying relevant records or status data, it returns the overall test situation accumulated during the previous memory testing process, facilitating developers to understand the performance of the memory in past tests. **Parameter Introduction**: - `ramt`: A pointer to the `RAMT` structure. Based on the memory testing task associated with this structure, it searches for and extracts the corresponding historical test result information. Different memory testing tasks have their own independent result records, and this pointer is used to locate the corresponding record position. ##### `ramt_result_latest` Function ```c uint32_t ramt_result_latest(RAMT *ramt); ``` **Function Description**: It obtains the latest result of the memory test, that is, it obtains the result information generated by the most recent memory test closest to the current time. It helps developers quickly know the state of the memory in the most recent test. **Parameter Introduction**: - `ramt`: A pointer to the `RAMT` structure. With the help of the structure pointed to by this pointer, it locates and obtains the latest result data of the corresponding memory test, ensuring that the latest situation of the correct target memory testing task is returned. ##### `ramt_task` Function ```c void ramt_task(RAMT *ramt); ``` **Function Description**: It periodically executes the operations related to the memory testing task according to the set testing mode and related configurations. In scenarios where continuous memory testing monitoring is required or tests are conducted at certain intervals, this function can be called to achieve the corresponding functions. **Parameter Introduction**: - `ramt`: A pointer to the `RAMT` structure. The function determines which memory to test and in which mode to execute the testing task through this pointer. It is associated with various key configuration information of the memory test and is the basis for executing specific testing operations.