aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorClyne Sullivan <clyne@bitgloo.com>2024-06-07 20:02:42 -0400
committerClyne Sullivan <clyne@bitgloo.com>2024-06-07 20:02:42 -0400
commit2535aace51f29c050d84ac7fcd923649d72f2ae4 (patch)
tree3c9a7e8935a06a1ce7fe833b4ed29127adc8f82e
parent6463ae4174d093f3eac4dfc28e234d105484ed0f (diff)
wip: prep code for brief execution
we do *not* have much power available
-rw-r--r--board.h8
-rw-r--r--cfg/halconf.h2
-rw-r--r--cfg/mcuconf.h2
-rw-r--r--main.cpp34
4 files changed, 24 insertions, 22 deletions
diff --git a/board.h b/board.h
index 55ef0aa..9576dba 100644
--- a/board.h
+++ b/board.h
@@ -53,11 +53,9 @@
/*
* IO lines assignments.
*/
-//#define LINE_LED_GREEN PAL_LINE(GPIOA, 12U)
-
-#define LINE_I2S_SD PAL_LINE(GPIOA, 12U) // or PB5
-#define LINE_I2S_WS PAL_LINE(GPIOB, 0U)
-#define LINE_I2S_CK PAL_LINE(GPIOA, 1U)
+#define LINE_I2S_SD PAL_LINE(GPIOA, 7U)
+#define LINE_I2S_WS PAL_LINE(GPIOA, 4U)
+#define LINE_I2S_CK PAL_LINE(GPIOA, 5U)
#define LINE_USART2_TX PAL_LINE(GPIOA, 14U)
diff --git a/cfg/halconf.h b/cfg/halconf.h
index 3a05139..164616c 100644
--- a/cfg/halconf.h
+++ b/cfg/halconf.h
@@ -142,7 +142,7 @@
* @brief Enables the SERIAL subsystem.
*/
#if !defined(HAL_USE_SERIAL) || defined(__DOXYGEN__)
-#define HAL_USE_SERIAL TRUE
+#define HAL_USE_SERIAL FALSE
#endif
/**
diff --git a/cfg/mcuconf.h b/cfg/mcuconf.h
index 3905c30..8c768d7 100644
--- a/cfg/mcuconf.h
+++ b/cfg/mcuconf.h
@@ -172,7 +172,7 @@
* SERIAL driver system settings.
*/
#define STM32_SERIAL_USE_USART1 FALSE
-#define STM32_SERIAL_USE_USART2 TRUE
+#define STM32_SERIAL_USE_USART2 FALSE
#define STM32_SERIAL_USE_LPUART1 FALSE
/*
diff --git a/main.cpp b/main.cpp
index 298c3f8..f7c8027 100644
--- a/main.cpp
+++ b/main.cpp
@@ -34,7 +34,7 @@ static constexpr auto MIC_BITS = 18u;
static constexpr auto SAMPLE_RATE = 48000u;
static constexpr unsigned I2S_BUFSIZ = 1024;
-static constexpr unsigned I2S_STRIDE = 16;
+static constexpr unsigned I2S_STRIDE = 32:
// Calculate reference amplitude value at compile time
static const auto MIC_REF_AMPL = sos_t((1 << (MIC_BITS - 1)) - 1) *
@@ -64,18 +64,19 @@ int main(void)
{
halInit();
osalSysEnable();
- osalThreadSleepMilliseconds(2000);
+ //osalThreadSleepMilliseconds(2000);
palSetPadMode(GPIOB, 7, PAL_MODE_OUTPUT_PUSHPULL);
- palSetPadMode(GPIOF, 2, PAL_MODE_UNCONNECTED);
+ palSetPad(GPIOB, 7);
+ //palSetPadMode(GPIOF, 2, PAL_MODE_UNCONNECTED);
palSetLineMode(LINE_I2S_SD, PAL_MODE_ALTERNATE(0));
palSetLineMode(LINE_I2S_WS, PAL_MODE_ALTERNATE(0));
palSetLineMode(LINE_I2S_CK, PAL_MODE_ALTERNATE(0));
- palSetLineMode(LINE_USART2_TX, PAL_MODE_ALTERNATE(1));
+ //palSetLineMode(LINE_USART2_TX, PAL_MODE_ALTERNATE(1));
- sdStart(&SD2, NULL);
- sdWrite(&SD2, (uint8_t *)"Noisemeter\n", 11);
- osalThreadSleepMilliseconds(2);
+ //sdStart(&SD2, NULL);
+ //sdWrite(&SD2, (uint8_t *)"Noisemeter\n", 11);
+ //osalThreadSleepMilliseconds(2);
i2sStart(&I2SD1, &i2sConfig);
i2sStartExchange(&I2SD1);
@@ -86,7 +87,7 @@ int main(void)
SCB->SCR |= SCB_SCR_SLEEPONEXIT_Msk;
__WFI();
- palSetPad(GPIOB, 7);
+ //palSetPad(GPIOB, 7);
const sos_t Leq_RMS = qfp_fsqrt(Leq_sum_sqr / qfp_uint2float(Leq_samples));
const sos_t Leq_dB = MIC_OFFSET_DB + MIC_REF_DB + sos_t(20.f) *
qfp_flog10(Leq_RMS / MIC_REF_AMPL);
@@ -94,12 +95,15 @@ int main(void)
Leq_samples = 0;
auto n = std::clamp(qfp_float2int(Leq_dB), 0, 999);
- strbuf[2] = n % 10 + '0'; n /= 10;
- strbuf[1] = n % 10 + '0'; n /= 10;
- strbuf[0] = n ? n + '0' : ' ';
- sdWrite(&SD2, strbuf, sizeof(strbuf));
- osalThreadSleepMilliseconds(2);
palClearPad(GPIOB, 7);
+ osalThreadSleepMicroseconds(200);
+ palSetPad(GPIOB, 7);
+ //strbuf[2] = n % 10 + '0'; n /= 10;
+ //strbuf[1] = n % 10 + '0'; n /= 10;
+ //strbuf[0] = n ? n + '0' : ' ';
+ //sdWrite(&SD2, strbuf, sizeof(strbuf));
+ //osalThreadSleepMilliseconds(2);
+ ////palClearPad(GPIOB, 7);
}
}
@@ -114,7 +118,7 @@ void i2sCallback(I2SDriver *i2s)
if (i2sReady.load())
return;
- palSetPad(GPIOB, 7);
+ //palSetPad(GPIOB, 7);
const auto halfsize = i2sBuffer.size() / 2;
const auto source = i2sBuffer.data() + (i2sIsBufferComplete(i2s) ? halfsize : 0);
auto samples = reinterpret_cast<sos_t *>(source);
@@ -135,6 +139,6 @@ void i2sCallback(I2SDriver *i2s)
i2sReady.store(true);
SCB->SCR &= ~SCB_SCR_SLEEPONEXIT_Msk;
}
- palClearPad(GPIOB, 7);
+ //palClearPad(GPIOB, 7);
}