diff --git a/arch/arm/src/lpc313x/lpc313x_spi.c b/arch/arm/src/lpc313x/lpc313x_spi.c index 98c3dc64d90c7335a30eb1a69d13e58e333dd50f..0d17be301955a662e78aa252cc5a5750762ab807 100644 --- a/arch/arm/src/lpc313x/lpc313x_spi.c +++ b/arch/arm/src/lpc313x/lpc313x_spi.c @@ -2,7 +2,8 @@ * arm/arm/src/lpc313x/lpc313x_spi.c * * Copyright (C) 2009-2010 Gregory Nutt. All rights reserved. - * Author: Gregory Nutt <spudmonkey@racsa.co.cr> + * Author: David Hewson, deriving in part from other SPI drivers originally by + * Gregory Nutt <spudmonkey@racsa.co.cr> * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions @@ -241,10 +242,12 @@ static inline void spi_select_slave(FAR struct lpc313x_spidev_s *priv, uint8_t s static inline uint16_t spi_readword(FAR struct lpc313x_spidev_s *priv) { /* Wait until the receive buffer is not empty */ + while ((getreg32 (LPC313X_SPI_STATUS) & SPI_STATUS_RXFIFOEMPTY) != 0) ; /* Then return the received byte */ + uint32_t val = getreg32 (LPC313X_SPI_FIFODATA); return val; @@ -267,9 +270,9 @@ static inline uint16_t spi_readword(FAR struct lpc313x_spidev_s *priv) static inline void spi_writeword(FAR struct lpc313x_spidev_s *priv, uint16_t word) { - /* Wait until the transmit buffer is empty */ + /* Wait until the transmit buffer is not full */ - while ((getreg32 (LPC313X_SPI_STATUS) & SPI_STATUS_TXFIFOFULL) != 0) + while ((getreg32 (LPC313X_SPI_STATUS) & SPI_STATUS_TXFIFOFULL) != 0) ; /* Then send the byte */ diff --git a/drivers/mtd/at45db.c b/drivers/mtd/at45db.c index d090a1b85396a5c3d59edc044fb355ab32c84fa5..28f9abc741d508d1cc507b3786d41d5062624dce 100644 --- a/drivers/mtd/at45db.c +++ b/drivers/mtd/at45db.c @@ -261,7 +261,7 @@ static void at45db_lock(struct at45db_dev_s *priv) * state. */ - SPI_SETMODE(priv->spi, SPIDEV_MODE3); + SPI_SETMODE(priv->spi, SPIDEV_MODE0); SPI_SETBITS(priv->spi, 8); (void)SPI_SETFREQUENCY(priv->spi, CONFIG_AT45DB_FREQUENCY); } @@ -275,7 +275,6 @@ static inline void at45db_unlock(struct at45db_dev_s *priv) (void)SPI_LOCK(priv->spi, false); } - /************************************************************************************ * Name: at45db_pwrdown ************************************************************************************/