From a4d9689259a7f2eb57473f7fc8e8dd7b2a8e3eaa Mon Sep 17 00:00:00 2001 From: Clyne Sullivan Date: Sat, 23 Jan 2021 15:35:08 -0500 Subject: [PATCH] cordic test: sqrt --- source/main.cpp | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/source/main.cpp b/source/main.cpp index dd98980..5afed63 100644 --- a/source/main.cpp +++ b/source/main.cpp @@ -89,6 +89,25 @@ int main() chThdCreateStatic(conversionThreadWA, sizeof(conversionThreadWA), NORMALPRIO, conversionThread, nullptr); + // TEST (success!) + /*double input = 0.25L; + + RCC->AHB2ENR |= RCC_AHB2ENR_CORDICEN; + uint32_t dummy = 0; + while (CORDIC->CSR & CORDIC_CSR_RRDY) + dummy = CORDIC->RDATA; + + CORDIC->CSR = (3 << CORDIC_CSR_PRECISION_Pos) | + (9 << CORDIC_CSR_FUNC_Pos); // 1 arg, 3 iterations, sqrt + + input *= 0x7FFFFFFF; + dummy = input; + CORDIC->WDATA = dummy; + while (!(CORDIC->CSR & CORDIC_CSR_RRDY)); + // result: + dummy = CORDIC->RDATA; // m cos() + double output = (double)dummy / 0x7FFFFFFF;*/ + main_loop(); }