use It8951 files
This commit is contained in:
176
inkycal/display/drivers/parallel_drivers/lib/Config/DEV_Config.c
Normal file
176
inkycal/display/drivers/parallel_drivers/lib/Config/DEV_Config.c
Normal file
@@ -0,0 +1,176 @@
|
||||
/*****************************************************************************
|
||||
* | File : DEV_Config.c
|
||||
* | Author : Waveshare team
|
||||
* | Function : Hardware underlying interface
|
||||
* | Info :
|
||||
*----------------
|
||||
* | This version: V3.0
|
||||
* | Date : 2019-09-17
|
||||
* | 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"
|
||||
#include <fcntl.h>
|
||||
|
||||
|
||||
/******************************************************************************
|
||||
function: GPIO Write
|
||||
parameter:
|
||||
Info:
|
||||
******************************************************************************/
|
||||
void DEV_Digital_Write(UWORD Pin, UBYTE Value)
|
||||
{
|
||||
bcm2835_gpio_write(Pin, Value);
|
||||
}
|
||||
|
||||
/******************************************************************************
|
||||
function: GPIO Read
|
||||
parameter:
|
||||
Info:
|
||||
******************************************************************************/
|
||||
UBYTE DEV_Digital_Read(UWORD Pin)
|
||||
{
|
||||
UBYTE Read_Value = 0;
|
||||
Read_Value = bcm2835_gpio_lev(Pin);
|
||||
return Read_Value;
|
||||
}
|
||||
|
||||
/******************************************************************************
|
||||
function: SPI Write
|
||||
parameter:
|
||||
Info:
|
||||
******************************************************************************/
|
||||
void DEV_SPI_WriteByte(UBYTE Value)
|
||||
{
|
||||
bcm2835_spi_transfer(Value);
|
||||
}
|
||||
|
||||
/******************************************************************************
|
||||
function: SPI Read
|
||||
parameter:
|
||||
Info:
|
||||
******************************************************************************/
|
||||
UBYTE DEV_SPI_ReadByte()
|
||||
{
|
||||
UBYTE Read_Value = 0x00;
|
||||
Read_Value = bcm2835_spi_transfer(0x00);
|
||||
return Read_Value;
|
||||
}
|
||||
|
||||
/******************************************************************************
|
||||
function: Time delay for ms
|
||||
parameter:
|
||||
Info:
|
||||
******************************************************************************/
|
||||
void DEV_Delay_ms(UDOUBLE xms)
|
||||
{
|
||||
bcm2835_delay(xms);
|
||||
}
|
||||
|
||||
|
||||
/******************************************************************************
|
||||
function: Time delay for us
|
||||
parameter:
|
||||
Info:
|
||||
******************************************************************************/
|
||||
void DEV_Delay_us(UDOUBLE xus)
|
||||
{
|
||||
bcm2835_delayMicroseconds(xus);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* GPIO Mode
|
||||
**/
|
||||
static void DEV_GPIO_Mode(UWORD Pin, UWORD Mode)
|
||||
{
|
||||
if(Mode == 0 || Mode == BCM2835_GPIO_FSEL_INPT) {
|
||||
bcm2835_gpio_fsel(Pin, BCM2835_GPIO_FSEL_INPT);
|
||||
} else {
|
||||
bcm2835_gpio_fsel(Pin, BCM2835_GPIO_FSEL_OUTP);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* GPIO Init
|
||||
**/
|
||||
static void DEV_GPIO_Init(void)
|
||||
{
|
||||
DEV_GPIO_Mode(EPD_RST_PIN, BCM2835_GPIO_FSEL_OUTP);
|
||||
DEV_GPIO_Mode(EPD_CS_PIN, BCM2835_GPIO_FSEL_OUTP);
|
||||
DEV_GPIO_Mode(EPD_BUSY_PIN, BCM2835_GPIO_FSEL_INPT);
|
||||
|
||||
DEV_Digital_Write(EPD_CS_PIN, HIGH);
|
||||
}
|
||||
|
||||
|
||||
|
||||
/******************************************************************************
|
||||
function: Module Initialize, the library and initialize the pins, SPI protocol
|
||||
parameter:
|
||||
Info:
|
||||
******************************************************************************/
|
||||
UBYTE DEV_Module_Init(void)
|
||||
{
|
||||
Debug("/***********************************/ \r\n");
|
||||
|
||||
if(!bcm2835_init()) {
|
||||
Debug("bcm2835 init failed !!! \r\n");
|
||||
return 1;
|
||||
} else {
|
||||
Debug("bcm2835 init success !!! \r\n");
|
||||
}
|
||||
|
||||
bcm2835_spi_begin(); //Start spi interface, set spi pin for the reuse function
|
||||
bcm2835_spi_setBitOrder(BCM2835_SPI_BIT_ORDER_MSBFIRST); //High first transmission
|
||||
bcm2835_spi_setDataMode(BCM2835_SPI_MODE0); //spi mode 0
|
||||
//bcm2835_spi_setClockDivider(BCM2835_SPI_CLOCK_DIVIDER_16); //For RPi3/3B/3B+
|
||||
bcm2835_spi_setClockDivider(BCM2835_SPI_CLOCK_DIVIDER_32); //For RPi 4
|
||||
/* SPI clock reference link:*/
|
||||
/*http://www.airspayce.com/mikem/bcm2835/group__constants.html#gaf2e0ca069b8caef24602a02e8a00884e*/
|
||||
|
||||
//GPIO Config
|
||||
DEV_GPIO_Init();
|
||||
|
||||
Debug("/***********************************/ \r\n");
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
|
||||
/******************************************************************************
|
||||
function: Module exits, closes SPI and BCM2835 library
|
||||
parameter:
|
||||
Info:
|
||||
******************************************************************************/
|
||||
void DEV_Module_Exit(void)
|
||||
{
|
||||
DEV_Digital_Write(EPD_CS_PIN, LOW);
|
||||
DEV_Digital_Write(EPD_RST_PIN, LOW);
|
||||
|
||||
bcm2835_spi_end();
|
||||
bcm2835_close();
|
||||
}
|
@@ -0,0 +1,96 @@
|
||||
/*****************************************************************************
|
||||
* | File : DEV_Config.h
|
||||
* | Author : Waveshare team
|
||||
* | Function : Hardware underlying interface
|
||||
* | Info :
|
||||
* Used to shield the underlying layers of each master
|
||||
* and enhance portability
|
||||
*----------------
|
||||
* | This version: V2.0
|
||||
* | Date : 2018-10-30
|
||||
* | Info :
|
||||
* 1.add:
|
||||
* UBYTE\UWORD\UDOUBLE
|
||||
* 2.Change:
|
||||
* EPD_RST -> EPD_RST_PIN
|
||||
* EPD_DC -> EPD_DC_PIN
|
||||
* EPD_CS -> EPD_CS_PIN
|
||||
* EPD_BUSY -> EPD_BUSY_PIN
|
||||
* 3.Remote:
|
||||
* EPD_RST_1\EPD_RST_0
|
||||
* EPD_DC_1\EPD_DC_0
|
||||
* EPD_CS_1\EPD_CS_0
|
||||
* EPD_BUSY_1\EPD_BUSY_0
|
||||
* 3.add:
|
||||
* #define DEV_Digital_Write(_pin, _value) bcm2835_GPIOI_write(_pin, _value)
|
||||
* #define DEV_Digital_Read(_pin) bcm2835_GPIOI_lev(_pin)
|
||||
* #define DEV_SPI_WriteByte(__value) bcm2835_spi_transfer(__value)
|
||||
#
|
||||
# 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 the 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.
|
||||
#
|
||||
******************************************************************************/
|
||||
#ifndef _DEV_CONFIG_H_
|
||||
#define _DEV_CONFIG_H_
|
||||
|
||||
#include <stdint.h>
|
||||
#include <stdlib.h>
|
||||
#include <stdio.h>
|
||||
#include <unistd.h>
|
||||
#include <errno.h>
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#include "Debug.h"
|
||||
|
||||
#include <bcm2835.h>
|
||||
|
||||
|
||||
/**
|
||||
* GPIO
|
||||
**/
|
||||
|
||||
#define EPD_RST_PIN 17
|
||||
#define EPD_CS_PIN 8
|
||||
#define EPD_BUSY_PIN 24
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* data
|
||||
**/
|
||||
#define UBYTE uint8_t
|
||||
#define UWORD uint16_t
|
||||
#define UDOUBLE uint32_t
|
||||
|
||||
|
||||
|
||||
/*------------------------------------------------------------------------------------------------------*/
|
||||
void DEV_Digital_Write(UWORD Pin, UBYTE Value);
|
||||
UBYTE DEV_Digital_Read(UWORD Pin);
|
||||
|
||||
void DEV_SPI_WriteByte(UBYTE Value);
|
||||
UBYTE DEV_SPI_ReadByte();
|
||||
|
||||
void DEV_Delay_ms(UDOUBLE xms);
|
||||
void DEV_Delay_us(UDOUBLE xus);
|
||||
|
||||
UBYTE DEV_Module_Init(void);
|
||||
void DEV_Module_Exit(void);
|
||||
|
||||
|
||||
#endif
|
47
inkycal/display/drivers/parallel_drivers/lib/Config/Debug.h
Normal file
47
inkycal/display/drivers/parallel_drivers/lib/Config/Debug.h
Normal file
@@ -0,0 +1,47 @@
|
||||
/*****************************************************************************
|
||||
* | File : Debug.h
|
||||
* | Author : Waveshare team
|
||||
* | Function : debug with printf
|
||||
* | Info :
|
||||
* Image scanning
|
||||
* Please use progressive scanning to generate images or fonts
|
||||
*----------------
|
||||
* | This version: V2.0
|
||||
* | Date : 2018-10-30
|
||||
* | Info :
|
||||
* 1.USE_DEBUG -> DEBUG, If you need to see the debug information,
|
||||
* clear the execution: make DEBUG=-DDEBUG
|
||||
#
|
||||
# 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 the 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.
|
||||
#
|
||||
|
||||
******************************************************************************/
|
||||
#ifndef __DEBUG_H
|
||||
#define __DEBUG_H
|
||||
|
||||
#include <stdio.h>
|
||||
|
||||
#if DEBUG
|
||||
#define Debug(fmt,...) printf("%s[%d]:"fmt,__FILE__,__LINE__,##__VA_ARGS__)
|
||||
#else
|
||||
#define Debug(fmt,...) printf(fmt,##__VA_ARGS__)
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
Reference in New Issue
Block a user