diff options
author | patacongo <patacongo@42af7a65-404d-4744-a932-0658087f49c3> | 2012-01-20 03:37:29 +0000 |
---|---|---|
committer | patacongo <patacongo@42af7a65-404d-4744-a932-0658087f49c3> | 2012-01-20 03:37:29 +0000 |
commit | a89135e23145cd538db501fd5c8b60bc2fcd4cb3 (patch) | |
tree | 11ea8443de9bdfb86fca51e6aef9c480a3af7ae2 /nuttx/arch/arm/src/lpc17xx | |
parent | 77c6594eb257557db6111945a3354ded40e41858 (diff) | |
download | px4-nuttx-a89135e23145cd538db501fd5c8b60bc2fcd4cb3.tar.gz px4-nuttx-a89135e23145cd538db501fd5c8b60bc2fcd4cb3.tar.bz2 px4-nuttx-a89135e23145cd538db501fd5c8b60bc2fcd4cb3.zip |
Leverage some bit timing logic from LPC17xx to the STM32 CAN driver
git-svn-id: svn://svn.code.sf.net/p/nuttx/code/trunk@4317 42af7a65-404d-4744-a932-0658087f49c3
Diffstat (limited to 'nuttx/arch/arm/src/lpc17xx')
-rwxr-xr-x | nuttx/arch/arm/src/lpc17xx/lpc17_can.c | 8 | ||||
-rwxr-xr-x | nuttx/arch/arm/src/lpc17xx/lpc17_can.h | 5 |
2 files changed, 9 insertions, 4 deletions
diff --git a/nuttx/arch/arm/src/lpc17xx/lpc17_can.c b/nuttx/arch/arm/src/lpc17xx/lpc17_can.c index 80e148077..0494904cf 100755 --- a/nuttx/arch/arm/src/lpc17xx/lpc17_can.c +++ b/nuttx/arch/arm/src/lpc17xx/lpc17_can.c @@ -151,6 +151,10 @@ # define CONFIG_CAN_TSEG2 7 #endif +#if CONFIG_CAN_TSEG2 < 1 || CONFIG_CAN_TSEG2 > CAN_BTR_TSEG2_MAX +# errror "CONFIG_CAN_TSEG2 is out of range" +#endif + #define CAN_BIT_QUANTA (CONFIG_CAN_TSEG1 + CONFIG_CAN_TSEG2 + 1) /* Debug ********************************************************************/ @@ -1127,7 +1131,7 @@ static int can_bittiming(struct up_dev_s *priv) { /* At the smallest brp value (1), there are already too few bit times * (CAN_CLOCK / baud) to meet our goal. brp must be one and we need - * make some reasonalble guesses about ts1 and ts2. + * make some reasonable guesses about ts1 and ts2. */ brp = 1; @@ -1153,7 +1157,7 @@ static int can_bittiming(struct up_dev_s *priv) ts1 = CONFIG_CAN_TSEG1; ts2 = CONFIG_CAN_TSEG2; brp = (nclks + (CAN_BIT_QUANTA/2)) / CAN_BIT_QUANTA; - DEBUGASSERT(brp >=1 && brp < 1024); + DEBUGASSERT(brp >=1 && brp <= CAN_BTR_BRP_MAX); } sjw = 1; diff --git a/nuttx/arch/arm/src/lpc17xx/lpc17_can.h b/nuttx/arch/arm/src/lpc17xx/lpc17_can.h index 0950dffe5..e990958fd 100755 --- a/nuttx/arch/arm/src/lpc17xx/lpc17_can.h +++ b/nuttx/arch/arm/src/lpc17xx/lpc17_can.h @@ -370,9 +370,10 @@ #define CAN_BTR_TSEG2_MASK (7 << CAN_BTR_TSEG2_SHIFT) #define CAN_BTR_SAM (1 << 23) /* Bit 23: Sampling */ /* Bits 24-31: Reserved */ + #define CAN_BTR_BRP_MAX (1024) /* Maximum BTR value (without decrement) */ -#define CAN_BTR_TSEG1_MAX (16) /* Maximum TSEG value (without decrement) */ -#define CAN_BTR_TSEG2_MAX (8) /* Maximum TSEG value (without decrement) */ +#define CAN_BTR_TSEG1_MAX (16) /* Maximum TSEG1 value (without decrement) */ +#define CAN_BTR_TSEG2_MAX (8) /* Maximum TSEG2 value (without decrement) */ /* Error Warning Limit */ |