Skip to content

LP4330_M4 i2c/spi update #442

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

Merged
merged 1 commit into from
Aug 13, 2014
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
11 changes: 7 additions & 4 deletions libraries/mbed/targets/hal/TARGET_NXP/TARGET_LPC43XX/i2c_api.c
Original file line number Diff line number Diff line change
Expand Up @@ -20,17 +20,20 @@
#include "pinmap.h"
#include "error.h"

// SCU mode for I2C SCL/SDA pins
#define SCU_PINIO_I2C SCU_PINIO_PULLNONE

static const PinMap PinMap_I2C_SDA[] = {
{P_DED, I2C_0, 0},
{P2_3, I2C_1, 1},
{PE_13, I2C_1, 2},
{P2_3, I2C_1, (SCU_PINIO_I2C | 1)},
{PE_13, I2C_1, (SCU_PINIO_I2C | 2)},
{NC, NC, 0}
};

static const PinMap PinMap_I2C_SCL[] = {
{P_DED, I2C_0, 0},
{P2_4, I2C_1, 1},
{PE_14, I2C_1, 2},
{P2_4, I2C_1, (SCU_PINIO_I2C | 1)},
{PE_14, I2C_1, (SCU_PINIO_I2C | 2)},
{NC, NC, 0}
};

Expand Down
72 changes: 38 additions & 34 deletions libraries/mbed/targets/hal/TARGET_NXP/TARGET_LPC43XX/serial_api.c
Original file line number Diff line number Diff line change
Expand Up @@ -31,45 +31,49 @@
******************************************************************************/
#define UART_NUM 4

// SCU mode for UART pins
#define SCU_PINIO_UART_TX SCU_MODE_PULLDOWN
#define SCU_PINIO_UART_RX SCU_PINIO_PULLNONE

static const PinMap PinMap_UART_TX[] = {
{P1_13, UART_1, (SCU_MODE_PULLDOWN | 1)},
{P1_15, UART_2, (SCU_MODE_PULLDOWN | 1)},
{P2_0, UART_0, (SCU_MODE_PULLDOWN | 1)},
{P2_3, UART_3, (SCU_MODE_PULLDOWN | 2)},
{P2_10, UART_2, (SCU_MODE_PULLDOWN | 2)},
{P3_4, UART_1, (SCU_MODE_PULLDOWN | 4)},
{P4_1, UART_3, (SCU_MODE_PULLDOWN | 6)},
{P5_6, UART_1, (SCU_MODE_PULLDOWN | 4)},
{P6_4, UART_0, (SCU_MODE_PULLDOWN | 2)},
{P7_1, UART_2, (SCU_MODE_PULLDOWN | 6)},
{P9_3, UART_3, (SCU_MODE_PULLDOWN | 7)},
{P9_5, UART_0, (SCU_MODE_PULLDOWN | 7)},
{PA_1, UART_2, (SCU_MODE_PULLDOWN | 3)},
{PC_13, UART_1, (SCU_MODE_PULLDOWN | 2)},
{PE_11, UART_1, (SCU_MODE_PULLDOWN | 2)},
{PF_2, UART_3, (SCU_MODE_PULLDOWN | 1)},
{PF_10, UART_0, (SCU_MODE_PULLDOWN | 1)},
{P1_13, UART_1, (SCU_PINIO_UART_TX | 1)},
{P1_15, UART_2, (SCU_PINIO_UART_TX | 1)},
{P2_0, UART_0, (SCU_PINIO_UART_TX | 1)},
{P2_3, UART_3, (SCU_PINIO_UART_TX | 2)},
{P2_10, UART_2, (SCU_PINIO_UART_TX | 2)},
{P3_4, UART_1, (SCU_PINIO_UART_TX | 4)},
{P4_1, UART_3, (SCU_PINIO_UART_TX | 6)},
{P5_6, UART_1, (SCU_PINIO_UART_TX | 4)},
{P6_4, UART_0, (SCU_PINIO_UART_TX | 2)},
{P7_1, UART_2, (SCU_PINIO_UART_TX | 6)},
{P9_3, UART_3, (SCU_PINIO_UART_TX | 7)},
{P9_5, UART_0, (SCU_PINIO_UART_TX | 7)},
{PA_1, UART_2, (SCU_PINIO_UART_TX | 3)},
{PC_13, UART_1, (SCU_PINIO_UART_TX | 2)},
{PE_11, UART_1, (SCU_PINIO_UART_TX | 2)},
{PF_2, UART_3, (SCU_PINIO_UART_TX | 1)},
{PF_10, UART_0, (SCU_PINIO_UART_TX | 1)},
{NC, NC, 0}
};

static const PinMap PinMap_UART_RX[] = {
{P1_14, UART_1, (SCU_PINIO_PULLNONE | 1)},
{P1_16, UART_2, (SCU_PINIO_PULLNONE | 1)},
{P2_1, UART_0, (SCU_PINIO_PULLNONE | 1)},
{P2_4, UART_3, (SCU_PINIO_PULLNONE | 2)},
{P2_11, UART_2, (SCU_PINIO_PULLNONE | 2)},
{P3_5, UART_1, (SCU_PINIO_PULLNONE | 4)},
{P4_2, UART_3, (SCU_PINIO_PULLNONE | 6)},
{P5_7, UART_1, (SCU_PINIO_PULLNONE | 4)},
{P6_5, UART_0, (SCU_PINIO_PULLNONE | 2)},
{P7_2, UART_2, (SCU_PINIO_PULLNONE | 6)},
{P9_4, UART_3, (SCU_PINIO_PULLNONE | 7)},
{P9_6, UART_0, (SCU_PINIO_PULLNONE | 7)},
{PA_2, UART_2, (SCU_PINIO_PULLNONE | 3)},
{PC_14, UART_1, (SCU_PINIO_PULLNONE | 2)},
{PE_12, UART_1, (SCU_PINIO_PULLNONE | 2)},
{PF_3, UART_3, (SCU_PINIO_PULLNONE | 1)},
{PF_11, UART_0, (SCU_PINIO_PULLNONE | 1)},
{P1_14, UART_1, (SCU_PINIO_UART_RX | 1)},
{P1_16, UART_2, (SCU_PINIO_UART_RX | 1)},
{P2_1, UART_0, (SCU_PINIO_UART_RX | 1)},
{P2_4, UART_3, (SCU_PINIO_UART_RX | 2)},
{P2_11, UART_2, (SCU_PINIO_UART_RX | 2)},
{P3_5, UART_1, (SCU_PINIO_UART_RX | 4)},
{P4_2, UART_3, (SCU_PINIO_UART_RX | 6)},
{P5_7, UART_1, (SCU_PINIO_UART_RX | 4)},
{P6_5, UART_0, (SCU_PINIO_UART_RX | 2)},
{P7_2, UART_2, (SCU_PINIO_UART_RX | 6)},
{P9_4, UART_3, (SCU_PINIO_UART_RX | 7)},
{P9_6, UART_0, (SCU_PINIO_UART_RX | 7)},
{PA_2, UART_2, (SCU_PINIO_UART_RX | 3)},
{PC_14, UART_1, (SCU_PINIO_UART_RX | 2)},
{PE_12, UART_1, (SCU_PINIO_UART_RX | 2)},
{PF_3, UART_3, (SCU_PINIO_UART_RX | 1)},
{PF_11, UART_0, (SCU_PINIO_UART_RX | 1)},
{NC, NC, 0}
};

Expand Down
67 changes: 38 additions & 29 deletions libraries/mbed/targets/hal/TARGET_NXP/TARGET_LPC43XX/spi_api.c
Original file line number Diff line number Diff line change
Expand Up @@ -23,48 +23,51 @@
#include "pinmap.h"
#include "error.h"

// SCU mode for SPI pins
#define SCU_PINIO_SPI SCU_PINIO_FAST

static const PinMap PinMap_SPI_SCLK[] = {
{P1_19, SPI_1, (SCU_PINIO_FAST | 1)},
{P3_0, SPI_0, (SCU_PINIO_FAST | 4)},
{P3_3, SPI_0, (SCU_PINIO_FAST | 2)},
{PF_0, SPI_0, (SCU_PINIO_FAST | 0)},
{PF_4, SPI_1, (SCU_PINIO_FAST | 0)},
{P1_19, SPI_1, (SCU_PINIO_SPI | 1)},
{P3_0, SPI_0, (SCU_PINIO_SPI | 4)},
{P3_3, SPI_0, (SCU_PINIO_SPI | 2)},
{PF_0, SPI_0, (SCU_PINIO_SPI | 0)},
{PF_4, SPI_1, (SCU_PINIO_SPI | 0)},
{NC, NC, 0}
};

static const PinMap PinMap_SPI_MOSI[] = {
{P0_1, SPI_1, (SCU_PINIO_FAST | 1)},
{P1_2, SPI_0, (SCU_PINIO_FAST | 5)},
{P1_4, SPI_1, (SCU_PINIO_FAST | 5)},
{P3_7, SPI_0, (SCU_PINIO_FAST | 5)},
{P3_8, SPI_0, (SCU_PINIO_FAST | 2)},
{P9_2, SPI_0, (SCU_PINIO_FAST | 7)},
{PF_3, SPI_0, (SCU_PINIO_FAST | 2)},
{PF_7, SPI_1, (SCU_PINIO_FAST | 2)},
{P0_1, SPI_1, (SCU_PINIO_SPI | 1)},
{P1_2, SPI_0, (SCU_PINIO_SPI | 5)},
{P1_4, SPI_1, (SCU_PINIO_SPI | 5)},
{P3_7, SPI_0, (SCU_PINIO_SPI | 5)},
{P3_8, SPI_0, (SCU_PINIO_SPI | 2)},
{P9_2, SPI_0, (SCU_PINIO_SPI | 7)},
{PF_3, SPI_0, (SCU_PINIO_SPI | 2)},
{PF_7, SPI_1, (SCU_PINIO_SPI | 2)},
{NC, NC, 0}
};

static const PinMap PinMap_SPI_MISO[] = {
{P0_0, SPI_1, (SCU_PINIO_FAST | 1)},
{P1_1, SPI_0, (SCU_PINIO_FAST | 5)},
{P1_3, SPI_1, (SCU_PINIO_FAST | 5)},
{P3_6, SPI_0, (SCU_PINIO_FAST | 5)},
{P3_7, SPI_0, (SCU_PINIO_FAST | 2)},
{P9_1, SPI_0, (SCU_PINIO_FAST | 7)},
{PF_2, SPI_0, (SCU_PINIO_FAST | 2)},
{PF_6, SPI_1, (SCU_PINIO_FAST | 2)},
{P0_0, SPI_1, (SCU_PINIO_SPI | 1)},
{P1_1, SPI_0, (SCU_PINIO_SPI | 5)},
{P1_3, SPI_1, (SCU_PINIO_SPI | 5)},
{P3_6, SPI_0, (SCU_PINIO_SPI | 5)},
{P3_7, SPI_0, (SCU_PINIO_SPI | 2)},
{P9_1, SPI_0, (SCU_PINIO_SPI | 7)},
{PF_2, SPI_0, (SCU_PINIO_SPI | 2)},
{PF_6, SPI_1, (SCU_PINIO_SPI | 2)},
{NC, NC, 0}
};

static const PinMap PinMap_SPI_SSEL[] = {
{P1_0, SPI_0, (SCU_PINIO_FAST | 5)},
{P1_5, SPI_1, (SCU_PINIO_FAST | 5)},
{P1_20, SPI_1, (SCU_PINIO_FAST | 2)},
{P3_6, SPI_0, (SCU_PINIO_FAST | 2)},
{P3_8, SPI_0, (SCU_PINIO_FAST | 5)},
{P9_0, SPI_0, (SCU_PINIO_FAST | 7)},
{PF_1, SPI_0, (SCU_PINIO_FAST | 2)},
{PF_5, SPI_1, (SCU_PINIO_FAST | 2)},
{P1_0, SPI_0, (SCU_PINIO_SPI | 5)},
{P1_5, SPI_1, (SCU_PINIO_SPI | 5)},
{P1_20, SPI_1, (SCU_PINIO_SPI | 2)},
{P3_6, SPI_0, (SCU_PINIO_SPI | 2)},
{P3_8, SPI_0, (SCU_PINIO_SPI | 5)},
{P9_0, SPI_0, (SCU_PINIO_SPI | 7)},
{PF_1, SPI_0, (SCU_PINIO_SPI | 2)},
{PF_5, SPI_1, (SCU_PINIO_SPI | 2)},
{NC, NC, 0}
};

Expand All @@ -82,6 +85,12 @@ void spi_init(spi_t *obj, PinName mosi, PinName miso, PinName sclk, PinName ssel

obj->spi = (LPC_SSP_T*)pinmap_merge(spi_data, spi_cntl);
MBED_ASSERT((int)obj->spi != NC);

// enable clocking
switch ((int)obj->spi) {
case SPI_0: LPC_CGU->BASE_CLK[CLK_BASE_SSP0] = (1 << 11) | (CLKIN_MAINPLL << 24); break;
case SPI_1: LPC_CGU->BASE_CLK[CLK_BASE_SSP1] = (1 << 11) | (CLKIN_MAINPLL << 24); break;
}

// set default format and frequency
if (ssel == NC) {
Expand Down