projects
/
fw
/
altos
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
altos: Broke TeleMetrum GPS reporting by holding the GPS mutex too much
[fw/altos]
/
src
/
lpc
/
ao_spi_lpc.c
diff --git
a/src/lpc/ao_spi_lpc.c
b/src/lpc/ao_spi_lpc.c
index e7edca4c1a165e7a090339c20e7354d4ec75601c..a889137cbb7a4e1f84437f601d76e78f8cc22ce8 100644
(file)
--- a/
src/lpc/ao_spi_lpc.c
+++ b/
src/lpc/ao_spi_lpc.c
@@
-42,7
+42,7
@@
static uint8_t spi_dev_null;
/* recv a byte */ \
get lpc_ssp->dr; \
} \
/* recv a byte */ \
get lpc_ssp->dr; \
} \
- } while (0)
;
+ } while (0)
void
ao_spi_send(void *block, uint16_t len, uint8_t id)
void
ao_spi_send(void *block, uint16_t len, uint8_t id)
@@
-89,24
+89,11
@@
ao_spi_get(uint8_t id, uint32_t speed)
/* Set the clock prescale */
lpc_ssp->cpsr = speed;
/* Set the clock prescale */
lpc_ssp->cpsr = speed;
-
- /* Enable the device */
- lpc_ssp->cr1 = ((0 << LPC_SSP_CR1_LBM) |
- (1 << LPC_SSP_CR1_SSE) |
- (LPC_SSP_CR1_MS_MASTER << LPC_SSP_CR1_MS) |
- (0 << LPC_SSP_CR1_SOD));
}
void
ao_spi_put(uint8_t id)
{
}
void
ao_spi_put(uint8_t id)
{
- struct lpc_ssp *lpc_ssp = ao_lpc_ssp[id];
-
- /* Disable the device */
- lpc_ssp->cr1 = ((0 << LPC_SSP_CR1_LBM) |
- (0 << LPC_SSP_CR1_SSE) |
- (LPC_SSP_CR1_MS_MASTER << LPC_SSP_CR1_MS) |
- (0 << LPC_SSP_CR1_SOD));
ao_mutex_put(&ao_spi_mutex[id]);
}
ao_mutex_put(&ao_spi_mutex[id]);
}
@@
-121,6
+108,13
@@
ao_spi_channel_init(uint8_t id)
(0 << LPC_SSP_CR0_CPOL) |
(0 << LPC_SSP_CR0_CPHA) |
(0 << LPC_SSP_CR0_SCR));
(0 << LPC_SSP_CR0_CPOL) |
(0 << LPC_SSP_CR0_CPHA) |
(0 << LPC_SSP_CR0_SCR));
+
+ /* Enable the device */
+ lpc_ssp->cr1 = ((0 << LPC_SSP_CR1_LBM) |
+ (1 << LPC_SSP_CR1_SSE) |
+ (LPC_SSP_CR1_MS_MASTER << LPC_SSP_CR1_MS) |
+ (0 << LPC_SSP_CR1_SOD));
+
/* Drain the receive fifo */
for (d = 0; d < LPC_SSP_FIFOSIZE; d++)
(void) lpc_ssp->dr;
/* Drain the receive fifo */
for (d = 0; d < LPC_SSP_FIFOSIZE; d++)
(void) lpc_ssp->dr;
@@
-131,7
+125,21
@@
ao_spi_init(void)
{
#if HAS_SPI_0
/* Configure pins */
{
#if HAS_SPI_0
/* Configure pins */
- lpc_ioconf.pio0_6 = ao_lpc_alternate(LPC_IOCONF_FUNC_SCK0);
+#if SPI_SCK0_P0_6
+ lpc_ioconf.pio0_6 = ao_lpc_alternate(LPC_IOCONF_FUNC_PIO0_6_SCK0);
+#define HAS_SCK0
+#endif
+#if SPI_SCK0_P0_10
+ lpc_ioconf.pio0_10 = ao_lpc_alternate(LPC_IOCONF_FUNC_PIO0_10_SCK0);
+#define HAS_SCK0
+#endif
+#if SPI_SCK0_P1_29
+ lpc_ioconf.pio1_29 = ao_lpc_alternate(LPC_IOCONF_FUNC_PIO1_29_SCK0);
+#define HAS_SCK0
+#endif
+#ifndef HAS_SCK0
+#error "No pin specified for SCK0"
+#endif
lpc_ioconf.pio0_8 = ao_lpc_alternate(LPC_IOCONF_FUNC_MISO0);
lpc_ioconf.pio0_9 = ao_lpc_alternate(LPC_IOCONF_FUNC_MOSI0);
lpc_ioconf.pio0_8 = ao_lpc_alternate(LPC_IOCONF_FUNC_MISO0);
lpc_ioconf.pio0_9 = ao_lpc_alternate(LPC_IOCONF_FUNC_MOSI0);
@@
-174,7
+182,7
@@
ao_spi_init(void)
#endif
#if SPI_MOSI1_P0_21
#endif
#if SPI_MOSI1_P0_21
- lpc_ioconf.pio
1
_21 = ao_lpc_alternate(LPC_IOCONF_FUNC_PIO0_21_MOSI1);
+ lpc_ioconf.pio
0
_21 = ao_lpc_alternate(LPC_IOCONF_FUNC_PIO0_21_MOSI1);
#define HAS_MOSI1
#endif
#if SPI_MOSI1_P1_22
#define HAS_MOSI1
#endif
#if SPI_MOSI1_P1_22
@@
-191,7
+199,8
@@
ao_spi_init(void)
/* Turn on the clock */
lpc_scb.ssp1clkdiv = 1;
/* Turn on the clock */
lpc_scb.ssp1clkdiv = 1;
- /* De-assert reset */
+ /* Reset the device */
+ lpc_scb.presetctrl &= ~(1 << LPC_SCB_PRESETCTRL_SSP1_RST_N);
lpc_scb.presetctrl |= (1 << LPC_SCB_PRESETCTRL_SSP1_RST_N);
ao_spi_channel_init(1);
#endif /* HAS_SPI_1 */
lpc_scb.presetctrl |= (1 << LPC_SCB_PRESETCTRL_SSP1_RST_N);
ao_spi_channel_init(1);
#endif /* HAS_SPI_1 */