How to dynamically load a function into IRAM

strangeman
Posts: 4
Joined: Thu Sep 16, 2021 11:40 am

How to dynamically load a function into IRAM

Postby strangeman » Sat Oct 22, 2022 8:38 am

for example:there are 3 functions,i want call them fast in interrupt,but i don't have enough IRAM,

Code: Select all

void func1(void){printf("func1");}
void func2(void){printf("func2");}
void func3(void){printf("func3");}

uint8_t IRAM_ATTR share_mem[1024];
typedef void (*func_t)(void)
bool IRAM_ATTR interrupt_func(void*parm)
{
	func_t func = (func_t)share_mem;
	func();
}
void set_iram_func(uint8_t index)
{
	switch(index)
	{
	default:
	case 0:{
		//TODO load func1 to share_mem
		break;
	}
	case 1:{
		//TODO load func2 to share_mem
		break;
	}
	case 2:{
		//TODO load func3 to share_mem
		break;
	}
	}
}

Who is online

Users browsing this forum: davidItaly and 251 guests