summaryrefslogtreecommitdiff
path: root/src/stmf0/ao_arch_funcs.h
diff options
context:
space:
mode:
authorBdale Garbee <bdale@gag.com>2016-09-05 20:59:11 -0600
committerBdale Garbee <bdale@gag.com>2016-09-05 20:59:11 -0600
commitc0ad087008856cfc2233b977abfc3f1dcbaccdcc (patch)
treeadc46abc430793112858ce5d1822d3fe0a395e71 /src/stmf0/ao_arch_funcs.h
parent148b013dd29c26920ddfb53449ed4d8cc5a4b5ee (diff)
parent4fdf8ca9ca1cd5a84b03bd7a03c5806af64b413d (diff)
Merge branch 'master' into branch-1.6
Diffstat (limited to 'src/stmf0/ao_arch_funcs.h')
-rw-r--r--src/stmf0/ao_arch_funcs.h55
1 files changed, 53 insertions, 2 deletions
diff --git a/src/stmf0/ao_arch_funcs.h b/src/stmf0/ao_arch_funcs.h
index 64311b23..8b6234c4 100644
--- a/src/stmf0/ao_arch_funcs.h
+++ b/src/stmf0/ao_arch_funcs.h
@@ -3,7 +3,8 @@
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; version 2 of the License.
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
*
* This program is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of
@@ -82,7 +83,57 @@ void
ao_spi_send_fixed(uint8_t value, uint16_t len, uint8_t spi_index);
void
-ao_spi_send_sync(void *block, uint16_t len, uint8_t spi_index);
+ao_spi_send_sync(const void *block, uint16_t len, uint8_t spi_index);
+
+void
+ao_spi_start_bytes(uint8_t spi_index);
+
+void
+ao_spi_stop_bytes(uint8_t spi_index);
+
+static inline void
+ao_spi_send_byte(uint8_t byte, uint8_t spi_index)
+{
+ struct stm_spi *stm_spi;
+
+ switch (AO_SPI_INDEX(spi_index)) {
+ case 0:
+ stm_spi = &stm_spi1;
+ break;
+ case 1:
+ stm_spi = &stm_spi2;
+ break;
+ }
+
+ while (!(stm_spi->sr & (1 << STM_SPI_SR_TXE)))
+ ;
+ stm_spi->dr = byte;
+ while (!(stm_spi->sr & (1 << STM_SPI_SR_RXNE)))
+ ;
+ (void) stm_spi->dr;
+}
+
+static inline uint8_t
+ao_spi_recv_byte(uint8_t spi_index)
+{
+ struct stm_spi *stm_spi;
+
+ switch (AO_SPI_INDEX(spi_index)) {
+ case 0:
+ stm_spi = &stm_spi1;
+ break;
+ case 1:
+ stm_spi = &stm_spi2;
+ break;
+ }
+
+ while (!(stm_spi->sr & (1 << STM_SPI_SR_TXE)))
+ ;
+ stm_spi->dr = 0xff;
+ while (!(stm_spi->sr & (1 << STM_SPI_SR_RXNE)))
+ ;
+ return stm_spi->dr;
+}
void
ao_spi_recv(void *block, uint16_t len, uint8_t spi_index);