Skip to content

Commit

Permalink
Initial commit
Browse files Browse the repository at this point in the history
  • Loading branch information
tsl0922 committed Nov 11, 2024
0 parents commit f353d23
Show file tree
Hide file tree
Showing 1,503 changed files with 324,924 additions and 0 deletions.
91 changes: 91 additions & 0 deletions EPD/DEV_Config.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,91 @@
/*****************************************************************************
* | File : DEV_Config.cpp
* | Author : Waveshare team
* | Function :
* | Info :
* Image scanning
* Please use progressive scanning to generate images or fonts
*----------------
* | This version: V1.0
* | Date : 2018-01-11
* | Info : Basic version
*
******************************************************************************/
#include "nrf_drv_spi.h"
#include "DEV_Config.h"

#include <errno.h>
#include <stdio.h>
#include <string.h>

uint32_t EPD_MOSI_PIN = 5;
uint32_t EPD_SCLK_PIN = 8;
uint32_t EPD_CS_PIN = 9;
uint32_t EPD_DC_PIN = 10;
uint32_t EPD_RST_PIN = 11;
uint32_t EPD_BUSY_PIN = 12;
uint32_t EPD_BS_PIN = 13;

static const nrf_drv_spi_t spi = NRF_DRV_SPI_INSTANCE(0);

/******************************************************************************
function: Initialize Arduino, Initialize Pins, and SPI
parameter:
Info:
******************************************************************************/
UBYTE DEV_Module_Init(void)
{
nrf_gpio_cfg_output(EPD_CS_PIN);
nrf_gpio_cfg_output(EPD_DC_PIN);
nrf_gpio_cfg_output(EPD_RST_PIN);
nrf_gpio_cfg_input(EPD_BUSY_PIN, NRF_GPIO_PIN_NOPULL);

nrf_gpio_cfg_output(EPD_BS_PIN);
DEV_Digital_Write(EPD_BS_PIN, 0);

nrf_drv_spi_config_t spi_config =
{
.sck_pin = EPD_SCLK_PIN,
.mosi_pin = EPD_MOSI_PIN,
.miso_pin = NRF_DRV_SPI_PIN_NOT_USED,
.ss_pin = NRF_DRV_SPI_PIN_NOT_USED,
.frequency = NRF_DRV_SPI_FREQ_4M,
.mode = NRF_DRV_SPI_MODE_0,
};
nrf_drv_spi_init(&spi, &spi_config, NULL);

DEV_Digital_Write(EPD_DC_PIN, 0);
DEV_Digital_Write(EPD_CS_PIN, 0);
DEV_Digital_Write(EPD_RST_PIN, 1);

return 0;
}

/*********************************************
function: Hardware interface
note:
SPI4W_Write_Byte(value) :
Register hardware SPI
*********************************************/
void DEV_SPI_WriteByte(UBYTE value)
{
nrf_drv_spi_transfer(&spi, &value, 1, NULL, 0);
}

UBYTE DEV_SPI_ReadByte(void)
{
UBYTE value;
nrf_drv_spi_transfer(&spi, NULL, 0, &value, 1);
return value;
}

void DEV_Module_Exit(void)
{
DEV_Digital_Write(EPD_DC_PIN, 0);
DEV_Digital_Write(EPD_CS_PIN, 0);

//close 5V
DEV_Digital_Write(EPD_RST_PIN, 0);

nrf_drv_spi_uninit(&spi);
}
56 changes: 56 additions & 0 deletions EPD/DEV_Config.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
/*****************************************************************************
* | File : DEV_Config.h
* | Author : Waveshare team
* | Function : debug with prntf
* | Info :
* Image scanning
* Please use progressive scanning to generate images or fonts
*----------------
* | This version: V1.0
* | Date : 2018-01-11
* | Info : Basic version
*
******************************************************************************/
#ifndef _DEV_CONFIG_H_
#define _DEV_CONFIG_H_

#include "nrf_delay.h"
#include "nrf_gpio.h"
#include <stdint.h>
#include <stdlib.h>

/**
* data
**/
#define UBYTE uint8_t
#define UWORD uint16_t
#define UDOUBLE uint32_t

extern uint32_t EPD_MOSI_PIN;
extern uint32_t EPD_SCLK_PIN;
extern uint32_t EPD_CS_PIN;
extern uint32_t EPD_DC_PIN;
extern uint32_t EPD_RST_PIN;
extern uint32_t EPD_BUSY_PIN;
extern uint32_t EPD_BS_PIN;

/**
* GPIO read and write
**/
#define DEV_Digital_Write(_pin, _value) nrf_gpio_pin_write(_pin, _value)
#define DEV_Digital_Read(_pin) nrf_gpio_pin_read(_pin)


/**
* delay x ms
**/
#define DEV_Delay_ms(__xms) nrf_delay_ms(__xms);
#define DEV_Delay_us(__xus) nrf_delay_us(__xus);

UBYTE DEV_Module_Init(void);
void DEV_Module_Exit(void);

void DEV_SPI_WriteByte(UBYTE value);
UBYTE DEV_SPI_ReadByte(void);

#endif
Loading

0 comments on commit f353d23

Please sign in to comment.