31c691c7c5
1. 預設 spi2 為 mode 0, 當 ads8691 初始化完成後, 將 spi2 切為 mode 2 2. 承上, 所以 adc driver 要比 dac driver 更早初始化 3. 將來會將 spi mode 整合 spi transfer, 雖然週邊共用 spi 但是可以每個週邊使用自己的 mode 4. 當調整增益, 更改輸出格式, 切換輸入來源時會把 m_flush_data 設為 1, 在讀 ad 值時會先預讀一次更新量測的結果
35 lines
599 B
C
35 lines
599 B
C
#pragma once
|
|
#ifndef __ADC_DRV_IF_H__
|
|
#define __ADC_DRV_IF_H__
|
|
|
|
#include <stdint.h>
|
|
#include <stdlib.h>
|
|
|
|
#define ADC0 (0x01 << 0)
|
|
#define ADC1 (0x01 << 1)
|
|
#define ADC2 (0x01 << 2)
|
|
#define ADC3 (0x01 << 3)
|
|
|
|
typedef enum
|
|
{
|
|
NP_GAIN_3P000,
|
|
NP_GAIN_2P500,
|
|
NP_GAIN_1P500,
|
|
NP_GAIN_1P250,
|
|
NP_GAIN_0P625,
|
|
P_GAIN_3P000,
|
|
P_GAIN_2P500,
|
|
P_GAIN_1P500,
|
|
P_GAIN_1P250,
|
|
} adc_gain_t;
|
|
|
|
typedef struct
|
|
{
|
|
int (*init)(void);
|
|
int (*reset)(void);
|
|
int (*read)(uint32_t channel, int32_t *adc_val);
|
|
int (*gain)(adc_gain_t gain);
|
|
} adc_drv_if_t;
|
|
|
|
#endif // !__ADC_DRV_IF_H__
|