Skip to content

Commit

Permalink
Improved performance
Browse files Browse the repository at this point in the history
By adding functions using IRAM and cache
  • Loading branch information
gjroots committed May 1, 2023
1 parent 02cfda3 commit 3ad0ece
Show file tree
Hide file tree
Showing 5 changed files with 15 additions and 7 deletions.
8 changes: 8 additions & 0 deletions components/utils/include/utils.h
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,14 @@ extern "C"
#include <stdlib.h>
#include <esp_err.h>

#ifdef ICACHE_FLASH
#define ICACHE_FLASH_ATTR __attribute__((section(".irom0.text")))
#define ICACHE_RODATA_ATTR __attribute__((section(".irom.text")))
#else
#define ICACHE_FLASH_ATTR
#define ICACHE_RODATA_ATTR
#endif /* ICACHE_FLASH */

float system_uptime_s(void);
void restart(void);

Expand Down
2 changes: 1 addition & 1 deletion components/utils/initialization.c
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ char *ssid, *ent_username, *ent_identity,
char currentMAC[18];

//-----------------------------------------------------------------------------
esp_err_t parms_init()
esp_err_t IRAM_ATTR parms_init()
{
int webServer = 1, ledEnable = 1, customDnsEnable = 0,
darkModeEnable = 0, randomizeMac = 0;
Expand Down
4 changes: 2 additions & 2 deletions components/web_server/response_handler.c
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ url_handler_t handlers[] = {


//-----------------------------------------------------------------------------
esp_err_t common_page_response_handler(httpd_req_t *req, int req_id)
esp_err_t ICACHE_FLASH_ATTR common_page_response_handler(httpd_req_t *req, int req_id)
{
for (int i = 0; i < sizeof(handlers) / sizeof(handlers[0]); i++)
{
Expand Down Expand Up @@ -108,7 +108,7 @@ const size_t num_js_files = sizeof(js_files) / sizeof(js_files[0]);


//-----------------------------------------------------------------------------
esp_err_t common_js_response(httpd_req_t *req)
esp_err_t ICACHE_FLASH_ATTR common_js_response(httpd_req_t *req)
{
for (int i = 0; i < num_js_files; i++)
{
Expand Down
4 changes: 2 additions & 2 deletions components/wifi_handler/wifi_handler.c
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@

//-----------------------------------------------------------------------------
// Handles wifi scan and return AP records in json string format
char *wifi_scan_handler(void)
char* IRAM_ATTR wifi_scan_handler(void)
{
// Disconnect from the current access point if not already connected
if (!ap_connect)
Expand Down Expand Up @@ -84,7 +84,7 @@ char *wifi_scan_handler(void)

//-----------------------------------------------------------------------------
// Handles wifi information and return in json format
char *wifi_info_handler(void)
char* IRAM_ATTR wifi_info_handler(void)
{
wifi_ap_record_t ap_info;
wifi_sta_list_t wifi_sta_list;
Expand Down
4 changes: 2 additions & 2 deletions components/wifi_handler/wifi_init.c
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ bool has_static_ip = false;
// initiating wifi setup
void wifi_init()
{

esp_log_level_set("wifi", ESP_LOG_NONE);
wifi_event_group = xEventGroupCreate();
esp_netif_init();
ESP_ERROR_CHECK(esp_event_loop_create_default());
Expand Down Expand Up @@ -127,7 +127,7 @@ void wifi_init()
// Enable DNS (offer) for dhcp server
dhcps_offer_t dhcps_dns_value = OFFER_DNS;
dhcps_set_option_info(6, &dhcps_dns_value, sizeof(dhcps_dns_value));

ESP_ERROR_CHECK(esp_wifi_start());

if (strlen(ssid) > 0)
Expand Down

0 comments on commit 3ad0ece

Please sign in to comment.