projects
/
fw
/
altos
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
altos/arm: Align data so that gcc 5.4 doesn't do byte-accesses. Add -Wcast-align
[fw/altos]
/
src
/
stm
/
ao_arch_funcs.h
diff --git
a/src/stm/ao_arch_funcs.h
b/src/stm/ao_arch_funcs.h
index 5a7782dea8913779c8aa01cb37eb93cdec8387bc..a9d0fa34f02fed0ab58159eb6f7293f059a00a16 100644
(file)
--- a/
src/stm/ao_arch_funcs.h
+++ b/
src/stm/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
*
* 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
*
* This program is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of
@@
-80,7
+81,13
@@
void
ao_spi_send_fixed(uint8_t value, uint16_t len, uint8_t spi_index);
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)
static inline void
ao_spi_send_byte(uint8_t byte, uint8_t spi_index)
@@
-96,25
+103,41
@@
ao_spi_send_byte(uint8_t byte, uint8_t spi_index)
break;
}
break;
}
- stm_spi->cr2 = ((0 << STM_SPI_CR2_TXEIE) |
- (0 << STM_SPI_CR2_RXNEIE) |
- (0 << STM_SPI_CR2_ERRIE) |
- (0 << STM_SPI_CR2_SSOE) |
- (0 << STM_SPI_CR2_TXDMAEN) |
- (0 << STM_SPI_CR2_RXDMAEN));
-
- /* Clear RXNE */
+ 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;
(void) stm_spi->dr;
+}
- while (!(stm_spi->sr & (1 << STM_SPI_SR_TXE)));
- stm_spi->dr = byte;
+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);
void
}
void
ao_spi_recv(void *block, uint16_t len, uint8_t spi_index);
void
-ao_spi_duplex(void *out, void *in, uint16_t len, uint8_t spi_index);
+ao_spi_duplex(
const
void *out, void *in, uint16_t len, uint8_t spi_index);
extern uint16_t ao_spi_speed[STM_NUM_SPI];
extern uint16_t ao_spi_speed[STM_NUM_SPI];
@@
-249,9
+272,6
@@
ao_dma_start(uint8_t index);
void
ao_dma_done_transfer(uint8_t index);
void
ao_dma_done_transfer(uint8_t index);
-void
-ao_dma_abort(uint8_t index);
-
void
ao_dma_alloc(uint8_t index);
void
ao_dma_alloc(uint8_t index);
@@
-343,11
+363,19
@@
ao_arch_memory_barrier() {
asm volatile("" ::: "memory");
}
asm volatile("" ::: "memory");
}
+static inline void
+ao_arch_irq_check(void) {
+ uint32_t primask;
+ asm("mrs %0,primask" : "=&r" (primask));
+ if ((primask & 1) == 0)
+ ao_panic(AO_PANIC_IRQ);
+}
+
#if HAS_TASK
static inline void
ao_arch_init_stack(struct ao_task *task, void *start)
{
#if HAS_TASK
static inline void
ao_arch_init_stack(struct ao_task *task, void *start)
{
- uint32_t *sp = (uint32_t *) (task->stack + AO_STACK_SIZE);
+ uint32_t *sp = (uint32_t *) (
(void*)
task->stack + AO_STACK_SIZE);
uint32_t a = (uint32_t) start;
int i;
uint32_t a = (uint32_t) start;
int i;
@@
-385,23
+413,11
@@
static inline void ao_arch_save_stack(void) {
uint32_t *sp;
asm("mov %0,sp" : "=&r" (sp) );
ao_cur_task->sp = (sp);
uint32_t *sp;
asm("mov %0,sp" : "=&r" (sp) );
ao_cur_task->sp = (sp);
- if ((uint8_t *) sp < &ao_cur_task->stack[0])
- ao_panic (AO_PANIC_STACK);
}
static inline void ao_arch_restore_stack(void) {
}
static inline void ao_arch_restore_stack(void) {
- uint32_t sp;
- uint32_t control;
-
- asm("mrs %0,control" : "=&r" (control));
- control |= (1 << 1);
- asm("msr control,%0" : : "r" (control));
- asm("isb");
-
- sp = (uint32_t) ao_cur_task->sp;
-
/* Switch stacks */
/* Switch stacks */
- asm("mov sp, %0" : : "r" (sp) );
+ asm("mov sp, %0" : : "r" (
ao_cur_task->
sp) );
/* Restore PRIMASK */
asm("pop {r0}");
/* Restore PRIMASK */
asm("pop {r0}");
@@
-454,14
+470,7
@@
static inline void ao_arch_start_scheduler(void) {
}
#endif
}
#endif
-static inline void ao_arch_isr_stack(void) {
- uint32_t control;
-
- asm("mrs %0,control" : "=&r" (control));
- control &= ~(1 << 1);
- asm("msr control,%0" : : "r" (control));
- asm("isb");
-}
+#define ao_arch_isr_stack()
#endif
#endif