/** * @brief Hard-resets AD1854. * * @details Resets the AD1854 device instance via hardware by toggling the * GPIO pin connected to AD1854 device. * * @param [in] hDevice AD1854 instance to work on. * @param [in] bEnable TRUE to enable AD1854 dataflow, FALSE to disable. * * @return Status * - #ADI_AD1854_SUCCESS: Successfully updated AD1854 dataflow. * - #ADI_AD1854_BAD_HANDLE: Supplied Device handle is invalid. * - #ADI_AD1854_GPIO_ERROR: GPIO configuration error. * */ ADI_AD1854_RESULT adi_ad1854_HwReset( ADI_AD1854_HANDLE const hDevice, ADI_GPIO_PORT const ePort, uint32_t const Pin) { /* Pointer to AD1854 device instance to work on */ ADI_AD1854_DEV *pDevice = (ADI_AD1854_DEV *) hDevice; /* Loop variable */ volatile uint32_t i; /* IF (Debug information enabled) */ #if defined (ADI_DEBUG) /* IF (AD1854 Handle is invalid) */ if (ValidateHandle (hDevice) != ADI_AD1854_SUCCESS) { return (ADI_AD1854_BAD_HANDLE); } #endif /* IF (AD1854 dataflow enabled) */ if (pDevice->bIsEnabled) { /* Report failure as AD1854 is already running */ return (ADI_AD1854_ALREADY_RUNNING); } /* Set the GPIO direction */ if (adi_gpio_SetDirection (ePort, Pin, ADI_GPIO_DIRECTION_OUTPUT)) { /* Failed to configure GPIO, return failure */ return (ADI_AD1854_GPIO_ERROR); } /* De-assert reset signal */ if (adi_gpio_Clear (ePort, Pin)) { /* Failed to configure GPIO, return failure */ return (ADI_AD1854_GPIO_ERROR); } /* Provide some delay to reset the device */ for (i = 0xFFFFFu; i > 0u; i--) { ; } /* Assert reset signal */ if (adi_gpio_Set (ePort, Pin)) { /* Failed to configure GPIO, return failure */ return (ADI_AD1854_GPIO_ERROR); } /* Return success */ return (ADI_AD1854_SUCCESS); }
//将片选取消SPI的复用,用于连续采样模式,同时拉低 void ad7793ContinueCSPin_Set(AD7793_CS Csx) { if(Csx.Spix == BF609_SPI0) { *pREG_PORTD_MUX &= ~SPI0_SEL1_PORTD_MUX;//Disable /* PORTx_FER registers */ *pREG_PORTD_FER &= ~SPI0_SEL1_PORTD_FER; //Disable /* set GPIO output */ adi_gpio_SetDirection( ADI_GPIO_PORT_D, ADI_GPIO_PIN_11, ADI_GPIO_DIRECTION_OUTPUT); /* set it down */ adi_gpio_Clear(ADI_GPIO_PORT_D, ADI_GPIO_PIN_11); } else if(Csx.Spix == BF609_SPI1) { *pREG_PORTD_MUX &= ~SPI1_SEL3_PORTD_MUX; /* PORTx_FER registers */ *pREG_PORTD_FER &= ~SPI1_SEL3_PORTD_FER; /* set GPIO output */ adi_gpio_SetDirection( ADI_GPIO_PORT_D, ADI_GPIO_PIN_10, ADI_GPIO_DIRECTION_OUTPUT); /* set it down */ adi_gpio_Clear(ADI_GPIO_PORT_D, ADI_GPIO_PIN_10); } }