44 lines
1.9 KiB
C
44 lines
1.9 KiB
C
#ifndef __DAC161S997_H__
|
|
#define __DAC161S997_H__
|
|
|
|
#include "main.h"
|
|
|
|
#define DAC_SPI_SCK(x) HAL_GPIO_WritePin(DAC_SPI_SCLK_GPIO_Port,DAC_SPI_SCLK_Pin,(GPIO_PinState)x)
|
|
#define DAC_SPI_MOSI(x) HAL_GPIO_WritePin(DAC_SPI_MOSI_GPIO_Port,DAC_SPI_MOSI_Pin,(GPIO_PinState)x)
|
|
#define DAC_SPI_MISO HAL_GPIO_ReadPin(DAC_SPI_MISO_GPIO_Port,DAC_SPI_MISO_Pin)
|
|
|
|
#define DAC_NSS1(x) HAL_GPIO_WritePin(DAC_NSS1_GPIO_Port,DAC_NSS1_Pin,(GPIO_PinState)x)
|
|
#define DAC_NSS2(x) HAL_GPIO_WritePin(DAC_NSS2_GPIO_Port,DAC_NSS2_Pin,(GPIO_PinState)x)
|
|
#define DAC_NSS3(x) HAL_GPIO_WritePin(DAC_NSS3_GPIO_Port,DAC_NSS3_Pin,(GPIO_PinState)x)
|
|
#define DAC_NSS4(x) HAL_GPIO_WritePin(DAC_NSS4_GPIO_Port,DAC_NSS4_Pin,(GPIO_PinState)x)
|
|
|
|
|
|
/* 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_RESET_CODE 0xC33C /**< Status of the chip */
|
|
|
|
uint8_t write_spi_byte(uint8_t Byte);
|
|
uint8_t read_spi_byte(void);
|
|
|
|
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);
|
|
|
|
#endif
|
|
|
|
|