[MP45DT02] move away from I2S module in need to free up ETH hardware
This commit is contained in:
parent
cae7fe1ed2
commit
6b38f3945e
|
@ -4,7 +4,10 @@
|
||||||
|
|
||||||
#define SAMPLE_AMOUNT 256
|
#define SAMPLE_AMOUNT 256
|
||||||
|
|
||||||
//extern I2S_HandleTypeDef hi2s2;
|
struct TestResult {
|
||||||
|
unsigned int lo_present:1;
|
||||||
|
unsigned int hi_present:1;
|
||||||
|
};
|
||||||
|
|
||||||
int MP45DT02_run_test(void)
|
int MP45DT02_run_test(void)
|
||||||
{
|
{
|
||||||
|
@ -14,66 +17,67 @@ int MP45DT02_run_test(void)
|
||||||
uint16_t sample_buffer[SAMPLE_AMOUNT];
|
uint16_t sample_buffer[SAMPLE_AMOUNT];
|
||||||
|
|
||||||
for (size_t t = 0; t < 5; t++) {
|
for (size_t t = 0; t < 5; t++) {
|
||||||
//HAL_I2S_Receive(&hi2s2, sample_buffer, SAMPLE_AMOUNT, 1000);
|
// gather samples
|
||||||
|
register unsigned int reset_value = (GPIO_PIN_10 << 16);
|
||||||
|
|
||||||
for (size_t i = 0; i < SAMPLE_AMOUNT; i++) {
|
for (size_t i = 0; i < SAMPLE_AMOUNT; i++) {
|
||||||
sample_buffer[i] = 0;
|
sample_buffer[i] = 0;
|
||||||
for (size_t j = 0; j < 16; j++) {
|
for (size_t j = 0; j < 16; j++) {
|
||||||
HAL_GPIO_WritePin(GPIOB, GPIO_PIN_10, GPIO_PIN_SET);
|
for (int k = 0; k < 16; k++) {
|
||||||
asm("nop");
|
GPIOB->BSRR = reset_value;
|
||||||
asm("nop");
|
asm("nop");
|
||||||
|
asm("nop");
|
||||||
|
asm("nop");
|
||||||
|
asm("nop");
|
||||||
|
asm("nop");
|
||||||
|
asm("nop");
|
||||||
|
asm("nop");
|
||||||
|
asm("nop");
|
||||||
|
asm("nop");
|
||||||
|
asm("nop");
|
||||||
|
asm("nop");
|
||||||
|
GPIOB->BSRR = GPIO_PIN_10;
|
||||||
|
}
|
||||||
sample_buffer[i] <<= 1;
|
sample_buffer[i] <<= 1;
|
||||||
sample_buffer[i] |= HAL_GPIO_ReadPin(GPIOC, GPIO_PIN_3);
|
sample_buffer[i] |= (GPIOC->IDR & (1 << 3)) >> 3;
|
||||||
HAL_GPIO_WritePin(GPIOB, GPIO_PIN_10, GPIO_PIN_RESET);
|
|
||||||
asm("nop");
|
|
||||||
asm("nop");
|
|
||||||
asm("nop");
|
|
||||||
asm("nop");
|
|
||||||
asm("nop");
|
|
||||||
asm("nop");
|
|
||||||
asm("nop");
|
|
||||||
asm("nop");
|
|
||||||
asm("nop");
|
|
||||||
asm("nop");
|
|
||||||
asm("nop");
|
|
||||||
asm("nop");
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
struct TestResult res = {};
|
||||||
|
|
||||||
|
// look for zeros
|
||||||
for (size_t i = 0; i < SAMPLE_AMOUNT / 2; i++)
|
for (size_t i = 0; i < SAMPLE_AMOUNT / 2; i++)
|
||||||
if (((uint32_t *) sample_buffer)[i]) {
|
if (~((uint32_t *) sample_buffer)[i]) {
|
||||||
DISPLAY_CLEAR;
|
res.lo_present = 1;
|
||||||
display_write_data_seq("MP45DT02 Mic");
|
break;
|
||||||
|
}
|
||||||
if (!t) {
|
|
||||||
DISPLAY_SET_CURSOR(1, 4);
|
// look for ones
|
||||||
display_write_data_seq("OK");
|
for (size_t i = 0; i < SAMPLE_AMOUNT / 2; i++)
|
||||||
} else {
|
if (((uint32_t *) sample_buffer)[i]) {
|
||||||
DISPLAY_SET_CURSOR(1, 4);
|
res.hi_present = 1;
|
||||||
display_write_data_byte('0' + t);
|
break;
|
||||||
display_write_data_seq(" 0 samples");
|
|
||||||
}
|
|
||||||
|
|
||||||
return 0;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// if ended up here, then no samples equaled to 1; that is not a good sign
|
|
||||||
DISPLAY_CLEAR;
|
DISPLAY_CLEAR;
|
||||||
display_write_data_seq("MP45DT02 Mic");
|
display_write_data_seq("MP45DT02 Mic");
|
||||||
|
|
||||||
|
if (t) {
|
||||||
|
DISPLAY_SET_CURSOR(1, 14);
|
||||||
|
display_write_data_byte('T');
|
||||||
|
display_write_data_byte('0' + t + 1);
|
||||||
|
}
|
||||||
|
|
||||||
DISPLAY_SET_CURSOR(1, 4);
|
DISPLAY_SET_CURSOR(1, 4);
|
||||||
display_write_data_byte('1' + t);
|
if (res.lo_present & res.hi_present) {
|
||||||
display_write_data_seq("/5: all zeros");
|
display_write_data_seq("OK");
|
||||||
|
return 0;
|
||||||
HAL_Delay(1000);
|
} else if (res.lo_present) {
|
||||||
|
display_write_data_seq("ALWAYS LO");
|
||||||
|
} else if (res.hi_present) {
|
||||||
|
display_write_data_seq("ALWAYS HI");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// t = 5, not a single 1 was recorded; microphone might be broken
|
|
||||||
DISPLAY_CLEAR;
|
|
||||||
display_write_data_seq("MP45DT02 Mic");
|
|
||||||
|
|
||||||
DISPLAY_SET_CURSOR(1, 4);
|
|
||||||
display_write_data_seq("NO ONES");
|
|
||||||
|
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
|
@ -598,11 +598,11 @@ static void MX_GPIO_Init(void)
|
||||||
GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_LOW;
|
GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_LOW;
|
||||||
HAL_GPIO_Init(GPIOE, &GPIO_InitStruct);
|
HAL_GPIO_Init(GPIOE, &GPIO_InitStruct);
|
||||||
|
|
||||||
/*Configure GPIO pins : PB10 PB7 */
|
/*Configure GPIO pin : PB10 */
|
||||||
GPIO_InitStruct.Pin = GPIO_PIN_10|GPIO_PIN_7;
|
GPIO_InitStruct.Pin = GPIO_PIN_10;
|
||||||
GPIO_InitStruct.Mode = GPIO_MODE_OUTPUT_PP;
|
GPIO_InitStruct.Mode = GPIO_MODE_OUTPUT_PP;
|
||||||
GPIO_InitStruct.Pull = GPIO_NOPULL;
|
GPIO_InitStruct.Pull = GPIO_NOPULL;
|
||||||
GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_LOW;
|
GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_HIGH;
|
||||||
HAL_GPIO_Init(GPIOB, &GPIO_InitStruct);
|
HAL_GPIO_Init(GPIOB, &GPIO_InitStruct);
|
||||||
|
|
||||||
/*Configure GPIO pin : PD11 */
|
/*Configure GPIO pin : PD11 */
|
||||||
|
@ -621,6 +621,13 @@ static void MX_GPIO_Init(void)
|
||||||
GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_LOW;
|
GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_LOW;
|
||||||
HAL_GPIO_Init(GPIOD, &GPIO_InitStruct);
|
HAL_GPIO_Init(GPIOD, &GPIO_InitStruct);
|
||||||
|
|
||||||
|
/*Configure GPIO pin : PB7 */
|
||||||
|
GPIO_InitStruct.Pin = GPIO_PIN_7;
|
||||||
|
GPIO_InitStruct.Mode = GPIO_MODE_OUTPUT_PP;
|
||||||
|
GPIO_InitStruct.Pull = GPIO_NOPULL;
|
||||||
|
GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_LOW;
|
||||||
|
HAL_GPIO_Init(GPIOB, &GPIO_InitStruct);
|
||||||
|
|
||||||
/* USER CODE BEGIN MX_GPIO_Init_2 */
|
/* USER CODE BEGIN MX_GPIO_Init_2 */
|
||||||
/* USER CODE END MX_GPIO_Init_2 */
|
/* USER CODE END MX_GPIO_Init_2 */
|
||||||
}
|
}
|
||||||
|
|
|
@ -99,6 +99,8 @@ PA7.Mode=RMII
|
||||||
PA7.Signal=ETH_CRS_DV
|
PA7.Signal=ETH_CRS_DV
|
||||||
PB1.Locked=true
|
PB1.Locked=true
|
||||||
PB1.Signal=ADCx_IN9
|
PB1.Signal=ADCx_IN9
|
||||||
|
PB10.GPIOParameters=GPIO_Speed
|
||||||
|
PB10.GPIO_Speed=GPIO_SPEED_FREQ_HIGH
|
||||||
PB10.Locked=true
|
PB10.Locked=true
|
||||||
PB10.Signal=GPIO_Output
|
PB10.Signal=GPIO_Output
|
||||||
PB11.Mode=RMII
|
PB11.Mode=RMII
|
||||||
|
|
Loading…
Reference in New Issue