Skip to content

Commit a7d6ff5

Browse files
committed
boolean to bool
1 parent ebea396 commit a7d6ff5

File tree

3 files changed

+23
-12
lines changed

3 files changed

+23
-12
lines changed

src/main.c

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@
3434

3535
/* Private typedef -----------------------------------------------------------*/
3636
/* USER CODE BEGIN PTD */
37-
boolean is_error;
37+
bool is_error;
3838
/* USER CODE END PTD */
3939

4040
/* Private define ------------------------------------------------------------*/
@@ -107,7 +107,9 @@ void SystemClock_Config(void)
107107
RCC_OscInitStruct.HSEState = RCC_HSE_ON;
108108
RCC_OscInitStruct.PLL.PLLState = RCC_PLL_ON;
109109
RCC_OscInitStruct.PLL.PLLSource = RCC_PLLSOURCE_HSE;
110+
#if USE_PLLI2SM
110111
RCC_OscInitStruct.PLL.PLLM = 15;
112+
#endif
111113
RCC_OscInitStruct.PLL.PLLN = 144;
112114
RCC_OscInitStruct.PLL.PLLP = RCC_PLLP_DIV4;
113115
RCC_OscInitStruct.PLL.PLLQ = 5;
@@ -232,7 +234,7 @@ static void MX_I2S3_Init_Ext(I2SSettingsSTM32 *settings)
232234
#undef SystemClock_Config
233235

234236
/// Starts the i2s processing
235-
boolean i2s_begin(I2SSettingsSTM32 *settings)
237+
bool i2s_begin(I2SSettingsSTM32 *settings)
236238
{
237239
// default values
238240
if (settings->mode ==0){
@@ -262,10 +264,10 @@ boolean i2s_begin(I2SSettingsSTM32 *settings)
262264
return !is_error;
263265
}
264266

265-
boolean startI2STransmit(I2SSettingsSTM32 *settings, void (*readToTransmit)(uint8_t *buffer, uint16_t byteCount), uint16_t buffer_size) {
267+
bool startI2STransmit(I2SSettingsSTM32 *settings, void (*readToTransmit)(uint8_t *buffer, uint16_t byteCount), uint16_t buffer_size) {
266268
readToTransmitCB = readToTransmit;
267269
void *dma_buffer_tx = calloc(1, buffer_size);
268-
boolean result = true;
270+
bool result = true;
269271
if (!i2s_begin(settings)){
270272
return false;
271273
}
@@ -278,8 +280,8 @@ boolean startI2STransmit(I2SSettingsSTM32 *settings, void (*readToTransmit)(uint
278280
return result;
279281
}
280282

281-
boolean startI2SReceive(I2SSettingsSTM32 *settings, void (*writeFromReceive)(uint8_t *buffer, uint16_t byteCount),uint16_t buffer_size) {
282-
boolean result = true;
283+
bool startI2SReceive(I2SSettingsSTM32 *settings, void (*writeFromReceive)(uint8_t *buffer, uint16_t byteCount),uint16_t buffer_size) {
284+
bool result = true;
283285
writeFromReceiveCB = writeFromReceive;
284286
void *dma_buffer_rx = calloc(1, buffer_size);
285287
if (!i2s_begin(settings)){
@@ -294,8 +296,8 @@ boolean startI2SReceive(I2SSettingsSTM32 *settings, void (*writeFromReceive)(uin
294296
return result;
295297
}
296298

297-
boolean startI2STransmitReceive(I2SSettingsSTM32 *settings, void (*readToTransmit)(uint8_t *buffer, uint16_t byteCount), void (*writeFromReceive)(uint8_t *buffer, uint16_t byteCount), uint16_t buffer_size) {
298-
boolean result = true;
299+
bool startI2STransmitReceive(I2SSettingsSTM32 *settings, void (*readToTransmit)(uint8_t *buffer, uint16_t byteCount), void (*writeFromReceive)(uint8_t *buffer, uint16_t byteCount), uint16_t buffer_size) {
300+
bool result = true;
299301
readToTransmitCB = readToTransmit;
300302
void *dma_buffer_tx = calloc(1, buffer_size);
301303
writeFromReceiveCB = writeFromReceive;

src/main.h

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,13 @@
1717
******************************************************************************
1818
*/
1919

20+
#ifdef STM32F407xx
21+
#define USE_PLLI2SM false
22+
#else
23+
#define USE_PLLI2SM true
24+
#endif
25+
26+
2027
/** @addtogroup I2S
2128
* @{
2229
*/
@@ -47,7 +54,7 @@ extern "C" {
4754
/* Exported types ------------------------------------------------------------*/
4855
/* USER CODE BEGIN ET */
4956
#ifndef __cplusplus
50-
typedef int boolean;
57+
typedef _Bool bool;
5158
#endif
5259
/* USER CODE END ET */
5360

@@ -77,11 +84,11 @@ typedef struct I2SSettingsSTM32 {
7784
} I2SSettingsSTM32;
7885

7986
/// Start to transmit I2S data
80-
boolean startI2STransmit(I2SSettingsSTM32 *settings,void (*readToTransmitCB)(uint8_t *buffer, uint16_t byteCount), uint16_t buffer_size);
87+
bool startI2STransmit(I2SSettingsSTM32 *settings,void (*readToTransmitCB)(uint8_t *buffer, uint16_t byteCount), uint16_t buffer_size);
8188
/// Start to receive I2S data
82-
boolean startI2SReceive(I2SSettingsSTM32 *settings,void (*writeFromReceiveCB)(uint8_t *buffer, uint16_t byteCount), uint16_t buffer_size);
89+
bool startI2SReceive(I2SSettingsSTM32 *settings,void (*writeFromReceiveCB)(uint8_t *buffer, uint16_t byteCount), uint16_t buffer_size);
8390
/// Start to receive and transmit I2S data
84-
boolean startI2STransmitReceive(I2SSettingsSTM32 *settings, void (*readToTransmit)(uint8_t *buffer, uint16_t byteCount), void (*writeFromReceive)(uint8_t *buffer, uint16_t byteCount), uint16_t buffer_size);
91+
bool startI2STransmitReceive(I2SSettingsSTM32 *settings, void (*readToTransmit)(uint8_t *buffer, uint16_t byteCount), void (*writeFromReceive)(uint8_t *buffer, uint16_t byteCount), uint16_t buffer_size);
8592
/// Stop I2S processing
8693
void stopI2S();
8794

src/stm32f4xx_hal_msp.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -109,7 +109,9 @@ void HAL_I2S_MspInit(I2S_HandleTypeDef* hi2s)
109109
*/
110110
PeriphClkInitStruct.PeriphClockSelection = RCC_PERIPHCLK_I2S;
111111
PeriphClkInitStruct.PLLI2S.PLLI2SN = 192;
112+
#if USE_PLLI2SM
112113
PeriphClkInitStruct.PLLI2S.PLLI2SM = 16;
114+
#endif
113115
PeriphClkInitStruct.PLLI2S.PLLI2SR = 2;
114116
if (HAL_RCCEx_PeriphCLKConfig(&PeriphClkInitStruct) != HAL_OK)
115117
{

0 commit comments

Comments
 (0)