Skip to content

Commit

Permalink
[LTD noup] sensor: add stub STM32F401x temperature driver
Browse files Browse the repository at this point in the history
The next patch will fill in the necessary functionality.

Signed-off-by: Marti Bolivar <[email protected]>
  • Loading branch information
Marti Bolivar authored and rsalveti committed Jun 1, 2017
1 parent 3191901 commit 52ce7ab
Show file tree
Hide file tree
Showing 5 changed files with 79 additions and 0 deletions.
2 changes: 2 additions & 0 deletions drivers/sensor/Kconfig
Original file line number Diff line number Diff line change
Expand Up @@ -107,3 +107,5 @@ source "drivers/sensor/th02/Kconfig"
source "drivers/sensor/tmp007/Kconfig"

source "drivers/sensor/tmp112/Kconfig"

source "drivers/sensor/stm32/Kconfig"
1 change: 1 addition & 0 deletions drivers/sensor/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -34,3 +34,4 @@ obj-$(CONFIG_SX9500) += sx9500/
obj-$(CONFIG_TH02) += th02/
obj-$(CONFIG_TMP007) += tmp007/
obj-$(CONFIG_TMP112) += tmp112/
obj-$(CONFIG_TEMP_STM32F401X) += stm32/
24 changes: 24 additions & 0 deletions drivers/sensor/stm32/Kconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
# Kconfig - STM32F401x temperature sensor configuration options

#
# Copyright (c) 2016 ARM Ltd.
# Copyright (c) 2017 Linaro Limited.
#
# SPDX-License-Identifier: Apache-2.0
#

menuconfig TEMP_STM32F401X
bool
prompt "STM32F401x Temperature Sensor"
depends on SENSOR && SOC_SERIES_STM32F4X
default n
help
Enable driver for STM32F401x temperature sensor.

config TEMP_STM32F401X_NAME
string
prompt "Driver name"
default "TEMP_0"
depends on TEMP_STM32F401X
help
Device name with which the STM32F401x temperature sensor is identified.
1 change: 1 addition & 0 deletions drivers/sensor/stm32/Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
obj-$(CONFIG_TEMP_STM32F401X) += temp_stm32f401x.o
51 changes: 51 additions & 0 deletions drivers/sensor/stm32/temp_stm32f401x.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
/*
* Copyright (c) 2017 Linaro Limited
*
* SPDX-License-Identifier: Apache-2.0
*/

/**
* @file
* @brief Temperature sensor driver for STM32F401x chips.
*
* @warning Temperature readings should be use for RELATIVE
* TEMPERATURE CHANGES ONLY.
*
* Inter-chip temperature sensor readings may vary by as much
* as 45 degrees C.
*/

#include <device.h>
#include <sensor.h>

/* TODO */
static int temp_stm32f401x_sample_fetch(struct device *dev,
enum sensor_channel chan)
{
return 0;
}

/* TODO */
static int temp_stm32f401x_channel_get(struct device *dev,
enum sensor_channel chan,
struct sensor_value *val)
{
val->val1 = 0;
val->val2 = 0;
return 0;
}

static const struct sensor_driver_api temp_stm32f401x_driver_api = {
.sample_fetch = temp_stm32f401x_sample_fetch,
.channel_get = temp_stm32f401x_channel_get,
};

/* TODO */
static int temp_stm32f401x_init(struct device *dev)
{
return 0;
}

DEVICE_AND_API_INIT(temp_stm32f401x, CONFIG_TEMP_STM32F401X_NAME,
temp_stm32f401x_init, NULL, NULL, POST_KERNEL,
CONFIG_SENSOR_INIT_PRIORITY, &temp_stm32f401x_driver_api);

0 comments on commit 52ce7ab

Please sign in to comment.