controller-pcba/User/driver/dac161s997.h

32 lines
1.3 KiB
C
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

#ifndef __DAC161S997_H__
#define __DAC161S997_H__
#include "main.h"
#include "user_spi.h"
/* Defines ********************************************************************/
/**
* @defgroup DAC161S997_REGS
* @{
*/
#define DAC161S997_XFR_REG 0x01 /**< Command: transfer data into register (protected write mode) */
#define DAC161S997_NOP_REG 0x02 /**< Command: does nothing except resetting the timeout timer */
#define DAC161S997_PROTECT_REG_WR_REG 0x03 /**< 1 means protected write mode in effect */
#define DAC161S997_DACCODE_REG 0x04 /**< 16 bit DAC code to be written */
#define DAC161S997_ERR_CONFIG_REG 0x05 /**< Configuration of error states */
#define DAC161S997_ERR_LOW_REG 0x06 /**< DAC code for the <4mA alarm level */
#define DAC161S997_ERR_HIGH_REG 0x07 /**< DAC code for the >20mA alarm level */
#define DAC161S997_RESET_REG 0x08 /**< Command: reset the chip */
#define DAC161S997_STATUS_REG 0x09 /**< Status of the chip */
#define DAC161S997_SPI SPI1
void dac161s997_write_reg(uint8_t dac_num, uint8_t reg, uint16_t data);
uint16_t dac161s997_read(uint8_t reg);
extern void dac161s997_init(void);
extern void dac161s997_output(uint8_t dac_num, float current);
// 定义DAC芯片编号只有一块DAC161S997
#define DAC161S997 1
#endif