Browse Source

Merge pull request #375 from FrankBoesing/Fixes-for-LC

Fixes for Teensy LC
dds
Paul Stoffregen 3 years ago
parent
commit
3d0cd00dc2
No account linked to committer's email address
3 changed files with 21 additions and 18 deletions
  1. +1
    -1
      analyze_fft256.cpp
  2. +1
    -1
      input_pdm.cpp
  3. +19
    -16
      utility/dspinst.h

+ 1
- 1
analyze_fft256.cpp View File



block = receiveReadOnly(); block = receiveReadOnly();
if (!block) return; if (!block) return;
#if AUDIO_BLOCK_SAMPLES == 128
#if AUDIO_BLOCK_SAMPLES == 128 && defined (__ARM_ARCH_7EM__)
if (!prevblock) { if (!prevblock) {
prevblock = block; prevblock = block;
return; return;

+ 1
- 1
input_pdm.cpp View File

* THE SOFTWARE. * THE SOFTWARE.
*/ */


#if !defined(__IMXRT1052__) && !defined(__IMXRT1062__)
#if defined(KINETISK)
#include <Arduino.h> #include <Arduino.h>
#include "input_pdm.h" #include "input_pdm.h"

+ 19
- 16
utility/dspinst.h View File

return out; return out;
} }
*/ */
#if defined (__ARM_ARCH_7EM__)
// computes (((a[31:16] + b[31:16]) << 16) | (a[15:0 + b[15:0])) (saturates) // computes (((a[31:16] + b[31:16]) << 16) | (a[15:0 + b[15:0])) (saturates)
static inline uint32_t signed_add_16_and_16(uint32_t a, uint32_t b) __attribute__((always_inline, unused)); static inline uint32_t signed_add_16_and_16(uint32_t a, uint32_t b) __attribute__((always_inline, unused));
static inline uint32_t signed_add_16_and_16(uint32_t a, uint32_t b) static inline uint32_t signed_add_16_and_16(uint32_t a, uint32_t b)
return out; return out;
} }


// Multiply two S.31 fractional integers, and return the 32 most significant
// bits after a shift left by the constant z.
// This comes from rockbox.org

static inline int32_t FRACMUL_SHL(int32_t x, int32_t y, int z)
{
int32_t t, t2;
asm ("smull %[t], %[t2], %[a], %[b]\n\t"
"mov %[t2], %[t2], asl %[c]\n\t"
"orr %[t], %[t2], %[t], lsr %[d]\n\t"
: [t] "=&r" (t), [t2] "=&r" (t2)
: [a] "r" (x), [b] "r" (y),
[c] "Mr" ((z) + 1), [d] "Mr" (31 - (z)));
return t;
}

#endif

//get Q from PSR //get Q from PSR
static inline uint32_t get_q_psr(void) __attribute__((always_inline, unused)); static inline uint32_t get_q_psr(void) __attribute__((always_inline, unused));
static inline uint32_t get_q_psr(void) static inline uint32_t get_q_psr(void)
"msr APSR_nzcvq,%0\n" : [t] "=&r" (t)::"cc"); "msr APSR_nzcvq,%0\n" : [t] "=&r" (t)::"cc");
} }


// Multiply two S.31 fractional integers, and return the 32 most significant
// bits after a shift left by the constant z.
// This comes from rockbox.org

static inline int32_t FRACMUL_SHL(int32_t x, int32_t y, int z)
{
int32_t t, t2;
asm ("smull %[t], %[t2], %[a], %[b]\n\t"
"mov %[t2], %[t2], asl %[c]\n\t"
"orr %[t], %[t2], %[t], lsr %[d]\n\t"
: [t] "=&r" (t), [t2] "=&r" (t2)
: [a] "r" (x), [b] "r" (y),
[c] "Mr" ((z) + 1), [d] "Mr" (31 - (z)));
return t;
}


#endif #endif

Loading…
Cancel
Save