Skip to content

Commit

Permalink
machine_bitstream: Add linker file for machine_bitstream IRAM placement.
Browse files Browse the repository at this point in the history
Now, the file machine_bitstream.c is identical for esp32, rp2
and mimxrt.
  • Loading branch information
robert-hh committed Sep 17, 2021
1 parent 9f3e020 commit 933cc85
Show file tree
Hide file tree
Showing 5 changed files with 10 additions and 10 deletions.
4 changes: 1 addition & 3 deletions ports/esp32/machine_bitstream.c
Original file line number Diff line number Diff line change
Expand Up @@ -31,9 +31,7 @@

#if MICROPY_PY_MACHINE_BITSTREAM

#define NS_TICKS_OVERHEAD (6)

void IRAM_ATTR machine_bitstream_high_low(mp_hal_pin_obj_t pin, uint32_t *timing_ns, const uint8_t *buf, size_t len) {
void machine_bitstream_high_low(mp_hal_pin_obj_t pin, uint32_t *timing_ns, const uint8_t *buf, size_t len) {
uint32_t fcpu_mhz = mp_hal_get_cpu_freq() / 1000000;
// Convert ns to cpu ticks [high_time_0, period_0, high_time_1, period_1].
for (size_t i = 0; i < 4; ++i) {
Expand Down
1 change: 1 addition & 0 deletions ports/esp32/main/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -164,6 +164,7 @@ idf_component_register(
${CMAKE_BINARY_DIR}
REQUIRES
${IDF_COMPONENTS}
LDFRAGMENTS "linker.lf"
)

# Set the MicroPython target as the current (main) IDF component target.
Expand Down
4 changes: 4 additions & 0 deletions ports/esp32/main/linker.lf
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
[mapping:msin]
archive: libmain.a
entries:
machine_bitstream (noflash)
9 changes: 3 additions & 6 deletions ports/esp32/mphalport.h
Original file line number Diff line number Diff line change
Expand Up @@ -61,19 +61,16 @@ __attribute__((always_inline)) static inline uint32_t mp_hal_ticks_cpu(void) {
}

#define mp_hal_ticks_cpu_init(void)

#define mp_hal_ticks_cpu_reset mp_hal_ticks_cpu
#define MP_HAL_BITSTREAM_NS_OVERHEAD (6)

static inline mp_uint_t mp_hal_get_cpu_freq(void) {
return ets_get_cpu_frequency() * 1000000;
}

#define MP_HAL_BITSTREAM_NS_OVERHEAD (6)

void mp_hal_delay_us(uint32_t);
#define mp_hal_delay_us_fast(us) ets_delay_us(us)
void mp_hal_set_interrupt_char(int c);
uint32_t mp_hal_get_cpu_freq(void);

#define mp_hal_quiet_timing_enter() MICROPY_BEGIN_ATOMIC_SECTION()
#define mp_hal_quiet_timing_exit(irq_state) MICROPY_END_ATOMIC_SECTION(irq_state)
Expand Down Expand Up @@ -123,7 +120,7 @@ static inline void mp_hal_pin_low(mp_hal_pin_obj_t pin) {
#endif
{
GPIO_REG_WRITE(GPIO_OUT_W1TC_REG, 1 << pin);
}
}
}

static inline void mp_hal_pin_high(mp_hal_pin_obj_t pin) {
Expand All @@ -134,7 +131,7 @@ static inline void mp_hal_pin_high(mp_hal_pin_obj_t pin) {
#endif
{
GPIO_REG_WRITE(GPIO_OUT_W1TS_REG, 1 << pin);
}
}
}

#endif // INCLUDED_MPHALPORT_H
2 changes: 1 addition & 1 deletion ports/mimxrt/mphalport.h
Original file line number Diff line number Diff line change
Expand Up @@ -82,11 +82,11 @@ static inline mp_uint_t mp_hal_ticks_cpu(void) {
}

#define mp_hal_ticks_cpu_reset mp_hal_ticks_cpu
#define MP_HAL_BITSTREAM_NS_OVERHEAD (6)

static inline mp_uint_t mp_hal_get_cpu_freq(void) {
return CLOCK_GetCpuClkFreq();
}

#define MP_HAL_BITSTREAM_NS_OVERHEAD (6)

#endif // MICROPY_INCLUDED_MIMXRT_MPHALPORT_H

0 comments on commit 933cc85

Please sign in to comment.