- Thu Feb 05, 2015 4:31 pm
#9100
I am gonna write you one, wait a sec.
Try this:
https://github.com/jrahlf/nodemcu-firmw ... master/binCall "gpio.crazy_toggle(your_gpio)".
Should give maximum performance with the espressif API. Maybe it can be further increased by direct register access..
The method might cause a reset, because it does not clear the watchdog periodically.
Edit: I overlooked this link:
viewtopic.php?p=1191#p1191 , that is probably faster than this code, using the api.
Can you post values with 80MHz and 160MHz?
Code: Select allstatic int crazy_gpio_toggle(lua_State* L){
unsigned pin;
uint32_t gpio_no = luaL_checkinteger( L, 1 );
int bit_value = 0x0;
uint32_t set_mask_0 = bit_value<<gpio_no;
uint32_t clear_mask_0 = ((~bit_value)&0x01)<<gpio_no;
uint32_t enable_mask_0 = 1<<gpio_no;
uint32_t disable_mask_0 = 0;
bit_value = 0x1;
uint32_t set_mask_1 = bit_value<<gpio_no;
uint32_t clear_mask_1 = ((~bit_value)&0x01)<<gpio_no;
uint32_t enable_mask_1 = 1<<gpio_no;
uint32_t disable_mask_1 = 0;
uint32_t i;
for(i = 10*1000*1000; i >= 0; i--){
gpio_output_set(set_mask_0, clear_mask_0, enable_mask_0, disable_mask_0);
gpio_output_set(set_mask_1, clear_mask_1, enable_mask_1, disable_mask_1);
gpio_output_set(set_mask_0, clear_mask_0, enable_mask_0, disable_mask_0);
gpio_output_set(set_mask_1, clear_mask_1, enable_mask_1, disable_mask_1);
gpio_output_set(set_mask_0, clear_mask_0, enable_mask_0, disable_mask_0);
gpio_output_set(set_mask_1, clear_mask_1, enable_mask_1, disable_mask_1);
gpio_output_set(set_mask_0, clear_mask_0, enable_mask_0, disable_mask_0);
gpio_output_set(set_mask_1, clear_mask_1, enable_mask_1, disable_mask_1);
gpio_output_set(set_mask_0, clear_mask_0, enable_mask_0, disable_mask_0);
gpio_output_set(set_mask_1, clear_mask_1, enable_mask_1, disable_mask_1);
gpio_output_set(set_mask_0, clear_mask_0, enable_mask_0, disable_mask_0);
}
}