-
Notifications
You must be signed in to change notification settings - Fork 14
Home
Welcome to the stm32-f103-CortexM3-ESP8266-WeatherStation wiki!
Had to modify this functions to be compatible with the current HAL from ST.
` void DHT22_Config_GPIO_INPUT() { #if 0 DHT22_Pin_GPIO_Config.GPIO_Pin = DHT22_Pin; DHT22_Pin_GPIO_Config.GPIO_Mode = GPIO_MODE_IN_FLOATING; DHT22_Pin_GPIO_Config.GPIO_Speed = GPIO_Speed_50MHz; GPIO_Init(GPIOB,&DHT22_Pin_GPIO_Config); #else GPIO_InitTypeDef GPIO_InitStruct = {0};
/*Configure GPIO pin : PB6 */
GPIO_InitStruct.Pin = DHT22_Pin;
GPIO_InitStruct.Mode = GPIO_MODE_IT_RISING_FALLING;
GPIO_InitStruct.Pull = GPIO_NOPULL;
HAL_GPIO_Init(GPIOB, &GPIO_InitStruct);
#endif }
void DHT22_Config_GPIO_OUTPUT() { #if 0 DHT22_Pin_GPIO_Config.GPIO_Pin = DHT22_Pin; DHT22_Pin_GPIO_Config.GPIO_Mode = GPIO_Mode_Out_PP; DHT22_Pin_GPIO_Config.GPIO_Speed = GPIO_Speed_50MHz; GPIO_Init(GPIOB,&DHT22_Pin_GPIO_Config); #else GPIO_InitTypeDef GPIO_InitStruct = {0};
/*Configure GPIO pin : PB6 */
GPIO_InitStruct.Pin = DHT22_Pin;
GPIO_InitStruct.Mode = GPIO_MODE_OUTPUT_OD; //HAD TO SWITCH TO OPEN DRAIN INSTEAD OF PUSH-PULL
GPIO_InitStruct.Pull = GPIO_NOPULL;
HAL_GPIO_Init(GPIOB, &GPIO_InitStruct);
//somehow a bug was setting the pin MODE to 0x0, which is reserved in output configuration
//this restores proper value
GPIOB->CRL |= 0x03000000;
#endif } `
Making output open drain worked around an apparent conflict in my HW that caused multiple EXTI interrupts at begining of start pulse, after switching to open drain, it looks OK:
Also due to using CubeMX hardware configurator the code generated already makes EXTI interrupts and inits clocks, so these two functions were not needed:
//DHT22_Config_CLK(); //DHT22_Config_EXTInterrupt_Enable();
Great code!