/***************************************************************************** * | File : DEV_Config.c * | Author : Waveshare team * | Function : Hardware underlying interface * | Info : *---------------- * | This version: V3.0 * | Date : 2019-07-31 * | Info : # # Permission is hereby granted, free of charge, to any person obtaining a copy # of this software and associated documnetation files (the "Software"), to deal # in the Software without restriction, including without limitation the rights # to use, copy, modify, merge, publish, distribute, sublicense, and/or sell # copies of theex Software, and to permit persons to whom the Software is # furished to do so, subject to the following conditions: # # The above copyright notice and this permission notice shall be included in # all copies or substantial portions of the Software. # # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, # FITNESS OR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE # AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER # LIABILITY WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN # THE SOFTWARE. # ******************************************************************************/ #include "DEV_Config.h" #if USE_LGPIO_LIB int GPIO_Handle; int SPI_Handle; #endif /** * GPIO **/ int EPD_RST_PIN; int EPD_DC_PIN; int EPD_CS_PIN; int EPD_BUSY_PIN; int EPD_PWR_PIN; int EPD_MOSI_PIN; int EPD_SCLK_PIN; /** * GPIO read and write **/ void DEV_Digital_Write(UWORD Pin, UBYTE Value) { #ifdef RPI #ifdef USE_BCM2835_LIB bcm2835_gpio_write(Pin, Value); #elif USE_WIRINGPI_LIB digitalWrite(Pin, Value); #elif USE_LGPIO_LIB lgGpioWrite(GPIO_Handle, Pin, Value); #elif USE_DEV_LIB GPIOD_Write(Pin, Value); #endif #endif #ifdef JETSON #ifdef USE_DEV_LIB SYSFS_GPIO_Write(Pin, Value); #elif USE_HARDWARE_LIB Debug("not support"); #endif #endif } UBYTE DEV_Digital_Read(UWORD Pin) { UBYTE Read_value = 0; #ifdef RPI #ifdef USE_BCM2835_LIB Read_value = bcm2835_gpio_lev(Pin); #elif USE_WIRINGPI_LIB Read_value = digitalRead(Pin); #elif USE_LGPIO_LIB Read_value = lgGpioRead(GPIO_Handle,Pin); #elif USE_DEV_LIB Read_value = GPIOD_Read(Pin); #endif #endif #ifdef JETSON #ifdef USE_DEV_LIB Read_value = SYSFS_GPIO_Read(Pin); #elif USE_HARDWARE_LIB Debug("not support"); #endif #endif return Read_value; } /** * SPI **/ void DEV_SPI_WriteByte(uint8_t Value) { #ifdef RPI #ifdef USE_BCM2835_LIB bcm2835_spi_transfer(Value); #elif USE_WIRINGPI_LIB wiringPiSPIDataRW(0,&Value,1); #elif USE_LGPIO_LIB lgSpiWrite(SPI_Handle,(char*)&Value, 1); #elif USE_DEV_LIB DEV_HARDWARE_SPI_TransferByte(Value); #endif #endif #ifdef JETSON #ifdef USE_DEV_LIB SYSFS_software_spi_transfer(Value); #elif USE_HARDWARE_LIB Debug("not support"); #endif #endif } void DEV_SPI_Write_nByte(uint8_t *pData, uint32_t Len) { #ifdef RPI #ifdef USE_BCM2835_LIB char rData[Len]; bcm2835_spi_transfernb((char *)pData,rData,Len); #elif USE_WIRINGPI_LIB wiringPiSPIDataRW(0, pData, Len); #elif USE_LGPIO_LIB lgSpiWrite(SPI_Handle,(char*)pData, Len); #elif USE_DEV_LIB DEV_HARDWARE_SPI_Transfer(pData, Len); #endif #endif #ifdef JETSON #ifdef USE_DEV_LIB //JETSON nano waits for hardware SPI // Debug("not support"); uint32_t i; for(i = 0; i