Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Fork of BurstSPI by
BurstSPI_KL25Z.cpp@3:7d9b64d67b22, 2013-07-04 (annotated)
- Committer:
- Sissors
- Date:
- Thu Jul 04 19:03:58 2013 +0000
- Revision:
- 3:7d9b64d67b22
Refactored code, added version 1 of KL25Z support
Who changed what in which revision?
| User | Revision | Line number | New contents of line |
|---|---|---|---|
| Sissors | 3:7d9b64d67b22 | 1 | #ifdef TARGET_KL25Z |
| Sissors | 3:7d9b64d67b22 | 2 | #include "BurstSPI.h" |
| Sissors | 3:7d9b64d67b22 | 3 | |
| Sissors | 3:7d9b64d67b22 | 4 | void BurstSPI::fastWrite(int data) { |
| Sissors | 3:7d9b64d67b22 | 5 | //Wait until FIFO has space |
| Sissors | 3:7d9b64d67b22 | 6 | while(((_spi.spi->S) & SPI_S_SPTEF_MASK) == 0); |
| Sissors | 3:7d9b64d67b22 | 7 | //transmit data |
| Sissors | 3:7d9b64d67b22 | 8 | _spi.spi->D = data; |
| Sissors | 3:7d9b64d67b22 | 9 | } |
| Sissors | 3:7d9b64d67b22 | 10 | |
| Sissors | 3:7d9b64d67b22 | 11 | void BurstSPI::clearRX( void ) { |
| Sissors | 3:7d9b64d67b22 | 12 | //We put in a delay here, this function shouldn't be called very often, so not a huge problem |
| Sissors | 3:7d9b64d67b22 | 13 | //Without delay you will rise the CS line before it is finished (been there, done that) |
| Sissors | 3:7d9b64d67b22 | 14 | //We use time required to transmit 20 bits (8 bits being transmitted, 8 bits in FIFO, 4 bits safety margin |
| Sissors | 3:7d9b64d67b22 | 15 | |
| Sissors | 3:7d9b64d67b22 | 16 | float bytetime = 20.0/_hz; |
| Sissors | 3:7d9b64d67b22 | 17 | wait(bytetime); |
| Sissors | 3:7d9b64d67b22 | 18 | |
| Sissors | 3:7d9b64d67b22 | 19 | //Wait until status is flagged that we can read, read: |
| Sissors | 3:7d9b64d67b22 | 20 | while (_spi.spi->S & SPI_S_SPRF_MASK == 0); |
| Sissors | 3:7d9b64d67b22 | 21 | int dummy = _spi.spi->D; |
| Sissors | 3:7d9b64d67b22 | 22 | |
| Sissors | 3:7d9b64d67b22 | 23 | } |
| Sissors | 3:7d9b64d67b22 | 24 | #endif |
