8000 lpc: Add support for Micromint Banbino 230E · micropython/micropython@8ef9200 · GitHub
[go: up one dir, main page]

Skip to content

Commit 8ef9200

Browse files
lpc: Add support for Micromint Banbino 230E
Signed-off-by: Martin Ribelotta <martinribelotta@gmail.com>
1 parent db56ebf commit 8ef9200

File tree

8 files changed

+244
-4
lines changed

8 files changed

+244
-4
lines changed

ports/lpc/board.h

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,6 @@
33

44
#include <chip.h>
55

6-
#define CONSOLE_UART LPC_USART2
7-
#define BOARD_CIAA_EDU_NXP_4337
8-
96
#ifdef __cplusplus
107
extern "C" {
118
#endif
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
11
CHIP=lpc43xx
2-
BOARD_CFLAGS=-D__USE_LPCOPEN
2+
BOARD_CFLAGS=-D__USE_LPCOPEN -DCONSOLE_UART=LPC_USART2 -DBOARD_CIAA_EDU_NXP_4337
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
LPCOpen v3.01
2+
3+
Release Date: 03/24/2017
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
CHIP=lpc43xx
2+
BOARD_CFLAGS=-D__USE_LPCOPEN -DCONSOLE_UART=LPC_USART2 -DBOARD_MICROMINT_BAMBINO_210E
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
#define MICROPY_HW_BOARD_NAME "Micromint BAMBINO 210E"
2+
#define MICROPY_HW_MCU_NAME "LPC4337"
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
/* Specify the memory areas */
2+
MEMORY
3+
{
4+
FLASH (rx) : ORIGIN = 0x1a000000, LENGTH = 512K
5+
RAM (xrw) : ORIGIN = 0x10000000, LENGTH = 32k
6+
7+
FLASHB (rx) : ORIGIN = 0x1b000000, LENGTH = 512K
8+
RAMB (rwx) : ORIGIN = 0x10080000, LENGTH = 32K
9+
RAMC (rwx) : ORIGIN = 0x10088000, LENGTH = 8K
10+
RAMD (rwx) : ORIGIN = 0x20000000, LENGTH = 64K
11+
}
12+
13+
_py_heap_start = ORIGIN(RAMD);
14+
_py_heap_end = ORIGIN(RAMD) + LENGTH(RAMD);
Lines changed: 81 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,81 @@
1+
###############################################################################
2+
#
3+
# Copyright 2014, Juan Cecconi (UTN-FRBA, Numetron)
4+
#
5+
# Redistribution and use in source and binary forms, with or without
6+
# modification, are permitted provided that the following conditions are met:
7+
#
8+
# 1. Redistributions of source code must retain the above copyright notice,
9+
# this list of conditions and the following disclaimer.
10+
#
11+
# 2. Redistributions in binary form must reproduce the above copyright notice,
12+
# this list of conditions and the following disclaimer in the documentation
13+
# and/or other materials provided with the distribution.
14+
#
15+
# 3. Neither the name of the copyright holder nor the names of its
16+
# contributors may be used to endorse or promote products derived from this
17+
# software without specific prior written permission.
18+
#
19+
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
20+
# AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
21+
# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
22+
# ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
23+
# LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
24+
# CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
25+
# SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
26+
# INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
27+
# CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
28+
# ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
29+
# POSSIBILITY OF SUCH DAMAGE.
30+
#
31+
###############################################################################
32+
33+
#interface ftdi
34+
interface cmsis-dap
35+
#cmsis_dap_vid_pid 0x1FC9 0x0081
36+
37+
#ftdi_vid_pid 0x0403 0x6010
38+
#ftdi_channel 0
39+
#ftdi_layout_init 0x0708 0xFFFB
40+
#ftdi_layout_signal nTRST -data 0x0100
41+
#ftdi_layout_signal nSRST -data 0x0200
42+
43+
transport select jtag
44+
adapter_khz 2000
45+
46+
set _CHIPNAME lpc4337
47+
48+
set _M4_JTAG_TAPID 0x4ba00477
49+
set _M0_JTAG_TAPID 0x0ba01477
50+
51+
jtag newtap $_CHIPNAME m4 -irlen 4 -ircapture 0x1 -irmask 0xf -expected-id $_M4_JTAG_TAPID
52+
jtag newtap $_CHIPNAME m0 -irlen 4 -ircapture 0x1 -irmask 0xf -expected-id $_M0_JTAG_TAPID
53+
54+
target create $_CHIPNAME.m4 cortex_m -chain-position $_CHIPNAME.m4
55+
target create $_CHIPNAME.m0 cortex_m -chain-position $_CHIPNAME.m0
56+
57+
set _WORKAREASIZE 0x8000
58+
$_CHIPNAME.m4 configure -work-area-phys 0x10000000 -work-area-size $_WORKAREASIZE
59+
60+
set _FLASHNAME $_CHIPNAME.flash
61+
flash bank $_FLASHNAME lpc2000 0x1a000000 0x80000 0 0 $_CHIPNAME.m4 lpc4300 96000 calc_checksum
62+
63+
reset_config none
64+
cortex_m reset_config vectreset
65+
66+
targets $_CHIPNAME.m4
67+
68+
$_CHIPNAME.m4 configure -event gdb-attach {
69+
echo "Reset Halt, due to gdb attached...!"
70+
reset halt
71+
}
72+
73+
init
74+
75+
proc lpc_flash { BIN } {
76+
init
77+
halt 0
78+
flash write_image erase unlock $BIN 0x1a000000 bin
79+
reset run
80+
shutdown
81+
}
Lines changed: 141 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,141 @@
1+
#include "board.h"
2+
3+
#include <stdint.h>
4+
5+
/* System configuration variables used by chip driver */
6+
const uint32_t ExtRateIn = 0;
7+
const uint32_t OscRateIn = 12000000;
8+
9+
/* Structure for initial base clock states */
10+
struct CLK_BASE_STATES {
11+
CHIP_CGU_BASE_CLK_T clk; /* Base clock */
12+
CHIP_CGU_CLKIN_T clkin; /* Base clock source, see UM for allowable souorces per base clock */
13+
bool autoblock_enab;/* Set to true to enable autoblocking on frequency change */
14+
bool powerdn; /* Set to true if the base clock is initially powered down */
15+
};
16+
17+
/* Initial base clock states are mostly on */
18+
STATIC const struct CLK_BASE_STATES InitClkStates[] = {
19+
{CLK_BASE_PHY_TX, CLKIN_ENET_TX, true, false},
20+
#if defined(USE_RMII)
21+
{CLK_BASE_PHY_RX, CLKIN_ENET_TX, true, false},
22+
#else
23+
{CLK_BASE_PHY_RX, CLKIN_ENET_RX, true, false},
24+
#endif
25+
26+
/* Clocks derived from dividers */
27+
{CLK_BASE_LCD, CLKIN_IDIVC, true, false},
28+
{CLK_BASE_USB1, CLKIN_IDIVD, true, true}
29+
};
30+
31+
/* SPIFI high speed pin mode setup */
32+
STATIC const PINMUX_GRP_T spifipinmuxing[] = {
33+
{0x3, 3, (SCU_PINIO_FAST | SCU_MODE_FUNC3)}, /* SPIFI CLK */
34+
{0x3, 4, (SCU_PINIO_FAST | SCU_MODE_FUNC3)}, /* SPIFI D3 */
35+
{0x3, 5, (SCU_PINIO_FAST | SCU_MODE_FUNC3)}, /* SPIFI D2 */
36+
{0x3, 6, (SCU_PINIO_FAST | SCU_MODE_FUNC3)}, /* SPIFI D1 */
37+
{0x3, 7, (SCU_PINIO_FAST | SCU_MODE_FUNC3)}, /* SPIFI D0 */
38+
{0x3, 8, (SCU_PINIO_FAST | SCU_MODE_FUNC3)} /* SPIFI CS/SSEL */
39+
};
40+
41+
STATIC const PINMUX_GRP_T pinmuxing[] = {
42+
/* RMII pin group */
43+
{0x1, 15, (SCU_MODE_HIGHSPEEDSLEW_EN | SCU_MODE_INACT | SCU_MODE_INBUFF_EN | SCU_MODE_ZIF_DIS | SCU_MODE_FUNC3)},
44+
{0x0, 0, (SCU_MODE_HIGHSPEEDSLEW_EN | SCU_MODE_INACT | SCU_MODE_INBUFF_EN | SCU_MODE_ZIF_DIS | SCU_MODE_FUNC2)},
45+
{0x1, 16, (SCU_MODE_HIGHSPEEDSLEW_EN | SCU_MODE_INACT | SCU_MODE_INBUFF_EN | SCU_MODE_ZIF_DIS | SCU_MODE_FUNC7)},
46+
{0x0, 1, (SCU_MODE_HIGHSPEEDSLEW_EN | SCU_MODE_INACT | SCU_MODE_ZIF_DIS | SCU_MODE_FUNC6)},
47+
{0x1, 19, (SCU_MODE_HIGHSPEEDSLEW_EN | SCU_MODE_INACT | SCU_MODE_INBUFF_EN | SCU_MODE_ZIF_DIS | SCU_MODE_FUNC0)},
48+
{0x1, 18, (SCU_MODE_HIGHSPEEDSLEW_EN | SCU_MODE_INACT | SCU_MODE_ZIF_DIS | SCU_MODE_FUNC3)},
49+
{0x1, 20, (SCU_MODE_HIGHSPEEDSLEW_EN | SCU_MODE_INACT | SCU_MODE_ZIF_DIS | SCU_MODE_FUNC3)},
50+
{0x1, 17, (SCU_MODE_HIGHSPEEDSLEW_EN | SCU_MODE_INACT | SCU_MODE_INBUFF_EN | SCU_MODE_ZIF_DIS | SCU_MODE_FUNC3)},
51+
{0x2, 0, (SCU_MODE_HIGHSPEEDSLEW_EN | SCU_MODE_INACT | SCU_MODE_ZIF_DIS | SCU_MODE_FUNC7)},
52+
/* Board LEDs */
53+
{0x2, 11, (SCU_MODE_INBUFF_EN | SCU_MODE_PULLDOWN | SCU_MODE_FUNC0)},
54+
{0x2, 12, (SCU_MODE_INBUFF_EN | SCU_MODE_PULLDOWN | SCU_MODE_FUNC0)},
55+
/* I2S */
56+
{0x3, 0, (SCU_PINIO_FAST | SCU_MODE_FUNC2)},
57+
{0x6, 0, (SCU_PINIO_FAST | SCU_MODE_FUNC4)},
58+
{0x7, 2, (SCU_PINIO_FAST | SCU_MODE_FUNC2)},
59+
{0x6, 2, (SCU_PINIO_FAST | SCU_MODE_FUNC3)},
60+
{0x7, 1, (SCU_PINIO_FAST | SCU_MODE_FUNC2)},
61+
{0x6, 1, (SCU_PINIO_FAST | SCU_MODE_FUNC3)},
62+
};
63+
64+
void Board_UART_Init(LPC_USART_T *pUART)
65+
{
66+
Chip_SCU_PinMuxSet(0x2, 10, (SCU_MODE_PULLDOWN | SCU_MODE_FUNC2)); /* P2.10 : UART2_TXD */
67+
Chip_SCU_PinMuxSet(0x2, 11, (SCU_MODE_INACT | SCU_MODE_INBUFF_EN | SCU_MODE_ZIF_DIS | SCU_MODE_FUNC2)); /* P2.11 : UART2_RX */
68+
}
69+
70+
/* Initialize debug output via UART for board */
71+
void Board_Debug_Init(void)
72+
{
73+
Board_UART_Init(CONSOLE_UART);
74+
75+
Chip_UART_Init(CONSOLE_UART);
76+
Chip_UART_SetBaudFDR(CONSOLE_UART, 115200);
77+
Chip_UART_ConfigData(CONSOLE_UART, UART_LCR_WLEN8 | UART_LCR_SBS_1BIT | UART_LCR_PARITY_DIS);
78+
/* Enable UART Transmit */
79+
Chip_UART_TXEnable(CONSOLE_UART);
80+
}
81+
82+
/* Set up and initialize all required blocks and functions related to the
83+
board hardware */
84+
void Board_Init(void)
85+
{
86+
/* Sets up DEBUG UART */
87+
Board_Debug_Init();
88+
89+
/* Initializes GPIO */
90+
Chip_GPIO_Init(LPC_GPIO_PORT);
91+
}
92+
93+
/* Sets up system pin muxing */
94+
void Board_SetupMuxing(void)
95+
{
96+
/* Setup system level pin muxing */
97+
Chip_SCU_SetPinMuxing(pinmuxing, sizeof(pinmuxing) / sizeof(PINMUX_GRP_T));
98+
99+
/* SPIFI pin setup is done prior to setting up system clocking */
100+
Chip_SCU_SetPinMuxing(spifipinmuxing, sizeof(spifipinmuxing) / sizeof(PINMUX_GRP_T));
101+
}
102+
103+
/* Set up and initialize clocking prior to call to main */
104+
void Board_SetupClocking(void)
105+
{
106+
int i;
107+
108+
Chip_SetupCoreClock(CLKIN_CRYSTAL, MAX_CLOCK_FREQ, true);
109+
110+
/* Reset and enable 32Khz oscillator */
111+
LPC_CREG->CREG0 &= ~((1 << 3) | (1 << 2));
112+
LPC_CREG->CREG0 |= (1 << 1) | (1 << 0);
113+
114+
/* Setup a divider E for main PLL clock switch SPIFI clock to that divider.
115+
Divide rate is based on CPU speed and speed of SPI FLASH part. */
116+
#if (MAX_CLOCK_FREQ > 180000000)
117+
Chip_Clock_SetDivider(CLK_IDIV_E, CLKIN_MAINPLL, 5);
118+
#else
119+
Chip_Clock_SetDivider(CLK_IDIV_E, CLKIN_MAINPLL, 4);
120+
#endif
121+
Chip_Clock_SetBaseClock(CLK_BASE_SPIFI, CLKIN_IDIVE, true, false);
122+
123+
/* Setup system base clocks and initial states. This won't enable and
124+
disable individual clocks, but sets up the base clock sources for
125+
each individual peripheral clock. */
126+
for (i = 0; i < (sizeof(InitClkStates) / sizeof(InitClkStates[0])); i++) {
127+
Chip_Clock_SetBaseClock(InitClkStates[i].clk, InitClkStates[i].clkin,
128+
InitClkStates[i].autoblock_enab, InitClkStates[i].powerdn);
129+
}
130+
}
131+
132+
/* Set up and initialize hardware prior to call to main */
133+
void Board_SystemInit(void)
134+
{
135+
/* Setup system clocking and memory. This is done early to allow the
136+
application and tools to clear memory and use scatter loading to
137+
external memory. */
138+
fpuInit();
139+
Board_SetupMuxing();
140+
Board_SetupClocking();
141+
}

0 commit comments

Comments
 (0)
0