Skip to content
Snippets Groups Projects
Unverified Commit cb09092c authored by Kevin "Bear Puncher" Weiss's avatar Kevin "Bear Puncher" Weiss Committed by GitHub
Browse files

Merge pull request #10125 from gschorcht/esp8266_cpu_freq

cpu/esp8266: cpu frequency settings feature added
parents d928ce68 0d796d6e
No related branches found
No related tags found
No related merge requests found
...@@ -5,6 +5,13 @@ ...@@ -5,6 +5,13 @@
* General Public License v2.1. See the file LICENSE in the top level * General Public License v2.1. See the file LICENSE in the top level
* directory for more details. * directory for more details.
*/ */
/**
* @ingroup cpu_esp8266
* @brief Default configurations required by the SDK
* @author Gunar Schorcht <gunar@schorcht.net>
* @file
* @{
*/
#ifndef USER_CONFIG_H #ifndef USER_CONFIG_H
#define USER_CONFIG_H #define USER_CONFIG_H
...@@ -13,10 +20,17 @@ ...@@ -13,10 +20,17 @@
extern "C" { extern "C" {
#endif #endif
/* This file is just to satisfy SDK */ /**
* @brief Default CPU frequency in MHz.
* Possible values are 80 and 160.
*/
#ifndef ESP8266_CPU_FREQUENCY
#define ESP8266_CPU_FREQUENCY 80
#endif
#ifdef __cplusplus #ifdef __cplusplus
} }
#endif #endif
#endif /* USER_CONFIG_H */ #endif /* USER_CONFIG_H */
/** @} */
...@@ -129,6 +129,19 @@ void system_restart(void) ...@@ -129,6 +129,19 @@ void system_restart(void)
__asm__ volatile (" call0 0x40000080 "); __asm__ volatile (" call0 0x40000080 ");
} }
extern bool system_update_cpu_freq(uint8 freq)
{
if (freq == 160) {
DPORT.CPU_CLOCK |= DPORT_CPU_CLOCK_X2;
ets_update_cpu_frequency(160);
}
else {
DPORT.CPU_CLOCK &= ~DPORT_CPU_CLOCK_X2;
ets_update_cpu_frequency(80);
}
return true;
}
/** /**
* Following code is completly or at least partially from * Following code is completly or at least partially from
* https://github.com/pvvx/esp8266web * https://github.com/pvvx/esp8266web
......
...@@ -42,13 +42,13 @@ extern "C" { ...@@ -42,13 +42,13 @@ extern "C" {
#define system_get_time phy_get_mactime #define system_get_time phy_get_mactime
#define system_get_chip_id() (((DPORT.OTP_MAC1 & 0xffff) << 8) + ((DPORT.OTP_MAC0 >> 24) & 0xff)) #define system_get_chip_id() (((DPORT.OTP_MAC1 & 0xffff) << 8) + ((DPORT.OTP_MAC0 >> 24) & 0xff))
#define system_get_cpu_freq ets_get_cpu_frequency #define system_get_cpu_freq ets_get_cpu_frequency
/* TODO #define system_update_cpu_freq ets_update_cpu_frequency */
extern int os_printf_plus (const char* format, ...); extern int os_printf_plus (const char* format, ...);
extern void system_deep_sleep (uint32_t time_in_us); extern void system_deep_sleep (uint32_t time_in_us);
extern uint8_t system_get_checksum(uint8_t *ptr, uint32_t len); extern uint8_t system_get_checksum(uint8_t *ptr, uint32_t len);
extern void system_restart (void); extern void system_restart (void);
extern bool system_update_cpu_freq(uint8 freq);
extern bool system_rtc_mem_read(uint32_t src_addr, void *des_addr, uint32_t save_size); extern bool system_rtc_mem_read(uint32_t src_addr, void *des_addr, uint32_t save_size);
extern bool system_rtc_mem_write(uint32_t src_addr, void *des_addr, uint32_t save_size); extern bool system_rtc_mem_write(uint32_t src_addr, void *des_addr, uint32_t save_size);
......
...@@ -170,8 +170,8 @@ void IRAM user_init (void) ...@@ -170,8 +170,8 @@ void IRAM user_init (void)
syscalls_init (); syscalls_init ();
thread_isr_stack_init (); thread_isr_stack_init ();
/* run system in high performance mode */ /* set system frequency */
system_update_cpu_freq(160); system_update_cpu_freq(ESP8266_CPU_FREQUENCY);
/* reinit system timer as microsecond timer */ /* reinit system timer as microsecond timer */
system_timer_reinit (); system_timer_reinit ();
...@@ -191,6 +191,7 @@ void IRAM user_init (void) ...@@ -191,6 +191,7 @@ void IRAM user_init (void)
#include "esp/dport_regs.h" #include "esp/dport_regs.h"
#include "esp/phy_info.h" #include "esp/phy_info.h"
#include "esp/spiflash.h" #include "esp/spiflash.h"
#include "user_config.h"
/** /**
* @brief Defines the structure of the file header in SPI flash * @brief Defines the structure of the file header in SPI flash
...@@ -661,8 +662,8 @@ void __attribute__((noreturn)) IRAM cpu_user_start (void) ...@@ -661,8 +662,8 @@ void __attribute__((noreturn)) IRAM cpu_user_start (void)
/** }@ */ /** }@ */
/* run system in high performance mode */ /* set system frequency */
/* TODO system_update_cpu_freq(160); */ system_update_cpu_freq(ESP8266_CPU_FREQUENCY);
/* PHASE 3: start RIOT-OS kernel */ /* PHASE 3: start RIOT-OS kernel */
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment