Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

STM32 temperature sensor #34538

Closed
Delsian opened this issue Apr 24, 2021 · 2 comments
Closed

STM32 temperature sensor #34538

Delsian opened this issue Apr 24, 2021 · 2 comments
Labels
Enhancement Changes/Updates/Additions to existing features platform: STM32 ST Micro STM32

Comments

@Delsian
Copy link
Contributor

Delsian commented Apr 24, 2021

Is your enhancement proposal related to a problem? Please describe.
STM32 chips contain an internal temperature sensor, but existing ADC bindings doesn't allow read internal temperature value in a proper way.

Describe the solution you'd like
Sensor binding similar to dts\bindings\sensor\nxp,kinetis-temperature.yaml

Additional context

/* Temperature sensor calibration value address */
#define TEMP130_CAL_ADDR ((uint16_t*) ((uint32_t) 0x1FF8007E))
#define TEMP30_CAL_ADDR ((uint16_t*) ((uint32_t) 0x1FF8007A))
#define VDD_CALIB ((uint16_t) (300))
#define VDD_APPLI ((uint16_t) (330)) // <-- change this to according to your supply voltage

int32_t ComputeTemperature(uint32_t measure)
{
  int32_t temperature;
  temperature = ((measure * VDD_APPLI / VDD_CALIB) - (int32_t)*TEMP30_CAL_ADDR );
  temperature = temperature *(int32_t)(130-30);
  temperature = temperature /(int32_t)(*TEMP130_CAL_ADDR -*TEMP30_CAL_ADDR);
  temperature = temperature + 30;
  return(temperature);
}

Other usable sources, for example, AN3964 "STM32L1x temperature sensor example"

@Delsian Delsian added the Enhancement Changes/Updates/Additions to existing features label Apr 24, 2021
@erwango erwango added the platform: STM32 ST Micro STM32 label Apr 26, 2021
@erwango
Copy link
Member

erwango commented Apr 26, 2021

@Delsian Thanks for this. Don't hesiate to contribute of you have solution in mind.

@Delsian
Copy link
Contributor Author

Delsian commented May 8, 2021

Implemented.

@Delsian Delsian closed this as completed May 8, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Enhancement Changes/Updates/Additions to existing features platform: STM32 ST Micro STM32
Projects
None yet
Development

No branches or pull requests

2 participants