Compare commits
No commits in common. "master" and "KSZ8081RND" have entirely different histories.
master
...
KSZ8081RND
@ -31,11 +31,8 @@ static size_t dht11_read_value(struct DHT11_Data *data)
|
|||||||
|
|
||||||
register uint32_t read_register = 0;
|
register uint32_t read_register = 0;
|
||||||
|
|
||||||
HAL_TIM_Base_Start(&htim2);
|
|
||||||
|
|
||||||
// try to trigger the output
|
|
||||||
for (int t = 0; t < 10; t++) {
|
|
||||||
TIM2->CNT = 0;
|
TIM2->CNT = 0;
|
||||||
|
HAL_TIM_Base_Start(&htim2);
|
||||||
|
|
||||||
GPIOD->MODER |= 0x00400000; // enable output mode on GPIOD 11
|
GPIOD->MODER |= 0x00400000; // enable output mode on GPIOD 11
|
||||||
|
|
||||||
@ -51,14 +48,12 @@ static size_t dht11_read_value(struct DHT11_Data *data)
|
|||||||
// reading pull down from DHT11
|
// reading pull down from DHT11
|
||||||
SKIP_LOW;
|
SKIP_LOW;
|
||||||
|
|
||||||
// waiting for response
|
// waiting for 500ms max
|
||||||
for (size_t i = TIM2->CNT + (200000 << 4); TIM2->CNT <= i; )
|
for (size_t i = TIM2->CNT + (500000 << 4); TIM2->CNT <= i; )
|
||||||
if (!(GPIOD->IDR & 0x0800))
|
if (!(GPIOD->IDR & 0x0800))
|
||||||
goto reading_data;
|
goto reading_data;
|
||||||
}
|
|
||||||
|
|
||||||
// if didn't exit through goto, then DHT11 awaiting has timed out
|
// if didn't exit through goto, then DHT11 awaiting has timed out
|
||||||
HAL_TIM_Base_Stop(&htim2);
|
|
||||||
return 1;
|
return 1;
|
||||||
|
|
||||||
reading_data:
|
reading_data:
|
||||||
|
@ -98,7 +98,6 @@ int ReadRegister(uint32_t reg, uint16_t *value)
|
|||||||
|
|
||||||
ETH->MACMIIAR = tmpreg1;
|
ETH->MACMIIAR = tmpreg1;
|
||||||
|
|
||||||
TIM2->CNT = 0;
|
|
||||||
HAL_TIM_Base_Start(&htim2);
|
HAL_TIM_Base_Start(&htim2);
|
||||||
|
|
||||||
while (ETH->MACMIIAR & 1) {
|
while (ETH->MACMIIAR & 1) {
|
||||||
@ -123,7 +122,6 @@ int WriteRegister(uint32_t reg, uint16_t value)
|
|||||||
ETH->MACMIIDR = value;
|
ETH->MACMIIDR = value;
|
||||||
ETH->MACMIIAR = tmpreg1;
|
ETH->MACMIIAR = tmpreg1;
|
||||||
|
|
||||||
TIM2->CNT = 0;
|
|
||||||
HAL_TIM_Base_Start(&htim2);
|
HAL_TIM_Base_Start(&htim2);
|
||||||
|
|
||||||
while (ETH->MACMIIAR & 1) {
|
while (ETH->MACMIIAR & 1) {
|
||||||
|
@ -32,6 +32,8 @@ static void print_error_message(HAL_StatusTypeDef result, size_t *err_count, siz
|
|||||||
display_write_data_seq("TIMEOUT");
|
display_write_data_seq("TIMEOUT");
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
HAL_Delay(1000);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void print_error_accel(HAL_StatusTypeDef result, size_t *err_count, size_t t, char *prefix)
|
static void print_error_accel(HAL_StatusTypeDef result, size_t *err_count, size_t t, char *prefix)
|
||||||
@ -85,6 +87,11 @@ int LSM9DS1_test_accel(void)
|
|||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
} else {
|
} else {
|
||||||
|
DISPLAY_SET_CURSOR(1, 4);
|
||||||
|
display_write_data_byte('0' + ((err_count / 10) % 10));
|
||||||
|
display_write_data_byte('0' + (err_count % 10));
|
||||||
|
display_write_data_seq(" errors");
|
||||||
|
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -122,6 +129,11 @@ int LSM9DS1_test_magnet(void)
|
|||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
} else {
|
} else {
|
||||||
|
DISPLAY_SET_CURSOR(1, 4);
|
||||||
|
display_write_data_byte('0' + ((err_count / 10) % 10));
|
||||||
|
display_write_data_byte('0' + (err_count % 10));
|
||||||
|
display_write_data_seq(" errors");
|
||||||
|
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user