99 lines
3.3 KiB
C
99 lines
3.3 KiB
C
#ifndef __EDC20_IO_H__
|
|
#define __EDC20_IO_H__
|
|
|
|
#ifdef __cplusplus
|
|
extern "C" {
|
|
#endif
|
|
|
|
#include <stdint.h>
|
|
#include "nrf_drv_spi.h"
|
|
#include "nrf_gpio.h"
|
|
|
|
#define ADCA2_PIN NRF_GPIO_PIN_MAP(0, 25)
|
|
#define ADCA1_PIN NRF_GPIO_PIN_MAP(0, 19)
|
|
#define ADCA0_PIN NRF_GPIO_PIN_MAP(0, 21)
|
|
#define RST_SW_PIN NRF_GPIO_PIN_MAP(0, 17)
|
|
#define POWER_5V_EN_PIN NRF_GPIO_PIN_MAP(0, 24)
|
|
#define POWER_12V_EN_PIN NRF_GPIO_PIN_MAP(0, 23)
|
|
#define OFF_PIN NRF_GPIO_PIN_MAP(0, 15)
|
|
#define SHUT_DOWN_PIN NRF_GPIO_PIN_MAP(1, 8)
|
|
#define INT9466_PIN NRF_GPIO_PIN_MAP(0, 27)
|
|
#define Vout_FB_PIN NRF_GPIO_PIN_MAP(0, 26)
|
|
#define Vout_IN_PIN NRF_GPIO_PIN_MAP(0, 4)
|
|
#define LEDTH_PIN NRF_GPIO_PIN_MAP(0, 28)
|
|
#define Iin4_TEST_PIN NRF_GPIO_PIN_MAP(1, 12)
|
|
#define Iin3_SEL_PIN NRF_GPIO_PIN_MAP(1, 14)
|
|
#define VBAT_PIN NRF_GPIO_PIN_MAP(0, 3)
|
|
#define Iin3_PIN NRF_GPIO_PIN_MAP(1, 13)
|
|
#define Iin2_PIN NRF_GPIO_PIN_MAP(1, 3)
|
|
#define Iin1_PIN NRF_GPIO_PIN_MAP(1, 10)
|
|
#define Vin2_PIN NRF_GPIO_PIN_MAP(1, 6)
|
|
#define Vin1_PIN NRF_GPIO_PIN_MAP(1, 11)
|
|
#define CV_CTRL_PIN NRF_GPIO_PIN_MAP(0, 16)
|
|
|
|
#define I2C0_SDA NRF_GPIO_PIN_MAP(0, 11)
|
|
#define I2C0_SCL NRF_GPIO_PIN_MAP(0, 22)
|
|
|
|
#define SPI1_CLK_PIN NRF_GPIO_PIN_MAP(0, 13)
|
|
#define SPI1_MOSI_PIN NRF_GPIO_PIN_MAP(0, 14)
|
|
|
|
#define CS_SW_PIN NRF_GPIO_PIN_MAP(0, 20)
|
|
#define CS_MEM_PIN NRF_GPIO_PIN_MAP(0, 8)
|
|
#define CS_ADC_PIN NRF_GPIO_PIN_MAP(0, 6)
|
|
#define CS_DAC_PIN NRF_GPIO_PIN_MAP(0, 5)
|
|
#define SPIM_CLK_PIN NRF_GPIO_PIN_MAP(0, 12)
|
|
#define SPIM_MOSI_PIN NRF_GPIO_PIN_MAP(0, 7)
|
|
#define SPIM_MISO_PIN NRF_GPIO_PIN_MAP(1, 9)
|
|
|
|
typedef struct
|
|
{
|
|
float mV_start;
|
|
float mV_stop;
|
|
float mV_step;
|
|
uint32_t uS_step;
|
|
uint32_t cycles;
|
|
bool hi_z_en;
|
|
} elite_dac_config_t;
|
|
|
|
void gpio_init(void);
|
|
void circuit_selection_vin_0(void);
|
|
void circuit_selection_vin_1(void);
|
|
void circuit_selection_vin_2(void);
|
|
void circuit_selection_Iin_0(void);
|
|
void circuit_selection_Iin_1(void);
|
|
void circuit_selection_Iin_2(void);
|
|
void circuit_selection_Iin_3(void);
|
|
void circuit_selection_Iin_4(void);
|
|
void circuit_selection_dac_coarse_tune_c(void);
|
|
void circuit_selection_dac_fine_tune_f0(void);
|
|
void circuit_selection_dac_fine_tune_f1(void);
|
|
void circuit_selection_dac_fine_tune_f2(void);
|
|
void circuit_selection_cv3_config(void);
|
|
void circuit_selection_cc_config(void);
|
|
void circuit_selection_dac_circuit_open(void);
|
|
|
|
void twi_init(void);
|
|
void twi0_write_reg(uint8_t slave_addr, uint8_t reg_addr, uint8_t *data, uint8_t data_len);
|
|
void twi0_read_reg(uint8_t slave_addr, uint8_t reg_addr, uint8_t *p_rx_buf, uint8_t rx_buffer_length);
|
|
|
|
void spi_init(void);
|
|
void spi1_write(uint8_t *p_tx_buffer, uint16_t tx_buffer_length);
|
|
void spim_xfer(uint32_t cs_pin, nrf_spim_mode_t mode, uint8_t *p_tx_buffer, uint16_t tx_buffer_length, uint8_t *p_rx_buf, uint16_t rx_buffer_length);
|
|
void spi2_set_mode(nrf_drv_spi_mode_t mode);
|
|
|
|
void edc20_io_init(void);
|
|
void edc20_io_power_off(void);
|
|
void edc20_io_power_on(void);
|
|
|
|
void edc20_dac_tim_start(uint32_t period, void (*callback)(void *p_arg), void *p_arg);
|
|
void edc20_dac_tim_stop(void);
|
|
|
|
void edc20_adc_tim_start(elite_dac_config_t *p_config);
|
|
void edc20_adc_tim_stop(void);
|
|
|
|
#ifdef __cplusplus
|
|
}
|
|
#endif
|
|
|
|
#endif /* ! __EDC20_IO_H__ */
|