summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKeith Packard <keithp@keithp.com>2013-06-12 00:43:31 -0700
committerKeith Packard <keithp@keithp.com>2013-08-25 22:24:01 -0700
commit312f6194a4bc75473cb0d61a6d58b66fb1f7c068 (patch)
tree7a7059f046d80d2d6743bf6d1b4d5e33f3b00567
parent2c2bbfd9a1a4b9de42cf566f21f179ff5ede0419 (diff)
altos/teletiny-v2.0: Support multiple SPI busses on CC1111
Needed for TeleMini v2.0 Signed-off-by: Keith Packard <keithp@keithp.com>
-rw-r--r--src/cc1111/ao_arch.h5
-rw-r--r--src/cc1111/ao_arch_funcs.h82
-rw-r--r--src/cc1111/ao_spi.c257
-rw-r--r--src/drivers/ao_ms5607.c2
-rw-r--r--src/telemini-v2.0/ao_pins.h4
-rw-r--r--src/telemini-v2.0/ao_telemini.c1
6 files changed, 231 insertions, 120 deletions
diff --git a/src/cc1111/ao_arch.h b/src/cc1111/ao_arch.h
index 9097557f..34235b08 100644
--- a/src/cc1111/ao_arch.h
+++ b/src/cc1111/ao_arch.h
@@ -321,4 +321,9 @@ void
ao_serial1_tx_isr(void) ao_arch_interrupt(14);
#endif
+#if HAS_EXTI_0
+void
+ao_p0_isr(void) __interrupt(13);
+#endif
+
#endif /* _AO_ARCH_H_ */
diff --git a/src/cc1111/ao_arch_funcs.h b/src/cc1111/ao_arch_funcs.h
index 8f1cc094..ae184108 100644
--- a/src/cc1111/ao_arch_funcs.h
+++ b/src/cc1111/ao_arch_funcs.h
@@ -19,46 +19,74 @@
* ao_spi.c
*/
-extern __xdata uint8_t ao_spi_mutex;
+#if !HAS_SPI_0 && !HAS_SPI_1
+#define HAS_SPI_0 1
+#define SPI_0_ALT_2 1
+#endif
+
+#if HAS_SPI_0 && HAS_SPI_1
+#define MULTI_SPI 1
+#define N_SPI 2
+#else
+#define MULTI_SPI 0
+#define N_SPI 1
+#endif
+
+extern __xdata uint8_t ao_spi_mutex[N_SPI];
+
+#if MULTI_SPI
+#define ao_spi_get(bus) ao_mutex_get(&ao_spi_mutex[bus])
+#define ao_spi_put(bus) ao_mutex_put(&ao_spi_mutex[bus])
+#else
+#define ao_spi_get(bus) ao_mutex_get(&ao_spi_mutex[0])
+#define ao_spi_put(bus) ao_mutex_put(&ao_spi_mutex[0])
+#endif
#define AO_SPI_SPEED_FAST 17
#define AO_SPI_SPEED_200kHz 13
-#define ao_spi_set_speed(speed) (U0GCR = (UxGCR_CPOL_NEGATIVE | \
- UxGCR_CPHA_FIRST_EDGE | \
- UxGCR_ORDER_MSB | \
- ((speed) << UxGCR_BAUD_E_SHIFT)))
+#if MULTI_SPI
+#define ao_spi_set_speed(bus,speed) (*(bus ? &U1GCR : &U0GCR) =(UxGCR_CPOL_NEGATIVE | \
+ UxGCR_CPHA_FIRST_EDGE | \
+ UxGCR_ORDER_MSB | \
+ ((speed) << UxGCR_BAUD_E_SHIFT)))
+#else
+#define ao_spi_set_speed(bus,speed) (U0GCR = (UxGCR_CPOL_NEGATIVE | \
+ UxGCR_CPHA_FIRST_EDGE | \
+ UxGCR_ORDER_MSB | \
+ ((speed) << UxGCR_BAUD_E_SHIFT)))
+#endif
#define ao_spi_get_slave(bus) do { \
- ao_mutex_get(&ao_spi_mutex); \
- ao_spi_set_speed(AO_SPI_SPEED_FAST); \
+ ao_spi_get(bus); \
+ ao_spi_set_speed(bus,AO_SPI_SPEED_FAST); \
} while (0)
#define ao_spi_put_slave(bus) do { \
- ao_mutex_put(&ao_spi_mutex); \
+ ao_spi_put(bus); \
} while (0)
#define ao_spi_get_mask(reg,mask,bus,speed) do { \
- ao_mutex_get(&ao_spi_mutex); \
- ao_spi_set_speed(speed); \
+ ao_spi_get(bus); \
+ ao_spi_set_speed(bus,speed); \
(reg) &= ~(mask); \
} while (0)
#define ao_spi_put_mask(reg,mask,bus) do { \
(reg) |= (mask); \
- ao_mutex_put(&ao_spi_mutex); \
+ ao_spi_put(bus); \
} while (0)
#define ao_spi_get_bit(reg,bit,pin,bus,speed) do { \
- ao_mutex_get(&ao_spi_mutex); \
- ao_spi_set_speed(speed); \
- pin = 0; \
+ ao_spi_get(bus); \
+ ao_spi_set_speed(bus,speed); \
+ pin = 0; \
} while (0)
#define ao_spi_put_bit(reg,bit,pin,bus) do { \
pin = 1; \
- ao_mutex_put(&ao_spi_mutex); \
+ ao_spi_put(bus); \
} while (0)
@@ -68,6 +96,13 @@ extern __xdata uint8_t ao_spi_mutex;
* from chip select low to chip select high
*/
+#if MULTI_SPI
+void
+ao_spi_send(void __xdata *block, uint16_t len, uint8_t bus) __reentrant;
+
+void
+ao_spi_recv(void __xdata *block, uint16_t len, uint8_t bus) __reentrant;
+#else
void
ao_spi_send_bus(void __xdata *block, uint16_t len) __reentrant;
@@ -76,6 +111,7 @@ ao_spi_recv_bus(void __xdata *block, uint16_t len) __reentrant;
#define ao_spi_send(block, len, bus) ao_spi_send_bus(block, len)
#define ao_spi_recv(block, len, bus) ao_spi_recv_bus(block, len)
+#endif
#if AO_SPI_SLAVE
void
@@ -88,10 +124,15 @@ ao_spi_recv_wait(void);
void
ao_spi_init(void);
-#define ao_spi_init_cs(port, mask) do { \
- SPI_CS_PORT |= mask; \
- SPI_CS_DIR |= mask; \
- SPI_CS_SEL &= ~mask; \
+#define token_paster(x,y) x ## y
+#define token_paster3(x,y,z) x ## y ## z
+#define token_evaluator(x,y) token_paster(x,y)
+#define token_evaluator3(x,y,z) token_paster3(x,y,z)
+
+#define ao_spi_init_cs(port, mask) do { \
+ port |= mask; \
+ token_evaluator(port,DIR) |= mask; \
+ token_evaluator(port,SEL) &= ~mask; \
} while (0)
#define cc1111_enable_output(port,dir,sel,pin,bit,v) do { \
@@ -102,7 +143,6 @@ ao_spi_init(void);
#define disable_unreachable _Pragma("disable_warning 126")
-#define token_paster(x,y) x ## y
-#define token_evaluator(x,y) token_paster(x,y)
#define ao_enable_output(port,bit,pin,v) cc1111_enable_output(port,token_evaluator(port,DIR), token_evaluator(port,SEL), pin, bit, v)
#define ao_gpio_set(port, bit, pin, v) ((pin) = (v))
+
diff --git a/src/cc1111/ao_spi.c b/src/cc1111/ao_spi.c
index cdef6bda..fb08f3f5 100644
--- a/src/cc1111/ao_spi.c
+++ b/src/cc1111/ao_spi.c
@@ -18,10 +18,6 @@
#include "ao.h"
/* Default pin usage for existing Altus Metrum devices */
-#if !HAS_SPI_0 && !HAS_SPI_1
-#define HAS_SPI_0 1
-#define SPI_0_ALT_2 1
-#endif
#ifndef SPI_CONST
#define SPI_CONST 0xff
@@ -61,62 +57,107 @@
*/
#if HAS_SPI_0
-#define SPI_CSR U0CSR
-#define SPI_BUF U0DBUFXADDR
-#define SPI_BAUD U0BAUD
-#define SPI_GCR U0GCR
-#define SPI_CFG_MASK PERCFG_U0CFG_ALT_MASK
-#define SPI_DMA_TX DMA_CFG0_TRIGGER_UTX0
-#define SPI_DMA_RX DMA_CFG0_TRIGGER_URX0
+#define SPI_BUF_0 &U0DBUFXADDR
+#define SPI_CSR_0 U0CSR
+#define SPI_BAUD_0 U0BAUD
+#define SPI_GCR_0 U0GCR
+#define SPI_CFG_MASK_0 PERCFG_U0CFG_ALT_MASK
+#define SPI_DMA_TX_0 DMA_CFG0_TRIGGER_UTX0
+#define SPI_DMA_RX_0 DMA_CFG0_TRIGGER_URX0
#if SPI_0_ALT_1
-#define SPI_CFG PERCFG_U0CFG_ALT_1
-#define SPI_SEL P0SEL
-#define SPI_BITS (1 << 3) | (1 << 2) | (1 << 5)
-#define SPI_CSS_BIT (1 << 4)
+#define SPI_CFG_0 PERCFG_U0CFG_ALT_1
+#define SPI_SEL_0 P0SEL
+#define SPI_BITS_0 (1 << 3) | (1 << 2) | (1 << 5)
+#define SPI_CSS_BIT_0 (1 << 4)
#endif
#if SPI_0_ALT_2
-#define SPI_CFG PERCFG_U0CFG_ALT_2
-#define SPI_SEL P1SEL
-#define SPI_PRI P2SEL_PRI3P1_USART0
-#define SPI_BITS (1 << 5) | (1 << 4) | (1 << 3)
-#define SPI_CSS_BIT (1 << 2)
+#define SPI_CFG_0 PERCFG_U0CFG_ALT_2
+#define SPI_SEL_0 P1SEL
+#define SPI_PRI_0 P2SEL_PRI3P1_USART0
+#define SPI_BITS_0 (1 << 5) | (1 << 4) | (1 << 3)
+#define SPI_CSS_BIT_0 (1 << 2)
#endif
#endif
#if HAS_SPI_1
-#define SPI_CSR U1CSR
-#define SPI_BUF U1DBUFXADDR
-#define SPI_BAUD U1BAUD
-#define SPI_GCR U1GCR
-#define SPI_CFG_MASK PERCFG_U1CFG_ALT_MASK
-#define SPI_DMA_TX DMA_CFG0_TRIGGER_UTX1
-#define SPI_DMA_RX DMA_CFG0_TRIGGER_URX1
+#define SPI_BUF_1 &U1DBUFXADDR
+#define SPI_CSR_1 U1CSR
+#define SPI_BAUD_1 U1BAUD
+#define SPI_GCR_1 U1GCR
+#define SPI_CFG_MASK_1 PERCFG_U1CFG_ALT_MASK
+#define SPI_DMA_TX_1 DMA_CFG0_TRIGGER_UTX1
+#define SPI_DMA_RX_1 DMA_CFG0_TRIGGER_URX1
#if SPI_1_ALT_1
-#define SPI_CFG PERCFG_U1CFG_ALT_1
-#define SPI_SEL P0SEL
-#define SPI_BITS (1 << 4) | (1 << 5) | (1 << 3)
-#define SPI_CSS_BIT (1 << 2)
+#define SPI_CFG_1 PERCFG_U1CFG_ALT_1
+#define SPI_SEL_1 P0SEL
+#define SPI_BITS_1 (1 << 4) | (1 << 5) | (1 << 3)
+#define SPI_CSS_BIT_1 (1 << 2)
#endif
#if SPI_1_ALT_2
-#define SPI_CFG PERCFG_U1CFG_ALT_2
-#define SPI_SEL P1SEL
-#define SPI_PRI P2SEL_PRI3P1_USART1
-#define SPI_BITS (1 << 6) | (1 << 7) | (1 << 5)
-#define SPI_CSS_BIT (1 << 4)
+#define SPI_CFG_1 PERCFG_U1CFG_ALT_2
+#define SPI_SEL_1 P1SEL
+#define SPI_PRI_1 P2SEL_PRI3P1_USART1
+#define SPI_BITS_1 (1 << 6) | (1 << 7) | (1 << 5)
+#define SPI_CSS_BIT_1 (1 << 4)
#endif
#endif
+#if MULTI_SPI
+
+#define SPI_BUF(bus) ((bus) ? SPI_BUF_1 : SPI_BUF_0)
+#define SPI_CSR(bus) ((bus) ? SPI_CSR_1 : SPI_CSR_0)
+#define SPI_BAUD(bus) ((bus) ? SPI_BAUD_1 : SPI_BAUD_0)
+#define SPI_GCR(bus) ((bus) ? SPI_GCR_1 : SPI_GCR_0)
+#define SPI_CFG_MASK(bus) ((bus) ? SPI_CFG_MASK_1 : SPI_CFG_MASK_0)
+#define SPI_DMA_TX(bus) ((bus) ? SPI_DMA_TX_1 : SPI_DMA_TX_0)
+#define SPI_DMA_RX(bus) ((bus) ? SPI_DMA_RX_1 : SPI_DMA_RX_0)
+#define SPI_CFG(bus) ((bus) ? SPI_CFG_1 : SPI_CFG_0)
+#define SPI_SEL(bus) ((bus) ? SPI_SEL_1 : SPI_SEL_0)
+#define SPI_BITS(bus) ((bus) ? SPI_BITS_1 : SPI_BITS_0)
+#define SPI_CSS_BIT(bus) ((bus) ? SPI_CSS_BIT_1 : SPI_CSS_BIT_0)
+
+#else
+
+#if HAS_SPI_0
+#define SPI_BUF(bus) SPI_BUF_0
+#define SPI_CSR(bus) SPI_CSR_0
+#define SPI_BAUD(bus) SPI_BAUD_0
+#define SPI_GCR(bus) SPI_GCR_0
+#define SPI_CFG_MASK(bus) SPI_CFG_MASK_0
+#define SPI_DMA_TX(bus) SPI_DMA_TX_0
+#define SPI_DMA_RX(bus) SPI_DMA_RX_0
+#define SPI_CFG(bus) SPI_CFG_0
+#define SPI_SEL(bus) SPI_SEL_0
+#define SPI_BITS(bus) SPI_BITS_0
+#define SPI_CSS_BIT(bus) SPI_CSS_BIT_0
+#endif
+#if HAS_SPI_1
+#define SPI_BUF(bus) SPI_BUF_1
+#define SPI_CSR(bus) SPI_CSR_1
+#define SPI_BAUD(bus) SPI_BAUD_1
+#define SPI_GCR(bus) SPI_GCR_1
+#define SPI_CFG_MASK(bus) SPI_CFG_MASK_1
+#define SPI_DMA_TX(bus) SPI_DMA_TX_1
+#define SPI_DMA_RX(bus) SPI_DMA_RX_1
+#define SPI_CFG(bus) SPI_CFG_1
+#define SPI_SEL(bus) SPI_SEL_1
+#define SPI_BITS(bus) SPI_BITS_1
+#define SPI_CSS_BIT(bus) SPI_CSS_BIT_1
+#endif
+
+#endif /* MULTI_SPI */
+
#if AO_SPI_SLAVE
-#define CSS SPI_CSS_BIT
+#define CSS(bus) SPI_CSS_BIT(bus)
#define UxCSR_DIRECTION UxCSR_SLAVE
#else
-#define CSS 0
+#define CSS(bus) 0
#define UxCSR_DIRECTION UxCSR_MASTER
#endif
@@ -124,15 +165,16 @@
* operation, from CS low to CS high. This means that any SPI
* user must protect the SPI bus with this mutex
*/
-__xdata uint8_t ao_spi_mutex;
-__xdata uint8_t ao_spi_dma_in_done;
-__xdata uint8_t ao_spi_dma_out_done;
+__xdata uint8_t ao_spi_mutex[N_SPI];
+__xdata uint8_t ao_spi_dma_in_done[N_SPI];
+__xdata uint8_t ao_spi_dma_out_done[N_SPI];
-uint8_t ao_spi_dma_out_id;
-uint8_t ao_spi_dma_in_id;
+uint8_t ao_spi_dma_out_id[N_SPI];
+uint8_t ao_spi_dma_in_id[N_SPI];
static __xdata uint8_t ao_spi_const;
+
/* Send bytes over SPI.
*
* This sets up two DMA engines, one writing the data and another reading
@@ -140,45 +182,52 @@ static __xdata uint8_t ao_spi_const;
* is complete, as the transmit register is double buffered and hence signals
* completion one byte before the transfer is actually complete
*/
+#if MULTI_SPI
+void
+ao_spi_send(void __xdata *block, uint16_t len, uint8_t bus) __reentrant
+#else
void
ao_spi_send_bus(void __xdata *block, uint16_t len) __reentrant
+#define bus 0
+#endif
{
- ao_dma_set_transfer(ao_spi_dma_in_id,
- &SPI_BUF,
+ ao_dma_set_transfer(ao_spi_dma_in_id[bus],
+ SPI_BUF(bus),
&ao_spi_const,
len,
DMA_CFG0_WORDSIZE_8 |
DMA_CFG0_TMODE_SINGLE |
- SPI_DMA_RX,
+ SPI_DMA_RX(bus),
DMA_CFG1_SRCINC_0 |
DMA_CFG1_DESTINC_0 |
DMA_CFG1_PRIORITY_NORMAL);
- ao_dma_set_transfer(ao_spi_dma_out_id,
+ ao_dma_set_transfer(ao_spi_dma_out_id[bus],
block,
- &SPI_BUF,
+ SPI_BUF(bus),
len,
DMA_CFG0_WORDSIZE_8 |
DMA_CFG0_TMODE_SINGLE |
- SPI_DMA_TX,
+ SPI_DMA_TX(bus),
DMA_CFG1_SRCINC_1 |
DMA_CFG1_DESTINC_0 |
DMA_CFG1_PRIORITY_NORMAL);
- ao_dma_start(ao_spi_dma_in_id);
- ao_dma_start(ao_spi_dma_out_id);
- ao_dma_trigger(ao_spi_dma_out_id);
+ ao_dma_start(ao_spi_dma_in_id[bus]);
+ ao_dma_start(ao_spi_dma_out_id[bus]);
+ ao_dma_trigger(ao_spi_dma_out_id[bus]);
#if !AO_SPI_SLAVE
- __critical while (!ao_spi_dma_in_done)
- ao_sleep(&ao_spi_dma_in_done);
+ __critical while (!ao_spi_dma_in_done[bus])
+ ao_sleep(&ao_spi_dma_in_done[bus]);
#endif
+#undef bus
}
#if AO_SPI_SLAVE
void
ao_spi_send_wait(void)
{
- __critical while (!ao_spi_dma_in_done)
- ao_sleep(&ao_spi_dma_in_done);
+ __critical while (!ao_spi_dma_in_done[0])
+ ao_sleep(&ao_spi_dma_in_done[0]);
}
#endif
@@ -188,16 +237,22 @@ ao_spi_send_wait(void)
* writing constant values to the SPI transmitter as that is what
* clocks the data coming in.
*/
+#if MULTI_SPI
+void
+ao_spi_recv(void __xdata *block, uint16_t len, uint8_t bus) __reentrant
+#else
void
ao_spi_recv_bus(void __xdata *block, uint16_t len) __reentrant
+#define bus 0
+#endif
{
- ao_dma_set_transfer(ao_spi_dma_in_id,
- &SPI_BUF,
+ ao_dma_set_transfer(ao_spi_dma_in_id[bus],
+ SPI_BUF(bus),
block,
len,
DMA_CFG0_WORDSIZE_8 |
DMA_CFG0_TMODE_SINGLE |
- SPI_DMA_RX,
+ SPI_DMA_RX(bus),
DMA_CFG1_SRCINC_0 |
DMA_CFG1_DESTINC_1 |
DMA_CFG1_PRIORITY_NORMAL);
@@ -205,24 +260,24 @@ ao_spi_recv_bus(void __xdata *block, uint16_t len) __reentrant
ao_spi_const = SPI_CONST;
#if !AO_SPI_SLAVE
- ao_dma_set_transfer(ao_spi_dma_out_id,
+ ao_dma_set_transfer(ao_spi_dma_out_id[bus],
&ao_spi_const,
- &SPI_BUF,
+ SPI_BUF(bus),
len,
DMA_CFG0_WORDSIZE_8 |
DMA_CFG0_TMODE_SINGLE |
- SPI_DMA_TX,
+ SPI_DMA_TX(bus),
DMA_CFG1_SRCINC_0 |
DMA_CFG1_DESTINC_0 |
DMA_CFG1_PRIORITY_NORMAL);
#endif
- ao_dma_start(ao_spi_dma_in_id);
+ ao_dma_start(ao_spi_dma_in_id[bus]);
#if !AO_SPI_SLAVE
- ao_dma_start(ao_spi_dma_out_id);
- ao_dma_trigger(ao_spi_dma_out_id);
- __critical while (!ao_spi_dma_in_done)
- ao_sleep(&ao_spi_dma_in_done);
+ ao_dma_start(ao_spi_dma_out_id[bus]);
+ ao_dma_trigger(ao_spi_dma_out_id[bus]);
+ __critical while (!ao_spi_dma_in_done[bus])
+ ao_sleep(&ao_spi_dma_in_done[bus]);
#endif
}
@@ -230,17 +285,43 @@ ao_spi_recv_bus(void __xdata *block, uint16_t len) __reentrant
void
ao_spi_recv_wait(void)
{
- __critical while (!ao_spi_dma_in_done)
- ao_sleep(&ao_spi_dma_in_done);
+ __critical while (!ao_spi_dma_in_done[0])
+ ao_sleep(&ao_spi_dma_in_done[0]);
}
#endif
+/* Set up the USART.
+ *
+ * SPI master/slave mode
+ */
+/* Set the baud rate and signal parameters
+ *
+ * The cc1111 is limited to a 24/8 MHz SPI clock.
+ * Every peripheral I've ever seen goes faster than that,
+ * so set the clock to 3MHz (BAUD_E 17, BAUD_M 0)
+ */
+#define SPI_INIT(bus,o) do { \
+ /* Set up the USART pin assignment */ \
+ PERCFG = (PERCFG & ~SPI_CFG_MASK(bus)) | SPI_CFG(bus); \
+ \
+ /* Make the SPI pins be controlled by the USART peripheral */ \
+ SPI_SEL(bus) |= SPI_BITS(bus) | CSS(bus); \
+ SPI_CSR(bus) = (UxCSR_MODE_SPI | UxCSR_RE | UxCSR_DIRECTION); \
+ SPI_BAUD(bus) = 0; \
+ SPI_GCR(bus) = (UxGCR_CPOL_NEGATIVE | \
+ UxGCR_CPHA_FIRST_EDGE | \
+ UxGCR_ORDER_MSB | \
+ (17 << UxGCR_BAUD_E_SHIFT)); \
+ /* Set up OUT DMA */ \
+ ao_spi_dma_out_id[o] = ao_dma_alloc(&ao_spi_dma_out_done[o]); \
+ \
+ /* Set up IN DMA */ \
+ ao_spi_dma_in_id[o] = ao_dma_alloc(&ao_spi_dma_in_done[o]); \
+ } while (0)
+
void
ao_spi_init(void)
{
- /* Set up the USART pin assignment */
- PERCFG = (PERCFG & ~SPI_CFG_MASK) | SPI_CFG;
-
/* Ensure that SPI USART takes precidence over the other USART
* for pins that they share
*/
@@ -248,30 +329,10 @@ ao_spi_init(void)
P2SEL = (P2SEL & ~P2SEL_PRI3P1_MASK) | SPI_PRI;
#endif
- /* Make the SPI pins be controlled by the USART peripheral */
- SPI_SEL |= SPI_BITS | CSS;
-
- /* Set up OUT DMA */
- ao_spi_dma_out_id = ao_dma_alloc(&ao_spi_dma_out_done);
-
- /* Set up IN DMA */
- ao_spi_dma_in_id = ao_dma_alloc(&ao_spi_dma_in_done);
-
- /* Set up the USART.
- *
- * SPI master/slave mode
- */
- SPI_CSR = (UxCSR_MODE_SPI | UxCSR_RE | UxCSR_DIRECTION);
-
- /* Set the baud rate and signal parameters
- *
- * The cc1111 is limited to a 24/8 MHz SPI clock.
- * Every peripheral I've ever seen goes faster than that,
- * so set the clock to 3MHz (BAUD_E 17, BAUD_M 0)
- */
- SPI_BAUD = 0;
- SPI_GCR = (UxGCR_CPOL_NEGATIVE |
- UxGCR_CPHA_FIRST_EDGE |
- UxGCR_ORDER_MSB |
- (17 << UxGCR_BAUD_E_SHIFT));
+#if HAS_SPI_0
+ SPI_INIT(0, 0);
+#endif
+#if HAS_SPI_1
+ SPI_INIT(1, MULTI_SPI);
+#endif
}
diff --git a/src/drivers/ao_ms5607.c b/src/drivers/ao_ms5607.c
index 4b4403a7..7c1acdd1 100644
--- a/src/drivers/ao_ms5607.c
+++ b/src/drivers/ao_ms5607.c
@@ -22,7 +22,7 @@
#if HAS_MS5607 || HAS_MS5611
static __xdata struct ao_ms5607_prom ms5607_prom;
-static uint8_t ms5607_configured;
+static __xdata uint8_t ms5607_configured;
static void
ao_ms5607_start(void) {
diff --git a/src/telemini-v2.0/ao_pins.h b/src/telemini-v2.0/ao_pins.h
index c27f47f1..9ecd076e 100644
--- a/src/telemini-v2.0/ao_pins.h
+++ b/src/telemini-v2.0/ao_pins.h
@@ -47,7 +47,9 @@
*/
#define HAS_SPI_0 1
+#define SPI_0_ALT_1 1
#define HAS_SPI_1 1
+#define SPI_1_ALT_2 1
#define SPI_CS_PORT P1
#define SPI_CS_SEL P1SEL
#define SPI_CS_DIR P1DIR
@@ -55,6 +57,7 @@
/*
* Flash
*/
+#define AO_M25_SPI_BUS 1
#define AO_M25_SPI_CS_PORT SPI_CS_PORT
#define AO_M25_SPI_CS_MASK 0x04 /* cs_flash is P1_2 */
#define M25_MAX_CHIPS 1
@@ -74,6 +77,7 @@
#define AO_MS5607_MISO_PIN 2
#define AO_MS5607_MISO_MASK (1 << AO_MS5607_MISO_PIN)
#define AO_MS5607_SPI_INDEX 0
+#define HAS_EXTI_0 1
/*
* Igniters
diff --git a/src/telemini-v2.0/ao_telemini.c b/src/telemini-v2.0/ao_telemini.c
index b85ce8c8..6b7545fb 100644
--- a/src/telemini-v2.0/ao_telemini.c
+++ b/src/telemini-v2.0/ao_telemini.c
@@ -17,6 +17,7 @@
#include "ao.h"
#include "ao_pins.h"
+#include <ao_exti.h>
__xdata uint8_t ao_force_freq;