资源简介
STM32驱动程序用MAX31856配合热电偶测量温度.有具体的模块电路以及驱动程序,芯片的数据手册参考资料
代码片段和文件信息
#include “max31856.h“
const char *TAG = “MAX31856“;
void max31856_write_register(spi_device_handle_t spi_handle uint8_t address uint8_t data) {
esp_err_t ret;
spi_transaction_t spi_transaction;
memset( &spi_transaction 0 sizeof( spi_transaction_t ) );
uint8_t tx_data[1] = {address | 0x80};
gpio_set_level(PIN_NUM_CS 0);
spi_transaction.flags = SPI_TRANS_USE_RXDATA;
spi_transaction.length = 8;
spi_transaction.tx_buffer = tx_data;
ret = spi_device_transmit(spi_handle &spi_transaction);
ESP_ERROR_CHECK(ret);
tx_data[0] = data;
ret = spi_device_transmit(spi_handle &spi_transaction);
ESP_ERROR_CHECK(ret);
gpio_set_level(PIN_NUM_CS 1);
}
uint8_t max31856_read_register(spi_device_handle_t spi_handle uint8_t address) {
esp_err_t ret;
spi_transaction_t spi_transaction;
memset( &spi_transaction 0 sizeof( spi_transaction_t ) );
uint8_t tx_data[1] = {address & 0x7F};
gpio_set_level(PIN_NUM_CS 0);
spi_transaction.flags = SPI_TRANS_USE_RXDATA;
spi_transaction.length = 8;
spi_transaction.tx_buffer = tx_data;
ret = spi_device_transmit(spi_handle &spi_transaction);
ESP_ERROR_CHECK(ret);
tx_data[0] = 0xFF;
ret = spi_device_transmit(spi_handle &spi_transaction);
ESP_ERROR_CHECK(ret);
gpio_set_level(PIN_NUM_CS 1);
uint8_t reg_value = spi_transaction.rx_data[0];
return reg_value;
}
uint8_t max31856_read_fast_register(spi_device_handle_t spi_handle uint8_t address) {
esp_err_t ret;
spi_transaction_t spi_transaction;
memset( &spi_transaction 0 sizeof( spi_transaction_t ) );
uint8_t tx_data[2] = {address & 0x7F 0xFF};
gpio_set_level(PIN_NUM_CS 0);
spi_transaction.flags = SPI_TRANS_USE_RXDATA;
spi_transaction.length = 16;
spi_transaction.tx_buffer = tx_data;
ret = spi_device_transmit(spi_handle &spi_transaction);
ESP_ERROR_CHECK(ret);
gpio_set_level(PIN_NUM_CS 1);
uint8_t reg_value = spi_transaction.rx_data[0];
return reg_value;
}
uint16_t max31856_read_register16(spi_device_handle_t spi_handle uint8_t address) {
esp_err_t ret;
spi_transaction_t spi_transaction;
memset( &spi_transaction 0 sizeof( spi_transaction_t ) );
uint8_t tx_data[1] = {address & 0x7F};
gpio_set_level(PIN_NUM_CS 0);
spi_transaction.length = 8;
spi_transaction.flags = SPI_TRANS_USE_RXDATA;
spi_transaction.tx_buffer = tx_data;
ret = spi_device_transmit(spi_handle &spi_transaction);
ESP_ERROR_CHECK(ret);
tx_data[0] = 0xFF;
spi_transaction.length = 8;
ret = spi_device_transmit(spi_handle &spi_transaction);
ESP_ERROR_CHECK(ret);
uint8_t b1 = spi_transaction.rx_data[0];
spi_transaction.length = 8;
ret = spi_device_transmit(spi_handle &spi_transaction);
ESP_ERROR_CHECK(ret);
uint8_t b2 = spi_transaction.rx_data[0];
gpio_set_level(PIN_NUM_CS 1);
uint16_t reg_value = ((b1 << 8) | b2);
return reg_value;
}
uin
属性 大小 日期 时间 名称
----------- --------- ---------- ----- ----
目录 0 2018-11-15 12:13 CJMCU-31856 资料\
文件 118794 2015-11-07 11:50 CJMCU-31856 资料\CJMCU-31856原理图.pdf
目录 0 2018-11-15 12:13 CJMCU-31856 资料\max31856-c\
文件 491 2018-09-19 05:16 CJMCU-31856 资料\max31856-c\.gitignore
目录 0 2018-09-19 05:16 CJMCU-31856 资料\max31856-c\components\
目录 0 2018-11-15 12:13 CJMCU-31856 资料\max31856-c\components\max31856\
文件 57 2018-09-19 05:16 CJMCU-31856 资料\max31856-c\components\max31856\component.mk
文件 9745 2018-09-19 05:16 CJMCU-31856 资料\max31856-c\components\max31856\max31856.c
文件 2705 2018-09-19 05:16 CJMCU-31856 资料\max31856-c\components\max31856\max31856.h
文件 1067 2018-09-19 05:16 CJMCU-31856 资料\max31856-c\LICENSE
目录 0 2018-11-15 12:13 CJMCU-31856 资料\max31856-c\main\
文件 145 2018-09-19 05:16 CJMCU-31856 资料\max31856-c\main\component.mk
文件 2249 2018-09-19 05:16 CJMCU-31856 资料\max31856-c\main\example.c
文件 1116 2018-09-19 05:16 CJMCU-31856 资料\max31856-c\main\Kconfig.projbuild
文件 180 2018-09-19 05:16 CJMCU-31856 资料\max31856-c\Makefile
文件 1204 2018-09-19 05:16 CJMCU-31856 资料\max31856-c\README.md
文件 13101 2018-09-19 05:16 CJMCU-31856 资料\max31856-c\sdkconfig
文件 3 2018-09-19 05:16 CJMCU-31856 资料\max31856-c\sdkconfig.defaults
文件 9997 2016-08-29 11:09 CJMCU-31856 资料\MAX31856-master.zip
文件 712567 2015-09-19 18:03 CJMCU-31856 资料\MAX31856.pdf
文件 1506984 2016-03-21 09:00 CJMCU-31856 资料\MAX31856_cn.pdf
文件 92777 2017-05-04 11:50 CJMCU-31856 资料\尺寸.jpg
文件 7742 2019-12-30 15:57 Adafruit_MAX31856-master.zip
- 上一篇:wifiphisher-1.4
- 下一篇:imx219 pdf
评论
共有 条评论