74 lines
1.8 KiB
C
74 lines
1.8 KiB
C
#ifndef __MS5803_H__
|
|
#define __MS5803_H__
|
|
|
|
#include "math.h"
|
|
#include "string.h"
|
|
#include "main.h"
|
|
#include "modbus.h"
|
|
|
|
#define MS5803_SCK(x) HAL_GPIO_WritePin(MS5803_SCK_GPIO_Port,MS5803_SCK_Pin,(GPIO_PinState)x)
|
|
#define MS5803_MOSI(x) HAL_GPIO_WritePin(MS5803_MOSI_GPIO_Port,MS5803_MOSI_Pin,(GPIO_PinState)x)
|
|
#define MS5803_MISO HAL_GPIO_ReadPin(MS5803_MISO_GPIO_Port,MS5803_MISO_Pin)
|
|
|
|
#define SENSOR_SELECT(x) HAL_GPIO_WritePin(SENSOR_SELECT_GPIO_Port,SENSOR_SELECT_Pin,(GPIO_PinState)x)
|
|
|
|
/* Size of buffer */
|
|
#define BUFFERSIZE (COUNTOF(aTxBuffer) - 1)
|
|
|
|
//************************CMD*********************************
|
|
|
|
#define RESET 0x1E
|
|
|
|
#define CD1_256 0x40 //OSR=256
|
|
#define CD1_512 0x42 //OSR=512
|
|
#define CD1_1024 0x44 //OSR=256
|
|
#define CD1_2048 0x46 //OSR=256
|
|
#define CD1_4096 0x48 //OSR=256
|
|
|
|
#define CD2_256 0x50 //OSR=256
|
|
#define CD2_512 0x52 //OSR=512
|
|
#define CD2_1024 0x54 //OSR=256
|
|
#define CD2_2048 0x56 //OSR=256
|
|
#define CD2_4096 0x58 //OSR=256
|
|
|
|
#define ADC_Read 0x00
|
|
|
|
#define Cof1 0xA2
|
|
#define Cof2 0xA4
|
|
#define Cof3 0xA6
|
|
#define Cof4 0xA8
|
|
#define Cof5 0xAA
|
|
#define Cof6 0xAC
|
|
//#define CRC 0xAE
|
|
|
|
//***********************************************************
|
|
|
|
typedef volatile struct
|
|
{
|
|
uint16_t C1[8]; //Pressure sensitivity
|
|
|
|
uint16_t C2[8]; //Pressure offset
|
|
|
|
uint16_t C3[8]; //Temperature coefficient of pressure sensitivity
|
|
|
|
uint16_t C4[8]; //Temperature coefficient of pressure offset
|
|
|
|
uint16_t C5[8]; //Reference temperature
|
|
|
|
uint16_t C6[8]; //Temperature coefficient of the temperature
|
|
}PromVar;
|
|
|
|
extern volatile int32_t CurrentTemp,CurrentPress;
|
|
extern uint8_t NSS_Select;
|
|
|
|
void setcs(void);
|
|
void clrcs(void);
|
|
|
|
void ms5803_init(void);
|
|
void ms5803_task(void);
|
|
|
|
#endif
|
|
|
|
/****END OF FILE****/
|
|
|