/** @brief SPI initialization @return none **/ void SPI_Init(void) { DioPul(pADI_GP0, 0xf8); /* Disable the internal pull ups on P0 */ DioCfg(pADI_GP0, 0x0015); /* Configure P0[2:0] for SPI1 */ DioPulPin(AD7798_CS_PORT, AD7798_CS_PIN_NUMBER, 0); // Disable the internal pull up on AD7798 CS pin DioOenPin(AD7798_CS_PORT, AD7798_CS_PIN_NUMBER, 1); // Set CS pin for AD7798 as output DioSet(AD7798_CS_PORT, AD7798_CS_PIN); DioPulPin(ADT7310_CS_PORT, ADT7310_CS_PIN_NUMBER, 0); // Disable the internal pull up on ADT7310 CS pin DioOenPin(ADT7310_CS_PORT, ADT7310_CS_PIN_NUMBER, 1); // Set CS pin for ADT7310 as output DioSet(ADT7310_CS_PORT, ADT7310_CS_PIN); DioPulPin(AD5270_CS_PORT, AD5270_CS_PIN_NUMBER, 0); // Disable the internal pull up on ADT7310 CS pin DioOenPin(AD5270_CS_PORT, AD5270_CS_PIN_NUMBER, 1); // Set CS pin for ADT7310 as output DioSet(AD5270_CS_PORT, AD5270_CS_PIN); SpiBaud(pADI_SPI1, 9, SPIDIV_BCRST_DIS); /* Set the SPI1 clock rate in Master mode to x kHz. */ /* SPI configuration*/ SpiCfg(pADI_SPI1, SPICON_MOD_TX4RX4, SPICON_MASEN_EN, SPICON_CON_EN | SPICON_SOEN_EN | SPICON_RXOF_EN | SPICON_ZEN_EN | SPICON_TIM_TXWR | SPICON_CPOL_HIGH | SPICON_CPHA_SAMPLETRAILING | SPICON_ENABLE_EN); }
/** @brief Initialization @return none **/ void AD7091R_Init(void) { SPI_Init(); /* SPI initialization */ DioPulPin(CONVST_PORT, CONVST_PIN_NUMBER, 0); /* Disable the internal pull up on CONVST pin */ DioOenPin(CONVST_PORT, CONVST_PIN_NUMBER, 1); /* Set CONVST pin as output */ DioSet(CONVST_PORT, CONVST_PIN); /* Set CONVST pin as high */ AD7091R_SoftwareReset(); /* Perform an AD7091R software reset required at initialization */ u8StartCounter = 0; /* Reset start counter */ }
static DeviceStatus_TYPE _drv_devopen(pDeviceAbstract pdev, uint16 oflag){ DioCfgPin(pADI_GP0,PIN0,0); //Set P0.0 as GPIO DioOenPin(pADI_GP0,PIN0,1); //Enable P0.0 Output DioPulPin(pADI_GP0,PIN0,1); //Enable P0.0 Output Pullup pwm_output_enable(); _drv_ioctl(pdev, PWM_IOC_RHREF_FORCE_H, NULL); _drv_ioctl(pdev, PWM_IOC_HEAT_FORCE_H, NULL); _drv_ioctl(pdev, PWM_IOC_MEASURE_ON, NULL); return DEVICE_OK; }
void SPIClass::Init() { DioPulPin(pADI_GP0, PIN0, 0); DioCfgPin(pADI_GP0, PIN0, 1); //MISO DioPulPin(pADI_GP0, PIN1, 0); DioCfgPin(pADI_GP0, PIN1, 1); //SCLK DioPulPin(pADI_GP0, PIN2, 0); DioCfgPin(pADI_GP0, PIN2, 1); //MOSI DioPulPin(CS_PORT, CS_PIN_NUMBER, 0); /* Disable the internal pull up on AD7798 CS pin */ DioOenPin(CS_PORT, CS_PIN_NUMBER, 1); /* Set CS pin for AD7798 as output */ DioSet(CS_PORT, CS_PIN); SpiBaud(pADI_SPI1, 9, SPIDIV_BCRST_DIS); /* Set the SPI1 clock rate in Master mode to x kHz. */ /* SPI configuration*/ SpiCfg(pADI_SPI1, SPICON_MOD_TX4RX4, SPICON_MASEN_EN, SPICON_CON_EN | SPICON_SOEN_EN | SPICON_RXOF_EN | SPICON_ZEN_EN | SPICON_TIM_TXWR | SPICON_CPOL_HIGH | SPICON_CPHA_SAMPLETRAILING | SPICON_ENABLE_EN); }
void init(uint32_t baud_rate) { if (m_handle_uart == (timer_handle_type)-1){ //300ms m_handle_uart = t_timer_manage.hard_timer_register(300, SV_TIMER_FLAG_ONE_SHOT, transceiver_uart0::byte_timer_timeout, this, "byte timer"); ASSERT(m_handle_uart != (timer_handle_type)-1); } //Select IO pins for UART. #ifdef def_HALF_DUPLEX_RS485 DioCfgPin(pADI_GP0,PIN4,0); //Set P0.4 as UART RTS //DioPulPin(pADI_GP0,PIN4,0); DioOcePin(pADI_GP0,PIN4,1); DioOenPin(pADI_GP0,PIN4,1); #endif #ifdef def_RUN_IN_EVB // Configure P0.1/P0.2 for UART pADI_GP0->GPCON = ((pADI_GP0->GPCON)&(~(BIT2|BIT3|BIT4|BIT5)))|0x3C; #else DioCfgPin(pADI_GP0,PIN6,1); //Set P0.6 as UART RXD DioCfgPin(pADI_GP0,PIN7,2); //Set P0.7 as UART TXD #endif UrtCfg(pADI_UART, baud_rate, COMLCR_WLS_8BITS, 0); // setup baud rate for 9600, 8-bits UrtMod(pADI_UART, COMMCR_DTR, 0); // Setup modem bits // Setup UART IRQ sources UrtIntCfg(pADI_UART, COMIEN_ERBFI | COMIEN_ELSI | COMIEN_EDSSI #ifdef def_DMA_SEND |COMIEN_EDMAT); #else );