move io config to board.c

pull/1/head
Clyne 6 months ago
parent e941048b06
commit 8745f7c294
Signed by: clyne
GPG Key ID: 3267C8EBF3F9AFC7

@ -40,6 +40,21 @@ void __early_init(void) {
* @note Add your board-specific code, if any. * @note Add your board-specific code, if any.
*/ */
void boardInit(void) { void boardInit(void) {
//palSetLineMode(LINE_LED_GREEN, PAL_MODE_OUTPUT_PUSHPULL); palSetLineMode(LINE_LED0, PAL_MODE_OUTPUT_PUSHPULL); palSetLine(LINE_LED0);
palSetLineMode(LINE_LED1, PAL_MODE_OUTPUT_PUSHPULL); palSetLine(LINE_LED1);
palSetLineMode(LINE_LED2, PAL_MODE_OUTPUT_PUSHPULL); palSetLine(LINE_LED2);
palSetLineMode(LINE_LED3, PAL_MODE_OUTPUT_PUSHPULL); palSetLine(LINE_LED3);
palSetLineMode(LINE_LED4, PAL_MODE_OUTPUT_PUSHPULL); palSetLine(LINE_LED4);
palSetLineMode(LINE_LED5, PAL_MODE_OUTPUT_PUSHPULL); palSetLine(LINE_LED5);
palSetLineMode(LINE_LED6, PAL_MODE_OUTPUT_PUSHPULL); palSetLine(LINE_LED6);
palSetLineMode(LINE_LED7, PAL_MODE_OUTPUT_PUSHPULL); palSetLine(LINE_LED7);
palSetLineMode(LINE_LED8, PAL_MODE_OUTPUT_PUSHPULL); palSetLine(LINE_LED8);
palSetLineMode(LINE_LED9, PAL_MODE_OUTPUT_PUSHPULL); palSetLine(LINE_LED9);
palSetLineMode(LINE_TP1, PAL_MODE_OUTPUT_PUSHPULL); palClearLine(LINE_TP1);
palSetLineMode(LINE_I2S_SD, PAL_MODE_ALTERNATE(0));
palSetLineMode(LINE_I2S_WS, PAL_MODE_ALTERNATE(0));
palSetLineMode(LINE_I2S_CK, PAL_MODE_ALTERNATE(0));
} }

@ -57,7 +57,7 @@
#define LINE_I2S_WS PAL_LINE(GPIOA, 4U) #define LINE_I2S_WS PAL_LINE(GPIOA, 4U)
#define LINE_I2S_CK PAL_LINE(GPIOA, 5U) #define LINE_I2S_CK PAL_LINE(GPIOA, 5U)
#define LINE_USART2_TX PAL_LINE(GPIOA, 14U) #define LINE_TP1 PAL_LINE(GPIOA, 12U)
#define LINE_LED0 PAL_LINE(GPIOB, 7U) #define LINE_LED0 PAL_LINE(GPIOB, 7U)
#define LINE_LED1 PAL_LINE(GPIOC, 14U) #define LINE_LED1 PAL_LINE(GPIOC, 14U)

@ -66,20 +66,6 @@ int main(void)
halInit(); halInit();
osalSysEnable(); osalSysEnable();
palSetLineMode(LINE_LED0, PAL_MODE_OUTPUT_PUSHPULL); palSetLine(LINE_LED0);
palSetLineMode(LINE_LED1, PAL_MODE_OUTPUT_PUSHPULL); palSetLine(LINE_LED1);
palSetLineMode(LINE_LED2, PAL_MODE_OUTPUT_PUSHPULL); palSetLine(LINE_LED2);
palSetLineMode(LINE_LED3, PAL_MODE_OUTPUT_PUSHPULL); palSetLine(LINE_LED3);
palSetLineMode(LINE_LED4, PAL_MODE_OUTPUT_PUSHPULL); palSetLine(LINE_LED4);
palSetLineMode(LINE_LED5, PAL_MODE_OUTPUT_PUSHPULL); palSetLine(LINE_LED5);
palSetLineMode(LINE_LED6, PAL_MODE_OUTPUT_PUSHPULL); palSetLine(LINE_LED6);
palSetLineMode(LINE_LED7, PAL_MODE_OUTPUT_PUSHPULL); palSetLine(LINE_LED7);
palSetLineMode(LINE_LED8, PAL_MODE_OUTPUT_PUSHPULL); palSetLine(LINE_LED8);
palSetLineMode(LINE_LED9, PAL_MODE_OUTPUT_PUSHPULL); palSetLine(LINE_LED9);
palSetLineMode(LINE_I2S_SD, PAL_MODE_ALTERNATE(0));
palSetLineMode(LINE_I2S_WS, PAL_MODE_ALTERNATE(0));
palSetLineMode(LINE_I2S_CK, PAL_MODE_ALTERNATE(0));
i2sReady.store(true); i2sReady.store(true);
i2sStart(&I2SD1, &i2sConfig); i2sStart(&I2SD1, &i2sConfig);
i2sStartExchange(&I2SD1); i2sStartExchange(&I2SD1);
@ -95,7 +81,9 @@ int main(void)
for (;;) { for (;;) {
i2sReady.store(false); i2sReady.store(false);
SCB->SCR |= SCB_SCR_SLEEPONEXIT_Msk; SCB->SCR |= SCB_SCR_SLEEPONEXIT_Msk;
//palClearLine(LINE_TP1);
__WFI(); __WFI();
//palSetLine(LINE_TP1);
const auto sum_sqr = std::exchange(Leq_sum_sqr, sos_t(0.f)); const auto sum_sqr = std::exchange(Leq_sum_sqr, sos_t(0.f));
const auto count = std::exchange(Leq_samples, 0); const auto count = std::exchange(Leq_samples, 0);
@ -148,6 +136,8 @@ void i2sCallback(I2SDriver *i2s)
if (i2sReady.load()) if (i2sReady.load())
return; return;
//palSetLine(LINE_TP1);
const auto halfsize = i2sBuffer.size() / 2; const auto halfsize = i2sBuffer.size() / 2;
const auto source = i2sBuffer.data() + (i2sIsBufferComplete(i2s) ? halfsize : 0); const auto source = i2sBuffer.data() + (i2sIsBufferComplete(i2s) ? halfsize : 0);
auto samples = reinterpret_cast<sos_t *>(source); auto samples = reinterpret_cast<sos_t *>(source);
@ -168,5 +158,7 @@ void i2sCallback(I2SDriver *i2s)
i2sReady.store(true); i2sReady.store(true);
SCB->SCR &= ~SCB_SCR_SLEEPONEXIT_Msk; SCB->SCR &= ~SCB_SCR_SLEEPONEXIT_Msk;
} }
//palClearLine(LINE_TP1);
} }

Loading…
Cancel
Save