no-OS
max31855.h
Go to the documentation of this file.
1 /***************************************************************************/
40 #ifndef __MAX31855_H__
41 #define __MAX31855_H__
42 
43 /******************************************************************************/
44 /***************************** Include Files **********************************/
45 /******************************************************************************/
46 
47 #include <stdint.h>
48 #include "no_os_spi.h"
49 #include "no_os_util.h"
50 
51 /******************************************************************************/
52 /********************** Macros and Constants Definitions **********************/
53 /******************************************************************************/
54 
55 #define MAX31855_GET_INTERNAL_TEMP(x) (no_os_field_get(NO_OS_GENMASK(15, 4), x))
56 #define MAX31855_GET_FAULT_BIT(x) (no_os_field_get(NO_OS_BIT(16), x))
57 #define MAX31855_GET_THERMOCOUPLE_TEMP(x) (no_os_field_get(NO_OS_GENMASK(31, 18), x))
58 #define MAX31855_GET_FAULTS(x) (no_os_field_get(NO_OS_GENMASK(2, 0), x))
59 
64 #define MAX31855_THERMOCOUPLE_TEMP_DEC_DIV 4
65 #define MAX31855_INTERNAL_TEMP_DEC_DIV 16
66 
68 #define MAX31855_THERMOCOUPLE_TEMP_SIGN_POS 13
69 #define MAX31855_INTERNAL_TEMP_SIGN_POS 11
70 
76 };
77 
82  int32_t integer;
83  int32_t decimal;
84 };
85 
88  uint8_t SCV:1;
90  uint8_t SCG:1;
92  uint8_t OC:1;
93 };
94 
97  uint8_t value;
98 };
99 
103 struct max31855_dev {
106 };
107 
109 int max31855_init(struct max31855_dev **, struct max31855_init_param *);
110 
112 int max31855_remove(struct max31855_dev *);
113 
115 int max31855_read_raw(struct max31855_dev *, uint32_t *);
116 
118 int max31855_read_temp(struct max31855_dev *, struct max31855_decimal *,
119  struct max31855_decimal *);
120 
121 #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:165
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:64
max31855_dev::comm_desc
struct no_os_spi_desc * comm_desc
Definition: max31855.h:104
MAX31855_GET_FAULT_BIT
#define MAX31855_GET_FAULT_BIT(x)
Definition: max31855.h:56
_max31855_fault_sts_mask::OC
uint8_t OC
Definition: max31855.h:92
device
Definition: ad9361_util.h:75
max31855_fault_sts
Definition: max31855.h:95
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:60
max31855_decimal::integer
int32_t integer
Definition: max31855.h:82
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:137
max31855_dev
MAX31855 descriptor.
Definition: max31855.h:103
max31855_fault_sts::fields
struct _max31855_fault_sts_mask fields
Definition: max31855.h:96
max31855_read_raw
int max31855_read_raw(struct max31855_dev *device, uint32_t *val)
Read raw register value.
Definition: max31855.c:111
MAX31855_GET_INTERNAL_TEMP
#define MAX31855_GET_INTERNAL_TEMP(x)
Definition: max31855.h:55
max31855_dev::fault
union max31855_fault_sts fault
Definition: max31855.h:105
MAX31855_GET_THERMOCOUPLE_TEMP
#define MAX31855_GET_THERMOCOUPLE_TEMP(x)
Definition: max31855.h:57
no_os_spi_desc
Structure holding SPI descriptor.
Definition: no_os_spi.h:177
max31855_init
int max31855_init(struct max31855_dev **, struct max31855_init_param *)
Device and comm init function.
Definition: max31855.c:63
max31855_init_param
MAX31855 comm init param.
Definition: max31855.h:74
max31855_read_raw
int max31855_read_raw(struct max31855_dev *, uint32_t *)
Read raw register value.
Definition: max31855.c:111
max31855_decimal::decimal
int32_t decimal
Definition: max31855.h:83
max31855_decimal
interger/decimal format used for temperature representation
Definition: max31855.h:81
MAX31855_THERMOCOUPLE_TEMP_SIGN_POS
#define MAX31855_THERMOCOUPLE_TEMP_SIGN_POS
Definition: max31855.h:68
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:75
max31855_remove
int max31855_remove(struct max31855_dev *)
Remove resources allocated by the init function.
Definition: max31855.c:90
_max31855_fault_sts_mask
Definition: max31855.h:86
max31855_init_param::spi_init
struct no_os_spi_init_param spi_init
Definition: max31855.h:75
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:119
MAX31855_INTERNAL_TEMP_DEC_DIV
#define MAX31855_INTERNAL_TEMP_DEC_DIV
Definition: max31855.h:65
MAX31855_GET_FAULTS
#define MAX31855_GET_FAULTS(x)
Definition: max31855.h:58
_max31855_fault_sts_mask::SCG
uint8_t SCG
Definition: max31855.h:90
MAX31855_INTERNAL_TEMP_SIGN_POS
#define MAX31855_INTERNAL_TEMP_SIGN_POS
Definition: max31855.h:69
max31855_fault_sts::value
uint8_t value
Definition: max31855.h:97
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:122
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:58
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:63
_max31855_fault_sts_mask::SCV
uint8_t SCV
Definition: max31855.h:88
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:90
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:137
no_os_spi_init_param
Structure holding the parameters for SPI initialization.
Definition: no_os_spi.h:131