The invention provides an interface for a counting or timing function of flight
control software and an implementation method of the interface, and belongs to the technical field of flight
control software. According to the method, a unified counter function is defined and comprises a counting array and a small frame number array which can be used by a plurality of counters, the counting array and the small frame number array are packaged, and the counting or timing function of the flight
control software is obtained; when a new counter is added, a new
global variable does not need to be defined, only a static subscript variable needs to be defined at the code position of the counter needing to be used in the flight control
software to indicate elements in a counting array corresponding to the currently used counter, the address of the static subscript variable is transmitted to a counter function through a formal parameter, and then the counter function is added. In this way, counting accumulation or zero clearing can be automatically achieved when a counter function is called, and
coupling use of counters is avoided. Due to the fact that the counting function of the counter function is achieved through the internal static counting array, and the counting array is packaged in the counter function, the risk that the counter is tampered by the outside is avoided to the maximum extent.