mirror of
				https://github.com/esp8266/Arduino.git
				synced 2025-11-03 14:33:37 +03:00 
			
		
		
		
	Add function to measure stack high water mark (thanks @g3gg0)
This commit is contained in:
		@@ -30,6 +30,12 @@ void ICACHE_RAM_ATTR cont_init(cont_t* cont) {
 | 
			
		||||
    cont->stack_guard2 = CONT_STACKGUARD;
 | 
			
		||||
    cont->stack_end = cont->stack + (sizeof(cont->stack) / 4);
 | 
			
		||||
    cont->struct_start = (unsigned*) cont;
 | 
			
		||||
    
 | 
			
		||||
    // fill stack with magic values to check high water mark
 | 
			
		||||
    for(int pos = 0; pos < sizeof(cont->stack) / 4; pos++)
 | 
			
		||||
    {
 | 
			
		||||
        cont->stack[pos] = CONT_STACKGUARD;
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
int ICACHE_RAM_ATTR cont_check(cont_t* cont) {
 | 
			
		||||
@@ -38,6 +44,19 @@ int ICACHE_RAM_ATTR cont_check(cont_t* cont) {
 | 
			
		||||
    return 0;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
int ICACHE_RAM_ATTR cont_get_free_stack(cont_t* cont) {
 | 
			
		||||
    uint32_t *head = cont->stack;
 | 
			
		||||
    int freeWords = 0;
 | 
			
		||||
 | 
			
		||||
    while(*head == CONT_STACKGUARD)
 | 
			
		||||
    {
 | 
			
		||||
        head++;
 | 
			
		||||
        freeWords++;
 | 
			
		||||
    }
 | 
			
		||||
    
 | 
			
		||||
    return freeWords * 4;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
bool ICACHE_RAM_ATTR cont_can_yield(cont_t* cont) {
 | 
			
		||||
    return !ETS_INTR_WITHINISR() &&
 | 
			
		||||
           cont->pc_ret != 0 && cont->pc_yield == 0;
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user