mirror of
https://github.com/apache/nuttx.git
synced 2026-06-02 17:48:54 +08:00
Many changes to reduce complaints from CppCheck. Several latent bugs fixes, but probably some new typos introduced
This commit is contained in:
@@ -6570,3 +6570,6 @@
|
||||
for the MIO283QT9A LCD. From Toby Duckworth (2014-2-10).
|
||||
* configs/mikroe-stm32f4/src/up_mio283qt9a.c: The Mikroe STM32F4 can
|
||||
now support the newer MIO283QT9A LCD. From Toby Duckworth (2014-2-10).
|
||||
* MANY files changes based on complaints from the tool CppCheck. Several
|
||||
latent bugs were fixed (and most likely some new typos were introducted)
|
||||
(2014-2-10).
|
||||
|
||||
@@ -228,7 +228,7 @@ void up_enable_irq(int irq)
|
||||
|
||||
void up_maskack_irq(int irq)
|
||||
{
|
||||
uint32_t reg = getreg32(INT_CTRL_REG);
|
||||
uint32_t reg;
|
||||
|
||||
/* Mask the interrupt */
|
||||
|
||||
|
||||
@@ -261,7 +261,7 @@ static ssize_t wdt_read(struct file *filep, char *buffer, size_t buflen)
|
||||
dbg("buflen=%d\n", buflen);
|
||||
if (buflen >= 18)
|
||||
{
|
||||
sprintf(buffer, "#08x %08x\n", c5471_wdt_cntl, c5471_wdt_count);
|
||||
sprintf(buffer, "%08x %08x\n", c5471_wdt_cntl, c5471_wdt_count);
|
||||
return 18;
|
||||
}
|
||||
return 0;
|
||||
|
||||
@@ -112,7 +112,6 @@ void up_allocate_heap(FAR void **heap_start, size_t *heap_size)
|
||||
|
||||
uintptr_t ubase = (uintptr_t)USERSPACE->us_bssend + CONFIG_MM_KERNEL_HEAPSIZE;
|
||||
size_t usize = CONFIG_RAM_END - ubase;
|
||||
int log2;
|
||||
|
||||
DEBUGASSERT(ubase < (uintptr_t)CONFIG_RAM_END);
|
||||
|
||||
@@ -151,9 +150,6 @@ void up_allocate_kheap(FAR void **heap_start, size_t *heap_size)
|
||||
*/
|
||||
|
||||
uintptr_t ubase = (uintptr_t)USERSPACE->us_bssend + CONFIG_MM_KERNEL_HEAPSIZE;
|
||||
size_t usize = CONFIG_RAM_END - ubase;
|
||||
int log2;
|
||||
|
||||
DEBUGASSERT(ubase < (uintptr_t)CONFIG_RAM_END);
|
||||
|
||||
/* Return the kernel heap settings (i.e., the part of the heap region
|
||||
|
||||
@@ -1254,7 +1254,7 @@ static int dm320_getcursor(FAR struct fb_vtable_s *vtable, FAR struct fb_cursora
|
||||
attrib->size.w = getreg16(DM320_OSD_CURXL);
|
||||
attrib->size.h = getreg16(DM320_OSD_CURYL);
|
||||
#endif
|
||||
irqrestore();
|
||||
irqrestore(flags);
|
||||
|
||||
attrib->mxsize.w = MAX_XRES;
|
||||
attrib->mxsize.h = MAX_YRES;
|
||||
@@ -1325,10 +1325,8 @@ static int dm320_setcursor(FAR struct fb_vtable_s *vtable, FAR struct fb_setcurs
|
||||
settings->size.h = MAX_YRES;
|
||||
}
|
||||
|
||||
flags = irqsave();
|
||||
putreg16(settings->size.w, DM320_OSD_CURXL);
|
||||
putreg16(settings->size.h, DM320_OSD_CURYL);
|
||||
restore_flags(flags);
|
||||
}
|
||||
#endif
|
||||
|
||||
@@ -1342,7 +1340,7 @@ static int dm320_setcursor(FAR struct fb_vtable_s *vtable, FAR struct fb_setcurs
|
||||
regval &= ~1;
|
||||
}
|
||||
putreg16(regval, DM320_OSD_RECTCUR);
|
||||
restore_flags(flags);
|
||||
irqrestore(flags);
|
||||
|
||||
gvdbg("DM320_OSD_CURXP: %04x\n", getreg16(DM320_OSD_CURXP));
|
||||
gvdbg("DM320_OSD_CURYP: %04x\n", getreg16(DM320_OSD_CURYP));
|
||||
|
||||
@@ -1761,7 +1761,7 @@ static inline void dm320_epinitialize(struct dm320_usbdev_s *priv)
|
||||
|
||||
/* FIFO address, max packet size, dual/single buffered */
|
||||
|
||||
dm320_putreg8(addrhi, DM320_USB_TXFIFO1);
|
||||
dm320_putreg8(addrlo, DM320_USB_TXFIFO1);
|
||||
dm320_putreg8(addrhi|g_epinfo[i].fifo, DM320_USB_TXFIFO2);
|
||||
|
||||
/* TX endpoint max packet size */
|
||||
|
||||
@@ -879,8 +879,10 @@ static int up_interrupt(int irq, void *context)
|
||||
|
||||
static int up_ioctl(struct file *filep, int cmd, unsigned long arg)
|
||||
{
|
||||
#ifdef CONFIG_SERIAL_TIOCSERGSTRUCT
|
||||
struct inode *inode = filep->f_inode;
|
||||
struct uart_dev_s *dev = inode->i_private;
|
||||
#endif
|
||||
int ret = OK;
|
||||
|
||||
switch (cmd)
|
||||
|
||||
@@ -500,10 +500,10 @@ static int spi_transfer(struct imx_spidev_s *priv, const void *txbuffer,
|
||||
{
|
||||
#ifndef CONFIG_SPI_POLLWAIT
|
||||
irqstate_t flags;
|
||||
#endif
|
||||
uint32_t regval;
|
||||
int ntxd;
|
||||
int ret;
|
||||
#endif
|
||||
int ntxd;
|
||||
|
||||
/* Set up to perform the transfer */
|
||||
|
||||
|
||||
@@ -709,7 +709,7 @@ static void up_rxint(struct uart_dev_s *dev, bool enable)
|
||||
}
|
||||
else
|
||||
{
|
||||
priv->ie |= UART_C2_RIE;
|
||||
priv->ie &= ~UART_C2_RIE;
|
||||
up_setuartint(priv);
|
||||
}
|
||||
|
||||
|
||||
@@ -100,7 +100,9 @@ extern void _vectors(void);
|
||||
|
||||
void __start(void)
|
||||
{
|
||||
#ifdef CONFIG_BOOT_RUNFROMFLASH
|
||||
const uint32_t *src;
|
||||
#endif
|
||||
uint32_t *dest;
|
||||
|
||||
/* Configure the uart so that we can get debug output as soon as possible */
|
||||
|
||||
@@ -111,6 +111,7 @@ static struct lpc31_i2cdev_s i2cdevices[2];
|
||||
/****************************************************************************
|
||||
* Private Functions
|
||||
****************************************************************************/
|
||||
|
||||
static int i2c_interrupt(int irq, FAR void *context);
|
||||
static void i2c_progress(struct lpc31_i2cdev_s *priv);
|
||||
static void i2c_timeout(int argc, uint32_t arg, ...);
|
||||
@@ -130,7 +131,8 @@ static int i2c_write(FAR struct i2c_dev_s *dev, const uint8_t *buffer, int
|
||||
static int i2c_read(FAR struct i2c_dev_s *dev, uint8_t *buffer, int buflen);
|
||||
static int i2c_transfer(FAR struct i2c_dev_s *dev, FAR struct i2c_msg_s *msgs, int count);
|
||||
|
||||
struct i2c_ops_s lpc31_i2c_ops = {
|
||||
struct i2c_ops_s lpc31_i2c_ops =
|
||||
{
|
||||
.setfrequency = i2c_setfrequency,
|
||||
.setaddress = i2c_setaddress,
|
||||
.write = i2c_write,
|
||||
@@ -233,17 +235,20 @@ static uint32_t i2c_setfrequency(FAR struct i2c_dev_s *dev, uint32_t frequency)
|
||||
if (freq > 100000)
|
||||
{
|
||||
/* asymetric per 400Khz I2C spec */
|
||||
|
||||
putreg32(((47 * freq) / (83 + 47)) / frequency, priv->base + LPC31_I2C_CLKHI_OFFSET);
|
||||
putreg32(((83 * freq) / (83 + 47)) / frequency, priv->base + LPC31_I2C_CLKLO_OFFSET);
|
||||
}
|
||||
else
|
||||
{
|
||||
/* 50/50 mark space ratio */
|
||||
|
||||
putreg32(((50 * freq) / 100) / frequency, priv->base + LPC31_I2C_CLKLO_OFFSET);
|
||||
putreg32(((50 * freq) / 100) / frequency, priv->base + LPC31_I2C_CLKHI_OFFSET);
|
||||
}
|
||||
|
||||
/* FIXME: This function should return the actual selected frequency */
|
||||
|
||||
return frequency;
|
||||
}
|
||||
|
||||
@@ -254,6 +259,7 @@ static uint32_t i2c_setfrequency(FAR struct i2c_dev_s *dev, uint32_t frequency)
|
||||
* Set the I2C slave address for a subsequent read/write
|
||||
*
|
||||
*******************************************************************************/
|
||||
|
||||
static int i2c_setaddress(FAR struct i2c_dev_s *dev, int addr, int nbits)
|
||||
{
|
||||
struct lpc31_i2cdev_s *priv = (struct lpc31_i2cdev_s *) dev;
|
||||
@@ -275,6 +281,7 @@ static int i2c_setaddress(FAR struct i2c_dev_s *dev, int addr, int nbits)
|
||||
* frequency and slave address.
|
||||
*
|
||||
*******************************************************************************/
|
||||
|
||||
static int i2c_write(FAR struct i2c_dev_s *dev, const uint8_t *buffer, int buflen)
|
||||
{
|
||||
struct lpc31_i2cdev_s *priv = (struct lpc31_i2cdev_s *) dev;
|
||||
@@ -299,6 +306,7 @@ static int i2c_write(FAR struct i2c_dev_s *dev, const uint8_t *buffer, int bufle
|
||||
* frequency and slave address.
|
||||
*
|
||||
*******************************************************************************/
|
||||
|
||||
static int i2c_read(FAR struct i2c_dev_s *dev, uint8_t *buffer, int buflen)
|
||||
{
|
||||
struct lpc31_i2cdev_s *priv = (struct lpc31_i2cdev_s *) dev;
|
||||
@@ -339,7 +347,9 @@ static int i2c_transfer (FAR struct i2c_dev_s *dev, FAR struct i2c_msg_s *msgs,
|
||||
i2c_progress(priv);
|
||||
|
||||
/* start a watchdog to timeout the transfer if
|
||||
* the bus is locked up... */
|
||||
* the bus is locked up...
|
||||
*/
|
||||
|
||||
wd_start(priv->timeout, I2C_TIMEOUT, i2c_timeout, 1, (uint32_t)priv);
|
||||
|
||||
while (priv->state != I2C_STATE_DONE)
|
||||
@@ -396,9 +406,11 @@ static void i2c_progress (struct lpc31_i2cdev_s *priv)
|
||||
stat = getreg32(priv->base + LPC31_I2C_STAT_OFFSET);
|
||||
|
||||
/* Were there arbitration problems? */
|
||||
|
||||
if ((stat & I2C_STAT_AFI) != 0)
|
||||
{
|
||||
/* Perform a soft reset */
|
||||
|
||||
i2c_reset(priv);
|
||||
|
||||
/* FIXME: automatic retry? */
|
||||
@@ -451,6 +463,7 @@ static void i2c_progress (struct lpc31_i2cdev_s *priv)
|
||||
if (priv->wrcnt < priv->hdrcnt)
|
||||
{
|
||||
/* Enable Tx FIFO Not Full Interrupt */
|
||||
|
||||
putreg32(ctrl | I2C_CTRL_TFFIE, priv->base + LPC31_I2C_CTRL_OFFSET);
|
||||
goto out;
|
||||
}
|
||||
@@ -474,12 +487,18 @@ static void i2c_progress (struct lpc31_i2cdev_s *priv)
|
||||
if (priv->rdcnt < msg->length)
|
||||
{
|
||||
/* Not all data received, fill the Tx FIFO with more dummies */
|
||||
|
||||
while ((priv->wrcnt != msg->length) && (stat & I2C_STAT_TFF) == 0)
|
||||
{
|
||||
if ((priv->wrcnt + 1) == msg->length && priv->nmsg == 1)
|
||||
{
|
||||
putreg32(I2C_TX_STOP, priv->base + LPC31_I2C_TX_OFFSET);
|
||||
}
|
||||
else
|
||||
{
|
||||
putreg32(0, priv->base + LPC31_I2C_TX_OFFSET);
|
||||
}
|
||||
|
||||
priv->wrcnt++;
|
||||
|
||||
stat = getreg32(priv->base + LPC31_I2C_STAT_OFFSET);
|
||||
@@ -488,11 +507,13 @@ static void i2c_progress (struct lpc31_i2cdev_s *priv)
|
||||
if (priv->wrcnt < msg->length)
|
||||
{
|
||||
/* Enable Tx FIFO not full and Rx Fifo Avail Interrupts */
|
||||
|
||||
putreg32(ctrl | I2C_CTRL_TFFIE | I2C_CTRL_RFDAIE, priv->base + LPC31_I2C_CTRL_OFFSET);
|
||||
}
|
||||
else
|
||||
{
|
||||
/* Enable Rx Fifo Avail Interrupts */
|
||||
|
||||
putreg32(ctrl | I2C_CTRL_RFDAIE, priv->base + LPC31_I2C_CTRL_OFFSET);
|
||||
}
|
||||
goto out;
|
||||
@@ -503,9 +524,13 @@ static void i2c_progress (struct lpc31_i2cdev_s *priv)
|
||||
while ((priv->wrcnt != msg->length) && (stat & I2C_STAT_TFF) == 0)
|
||||
{
|
||||
if ((priv->wrcnt + 1) == msg->length && priv->nmsg == 1)
|
||||
{
|
||||
putreg32(I2C_TX_STOP | msg->buffer[priv->wrcnt], priv->base + LPC31_I2C_TX_OFFSET);
|
||||
}
|
||||
else
|
||||
{
|
||||
putreg32(msg->buffer[priv->wrcnt], priv->base + LPC31_I2C_TX_OFFSET);
|
||||
}
|
||||
|
||||
priv->wrcnt++;
|
||||
|
||||
@@ -515,20 +540,24 @@ static void i2c_progress (struct lpc31_i2cdev_s *priv)
|
||||
if (priv->wrcnt < msg->length)
|
||||
{
|
||||
/* Enable Tx Fifo not full Interrupt */
|
||||
|
||||
putreg32(ctrl | I2C_CTRL_TFFIE, priv->base + LPC31_I2C_CTRL_OFFSET);
|
||||
goto out;
|
||||
}
|
||||
}
|
||||
|
||||
/* Transfer completed, move onto the next one */
|
||||
|
||||
priv->state = I2C_STATE_START;
|
||||
|
||||
if (--priv->nmsg == 0)
|
||||
{
|
||||
/* Final transfer, wait for Transmit Done Interrupt */
|
||||
|
||||
putreg32(ctrl, priv->base + LPC31_I2C_CTRL_OFFSET);
|
||||
goto out;
|
||||
}
|
||||
|
||||
priv->msgs++;
|
||||
break;
|
||||
}
|
||||
@@ -542,11 +571,16 @@ out:
|
||||
/* You'd expect the NAI bit to be set when no acknowledge was
|
||||
* received - but it gets cleared whenever a write it done to
|
||||
* the TXFIFO - so we've gone and cleared it while priming the
|
||||
* rest of the transfer! */
|
||||
* rest of the transfer!
|
||||
*/
|
||||
|
||||
if ((stat = getreg32(priv->base + LPC31_I2C_TXFL_OFFSET)) != 0)
|
||||
{
|
||||
if (priv->nmsg == 0)
|
||||
{
|
||||
priv->nmsg++;
|
||||
}
|
||||
|
||||
i2c_reset(priv);
|
||||
}
|
||||
|
||||
@@ -572,18 +606,23 @@ static void i2c_timeout (int argc, uint32_t arg, ...)
|
||||
if (priv->state != I2C_STATE_DONE)
|
||||
{
|
||||
/* If there's data remaining in the TXFIFO, then ensure at least
|
||||
* one transfer has failed to complete.. */
|
||||
* one transfer has failed to complete.
|
||||
*/
|
||||
|
||||
if (getreg32(priv->base + LPC31_I2C_TXFL_OFFSET) != 0)
|
||||
{
|
||||
if (priv->nmsg == 0)
|
||||
{
|
||||
priv->nmsg++;
|
||||
}
|
||||
}
|
||||
|
||||
/* Soft reset the USB controller */
|
||||
|
||||
i2c_reset(priv);
|
||||
|
||||
/* Mark the transfer as finished */
|
||||
|
||||
priv->state = I2C_STATE_DONE;
|
||||
sem_post(&priv->wait);
|
||||
}
|
||||
@@ -603,6 +642,7 @@ static void i2c_reset (struct lpc31_i2cdev_s *priv)
|
||||
putreg32(I2C_CTRL_RESET, priv->base + LPC31_I2C_CTRL_OFFSET);
|
||||
|
||||
/* Wait for Reset to complete */
|
||||
|
||||
while ((getreg32(priv->base + LPC31_I2C_CTRL_OFFSET) & I2C_CTRL_RESET) != 0)
|
||||
;
|
||||
}
|
||||
|
||||
@@ -214,7 +214,7 @@ static inline int sam_configinterrupt(uintptr_t base, uint32_t pin,
|
||||
* 11 Reserved
|
||||
*/
|
||||
|
||||
gpio_pinset_t edges = cfgset & GPIO_INT_MASK;
|
||||
gpio_pinset_t edges = (cfgset & GPIO_INT_MASK);
|
||||
|
||||
if (edges == GPIO_INT_RISING)
|
||||
{
|
||||
@@ -398,16 +398,16 @@ static inline int sam_configperiph(uintptr_t base, uint32_t pin,
|
||||
* 11 Reserved
|
||||
*/
|
||||
|
||||
edges = cfgset & GPIO_INT_MASK;
|
||||
edges = (cfgset & GPIO_INT_MASK);
|
||||
if (edges == GPIO_INT_RISING)
|
||||
{
|
||||
/* Rising only.. disable interrrupts on the falling edge */
|
||||
/* Rising only.. disable interrupts on the falling edge */
|
||||
|
||||
putreg32(pin, base + SAM_GPIO_IMR0S_OFFSET);
|
||||
}
|
||||
else if (edges == GPIO_INT_FALLING)
|
||||
{
|
||||
/* Falling only.. disable interrrupts on the rising edge */
|
||||
/* Falling only.. disable interrupts on the rising edge */
|
||||
|
||||
putreg32(pin, base + SAM_GPIO_IMR1S_OFFSET);
|
||||
}
|
||||
|
||||
@@ -109,12 +109,10 @@ int stm32_dumpgpio(uint32_t pinset, const char *msg)
|
||||
irqstate_t flags;
|
||||
uint32_t base;
|
||||
unsigned int port;
|
||||
unsigned int pin;
|
||||
|
||||
/* Get the base address associated with the GPIO port */
|
||||
|
||||
port = (pinset & GPIO_PORT_MASK) >> GPIO_PORT_SHIFT;
|
||||
pin = (pinset & GPIO_PIN_MASK) >> GPIO_PIN_SHIFT;
|
||||
base = g_gpiobase[port];
|
||||
|
||||
/* The following requires exclusive access to the GPIO registers */
|
||||
|
||||
@@ -753,8 +753,10 @@ static int up_interrupt(int irq, void *context)
|
||||
|
||||
static int up_ioctl(struct file *filep, int cmd, unsigned long arg)
|
||||
{
|
||||
#ifdef CONFIG_SERIAL_TIOCSERGSTRUCT
|
||||
struct inode *inode = filep->f_inode;
|
||||
struct uart_dev_s *dev = inode->i_private;
|
||||
#endif
|
||||
int ret = OK;
|
||||
|
||||
switch (cmd)
|
||||
|
||||
@@ -82,7 +82,10 @@ size_t up_check_tcbstack(FAR struct tcb_s *tcb)
|
||||
{
|
||||
FAR uint8_t *ptr;
|
||||
size_t mark;
|
||||
int i, j;
|
||||
#if 0
|
||||
int i;
|
||||
int j;
|
||||
#endif
|
||||
|
||||
/* The AVR uses a push-down stack: the stack grows toward lower addresses
|
||||
* in memory. We need to start at the lowest address in the stack memory
|
||||
@@ -121,8 +124,10 @@ size_t up_check_tcbstack(FAR struct tcb_s *tcb)
|
||||
{
|
||||
ch = 'X';
|
||||
}
|
||||
|
||||
up_putc(ch);
|
||||
}
|
||||
|
||||
up_putc('\n');
|
||||
}
|
||||
}
|
||||
|
||||
@@ -291,7 +291,7 @@ static void emac_receive(FAR struct emac_driver_s *priv)
|
||||
}
|
||||
}
|
||||
}
|
||||
while (); /* While there are more packets to be processed */
|
||||
while (true); /* While there are more packets to be processed */
|
||||
}
|
||||
|
||||
/****************************************************************************
|
||||
|
||||
@@ -534,7 +534,7 @@ static int up_poll(FAR struct file *filep, FAR struct pollfd *fds,
|
||||
{
|
||||
FAR struct inode *inode;
|
||||
FAR struct up_dev_s *priv;
|
||||
int ret = OK;
|
||||
int ret;
|
||||
int i;
|
||||
|
||||
ivdbg("setup: %d\n", (int)setup);
|
||||
|
||||
@@ -302,7 +302,6 @@ static uint8_t z16f_disableuartirq(struct uart_dev_s *dev)
|
||||
|
||||
static void z16f_restoreuartirq(struct uart_dev_s *dev, uint8_t state)
|
||||
{
|
||||
struct z16f_uart_s *priv = (struct z16f_uart_s*)dev->priv;
|
||||
irqstate_t flags = irqsave();
|
||||
|
||||
z16f_txint(dev, (state & STATE_TXENABLED) ? true : false);
|
||||
@@ -400,7 +399,6 @@ static int z16f_setup(struct uart_dev_s *dev)
|
||||
|
||||
static void z16f_shutdown(struct uart_dev_s *dev)
|
||||
{
|
||||
struct z16f_uart_s *priv = (struct z16f_uart_s*)dev->priv;
|
||||
(void)z16f_disableuartirq(dev);
|
||||
}
|
||||
|
||||
|
||||
@@ -393,7 +393,6 @@ static void i2c_stop(void)
|
||||
static int i2c_sendaddr(struct ez80_i2cdev_s *priv, uint8_t readbit)
|
||||
{
|
||||
uint8_t sr;
|
||||
int ret = OK;
|
||||
|
||||
/* Wait for the IFLG bit to transition to 1. At this point, we should
|
||||
* have status == 8 meaning that the start bit was sent successfully.
|
||||
|
||||
@@ -284,7 +284,7 @@ static uint8_t spi_waitspif(void)
|
||||
* Name: spi_transfer
|
||||
*
|
||||
* Description:
|
||||
* Send one byte on SPI, return th response
|
||||
* Send one byte on SPI, return the response
|
||||
*
|
||||
* Input Parameters:
|
||||
* ch - the byte to send
|
||||
@@ -361,7 +361,7 @@ static void spi_sndblock(FAR struct spi_dev_s *dev, FAR const void *buffer,
|
||||
FAR const uint8_t *ptr = (FAR const uint8_t*)buffer;
|
||||
uint8_t response;
|
||||
|
||||
/* Loop while thre are bytes remaining to be sent */
|
||||
/* Loop while there are bytes remaining to be sent */
|
||||
|
||||
while (buflen-- > 0)
|
||||
{
|
||||
@@ -392,7 +392,6 @@ static void spi_sndblock(FAR struct spi_dev_s *dev, FAR const void *buffer,
|
||||
static void spi_recvblock(FAR struct spi_dev_s *dev, FAR void *buffer, size_t buflen)
|
||||
{
|
||||
FAR uint8_t *ptr = (FAR uint8_t*)buffer;
|
||||
uint8_t response;
|
||||
|
||||
/* Loop while thre are bytes remaining to be sent */
|
||||
|
||||
|
||||
@@ -438,7 +438,6 @@ int up_addrenv_destroy(task_addrenv_t addrenv)
|
||||
int up_addrenv_assign(task_addrenv_t addrenv, FAR struct tcb_s *tcb)
|
||||
{
|
||||
FAR struct z180_cbr_s *cbr = (FAR struct z180_cbr_s *)addrenv;
|
||||
int ret;
|
||||
|
||||
/* Make sure that there is no address environment in place on this TCB */
|
||||
|
||||
|
||||
@@ -284,7 +284,6 @@ static uint8_t z8_disableuartirq(FAR struct uart_dev_s *dev)
|
||||
|
||||
static void z8_restoreuartirq(FAR struct uart_dev_s *dev, uint8_t state)
|
||||
{
|
||||
struct z8_uart_s *priv = (struct z8_uart_s*)dev->priv;
|
||||
irqstate_t flags = irqsave();
|
||||
|
||||
z8_txint(dev, (state & STATE_TXENABLED) ? true : false);
|
||||
@@ -322,7 +321,6 @@ static void z8_consoleput(uint8_t ch)
|
||||
|
||||
void z8_uartconfigure(void)
|
||||
{
|
||||
uint16_t brg;
|
||||
uint8_t val;
|
||||
|
||||
/* Configure GPIO Port A pins 4 & 5 for alternate function */
|
||||
@@ -421,7 +419,6 @@ static int z8_setup(FAR struct uart_dev_s *dev)
|
||||
|
||||
static void z8_shutdown(FAR struct uart_dev_s *dev)
|
||||
{
|
||||
struct z8_uart_s *priv = (struct z8_uart_s*)dev->priv;
|
||||
(void)z8_disableuartirq(dev);
|
||||
}
|
||||
|
||||
|
||||
@@ -124,12 +124,13 @@ static inline int elf_sectname(FAR struct elf_loadinfo_s *loadinfo,
|
||||
readlen = loadinfo->buflen - bytesread;
|
||||
if (offset + readlen > loadinfo->filelen)
|
||||
{
|
||||
readlen = loadinfo->filelen - offset;
|
||||
if (readlen <= 0)
|
||||
if (loadinfo->filelen <= offset)
|
||||
{
|
||||
bdbg("At end of file\n");
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
readlen = loadinfo->filelen - offset;
|
||||
}
|
||||
|
||||
/* Read that number of bytes into the array */
|
||||
|
||||
@@ -110,12 +110,13 @@ static int elf_symname(FAR struct elf_loadinfo_s *loadinfo,
|
||||
readlen = loadinfo->buflen - bytesread;
|
||||
if (offset + readlen > loadinfo->filelen)
|
||||
{
|
||||
readlen = loadinfo->filelen - offset;
|
||||
if (readlen <= 0)
|
||||
if (loadinfo->filelen <= offset)
|
||||
{
|
||||
bdbg("At end of file\n");
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
readlen = loadinfo->filelen - offset;
|
||||
}
|
||||
|
||||
/* Read that number of bytes into the array */
|
||||
|
||||
@@ -97,7 +97,6 @@ int nxflat_init(const char *filename, struct nxflat_loadinfo_s *loadinfo)
|
||||
{
|
||||
uint32_t datastart;
|
||||
uint32_t dataend;
|
||||
uint32_t bssstart;
|
||||
uint32_t bssend;
|
||||
int ret;
|
||||
|
||||
@@ -152,7 +151,6 @@ int nxflat_init(const char *filename, struct nxflat_loadinfo_s *loadinfo)
|
||||
|
||||
datastart = ntohl(loadinfo->header.h_datastart);
|
||||
dataend = ntohl(loadinfo->header.h_dataend);
|
||||
bssstart = dataend;
|
||||
bssend = ntohl(loadinfo->header.h_bssend);
|
||||
|
||||
/* And put this information into the loadinfo structure as well.
|
||||
|
||||
@@ -103,7 +103,7 @@ static int nsh_spifi_initialize(void)
|
||||
return ret;
|
||||
}
|
||||
#else
|
||||
/* Initialize to provide NXFFS on the MTD interface */1G
|
||||
/* Initialize to provide NXFFS on the MTD interface */
|
||||
|
||||
ret = nxffs_initialize(mtd);
|
||||
if (ret < 0)
|
||||
|
||||
@@ -109,7 +109,7 @@ void stm32_board_clockconfig(void)
|
||||
regval |= STM32_RCC_CFGR_PPRE1;
|
||||
putreg32(regval, STM32_RCC_CFGR);
|
||||
|
||||
/* Set the PLL dividers and multiplers to configure the main PLL */
|
||||
/* Set the PLL dividers and multipliers to configure the main PLL */
|
||||
|
||||
regval = (STM32_PLLCFG_PLLM | STM32_PLLCFG_PLLN |STM32_PLLCFG_PLLP |
|
||||
RCC_PLLCFG_PLLSRC_HSI | STM32_PLLCFG_PLLQ);
|
||||
|
||||
@@ -181,9 +181,6 @@
|
||||
|
||||
int nsh_archinitialize(void)
|
||||
{
|
||||
#if defined(HAVE_USBHOST) || defined(HAVE_USBMONITOR)
|
||||
int ret;
|
||||
#endif
|
||||
#ifdef CONFIG_STM32_SPI3
|
||||
FAR struct spi_dev_s *spi;
|
||||
FAR struct mtd_dev_s *mtd;
|
||||
|
||||
@@ -125,11 +125,10 @@
|
||||
|
||||
int nsh_archinitialize(void)
|
||||
{
|
||||
#ifdef NSH_HAVEMMCSD
|
||||
FAR struct spi_dev_s *spi;
|
||||
int ret;
|
||||
|
||||
#ifdef NSH_HAVEMMCSD
|
||||
|
||||
/* Get the SPI port */
|
||||
|
||||
message("nsh_archinitialize: Initializing SPI port %d\n",
|
||||
|
||||
@@ -1365,9 +1365,6 @@ int arch_tcinitialize(int minor)
|
||||
{
|
||||
FAR struct tc_dev_s *priv;
|
||||
char devname[DEV_NAMELEN];
|
||||
#ifdef CONFIG_TOUCHSCREEN_MULTIPLE
|
||||
irqstate_t flags;
|
||||
#endif
|
||||
int ret;
|
||||
|
||||
ivdbg("minor: %d\n", minor);
|
||||
|
||||
@@ -195,7 +195,9 @@ void stm32_boardinitialize(void)
|
||||
|
||||
int nsh_archinitialize(void)
|
||||
{
|
||||
#ifdef CONFIG_MMCSD
|
||||
int ret;
|
||||
#endif
|
||||
|
||||
/* Configure ADC pins */
|
||||
|
||||
|
||||
@@ -147,6 +147,7 @@ xcpt_t board_button_irq(int id, xcpt_t irqhandler)
|
||||
sam_gpioirq(IRQ_SW0);
|
||||
(void)irq_attach(IRQ_SW0, irqhandler);
|
||||
sam_gpioirqenable(IRQ_SW0);
|
||||
irqrestore(flags);
|
||||
}
|
||||
|
||||
/* Return the old button handler (so that it can be restored) */
|
||||
|
||||
@@ -145,6 +145,7 @@ xcpt_t board_button_irq(int id, xcpt_t irqhandler)
|
||||
sam_gpioirq(IRQ_BP2);
|
||||
(void)irq_attach(IRQ_BP2, irqhandler);
|
||||
sam_gpioirqenable(IRQ_BP2);
|
||||
irqrestore(flags);
|
||||
}
|
||||
|
||||
/* Return the old button handler (so that it can be restored) */
|
||||
|
||||
@@ -116,6 +116,7 @@ static inline void up_setrs(bool data)
|
||||
{
|
||||
regval &= ~(1 << 0); /* Low = control */
|
||||
}
|
||||
|
||||
putreg8(regval, M16C_P6);
|
||||
}
|
||||
|
||||
@@ -128,7 +129,7 @@ static inline void up_seten(void)
|
||||
/* Set bit 1 of port 6 */
|
||||
|
||||
register uint8_t regval = getreg8(M16C_P6);
|
||||
regval = (1 << 1);
|
||||
regval |= (1 << 1);
|
||||
putreg8(regval, M16C_P6);
|
||||
}
|
||||
|
||||
|
||||
@@ -82,13 +82,11 @@
|
||||
|
||||
int nsh_archinitialize(void)
|
||||
{
|
||||
int ret = OK;
|
||||
|
||||
#ifdef CONFIG_STM32_LCD
|
||||
/* Initialize the SLCD and register the SLCD device as /dev/slcd */
|
||||
|
||||
#ifdef CONFIG_STM32_LCD
|
||||
ret = stm32_slcd_initialize();
|
||||
return stm32_slcd_initialize();
|
||||
#else
|
||||
return OK;
|
||||
#endif
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
@@ -135,7 +135,7 @@ uint8_t board_buttons(void)
|
||||
#ifdef CONFIG_ARCH_IRQBUTTONS
|
||||
xcpt_t board_button_irq(int id, xcpt_t irqhandler)
|
||||
{
|
||||
xcpt_t oldhandler = NULL;
|
||||
xcpt_t oldhandler;
|
||||
uint32_t pinset;
|
||||
|
||||
/* Map the button id to the GPIO bit set. */
|
||||
|
||||
@@ -110,6 +110,7 @@ static void putconsole(char ch)
|
||||
{
|
||||
(void)putc(ch, g_logstream);
|
||||
}
|
||||
|
||||
(void)putchar(ch);
|
||||
}
|
||||
|
||||
@@ -139,6 +140,7 @@ static void printconsole(const char *fmt, ...)
|
||||
{
|
||||
(void)vfprintf(g_logstream, fmt, ap);
|
||||
}
|
||||
|
||||
(void)vprintf(fmt, ap);
|
||||
va_end(ap);
|
||||
}
|
||||
@@ -435,7 +437,7 @@ static void close_tty(void)
|
||||
(void)close(g_fd);
|
||||
}
|
||||
|
||||
if (g_logstream >= 0)
|
||||
if (g_logstream)
|
||||
{
|
||||
(void)fclose(g_logstream);
|
||||
}
|
||||
@@ -717,7 +719,7 @@ int main(int argc, char **argv, char **envp)
|
||||
{
|
||||
sendfile(g_fd, filename, 0);
|
||||
}
|
||||
else if (ch1 == 'v' || ch1 == 'v')
|
||||
else if (ch1 == 'v' || ch1 == 'V')
|
||||
{
|
||||
sendfile(g_fd, filename, 1);
|
||||
}
|
||||
|
||||
@@ -364,7 +364,7 @@ static int adc_ioctl(FAR struct file *filep, int cmd, unsigned long arg)
|
||||
{
|
||||
FAR struct inode *inode = filep->f_inode;
|
||||
FAR struct adc_dev_s *dev = inode->i_private;
|
||||
int ret = OK;
|
||||
int ret;
|
||||
|
||||
ret = dev->ad_ops->ao_ioctl(dev, cmd, arg);
|
||||
return ret;
|
||||
|
||||
@@ -175,11 +175,15 @@ static uint8_t getspsreg(uint16_t sps)
|
||||
0x03,0x13,0x23,0x33,0x43,0x53,0x63,0x72,0x82,0x92,0xa1,0xb0,0xc0,0xd0,0xe0,0xf0,
|
||||
};
|
||||
int i;
|
||||
|
||||
for (i=0; i<16; i++)
|
||||
{
|
||||
if (sps<sps_tab[i])
|
||||
{
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
return sps_reg[i];
|
||||
}
|
||||
|
||||
@@ -200,8 +204,8 @@ static void adc_reset(FAR struct adc_dev_s *dev)
|
||||
SPI_SETFREQUENCY(spi, CONFIG_ADS1255_FREQUENCY);
|
||||
usleep(1000);
|
||||
SPI_SELECT(spi, priv->devno, true);
|
||||
SPI_SEND(spi,ADS125X_WREG+0x03); //WRITE SPS REG
|
||||
SPI_SEND(spi,0x00); //count=1
|
||||
SPI_SEND(spi,ADS125X_WREG+0x03); /* WRITE SPS REG */
|
||||
SPI_SEND(spi,0x00); /* count=1 */
|
||||
SPI_SEND(spi,0x63);
|
||||
SPI_SELECT(spi, priv->devno, false);
|
||||
}
|
||||
@@ -217,23 +221,30 @@ static int adc_setup(FAR struct adc_dev_s *dev)
|
||||
FAR struct up_dev_s *priv = (FAR struct up_dev_s *)dev->ad_priv;
|
||||
FAR struct spi_dev_s *spi = priv->spi;
|
||||
int ret = irq_attach(priv->irq, adc_interrupt);
|
||||
|
||||
if (ret == OK)
|
||||
{
|
||||
SPI_SELECT(spi, priv->devno, true);
|
||||
SPI_SEND(spi,ADS125X_WREG); //WRITE REG from 0
|
||||
SPI_SEND(spi,0x03); //count=4+1
|
||||
SPI_SEND(spi,ADS125X_WREG); /* WRITE REG from 0 */
|
||||
SPI_SEND(spi,0x03); /* count=4+1 */
|
||||
if (priv->buf)
|
||||
SPI_SEND(spi,ADS125X_BUFON); //REG0 STATUS BUFFER ON
|
||||
{
|
||||
SPI_SEND(spi,ADS125X_BUFON); /* REG0 STATUS BUFFER ON */
|
||||
}
|
||||
else
|
||||
{
|
||||
SPI_SEND(spi,ADS125X_BUFOFF);
|
||||
}
|
||||
|
||||
SPI_SEND(spi,priv->mux[0]);
|
||||
SPI_SEND(spi,priv->pga); //REG2 ADCON PGA=2
|
||||
SPI_SEND(spi,priv->pga); /* REG2 ADCON PGA=2 */
|
||||
SPI_SEND(spi,getspsreg(priv->sps));
|
||||
usleep(1000);
|
||||
SPI_SEND(spi,ADS125X_SELFCAL);
|
||||
SPI_SELECT(spi, priv->devno, false);
|
||||
up_enable_irq(priv->irq);
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
@@ -254,10 +265,14 @@ static void adc_rxint(FAR struct adc_dev_s *dev, bool enable)
|
||||
{
|
||||
FAR struct up_dev_s *priv = (FAR struct up_dev_s *)dev->ad_priv;
|
||||
if (enable)
|
||||
{
|
||||
up_enable_irq(priv->irq);
|
||||
}
|
||||
else
|
||||
{
|
||||
up_disable_irq(priv->irq);
|
||||
}
|
||||
}
|
||||
|
||||
/* All ioctl calls will be routed through this method */
|
||||
|
||||
@@ -269,7 +284,6 @@ static int adc_ioctl(FAR struct adc_dev_s *dev, int cmd, unsigned long arg)
|
||||
|
||||
static int adc_interrupt(int irq, void *context)
|
||||
{
|
||||
uint32_t regval;
|
||||
FAR struct up_dev_s *priv = (FAR struct up_dev_s *)g_adcdev.ad_priv;
|
||||
FAR struct spi_dev_s *spi = priv->spi;
|
||||
unsigned char buf[4];
|
||||
|
||||
+22
-4
@@ -68,7 +68,6 @@
|
||||
#define HALF_SECOND_MSEC 500
|
||||
#define HALF_SECOND_USEC 500000L
|
||||
|
||||
|
||||
/****************************************************************************
|
||||
* Private Function Prototypes
|
||||
****************************************************************************/
|
||||
@@ -155,11 +154,14 @@ static int dac_open(FAR struct file *filep)
|
||||
|
||||
dev->ad_ocount = tmp;
|
||||
}
|
||||
|
||||
irqrestore(flags);
|
||||
}
|
||||
}
|
||||
|
||||
sem_post(&dev->ad_closesem);
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
@@ -220,6 +222,7 @@ static int dac_close(FAR struct file *filep)
|
||||
sem_post(&dev->ad_closesem);
|
||||
}
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
@@ -260,6 +263,7 @@ static int dac_xmit(FAR struct dac_dev_s *dev)
|
||||
|
||||
enable = (ret == OK ? true : false);
|
||||
}
|
||||
|
||||
dev->ad_ops->ao_txint(dev, enable);
|
||||
return ret;
|
||||
}
|
||||
@@ -274,7 +278,7 @@ static ssize_t dac_write(FAR struct file *filep, FAR const char *buffer, size_t
|
||||
FAR struct dac_dev_s *dev = inode->i_private;
|
||||
FAR struct dac_fifo_s *fifo = &dev->ad_xmit;
|
||||
FAR struct dac_msg_s *msg;
|
||||
bool empty = false;
|
||||
bool empty;
|
||||
ssize_t nsent = 0;
|
||||
irqstate_t flags;
|
||||
int nexttail;
|
||||
@@ -296,17 +300,29 @@ static ssize_t dac_write(FAR struct file *filep, FAR const char *buffer, size_t
|
||||
*/
|
||||
|
||||
if (buflen % 5 == 0 )
|
||||
{
|
||||
msglen = 5;
|
||||
}
|
||||
else if (buflen % 4 == 0)
|
||||
{
|
||||
msglen = 4;
|
||||
}
|
||||
else if (buflen % 3 == 0)
|
||||
{
|
||||
msglen = 3;
|
||||
}
|
||||
else if (buflen % 2 == 0)
|
||||
{
|
||||
msglen = 2;
|
||||
}
|
||||
else if (buflen == 1)
|
||||
{
|
||||
msglen = 1;
|
||||
}
|
||||
else
|
||||
{
|
||||
msglen = 5;
|
||||
}
|
||||
|
||||
while ((buflen - nsent) >= msglen )
|
||||
{
|
||||
@@ -336,6 +352,7 @@ static ssize_t dac_write(FAR struct file *filep, FAR const char *buffer, size_t
|
||||
{
|
||||
ret = nsent;
|
||||
}
|
||||
|
||||
goto return_with_irqdisabled;
|
||||
}
|
||||
|
||||
@@ -399,6 +416,7 @@ static ssize_t dac_write(FAR struct file *filep, FAR const char *buffer, size_t
|
||||
fifo->af_buffer[fifo->af_tail].am_data=buffer[nsent];
|
||||
fifo->af_buffer[fifo->af_tail].am_data<<=24;
|
||||
}
|
||||
|
||||
/* Increment the tail of the circular buffer */
|
||||
|
||||
fifo->af_tail = nexttail;
|
||||
@@ -434,7 +452,7 @@ static int dac_ioctl(FAR struct file *filep, int cmd, unsigned long arg)
|
||||
{
|
||||
FAR struct inode *inode = filep->f_inode;
|
||||
FAR struct dac_dev_s *dev = inode->i_private;
|
||||
int ret = OK;
|
||||
int ret;
|
||||
|
||||
ret = dev->ad_ops->ao_ioctl(dev, cmd, arg);
|
||||
return ret;
|
||||
@@ -480,6 +498,7 @@ int dac_txdone(FAR struct dac_dev_s *dev)
|
||||
ret = sem_post(&dev->ad_xmit.af_sem);
|
||||
}
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
@@ -496,4 +515,3 @@ int dac_register(FAR const char *path, FAR struct dac_dev_s *dev)
|
||||
|
||||
return register_driver(path, &dac_fops, 0555, dev);
|
||||
}
|
||||
|
||||
|
||||
@@ -1256,8 +1256,11 @@ static void *vs1053_workerthread(pthread_addr_t pvarg)
|
||||
FAR struct vs1053_struct_s *dev = (struct vs1053_struct_s *) pvarg;
|
||||
struct audio_msg_s msg;
|
||||
FAR struct ap_buffer_s *pBuf;
|
||||
int size, prio;
|
||||
int size;
|
||||
int prio;
|
||||
#ifndef CONFIG_AUDIO_EXCLUDE_STOP
|
||||
uint16_t reg;
|
||||
#endif
|
||||
uint8_t timeout;
|
||||
|
||||
auddbg("Entry\n");
|
||||
@@ -1454,7 +1457,7 @@ static int vs1053_start(FAR struct audio_lowerhalf_s *lower)
|
||||
|
||||
/* Pop the first enqueued buffer */
|
||||
|
||||
if ((ret = (sem_wait(&dev->apbq_sem)) == OK))
|
||||
if ((ret = sem_wait(&dev->apbq_sem)) == OK)
|
||||
{
|
||||
dev->pBuf = (FAR struct ap_buffer_s *) dq_remfirst(&dev->apbq);
|
||||
apb_reference(dev->pBuf); /* Add our buffer reference */
|
||||
|
||||
@@ -1082,7 +1082,7 @@ static int ads7843e_poll(FAR struct file *filep, FAR struct pollfd *fds,
|
||||
{
|
||||
FAR struct inode *inode;
|
||||
FAR struct ads7843e_dev_s *priv;
|
||||
int ret = OK;
|
||||
int ret;
|
||||
int i;
|
||||
|
||||
ivdbg("setup: %d\n", (int)setup);
|
||||
|
||||
@@ -1063,9 +1063,7 @@ static int max11802_poll(FAR struct file *filep, FAR struct pollfd *fds,
|
||||
{
|
||||
FAR struct inode *inode;
|
||||
FAR struct max11802_dev_s *priv;
|
||||
pollevent_t eventset;
|
||||
int ndx;
|
||||
int ret = OK;
|
||||
int ret;
|
||||
int i;
|
||||
|
||||
ivdbg("setup: %d\n", (int)setup);
|
||||
|
||||
@@ -381,7 +381,7 @@ int stmpe811_gpioattach(STMPE811_HANDLE handle, uint8_t pinconfig,
|
||||
{
|
||||
/* Enable interrupts for this GPIO */
|
||||
|
||||
regval &= ~GPIO_PIN(pin);
|
||||
regval |= GPIO_PIN(pin);
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -389,6 +389,7 @@ int stmpe811_gpioattach(STMPE811_HANDLE handle, uint8_t pinconfig,
|
||||
|
||||
regval &= ~GPIO_PIN(pin);
|
||||
}
|
||||
|
||||
stmpe811_putreg8(priv, STMPE811_GPIO_EN, regval);
|
||||
|
||||
sem_post(&priv->exclsem);
|
||||
|
||||
@@ -769,7 +769,7 @@ static void stmpe811_timeout(int argc, uint32_t arg1, ...)
|
||||
|
||||
/* Are we still stuck in the pen down state? */
|
||||
|
||||
if (priv->sample.contact == CONTACT_MOVE ||
|
||||
if (priv->sample.contact == CONTACT_DOWN ||
|
||||
priv->sample.contact == CONTACT_MOVE)
|
||||
{
|
||||
/* Yes... is the worker thread available? If not, then apparently
|
||||
@@ -1127,7 +1127,7 @@ void stmpe811_tscworker(FAR struct stmpe811_dev_s *priv, uint8_t intsta)
|
||||
*/
|
||||
|
||||
ignored:
|
||||
if (priv->sample.contact == CONTACT_MOVE ||
|
||||
if (priv->sample.contact == CONTACT_DOWN ||
|
||||
priv->sample.contact == CONTACT_MOVE)
|
||||
{
|
||||
(void)wd_start(priv->wdog, STMPE811_PENUP_TICKS, stmpe811_timeout,
|
||||
|
||||
@@ -455,7 +455,6 @@ static int st7567_putrun(fb_coord_t row, fb_coord_t col, FAR const uint8_t *buff
|
||||
FAR struct st7567_dev_s *priv = &g_st7567dev;
|
||||
FAR uint8_t *fbptr;
|
||||
FAR uint8_t *ptr;
|
||||
uint8_t devcol;
|
||||
uint8_t fbmask;
|
||||
uint8_t page;
|
||||
uint8_t usrmask;
|
||||
|
||||
@@ -905,7 +905,7 @@ static int mtdconfig_open(FAR struct file *filep)
|
||||
{
|
||||
FAR struct inode *inode = filep->f_inode;
|
||||
FAR struct mtdconfig_struct_s *dev = inode->i_private;
|
||||
int ret = OK;
|
||||
int ret;
|
||||
|
||||
/* Get exclusive access to the device */
|
||||
|
||||
|
||||
+253
-136
File diff suppressed because it is too large
Load Diff
@@ -152,7 +152,7 @@ static int bat_ioctl(FAR struct file *filep, int cmd, unsigned long arg)
|
||||
{
|
||||
FAR struct inode *inode = filep->f_inode;
|
||||
FAR struct battery_dev_s *dev = inode->i_private;
|
||||
int ret = -EINVAL;
|
||||
int ret;
|
||||
|
||||
/* Inforce mutually exclusive access to the battery driver */
|
||||
|
||||
|
||||
@@ -50,10 +50,12 @@
|
||||
#include <nuttx/sercomm/sercomm.h>
|
||||
|
||||
/* stubs to make serial driver happy */
|
||||
|
||||
void sercomm_recvchars(void *a) { }
|
||||
void sercomm_xmitchars(void *a) { }
|
||||
|
||||
/* Stubs to make memory allocator happy */
|
||||
|
||||
void cons_puts(void *foo){}
|
||||
void delay_ms(int ms){}
|
||||
|
||||
@@ -83,11 +85,13 @@ static const struct file_operations g_sercom_console_ops =
|
||||
#endif
|
||||
};
|
||||
|
||||
static FAR uart_dev_t *readdev = NULL;
|
||||
static struct msgb *recvmsg = NULL;
|
||||
|
||||
/****************************************************************************
|
||||
* Helper functions
|
||||
****************************************************************************/
|
||||
static FAR uart_dev_t *readdev = NULL;
|
||||
static struct msgb *recvmsg = NULL;
|
||||
|
||||
static void recv_cb(uint8_t dlci, struct msgb *msg)
|
||||
{
|
||||
sem_post(&readdev->recvsem);
|
||||
@@ -105,15 +109,19 @@ static ssize_t sc_console_read(file_t *filep, FAR char *buffer, size_t buflen)
|
||||
struct msgb *tmp;
|
||||
|
||||
/* Wait until data is received */
|
||||
while(recvmsg == NULL) {
|
||||
|
||||
while (recvmsg == NULL)
|
||||
{
|
||||
sem_wait(&readdev->recvsem);
|
||||
}
|
||||
|
||||
len = recvmsg->len > buflen ? buflen : recvmsg->len;
|
||||
memcpy(buffer, msgb_get(recvmsg, len), len);
|
||||
|
||||
if(recvmsg->len == 0) {
|
||||
if (recvmsg->len == 0)
|
||||
{
|
||||
/* prevent inconsistent msg by first invalidating it, then free it */
|
||||
|
||||
tmp = recvmsg;
|
||||
recvmsg = NULL;
|
||||
msgb_free(tmp);
|
||||
@@ -123,30 +131,39 @@ static ssize_t sc_console_read(file_t *filep, FAR char *buffer, size_t buflen)
|
||||
}
|
||||
|
||||
/* XXX: redirect to old Osmocom-BB comm/sercomm_cons.c -> 2 buffers */
|
||||
|
||||
extern int sercomm_puts(const char *s);
|
||||
|
||||
static ssize_t sc_console_write(file_t *filep, FAR const char *buffer, size_t buflen)
|
||||
{
|
||||
int i, cnt;
|
||||
char dstbuf[32];
|
||||
int cnt;
|
||||
|
||||
if (buflen >= 31)
|
||||
{
|
||||
cnt = 31;
|
||||
}
|
||||
else
|
||||
{
|
||||
cnt = buflen;
|
||||
}
|
||||
|
||||
memcpy(dstbuf, buffer, cnt);
|
||||
dstbuf[cnt] = '\0';
|
||||
|
||||
/* print part of our buffer */
|
||||
|
||||
sercomm_puts(dstbuf);
|
||||
|
||||
/* wait a little bit to get data transfered */
|
||||
|
||||
up_mdelay(1);
|
||||
|
||||
return cnt;
|
||||
}
|
||||
|
||||
/* Forward ioctl to uart driver */
|
||||
|
||||
static int sc_console_ioctl(struct file *filep, int cmd, unsigned long arg)
|
||||
{
|
||||
FAR struct inode *inode = filep->f_inode;
|
||||
@@ -160,9 +177,11 @@ static int sc_console_ioctl(struct file *filep, int cmd, unsigned long arg)
|
||||
************************************************************************************/
|
||||
|
||||
/* Use sercomm on uart driver, register console driver */
|
||||
|
||||
int sercomm_register(FAR const char *path, FAR uart_dev_t *dev)
|
||||
{
|
||||
/* XXX: initialize MODEMUART to be used for sercomm*/
|
||||
|
||||
uart_init(SERCOMM_UART_NR, 1);
|
||||
uart_baudrate(SERCOMM_UART_NR, UART_115200);
|
||||
readdev = dev;
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user