From 0e36bdd457fd9ef434ec1893bb22b03855036911 Mon Sep 17 00:00:00 2001 From: unknown Date: Mon, 9 Sep 2013 14:10:11 +0200 Subject: [PATCH] Bugfix: PIN Modes was not set correctly Added: Export to uVision and Code Red toolchains --- .../hal/TARGET_NXP/TARGET_LPC408X/PinNames.h | 6 +-- .../hal/TARGET_NXP/TARGET_LPC408X/can_api.c | 2 +- .../TARGET_NXP/TARGET_LPC408X/ethernet_api.c | 44 +++++++++++++++++++ workspace_tools/export/codered.py | 2 +- workspace_tools/export/uvision4.py | 2 +- workspace_tools/export_test.py | 4 +- 6 files changed, 52 insertions(+), 8 deletions(-) diff --git a/libraries/mbed/targets/hal/TARGET_NXP/TARGET_LPC408X/PinNames.h b/libraries/mbed/targets/hal/TARGET_NXP/TARGET_LPC408X/PinNames.h index 987ccbe6d3..cf08642844 100644 --- a/libraries/mbed/targets/hal/TARGET_NXP/TARGET_LPC408X/PinNames.h +++ b/libraries/mbed/targets/hal/TARGET_NXP/TARGET_LPC408X/PinNames.h @@ -88,9 +88,9 @@ typedef enum { } PinName; typedef enum { - PullUp = 0, - PullDown = 3, - PullNone = 2, + PullUp = 2, + PullDown = 1, + PullNone = 0, OpenDrain = 4 } PinMode; diff --git a/libraries/mbed/targets/hal/TARGET_NXP/TARGET_LPC408X/can_api.c b/libraries/mbed/targets/hal/TARGET_NXP/TARGET_LPC408X/can_api.c index 0858f38ca2..2c13747817 100644 --- a/libraries/mbed/targets/hal/TARGET_NXP/TARGET_LPC408X/can_api.c +++ b/libraries/mbed/targets/hal/TARGET_NXP/TARGET_LPC408X/can_api.c @@ -164,7 +164,7 @@ void can_irq_set(can_t *obj, CanIrqType type, uint32_t enable) { 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); } diff --git a/libraries/mbed/targets/hal/TARGET_NXP/TARGET_LPC408X/ethernet_api.c b/libraries/mbed/targets/hal/TARGET_NXP/TARGET_LPC408X/ethernet_api.c index 8737fce8f1..b51ea72341 100644 --- a/libraries/mbed/targets/hal/TARGET_NXP/TARGET_LPC408X/ethernet_api.c +++ b/libraries/mbed/targets/hal/TARGET_NXP/TARGET_LPC408X/ethernet_api.c @@ -962,3 +962,47 @@ void ethernet_set_link(int speed, int duplex) { 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); +} diff --git a/workspace_tools/export/codered.py b/workspace_tools/export/codered.py index 16d42ec7b6..544cce2a8d 100644 --- a/workspace_tools/export/codered.py +++ b/workspace_tools/export/codered.py @@ -20,7 +20,7 @@ from os.path import splitext, basename class CodeRed(Exporter): NAME = 'CodeRed' - TARGETS = ['LPC1768'] + TARGETS = ['LPC1768', 'LPC4088'] TOOLCHAIN = 'GCC_CR' def generate(self): diff --git a/workspace_tools/export/uvision4.py b/workspace_tools/export/uvision4.py index 2859e2df7e..d1f3432ad4 100644 --- a/workspace_tools/export/uvision4.py +++ b/workspace_tools/export/uvision4.py @@ -21,7 +21,7 @@ from os.path import basename class Uvision4(Exporter): NAME = 'uVision4' TOOLCHAIN = 'ARM' - TARGETS = ['LPC1768', 'LPC11U24', 'KL25Z', 'LPC1347', 'LPC1114'] + TARGETS = ['LPC1768', 'LPC11U24', 'KL25Z', 'LPC1347', 'LPC1114', 'LPC4088'] FILE_TYPES = { 'c_sources':'1', 'cpp_sources':'8', diff --git a/workspace_tools/export_test.py b/workspace_tools/export_test.py index 877f1aeb30..cc1d6eeb35 100644 --- a/workspace_tools/export_test.py +++ b/workspace_tools/export_test.py @@ -76,9 +76,9 @@ if __name__ == '__main__': setup_test_user_prj() for toolchain, target in [ - ('uvision', 'LPC1768'), ('uvision', 'LPC11U24'), ('uvision', 'KL25Z'), ('uvision', 'LPC1347'), ('uvision', 'LPC1114'), + ('uvision', 'LPC1768'), ('uvision', 'LPC11U24'), ('uvision', 'KL25Z'), ('uvision', 'LPC1347'), ('uvision', 'LPC1114'), ('uvision', 'LPC4088'), - ('codered', 'LPC1768'), + ('codered', 'LPC1768'), ('codered', 'LPC4088'), # Linux path: /home/emimon01/bin/gcc-cs/bin/ # Windows path: "C:/Program Files (x86)/CodeSourcery/Sourcery_CodeBench_Lite_for_ARM_EABI/bin/"