summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rwxr-xr-xnuttx/ChangeLog5
-rw-r--r--nuttx/arch/mips/src/pic32mz/pic32mz-config.h16
-rw-r--r--nuttx/arch/mips/src/pic32mz/pic32mz-head.S30
-rw-r--r--nuttx/configs/pic32mz-starterkit/include/board.h2
-rw-r--r--nuttx/drivers/can.c29
5 files changed, 53 insertions, 29 deletions
diff --git a/nuttx/ChangeLog b/nuttx/ChangeLog
index 6569b8f3f..c2b8ab661 100755
--- a/nuttx/ChangeLog
+++ b/nuttx/ChangeLog
@@ -9872,3 +9872,8 @@
* libc/time/lib/lib_sfrtime.c: Missing implementation of %C in
sfrtime() C (was being treated as %y). From Freddie Chopin
(2015-02-23).
+ * drivers/can.c: In the can_open function: this line
+ 'dev->cd_ocount = tmp;' needs to be moved a few lines down otherwise
+ the open count will only be incremented from 0 to 1. This causes
+ problems when trying to open the can bus from two different tasks.
+ SourceForge Patch #46 from Anonymous (2015-02-23).
diff --git a/nuttx/arch/mips/src/pic32mz/pic32mz-config.h b/nuttx/arch/mips/src/pic32mz/pic32mz-config.h
index c00062a96..bbbc38381 100644
--- a/nuttx/arch/mips/src/pic32mz/pic32mz-config.h
+++ b/nuttx/arch/mips/src/pic32mz/pic32mz-config.h
@@ -207,21 +207,21 @@
/* System PLL Divided Input Clock Frequency Range bits */
-#if BOARD_PLL_INPUT < 5000000
-# error BOARD_PLL_INPUT too low
+#if (BOARD_PLL_INPUT / BOARD_PLL_IDIV) < 5000000
+# error BOARD_PLL_INPUT / BOARD_PLL_IDIV too low
# define CONFIG_PIC32MZ_FPLLRNG DEVCFG2_FPLLRNG_BYPASS /* < 5 MHz */
-#elif BOARD_PLL_INPUT < 9000000
+#elif (BOARD_PLL_INPUT / BOARD_PLL_IDIV) < 9000000
# define CONFIG_PIC32MZ_FPLLRNG DEVCFG2_FPLLRNG_5_10MHZ /* 5-10 MHz */
-#elif BOARD_PLL_INPUT < 14500000
+#elif (BOARD_PLL_INPUT / BOARD_PLL_IDIV) < 14500000
# define CONFIG_PIC32MZ_FPLLRNG DEVCFG2_FPLLRNG_8_16MHZ /* 8-16 MHz */
-#elif BOARD_PLL_INPUT < 23500000
+#elif (BOARD_PLL_INPUT / BOARD_PLL_IDIV) < 23500000
# define CONFIG_PIC32MZ_FPLLRNG DEVCFG2_FPLLRNG_13_26MHZ /* 13-26 MHz */
-#elif BOARD_PLL_INPUT < 39000000
+#elif (BOARD_PLL_INPUT / BOARD_PLL_IDIV) < 39000000
# define CONFIG_PIC32MZ_FPLLRNG DEVCFG2_FPLLRNG_21_42MHZ /* 21-42 MHz */
-#elif BOARD_PLL_INPUT < 64000000
+#elif (BOARD_PLL_INPUT / BOARD_PLL_IDIV) < 64000000
# define CONFIG_PIC32MZ_FPLLRNG DEVCFG2_FPLLRNG_34_64MHZ /* 36-64 MHz */
#else
-# error BOARD_PLL_INPUT too high
+# error BOARD_PLL_INPUT / BOARD_PLL_IDIV too high
# define CONFIG_PIC32MZ_FPLLRNG DEVCFG2_FPLLRNG_34_64MHZ /* 36-64 MHz */
#endif
diff --git a/nuttx/arch/mips/src/pic32mz/pic32mz-head.S b/nuttx/arch/mips/src/pic32mz/pic32mz-head.S
index b6f089bfd..8ea252dce 100644
--- a/nuttx/arch/mips/src/pic32mz/pic32mz-head.S
+++ b/nuttx/arch/mips/src/pic32mz/pic32mz-head.S
@@ -161,12 +161,14 @@
.ent __reset
__reset:
- .word 0x10000003 /* MIPS32: branch forward 0x10 bytes from here */
- /* MicroMIPS: ADDI32 $0, $0, 0x0007 (nop) */
- /* DO NOT change the relative branch */
- .word 0x00000000 /* NOP */
-
- /* If se get here then we are in microMIPS mode. That is because the
+ .word 0x10000004 /* 0x0000 */
+ /* MIPS32: Branch forward 0x14 bytes */
+ /* MicroMIPS: ADDI32 $0, $0, 0x0007 (NOP) */
+ .word 0x00000000 /* 0x0004 */
+ /* MIPS32: NOP */
+ /* MicroMIPS: NOP */
+
+ /* If we get here then we are in microMIPS mode. That is because the
* preceding instructions are all NOP in that case and we fall through
* to here. Otherwise, we branched to __reset_switch_isa
*/
@@ -174,17 +176,23 @@ __reset:
.set micromips
__reset_micromips:
- la k0, __start /* Just jump to the startup initialization code */
- jr k0
- nop
- /* Device not in proper ISA mode */
+ /* Just jump to the startup initialization code */
+
+ la k0, __start /* 0x0008 */
+ jr k0 /* 0x0010 */
+ nop /* 0x0012 */
+
+ /* Device not in proper ISA mode. If we are not in microMIPS mode then
+ * we get here from the first instruction at __reset which will get
+ * interpreted as a branch to this location.
+ */
.align 2
.set nomicromips
__reset_halt:
- b __reset_halt
+ b __reset_halt /* 0x0014 <- Branch target */
nop
.end __reset
diff --git a/nuttx/configs/pic32mz-starterkit/include/board.h b/nuttx/configs/pic32mz-starterkit/include/board.h
index 078309549..6b060f9c3 100644
--- a/nuttx/configs/pic32mz-starterkit/include/board.h
+++ b/nuttx/configs/pic32mz-starterkit/include/board.h
@@ -59,7 +59,7 @@
/* Oscillator modes */
-#define BOARD_FNOSC_POSC 1 /* Use primary oscillator */
+#define BOARD_FNOSC_SPLL 1 /* Use system PLL */
#define BOARD_POSC_HSMODE 1 /* High-speed crystal (HS) mode */
/* PLL configuration and resulting CPU clock.
diff --git a/nuttx/drivers/can.c b/nuttx/drivers/can.c
index 278acbd4f..f1a57925e 100644
--- a/nuttx/drivers/can.c
+++ b/nuttx/drivers/can.c
@@ -1,7 +1,7 @@
/****************************************************************************
* drivers/can.c
*
- * Copyright (C) 2008-2009, 2011-2012, 2014 Gregory Nutt. All rights reserved.
+ * Copyright (C) 2008-2009, 2011-2012, 2014-2015 Gregory Nutt. All rights reserved.
* Author: Gregory Nutt <gnutt@nuttx.org>
*
* Redistribution and use in source and binary forms, with or without
@@ -116,6 +116,9 @@ static const struct file_operations g_canops =
#ifndef CONFIG_DISABLE_POLL
, 0 /* poll */
#endif
+#ifndef CONFIG_DISABLE_PSEUDOFS_OPERATIONS
+ , 0 /* unlink */
+#endif
};
/****************************************************************************
@@ -183,13 +186,21 @@ static int can_open(FAR struct file *filep)
dev_rxint(dev, true);
- /* Save the new open count on success */
+ /* Save the new open count only on success */
- dev->cd_ocount = tmp;
+ dev->cd_ocount = 1;
}
+
irqrestore(flags);
}
+ else
+ {
+ /* Save the incremented open count */
+
+ dev->cd_ocount = tmp;
+ }
}
+
sem_post(&dev->cd_closesem);
}
@@ -336,9 +347,9 @@ static ssize_t can_read(FAR struct file *filep, FAR char *buffer,
int msglen = CAN_MSGLEN(msg->cm_hdr.ch_dlc);
if (nread + msglen > buflen)
- {
- break;
- }
+ {
+ break;
+ }
/* Copy the message to the user buffer */
@@ -409,7 +420,7 @@ static int can_xmit(FAR struct can_dev_s *dev)
while (dev->cd_xmit.tx_queue != dev->cd_xmit.tx_tail && dev_txready(dev))
{
- /* No.. The fifo should not be empty in this case */
+ /* No.. The FIFO should not be empty in this case */
DEBUGASSERT(dev->cd_xmit.tx_head != dev->cd_xmit.tx_tail);
@@ -487,7 +498,7 @@ static ssize_t can_write(FAR struct file *filep, FAR const char *buffer,
nexttail = 0;
}
- /* If the XMIT fifo becomes full, then wait for space to become available */
+ /* If the XMIT FIFO becomes full, then wait for space to become available */
while (nexttail == fifo->tx_head)
{
@@ -637,7 +648,7 @@ static int can_ioctl(FAR struct file *filep, int cmd, unsigned long arg)
{
FAR struct inode *inode = filep->f_inode;
FAR struct can_dev_s *dev = inode->i_private;
- int ret = OK;
+ int ret = OK;
canvdbg("cmd: %d arg: %ld\n", cmd, arg);