ESP8266 ILI9341 display support code with printf sources, wire-frame viewer and custom fonts  1.0
ESP8266ILI9341DisplayProject
Macros | Functions | Variables
hspi.c File Reference

HSPI driver for ESP8255 Based on initial work from Sem 2015 - rewrittem Added code to handle proper aligned reads and writes and buffering. More...

#include "user_config.h"
#include <stdint.h>
#include <stdarg.h>
#include <string.h>
#include <math.h>
#include "hspi.h"
#include "gpio.h"

Go to the source code of this file.

Macros

#define HSPI_PRESCALER   16
 

Functions

void hspi_init (uint32_t prescale, int hwcs)
 HSPI Initiaization - with automatic chip select Pins: MISO GPIO12 MOSI GPIO13 CLK GPIO14 CS GPIO15 - optional DC GPIO2. More...
 
static void hspi_config (int configState)
 HSPI Configuration for tranasmit and receive. More...
 
static void hspi_setBits (uint16_t bytes)
 HSPI FIFO send or receive byte count. More...
 
static void hspi_startSend (void)
 HSPI Start Send. More...
 
void hspi_waitReady (void)
 HSPI Ready wait. More...
 
static void hspi_writeFIFO (uint8_t *write_data, int bytes)
 HSPI FIFO write in units of 32 bits (4 byte words) More...
 
static void hspi_readFIFO (uint8_t *read_data, int bytes)
 HSPI FIFO Read in units of 32 bits (4 byte words) More...
 
void hspi_TX (uint8_t *data, int count)
 SPI buffered write functions. More...
 
void hspi_TXRX (uint8_t *data, int count)
 HSPI write and read using FIFO. More...
 
void hspi_RX (uint8_t *data, int count)
 HSPI read using FIFO. More...
 

Variables

static _hspi_init_done = 0
 
uint32_t hspi_clock = -1
 hspi clock cached value More...
 

Detailed Description

HSPI driver for ESP8255 Based on initial work from Sem 2015 - rewrittem Added code to handle proper aligned reads and writes and buffering.

Copyright © 2015 Sem
Copyright © 2015 Mike Gore, GPL License
You are free to use this code under the terms of GPL
Please retain a copy of this notice in any code you use it in.

This is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.

This software is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.

You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/.

Definition in file hspi.c.

Macro Definition Documentation

#define HSPI_PRESCALER   16

Definition at line 37 of file hspi.c.

Function Documentation

static void hspi_config ( int  configState)
static

HSPI Configuration for tranasmit and receive.

Parameters
[in]configStateCONFIG_FOR_RX_TX or CONFIG_FOR_RX
Returns
void

Definition at line 104 of file hspi.c.

Referenced by hspi_RX(), hspi_TX(), and hspi_TXRX().

void hspi_init ( uint32_t  prescale,
int  hwcs 
)

HSPI Initiaization - with automatic chip select Pins: MISO GPIO12 MOSI GPIO13 CLK GPIO14 CS GPIO15 - optional DC GPIO2.

Parameters
[in]prescaleprescale from CPU clock 0 .. 0x1fff
[in]hwcsenable GPIO15 hardware chip select
Returns
void

Definition at line 55 of file hspi.c.

Referenced by setup(), and spi_init().

static void hspi_readFIFO ( uint8_t read_data,
int  bytes 
)
static

HSPI FIFO Read in units of 32 bits (4 byte words)

Parameters
[in]read_dataread buffer
[in]bytesbytes to write
Returns
void

Definition at line 215 of file hspi.c.

Referenced by hspi_RX(), and hspi_TXRX().

void hspi_RX ( uint8_t data,
int  count 
)

HSPI read using FIFO.

Parameters
[in]*datareceive buffer
[in]countnumber of bytes to read
Returns
void

Definition at line 318 of file hspi.c.

Referenced by spi_RX(), and spi_RX_buffer().

static void hspi_setBits ( uint16_t  bytes)
static

HSPI FIFO send or receive byte count.

Parameters
[in]bytesbytes to send or receive
Returns
void

Definition at line 140 of file hspi.c.

Referenced by hspi_readFIFO(), and hspi_writeFIFO().

static void hspi_startSend ( void  )
static

HSPI Start Send.

Returns
void

Definition at line 151 of file hspi.c.

Referenced by hspi_RX(), hspi_TX(), and hspi_TXRX().

void hspi_TX ( uint8_t data,
int  count 
)

SPI buffered write functions.

=================================================================HSPI write using FIFO

Parameters
[in]*datatransmit buffer
[in]countnumber of bytes to write
Returns
void

Definition at line 265 of file hspi.c.

Referenced by spi_TX(), and spi_TX_buffer().

void hspi_TXRX ( uint8_t data,
int  count 
)

HSPI write and read using FIFO.

Parameters
[in]*datatransmit / receive buffer
[in]countnumber of bytes to write / read
Returns
void

Definition at line 292 of file hspi.c.

Referenced by spi_TXRX(), and spi_TXRX_buffer().

void hspi_waitReady ( void  )

HSPI Ready wait.

Returns
void

Definition at line 159 of file hspi.c.

Referenced by esp_yield(), hspi_config(), hspi_init(), hspi_RX(), hspi_TX(), hspi_TXRX(), loop_wrapper(), and spi_waitReady().

static void hspi_writeFIFO ( uint8_t write_data,
int  bytes 
)
static

HSPI FIFO write in units of 32 bits (4 byte words)

Parameters
[in]write_datawrite buffer
[in]bytesbytes to write
Returns
void

Definition at line 169 of file hspi.c.

Referenced by hspi_RX(), hspi_TX(), and hspi_TXRX().

Variable Documentation

_hspi_init_done = 0
static

Definition at line 41 of file hspi.c.

Referenced by hspi_init().

uint32_t hspi_clock = -1

hspi clock cached value

Definition at line 44 of file hspi.c.

Referenced by hspi_init().