no-OS
max31855.h
Go to the documentation of this file.
1 /***************************************************************************/
34 #ifndef __MAX31855_H__
35 #define __MAX31855_H__
36 
37 /******************************************************************************/
38 /***************************** Include Files **********************************/
39 /******************************************************************************/
40 
41 #include <stdint.h>
42 #include "no_os_spi.h"
43 #include "no_os_util.h"
44 
45 /******************************************************************************/
46 /********************** Macros and Constants Definitions **********************/
47 /******************************************************************************/
48 
49 #define MAX31855_GET_INTERNAL_TEMP(x) (no_os_field_get(NO_OS_GENMASK(15, 4), x))
50 #define MAX31855_GET_FAULT_BIT(x) (no_os_field_get(NO_OS_BIT(16), x))
51 #define MAX31855_GET_THERMOCOUPLE_TEMP(x) (no_os_field_get(NO_OS_GENMASK(31, 18), x))
52 #define MAX31855_GET_FAULTS(x) (no_os_field_get(NO_OS_GENMASK(2, 0), x))
53 
58 #define MAX31855_THERMOCOUPLE_TEMP_DEC_DIV 4
59 #define MAX31855_INTERNAL_TEMP_DEC_DIV 16
60 
62 #define MAX31855_THERMOCOUPLE_TEMP_SIGN_POS 13
63 #define MAX31855_INTERNAL_TEMP_SIGN_POS 11
64 
70 };
71 
76  int32_t integer;
77  int32_t decimal;
78 };
79 
82  uint8_t SCV:1;
84  uint8_t SCG:1;
86  uint8_t OC:1;
87 };
88 
91  uint8_t value;
92 };
93 
97 struct max31855_dev {
100 };
101 
103 int max31855_init(struct max31855_dev **, struct max31855_init_param *);
104 
106 int max31855_remove(struct max31855_dev *);
107 
109 int max31855_read_raw(struct max31855_dev *, uint32_t *);
110 
112 int max31855_read_temp(struct max31855_dev *, struct max31855_decimal *,
113  struct max31855_decimal *);
114 
115 #endif
no_os_alloc.h
no_os_div_s64_rem
int64_t no_os_div_s64_rem(int64_t dividend, int32_t divisor, int32_t *remainder)
no_os_spi_write_and_read
int32_t no_os_spi_write_and_read(struct no_os_spi_desc *desc, uint8_t *data, uint16_t bytes_number)
Write and read data to/from SPI.
Definition: no_os_spi.c:159
no_os_spi.h
Header file of SPI Interface.
max31855.h
MAX31855_THERMOCOUPLE_TEMP_DEC_DIV
#define MAX31855_THERMOCOUPLE_TEMP_DEC_DIV
Definition: max31855.h:58
max31855_dev::comm_desc
struct no_os_spi_desc * comm_desc
Definition: max31855.h:98
MAX31855_GET_FAULT_BIT
#define MAX31855_GET_FAULT_BIT(x)
Definition: max31855.h:50
_max31855_fault_sts_mask::OC
uint8_t OC
Definition: max31855.h:86
device
Definition: ad9361_util.h:69
max31855_fault_sts
Definition: max31855.h:89
no_os_calloc
void * no_os_calloc(size_t nitems, size_t size)
Allocate memory and return a pointer to it, set memory to 0.
Definition: chibios_alloc.c:54
max31855_decimal::integer
int32_t integer
Definition: max31855.h:76
max31855_read_temp
int max31855_read_temp(struct max31855_dev *, struct max31855_decimal *, struct max31855_decimal *)
Read thermocouple and internal temperatures (converted in deg. C)
Definition: max31855.c:131
max31855_dev
MAX31855 descriptor.
Definition: max31855.h:97
max31855_fault_sts::fields
struct _max31855_fault_sts_mask fields
Definition: max31855.h:90
max31855_read_raw
int max31855_read_raw(struct max31855_dev *device, uint32_t *val)
Read raw register value.
Definition: max31855.c:105
MAX31855_GET_INTERNAL_TEMP
#define MAX31855_GET_INTERNAL_TEMP(x)
Definition: max31855.h:49
max31855_dev::fault
union max31855_fault_sts fault
Definition: max31855.h:99
MAX31855_GET_THERMOCOUPLE_TEMP
#define MAX31855_GET_THERMOCOUPLE_TEMP(x)
Definition: max31855.h:51
no_os_spi_desc
Structure holding SPI descriptor.
Definition: no_os_spi.h:192
max31855_init
int max31855_init(struct max31855_dev **, struct max31855_init_param *)
Device and comm init function.
Definition: max31855.c:57
max31855_init_param
MAX31855 comm init param.
Definition: max31855.h:68
max31855_read_raw
int max31855_read_raw(struct max31855_dev *, uint32_t *)
Read raw register value.
Definition: max31855.c:105
max31855_decimal::decimal
int32_t decimal
Definition: max31855.h:77
max31855_decimal
interger/decimal format used for temperature representation
Definition: max31855.h:75
MAX31855_THERMOCOUPLE_TEMP_SIGN_POS
#define MAX31855_THERMOCOUPLE_TEMP_SIGN_POS
Definition: max31855.h:62
no_os_free
void no_os_free(void *ptr)
Deallocate memory previously allocated by a call to no_os_calloc or no_os_malloc.
Definition: chibios_alloc.c:69
max31855_remove
int max31855_remove(struct max31855_dev *)
Remove resources allocated by the init function.
Definition: max31855.c:84
_max31855_fault_sts_mask
Definition: max31855.h:80
max31855_init_param::spi_init
struct no_os_spi_init_param spi_init
Definition: max31855.h:69
no_os_get_unaligned_be32
uint32_t no_os_get_unaligned_be32(uint8_t *buf)
init_param
struct ad7616_init_param init_param
Definition: ad7616_sdz.c:113
MAX31855_INTERNAL_TEMP_DEC_DIV
#define MAX31855_INTERNAL_TEMP_DEC_DIV
Definition: max31855.h:59
MAX31855_GET_FAULTS
#define MAX31855_GET_FAULTS(x)
Definition: max31855.h:52
_max31855_fault_sts_mask::SCG
uint8_t SCG
Definition: max31855.h:84
MAX31855_INTERNAL_TEMP_SIGN_POS
#define MAX31855_INTERNAL_TEMP_SIGN_POS
Definition: max31855.h:63
max31855_fault_sts::value
uint8_t value
Definition: max31855.h:91
no_os_spi_remove
int32_t no_os_spi_remove(struct no_os_spi_desc *desc)
Free the resources allocated by no_os_spi_init().
Definition: no_os_spi.c:116
no_os_spi_init
int32_t no_os_spi_init(struct no_os_spi_desc **desc, const struct no_os_spi_init_param *param)
Initialize the SPI communication peripheral.
Definition: no_os_spi.c:52
no_os_util.h
Header file of utility functions.
no_os_sign_extend32
int32_t no_os_sign_extend32(uint32_t value, int index)
max31855_init
int max31855_init(struct max31855_dev **device, struct max31855_init_param *init_param)
Device and comm init function.
Definition: max31855.c:57
_max31855_fault_sts_mask::SCV
uint8_t SCV
Definition: max31855.h:82
errno.h
Error macro definition for ARM Compiler.
max31855_remove
int max31855_remove(struct max31855_dev *device)
Remove resources allocated by the init function.
Definition: max31855.c:84
max31855_read_temp
int max31855_read_temp(struct max31855_dev *device, struct max31855_decimal *thermocouple_temp, struct max31855_decimal *internal_temp)
Read thermocouple and internal temperatures (converted in deg. C)
Definition: max31855.c:131
no_os_spi_init_param
Structure holding the parameters for SPI initialization.
Definition: no_os_spi.h:140