1
0
mirror of https://github.com/esp8266/Arduino.git synced 2025-04-21 10:26:06 +03:00

23 Commits

Author SHA1 Message Date
Max Prokhorov
599492ec43
libraries/SPI: abs -> std::abs and cast fixes (#7362)
* libraries/SPI: remove pointless abs(...) call

SPI library code erroneously assumed that:
- abs() is a C function, so include stdlib.h is required.
  what happens instead is Arduino.h shadows `abs()` with it's own macro
- uint32_t() - int32_t() promotes to int32_t, thus needing abs()

Fix both issues, leaving existing calculations as-is.

* additional changes for freq and constants

- restore abs call, cast freq to correctly display the intent
- update magic numbers comments
- move some spiclk_t magic numbers to func consts
2020-06-13 11:17:06 -07:00
Kristian Sloth Lauszus
5d20137339 Set SPI_HAS_TRANSACTION to 1 (#6591)
See #2639
2019-10-04 17:25:54 -07:00
Allman-astyler
eea9999dc5 Revert "Allman now (#6080)" (#6090)
This reverts commit 98125f88605cd7e46e9be4e1b3ad0600dd5d2b51.
2019-05-14 00:09:54 +02:00
Allman-astyler
98125f8860 Allman now (#6080)
* switch restyle script for CI

* remove confirmation

* restyle with allman
2019-05-13 16:41:34 +02:00
Earle F. Philhower, III
8c01516f8a Allow unaligned input/output to SPI::transferBytes (#5709)
* Allow unaligned input/output to SPI::transferBytes

Fixes #4967

Support any alignment of input and output pointers and transfer lengths
in SPI::transferBytes.  Use 32-bit transfers and FIFO as much as
possible.

* Refactor misaligned transfer, avoid RMW to FIFO

The SPI FIFO can't properly do RMW (i.e. bytewise updates) because when
you read the FIFO you are actually reading the SPI read data, not what
was written into the write FIFO.

Refactor the transferBytes to take account of this.  For aligned input
and outputs, perform as before (but handle non-x4 sizes properly).  For
misaligned inputs, if it's unidirectional then do bytewise until the
direction data pointer is aligned and then do 32b accesses.  Fod
bidirectional and misaligned inputs, copy the output data to an aligned
buffer, do the transfer, then copy the read back data from temp aligned
buffer to the real input buffer.

* Fix comments, clean condition checks, save stack

Add more comments and adjust naming to be more informative in
transferBytes_ and *aligned_.  Save 64bytes of stack in double
misaligned case.

* Optimize misaligned transfers, reduce code size

On any misaligned input or output, always use a temp buffer.  No need
for special casing and bytewise ::transfer().  This should be faster as
bytewise ::transfer involves a significant number of IO register
accesses and setup.  Thanks to @devyte for the suggestion.
2019-02-03 12:17:06 -03:00
david gauchard
3cc12b1e08 arduino API's SPI::transfer(void*, size) (optimized) (#4925)
* SPI::transfer(void*, size) (optimized)

* spi: transfer(): fix checking size

* spi: transferBytes_: 32bits miso transfer

* spi: transferBytes_: fix declaration

* spi: transferBytes: add comments, reduce diff
2018-07-27 10:44:02 -04:00
david gauchard
559cb35025 spi: use const for output buffers (#4552) 2018-03-23 13:39:20 -03:00
jpmendoza
af0f5ed956 Issue #1062: Implement support for HSPI overlap mode. 2017-05-08 03:04:11 -05:00
Clemens Kirchgatterer
18297458be allows global object instances be switch off with defines (#2344) 2016-08-01 11:21:50 +08:00
WereCatf
a64a694f6d Speed up SPI.writePattern() 2016-04-16 20:02:06 +03:00
John Doe
d87bb1e12e spi clock does not depend on cpu clock 2015-06-02 01:13:15 +03:00
John Doe
6ab3c76e03 register and clock changes 2015-06-02 00:11:20 +03:00
Markus Sattler
2eea25873d fix SPI speed calculation @160Mhz Clock 2015-05-15 13:42:30 +02:00
Markus Sattler
27f45a205a SD:
- optimize SPI usage 148% write speed (24kB/s -> 37kB/s) and 127% read speed (121kB/s -> 155kB/s) at 8MHz
 - add clock frequency as parameter for begin(csPin, frequency)
 - SD @80MHz write: 84kB/s read: 231kB/s

SPI add functions:
 - void write32(uint32_t data);
 - void write32(uint32_t data, bool msb);
 - void transferBytes(uint8_t * out, uint8_t * in, uint32_t size);

Adafruit_ILI9341:
 - code clean
2015-05-10 17:34:16 +02:00
Markus Sattler
070f2b3a14 many speed optimizations in Adafruit_ILI9341 lib (3x times faster)
add new SPI function:

  void write(uint8_t data);
  void write16(uint16_t data);
  void write16(uint16_t data, bool msb);
  void writeBytes(uint8_t * data, uint32_t size);
  void writePattern(uint8_t * data, uint8_t size, uint32_t repeat);

Adafruit_ILI9341:
| Benchmark                 | Old (ms) | New (ms) | Speedup     |
| ------------------------- | -------- | -------- | ----------- |
| Screen fill 				| 1248369  | 278707   |  +347,91%   |
| Text 						| 86102    | 53785    |  +60,09%    |
| Lines 					| 825400   | 536374   |  +53,89%    |
| Horiz/Vert Lines 			| 101875   | 24653    |  +313,24%   |
| Rectangles (outline) 		| 65720    | 17295    |  +279,99%   |
| Rectangles (filled) 		| 2592250  | 579157   |  +347,59%   |
| Circles (filled) 			| 411475   | 179454   |  +129,29%   |
| Circles (outline) 		| 360002   | 233584   |  +54,12%    |
| Triangles (outline)		| 261772   | 170118   |  +53,88%    |
| Triangles (filled) 		| 866951   | 246237   |  +252,08%   |
| Rounded rects (outline) 	| 154131   | 81570    |  +88,96%    |
| Rounded rects (filled) 	| 2828112  | 660983   |  +327,86%   |
|                           |          |          |             |
| Total                     | 9802159  | 3061917  |  +220,13%   |
2015-05-09 16:19:32 +02:00
Markus Sattler
5cbcd1da3c rework Adafruit_ILI9341 complete now uses the new SPI implementation
tested with example graphicstest_esp8266

add missing define to SPI.h
2015-05-08 14:45:47 +02:00
Markus Sattler
49fc1980fe add back SPI_CLOCK_DIVx defines may needed by some library
Note:
better use SPI.setFrequency()
2015-05-07 22:16:51 +02:00
Markus Sattler
ee5def9c8c add CPHA support for SPI
- tested with logic analyzer
2015-05-07 19:48:55 +02:00
Markus Sattler
163858dc44 fix use SPI.beginTransaction crash 2015-05-07 19:25:25 +02:00
Markus Sattler
6599a9f52a add SPIClass::transfer16 (needed by some display libs) 2015-05-04 18:11:46 +02:00
ficeto
fbec557ddb Importing my changes 2015-04-30 20:48:50 +03:00
Andrey Filimonov
4626a9df80 Initial ESP8266 HW SPI implementation
ILI9341 lib as a client for SPI lib
2015-04-01 07:10:31 +03:00
Ivan Grokhotkov
ee762f3150 Add WIP SPI library 2015-01-21 04:19:04 +03:00