1
0
mirror of https://github.com/esp8266/Arduino.git synced 2025-04-19 23:22:16 +03:00

27 Commits

Author SHA1 Message Date
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
Richard Allen
40c159fcf5 Remove a number of extui instructions
Using a uint8_t for the loop counter resulted
in a number of 8-bit extract (extui) instructions.
Using a uint32_t prevents this.
2017-06-06 23:23:09 -05:00
Richard Allen
00815f2db4 Manually manage FIFO volatility
Replace volatile with properly placed __sync_synchronize

SPI1W0 is volatile, but when writing multiple words
to the FIFO (which is really just a piece of SRAM),
we don't need to worry about write ordering. We only
need worry about write ordering such that all FIFO
words are written completely before HSPI is told to
use FIFO by setting SPI1CMD |= SPIBUSY;
2017-06-06 23:23:09 -05:00
Richard Allen
c07c8dc88e Small cleanup to SPI write16 and write32 for big-endian
Merge a common line.
2017-06-06 23:23:09 -05: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
8ffe1aa2e2 Speed up writePattern() a bit more 2016-04-18 01:26:03 +03:00
WereCatf
a64a694f6d Speed up SPI.writePattern() 2016-04-16 20:02:06 +03:00
Marco
bda212552c Fix SPI.transfer16() using wrong endianness 2016-04-04 22:10:36 -07:00
reiyawea
66b68d4ada add CPOL setting 2016-03-16 17:28:24 +08: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
e0c1b47937 add some notes to the SPI functions (aligned to 32Bit)
- Fatal exception (9)
2015-05-13 19:03:21 +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
dcc899a1b5 some speed optimizations 2015-05-08 15:33:48 +02:00
Markus Sattler
7c33efc3d8 fix SPI run on system clock 2015-05-08 15:30:27 +02:00
Markus Sattler
d7a88c3ea3 use a function to calculate best match clock register for SPI
TEST:

Frequency: 1000000  -> [0x009C1001] EQU: 0	 Pre: 39     N: 1	 H: 0	 L: 1	 - Back Calculated Frequency: 1000000
Frequency: 4000000  -> [0x00001001] EQU: 0	 Pre: 0	     N: 1	 H: 0	 L: 1	 - Back Calculated Frequency: 40000000
Frequency: 2000000  -> [0x00041001] EQU: 0	 Pre: 1	     N: 1	 H: 0	 L: 1	 - Back Calculated Frequency: 20000000
Frequency: 1600000  -> [0x00004002] EQU: 0	 Pre: 0	     N: 4	 H: 0	 L: 2	 - Back Calculated Frequency: 16000000
Frequency: 1610000  -> [0x00004002] EQU: 0	 Pre: 0	     N: 4	 H: 0	 L: 2	 - Back Calculated Frequency: 16000000
Frequency: 1000000  -> [0x000C1001] EQU: 0	 Pre: 3	     N: 1	 H: 0	 L: 1	 - Back Calculated Frequency: 10000000
Frequency: 8000000  -> [0x00101001] EQU: 0	 Pre: 4	     N: 1	 H: 0	 L: 1	 - Back Calculated Frequency: 8000000
Frequency: 5000000  -> [0x001C1001] EQU: 0	 Pre: 7	     N: 1	 H: 0	 L: 1	 - Back Calculated Frequency: 5000000
Frequency: 4000000  -> [0x00241001] EQU: 0	 Pre: 9	     N: 1	 H: 0	 L: 1	 - Back Calculated Frequency: 4000000
Frequency: 2000000  -> [0x004C1001] EQU: 0	 Pre: 19	 N: 1	 H: 0	 L: 1	 - Back Calculated Frequency: 2000000
Frequency: 1000000  -> [0x009C1001] EQU: 0	 Pre: 39	 N: 1	 H: 0	 L: 1	 - Back Calculated Frequency: 1000000
Frequency: 500000   -> [0x013C1001] EQU: 0	 Pre: 79	 N: 1	 H: 0	 L: 1	 - Back Calculated Frequency: 500000
Frequency: 250000   -> [0x027C1001] EQU: 0	 Pre: 159	 N: 1	 H: 0	 L: 1	 - Back Calculated Frequency: 250000
Frequency: 125000   -> [0x04FC1001] EQU: 0	 Pre: 319	 N: 1	 H: 0	 L: 1	 - Back Calculated Frequency: 125000
Frequency: 6666666  -> [0x00141001] EQU: 0	 Pre: 5	 	 N: 1	 H: 0	 L: 1	 - Back Calculated Frequency: 6666666
Frequency: 6000000  -> [0x00181001] EQU: 0	 Pre: 6	 	 N: 1	 H: 0	 L: 1	 - Back Calculated Frequency: 5714285
Frequency: 3000000  -> [0x00202001] EQU: 0	 Pre: 8	 	 N: 2	 H: 0	 L: 1	 - Back Calculated Frequency: 2962962
Frequency: 100	    -> [0x7FFFF020] EQU: 0	 Pre: 8191	 N: 63	 H: 0	 L: 32	 - Back Calculated Frequency: 152
Frequency: 125000   -> [0x04FC1001] EQU: 0	 Pre: 319	 N: 1	 H: 0	 L: 1	 - Back Calculated Frequency: 125000
Frequency: 16457    -> [0x25F81001] EQU: 0	 Pre: 2430	 N: 1	 H: 0	 L: 1	 - Back Calculated Frequency: 16454
2015-05-08 00:48:08 +02:00
Markus Sattler
7f4a10062b update README
add some docu and todo
2015-05-07 20:48:59 +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
Ivan Grokhotkov
dfbc499627 Fix slashes in SPI library 2015-04-03 08:18:23 +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