1. Clock management CLK (1)Uns ncounts = CLK_countspms(void) Returns the count value of the high-resolution clock of the timer per millisecond (2)LgUns currtime = CLK_gethtime(void) Returns the count value of the high-resolution clock. If it exceeds 32 bits, it will be reset to zero. The high-resolution clock is the DSP clock divided by (TDDR+1) (3)LgUns currtime = CLK_getltime(void) Returns the count value of the low-resolution clock. If it exceeds 32 bits, it will be reset to zero. The high-resolution clock is the DSP clock divided by (TDDR+1) and then divided by (PRD+1) (4)Uns period = CLK_getprd(void) Returns the value of the CLK manager period register 2. Period function PRD (1)LgUns num = PRD_getticks(void) Returns the 32-bit period function management count value (2)void PRD_start(PRD_Obj* period) Starts the PRD module counter. Generally, mode=one-shot (3)void PRD_stop(PRD_Obj* period) turns off the PRD module counter (4) void PRD_tick(void) adds 1 to the counter of the periodic module so that the periodic module manager can determine which periodic function can be run. III. Software interrupt management SWI (1) void SWI_andn(SWI_Obj* swi, Uns mask) mask The mask word parameter performs an AND operation on the mailbox value and mask, and replaces the previous mailbox value with the result. If it is 0, start the software interrupt and restore the initial value of the mailbox (2) void SWI_andn(SWI_Obj* swi) reduces the mailbox value by 1, and replaces the previous mailbox value with the result. If it is 0, start the software interrupt and restore the initial value of the mailbox (3) void SWI_disable(Void) disables software interrupts (4) void SWI_enable(Void) enables software interrupts (5) Uns num = SWI_getmbox(void) Returns the mailbox value of the current SWI object being executed. If the interrupt has already started executing, DSP/BIOS will save this value first. (6) Uns key = SWI_getpri(SWI_Obj * swi) Returns the priority of the specified SWI object. (7) void SWI_inc(SWI_Obj * swi) Adds 1 to the mailbox value of the specified SWI object and starts the software interrupt. Even if the user calls it multiple times, it will be executed once in the end. (8) void SWI_or(SWI_Obj* swi, Uns mask) The mask mask word parameter will start the specified software interrupt, and perform an AND operation on the mailbox value of this software interrupt and the mask, and use the result to replace the previous mailbox value. After the interrupt is completed, the mailbox value is restored to the initial value. Generally, call SWI_getmbox to obtain the mailbox value that triggered this software interrupt. (9) void SWI_post(SWI_Handle swi) Starts the software interrupt of the specified SWI object. This function is not affected by the mailbox value and does not affect the mailbox value. Generally, a software interrupt is started periodically, _SWI_post is filled into the function setting column of the PRD object, and the parameters for starting the software interrupt are written to arg0 (10) Uns key = SWI_raisepri(Uns mask) Increase the priority of the SWI software interrupt, generally key = SWI_raisepri(SWI_getpri(&swi_1)); --access shared resouces-- SWI_restorepri(key) Copy code (11) void SWI_restorepri(Uns key) Restore the original priority (12) SWI_Obj * swi = SWI_self(void) The address of the software interrupt of the currently executed SWI object IV. Information output management LOG (1) void LOG_disable(LOG_Obj * log) Disable the log function of the specified direction (2) void LOG_enable(LOG_Obj * log) Enable the log function of the specified direction (3) void LOG_error(String format, Arg arg0) void LOG_message(String format, Arg arg0) The previous function can write an event, data or error message to the system log in the specified format string, which is not affected by the TRC tracking management module. The latter function is similar to the previous function, but is affected by the TRC tracking management module. (4) void LOG_event(LOG_Obj * log, Arg arg0, Arg arg1, Arg arg2) Writes an unformatted event message to the log. (5) void LOG_printf(LOG_Obj * log, String format, int arg0, int arg1) The specified LOG window displays the message %d %x %o %s (6) void LOG_reset(LOG_Obj * log) Resets the log buffer V. Memory Management MEM (1) void * addr = MEM_alloc(int segid,Uns size,Uns align) Allocates continuous blocks to the specified storage segment and returns the starting address segid = the identifier or ID number of the storage segment size The block size is equal to the number of words align. The boundary conditions are only 0 or power of 2. If align is 0 or 1, there is no constraint. (2) void * addr = MEM_calloc(segid, size, align) allocates memory and initializes it to 0. (3) int segid = MEM_define(Ptr base, Uns length, MEM_Attrs* attrs) defines a new memory segment. The return value is the ID label of the storage segment. If the attr parameter is NULL, it will be configured according to the default parameters. The parameters of the segment are specified by the structure type MEM_Attrs. This function is only used in the main function. base: base address of the new segment length: segment length attrs: segment attributes (4) bool status = MEM_free(segid,addr,size) Releases the requested dynamic memory. It cannot be called in SWI and HWI. Before calling, use the API in LCK to check the locking status of the memory block. (5) void MEM_redefine(segid,base,length) Redefine a storage segment. It can only be called in main. (6) bool status = MEM_stat(int segid, MEM_Stat * statbuf) segid storage segment identifier statbuf status buffer pointer struct mem_stat{ Uns size; //storage segment size Uns used; //number used Uns length; //maximum continuous storage block length} Copy code Similarly: if segid is valid, MEM_stat returns TRUE Cannot be used in SWI and HWI. The lock status should be determined. (7) void * addr = MEM_valloc(int segid, Uns size, Uns align,char value) First apply for memory and initialize it to the specified value value VI. C6000 dedicated module C64x (1)Uns oldmask = C64_diableIER(Uns mask) Turn off the corresponding interrupt return value The actual masked interrupt (2)void C64_enableIER(Uns oldmask) Open the corresponding interrupt Uns oldmask; oldmask = C64_disableIER(0x1); // disable INT0 C64_enableIER(oldmask); // enable INT0 Copy code (3)void C64_plug(int vecid, Fxn fxn, int dmachan) Insert an interrupt vector int vecid: interrupt sequence number Fxn fxn: function pointer of the interrupt service program int dmachan: Insert the DMA channel used by the operation Write ISFP to the interrupt service table IST. If IST is in external RAM, CPU copying replaces DMA. At this time, DMA is -1. When IST is in on-chip RAM, DMA is used, which is 0, 1, 2, 3. The user ensures that the DMA channel is valid when the function is called. VII. Statistics module STS (1) void STS_add(STS_Obj * sts, LgInt value) Use the data we provide to update the Total, Count, Max and other parameters of the STS statistics object. Pass in a 32-bit parameter, Count plus 1, Total accumulates the passed 32-bit parameter, and MAX records the maximum value of the passed parameter. (2) void STS_delta(STA_Obj * sts, LgInt value) Each object contains an initial value, which is specified by the configuration file or set by the STS_set function. STS_delta first calculates the difference between the current passed parameter and the previous initial value, and then calls STS_add to update the statistical accumulated value. It is usually used together with STS_set, eg: STS_set(&sts,CLK_gethtime()); STS_delta(&sts,CLK_gethtime()); Copy code (3) void STS_reset (STS_Obj * sts) Resets the accumulated value in the statistics object. Count and Total are set to 0. MAX becomes the largest negative value. (4) void STS_set (STS_Obj * sts, LgInt value) Monitors or counts the execution time of the program