diff options
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 */ |