#ifndef __LHP_M31820_h
#define __LHP_M31820_h

#include <libopencm3/stm32/rcc.h>
#include <libopencm3/stm32/gpio.h>
#include <libLHP_UART.h>
#include <libLHP_D1W.h>
#include <stdint.h>



#define M31820_ALRM_SEARCH      0xec
#define M31820_CONVERT          0x44
#define M31820_READ_SCRATCHPAD  0xbe
#define M31820_WRITE_SCRATCHPAD 0x4e
#define M31820_COPY_SCRATCHPAD  0x48
#define M31820_RECALL_E2        0xb8
#define M31820_READ_POW         0xb4

#define  M31820_CONFIG_9BITS   0xf8
#define  M31820_CONFIG_10BITS  0xfc
#define  M31820_CONFIG_11BITS  0xfa
#define  M31820_CONFIG_12BITS  0xfe

#define TCONV_9BITS             94
#define TCONV_10BITS            188
#define TCONV_11BITS             375
#define TCONV_12BITS             750


uint32_t m31820_get_temp(uint8_t num,uint8_t id);
#endif
