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.
BExprSPIArduino.hpp@1:1a1cf1ae06f3, 2020-04-11 (annotated)
- Committer:
- kabukistarship
- Date:
- Sat Apr 11 08:47:51 2020 +0000
- Revision:
- 1:1a1cf1ae06f3
Change.Port to Arduino using SickBay programming model. #13 #A.
Who changed what in which revision?
| User | Revision | Line number | New contents of line |
|---|---|---|---|
| kabukistarship | 1:1a1cf1ae06f3 | 1 | /* Kabuki Tek @version 0.x |
| kabukistarship | 1:1a1cf1ae06f3 | 2 | @link https://github.com/KabukiStarship/KabukiTek.git |
| kabukistarship | 1:1a1cf1ae06f3 | 3 | @file /ExprI2CMbed.hpp |
| kabukistarship | 1:1a1cf1ae06f3 | 4 | @author Cale McCollough <https://cale-mccollough.github.io> |
| kabukistarship | 1:1a1cf1ae06f3 | 5 | @license Copyright 2020 (C) Kabuki Starship <kabukistarship.com>. |
| kabukistarship | 1:1a1cf1ae06f3 | 6 | This Source Code Form is subject to the terms of the Mozilla Public License, |
| kabukistarship | 1:1a1cf1ae06f3 | 7 | v. 2.0. If a copy of the MPL was not distributed with this file, you can obtain |
| kabukistarship | 1:1a1cf1ae06f3 | 8 | one at <https://mozilla.org/MPL/2.0/>. */ |
| kabukistarship | 1:1a1cf1ae06f3 | 9 | #pragma once |
| kabukistarship | 1:1a1cf1ae06f3 | 10 | #ifndef KabukiTekExprI2CMbedDecl |
| kabukistarship | 1:1a1cf1ae06f3 | 11 | #define KabukiTekExprI2CMbedDecl |
| kabukistarship | 1:1a1cf1ae06f3 | 12 | #include "BExpr.h" |
| kabukistarship | 1:1a1cf1ae06f3 | 13 | #include <Arduino.h> |
| kabukistarship | 1:1a1cf1ae06f3 | 14 | |
| kabukistarship | 1:1a1cf1ae06f3 | 15 | Expr* EvaluateSPI (Expr* Expr) { |
| kabukistarship | 1:1a1cf1ae06f3 | 16 | int BytesInLength = Expr->BytesInLength, |
| kabukistarship | 1:1a1cf1ae06f3 | 17 | BytesOutLength = Expr->BytesOutLength; |
| kabukistarship | 1:1a1cf1ae06f3 | 18 | char* BytesIn = Expr->BytesIn, |
| kabukistarship | 1:1a1cf1ae06f3 | 19 | * BytesInEnd = BytesIn + Expr->BytesInLength; |
| kabukistarship | 1:1a1cf1ae06f3 | 20 | char* BytesOut = Expr->BytesOut, |
| kabukistarship | 1:1a1cf1ae06f3 | 21 | * BytesOutEnd = BytesOut + Expr->BytesOutLength; |
| kabukistarship | 1:1a1cf1ae06f3 | 22 | while (BytesIn < BytesInEnd && BytesOut < BytesOutEnd) { |
| kabukistarship | 1:1a1cf1ae06f3 | 23 | char BytesInByte; |
| kabukistarship | 1:1a1cf1ae06f3 | 24 | if (BytesIn < BytesInEnd) BytesInByte = *BytesIn++; |
| kabukistarship | 1:1a1cf1ae06f3 | 25 | else BytesInByte = 0; |
| kabukistarship | 1:1a1cf1ae06f3 | 26 | char BytesOutByte = SPI.transfer (BytesInByte); |
| kabukistarship | 1:1a1cf1ae06f3 | 27 | if (BytesOut < BytesOutLength) *BytesOut++ = BytesOutByte; |
| kabukistarship | 1:1a1cf1ae06f3 | 28 | } |
| kabukistarship | 1:1a1cf1ae06f3 | 29 | Expr->BytesOutLength = BytesOutEnd - BytesOut; |
| kabukistarship | 1:1a1cf1ae06f3 | 30 | return Expr; |
| kabukistarship | 1:1a1cf1ae06f3 | 31 | } |
| kabukistarship | 1:1a1cf1ae06f3 | 32 | |
| kabukistarship | 1:1a1cf1ae06f3 | 33 | #undef ExprBytesInLengthMax |
| kabukistarship | 1:1a1cf1ae06f3 | 34 | #undef ExprBytesOutLengthMax |
| kabukistarship | 1:1a1cf1ae06f3 | 35 | #endif |