Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

LPC4088: PIN mode fix, export to external tools and MAC address retrieval #62

Merged
merged 3 commits into from
Sep 13, 2013
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -88,9 +88,9 @@ typedef enum {
} PinName;

typedef enum {
PullUp = 0,
PullDown = 3,
PullNone = 2,
PullUp = 2,
PullDown = 1,
PullNone = 0,
OpenDrain = 4
} PinMode;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
2 changes: 1 addition & 1 deletion workspace_tools/export/codered.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@

class CodeRed(Exporter):
NAME = 'CodeRed'
TARGETS = ['LPC1768']
TARGETS = ['LPC1768', 'LPC4088']
TOOLCHAIN = 'GCC_CR'

def generate(self):
Expand Down
1,922 changes: 1,922 additions & 0 deletions workspace_tools/export/codered_lpc4088_cproject.tmpl

Large diffs are not rendered by default.

84 changes: 84 additions & 0 deletions workspace_tools/export/codered_lpc4088_project.tmpl
Original file line number Diff line number Diff line change
@@ -0,0 +1,84 @@
<?xml version="1.0" encoding="UTF-8"?>
<projectDescription>
<name>{{name}}</name>
<comment>This file was automagically generated by mbed.org. For more information, see http://mbed.org/handbook/Exporting-To-Code-Red</comment>
<projects>
</projects>
<buildSpec>
<buildCommand>
<name>org.eclipse.cdt.managedbuilder.core.genmakebuilder</name>
<triggers>clean,full,incremental,</triggers>
<arguments>
<dictionary>
<key>?name?</key>
<value></value>
</dictionary>
<dictionary>
<key>org.eclipse.cdt.make.core.append_environment</key>
<value>true</value>
</dictionary>
<dictionary>
<key>org.eclipse.cdt.make.core.autoBuildTarget</key>
<value>all</value>
</dictionary>
<dictionary>
<key>org.eclipse.cdt.make.core.buildArguments</key>
<value></value>
</dictionary>
<dictionary>
<key>org.eclipse.cdt.make.core.buildCommand</key>
<value>make</value>
</dictionary>
<dictionary>
<key>org.eclipse.cdt.make.core.buildLocation</key>
<value>${workspace_loc:/{{name}}/Debug}</value>
</dictionary>
<dictionary>
<key>org.eclipse.cdt.make.core.cleanBuildTarget</key>
<value>clean</value>
</dictionary>
<dictionary>
<key>org.eclipse.cdt.make.core.contents</key>
<value>org.eclipse.cdt.make.core.activeConfigSettings</value>
</dictionary>
<dictionary>
<key>org.eclipse.cdt.make.core.enableAutoBuild</key>
<value>false</value>
</dictionary>
<dictionary>
<key>org.eclipse.cdt.make.core.enableCleanBuild</key>
<value>true</value>
</dictionary>
<dictionary>
<key>org.eclipse.cdt.make.core.enableFullBuild</key>
<value>true</value>
</dictionary>
<dictionary>
<key>org.eclipse.cdt.make.core.fullBuildTarget</key>
<value>all</value>
</dictionary>
<dictionary>
<key>org.eclipse.cdt.make.core.stopOnError</key>
<value>true</value>
</dictionary>
<dictionary>
<key>org.eclipse.cdt.make.core.useDefaultBuildCmd</key>
<value>true</value>
</dictionary>
</arguments>
</buildCommand>
<buildCommand>
<name>org.eclipse.cdt.managedbuilder.core.ScannerConfigBuilder</name>
<triggers>full,incremental,</triggers>
<arguments>
</arguments>
</buildCommand>
</buildSpec>
<natures>
<nature>org.eclipse.cdt.core.cnature</nature>
<nature>org.eclipse.cdt.core.ccnature</nature>
<nature>org.eclipse.cdt.managedbuilder.core.managedBuildNature</nature>
<nature>org.eclipse.cdt.managedbuilder.core.ScannerConfigNature</nature>
</natures>
</projectDescription>

2 changes: 1 addition & 1 deletion workspace_tools/export/uvision4.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
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',
Expand Down
Loading