Skip to content

Commit

Permalink
STM32F723xx
Browse files Browse the repository at this point in the history
  • Loading branch information
pschatzmann committed Jul 28, 2024
1 parent ef1c2df commit 204e349
Show file tree
Hide file tree
Showing 3 changed files with 67 additions and 74 deletions.
14 changes: 9 additions & 5 deletions src/stm32-config-i2s.h
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,13 @@
#define STM32_I2S_WITH_OBJECT
#define USE_FULL_ASSERT

#ifndef I2S_FULLDUPLEXMODE_DISABLE
# define I2S_FULLDUPLEXMODE_DISABLE (0x00000000U)
#endif
#ifndef I2S_FULLDUPLEXMODE_ENABLE
# define I2S_FULLDUPLEXMODE_ENABLE (0x00000001U)
#endif

#ifdef ARDUINO_BLACKPILL_F411CE
#define SPI_INSTANCE_FOR_I2S SPI3
#define STM_I2S_PINS \
Expand All @@ -19,7 +26,6 @@
#define PLLN 192
#define PLLR 2
#define IS_F4
#define IS_READWRITE

#endif

Expand All @@ -38,7 +44,6 @@
#define PLLN 100
#define PLLR 2
#define IS_F4
#define IS_READWRITE

#endif

Expand All @@ -53,7 +58,6 @@
{data_in, PC_11, GPIO_AF6_SPI3}\
};
#define IS_H7
#define IS_READWRITE
#endif

#ifdef STM32H743xx
Expand All @@ -67,7 +71,6 @@
{data_in, PB_4, GPIO_AF6_SPI3}\
};
#define IS_H7
#define IS_READWRITE
#endif

#ifdef STM32F723xx
Expand All @@ -76,9 +79,10 @@
{ \
{mclk, PC_7, GPIO_AF6_SPI3},\
{bck, PC_10, GPIO_AF6_SPI3},\
{ws, PA_15, GPIO_AF6_SPI3},\
{ws, PA_4, GPIO_AF6_SPI3},\
{data_out, PC_12, GPIO_AF6_SPI3},\
{data_in, PC_11, GPIO_AF6_SPI3}\
};
#define IS_F7
#define SPI_CLOCK_SOURCE LL_RCC_SPI123_CLKSOURCE_PLL1Q
#endif
23 changes: 9 additions & 14 deletions src/stm32-i2s.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
namespace stm32_i2s {

//Stm32I2sClass I2S;
Stm32I2sClass *self_I2S = nullptr;

bool stm32_i2s_is_error = false;

Expand All @@ -23,7 +24,7 @@ extern "C" void HAL_I2S_RxHalfCpltCallback(I2S_HandleTypeDef *hi2s) {
self_I2S->cb_TxRxHalfComplete(hi2s);
}

extern "C" void HAL_I2S_ErrorCallback(I2S_HandleTypeDef *hi2s) { Report_Error(); }
extern "C" void HAL_I2S_ErrorCallback(I2S_HandleTypeDef *hi2s) { Report_Error(10); }

/**
* @brief This function handles DMA1 stream0 global interrupt.
Expand Down Expand Up @@ -54,28 +55,22 @@ extern "C" void HAL_I2S_MspDeInit(I2S_HandleTypeDef *hi2s) { self_I2S->cb_HAL_I2
* @brief This function is executed in case of error occurrence.
* @retval None
*/
void Report_Error() {
void Report_Error(int no) {
stm32_i2s_is_error = true;
STM32_LOG("%s", "stm32-i2s: Error");
STM32_LOG("%s %d", "stm32-i2s: Error", no);
}

/**
* @brief Write log output to Serial
*/
void STM32_LOG(const char *fmt, ...) {
// char log_buffer[200];
// strcpy(log_buffer, "STM32: ");
// va_list arg;
// va_start(arg, fmt);
// int len = vsnprintf(log_buffer + 7, 200, fmt, arg);
// va_end(arg);
// Serial.println(log_buffer);
// Serial.flush();

// minimize progmem when not used
char log_buffer[200];
strcpy(log_buffer, "STM32: ");
va_list arg;
va_start(arg, fmt);
self_I2S->STM32_LOG(fmt, arg);
int len = vsnprintf(log_buffer + 7, 200, fmt, arg);
va_end(arg);
self_I2S->STM32_LOG(log_buffer);
va_end(arg);
}

Expand Down
Loading

0 comments on commit 204e349

Please sign in to comment.