esp8266/esp_mphal: Move most functions in esp_mphal.c from iRAM to iROM.
The ones that are moved out of iRAM should not need to be there, because either they call functions in iROM (eg mp_hal_stdout_tx_str), or they are only ever called from a function in iROM and not from an interrupt (eg ets_esf_free_bufs). This frees up about 800 bytes of iRAM.
This commit is contained in:
parent
caa7725642
commit
f2218c2fbd
@ -170,6 +170,7 @@ SECTIONS
|
|||||||
*modlwip.o(.literal* .text*)
|
*modlwip.o(.literal* .text*)
|
||||||
*modsocket.o(.literal* .text*)
|
*modsocket.o(.literal* .text*)
|
||||||
*modonewire.o(.literal* .text*)
|
*modonewire.o(.literal* .text*)
|
||||||
|
*esp_mphal.o(.literal* .text*)
|
||||||
|
|
||||||
/* we put as much rodata as possible in this section */
|
/* we put as much rodata as possible in this section */
|
||||||
/* note that only rodata accessed as a machine word is allowed here */
|
/* note that only rodata accessed as a machine word is allowed here */
|
||||||
|
@ -50,7 +50,7 @@ void mp_hal_init(void) {
|
|||||||
uart_attached_to_dupterm = 0;
|
uart_attached_to_dupterm = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
void mp_hal_delay_us(uint32_t us) {
|
void MP_FASTCODE(mp_hal_delay_us)(uint32_t us) {
|
||||||
uint32_t start = system_get_time();
|
uint32_t start = system_get_time();
|
||||||
while (system_get_time() - start < us) {
|
while (system_get_time() - start < us) {
|
||||||
ets_event_poll();
|
ets_event_poll();
|
||||||
@ -128,17 +128,13 @@ void mp_hal_debug_tx_strn_cooked(void *env, const char *str, uint32_t len) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
uint32_t mp_hal_ticks_ms(void) {
|
uint32_t MP_FASTCODE(mp_hal_ticks_ms)(void) {
|
||||||
// Compute milliseconds from 64-bit microsecond counter
|
// Compute milliseconds from 64-bit microsecond counter
|
||||||
system_time_update();
|
system_time_update();
|
||||||
return ((uint64_t)system_time_high_word << 32 | (uint64_t)system_time_low_word) / 1000;
|
return ((uint64_t)system_time_high_word << 32 | (uint64_t)system_time_low_word) / 1000;
|
||||||
}
|
}
|
||||||
|
|
||||||
uint32_t mp_hal_ticks_us(void) {
|
void MP_FASTCODE(mp_hal_delay_ms)(uint32_t delay) {
|
||||||
return system_get_time();
|
|
||||||
}
|
|
||||||
|
|
||||||
void mp_hal_delay_ms(uint32_t delay) {
|
|
||||||
mp_hal_delay_us(delay * 1000);
|
mp_hal_delay_us(delay * 1000);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -152,7 +148,8 @@ void __assert_func(const char *file, int line, const char *func, const char *exp
|
|||||||
mp_raise_msg(&mp_type_AssertionError, MP_ERROR_TEXT("C-level assert"));
|
mp_raise_msg(&mp_type_AssertionError, MP_ERROR_TEXT("C-level assert"));
|
||||||
}
|
}
|
||||||
|
|
||||||
void mp_hal_signal_input(void) {
|
// May be called by uart0_rx_intr_handler.
|
||||||
|
void MP_FASTCODE(mp_hal_signal_input)(void) {
|
||||||
#if MICROPY_REPL_EVENT_DRIVEN
|
#if MICROPY_REPL_EVENT_DRIVEN
|
||||||
system_os_post(UART_TASK_ID, 0, 0);
|
system_os_post(UART_TASK_ID, 0, 0);
|
||||||
#endif
|
#endif
|
||||||
|
@ -24,6 +24,7 @@
|
|||||||
* THE SOFTWARE.
|
* THE SOFTWARE.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
#include "user_interface.h"
|
||||||
#include "py/ringbuf.h"
|
#include "py/ringbuf.h"
|
||||||
#include "lib/utils/interrupt_char.h"
|
#include "lib/utils/interrupt_char.h"
|
||||||
#include "xtirq.h"
|
#include "xtirq.h"
|
||||||
@ -46,7 +47,10 @@ extern int uart_attached_to_dupterm;
|
|||||||
void mp_hal_init(void);
|
void mp_hal_init(void);
|
||||||
void mp_hal_rtc_init(void);
|
void mp_hal_rtc_init(void);
|
||||||
|
|
||||||
uint32_t mp_hal_ticks_us(void);
|
__attribute__((always_inline)) static inline uint32_t mp_hal_ticks_us(void) {
|
||||||
|
return system_get_time();
|
||||||
|
}
|
||||||
|
|
||||||
__attribute__((always_inline)) static inline uint32_t mp_hal_ticks_cpu(void) {
|
__attribute__((always_inline)) static inline uint32_t mp_hal_ticks_cpu(void) {
|
||||||
uint32_t ccount;
|
uint32_t ccount;
|
||||||
__asm__ __volatile__ ("rsr %0,ccount" : "=a" (ccount));
|
__asm__ __volatile__ ("rsr %0,ccount" : "=a" (ccount));
|
||||||
|
Loading…
Reference in New Issue
Block a user