mbed library sources

Dependents:   Encrypted my_mbed lklk CyaSSL_DTLS_Cellular ... more

Superseded

This library was superseded by mbed-dev - https://os.mbed.com/users/mbed_official/code/mbed-dev/.

Development branch of the mbed library sources. This library is kept in synch with the latest changes from the mbed SDK and it is not guaranteed to work.

If you are looking for a stable and tested release, please import one of the official mbed library releases:

Import librarymbed

The official Mbed 2 C/C++ SDK provides the software platform and libraries to build your applications.

Files at this revision

API Documentation at this revision

Comitter:
mbed_official
Date:
Fri Sep 13 14:22:58 2013 +0100
Parent:
21:67d3158c7b56
Child:
23:8d50de55f208
Commit message:
Synchronized with git revision 2481fbe2a21f381cba6e6c3abdaceaed7e288e06

Changed in this revision

targets/hal/TARGET_NXP/TARGET_LPC408X/PinNames.h Show annotated file Show diff for this revision Revisions of this file
targets/hal/TARGET_NXP/TARGET_LPC408X/can_api.c Show annotated file Show diff for this revision Revisions of this file
targets/hal/TARGET_NXP/TARGET_LPC408X/ethernet_api.c Show annotated file Show diff for this revision Revisions of this file
--- a/targets/hal/TARGET_NXP/TARGET_LPC408X/PinNames.h	Wed Sep 11 16:54:00 2013 +0100
+++ b/targets/hal/TARGET_NXP/TARGET_LPC408X/PinNames.h	Fri Sep 13 14:22:58 2013 +0100
@@ -88,9 +88,9 @@
 } PinName;
 
 typedef enum {
-    PullUp = 0,
-    PullDown = 3,
-    PullNone = 2,
+    PullUp = 2,
+    PullDown = 1,
+    PullNone = 0,
     OpenDrain = 4
 } PinMode;
 
--- a/targets/hal/TARGET_NXP/TARGET_LPC408X/can_api.c	Wed Sep 11 16:54:00 2013 +0100
+++ b/targets/hal/TARGET_NXP/TARGET_LPC408X/can_api.c	Fri Sep 13 14:22:58 2013 +0100
@@ -164,7 +164,7 @@
     obj->dev->MOD &= ~(1);
     
     // Enable NVIC if at least 1 interrupt is active
-    if(LPC_CAN1->IER | LPC_CAN2->IER != 0) {
+    if((LPC_CAN1->IER | LPC_CAN2->IER) != 0) {
         NVIC_SetVector(CAN_IRQn, (uint32_t) &can_irq_n);
         NVIC_EnableIRQ(CAN_IRQn);
     }
--- a/targets/hal/TARGET_NXP/TARGET_LPC408X/ethernet_api.c	Wed Sep 11 16:54:00 2013 +0100
+++ b/targets/hal/TARGET_NXP/TARGET_LPC408X/ethernet_api.c	Fri Sep 13 14:22:58 2013 +0100
@@ -962,3 +962,47 @@
             break;
     }
 }
+
+/*
+ * The Embedded Artists LPC4088 QuickStart Board has an eeprom with a unique
+ * 48 bit ID. This ID is used as MAC address.
+ */
+
+#include "i2c_api.h"
+
+static int _macRetrieved = 0;
+static char _macAddr[6] = {0x00,0x02,0xF7,0xF0,0x00,0x00};
+#define EEPROM_24AA02E48_ADDR (0xA0)
+
+void mbed_mac_address(char *mac) {
+
+    if (_macRetrieved == 0) {
+        char tmp[6];
+        i2c_t i2cObj;
+
+        i2c_init(&i2cObj, P0_27, P0_28);
+
+        do {
+            // the unique ID is at offset 0xFA
+            tmp[0] = 0xFA;
+            if (i2c_write(&i2cObj, EEPROM_24AA02E48_ADDR, tmp, 1, 1) != 1) {
+                break; // failed to write
+            }
+
+
+            if (i2c_read(&i2cObj, EEPROM_24AA02E48_ADDR, tmp, 6, 1) != 6) {
+                break; // failed to read
+            }
+
+            memcpy(_macAddr, tmp, 6);
+
+        } while(0);
+
+        // We always consider the MAC address to be retrieved even though
+        // reading from the eeprom failed. If it wasn't possible to read
+        // from eeprom the default address will be used.
+        _macRetrieved = 1;
+    }
+
+    memcpy(mac, _macAddr, 6);
+}