mbed w/ spi bug fig

Dependents:   display-puck

Fork of mbed-src by mbed official

Files at this revision

API Documentation at this revision

Comitter:
mbed_official
Date:
Wed Jun 11 09:30:07 2014 +0100
Parent:
224:e7c230c6cb31
Child:
226:b062af740e40
Commit message:
Synchronized with git revision ff65c63a80830b0c36f91f13488d79bafef442e6

Full URL: https://github.com/mbedmicro/mbed/commit/ff65c63a80830b0c36f91f13488d79bafef442e6/

Add support for remote CAN frames on LPC11CXX

Changed in this revision

targets/cmsis/TARGET_Freescale/TARGET_K64F/TOOLCHAIN_GCC_ARM/K64FN1M0xxx12.ld Show annotated file Show diff for this revision Revisions of this file
targets/cmsis/TARGET_Freescale/TARGET_K64F/TOOLCHAIN_GCC_ARM/startup_MK64F12.s Show annotated file Show diff for this revision Revisions of this file
targets/cmsis/TARGET_Freescale/TARGET_K64F/cmsis_nvic.h Show annotated file Show diff for this revision Revisions of this file
targets/hal/TARGET_Freescale/TARGET_KPSDK_MCUS/TARGET_KPSDK_CODE/drivers/enet/src/fsl_enet_irq.c Show annotated file Show diff for this revision Revisions of this file
targets/hal/TARGET_NXP/TARGET_LPC11XX_11CXX/TARGET_LPC11CXX/can_api.c Show annotated file Show diff for this revision Revisions of this file
--- a/targets/cmsis/TARGET_Freescale/TARGET_K64F/TOOLCHAIN_GCC_ARM/K64FN1M0xxx12.ld	Wed Jun 11 08:45:06 2014 +0100
+++ b/targets/cmsis/TARGET_Freescale/TARGET_K64F/TOOLCHAIN_GCC_ARM/K64FN1M0xxx12.ld	Wed Jun 11 09:30:07 2014 +0100
@@ -7,7 +7,7 @@
   VECTORS (rx)          : ORIGIN = 0x00000000, LENGTH = 0x00000400
   FLASH_PROTECTION (rx) : ORIGIN = 0x00000400, LENGTH = 0x00000010
   FLASH (rx)            : ORIGIN = 0x00000410, LENGTH = 0x00100000 - 0x00000410
-  RAM (rwx)             : ORIGIN = 0x1FFF0400, LENGTH = 0x00040000 - 0x00000400
+  RAM (rwx)             : ORIGIN = 0x1FFF0198, LENGTH = 0x00040000 - 0x00000198
 }
 
 /* Linker script to place sections and symbol values. Should be used together
--- a/targets/cmsis/TARGET_Freescale/TARGET_K64F/TOOLCHAIN_GCC_ARM/startup_MK64F12.s	Wed Jun 11 08:45:06 2014 +0100
+++ b/targets/cmsis/TARGET_Freescale/TARGET_K64F/TOOLCHAIN_GCC_ARM/startup_MK64F12.s	Wed Jun 11 09:30:07 2014 +0100
@@ -49,7 +49,7 @@
 #ifdef __STACK_SIZE
     .equ    Stack_Size, __STACK_SIZE
 #else
-    .equ    Stack_Size, 0x400
+    .equ    Stack_Size, 0xC00
 #endif
     .globl    __StackTop
     .globl    __StackLimit
@@ -64,7 +64,7 @@
 #ifdef __HEAP_SIZE
     .equ    Heap_Size, __HEAP_SIZE
 #else
-    .equ    Heap_Size, 0x80
+    .equ    Heap_Size, 0x400
 #endif
     .globl    __HeapBase
     .globl    __HeapLimit
@@ -199,6 +199,18 @@
  *      __data_start__/__data_end__: RAM address range that data should be
  *      copied to. Both must be aligned to 4 bytes boundary.  */
 
+disable_watchdog:
+    /* unlock */
+    ldr r1, =0x4005200e
+    ldr r0, =0xc520
+    strh r0, [r1]
+    ldr r0, =0xd928
+    strh r0, [r1]
+    /* disable */
+    ldr r1, =0x40052000
+    ldr r0, =0x01d2
+    strh r0, [r1]
+
     ldr    r1, =__etext
     ldr    r2, =__data_start__
     ldr    r3, =__data_end__
--- a/targets/cmsis/TARGET_Freescale/TARGET_K64F/cmsis_nvic.h	Wed Jun 11 08:45:06 2014 +0100
+++ b/targets/cmsis/TARGET_Freescale/TARGET_K64F/cmsis_nvic.h	Wed Jun 11 09:30:07 2014 +0100
@@ -7,7 +7,7 @@
 #ifndef MBED_CMSIS_NVIC_H
 #define MBED_CMSIS_NVIC_H
 
-#define NVIC_NUM_VECTORS      (16 + 85)   // CORE + MCU Peripherals
+#define NVIC_NUM_VECTORS      (16 + 86)   // CORE + MCU Peripherals
 #define NVIC_USER_IRQ_OFFSET  16
 
 #include "cmsis.h"
--- a/targets/hal/TARGET_Freescale/TARGET_KPSDK_MCUS/TARGET_KPSDK_CODE/drivers/enet/src/fsl_enet_irq.c	Wed Jun 11 08:45:06 2014 +0100
+++ b/targets/hal/TARGET_Freescale/TARGET_KPSDK_MCUS/TARGET_KPSDK_CODE/drivers/enet/src/fsl_enet_irq.c	Wed Jun 11 09:30:07 2014 +0100
@@ -33,7 +33,7 @@
 /*******************************************************************************
  * Variables
  ******************************************************************************/
-extern void *enetIfHandle;
+
 
 /* Internal irq number*/
 typedef enum _enet_irq_number
@@ -81,24 +81,7 @@
 /*******************************************************************************
  * Code
  ******************************************************************************/
-#if defined (K64F12_SERIES) || defined (K70F12_SERIES) 
-void ENET_Transmit_IRQHandler(void)
-{
-     enet_mac_tx_isr(enetIfHandle);
-}
-
-void ENET_Receive_IRQHandler(void)
-{
-     enet_mac_rx_isr(enetIfHandle);
-}
-
-#if FSL_FEATURE_ENET_SUPPORT_PTP
-void ENET_1588_Timer_IRQHandler(void)
-{
-     enet_mac_ts_isr(enetIfHandle);
-}
-#endif
-#endif
+/* The code was moved to k64f mac file (eth) */
 
 /*******************************************************************************
  * EOF
--- a/targets/hal/TARGET_NXP/TARGET_LPC11XX_11CXX/TARGET_LPC11CXX/can_api.c	Wed Jun 11 08:45:06 2014 +0100
+++ b/targets/hal/TARGET_NXP/TARGET_LPC11XX_11CXX/TARGET_LPC11CXX/can_api.c	Wed Jun 11 09:30:07 2014 +0100
@@ -69,12 +69,12 @@
             LPC_CAN->IF1_ARB1 = BFN_PREP(id, CANIFn_ARB1_ID);
             LPC_CAN->IF1_ARB2 = CANIFn_ARB2_MSGVAL | CANIFn_ARB2_XTD | BFN_PREP(id >> 16, CANIFn_ARB2_ID);
             LPC_CAN->IF1_MSK1 = BFN_PREP(mask, CANIFn_MSK1_MSK);
-            LPC_CAN->IF1_MSK2 = CANIFn_MSK2_MXTD | CANIFn_MSK2_MDIR | BFN_PREP(mask >> 16, CANIFn_MSK2_MSK);
+            LPC_CAN->IF1_MSK2 = CANIFn_MSK2_MXTD /* | CANIFn_MSK2_MDIR */ | BFN_PREP(mask >> 16, CANIFn_MSK2_MSK);
         }
         else {
             // Mark message valid, Direction = TX, Set Identifier and mask everything
             LPC_CAN->IF1_ARB2 = CANIFn_ARB2_MSGVAL | BFN_PREP(id << 2, CANIFn_ARB2_ID);
-            LPC_CAN->IF1_MSK2 = CANIFn_MSK2_MDIR | BFN_PREP(mask << 2, CANIFn_MSK2_MSK);
+            LPC_CAN->IF1_MSK2 = /* CANIFn_MSK2_MDIR | */ BFN_PREP(mask << 2, CANIFn_MSK2_MSK);
         }
         
         // Use mask, single message object and set DLC
@@ -286,16 +286,22 @@
     // Make sure the interface is available
     while( LPC_CAN->IF1_CMDREQ & CANIFn_CMDREQ_BUSY );
 
+    // Set the direction bit based on the message type
+    uint32_t direction = 0;
+    if (msg.type == CANData) {
+        direction = CANIFn_ARB2_DIR;
+    }
+
     if(msg.format == CANExtended)    {
-        // Mark message valid, Direction = TX, Extended Frame, Set Identifier and mask everything
+        // Mark message valid, Extended Frame, Set Identifier and mask everything
         LPC_CAN->IF1_ARB1 = BFN_PREP(msg.id, CANIFn_ARB1_ID);
-        LPC_CAN->IF1_ARB2 = CANIFn_ARB2_MSGVAL | CANIFn_ARB2_XTD | CANIFn_ARB2_DIR | BFN_PREP(msg.id >> 16, CANIFn_ARB2_ID);
+        LPC_CAN->IF1_ARB2 = CANIFn_ARB2_MSGVAL | CANIFn_ARB2_XTD | direction | BFN_PREP(msg.id >> 16, CANIFn_ARB2_ID);
         LPC_CAN->IF1_MSK1 = BFN_PREP(ID_EXT_MASK, CANIFn_MSK1_MSK);
         LPC_CAN->IF1_MSK2 = CANIFn_MSK2_MXTD | CANIFn_MSK2_MDIR | BFN_PREP(ID_EXT_MASK >> 16, CANIFn_MSK2_MSK);
     }
     else {
-        // Mark message valid, Direction = TX, Set Identifier and mask everything
-        LPC_CAN->IF1_ARB2 = CANIFn_ARB2_MSGVAL | CANIFn_ARB2_DIR | BFN_PREP(msg.id << 2, CANIFn_ARB2_ID);
+        // Mark message valid, Set Identifier and mask everything
+        LPC_CAN->IF1_ARB2 = CANIFn_ARB2_MSGVAL | direction | BFN_PREP(msg.id << 2, CANIFn_ARB2_ID);
         LPC_CAN->IF1_MSK2 = CANIFn_MSK2_MDIR | BFN_PREP(ID_STD_MASK << 2, CANIFn_MSK2_MSK);
     }
     
@@ -364,8 +370,13 @@
             msg->id = (LPC_CAN->IF2_ARB2 & CANIFn_ARB2_ID_MASK) >> 2;
         }
 
-        // TODO: Remote frame support
-        msg->type       = CANData;
+        if (LPC_CAN->IF2_ARB2 & CANIFn_ARB2_DIR) {
+            msg->type   = CANRemote;
+        }
+        else {
+            msg->type   = CANData;
+        }
+
         msg->len        = BFN_GET(LPC_CAN->IF2_MCTRL, CANIFn_MCTRL_DLC); // TODO: If > 8, len = 8
         msg->data[0]    = BFN_GET(LPC_CAN->IF2_DA1, CANIFn_DA1_DATA0);
         msg->data[1]    = BFN_GET(LPC_CAN->IF2_DA1, CANIFn_DA1_DATA1);