初始版本
This commit is contained in:
@@ -0,0 +1,110 @@
|
||||
#ifndef ____HDL_CS5552_H_
|
||||
#define ____HDL_CS5552_H_
|
||||
|
||||
#include "hc32_ll.h"
|
||||
#include "hdl_clk.h"
|
||||
|
||||
#define CS5552_SPI CM_SPI1
|
||||
#define CS5552_SPI_CLK FCG1_PERIPH_SPI1
|
||||
|
||||
#define CS5552_CS_PORT GPIO_PORT_A
|
||||
#define CS5552_CS_PIN GPIO_PIN_04
|
||||
#define CS5552_CS_FUNC GPIO_FUNC_42
|
||||
|
||||
#define CS5552_SCLK_PORT GPIO_PORT_A
|
||||
#define CS5552_SCLK_PIN GPIO_PIN_07
|
||||
#define CS5552_SCLK_FUNC GPIO_FUNC_43
|
||||
|
||||
#define CS5552_MISO_PORT GPIO_PORT_A
|
||||
#define CS5552_MISO_PIN GPIO_PIN_06
|
||||
#define CS5552_MISO_FUNC GPIO_FUNC_41
|
||||
|
||||
#define CS5552_MOSI_PORT GPIO_PORT_A
|
||||
#define CS5552_MOSI_PIN GPIO_PIN_05
|
||||
#define CS5552_MOSI_FUNC GPIO_FUNC_40
|
||||
|
||||
#define SET_CS5552_CS() GPIO_SetPins(CS5552_CS_PORT, CS5552_CS_PIN)
|
||||
#define CLR_CS5552_CS() GPIO_ResetPins(CS5552_CS_PORT, CS5552_CS_PIN)
|
||||
|
||||
#define SET_CS5552_DOUT() GPIO_SetPins(CS5552_MISO_PORT, CS5552_MISO_PIN)
|
||||
#define CLR_CS5552_DOUT() GPIO_ResetPins(CS5552_MISO_PORT, CS5552_MISO_PIN)
|
||||
#define GET_CS5552_DOUT() GPIO_ReadInputPins(CS5552_MISO_PORT, CS5552_MISO_PIN)
|
||||
|
||||
#define SET_CS5552_DIN() GPIO_SetPins(CS5552_MOSI_PORT, CS5552_MOSI_PIN)
|
||||
#define CLR_CS5552_DIN() GPIO_ResetPins(CS5552_MOSI_PORT, CS5552_MOSI_PIN)
|
||||
|
||||
#define SET_CS5552_SCLK() GPIO_SetPins(CS5552_SCLK_PORT, CS5552_SCLK_PIN)
|
||||
#define CLR_CS5552_SCLK() GPIO_ResetPins(CS5552_SCLK_PORT, CS5552_SCLK_PIN)
|
||||
|
||||
#define OS_CH0_R 0x05
|
||||
#define OS_CH0_W 0x00
|
||||
|
||||
#define GAIN_CH0_R 0x0C
|
||||
#define GAIN_CH0_W 0x09
|
||||
|
||||
#define OS_CH1_R 0x14
|
||||
#define OS_CH1_W 0x11
|
||||
|
||||
#define GAIN_CH1_R 0x1D
|
||||
#define GAIN_CH1_W 0x18
|
||||
|
||||
#define CONV_CONF0_R 0x24
|
||||
#define CONV_CONF0_W 0x21
|
||||
|
||||
#define CONV_CONF1_R 0x2D
|
||||
#define CONV_CONF1_W 0x28
|
||||
|
||||
#define SYS_CONF0_R 0x35
|
||||
#define SYS_CONF0_W 0x30
|
||||
|
||||
#define SYS_CONF1_R 0x3C
|
||||
#define SYS_CONF1_W 0x39
|
||||
|
||||
#define SYS_CONF2_R 0x44
|
||||
#define SYS_CONF2_W 0x41
|
||||
|
||||
#define CONV_DATA_R 0x55
|
||||
|
||||
#define CONV_CH0 0x81
|
||||
#define CONV_CH1 0x90
|
||||
|
||||
#define SELF_OFFSET_CH0 0x84
|
||||
#define SELF_OFFSET_CH1 0x95
|
||||
|
||||
#define SYS_OFFSET_CH0 0x8B
|
||||
#define SYS_OFFSET_CH1 0x9A
|
||||
|
||||
#define OFFSET_CNT 9
|
||||
|
||||
typedef enum
|
||||
{
|
||||
CS5552_IDLE,
|
||||
CS5552_OFFSET,
|
||||
CS5552_OFFSET_READ,
|
||||
CS5552_START,
|
||||
CS5552_READ
|
||||
}en_cs5552_step;
|
||||
|
||||
typedef enum
|
||||
{
|
||||
CS5552_CH0,
|
||||
CS5552_CH1,
|
||||
}en_cs5552_ch;
|
||||
|
||||
typedef struct
|
||||
{
|
||||
en_cs5552_step step; //流程
|
||||
en_cs5552_ch channel_sta; //当前转换通道
|
||||
int32_t buf[2]; //通道数据
|
||||
uint32_t offset_ch0[OFFSET_CNT]; //通道0校准值
|
||||
uint32_t offset_ch1[OFFSET_CNT]; //通道1校准值
|
||||
}stc_cs5552_t;
|
||||
|
||||
void hdl_cs5552_init(void);
|
||||
uint32_t hdl_cs5552_reg_read(uint8_t cmd);
|
||||
|
||||
void hdl_cs5552_value_get(int32_t *buf);
|
||||
void hdl_cs5552_conv_start(void);
|
||||
void hdl_cs5552_proc(void);
|
||||
|
||||
#endif
|
||||
Reference in New Issue
Block a user