2019-08-19 17:16:08 +02:00
|
|
|
/****************************************************************************
|
2020-05-12 22:19:26 +02:00
|
|
|
* boards/arm/stm32/common/src/stm32_max31855.c
|
2015-09-13 23:50:02 +02:00
|
|
|
*
|
2021-03-19 09:05:04 +01:00
|
|
|
* 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
|
2015-09-13 23:50:02 +02:00
|
|
|
*
|
2021-03-19 09:05:04 +01:00
|
|
|
* http://www.apache.org/licenses/LICENSE-2.0
|
2015-09-13 23:50:02 +02:00
|
|
|
*
|
2021-03-19 09:05:04 +01:00
|
|
|
* 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.
|
2015-09-13 23:50:02 +02:00
|
|
|
*
|
2019-08-19 17:16:08 +02:00
|
|
|
****************************************************************************/
|
2015-09-13 23:50:02 +02:00
|
|
|
|
2019-08-19 17:16:08 +02:00
|
|
|
/****************************************************************************
|
2015-09-13 23:50:02 +02:00
|
|
|
* Included Files
|
2019-08-19 17:16:08 +02:00
|
|
|
****************************************************************************/
|
2015-09-13 23:50:02 +02:00
|
|
|
|
|
|
|
#include <nuttx/config.h>
|
|
|
|
|
|
|
|
#include <errno.h>
|
|
|
|
#include <debug.h>
|
2020-05-12 22:19:26 +02:00
|
|
|
#include <stdio.h>
|
2015-09-13 23:50:02 +02:00
|
|
|
|
|
|
|
#include <nuttx/spi/spi.h>
|
2020-05-12 22:19:26 +02:00
|
|
|
#include <arch/board/board.h>
|
2015-09-13 23:50:02 +02:00
|
|
|
#include <nuttx/sensors/max31855.h>
|
|
|
|
|
|
|
|
#include "stm32.h"
|
|
|
|
#include "stm32_spi.h"
|
|
|
|
|
2019-08-19 17:16:08 +02:00
|
|
|
/****************************************************************************
|
2015-09-13 23:50:02 +02:00
|
|
|
* Public Functions
|
2019-08-19 17:16:08 +02:00
|
|
|
****************************************************************************/
|
2015-09-13 23:50:02 +02:00
|
|
|
|
2019-08-19 17:16:08 +02:00
|
|
|
/****************************************************************************
|
2020-05-12 22:19:26 +02:00
|
|
|
* Name: board_max31855_initialize
|
2015-09-13 23:50:02 +02:00
|
|
|
*
|
|
|
|
* Description:
|
|
|
|
* Initialize and register the MAX31855 Temperature Sensor driver.
|
|
|
|
*
|
2018-02-01 17:00:02 +01:00
|
|
|
* Input Parameters:
|
2020-05-12 22:19:26 +02:00
|
|
|
* devno - The device number, used to build the device path as /dev/tempN
|
|
|
|
* busno - The SPI bus number
|
2015-09-13 23:50:02 +02:00
|
|
|
*
|
|
|
|
* Returned Value:
|
|
|
|
* Zero (OK) on success; a negated errno value on failure.
|
|
|
|
*
|
2019-08-19 17:16:08 +02:00
|
|
|
****************************************************************************/
|
2015-09-13 23:50:02 +02:00
|
|
|
|
2020-05-12 22:19:26 +02:00
|
|
|
int board_max31855_initialize(int devno, int busno)
|
2015-09-13 23:50:02 +02:00
|
|
|
{
|
|
|
|
FAR struct spi_dev_s *spi;
|
2020-05-12 22:19:26 +02:00
|
|
|
char devpath[12];
|
2015-09-13 23:50:02 +02:00
|
|
|
int ret;
|
|
|
|
|
2020-05-12 22:19:26 +02:00
|
|
|
spi = stm32_spibus_initialize(busno);
|
2015-09-13 23:50:02 +02:00
|
|
|
|
|
|
|
if (!spi)
|
|
|
|
{
|
|
|
|
return -ENODEV;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Then register the barometer sensor */
|
2015-10-04 23:28:03 +02:00
|
|
|
|
2020-05-12 22:19:26 +02:00
|
|
|
snprintf(devpath, 12, "/dev/temp%d", devno);
|
|
|
|
ret = max31855_register(devpath, spi, devno);
|
2015-09-13 23:50:02 +02:00
|
|
|
if (ret < 0)
|
|
|
|
{
|
2016-06-13 01:02:46 +02:00
|
|
|
snerr("ERROR: Error registering MAX31855\n");
|
2015-09-13 23:50:02 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
return ret;
|
|
|
|
}
|