Files
microchip-application-bmd38…/edc20_pin_ctrl.h
T
chain40 31c691c7c5 feat: 實作 ads8691 driver 以及 adc_drv_if 實作
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 值時會先預讀一次更新量測的結果
2024-03-22 07:29:06 +08:00

58 lines
2.2 KiB
C

#pragma once
#ifndef __EDC20_PIN_CTRL_H__
#define __EDC20_PIN_CTRL_H__
#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 SPI2_CLK_PIN NRF_GPIO_PIN_MAP(0, 12)
#define SPI2_MOSI_PIN NRF_GPIO_PIN_MAP(0, 7)
#define SPI2_MISO_PIN NRF_GPIO_PIN_MAP(1, 9)
void gpio_init(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, uint8_t tx_buffer_length);
void spi2_write(uint32_t cs_pin, uint8_t *p_tx_buffer, uint8_t tx_buffer_length, uint8_t *p_rx_buf, uint8_t rx_buffer_length);
void spi2_set_mode(nrf_drv_spi_mode_t mode);
#endif // !__EDC20_PIN_CTRL_H__