mirror of https://github.com/ARMmbed/mbed-os.git
Merged bugfixes and improvments for LPC1768 target to LPC4088 target
parent
f2f7b213cd
commit
bb35d16521
|
@ -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
|
||||
|
|
|
@ -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)
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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");
|
||||
}
|
||||
|
||||
|
|
|
@ -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");
|
||||
}
|
||||
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
|
||||
|
|
|
@ -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) {
|
||||
|
|
|
@ -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;
|
||||
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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) {
|
||||
|
|
|
@ -385,6 +385,7 @@
|
|||
{% for file in object_files %}
|
||||
{{file}}
|
||||
{% endfor %}
|
||||
--any_placement=first_fit
|
||||
</Misc>
|
||||
<LinkerInputFile></LinkerInputFile>
|
||||
<DisabledWarnings></DisabledWarnings>
|
||||
|
|
Loading…
Reference in New Issue