stm32: move lm75 handling into common board logic; delete unused lm75 file for stm3210e-eval
This commit is contained in:
parent
35471e33dc
commit
7c7836d1d7
80
boards/arm/stm32/common/include/stm32_lm75.h
Normal file
80
boards/arm/stm32/common/include/stm32_lm75.h
Normal file
@ -0,0 +1,80 @@
|
||||
/****************************************************************************
|
||||
* boards/arm/stm32/common/include/stm32_lm75.h
|
||||
*
|
||||
* Licensed to the Apache Software Foundation (ASF) under one or more
|
||||
* contributor license agreements. See the NOTICE file distributed with
|
||||
* this work for additional information regarding copyright ownership. The
|
||||
* ASF licenses this file to you under the Apache License, Version 2.0 (the
|
||||
* "License"); you may not use this file except in compliance with the
|
||||
* License. You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
|
||||
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
|
||||
* License for the specific language governing permissions and limitations
|
||||
* under the License.
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
#ifndef __STM32_LM75_H
|
||||
#define __STM32_LM75_H
|
||||
|
||||
/****************************************************************************
|
||||
* Included Files
|
||||
****************************************************************************/
|
||||
|
||||
#include <nuttx/config.h>
|
||||
|
||||
/****************************************************************************
|
||||
* Pre-processor Definitions
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Public Types
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Public Data
|
||||
****************************************************************************/
|
||||
|
||||
#ifdef __cplusplus
|
||||
#define EXTERN extern "C"
|
||||
extern "C"
|
||||
{
|
||||
#else
|
||||
#define EXTERN extern
|
||||
#endif
|
||||
|
||||
/****************************************************************************
|
||||
* Inline Functions
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Public Function Prototypes
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Name: board_lm75_initialize
|
||||
*
|
||||
* Description:
|
||||
* Initialize and register the LM-75 Temperature Sensor driver.
|
||||
*
|
||||
* Input Parameters:
|
||||
* devno - The device number, used to build the device path as /dev/tempN
|
||||
* busno - The I2C bus number
|
||||
*
|
||||
* Returned Value:
|
||||
* Zero (OK) on success; a negated errno value on failure.
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
int board_lm75_initialize(int devno, int busno);
|
||||
|
||||
#undef EXTERN
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif // __STM32_LM75_H
|
@ -46,6 +46,10 @@ ifeq ($(CONFIG_LCD_SSD1306),y)
|
||||
CSRCS += stm32_ssd1306.c
|
||||
endif
|
||||
|
||||
ifeq ($(CONFIG_SENSORS_LM75),y)
|
||||
CSRCS += stm32_lm75.c
|
||||
endif
|
||||
|
||||
DEPPATH += --dep-path src
|
||||
VPATH += :src
|
||||
CFLAGS += $(shell $(INCDIR) $(INCDIROPT) "$(CC)" $(TOPDIR)$(DELIM)arch$(DELIM)$(CONFIG_ARCH)$(DELIM)src$(DELIM)board$(DELIM)src)
|
||||
|
103
boards/arm/stm32/common/src/stm32_lm75.c
Normal file
103
boards/arm/stm32/common/src/stm32_lm75.c
Normal file
@ -0,0 +1,103 @@
|
||||
/****************************************************************************
|
||||
* boards/arm/stm32/common/src/stm32_lm75.c
|
||||
*
|
||||
* Licensed to the Apache Software Foundation (ASF) under one or more
|
||||
* contributor license agreements. See the NOTICE file distributed with
|
||||
* this work for additional information regarding copyright ownership. The
|
||||
* ASF licenses this file to you under the Apache License, Version 2.0 (the
|
||||
* "License"); you may not use this file except in compliance with the
|
||||
* License. You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
|
||||
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
|
||||
* License for the specific language governing permissions and limitations
|
||||
* under the License.
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Included Files
|
||||
****************************************************************************/
|
||||
|
||||
#include <nuttx/config.h>
|
||||
|
||||
#include <stdio.h>
|
||||
#include <errno.h>
|
||||
|
||||
#include <nuttx/i2c/i2c_master.h>
|
||||
#include <nuttx/sensors/lm75.h>
|
||||
|
||||
#include "stm32.h"
|
||||
#include "stm32_i2c.h"
|
||||
|
||||
/****************************************************************************
|
||||
* Pre-processor Definitions
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Private Types
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Private Function Prototypes
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Private Data
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Public Data
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Private Functions
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Public Functions
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Name: board_lm75_initialize
|
||||
*
|
||||
* Description:
|
||||
* Initialize and register the LM-75 Temperature Sensor driver.
|
||||
*
|
||||
* Input Parameters:
|
||||
* devno - The device number, used to build the device path as /dev/tempN
|
||||
* busno - The I2C bus number
|
||||
*
|
||||
* Returned Value:
|
||||
* Zero (OK) on success; a negated errno value on failure.
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
int board_lm75_initialize(int devno, int busno)
|
||||
{
|
||||
FAR struct i2c_master_s *i2c;
|
||||
char devpath[12];
|
||||
int ret;
|
||||
|
||||
/* Get an instance of the I2C1 interface */
|
||||
|
||||
i2c = stm32_i2cbus_initialize(busno);
|
||||
if (!i2c)
|
||||
{
|
||||
return -ENODEV;
|
||||
}
|
||||
|
||||
/* Then register the temperature sensor */
|
||||
|
||||
snprintf(devpath, 12, "/dev/temp%d", devno);
|
||||
ret = lm75_register(devpath, i2c, 0x48);
|
||||
if (ret < 0)
|
||||
{
|
||||
stm32_i2cbus_uninitialize(i2c);
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
@ -60,10 +60,6 @@ ifeq ($(CONFIG_USBDEV_COMPOSITE),y)
|
||||
CSRCS += stm32_composite.c
|
||||
endif
|
||||
|
||||
ifeq ($(CONFIG_LM75_I2C),y)
|
||||
CSRCS += stm32_lm75.c
|
||||
endif
|
||||
|
||||
ifeq ($(CONFIG_CAN),y)
|
||||
CSRCS += stm32_can.c
|
||||
endif
|
||||
|
@ -1,122 +0,0 @@
|
||||
/****************************************************************************
|
||||
* boards/arm/stm32/stm3210e-eval/src/stm32_lm75.c
|
||||
*
|
||||
* Copyright (C) 2011, 2016 Gregory Nutt. All rights reserved.
|
||||
* Author: Gregory Nutt <gnutt@nuttx.org>
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
*
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in
|
||||
* the documentation and/or other materials provided with the
|
||||
* distribution.
|
||||
* 3. Neither the name NuttX nor the names of its contributors may be
|
||||
* used to endorse or promote products derived from this software
|
||||
* without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
|
||||
* FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
|
||||
* COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
|
||||
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
|
||||
* BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
|
||||
* OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
|
||||
* AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
|
||||
* ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
* POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Included Files
|
||||
****************************************************************************/
|
||||
|
||||
#include <nuttx/config.h>
|
||||
|
||||
#include <errno.h>
|
||||
|
||||
#include <nuttx/i2c/i2c_master.h>
|
||||
#include <nuttx/sensors/lm75.h>
|
||||
|
||||
#include "stm32.h"
|
||||
#include "stm32_i2c.h"
|
||||
#include "stm3210e-eval.h"
|
||||
|
||||
#if defined(CONFIG_I2C) && defined(CONFIG_LM75_I2C) && defined(CONFIG_STM32_I2C1)
|
||||
|
||||
/****************************************************************************
|
||||
* Public Functions
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Name: stm32_lm75initialize
|
||||
*
|
||||
* Description:
|
||||
* Initialize and register the LM-75 Temperature Sensor driver.
|
||||
*
|
||||
* Input Parameters:
|
||||
* devpath - The full path to the driver to register. E.g., "/dev/temp0"
|
||||
*
|
||||
* Returned Value:
|
||||
* Zero (OK) on success; a negated errno value on failure.
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
int stm32_lm75initialize(FAR const char *devpath)
|
||||
{
|
||||
FAR struct i2c_master_s *i2c;
|
||||
int ret;
|
||||
|
||||
/* Configure PB.5 as Input pull-up. This pin can be used as a temperature
|
||||
* sensor interrupt (not fully implemented).
|
||||
*/
|
||||
|
||||
stm32_configgpio(GPIO_LM75_OSINT);
|
||||
|
||||
/* Get an instance of the I2C1 interface */
|
||||
|
||||
i2c = stm32_i2cbus_initialize(1);
|
||||
if (!i2c)
|
||||
{
|
||||
return -ENODEV;
|
||||
}
|
||||
|
||||
/* Then register the temperature sensor */
|
||||
|
||||
ret = lm75_register(devpath, i2c, 0x48);
|
||||
if (ret < 0)
|
||||
{
|
||||
stm32_i2cbus_uninitialize(i2c);
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
/****************************************************************************
|
||||
* Name: stm32_lm75attach
|
||||
*
|
||||
* Description:
|
||||
* Attach the LM-75 interrupt handler
|
||||
*
|
||||
* Input Parameters:
|
||||
* irqhandler - the LM-75 interrupt handler
|
||||
* arg - The argument that will accompany the interrupt
|
||||
*
|
||||
* Returned Value:
|
||||
* Zero (OK) returned on success; a negated errno value is returned on failure.
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
int stm32_lm75attach(xcpt_t irqhandler, void *arg)
|
||||
{
|
||||
stm32_gpiosetevent(GPIO_LM75_OSINT, true, true, true, irqhandler, arg);
|
||||
return OK;
|
||||
}
|
||||
|
||||
#endif /* CONFIG_I2C && CONFIG_LM75_I2C && CONFIG_STM32_I2C1 */
|
@ -73,10 +73,6 @@ ifeq ($(CONFIG_LCD_BACKPACK),y)
|
||||
CSRCS += stm32_lcd_backpack.c
|
||||
endif
|
||||
|
||||
ifeq ($(CONFIG_LM75_I2C),y)
|
||||
CSRCS += stm32_lm75.c
|
||||
endif
|
||||
|
||||
ifeq ($(CONFIG_RGBLED),y)
|
||||
CSRCS += stm32_rgbled.c
|
||||
endif
|
||||
|
@ -109,6 +109,9 @@
|
||||
#include "stm32_tone.h"
|
||||
#endif
|
||||
|
||||
#ifdef CONFIG_SENSORS_LM75
|
||||
#include "stm32_lm75.h"
|
||||
#endif
|
||||
|
||||
/****************************************************************************
|
||||
* Pre-processor Definitions
|
||||
@ -308,7 +311,7 @@ int stm32_bringup(void)
|
||||
#ifdef CONFIG_LM75_I2C
|
||||
/* Configure and initialize the LM75 sensor */
|
||||
|
||||
ret = stm32_lm75initialize("/dev/temp");
|
||||
ret = board_lm75_initialize(0, 1);
|
||||
if (ret < 0)
|
||||
{
|
||||
syslog(LOG_ERR, "ERROR: stm32_lm75initialize() failed: %d\n", ret);
|
||||
|
@ -1,122 +0,0 @@
|
||||
/****************************************************************************
|
||||
* boards/arm/stm32/stm32f103-minimum/src/stm32_lm75.c
|
||||
*
|
||||
* Copyright (C) 2017 Gregory Nutt. All rights reserved.
|
||||
* Author: Gregory Nutt <gnutt@nuttx.org>
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
*
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in
|
||||
* the documentation and/or other materials provided with the
|
||||
* distribution.
|
||||
* 3. Neither the name NuttX nor the names of its contributors may be
|
||||
* used to endorse or promote products derived from this software
|
||||
* without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
|
||||
* FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
|
||||
* COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
|
||||
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
|
||||
* BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
|
||||
* OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
|
||||
* AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
|
||||
* ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
* POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Included Files
|
||||
****************************************************************************/
|
||||
|
||||
#include <nuttx/config.h>
|
||||
|
||||
#include <errno.h>
|
||||
|
||||
#include <nuttx/i2c/i2c_master.h>
|
||||
#include <nuttx/sensors/lm75.h>
|
||||
|
||||
#include "stm32.h"
|
||||
#include "stm32_i2c.h"
|
||||
#include "stm32f103_minimum.h"
|
||||
|
||||
#if defined(CONFIG_I2C) && defined(CONFIG_LM75_I2C) && defined(CONFIG_STM32_I2C1)
|
||||
|
||||
/****************************************************************************
|
||||
* Public Functions
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Name: stm32_lm75initialize
|
||||
*
|
||||
* Description:
|
||||
* Initialize and register the LM-75 Temperature Sensor driver.
|
||||
*
|
||||
* Input Parameters:
|
||||
* devpath - The full path to the driver to register. E.g., "/dev/temp0"
|
||||
*
|
||||
* Returned Value:
|
||||
* Zero (OK) on success; a negated errno value on failure.
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
int stm32_lm75initialize(FAR const char *devpath)
|
||||
{
|
||||
FAR struct i2c_master_s *i2c;
|
||||
int ret;
|
||||
|
||||
/* Configure PB.5 as Input pull-up. This pin can be used as a temperature
|
||||
* sensor interrupt (not fully implemented).
|
||||
*/
|
||||
|
||||
stm32_configgpio(GPIO_LM75_OSINT);
|
||||
|
||||
/* Get an instance of the I2C1 interface */
|
||||
|
||||
i2c = stm32_i2cbus_initialize(1);
|
||||
if (!i2c)
|
||||
{
|
||||
return -ENODEV;
|
||||
}
|
||||
|
||||
/* Then register the temperature sensor */
|
||||
|
||||
ret = lm75_register(devpath, i2c, 0x48);
|
||||
if (ret < 0)
|
||||
{
|
||||
stm32_i2cbus_uninitialize(i2c);
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
/****************************************************************************
|
||||
* Name: stm32_lm75attach
|
||||
*
|
||||
* Description:
|
||||
* Attach the LM-75 interrupt handler
|
||||
*
|
||||
* Input Parameters:
|
||||
* irqhandler - the LM-75 interrupt handler
|
||||
* arg - The argument that will accompany the interrupt
|
||||
*
|
||||
* Returned Value:
|
||||
* Zero (OK) returned on success; a negated errno value is returned on failure.
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
int stm32_lm75attach(xcpt_t irqhandler, void *arg)
|
||||
{
|
||||
stm32_gpiosetevent(GPIO_LM75_OSINT, true, true, true, irqhandler, arg);
|
||||
return OK;
|
||||
}
|
||||
|
||||
#endif /* CONFIG_I2C && CONFIG_LM75_I2C && CONFIG_STM32_I2C1 */
|
Loading…
Reference in New Issue
Block a user