ARM: simplify serial and get rid of mbed-pinmap_common.c.
We have only one UART, we use only one UART, so it's pointless to
do pin mapping calculations at runtime.
Binary size down by 268 bytes:
SIZES ARM... lpc1114
FLASH : 1724 bytes 6%
RAM : 156 bytes 4%
EEPROM : 0 bytes 0%
This commit is contained in:
parent
a5cb1bd31a
commit
776f90ff2c
|
|
@ -98,7 +98,7 @@ TARGET = $(PROGRAM).hex
|
|||
# Until the generic ARM port is completed, we'd have to wrap all sources
|
||||
# in #ifdef __AVR__. To avoid this, build only a selection for now:
|
||||
SOURCES = mendel.c cpu.c serial.c
|
||||
SOURCES += mbed-serial_api.c mbed-pinmap.c mbed-pinmap_common.c
|
||||
SOURCES += mbed-serial_api.c mbed-pinmap.c
|
||||
ifeq ($(MCU), lpc1114)
|
||||
SOURCES += mbed-system_LPC11xx.c
|
||||
endif
|
||||
|
|
|
|||
|
|
@ -43,11 +43,6 @@ typedef struct {
|
|||
void pin_function(PinName pin, int function);
|
||||
void pin_mode (PinName pin, PinMode mode);
|
||||
|
||||
uint32_t pinmap_peripheral(PinName pin, const PinMap* map);
|
||||
uint32_t pinmap_merge (uint32_t a, uint32_t b);
|
||||
void pinmap_pinout (PinName pin, const PinMap *map);
|
||||
uint32_t pinmap_find_peripheral(PinName pin, const PinMap* map);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
|
|
|||
|
|
@ -1,81 +0,0 @@
|
|||
/* mbed Microcontroller Library
|
||||
* Copyright (c) 2006-2013 ARM Limited
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
/*
|
||||
Notes for Teacup:
|
||||
|
||||
Copied from $(MBED)/libraries/mbed/common/pinmap_common.c.
|
||||
|
||||
Used only to get things running quickly. Without serial it's almost
|
||||
impossible to see wether code changes work. Should go away soon, because
|
||||
all this MBED stuff is too bloated for Teacup's purposes.
|
||||
|
||||
- Prefixed names of #include files with mbed- to match the names of the
|
||||
copies in the Teacup repo.
|
||||
- Wrapped the whole file in #ifdef __ARMEL__ to not cause conflicts with
|
||||
AVR builds.
|
||||
*/
|
||||
#ifdef __ARMEL__
|
||||
#include "mbed-pinmap.h"
|
||||
|
||||
void pinmap_pinout(PinName pin, const PinMap *map) {
|
||||
if (pin == NC)
|
||||
return;
|
||||
|
||||
while (map->pin != NC) {
|
||||
if (map->pin == pin) {
|
||||
pin_function(pin, map->function);
|
||||
|
||||
pin_mode(pin, PullNone);
|
||||
return;
|
||||
}
|
||||
map++;
|
||||
}
|
||||
}
|
||||
|
||||
uint32_t pinmap_merge(uint32_t a, uint32_t b) {
|
||||
// both are the same (inc both NC)
|
||||
if (a == b)
|
||||
return a;
|
||||
|
||||
// one (or both) is not connected
|
||||
if (a == (uint32_t)NC)
|
||||
return b;
|
||||
if (b == (uint32_t)NC)
|
||||
return a;
|
||||
|
||||
// mis-match error case
|
||||
return (uint32_t)NC;
|
||||
}
|
||||
|
||||
uint32_t pinmap_find_peripheral(PinName pin, const PinMap* map) {
|
||||
while (map->pin != NC) {
|
||||
if (map->pin == pin)
|
||||
return map->peripheral;
|
||||
map++;
|
||||
}
|
||||
return (uint32_t)NC;
|
||||
}
|
||||
|
||||
uint32_t pinmap_peripheral(PinName pin, const PinMap* map) {
|
||||
uint32_t peripheral = (uint32_t)NC;
|
||||
|
||||
if (pin == (PinName)NC)
|
||||
return (uint32_t)NC;
|
||||
peripheral = pinmap_find_peripheral(pin, map);
|
||||
|
||||
return peripheral;
|
||||
}
|
||||
#endif /* __ARMEL__ */
|
||||
|
|
@ -44,22 +44,6 @@
|
|||
******************************************************************************/
|
||||
#define UART_NUM 1
|
||||
|
||||
static const PinMap PinMap_UART_TX[] = {
|
||||
{P2_8 , UART_0, 0x02},
|
||||
{P3_5 , UART_0, 0x02},
|
||||
{P3_0 , UART_0, 0x03},
|
||||
{P1_7 , UART_0, 0x01},
|
||||
{NC , NC , 0x00}
|
||||
};
|
||||
|
||||
static const PinMap PinMap_UART_RX[] = {
|
||||
{P2_7 , UART_0, 0x02},
|
||||
{P3_4 , UART_0, 0x02},
|
||||
{P3_1 , UART_0, 0x03},
|
||||
{P1_6 , UART_0, 0x01},
|
||||
{NC , NC , 0x00}
|
||||
};
|
||||
|
||||
static uint32_t serial_irq_ids[UART_NUM] = {0};
|
||||
static uart_irq_handler irq_handler;
|
||||
|
||||
|
|
@ -69,10 +53,7 @@ serial_t stdio_uart;
|
|||
void mbed_serial_init(serial_t *obj, PinName tx, PinName rx) {
|
||||
int is_stdio_uart = 0;
|
||||
|
||||
// determine the UART to use
|
||||
UARTName uart_tx = (UARTName)pinmap_peripheral(tx, PinMap_UART_TX);
|
||||
UARTName uart_rx = (UARTName)pinmap_peripheral(rx, PinMap_UART_RX);
|
||||
UARTName uart = (UARTName)pinmap_merge(uart_tx, uart_rx);
|
||||
UARTName uart = UART_0;
|
||||
|
||||
obj->uart = (LPC_UART_TypeDef *)uart;
|
||||
LPC_SYSCON->SYSAHBCLKCTRL |= (1<<12);
|
||||
|
|
@ -93,16 +74,10 @@ void mbed_serial_init(serial_t *obj, PinName tx, PinName rx) {
|
|||
mbed_serial_format(obj, 8, ParityNone, 1);
|
||||
|
||||
// pinout the chosen uart
|
||||
pinmap_pinout(tx, PinMap_UART_TX);
|
||||
pinmap_pinout(rx, PinMap_UART_RX);
|
||||
|
||||
// set rx/tx pins in PullUp mode
|
||||
if (tx != NC) {
|
||||
pin_function(tx, 0x01);
|
||||
pin_mode(tx, PullUp);
|
||||
}
|
||||
if (rx != NC) {
|
||||
pin_function(rx, 0x01);
|
||||
pin_mode(rx, PullUp);
|
||||
}
|
||||
|
||||
switch (uart) {
|
||||
case UART_0: obj->index = 0; break;
|
||||
|
|
@ -299,10 +274,6 @@ void mbed_serial_clear(serial_t *obj) {
|
|||
| 0 << 6; // interrupt depth
|
||||
}
|
||||
|
||||
void mbed_serial_pinout_tx(PinName tx) {
|
||||
pinmap_pinout(tx, PinMap_UART_TX);
|
||||
}
|
||||
|
||||
void mbed_serial_break_clear(serial_t *obj) {
|
||||
obj->uart->LCR &= ~(1 << 6);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -78,8 +78,6 @@ void mbed_serial_clear (serial_t *obj);
|
|||
void mbed_serial_break_set (serial_t *obj);
|
||||
void mbed_serial_break_clear(serial_t *obj);
|
||||
|
||||
void mbed_serial_pinout_tx(PinName tx);
|
||||
|
||||
void mbed_serial_set_flow_control(serial_t *obj, FlowControl type, PinName rxflow, PinName txflow);
|
||||
|
||||
#ifdef __cplusplus
|
||||
|
|
|
|||
Loading…
Reference in New Issue