Merge remote-tracking branch 'github/master'

pull/78/merge
Bogdan Marinescu 2013-09-25 10:27:17 +01:00
commit 8f57c1e847
13 changed files with 90 additions and 61 deletions

View File

@ -34,7 +34,9 @@
#ifndef __LPC407x_8x_177x_8x_H__
#define __LPC407x_8x_177x_8x_H__
#define CORE_M4
#if defined(__CORTEX_M4) && !defined(CORE_M4)
#define CORE_M4
#endif
// ##################
// Code Red - excluded extern "C" as unrequired

View File

@ -11,7 +11,10 @@ LR_IROM1 0x00000000 0x00080000 { ; load region size_region
RW_IRAM1 0x100000E8 0x0000FF18 { ; RW data
.ANY (+RW +ZI)
}
RW_IRAM2 0x20000000 0x00008000 {
RW_IRAM2 0x20000000 0x00004000 {
.ANY (AHBSRAM0)
}
RW_IRAM3 0x20004000 0x00004000 {
.ANY (AHBSRAM1)
}
}

View File

@ -43,7 +43,7 @@ static const PinMap PinMap_ADC[] = {
void analogin_init(analogin_t *obj, PinName pin) {
obj->adc = (ADCName)pinmap_peripheral(pin, PinMap_ADC);
if (obj->adc == (uint32_t)NC) {
if (obj->adc == (ADCName)NC) {
error("ADC pin mapping failed");
}

View File

@ -25,7 +25,7 @@ static const PinMap PinMap_DAC[] = {
void analogout_init(dac_t *obj, PinName pin) {
obj->dac = (DACName)pinmap_peripheral(pin, PinMap_DAC);
if (obj->dac == (uint32_t)NC) {
if (obj->dac == (DACName)NC) {
error("DAC pin mapping failed");
}

View File

@ -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_SC->PCONP & (1 << 13)) && LPC_CAN1->IER) || ((LPC_SC->PCONP & (1 << 14)) && LPC_CAN2->IER)) {
NVIC_SetVector(CAN_IRQn, (uint32_t) &can_irq_n);
NVIC_EnableIRQ(CAN_IRQn);
}

View File

@ -722,7 +722,7 @@ int ethernet_receive() {
if(receive_idx == -1) {
receive_idx = LPC_EMAC->RxConsumeIndex;
} else {
while(!(rxstat[receive_idx].Info & RINFO_LAST_FLAG) && (receive_idx != LPC_EMAC->RxProduceIndex)) {
while(!(rxstat[receive_idx].Info & RINFO_LAST_FLAG) && ((uint32_t)receive_idx != LPC_EMAC->RxProduceIndex)) {
receive_idx = rinc(receive_idx, NUM_RX_FRAG);
}
unsigned int info = rxstat[receive_idx].Info;
@ -738,7 +738,7 @@ int ethernet_receive() {
LPC_EMAC->RxConsumeIndex = receive_idx;
}
if(receive_idx == LPC_EMAC->RxProduceIndex) {
if((uint32_t)receive_idx == LPC_EMAC->RxProduceIndex) {
receive_idx = -1;
return 0;
}
@ -787,7 +787,7 @@ int ethernet_read(char *data, int dlen) {
void *pdst, *psrc;
int doff = 0;
if(receive_idx == LPC_EMAC->RxProduceIndex || receive_idx == -1) {
if((uint32_t)receive_idx == LPC_EMAC->RxProduceIndex || receive_idx == -1) {
return 0;
}

View File

@ -30,44 +30,66 @@ static void handle_interrupt_in(void) {
uint32_t fall0 = LPC_GPIOINT->IO0IntStatF;
uint32_t rise2 = LPC_GPIOINT->IO2IntStatR;
uint32_t fall2 = LPC_GPIOINT->IO2IntStatF;
uint32_t mask0 = 0;
uint32_t mask2 = 0;
int i;
// P0.0-0.31
for (i = 0; i < 32; i++) {
uint32_t pmask = (1 << i);
if (rise0 & pmask) {
mask0 |= pmask;
if (channel_ids[i] != 0)
irq_handler(channel_ids[i], IRQ_RISE);
}
if (fall0 & pmask) {
mask0 |= pmask;
if (channel_ids[i] != 0)
irq_handler(channel_ids[i], IRQ_FALL);
}
uint8_t bitloc;
// Continue as long as there are interrupts pending
while(rise0 > 0) {
// CLZ returns number of leading zeros, 31 minus that is location of
// first pending interrupt
bitloc = 31 - __CLZ(rise0);
if (channel_ids[bitloc] != 0)
irq_handler(channel_ids[bitloc], IRQ_RISE); //Run that interrupt
// Both clear the interrupt with clear register, and remove it from
// our local copy of the interrupt pending register
LPC_GPIOINT->IO0IntClr = 1 << bitloc;
rise0 -= 1<<bitloc;
}
// P2.0-2.31
for (i = 0; i < 32; i++) {
uint32_t pmask = (1 << i);
int channel_index = i + 32;
if (rise2 & pmask) {
mask2 |= pmask;
if (channel_ids[channel_index] != 0)
irq_handler(channel_ids[channel_index], IRQ_RISE);
}
if (fall2 & pmask) {
mask2 |= pmask;
if (channel_ids[channel_index] != 0)
irq_handler(channel_ids[channel_index], IRQ_FALL);
}
// Continue as long as there are interrupts pending
while(fall0 > 0) {
// CLZ returns number of leading zeros, 31 minus that is location of
// first pending interrupt
bitloc = 31 - __CLZ(fall0);
if (channel_ids[bitloc] != 0)
irq_handler(channel_ids[bitloc], IRQ_FALL); //Run that interrupt
// Both clear the interrupt with clear register, and remove it from
// our local copy of the interrupt pending register
LPC_GPIOINT->IO0IntClr = 1 << bitloc;
fall0 -= 1<<bitloc;
}
// Same for port 2
// Continue as long as there are interrupts pending
while(rise2 > 0) {
// CLZ returns number of leading zeros, 31 minus that is location of
// first pending interrupt
bitloc = 31 - __CLZ(rise2);
if (channel_ids[bitloc+32] != 0)
irq_handler(channel_ids[bitloc+32], IRQ_RISE); //Run that interrupt
// Both clear the interrupt with clear register, and remove it from
// our local copy of the interrupt pending register
LPC_GPIOINT->IO2IntClr = 1 << bitloc;
rise2 -= 1<<bitloc;
}
// Continue as long as there are interrupts pending
while(fall2 > 0) {
// CLZ returns number of leading zeros, 31 minus that is location of
// first pending interrupt
bitloc = 31 - __CLZ(fall2);
if (channel_ids[bitloc+32] != 0)
irq_handler(channel_ids[bitloc+32], IRQ_FALL); //Run that interrupt
// Both clear the interrupt with clear register, and remove it from
// our local copy of the interrupt pending register
LPC_GPIOINT->IO2IntClr = 1 << bitloc;
fall2 -= 1<<bitloc;
}
// Clear the interrupts we just handled
LPC_GPIOINT->IO0IntClr = mask0;
LPC_GPIOINT->IO2IntClr = mask2;
}
int gpio_irq_init(gpio_irq_t *obj, PinName pin, gpio_irq_handler handler, uint32_t id) {

View File

@ -17,7 +17,7 @@
#include "error.h"
void pin_function(PinName pin, int function) {
if (pin == (uint32_t)NC) return;
if (pin == (PinName)NC) return;
__IO uint32_t *reg = (__IO uint32_t*) (LPC_IOCON_BASE + 4 * pin);
@ -26,7 +26,7 @@ void pin_function(PinName pin, int function) {
}
void pin_mode(PinName pin, PinMode mode) {
if (pin == (uint32_t)NC) { return; }
if (pin == (PinName)NC) { return; }
uint32_t drain = ((uint32_t) mode & (uint32_t) OpenDrain) >> 2;

View File

@ -66,7 +66,7 @@ static unsigned int pwm_clock_mhz;
void pwmout_init(pwmout_t* obj, PinName pin) {
// determine the channel
PWMName pwm = (PWMName)pinmap_peripheral(pin, PinMap_PWM);
if (pwm == (uint32_t)NC)
if (pwm == (PWMName)NC)
error("PwmOut pin mapping failed");
obj->channel = pwm;

View File

@ -287,9 +287,10 @@ int serial_writable(serial_t *obj) {
}
void serial_clear(serial_t *obj) {
obj->uart->FCR = 1 << 1 // rx FIFO reset
| 1 << 2 // tx FIFO reset
| 0 << 6; // interrupt depth
obj->uart->FCR = 1 << 0 // FIFO Enable - 0 = Disables, 1 = Enabled
| 1 << 1 // rx FIFO reset
| 1 << 2 // tx FIFO reset
| 0 << 6; // interrupt depth
}
void serial_pinout_tx(PinName tx) {

View File

@ -17,14 +17,14 @@
<folderInfo id="com.arm.eclipse.build.config.baremetal.exe.debug.1914396777." name="/" resourcePath="">
<toolChain errorParsers="com.arm.eclipse.builder.armcc.error" id="com.arm.toolchain.baremetal.exe.debug.1781361929" name="ARM Compiler" superClass="com.arm.toolchain.baremetal.exe.debug">
<targetPlatform binaryParser="" id="com.arm.eclipse.build.config.baremetal.exe.debug.1914396777..1121504975" name=""/>
<builder buildPath="${workspace_loc:/ds5_lpc11u24/Build}" errorParsers="org.eclipse.cdt.core.GmakeErrorParser;org.eclipse.cdt.core.CWDLocator" id="com.arm.toolchain.baremetal.builder.1633639159" keepEnvironmentInBuildfile="false" managedBuildOn="true" name="Gnu Make Builder" superClass="com.arm.toolchain.baremetal.builder"/>
<builder autoBuildTarget="all" buildPath="${workspace_loc:/ds5_lpc11u24/Build}" cleanBuildTarget="clean" id="org.eclipse.cdt.build.core.internal.builder.1955892657" incrementalBuildTarget="all" managedBuildOn="true" name="CDT Internal Builder" superClass="org.eclipse.cdt.build.core.internal.builder"/>
<tool id="com.arm.tool.c.compiler.baremetal.exe.debug.1694050615" name="ARM C Compiler" superClass="com.arm.tool.c.compiler.baremetal.exe.debug"/>
<tool command="armcc" commandLinePattern="${COMMAND} ${FLAGS} ${OUTPUT_FLAG} ${OUTPUT_PREFIX}${OUTPUT} ${INPUTS}" errorParsers="" id="com.arm.tool.cpp.compiler.baremetal.exe.debug.1642314243" name="ARM C++ Compiler" superClass="com.arm.tool.cpp.compiler.baremetal.exe.debug">
<option id="com.arm.tool.c.compiler.option.targetcpu.235324898" name="Target CPU (--cpu)" superClass="com.arm.tool.c.compiler.option.targetcpu" value="Cortex-M0" valueType="string"/>
<option id="com.arm.tool.c.compiler.option.incpath.1328570024" name="Include path (-I)" superClass="com.arm.tool.c.compiler.option.incpath" valueType="includePath">
<listOptionValue builtIn="false" value="&quot;${workspace_loc:/ds5_lpc11u24/mbed}&quot;"/>
<listOptionValue builtIn="false" value="&quot;${workspace_loc:/ds5_lpc11u24/mbed/LPC11U24/ARM}&quot;"/>
<listOptionValue builtIn="false" value="&quot;${workspace_loc:/ds5_lpc11u24/mbed/LPC11U24}&quot;"/>
{% for path in include_paths %}
<listOptionValue builtIn="false" value="&quot;${workspace_loc:/${ProjName}/{{path}}}&quot;"/>
{% endfor %}
</option>
<inputType id="com.arm.tool.c.compiler.input.51293980" superClass="com.arm.tool.c.compiler.input"/>
<inputType id="com.arm.tool.cpp.compiler.input.2068563074" superClass="com.arm.tool.cpp.compiler.input"/>
@ -34,7 +34,7 @@
</tool>
<tool command="armlink" commandLinePattern="${COMMAND} ${FLAGS} ${OUTPUT_FLAG} ${OUTPUT_PREFIX}${OUTPUT} ${INPUTS}" errorParsers="" id="com.arm.tool.c.linker.2036393580" name="ARM Linker" superClass="com.arm.tool.c.linker">
<option id="com.arm.tool.c.linker.option.cpu.419580654" name="Target CPU (--cpu)" superClass="com.arm.tool.c.linker.option.cpu" value="Cortex-M0" valueType="string"/>
<option id="com.arm.tool.c.linker.option.scatter.1235987457" name="Scatter file (--scatter)" superClass="com.arm.tool.c.linker.option.scatter" value="${ProjDirPath}/mbed/LPC11U24/ARM/LPC11U24.sct" valueType="string"/>
<option id="com.arm.tool.c.linker.option.scatter.1235987457" name="Scatter file (--scatter)" superClass="com.arm.tool.c.linker.option.scatter" value="${ProjDirPath}/{{ scatter_file }}" valueType="string"/>
<option id="com.arm.tool.c.linker.userobjs.1389137013" name="Other object files" superClass="com.arm.tool.c.linker.userobjs" valueType="userObjs">
{% for path in object_files %}
<listOptionValue builtIn="false" value="&quot;${workspace_loc:/${ProjName}/{{path}}}&quot;"/>

View File

@ -17,13 +17,13 @@
<folderInfo id="com.arm.eclipse.build.config.baremetal.exe.debug.1910477576." name="/" resourcePath="">
<toolChain id="com.arm.toolchain.baremetal.exe.debug.1293445387" name="ARM Compiler" superClass="com.arm.toolchain.baremetal.exe.debug">
<targetPlatform id="com.arm.eclipse.build.config.baremetal.exe.debug.1910477576..2093450286" name=""/>
<builder buildPath="${workspace_loc:/ds5_lpc1768/Build}" id="com.arm.toolchain.baremetal.builder.457933156" keepEnvironmentInBuildfile="false" managedBuildOn="true" name="Gnu Make Builder" superClass="com.arm.toolchain.baremetal.builder"/>
<builder autoBuildTarget="all" buildPath="${workspace_loc:/ds5_lpc1768/Build}" cleanBuildTarget="clean" id="org.eclipse.cdt.build.core.internal.builder.2019880438" incrementalBuildTarget="all" managedBuildOn="true" name="CDT Internal Builder" superClass="org.eclipse.cdt.build.core.internal.builder"/>
<tool id="com.arm.tool.c.compiler.baremetal.exe.debug.518028859" name="ARM C Compiler" superClass="com.arm.tool.c.compiler.baremetal.exe.debug"/>
<tool id="com.arm.tool.cpp.compiler.baremetal.exe.debug.773836201" name="ARM C++ Compiler" superClass="com.arm.tool.cpp.compiler.baremetal.exe.debug">
<option id="com.arm.tool.c.compiler.option.incpath.337015821" name="Include path (-I)" superClass="com.arm.tool.c.compiler.option.incpath" valueType="includePath">
<listOptionValue builtIn="false" value="&quot;${workspace_loc:/${ProjName}/mbed/LPC1768}&quot;"/>
<listOptionValue builtIn="false" value="&quot;${workspace_loc:/${ProjName}/mbed/LPC1768/ARM}&quot;"/>
<listOptionValue builtIn="false" value="&quot;${workspace_loc:/${ProjName}/mbed}&quot;"/>
{% for path in include_paths %}
<listOptionValue builtIn="false" value="&quot;${workspace_loc:/${ProjName}/{{path}}}&quot;"/>
{% endfor %}
</option>
<option id="com.arm.tool.c.compiler.option.targetcpu.1479931161" name="Target CPU (--cpu)" superClass="com.arm.tool.c.compiler.option.targetcpu" value="Cortex-M3" valueType="string"/>
<inputType id="com.arm.tool.c.compiler.input.982666453" superClass="com.arm.tool.c.compiler.input"/>
@ -34,7 +34,7 @@
</tool>
<tool id="com.arm.tool.c.linker.2036393580" name="ARM Linker" superClass="com.arm.tool.c.linker">
<option id="com.arm.tool.c.linker.option.cpu.419580654" name="Target CPU (--cpu)" superClass="com.arm.tool.c.linker.option.cpu" value="Cortex-M3" valueType="string"/>
<option id="com.arm.tool.c.linker.option.scatter.1235987457" name="Scatter file (--scatter)" superClass="com.arm.tool.c.linker.option.scatter" value="${ProjDirPath}/mbed/LPC1768/ARM/LPC1768.sct" valueType="string"/>
<option id="com.arm.tool.c.linker.option.scatter.1235987457" name="Scatter file (--scatter)" superClass="com.arm.tool.c.linker.option.scatter" value="${ProjDirPath}/{{ scatter_file }}" valueType="string"/>
<option id="com.arm.tool.c.linker.userobjs.1389137013" name="Other object files" superClass="com.arm.tool.c.linker.userobjs" valueType="userObjs">
{% for path in object_files %}
<listOptionValue builtIn="false" value="&quot;${workspace_loc:/${ProjName}/{{path}}}&quot;"/>
@ -102,4 +102,4 @@
<autodiscovery enabled="true" problemReportingEnabled="true" selectedProfileId="com.arm.eclipse.builder.armcc.ARMCompilerDiscoveryProfile"/>
</scannerConfigBuildInfo>
</storageModule>
</cproject>
</cproject>

View File

@ -385,6 +385,7 @@
{% for file in object_files %}
{{file}}
{% endfor %}
--any_placement=first_fit
</Misc>
<LinkerInputFile></LinkerInputFile>
<DisabledWarnings></DisabledWarnings>