184 lines
6.2 KiB
C
184 lines
6.2 KiB
C
/*******************************************************************************
|
||
* File Name : SIG24130.h
|
||
* Description : Implementation of SIG24130/SIG24131/SIG24132 Driver.
|
||
* Author : Bob Zhou(support@signal-micro.com)
|
||
********************************************************************************
|
||
* Copyright 2023(c) Nanjing Signal Micro.
|
||
*
|
||
* All rights reserved.
|
||
*
|
||
* Software License Agreement
|
||
*
|
||
* Redistribution and use in source and binary forms, with or without modification,
|
||
* are permitted provided that the following conditions are met:
|
||
*
|
||
* - Redistributions of source code must retain the above copyright notice,
|
||
* this list of conditions and the following disclaimer.
|
||
*
|
||
* - Redistributions in binary form must reproduce the above copyright notice,
|
||
* this list of conditions and the following disclaimer in the documentation
|
||
* and/or other materials provided with the distribution.
|
||
*
|
||
* - Neither the name of Nanjing Signal Micro nor the names of its contributors
|
||
* may be used to endorse or promote products derived from this software
|
||
* without specific prior written permission.
|
||
*
|
||
* - The use of this software may or may not infringe the patent rights of one
|
||
* or more patent holders. This license does not release you from the requirement
|
||
* that you obtain separate licenses from these patent holders to use this software.
|
||
*
|
||
* - Use of the software either in source or binary form, must be run on or directly
|
||
* connected to an Nanjing Signal Micro component.
|
||
*
|
||
* THIS SOFTWARE IS PROVIDED BY NANJING SIGNAL MICRO "AS IS" AND ANY EXPRESS OR
|
||
* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, NON-INFRINGEMENT,
|
||
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
|
||
* IN NO EVENT SHALL NANJING SIGNAL MICRO BE LIABLE FOR ANY DIRECT, INDIRECT,
|
||
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
||
* LIMITED TO, INTELLECTUAL PROPERTY RIGHTS, PROCUREMENT OF SUBSTITUTE GOODS OR
|
||
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
||
* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
|
||
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||
*
|
||
********************************************************************************
|
||
* SVN Revision: 1.0
|
||
*******************************************************************************/
|
||
|
||
#ifndef __SIG24130_H__
|
||
#define __SIG24130_H__
|
||
|
||
#ifdef __cplusplus
|
||
extern "C"
|
||
{
|
||
#endif
|
||
#include "stdint.h"
|
||
#include "data_type_def.h"
|
||
|
||
#define SIG24130_CS_GPIO_Port GPIOB
|
||
#define SIG24130_CS_Pin GPIO_PIN_12
|
||
#define SIG24130_CSn_LOW HAL_GPIO_WritePin(SIG24130_CS_GPIO_Port, SIG24130_CS_Pin, GPIO_PIN_RESET)
|
||
#define SIG24130_CSn_HIGH HAL_GPIO_WritePin(SIG24130_CS_GPIO_Port, SIG24130_CS_Pin, GPIO_PIN_SET)
|
||
|
||
// Register address
|
||
#define CMD_WRITE 0x20
|
||
#define CMD_READ 0x40
|
||
#define CONF0 0x01
|
||
#define CONF1 0x02
|
||
#define OFFSET 0x03
|
||
#define GAIN 0x04
|
||
// Speed choices
|
||
#define SPEED_2p5 0x00
|
||
#define SPEED_5 0x01
|
||
#define SPEED_10 0x02
|
||
#define SPEED_12p5 0x03
|
||
#define SPEED_15 0x04
|
||
#define SPEED_20 0x05
|
||
#define SPEED_25 0x06
|
||
#define SPEED_30 0x07
|
||
#define SPEED_40 0x08
|
||
#define SPEED_50 0x09
|
||
#define SPEED_60 0x0A
|
||
#define SPEED_80 0x0B
|
||
#define SPEED_100 0x0C
|
||
#define SPEED_120 0x0D
|
||
#define SPEED_160 0x0E
|
||
#define SPEED_200 0x0F
|
||
#define SPEED_240 0x10
|
||
#define SPEED_250 0x31
|
||
#define SPEED_300 0x11
|
||
#define SPEED_400 0x12
|
||
#define SPEED_480 0x13
|
||
#define SPEED_500 0x34
|
||
#define SPEED_600 0x14
|
||
#define SPEED_800 0x15
|
||
#define SPEED_1000 0x36
|
||
#define SPEED_1200 0x16
|
||
#define SPEED_2000 0x37
|
||
#define SPEED_2400 0x17
|
||
#define SPEED_4000 0x38
|
||
#define SPEED_4800 0x18
|
||
#define SPEED_8000 0x39
|
||
#define SPEED_9600 0x19
|
||
// Gain choices
|
||
#define GAIN_1 0x00
|
||
#define GAIN_2 0x01
|
||
#define GAIN_4 0x02
|
||
#define GAIN_8 0x03
|
||
#define GAIN_16 0x04
|
||
#define GAIN_32 0x05
|
||
#define GAIN_64 0x06
|
||
#define GAIN_128 0x07
|
||
#define GAIN_256 0x08
|
||
// Input choices
|
||
#define AIN0 0x00
|
||
#define AIN1 0x01
|
||
#define AIN2 0x02
|
||
#define AIN3 0x03
|
||
#define AIN4 0x04
|
||
#define AIN5 0x05
|
||
#define AIN6 0x06
|
||
#define AIN7 0x07
|
||
#define AINCOM 0x08
|
||
#define TPS 0x09
|
||
#define AVSS 0x0A
|
||
#define AVDD 0x0B
|
||
#define AVDD_AVSS 0x0C
|
||
#define DVDD_DVSS 0x0D
|
||
// Reference choices
|
||
#define EXTREF0 0x00
|
||
#define EXTREF1 0x01
|
||
#define INTREF_2P5V 0x02
|
||
#define INTREF_1P17V 0x03
|
||
// IDAC current choices
|
||
#define CURRENT_0uA 0x00
|
||
#define CURRENT_10uA 0x01
|
||
#define CURRENT_50uA 0x02
|
||
#define CURRENT_100uA 0x03
|
||
#define CURRENT_200uA 0x04
|
||
#define CURRENT_250uA 0x05
|
||
#define CURRENT_500uA 0x06
|
||
#define CURRENT_1000uA 0x07
|
||
|
||
extern void delay_nus(int nus);
|
||
extern void SIG24130_SendByte(uint8_t data);
|
||
extern uint8_t SIG24130_ReceiveByte(void);
|
||
extern uint8_t SPIDEV1_transfer(uint8_t *send, uint8_t *receive, uint8_t bytes_num);
|
||
|
||
extern void SIG24130_WriteRegister(uint8_t addr, uint8_t H_DATA, uint8_t M_DATA, uint8_t L_DATA);
|
||
extern uint32_t SIG24130_ReadRegister(uint8_t addr);
|
||
|
||
extern void SIG24130_SetInputMux(uint8_t muxp, uint8_t muxn);
|
||
extern void SIG24130_SetSpeed(uint8_t speed);
|
||
extern void SIG24130_SetFilter(uint8_t sinc4, uint8_t rej60);
|
||
extern void SIG24130_SetGain(uint8_t gain);
|
||
extern void SIG24130_SetBuffer(uint8_t buffer);
|
||
extern void SIG24130_SetRefMux(uint8_t refmux);
|
||
extern void SIG24130_SetSingleShot(uint8_t single);
|
||
extern void SIG24130_SetZeroLatency(uint8_t latency);
|
||
|
||
extern void SIG24130_SetIDAC(uint8_t idac_size, uint8_t idac2_mux, uint8_t idac1_mux, uint8_t idac_pair);
|
||
extern void SIG24130_SetBCS(uint8_t burnout);
|
||
extern void SIG24130_SetVbias(uint8_t vbias);
|
||
extern void SIG24130_SetDelay(uint8_t delay);
|
||
extern void SIG24130_SetRefOut(uint8_t refout);
|
||
|
||
extern void SIG24130_Reset(void);
|
||
extern void SIG24130_Sync(void);
|
||
extern void SIG24130_Sleep(void);
|
||
extern void SIG24130_Wakeup(void);
|
||
extern void SIG24130_SYSOCAL(void);
|
||
extern void SIG24130_SYSGCAL(void);
|
||
extern void SIG24130_SELFOCAL(void);
|
||
extern void SIG24130_Init(void);
|
||
|
||
extern unsigned long SIG24130_RetrievalData(uint8_t rdata, uint8_t chksum);
|
||
extern unsigned long SIG16130_RetrievalData(uint8_t rdata, uint8_t chksum);
|
||
|
||
extern void fun_get_sig16132_ch(uint8_t channel, float32 *data);
|
||
|
||
#ifdef __cplusplus
|
||
}
|
||
#endif
|
||
#endif
|