Eliminate some warnings

This commit is contained in:
Gregory Nutt
2015-09-08 09:20:18 -06:00
parent 9cd1e34792
commit a7e43c7fdb
4 changed files with 121 additions and 94 deletions
+1 -1
Submodule arch updated: 2391024361...64609d18df
+1 -1
Submodule configs updated: 11b777b1b5...c706f1adc1
+56 -32
View File
@@ -300,11 +300,17 @@ struct cc1101_dev_s
uint8_t power; uint8_t power;
}; };
/****************************************************************************
* Private Data
****************************************************************************/
static volatile int cc1101_interrupt = 0;
/**************************************************************************** /****************************************************************************
* Private Functions * Private Functions
****************************************************************************/ ****************************************************************************/
void cc1101_access_begin(struct cc1101_dev_s * dev) void cc1101_access_begin(FAR struct cc1101_dev_s * dev)
{ {
(void)SPI_LOCK(dev->spi, true); (void)SPI_LOCK(dev->spi, true);
SPI_SELECT(dev->spi, SPIDEV_WIRELESS, true); SPI_SELECT(dev->spi, SPIDEV_WIRELESS, true);
@@ -312,24 +318,28 @@ void cc1101_access_begin(struct cc1101_dev_s * dev)
SPI_SETBITS(dev->spi, 8); SPI_SETBITS(dev->spi, 8);
} }
void cc1101_access_end(struct cc1101_dev_s * dev) void cc1101_access_end(FAR struct cc1101_dev_s * dev)
{ {
SPI_SELECT(dev->spi, SPIDEV_WIRELESS, false); SPI_SELECT(dev->spi, SPIDEV_WIRELESS, false);
(void)SPI_LOCK(dev->spi, false); (void)SPI_LOCK(dev->spi, false);
} }
/** CC1101 Access with Range Check /* CC1101 Access with Range Check
* *
* \param dev CC1101 Private Structure * Input Paramters:
* \param addr CC1101 Address * dev CC1101 Private Structure
* \param buf Pointer to buffer, either for read or write access * addr CC1101 Address
* \param length when >0 it denotes read access, when <0 it denotes write * buf Pointer to buffer, either for read or write access
* length when >0 it denotes read access, when <0 it denotes write
* access of -length. abs(length) greater of 1 implies burst mode, * access of -length. abs(length) greater of 1 implies burst mode,
* however * however
* \return OK on success or errno is set. *
* Returned Value:
* OK on success or errno is set.
*/ */
int cc1101_access(struct cc1101_dev_s * dev, uint8_t addr, uint8_t *buf, int length) int cc1101_access(FAR struct cc1101_dev_s * dev, uint8_t addr,
FAR uint8_t *buf, int length)
{ {
int stabyte; int stabyte;
@@ -339,31 +349,47 @@ int cc1101_access(struct cc1101_dev_s * dev, uint8_t addr, uint8_t *buf, int len
*/ */
if ((addr & CC1101_READ_SINGLE) && length != 1) if ((addr & CC1101_READ_SINGLE) && length != 1)
{
return ERROR; return ERROR;
}
/* Prepare SPI */ /* Prepare SPI */
cc1101_access_begin(dev); cc1101_access_begin(dev);
if (length>1 || length < -1) if (length>1 || length < -1)
{
SPI_SETFREQUENCY(dev->spi, CC1101_SPIFREQ_BURST); SPI_SETFREQUENCY(dev->spi, CC1101_SPIFREQ_BURST);
else SPI_SETFREQUENCY(dev->spi, CC1101_SPIFREQ_SINGLE); }
else
{
SPI_SETFREQUENCY(dev->spi, CC1101_SPIFREQ_SINGLE);
}
/* Transfer */ /* Transfer */
if (length <= 0) { /* 0 length are command strobes */ if (length <= 0)
{
/* 0 length are command strobes */
if (length < -1) if (length < -1)
{
addr |= CC1101_WRITE_BURST; addr |= CC1101_WRITE_BURST;
}
stabyte = SPI_SEND(dev->spi, addr); stabyte = SPI_SEND(dev->spi, addr);
if (length) { if (length)
{
SPI_SNDBLOCK(dev->spi, buf, -length); SPI_SNDBLOCK(dev->spi, buf, -length);
} }
} }
else { else
{
addr |= CC1101_READ_SINGLE; addr |= CC1101_READ_SINGLE;
if (length > 1) if (length > 1)
{
addr |= CC1101_READ_BURST; addr |= CC1101_READ_BURST;
}
stabyte = SPI_SEND(dev->spi, addr); stabyte = SPI_SEND(dev->spi, addr);
SPI_RECVBLOCK(dev->spi, buf, length); SPI_RECVBLOCK(dev->spi, buf, length);
@@ -374,13 +400,13 @@ int cc1101_access(struct cc1101_dev_s * dev, uint8_t addr, uint8_t *buf, int len
return stabyte; return stabyte;
} }
/* Strobes command and returns chip status byte
/** Strobes command and returns chip status byte
* *
* By default commands are send as Write. To a command, * By default commands are send as Write. To a command,
* CC1101_READ_SINGLE may be OR'ed to obtain the number of RX bytes * CC1101_READ_SINGLE may be OR'ed to obtain the number of RX bytes
* pending in RX FIFO. * pending in RX FIFO.
*/ */
inline uint8_t cc1101_strobe(struct cc1101_dev_s * dev, uint8_t command) inline uint8_t cc1101_strobe(struct cc1101_dev_s * dev, uint8_t command)
{ {
uint8_t status; uint8_t status;
@@ -395,41 +421,42 @@ inline uint8_t cc1101_strobe(struct cc1101_dev_s * dev, uint8_t command)
return status; return status;
} }
int cc1101_reset(struct cc1101_dev_s * dev) int cc1101_reset(struct cc1101_dev_s * dev)
{ {
cc1101_strobe(dev, CC1101_SRES); cc1101_strobe(dev, CC1101_SRES);
return OK; return OK;
} }
int cc1101_checkpart(struct cc1101_dev_s * dev) int cc1101_checkpart(struct cc1101_dev_s * dev)
{ {
uint8_t partnum, version; uint8_t partnum;
uint8_t version;
if (cc1101_access(dev, CC1101_PARTNUM, &partnum, 1) < 0 || if (cc1101_access(dev, CC1101_PARTNUM, &partnum, 1) < 0 ||
cc1101_access(dev, CC1101_VERSION, &version, 1) < 0) cc1101_access(dev, CC1101_VERSION, &version, 1) < 0)
{
return ERROR; return ERROR;
}
if (partnum == CC1101_PARTNUM_VALUE && version == CC1101_VERSION_VALUE) if (partnum == CC1101_PARTNUM_VALUE && version == CC1101_VERSION_VALUE)
{
return OK; return OK;
}
return ERROR; return ERROR;
} }
void cc1101_dumpregs(struct cc1101_dev_s * dev, uint8_t addr, uint8_t length) void cc1101_dumpregs(struct cc1101_dev_s * dev, uint8_t addr, uint8_t length)
{ {
uint8_t buf[0x30], i; uint8_t buf[0x30], i;
cc1101_access(dev, addr, buf, length); cc1101_access(dev, addr, FAR uint8_t *buf, length);
printf("CC1101[%2x]: ", addr); printf("CC1101[%2x]: ", addr);
for (i=0; i<length; i++) printf(" %2x,", buf[i]); for (i=0; i<length; i++) printf(" %2x,", buf[i]);
printf("\n"); printf("\n");
} }
void cc1101_setpacketctrl(struct cc1101_dev_s * dev) void cc1101_setpacketctrl(struct cc1101_dev_s * dev)
{ {
uint8_t values[3]; uint8_t values[3];
@@ -468,14 +495,11 @@ void cc1101_setpacketctrl(struct cc1101_dev_s * dev)
// WOREVT1:WOREVT0 - 16-bit timeout register // WOREVT1:WOREVT0 - 16-bit timeout register
} }
/**************************************************************************** /****************************************************************************
* Callbacks * Callbacks
****************************************************************************/ ****************************************************************************/
volatile int cc1101_interrupt = 0; /* External line triggers this callback
/** External line triggers this callback
* *
* The concept todo is: * The concept todo is:
* - GPIO provides EXTI Interrupt * - GPIO provides EXTI Interrupt
@@ -612,7 +636,7 @@ int cc1101_setgdo(struct cc1101_dev_s * dev, uint8_t pin, uint8_t function)
/* Force XOSC to stay active even in sleep mode */ /* Force XOSC to stay active even in sleep mode */
int value = CC1101_MCSM0_VALUE | CC1101_MCSM0_XOSC_FORCE_ON; int value = CC1101_MCSM0_VALUE | CC1101_MCSM0_XOSC_FORCE_ON;
cc1101_access(dev, CC1101_MCSM0, &value, -1); cc1101_access(dev, CC1101_MCSM0, (FAR uint8_t *)&value, -1);
dev->flags |= FLAGS_XOSCENABLED; dev->flags |= FLAGS_XOSCENABLED;
} }
@@ -621,7 +645,7 @@ int cc1101_setgdo(struct cc1101_dev_s * dev, uint8_t pin, uint8_t function)
/* Disable XOSC in sleep mode */ /* Disable XOSC in sleep mode */
int value = CC1101_MCSM0_VALUE; int value = CC1101_MCSM0_VALUE;
cc1101_access(dev, CC1101_MCSM0, &value, -1); cc1101_access(dev, CC1101_MCSM0, (FAR uint8_t *)&value, -1);
dev->flags &= ~FLAGS_XOSCENABLED; dev->flags &= ~FLAGS_XOSCENABLED;
} }
@@ -634,24 +658,24 @@ int cc1101_setrf(struct cc1101_dev_s * dev, const struct c1101_rfsettings_s *set
ASSERT(dev); ASSERT(dev);
ASSERT(settings); ASSERT(settings);
if (cc1101_access(dev, CC1101_FSCTRL1, &settings->FSCTRL1, -11) < 0) if (cc1101_access(dev, CC1101_FSCTRL1, (FAR uint8_t *)&settings->FSCTRL1, -11) < 0)
{ {
return ERROR; return ERROR;
} }
if (cc1101_access(dev, CC1101_FOCCFG, &settings->FOCCFG, -5) < 0) if (cc1101_access(dev, CC1101_FOCCFG, (FAR uint8_t *)&settings->FOCCFG, -5) < 0)
{ {
return ERROR; return ERROR;
} }
if (cc1101_access(dev, CC1101_FREND1, &settings->FREND1, -6) < 0) if (cc1101_access(dev, CC1101_FREND1, (FAR uint8_t *)&settings->FREND1, -6) < 0)
{ {
return ERROR; return ERROR;
} }
/* Load Power Table */ /* Load Power Table */
if (cc1101_access(dev, CC1101_PATABLE, settings->PA, -8) < 0) if (cc1101_access(dev, CC1101_PATABLE, (FAR uint8_t *)settings->PA, -8) < 0)
{ {
return ERROR; return ERROR;
} }
@@ -823,7 +847,7 @@ int cc1101_write(struct cc1101_dev_s * dev, const uint8_t * buf, size_t size)
} }
cc1101_access(dev, CC1101_TXFIFO, &packetlen, -1); cc1101_access(dev, CC1101_TXFIFO, &packetlen, -1);
cc1101_access(dev, CC1101_TXFIFO, buf, -size); cc1101_access(dev, CC1101_TXFIFO, (FAR uint8_t *)buf, -size);
return 0; return 0;
} }
+3
View File
@@ -46,6 +46,8 @@
#include <nuttx/net/iob.h> #include <nuttx/net/iob.h>
#ifdef CONFIG_NET_IOB
/**************************************************************************** /****************************************************************************
* Pre-processor Definitions * Pre-processor Definitions
****************************************************************************/ ****************************************************************************/
@@ -132,4 +134,5 @@ FAR struct iob_s *iob_tryalloc(bool throttled);
FAR struct iob_qentry_s *iob_free_qentry(FAR struct iob_qentry_s *iobq); FAR struct iob_qentry_s *iob_free_qentry(FAR struct iob_qentry_s *iobq);
#endif /* CONFIG_NET_IOB */
#endif /* __NET_IOB_IOB_H */ #endif /* __NET_IOB_IOB_H */