mirror of
https://github.com/apache/nuttx.git
synced 2026-06-08 01:42:58 +08:00
Review of previous commit for coding style. Tickless RIT logic still does not follow naming conventions or file format rules
This commit is contained in:
@@ -1,7 +1,7 @@
|
||||
/****************************************************************************
|
||||
* arch/arm/src/lpc43xx/lpc43_i2c.c
|
||||
*
|
||||
* Copyright (C) 2012, 2014 Gregory Nutt. All rights reserved.
|
||||
* Copyright (C) 2012, 2014-2015 Gregory Nutt. All rights reserved.
|
||||
* Author: Gregory Nutt <gnutt@nuttx.org>
|
||||
*
|
||||
* Ported from from the LPC17 version:
|
||||
@@ -234,8 +234,8 @@ static int i2c_write(FAR struct i2c_dev_s *dev, const uint8_t *buffer,
|
||||
priv->msg.buffer = (uint8_t *)buffer;
|
||||
priv->msg.length = buflen;
|
||||
|
||||
priv->nmsg = 1;
|
||||
priv->msgs = &(priv->msg);
|
||||
priv->nmsg = 1;
|
||||
priv->msgs = &(priv->msg);
|
||||
|
||||
if (buflen > 0)
|
||||
{
|
||||
@@ -261,14 +261,14 @@ static int i2c_read(FAR struct i2c_dev_s *dev, uint8_t *buffer, int buflen)
|
||||
|
||||
DEBUGASSERT(dev != NULL);
|
||||
|
||||
priv->wrcnt = 0;
|
||||
priv->rdcnt = 0;
|
||||
priv->wrcnt = 0;
|
||||
priv->rdcnt = 0;
|
||||
priv->msg.flags = I2C_M_READ;
|
||||
priv->msg.buffer = buffer;
|
||||
priv->msg.length = buflen;
|
||||
|
||||
priv->nmsg = 1;
|
||||
priv->msgs = &(priv->msg);
|
||||
priv->nmsg = 1;
|
||||
priv->msgs = &(priv->msg);
|
||||
|
||||
if (buflen > 0)
|
||||
{
|
||||
@@ -427,8 +427,15 @@ static int i2c_interrupt(int irq, FAR void *context)
|
||||
|
||||
case 0x08: /* A START condition has been transmitted. */
|
||||
case 0x10: /* A Repeated START condition has been transmitted. */
|
||||
putreg32(((I2C_M_READ & msg->flags) == I2C_M_READ)?I2C_READADDR8(msg->addr):I2C_WRITEADDR8(msg->addr), priv->base + LPC43_I2C_DAT_OFFSET); /* set address */
|
||||
putreg32(I2C_CONCLR_STAC, priv->base + LPC43_I2C_CONCLR_OFFSET); /* clear start bit */
|
||||
/* Set address */
|
||||
|
||||
putreg32(((I2C_M_READ & msg->flags) == I2C_M_READ) ?
|
||||
I2C_READADDR8(msg->addr) :
|
||||
I2C_WRITEADDR8(msg->addr), priv->base + LPC43_I2C_DAT_OFFSET);
|
||||
|
||||
/* Clear start bit */
|
||||
|
||||
putreg32(I2C_CONCLR_STAC, priv->base + LPC43_I2C_CONCLR_OFFSET);
|
||||
break;
|
||||
|
||||
/* Write cases */
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
/****************************************************************************
|
||||
* arch/arm/src/lpc43xx/lpc43_spi.c
|
||||
*
|
||||
* Copyright (C) 2012 Gregory Nutt. All rights reserved.
|
||||
* Copyright (C) 2015 Gregory Nutt. All rights reserved.
|
||||
* Author: Gregory Nutt <gnutt@nuttx.org>
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
@@ -603,20 +603,20 @@ FAR struct spi_dev_s *lpc43_spiinitialize(int port)
|
||||
|
||||
FAR struct spi_dev_s *up_spiinitialize(int port)
|
||||
{
|
||||
if (port) {
|
||||
#if ( defined(CONFIG_LPC43_SSP0) || defined(CONFIG_LPC43_SSP1) )
|
||||
return lpc43_sspinitialize(port-1);
|
||||
if (port)
|
||||
{
|
||||
#if defined(CONFIG_LPC43_SSP0) || defined(CONFIG_LPC43_SSP1)
|
||||
return lpc43_sspinitialize(port - 1);
|
||||
#else
|
||||
return NULL;
|
||||
return NULL;
|
||||
#endif
|
||||
} else {
|
||||
}
|
||||
else
|
||||
{
|
||||
#if defined(CONFIG_LPC43_SPI)
|
||||
return lpc43_spiinitialize(port);
|
||||
return lpc43_spiinitialize(port);
|
||||
#else
|
||||
return NULL;
|
||||
return NULL;
|
||||
#endif
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -534,8 +534,30 @@ static uint16_t ssp_send(FAR struct spi_dev_s *dev, uint16_t wd)
|
||||
return (uint16_t)regval;
|
||||
}
|
||||
|
||||
/****************************************************************************
|
||||
* Name: ssp_exchange
|
||||
*
|
||||
* Description:
|
||||
* Exahange a block of data from SPI. Required.
|
||||
*
|
||||
* Input Parameters:
|
||||
* dev - Device-specific state data
|
||||
* txbuffer - A pointer to the buffer of data to be sent
|
||||
* rxbuffer - A pointer to the buffer in which to receive data
|
||||
* nwords - the length of data that to be exchanged in units of words.
|
||||
* The wordsize is determined by the number of bits-per-word
|
||||
* selected for the SPI interface. If nbits <= 8, the data is
|
||||
* packed into uint8_t's; if nbits >8, the data is packed into
|
||||
* uint16_t's
|
||||
*
|
||||
* Returned Value:
|
||||
* None
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
static void ssp_exchange(FAR struct spi_dev_s *dev, FAR const void *txbuffer,
|
||||
FAR void *rxbuffer, size_t nwords) {
|
||||
FAR void *rxbuffer, size_t nwords)
|
||||
{
|
||||
FAR struct lpc43_sspdev_s *priv = (FAR struct lpc43_sspdev_s *)dev;
|
||||
union
|
||||
{
|
||||
@@ -550,7 +572,7 @@ static void ssp_exchange(FAR struct spi_dev_s *dev, FAR const void *txbuffer,
|
||||
FAR const void *pv;
|
||||
} rx;
|
||||
uint32_t data;
|
||||
uint32_t datadummy = (priv->nbits > 8)?0xffff:0xff;
|
||||
uint32_t datadummy = (priv->nbits > 8) ? 0xffff : 0xff;
|
||||
uint32_t rxpending = 0;
|
||||
|
||||
/* While there is remaining to be sent (and no synchronization error has occurred) */
|
||||
@@ -569,38 +591,39 @@ static void ssp_exchange(FAR struct spi_dev_s *dev, FAR const void *txbuffer,
|
||||
|
||||
spivdbg("TX: rxpending: %d nwords: %d\n", rxpending, nwords);
|
||||
while ((ssp_getreg(priv, LPC43_SSP_SR_OFFSET) & SSP_SR_TNF) &&
|
||||
(rxpending < LPC43_SSP_FIFOSZ) && nwords)
|
||||
{
|
||||
if (txbuffer && priv->nbits > 8)
|
||||
{
|
||||
data = (uint32_t)*tx.p16++;
|
||||
}
|
||||
else
|
||||
{
|
||||
data = (uint32_t)*tx.p8++;
|
||||
}
|
||||
(rxpending < LPC43_SSP_FIFOSZ) && nwords)
|
||||
{
|
||||
if (txbuffer && priv->nbits > 8)
|
||||
{
|
||||
data = (uint32_t)*tx.p16++;
|
||||
}
|
||||
else
|
||||
{
|
||||
data = (uint32_t)*tx.p8++;
|
||||
}
|
||||
|
||||
ssp_putreg(priv, LPC43_SSP_DR_OFFSET, txbuffer?data:datadummy);
|
||||
nwords--;
|
||||
rxpending++;
|
||||
}
|
||||
ssp_putreg(priv, LPC43_SSP_DR_OFFSET, txbuffer?data:datadummy);
|
||||
nwords--;
|
||||
rxpending++;
|
||||
}
|
||||
|
||||
/* Now, read the RX data from the RX FIFO while the RX FIFO is not empty */
|
||||
|
||||
spivdbg("RX: rxpending: %d\n", rxpending);
|
||||
while (ssp_getreg(priv, LPC43_SSP_SR_OFFSET) & SSP_SR_RNE)
|
||||
{
|
||||
data = ssp_getreg(priv, LPC43_SSP_DR_OFFSET);
|
||||
if (rxbuffer && priv->nbits > 8)
|
||||
{
|
||||
*rx.p16++ = (uint16_t)data;
|
||||
}
|
||||
else
|
||||
{
|
||||
*rx.p8++ = (uint8_t)data;
|
||||
}
|
||||
rxpending--;
|
||||
}
|
||||
{
|
||||
data = ssp_getreg(priv, LPC43_SSP_DR_OFFSET);
|
||||
if (rxbuffer && priv->nbits > 8)
|
||||
{
|
||||
*rx.p16++ = (uint16_t)data;
|
||||
}
|
||||
else
|
||||
{
|
||||
*rx.p8++ = (uint8_t)data;
|
||||
}
|
||||
|
||||
rxpending--;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -616,7 +639,8 @@ static void ssp_exchange(FAR struct spi_dev_s *dev, FAR const void *txbuffer,
|
||||
* nwords - the length of data to send from the buffer in number of words.
|
||||
* The wordsize is determined by the number of bits-per-word
|
||||
* selected for the SPI interface. If nbits <= 8, the data is
|
||||
* packed into uint8_t's; if nbits >8, the data is packed into uint16_t's
|
||||
* packed into uint8_t's; if nbits >8, the data is packed into
|
||||
* uint16_t's
|
||||
*
|
||||
* Returned Value:
|
||||
* None
|
||||
@@ -640,7 +664,8 @@ static void ssp_sndblock(FAR struct spi_dev_s *dev, FAR const void *buffer, size
|
||||
* nwords - the length of data that can be received in the buffer in number
|
||||
* of words. The wordsize is determined by the number of bits-per-word
|
||||
* selected for the SPI interface. If nbits <= 8, the data is
|
||||
* packed into uint8_t's; if nbits >8, the data is packed into uint16_t's
|
||||
* packed into uint8_t's; if nbits >8, the data is packed into
|
||||
* uint16_t's
|
||||
*
|
||||
* Returned Value:
|
||||
* None
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
Reference in New Issue
Block a user