mbed source development branch

Fork of mbed-dev by mbed official

Files at this revision

API Documentation at this revision

Comitter:
ptpaterson
Date:
Thu Nov 03 16:21:53 2016 +0000
Parent:
149:156823d33999
Commit message:
targets LPC11Cxx, LPC15xx: can_api can_filter function properly returns 0 if handle argument is out of bounds (handle > 32).

Changed in this revision

targets/TARGET_NXP/TARGET_LPC11XX_11CXX/TARGET_LPC11CXX/can_api.c Show annotated file Show diff for this revision Revisions of this file
targets/TARGET_NXP/TARGET_LPC15XX/can_api.c Show annotated file Show diff for this revision Revisions of this file
diff -r 156823d33999 -r cd63f849362a targets/TARGET_NXP/TARGET_LPC11XX_11CXX/TARGET_LPC11CXX/can_api.c
--- a/targets/TARGET_NXP/TARGET_LPC11XX_11CXX/TARGET_LPC11CXX/can_api.c	Fri Oct 28 11:17:30 2016 +0100
+++ b/targets/TARGET_NXP/TARGET_LPC11XX_11CXX/TARGET_LPC11CXX/can_api.c	Thu Nov 03 16:21:53 2016 +0000
@@ -85,6 +85,7 @@
 
 int can_filter(can_t *obj, uint32_t id, uint32_t mask, CANFormat format, int32_t handle) {
     uint16_t i;
+    int retval = 0;
 
     // Find first free message object
     if(handle == 0) {
@@ -99,6 +100,7 @@
     }
     
     if(handle > 0 && handle < 32) {
+        retval = handle;
         if(format == CANExtended) {
             // Mark message valid, Direction = TX, Extended Frame, Set Identifier and mask everything
             LPC_CAN->IF1_ARB1 = BFN_PREP(id, CANIFn_ARB1_ID);
@@ -125,7 +127,7 @@
         while( LPC_CAN->IF1_CMDREQ & CANIFn_CMDREQ_BUSY );
     }
     
-    return handle;
+    return retval;
 }
 
 static inline void can_irq() {
diff -r 156823d33999 -r cd63f849362a targets/TARGET_NXP/TARGET_LPC15XX/can_api.c
--- a/targets/TARGET_NXP/TARGET_LPC15XX/can_api.c	Fri Oct 28 11:17:30 2016 +0100
+++ b/targets/TARGET_NXP/TARGET_LPC15XX/can_api.c	Thu Nov 03 16:21:53 2016 +0000
@@ -125,6 +125,7 @@
 
 int can_filter(can_t *obj, uint32_t id, uint32_t mask, CANFormat format, int32_t handle) {
     uint16_t i;
+    int retval = 0;
 
     // Find first free message object
     if (handle == 0) {
@@ -140,6 +141,7 @@
     }
 
     if (handle > 0 && handle < 32) {
+        retval = handle;
         if (format == CANExtended) {
             // Mark message valid, Direction = TX, Extended Frame, Set Identifier and mask everything
             LPC_C_CAN0->CANIF1_ARB1 = (id & 0xFFFF);
@@ -165,7 +167,7 @@
         while ( LPC_C_CAN0->CANIF1_CMDREQ & CANIFn_CMDREQ_BUSY );
     }
 
-    return handle;
+    return retval;
 }
 
 static inline void can_irq() {