mirror of
https://github.com/hathach/tinyusb.git
synced 2025-01-17 05:32:55 +08:00
400 lines
18 KiB
C
400 lines
18 KiB
C
|
/**************************************************************************/
|
||
|
/*!
|
||
|
@file board_mcb1800.c
|
||
|
@author hathach (tinyusb.org)
|
||
|
|
||
|
@section LICENSE
|
||
|
|
||
|
Software License Agreement (BSD License)
|
||
|
|
||
|
Copyright (c) 2018, hathach (tinyusb.org)
|
||
|
All rights reserved.
|
||
|
|
||
|
Redistribution and use in source and binary forms, with or without
|
||
|
modification, are permitted provided that the following conditions are met:
|
||
|
1. Redistributions of source code must retain the above copyright
|
||
|
notice, this list of conditions and the following disclaimer.
|
||
|
2. Redistributions in binary form must reproduce the above copyright
|
||
|
notice, this list of conditions and the following disclaimer in the
|
||
|
documentation and/or other materials provided with the distribution.
|
||
|
3. Neither the name of the copyright holders nor the
|
||
|
names of its contributors may be used to endorse or promote products
|
||
|
derived from this software without specific prior written permission.
|
||
|
|
||
|
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ''AS IS'' AND ANY
|
||
|
EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||
|
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||
|
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER BE LIABLE FOR ANY
|
||
|
DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
||
|
(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||
|
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
|
||
|
ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||
|
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||
|
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||
|
|
||
|
This file is part of the tinyusb stack.
|
||
|
*/
|
||
|
/**************************************************************************/
|
||
|
|
||
|
#ifdef BOARD_MCB1800
|
||
|
|
||
|
#include "../board.h"
|
||
|
#include "tusb.h"
|
||
|
|
||
|
#define LED_PORT 6
|
||
|
#define LED_PIN 24
|
||
|
|
||
|
//--------------------------------------------------------------------+
|
||
|
// MACRO TYPEDEF CONSTANT ENUM DECLARATION
|
||
|
//--------------------------------------------------------------------+
|
||
|
/* System configuration variables used by chip driver */
|
||
|
const uint32_t ExtRateIn = 0;
|
||
|
const uint32_t OscRateIn = 12000000;
|
||
|
|
||
|
STATIC const PINMUX_GRP_T pinmuxing[] = {
|
||
|
/* RMII pin group */
|
||
|
{0x1, 19,
|
||
|
(SCU_MODE_HIGHSPEEDSLEW_EN | SCU_MODE_INACT | SCU_MODE_INBUFF_EN | SCU_MODE_ZIF_DIS | SCU_MODE_FUNC0)},
|
||
|
{0x0, 1, (SCU_MODE_HIGHSPEEDSLEW_EN | SCU_MODE_INACT | SCU_MODE_ZIF_DIS | SCU_MODE_FUNC6)},
|
||
|
{0x1, 18, (SCU_MODE_HIGHSPEEDSLEW_EN | SCU_MODE_INACT | SCU_MODE_ZIF_DIS | SCU_MODE_FUNC3)},
|
||
|
{0x1, 20, (SCU_MODE_HIGHSPEEDSLEW_EN | SCU_MODE_INACT | SCU_MODE_ZIF_DIS | SCU_MODE_FUNC3)},
|
||
|
{0x1, 17,
|
||
|
(SCU_MODE_HIGHSPEEDSLEW_EN | SCU_MODE_INACT | SCU_MODE_INBUFF_EN | SCU_MODE_ZIF_DIS | SCU_MODE_FUNC3)},
|
||
|
{0xC, 1, (SCU_MODE_HIGHSPEEDSLEW_EN | SCU_MODE_INACT | SCU_MODE_ZIF_DIS | SCU_MODE_FUNC3)},
|
||
|
{0x1, 16,
|
||
|
(SCU_MODE_HIGHSPEEDSLEW_EN | SCU_MODE_INACT | SCU_MODE_INBUFF_EN | SCU_MODE_ZIF_DIS | SCU_MODE_FUNC7)},
|
||
|
{0x1, 15,
|
||
|
(SCU_MODE_HIGHSPEEDSLEW_EN | SCU_MODE_INACT | SCU_MODE_INBUFF_EN | SCU_MODE_ZIF_DIS | SCU_MODE_FUNC3)},
|
||
|
{0x0, 0,
|
||
|
(SCU_MODE_HIGHSPEEDSLEW_EN | SCU_MODE_INACT | SCU_MODE_INBUFF_EN | SCU_MODE_ZIF_DIS | SCU_MODE_FUNC2)},
|
||
|
/* External data lines D0 .. D15 */
|
||
|
{0x1, 7,
|
||
|
(SCU_MODE_INACT | SCU_MODE_INBUFF_EN | SCU_MODE_ZIF_DIS | SCU_MODE_HIGHSPEEDSLEW_EN | SCU_MODE_FUNC3)},
|
||
|
{0x1, 8,
|
||
|
(SCU_MODE_INACT | SCU_MODE_INBUFF_EN | SCU_MODE_ZIF_DIS | SCU_MODE_HIGHSPEEDSLEW_EN | SCU_MODE_FUNC3)},
|
||
|
{0x1, 9,
|
||
|
(SCU_MODE_INACT | SCU_MODE_INBUFF_EN | SCU_MODE_ZIF_DIS | SCU_MODE_HIGHSPEEDSLEW_EN | SCU_MODE_FUNC3)},
|
||
|
{0x1, 10,
|
||
|
(SCU_MODE_INACT | SCU_MODE_INBUFF_EN | SCU_MODE_ZIF_DIS | SCU_MODE_HIGHSPEEDSLEW_EN | SCU_MODE_FUNC3)},
|
||
|
{0x1, 11,
|
||
|
(SCU_MODE_INACT | SCU_MODE_INBUFF_EN | SCU_MODE_ZIF_DIS | SCU_MODE_HIGHSPEEDSLEW_EN | SCU_MODE_FUNC3)},
|
||
|
{0x1, 12,
|
||
|
(SCU_MODE_INACT | SCU_MODE_INBUFF_EN | SCU_MODE_ZIF_DIS | SCU_MODE_HIGHSPEEDSLEW_EN | SCU_MODE_FUNC3)},
|
||
|
{0x1, 13,
|
||
|
(SCU_MODE_INACT | SCU_MODE_INBUFF_EN | SCU_MODE_ZIF_DIS | SCU_MODE_HIGHSPEEDSLEW_EN | SCU_MODE_FUNC3)},
|
||
|
{0x1, 14,
|
||
|
(SCU_MODE_INACT | SCU_MODE_INBUFF_EN | SCU_MODE_ZIF_DIS | SCU_MODE_HIGHSPEEDSLEW_EN | SCU_MODE_FUNC3)},
|
||
|
{0x5, 4,
|
||
|
(SCU_MODE_INACT | SCU_MODE_INBUFF_EN | SCU_MODE_ZIF_DIS | SCU_MODE_HIGHSPEEDSLEW_EN | SCU_MODE_FUNC2)},
|
||
|
{0x5, 5,
|
||
|
(SCU_MODE_INACT | SCU_MODE_INBUFF_EN | SCU_MODE_ZIF_DIS | SCU_MODE_HIGHSPEEDSLEW_EN | SCU_MODE_FUNC2)},
|
||
|
{0x5, 6,
|
||
|
(SCU_MODE_INACT | SCU_MODE_INBUFF_EN | SCU_MODE_ZIF_DIS | SCU_MODE_HIGHSPEEDSLEW_EN | SCU_MODE_FUNC2)},
|
||
|
{0x5, 7,
|
||
|
(SCU_MODE_INACT | SCU_MODE_INBUFF_EN | SCU_MODE_ZIF_DIS | SCU_MODE_HIGHSPEEDSLEW_EN | SCU_MODE_FUNC2)},
|
||
|
{0x5, 0,
|
||
|
(SCU_MODE_INACT | SCU_MODE_INBUFF_EN | SCU_MODE_ZIF_DIS | SCU_MODE_HIGHSPEEDSLEW_EN | SCU_MODE_FUNC2)},
|
||
|
{0x5, 1,
|
||
|
(SCU_MODE_INACT | SCU_MODE_INBUFF_EN | SCU_MODE_ZIF_DIS | SCU_MODE_HIGHSPEEDSLEW_EN | SCU_MODE_FUNC2)},
|
||
|
{0x5, 2,
|
||
|
(SCU_MODE_INACT | SCU_MODE_INBUFF_EN | SCU_MODE_ZIF_DIS | SCU_MODE_HIGHSPEEDSLEW_EN | SCU_MODE_FUNC2)},
|
||
|
{0x5, 3,
|
||
|
(SCU_MODE_INACT | SCU_MODE_INBUFF_EN | SCU_MODE_ZIF_DIS | SCU_MODE_HIGHSPEEDSLEW_EN | SCU_MODE_FUNC2)},
|
||
|
{0xD, 2,
|
||
|
(SCU_MODE_INACT | SCU_MODE_INBUFF_EN | SCU_MODE_ZIF_DIS | SCU_MODE_HIGHSPEEDSLEW_EN | SCU_MODE_FUNC2)},
|
||
|
{0xD, 3,
|
||
|
(SCU_MODE_INACT | SCU_MODE_INBUFF_EN | SCU_MODE_ZIF_DIS | SCU_MODE_HIGHSPEEDSLEW_EN | SCU_MODE_FUNC2)},
|
||
|
{0xD, 4,
|
||
|
(SCU_MODE_INACT | SCU_MODE_INBUFF_EN | SCU_MODE_ZIF_DIS | SCU_MODE_HIGHSPEEDSLEW_EN | SCU_MODE_FUNC2)},
|
||
|
{0xD, 5,
|
||
|
(SCU_MODE_INACT | SCU_MODE_INBUFF_EN | SCU_MODE_ZIF_DIS | SCU_MODE_HIGHSPEEDSLEW_EN | SCU_MODE_FUNC2)},
|
||
|
{0xD, 6,
|
||
|
(SCU_MODE_INACT | SCU_MODE_INBUFF_EN | SCU_MODE_ZIF_DIS | SCU_MODE_HIGHSPEEDSLEW_EN | SCU_MODE_FUNC2)},
|
||
|
{0xD, 7,
|
||
|
(SCU_MODE_INACT | SCU_MODE_INBUFF_EN | SCU_MODE_ZIF_DIS | SCU_MODE_HIGHSPEEDSLEW_EN | SCU_MODE_FUNC2)},
|
||
|
{0xD, 8,
|
||
|
(SCU_MODE_INACT | SCU_MODE_INBUFF_EN | SCU_MODE_ZIF_DIS | SCU_MODE_HIGHSPEEDSLEW_EN | SCU_MODE_FUNC2)},
|
||
|
{0xD, 9,
|
||
|
(SCU_MODE_INACT | SCU_MODE_INBUFF_EN | SCU_MODE_ZIF_DIS | SCU_MODE_HIGHSPEEDSLEW_EN | SCU_MODE_FUNC2)},
|
||
|
{0xE, 5,
|
||
|
(SCU_MODE_INACT | SCU_MODE_INBUFF_EN | SCU_MODE_ZIF_DIS | SCU_MODE_HIGHSPEEDSLEW_EN | SCU_MODE_FUNC3)},
|
||
|
{0xE, 6,
|
||
|
(SCU_MODE_INACT | SCU_MODE_INBUFF_EN | SCU_MODE_ZIF_DIS | SCU_MODE_HIGHSPEEDSLEW_EN | SCU_MODE_FUNC3)},
|
||
|
{0xE, 7,
|
||
|
(SCU_MODE_INACT | SCU_MODE_INBUFF_EN | SCU_MODE_ZIF_DIS | SCU_MODE_HIGHSPEEDSLEW_EN | SCU_MODE_FUNC3)},
|
||
|
{0xE, 8,
|
||
|
(SCU_MODE_INACT | SCU_MODE_INBUFF_EN | SCU_MODE_ZIF_DIS | SCU_MODE_HIGHSPEEDSLEW_EN | SCU_MODE_FUNC3)},
|
||
|
{0xE, 9,
|
||
|
(SCU_MODE_INACT | SCU_MODE_INBUFF_EN | SCU_MODE_ZIF_DIS | SCU_MODE_HIGHSPEEDSLEW_EN | SCU_MODE_FUNC3)},
|
||
|
{0xE, 10,
|
||
|
(SCU_MODE_INACT | SCU_MODE_INBUFF_EN | SCU_MODE_ZIF_DIS | SCU_MODE_HIGHSPEEDSLEW_EN | SCU_MODE_FUNC3)},
|
||
|
{0xE, 11,
|
||
|
(SCU_MODE_INACT | SCU_MODE_INBUFF_EN | SCU_MODE_ZIF_DIS | SCU_MODE_HIGHSPEEDSLEW_EN | SCU_MODE_FUNC3)},
|
||
|
{0xE, 12,
|
||
|
(SCU_MODE_INACT | SCU_MODE_INBUFF_EN | SCU_MODE_ZIF_DIS | SCU_MODE_HIGHSPEEDSLEW_EN | SCU_MODE_FUNC3)},
|
||
|
/* Address lines A0 .. A23 */
|
||
|
{0x2, 9,
|
||
|
(SCU_MODE_INACT | SCU_MODE_INBUFF_EN | SCU_MODE_ZIF_DIS | SCU_MODE_HIGHSPEEDSLEW_EN | SCU_MODE_FUNC3)},
|
||
|
{0x2, 10,
|
||
|
(SCU_MODE_INACT | SCU_MODE_INBUFF_EN | SCU_MODE_ZIF_DIS | SCU_MODE_HIGHSPEEDSLEW_EN | SCU_MODE_FUNC3)},
|
||
|
{0x2, 11,
|
||
|
(SCU_MODE_INACT | SCU_MODE_INBUFF_EN | SCU_MODE_ZIF_DIS | SCU_MODE_HIGHSPEEDSLEW_EN | SCU_MODE_FUNC3)},
|
||
|
{0x2, 12,
|
||
|
(SCU_MODE_INACT | SCU_MODE_INBUFF_EN | SCU_MODE_ZIF_DIS | SCU_MODE_HIGHSPEEDSLEW_EN | SCU_MODE_FUNC3)},
|
||
|
{0x2, 13,
|
||
|
(SCU_MODE_INACT | SCU_MODE_INBUFF_EN | SCU_MODE_ZIF_DIS | SCU_MODE_HIGHSPEEDSLEW_EN | SCU_MODE_FUNC3)},
|
||
|
{0x1, 0,
|
||
|
(SCU_MODE_INACT | SCU_MODE_INBUFF_EN | SCU_MODE_ZIF_DIS | SCU_MODE_HIGHSPEEDSLEW_EN | SCU_MODE_FUNC2)},
|
||
|
{0x1, 1,
|
||
|
(SCU_MODE_INACT | SCU_MODE_INBUFF_EN | SCU_MODE_ZIF_DIS | SCU_MODE_HIGHSPEEDSLEW_EN | SCU_MODE_FUNC2)},
|
||
|
{0x1, 2,
|
||
|
(SCU_MODE_INACT | SCU_MODE_INBUFF_EN | SCU_MODE_ZIF_DIS | SCU_MODE_HIGHSPEEDSLEW_EN | SCU_MODE_FUNC2)},
|
||
|
{0x2, 8,
|
||
|
(SCU_MODE_INACT | SCU_MODE_INBUFF_EN | SCU_MODE_ZIF_DIS | SCU_MODE_HIGHSPEEDSLEW_EN | SCU_MODE_FUNC3)},
|
||
|
{0x2, 7,
|
||
|
(SCU_MODE_INACT | SCU_MODE_INBUFF_EN | SCU_MODE_ZIF_DIS | SCU_MODE_HIGHSPEEDSLEW_EN | SCU_MODE_FUNC3)},
|
||
|
{0x2, 6,
|
||
|
(SCU_MODE_INACT | SCU_MODE_INBUFF_EN | SCU_MODE_ZIF_DIS | SCU_MODE_HIGHSPEEDSLEW_EN | SCU_MODE_FUNC2)},
|
||
|
{0x2, 2,
|
||
|
(SCU_MODE_INACT | SCU_MODE_INBUFF_EN | SCU_MODE_ZIF_DIS | SCU_MODE_HIGHSPEEDSLEW_EN | SCU_MODE_FUNC2)},
|
||
|
{0x2, 1,
|
||
|
(SCU_MODE_INACT | SCU_MODE_INBUFF_EN | SCU_MODE_ZIF_DIS | SCU_MODE_HIGHSPEEDSLEW_EN | SCU_MODE_FUNC2)},
|
||
|
{0x2, 0,
|
||
|
(SCU_MODE_INACT | SCU_MODE_INBUFF_EN | SCU_MODE_ZIF_DIS | SCU_MODE_HIGHSPEEDSLEW_EN | SCU_MODE_FUNC2)},
|
||
|
{0x6, 8,
|
||
|
(SCU_MODE_INACT | SCU_MODE_INBUFF_EN | SCU_MODE_ZIF_DIS | SCU_MODE_HIGHSPEEDSLEW_EN | SCU_MODE_FUNC1)},
|
||
|
{0x6, 7,
|
||
|
(SCU_MODE_INACT | SCU_MODE_INBUFF_EN | SCU_MODE_ZIF_DIS | SCU_MODE_HIGHSPEEDSLEW_EN | SCU_MODE_FUNC1)},
|
||
|
{0xD, 16,
|
||
|
(SCU_MODE_INACT | SCU_MODE_INBUFF_EN | SCU_MODE_ZIF_DIS | SCU_MODE_HIGHSPEEDSLEW_EN | SCU_MODE_FUNC2)},
|
||
|
{0xD, 15,
|
||
|
(SCU_MODE_INACT | SCU_MODE_INBUFF_EN | SCU_MODE_ZIF_DIS | SCU_MODE_HIGHSPEEDSLEW_EN | SCU_MODE_FUNC2)},
|
||
|
{0xE, 0,
|
||
|
(SCU_MODE_INACT | SCU_MODE_INBUFF_EN | SCU_MODE_ZIF_DIS | SCU_MODE_HIGHSPEEDSLEW_EN | SCU_MODE_FUNC3)},
|
||
|
{0xE, 1,
|
||
|
(SCU_MODE_INACT | SCU_MODE_INBUFF_EN | SCU_MODE_ZIF_DIS | SCU_MODE_HIGHSPEEDSLEW_EN | SCU_MODE_FUNC3)},
|
||
|
{0xE, 2,
|
||
|
(SCU_MODE_INACT | SCU_MODE_INBUFF_EN | SCU_MODE_ZIF_DIS | SCU_MODE_HIGHSPEEDSLEW_EN | SCU_MODE_FUNC3)},
|
||
|
{0xE, 3,
|
||
|
(SCU_MODE_INACT | SCU_MODE_INBUFF_EN | SCU_MODE_ZIF_DIS | SCU_MODE_HIGHSPEEDSLEW_EN | SCU_MODE_FUNC3)},
|
||
|
{0xE, 4,
|
||
|
(SCU_MODE_INACT | SCU_MODE_INBUFF_EN | SCU_MODE_ZIF_DIS | SCU_MODE_HIGHSPEEDSLEW_EN | SCU_MODE_FUNC3)},
|
||
|
{0xA, 4,
|
||
|
(SCU_MODE_INACT | SCU_MODE_INBUFF_EN | SCU_MODE_ZIF_DIS | SCU_MODE_HIGHSPEEDSLEW_EN | SCU_MODE_FUNC3)},
|
||
|
/* EMC control signals */
|
||
|
{0x1, 4,
|
||
|
(SCU_MODE_INACT | SCU_MODE_INBUFF_EN | SCU_MODE_ZIF_DIS | SCU_MODE_HIGHSPEEDSLEW_EN | SCU_MODE_FUNC3)},
|
||
|
{0x6, 6,
|
||
|
(SCU_MODE_INACT | SCU_MODE_INBUFF_EN | SCU_MODE_ZIF_DIS | SCU_MODE_HIGHSPEEDSLEW_EN | SCU_MODE_FUNC1)},
|
||
|
{0xD, 13,
|
||
|
(SCU_MODE_INACT | SCU_MODE_INBUFF_EN | SCU_MODE_ZIF_DIS | SCU_MODE_HIGHSPEEDSLEW_EN | SCU_MODE_FUNC2)},
|
||
|
{0xD, 10,
|
||
|
(SCU_MODE_INACT | SCU_MODE_INBUFF_EN | SCU_MODE_ZIF_DIS | SCU_MODE_HIGHSPEEDSLEW_EN | SCU_MODE_FUNC2)},
|
||
|
{0x6, 9,
|
||
|
(SCU_MODE_INACT | SCU_MODE_INBUFF_EN | SCU_MODE_ZIF_DIS | SCU_MODE_HIGHSPEEDSLEW_EN | SCU_MODE_FUNC3)},
|
||
|
{0x1, 6,
|
||
|
(SCU_MODE_INACT | SCU_MODE_INBUFF_EN | SCU_MODE_ZIF_DIS | SCU_MODE_HIGHSPEEDSLEW_EN | SCU_MODE_FUNC3)},
|
||
|
{0x6, 4,
|
||
|
(SCU_MODE_INACT | SCU_MODE_INBUFF_EN | SCU_MODE_ZIF_DIS | SCU_MODE_HIGHSPEEDSLEW_EN | SCU_MODE_FUNC3)},
|
||
|
{0x6, 5,
|
||
|
(SCU_MODE_INACT | SCU_MODE_INBUFF_EN | SCU_MODE_ZIF_DIS | SCU_MODE_HIGHSPEEDSLEW_EN | SCU_MODE_FUNC3)},
|
||
|
{0x6, 11,
|
||
|
(SCU_MODE_INACT | SCU_MODE_INBUFF_EN | SCU_MODE_ZIF_DIS | SCU_MODE_HIGHSPEEDSLEW_EN | SCU_MODE_FUNC3)},
|
||
|
{0x6, 12,
|
||
|
(SCU_MODE_INACT | SCU_MODE_INBUFF_EN | SCU_MODE_ZIF_DIS | SCU_MODE_HIGHSPEEDSLEW_EN | SCU_MODE_FUNC3)},
|
||
|
{0x6, 10,
|
||
|
(SCU_MODE_INACT | SCU_MODE_INBUFF_EN | SCU_MODE_ZIF_DIS | SCU_MODE_HIGHSPEEDSLEW_EN | SCU_MODE_FUNC3)},
|
||
|
{0xD, 0,
|
||
|
(SCU_MODE_INACT | SCU_MODE_INBUFF_EN | SCU_MODE_ZIF_DIS | SCU_MODE_HIGHSPEEDSLEW_EN | SCU_MODE_FUNC2)},
|
||
|
{0xE, 13,
|
||
|
(SCU_MODE_INACT | SCU_MODE_INBUFF_EN | SCU_MODE_ZIF_DIS | SCU_MODE_HIGHSPEEDSLEW_EN | SCU_MODE_FUNC3)},
|
||
|
{0x1, 3, (SCU_PINIO_FAST | SCU_MODE_FUNC3)},
|
||
|
{0x1, 4, (SCU_PINIO_FAST | SCU_MODE_FUNC3)},
|
||
|
{0x6, 6, (SCU_PINIO_FAST | SCU_MODE_FUNC1)},
|
||
|
{0x1, 5, (SCU_PINIO_FAST | SCU_MODE_FUNC3)},
|
||
|
{0x1, 6, (SCU_PINIO_FAST | SCU_MODE_FUNC3)},
|
||
|
/* Board LEDs */
|
||
|
{0xD, 10, (SCU_MODE_INBUFF_EN | SCU_MODE_INACT | SCU_MODE_FUNC4)},
|
||
|
{0xD, 11, (SCU_MODE_INBUFF_EN | SCU_MODE_INACT | SCU_MODE_FUNC4)},
|
||
|
{0xD, 12, (SCU_MODE_INBUFF_EN | SCU_MODE_INACT | SCU_MODE_FUNC4)},
|
||
|
{0xD, 13, (SCU_MODE_INBUFF_EN | SCU_MODE_INACT | SCU_MODE_FUNC4)},
|
||
|
{0xD, 14, (SCU_MODE_INBUFF_EN | SCU_MODE_INACT | SCU_MODE_FUNC4)},
|
||
|
{0x9, 0, (SCU_MODE_INBUFF_EN | SCU_MODE_INACT | SCU_MODE_FUNC0)},
|
||
|
{0x9, 1, (SCU_MODE_INBUFF_EN | SCU_MODE_INACT | SCU_MODE_FUNC0)},
|
||
|
{0x9, 2, (SCU_MODE_INBUFF_EN | SCU_MODE_INACT | SCU_MODE_FUNC0)},
|
||
|
/* SSP0 */
|
||
|
{0xF, 0, (SCU_PINIO_FAST | SCU_MODE_FUNC0)},
|
||
|
{0xF, 1, (SCU_PINIO_FAST | SCU_MODE_FUNC4)},
|
||
|
{0xF, 2, (SCU_PINIO_FAST | SCU_MODE_FUNC2)},
|
||
|
{0xF, 3, (SCU_PINIO_FAST | SCU_MODE_FUNC2)},
|
||
|
/* LCD interface, 16bpp */
|
||
|
{0x4, 1, ( SCU_MODE_PULLUP | SCU_MODE_FUNC5)},
|
||
|
{0x4, 2, ( SCU_MODE_PULLUP | SCU_MODE_FUNC2)},
|
||
|
{0x4, 5, ( SCU_MODE_PULLUP | SCU_MODE_FUNC2)},
|
||
|
{0x4, 6, ( SCU_MODE_PULLUP | SCU_MODE_FUNC2)},
|
||
|
{0x4, 7, ( SCU_MODE_PULLUP | SCU_MODE_FUNC0)},
|
||
|
{0x4, 9, ( SCU_MODE_PULLUP | SCU_MODE_FUNC2)},
|
||
|
{0x4, 10, (SCU_MODE_PULLUP | SCU_MODE_FUNC2)},
|
||
|
{0x7, 0, ( SCU_MODE_PULLUP | SCU_MODE_FUNC0)},
|
||
|
{0x7, 6, ( SCU_MODE_PULLUP | SCU_MODE_FUNC3)},
|
||
|
{0x8, 3, ( SCU_MODE_PULLUP | SCU_MODE_FUNC3)},
|
||
|
{0x8, 4, ( SCU_MODE_PULLUP | SCU_MODE_FUNC3)},
|
||
|
{0x8, 5, ( SCU_MODE_PULLUP | SCU_MODE_FUNC3)},
|
||
|
{0x8, 6, ( SCU_MODE_PULLUP | SCU_MODE_FUNC3)},
|
||
|
{0x8, 7, ( SCU_MODE_PULLUP | SCU_MODE_FUNC3)},
|
||
|
{0xB, 0, ( SCU_MODE_PULLUP | SCU_MODE_FUNC2)},
|
||
|
{0xB, 1, ( SCU_MODE_PULLUP | SCU_MODE_FUNC2)},
|
||
|
{0xB, 2, ( SCU_MODE_PULLUP | SCU_MODE_FUNC2)},
|
||
|
{0xB, 3, ( SCU_MODE_PULLUP | SCU_MODE_FUNC2)},
|
||
|
{0xB, 4, ( SCU_MODE_PULLUP | SCU_MODE_FUNC2)},
|
||
|
{0xB, 5, ( SCU_MODE_PULLUP | SCU_MODE_FUNC2)},
|
||
|
{0xB, 6, ( SCU_MODE_PULLUP | SCU_MODE_FUNC2)},
|
||
|
/* I2S */
|
||
|
{0x3, 0, (SCU_PINIO_FAST | SCU_MODE_FUNC2)},
|
||
|
{0x6, 0, (SCU_PINIO_FAST | SCU_MODE_FUNC4)},
|
||
|
{0x7, 2, (SCU_PINIO_FAST | SCU_MODE_FUNC2)},
|
||
|
{0x6, 2, (SCU_PINIO_FAST | SCU_MODE_FUNC3)},
|
||
|
{0x7, 1, (SCU_PINIO_FAST | SCU_MODE_FUNC2)},
|
||
|
{0x6, 1, (SCU_PINIO_FAST | SCU_MODE_FUNC3)},
|
||
|
/* CCAN */
|
||
|
{0x3, 2, (SCU_MODE_INACT | SCU_MODE_FUNC2)}, /* PE.3 CAN TD1 | SCU_MODE_FUNC1) */
|
||
|
{0x3, 1, (SCU_MODE_INACT | SCU_MODE_INBUFF_EN | SCU_MODE_FUNC2)}, /* PE.2 CAN RD1 | SCU_MODE_FUNC1) */
|
||
|
};
|
||
|
|
||
|
|
||
|
/* Pin clock mux values, re-used structure, value in first index is meaningless */
|
||
|
STATIC const PINMUX_GRP_T pinclockmuxing[] = {
|
||
|
{0, 0, (SCU_MODE_INACT | SCU_MODE_INBUFF_EN | SCU_MODE_ZIF_DIS | SCU_MODE_HIGHSPEEDSLEW_EN | SCU_MODE_FUNC0)},
|
||
|
{0, 1, (SCU_MODE_INACT | SCU_MODE_INBUFF_EN | SCU_MODE_ZIF_DIS | SCU_MODE_HIGHSPEEDSLEW_EN | SCU_MODE_FUNC0)},
|
||
|
{0, 2, (SCU_MODE_INACT | SCU_MODE_INBUFF_EN | SCU_MODE_ZIF_DIS | SCU_MODE_HIGHSPEEDSLEW_EN | SCU_MODE_FUNC0)},
|
||
|
{0, 3, (SCU_MODE_INACT | SCU_MODE_INBUFF_EN | SCU_MODE_ZIF_DIS | SCU_MODE_HIGHSPEEDSLEW_EN | SCU_MODE_FUNC0)},
|
||
|
};
|
||
|
|
||
|
|
||
|
/*------------------------------------------------------------------*/
|
||
|
/* BOARD API
|
||
|
*------------------------------------------------------------------*/
|
||
|
// Invoked by startup code
|
||
|
void SystemInit(void)
|
||
|
{
|
||
|
/* Setup system level pin muxing */
|
||
|
Chip_SCU_SetPinMuxing(pinmuxing, sizeof(pinmuxing) / sizeof(PINMUX_GRP_T));
|
||
|
|
||
|
/* Clock pins only, group field not used */
|
||
|
for (int i = 0; i < (sizeof(pinclockmuxing) / sizeof(pinclockmuxing[0])); i++)
|
||
|
{
|
||
|
Chip_SCU_ClockPinMuxSet(pinclockmuxing[i].pinnum, pinclockmuxing[i].modefunc);
|
||
|
}
|
||
|
|
||
|
Chip_SetupXtalClocking();
|
||
|
}
|
||
|
|
||
|
void board_init(void)
|
||
|
{
|
||
|
SystemCoreClockUpdate();
|
||
|
|
||
|
#if CFG_TUSB_OS == OPT_OS_NONE
|
||
|
SysTick_Config( SystemCoreClock / BOARD_TICKS_HZ );
|
||
|
#endif
|
||
|
|
||
|
Chip_GPIO_Init(LPC_GPIO_PORT);
|
||
|
|
||
|
//------------- LED -------------//
|
||
|
/* Port and bit mapping for LEDs on GPIOs */
|
||
|
const uint8_t ledports[] = {6, 6, 6, 6, 6, 4, 4, 4};
|
||
|
const uint8_t ledbits[] = {24, 25, 26, 27, 28, 12, 13, 14};
|
||
|
|
||
|
for (int i = 0; i < (sizeof(ledports) / sizeof(ledports[0])); i++)
|
||
|
{
|
||
|
Chip_GPIO_SetPinDIROutput(LPC_GPIO_PORT, ledports[i], ledbits[i]);
|
||
|
Chip_GPIO_SetPinState(LPC_GPIO_PORT, LED_PORT, LED_PIN, false);
|
||
|
}
|
||
|
|
||
|
#if 0
|
||
|
//------------- BUTTON -------------//
|
||
|
for(uint8_t i=0; i<BOARD_BUTTON_COUNT; i++)
|
||
|
{
|
||
|
scu_pinmux(buttons[i].mux_port, buttons[i].mux_pin, GPIO_NOPULL, FUNC0);
|
||
|
GPIO_SetDir(buttons[i].gpio_port, BIT_(buttons[i].gpio_pin), 0);
|
||
|
}
|
||
|
|
||
|
//------------- UART -------------//
|
||
|
scu_pinmux(BOARD_UART_PIN_PORT, BOARD_UART_PIN_TX, MD_PDN, FUNC1);
|
||
|
scu_pinmux(BOARD_UART_PIN_PORT, BOARD_UART_PIN_RX, MD_PLN | MD_EZI | MD_ZI, FUNC1);
|
||
|
|
||
|
UART_CFG_Type UARTConfigStruct;
|
||
|
UART_ConfigStructInit(&UARTConfigStruct);
|
||
|
UARTConfigStruct.Baud_rate = CFG_UART_BAUDRATE;
|
||
|
UARTConfigStruct.Clock_Speed = 0;
|
||
|
|
||
|
UART_Init(BOARD_UART_PORT, &UARTConfigStruct);
|
||
|
UART_TxCmd(BOARD_UART_PORT, ENABLE); // Enable UART Transmit
|
||
|
#endif
|
||
|
|
||
|
//------------- USB -------------//
|
||
|
// USB0 Vbus Power: P2_3 on EA4357 channel B U20 GPIO26 active low (base board)
|
||
|
Chip_SCU_PinMuxSet(2, 3, SCU_MODE_PULLUP | SCU_MODE_INBUFF_EN | SCU_MODE_FUNC7);
|
||
|
|
||
|
#if CFG_TUSB_RHPORT0_MODE & OPT_MODE_DEVICE
|
||
|
// P9_5 (GPIO5[18]) (GPIO28 on oem base) as USB connect, active low.
|
||
|
Chip_SCU_PinMuxSet(9, 5, SCU_MODE_PULLDOWN | SCU_MODE_FUNC4);
|
||
|
Chip_GPIO_SetPinDIROutput(LPC_GPIO_PORT, 5, 18);
|
||
|
#endif
|
||
|
|
||
|
// USB1 Power: EA4357 channel A U20 is enabled by SJ5 connected to pad 1-2, no more action required
|
||
|
// TODO Remove R170, R171, solder a pair of 15K to USB1 D+/D- to test with USB1 Host
|
||
|
}
|
||
|
|
||
|
void board_led_control(bool state)
|
||
|
{
|
||
|
Chip_GPIO_SetPinState(LPC_GPIO_PORT, LED_PORT, LED_PIN, state);
|
||
|
}
|
||
|
|
||
|
//------------- Buttons -------------//
|
||
|
static bool button_read(uint8_t id)
|
||
|
{
|
||
|
// return !BIT_TEST_( GPIO_ReadValue(buttons[id].gpio_port), buttons[id].gpio_pin ); // button is active low
|
||
|
}
|
||
|
|
||
|
uint32_t board_buttons(void)
|
||
|
{
|
||
|
uint32_t result = 0;
|
||
|
|
||
|
// for(uint8_t i=0; i<BOARD_BUTTON_COUNT; i++) result |= (button_read(i) ? BIT_(i) : 0);
|
||
|
|
||
|
return result;
|
||
|
}
|
||
|
|
||
|
|
||
|
//------------- UART -------------//
|
||
|
uint8_t board_uart_getchar(void)
|
||
|
{
|
||
|
//return UART_ReceiveByte(BOARD_UART_PORT);
|
||
|
}
|
||
|
void board_uart_putchar(uint8_t c)
|
||
|
{
|
||
|
//UART_Send(BOARD_UART_PORT, &c, 1, BLOCKING);
|
||
|
}
|
||
|
|
||
|
/*------------------------------------------------------------------*/
|
||
|
/* TUSB HAL MILLISECOND
|
||
|
*------------------------------------------------------------------*/
|
||
|
#if CFG_TUSB_OS == OPT_OS_NONE
|
||
|
|
||
|
volatile uint32_t system_ticks = 0;
|
||
|
|
||
|
void SysTick_Handler (void)
|
||
|
{
|
||
|
system_ticks++;
|
||
|
}
|
||
|
|
||
|
uint32_t tusb_hal_millis(void)
|
||
|
{
|
||
|
return board_tick2ms(system_ticks);
|
||
|
}
|
||
|
|
||
|
#endif
|
||
|
|
||
|
#endif
|
||
|
|