(self, token, buf)
| 210 | self.spi.write(b"\xff") |
| 211 | |
| 212 | def write(self, token, buf): |
| 213 | self.cs(0) |
| 214 | |
| 215 | # send: start of block, data, checksum |
| 216 | self.spi.read(1, token) |
| 217 | self.spi.write(buf) |
| 218 | self.spi.write(b"\xff") |
| 219 | self.spi.write(b"\xff") |
| 220 | |
| 221 | # check the response |
| 222 | if (self.spi.read(1, 0xFF)[0] & 0x1F) != 0x05: |
| 223 | self.cs(1) |
| 224 | self.spi.write(b"\xff") |
| 225 | return |
| 226 | |
| 227 | # wait for write to finish |
| 228 | while self.spi.read(1, 0xFF)[0] == 0: |
| 229 | pass |
| 230 | |
| 231 | self.cs(1) |
| 232 | self.spi.write(b"\xff") |
| 233 | |
| 234 | def write_token(self, token): |
| 235 | self.cs(0) |
no outgoing calls
no test coverage detected