|
|
@ -118,22 +118,22 @@ return s;
|
|
|
|
)cpp";
|
|
|
|
)cpp";
|
|
|
|
static std::string file_header_l4 = R"cpp(
|
|
|
|
static std::string file_header_l4 = R"cpp(
|
|
|
|
#include <cstdint>
|
|
|
|
#include <cstdint>
|
|
|
|
#include <span>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
using Sample = uint16_t;
|
|
|
|
using Sample = uint16_t;
|
|
|
|
using Samples = std::span<Sample, $0>;
|
|
|
|
using Samples = Sample[$0];
|
|
|
|
|
|
|
|
constexpr unsigned int SIZE = $0;
|
|
|
|
|
|
|
|
|
|
|
|
Sample *process_data(Samples samples);
|
|
|
|
Sample *process_data(Samples samples);
|
|
|
|
extern "C" void process_data_entry()
|
|
|
|
extern "C" void process_data_entry()
|
|
|
|
{
|
|
|
|
{
|
|
|
|
Sample *samples;
|
|
|
|
Sample *samples;
|
|
|
|
asm("mov %0, r0" : "=r" (samples));
|
|
|
|
asm("mov %0, r0" : "=r" (samples));
|
|
|
|
process_data(Samples(samples, $0));
|
|
|
|
process_data(samples);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
static float PI = 3.14159265358979L;
|
|
|
|
static inline float PI = 3.14159265358979L;
|
|
|
|
__attribute__((naked))
|
|
|
|
__attribute__((naked))
|
|
|
|
auto sin(float x) {
|
|
|
|
static inline auto sin(float x) {
|
|
|
|
asm("vmov.f32 r1, s0;"
|
|
|
|
asm("vmov.f32 r1, s0;"
|
|
|
|
"eor r0, r0;"
|
|
|
|
"eor r0, r0;"
|
|
|
|
"svc 1;"
|
|
|
|
"svc 1;"
|
|
|
@ -142,7 +142,7 @@ asm("vmov.f32 r1, s0;"
|
|
|
|
return 0;
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
__attribute__((naked))
|
|
|
|
__attribute__((naked))
|
|
|
|
auto cos(float x) {
|
|
|
|
static inline auto cos(float x) {
|
|
|
|
asm("vmov.f32 r1, s0;"
|
|
|
|
asm("vmov.f32 r1, s0;"
|
|
|
|
"mov r0, #1;"
|
|
|
|
"mov r0, #1;"
|
|
|
|
"svc 1;"
|
|
|
|
"svc 1;"
|
|
|
@ -151,7 +151,7 @@ asm("vmov.f32 r1, s0;"
|
|
|
|
return 0;
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
__attribute__((naked))
|
|
|
|
__attribute__((naked))
|
|
|
|
auto tan(float x) {
|
|
|
|
static inline auto tan(float x) {
|
|
|
|
asm("vmov.f32 r1, s0;"
|
|
|
|
asm("vmov.f32 r1, s0;"
|
|
|
|
"mov r0, #2;"
|
|
|
|
"mov r0, #2;"
|
|
|
|
"svc 1;"
|
|
|
|
"svc 1;"
|
|
|
@ -160,24 +160,24 @@ asm("vmov.f32 r1, s0;"
|
|
|
|
return 0;
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
__attribute__((naked))
|
|
|
|
__attribute__((naked))
|
|
|
|
auto sqrt(float) {
|
|
|
|
static inline auto sqrt(float) {
|
|
|
|
asm("vsqrt.f32 s0, s0; bx lr");
|
|
|
|
asm("vsqrt.f32 s0, s0; bx lr");
|
|
|
|
return 0;
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
auto readpot1() {
|
|
|
|
static inline auto param1() {
|
|
|
|
Sample s;
|
|
|
|
Sample s;
|
|
|
|
asm("push {r4-r11}; eor r0, r0; svc 3; mov %0, r0; pop {r4-r11}" : "=r"(s));
|
|
|
|
asm("eor r0, r0; svc 3; mov %0, r0" : "=r" (s) :: "r0");
|
|
|
|
return s;
|
|
|
|
return s;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
auto readpot2() {
|
|
|
|
static inline auto param2() {
|
|
|
|
Sample s;
|
|
|
|
Sample s;
|
|
|
|
asm("push {r4-r11}; mov r0, #1; svc 3; mov %0, r0; pop {r4-r11}" : "=r"(s));
|
|
|
|
asm("mov r0, #1; svc 3; mov %0, r0" : "=r" (s) :: "r0");
|
|
|
|
return s;
|
|
|
|
return s;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
//void puts(const char *s) {
|
|
|
|
//static inline void puts(const char *s) {
|
|
|
|
// 's' will already be in r0.
|
|
|
|
// // 's' will already be in r0.
|
|
|
|
// asm("push {r4-r6}; svc 4; pop {r4-r6}");
|
|
|
|
// asm("push {r4-r6}; svc 4; pop {r4-r6}");
|
|
|
|
//}
|
|
|
|
//}
|
|
|
|
|
|
|
|
|
|
|
@ -189,7 +189,7 @@ return s;
|
|
|
|
static std::string file_content =
|
|
|
|
static std::string file_content =
|
|
|
|
R"cpp(Sample* process_data(Samples samples)
|
|
|
|
R"cpp(Sample* process_data(Samples samples)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
return samples.data();
|
|
|
|
return samples;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
)cpp";
|
|
|
|
)cpp";
|
|
|
|
|
|
|
|
|
|
|
|