mirror of
https://github.com/hathach/tinyusb.git
synced 2025-02-14 18:40:37 +00:00
use lpcopen for ea4357, blinky ok
This commit is contained in:
parent
087c5d0de6
commit
bb7123eed1
@ -20,7 +20,7 @@
|
||||
arm_target_interface_type="SWD"
|
||||
build_treat_warnings_as_errors="Yes"
|
||||
c_preprocessor_definitions="CORE_M4;__LPC4300_FAMILY;__LPC435x_SUBFAMILY;ARM_MATH_CM4;FLASH_PLACEMENT=1;BOARD_EA4357;CFG_TUSB_MCU=OPT_MCU_LPC43XX;CFG_TUSB_MEM_SECTION= __attribute__((section(".bss2")))"
|
||||
c_user_include_directories="../../src;$(rootDir)/hw/cmsis/Include;$(rootDir)/hw;$(rootDir)/src;$(lpcDir)/CMSIS_LPC43xx_DriverLib/inc"
|
||||
c_user_include_directories="../../src;$(rootDir)/hw;$(rootDir)/src;$(lpcDir)//inc;$(lpcDir)//inc/config_43xx"
|
||||
debug_register_definition_file="LPC43xx_Registers.xml"
|
||||
debug_target_connection="J-Link"
|
||||
gcc_entry_point="Reset_Handler"
|
||||
@ -28,7 +28,7 @@
|
||||
linker_memory_map_file="LPC4357 Cortex-M4_MemoryMap.xml"
|
||||
linker_section_placement_file="flash_placement.xml"
|
||||
linker_section_placements_segments="FLASH RX 0x1a000000 0x00080000;RAM RWX 0x10000000 0x00008000"
|
||||
macros="DeviceFamily=LPC4300;DeviceSubFamily=LPC435x;Target=LPC4357 Cortex-M4;Placement=Flash;rootDir=../../../../..;lpcDir=../../../../../hw/mcu/nxp/lpc43xx"
|
||||
macros="DeviceFamily=LPC4300;DeviceSubFamily=LPC435x;Target=LPC4357 Cortex-M4;Placement=Flash;rootDir=../../../../..;lpcDir=../../../../../hw/mcu/nxp/lpc_chip_43xx"
|
||||
project_directory=""
|
||||
project_type="Executable"
|
||||
target_reset_script="Reset();"
|
||||
@ -47,24 +47,127 @@
|
||||
<folder Name="ea4357">
|
||||
<file file_name="../../../../../hw/bsp/ea4357/board_ea4357.c" />
|
||||
<file file_name="../../../../../hw/bsp/ea4357/board_ea4357.h" />
|
||||
<folder Name="oem_base_board">
|
||||
<file file_name="../../../../../hw/bsp/ea4357/oem_base_board/pca9532.c" />
|
||||
<file file_name="../../../../../hw/bsp/ea4357/oem_base_board/pca9532.h" />
|
||||
</folder>
|
||||
<file file_name="../../../../../hw/bsp/ea4357/pca9532.c" />
|
||||
<file file_name="../../../../../hw/bsp/ea4357/pca9532.h" />
|
||||
</folder>
|
||||
</folder>
|
||||
<folder Name="mcu">
|
||||
<folder Name="nxp">
|
||||
<folder Name="lpc43xx">
|
||||
<folder Name="CMSIS_LPC43xx_DriverLib">
|
||||
<folder Name="src">
|
||||
<file file_name="../../../../../hw/mcu/nxp/lpc43xx/CMSIS_LPC43xx_DriverLib/src/system_LPC43xx.c" />
|
||||
<file file_name="../../../../../hw/mcu/nxp/lpc43xx/CMSIS_LPC43xx_DriverLib/src/lpc43xx_gpio.c" />
|
||||
<file file_name="../../../../../hw/mcu/nxp/lpc43xx/CMSIS_LPC43xx_DriverLib/src/lpc43xx_cgu.c" />
|
||||
<file file_name="../../../../../hw/mcu/nxp/lpc43xx/CMSIS_LPC43xx_DriverLib/src/lpc43xx_scu.c" />
|
||||
<file file_name="../../../../../hw/mcu/nxp/lpc43xx/CMSIS_LPC43xx_DriverLib/src/lpc43xx_i2c.c" />
|
||||
<folder Name="lpc_chip_43xx">
|
||||
<folder Name="inc">
|
||||
<file file_name="../../../../../hw/mcu/nxp/lpc_chip_43xx/inc/adc_18xx_43xx.h" />
|
||||
<file file_name="../../../../../hw/mcu/nxp/lpc_chip_43xx/inc/aes_18xx_43xx.h" />
|
||||
<file file_name="../../../../../hw/mcu/nxp/lpc_chip_43xx/inc/arm_common_tables.h" />
|
||||
<file file_name="../../../../../hw/mcu/nxp/lpc_chip_43xx/inc/arm_math.h" />
|
||||
<file file_name="../../../../../hw/mcu/nxp/lpc_chip_43xx/inc/atimer_18xx_43xx.h" />
|
||||
<file file_name="../../../../../hw/mcu/nxp/lpc_chip_43xx/inc/ccan_18xx_43xx.h" />
|
||||
<file file_name="../../../../../hw/mcu/nxp/lpc_chip_43xx/inc/cguccu_18xx_43xx.h" />
|
||||
<file file_name="../../../../../hw/mcu/nxp/lpc_chip_43xx/inc/chip.h" />
|
||||
<file file_name="../../../../../hw/mcu/nxp/lpc_chip_43xx/inc/chip_clocks.h" />
|
||||
<file file_name="../../../../../hw/mcu/nxp/lpc_chip_43xx/inc/chip_lpc18xx.h" />
|
||||
<file file_name="../../../../../hw/mcu/nxp/lpc_chip_43xx/inc/chip_lpc43xx.h" />
|
||||
<file file_name="../../../../../hw/mcu/nxp/lpc_chip_43xx/inc/clock_18xx_43xx.h" />
|
||||
<file file_name="../../../../../hw/mcu/nxp/lpc_chip_43xx/inc/cmsis.h" />
|
||||
<file file_name="../../../../../hw/mcu/nxp/lpc_chip_43xx/inc/cmsis_18xx.h" />
|
||||
<file file_name="../../../../../hw/mcu/nxp/lpc_chip_43xx/inc/cmsis_43xx.h" />
|
||||
<file file_name="../../../../../hw/mcu/nxp/lpc_chip_43xx/inc/cmsis_43xx_m0app.h" />
|
||||
<file file_name="../../../../../hw/mcu/nxp/lpc_chip_43xx/inc/cmsis_43xx_m0sub.h" />
|
||||
<file file_name="../../../../../hw/mcu/nxp/lpc_chip_43xx/inc/core_cm0.h" />
|
||||
<file file_name="../../../../../hw/mcu/nxp/lpc_chip_43xx/inc/core_cm0plus.h" />
|
||||
<file file_name="../../../../../hw/mcu/nxp/lpc_chip_43xx/inc/core_cm3.h" />
|
||||
<file file_name="../../../../../hw/mcu/nxp/lpc_chip_43xx/inc/core_cm4.h" />
|
||||
<file file_name="../../../../../hw/mcu/nxp/lpc_chip_43xx/inc/core_cm4_simd.h" />
|
||||
<file file_name="../../../../../hw/mcu/nxp/lpc_chip_43xx/inc/core_cmFunc.h" />
|
||||
<file file_name="../../../../../hw/mcu/nxp/lpc_chip_43xx/inc/core_cmInstr.h" />
|
||||
<file file_name="../../../../../hw/mcu/nxp/lpc_chip_43xx/inc/core_sc000.h" />
|
||||
<file file_name="../../../../../hw/mcu/nxp/lpc_chip_43xx/inc/core_sc300.h" />
|
||||
<file file_name="../../../../../hw/mcu/nxp/lpc_chip_43xx/inc/creg_18xx_43xx.h" />
|
||||
<file file_name="../../../../../hw/mcu/nxp/lpc_chip_43xx/inc/dac_18xx_43xx.h" />
|
||||
<file file_name="../../../../../hw/mcu/nxp/lpc_chip_43xx/inc/eeprom.h" />
|
||||
<file file_name="../../../../../hw/mcu/nxp/lpc_chip_43xx/inc/eeprom_18xx_43xx.h" />
|
||||
<file file_name="../../../../../hw/mcu/nxp/lpc_chip_43xx/inc/emc_18xx_43xx.h" />
|
||||
<file file_name="../../../../../hw/mcu/nxp/lpc_chip_43xx/inc/enet_18xx_43xx.h" />
|
||||
<file file_name="../../../../../hw/mcu/nxp/lpc_chip_43xx/inc/error.h" />
|
||||
<file file_name="../../../../../hw/mcu/nxp/lpc_chip_43xx/inc/evrt_18xx_43xx.h" />
|
||||
<file file_name="../../../../../hw/mcu/nxp/lpc_chip_43xx/inc/fmc_18xx_43xx.h" />
|
||||
<file file_name="../../../../../hw/mcu/nxp/lpc_chip_43xx/inc/fpu_init.h" />
|
||||
<file file_name="../../../../../hw/mcu/nxp/lpc_chip_43xx/inc/gima_18xx_43xx.h" />
|
||||
<file file_name="../../../../../hw/mcu/nxp/lpc_chip_43xx/inc/gpdma_18xx_43xx.h" />
|
||||
<file file_name="../../../../../hw/mcu/nxp/lpc_chip_43xx/inc/gpio_18xx_43xx.h" />
|
||||
<file file_name="../../../../../hw/mcu/nxp/lpc_chip_43xx/inc/gpiogroup_18xx_43xx.h" />
|
||||
<file file_name="../../../../../hw/mcu/nxp/lpc_chip_43xx/inc/hsadc_18xx_43xx.h" />
|
||||
<file file_name="../../../../../hw/mcu/nxp/lpc_chip_43xx/inc/i2c_18xx_43xx.h" />
|
||||
<file file_name="../../../../../hw/mcu/nxp/lpc_chip_43xx/inc/i2c_common_18xx_43xx.h" />
|
||||
<file file_name="../../../../../hw/mcu/nxp/lpc_chip_43xx/inc/i2cm_18xx_43xx.h" />
|
||||
<file file_name="../../../../../hw/mcu/nxp/lpc_chip_43xx/inc/i2s_18xx_43xx.h" />
|
||||
<file file_name="../../../../../hw/mcu/nxp/lpc_chip_43xx/inc/iap.h" />
|
||||
<file file_name="../../../../../hw/mcu/nxp/lpc_chip_43xx/inc/iap_18xx_43xx.h" />
|
||||
<file file_name="../../../../../hw/mcu/nxp/lpc_chip_43xx/inc/lcd_18xx_43xx.h" />
|
||||
<file file_name="../../../../../hw/mcu/nxp/lpc_chip_43xx/inc/lpc_types.h" />
|
||||
<file file_name="../../../../../hw/mcu/nxp/lpc_chip_43xx/inc/mcpwm_18xx_43xx.h" />
|
||||
<file file_name="../../../../../hw/mcu/nxp/lpc_chip_43xx/inc/otp_18xx_43xx.h" />
|
||||
<file file_name="../../../../../hw/mcu/nxp/lpc_chip_43xx/inc/packing.h" />
|
||||
<file file_name="../../../../../hw/mcu/nxp/lpc_chip_43xx/inc/pinint_18xx_43xx.h" />
|
||||
<file file_name="../../../../../hw/mcu/nxp/lpc_chip_43xx/inc/pmc_18xx_43xx.h" />
|
||||
<file file_name="../../../../../hw/mcu/nxp/lpc_chip_43xx/inc/qei_18xx_43xx.h" />
|
||||
<file file_name="../../../../../hw/mcu/nxp/lpc_chip_43xx/inc/rgu_18xx_43xx.h" />
|
||||
<file file_name="../../../../../hw/mcu/nxp/lpc_chip_43xx/inc/ring_buffer.h" />
|
||||
<file file_name="../../../../../hw/mcu/nxp/lpc_chip_43xx/inc/ritimer_18xx_43xx.h" />
|
||||
<file file_name="../../../../../hw/mcu/nxp/lpc_chip_43xx/inc/romapi_18xx_43xx.h" />
|
||||
<file file_name="../../../../../hw/mcu/nxp/lpc_chip_43xx/inc/rtc_18xx_43xx.h" />
|
||||
<file file_name="../../../../../hw/mcu/nxp/lpc_chip_43xx/inc/rtc_ut.h" />
|
||||
<file file_name="../../../../../hw/mcu/nxp/lpc_chip_43xx/inc/sct_18xx_43xx.h" />
|
||||
<file file_name="../../../../../hw/mcu/nxp/lpc_chip_43xx/inc/sct_pwm_18xx_43xx.h" />
|
||||
<file file_name="../../../../../hw/mcu/nxp/lpc_chip_43xx/inc/scu_18xx_43xx.h" />
|
||||
<file file_name="../../../../../hw/mcu/nxp/lpc_chip_43xx/inc/sdif_18xx_43xx.h" />
|
||||
<file file_name="../../../../../hw/mcu/nxp/lpc_chip_43xx/inc/sdio_18xx_43xx.h" />
|
||||
<file file_name="../../../../../hw/mcu/nxp/lpc_chip_43xx/inc/sdmmc.h" />
|
||||
<file file_name="../../../../../hw/mcu/nxp/lpc_chip_43xx/inc/sdmmc_18xx_43xx.h" />
|
||||
<file file_name="../../../../../hw/mcu/nxp/lpc_chip_43xx/inc/sgpio_18xx_43xx.h" />
|
||||
<file file_name="../../../../../hw/mcu/nxp/lpc_chip_43xx/inc/spi_18xx_43xx.h" />
|
||||
<file file_name="../../../../../hw/mcu/nxp/lpc_chip_43xx/inc/spifi_18xx_43xx.h" />
|
||||
<file file_name="../../../../../hw/mcu/nxp/lpc_chip_43xx/inc/ssp_18xx_43xx.h" />
|
||||
<file file_name="../../../../../hw/mcu/nxp/lpc_chip_43xx/inc/stopwatch.h" />
|
||||
<file file_name="../../../../../hw/mcu/nxp/lpc_chip_43xx/inc/timer_18xx_43xx.h" />
|
||||
<file file_name="../../../../../hw/mcu/nxp/lpc_chip_43xx/inc/uart_18xx_43xx.h" />
|
||||
<file file_name="../../../../../hw/mcu/nxp/lpc_chip_43xx/inc/usbhs_18xx_43xx.h" />
|
||||
<file file_name="../../../../../hw/mcu/nxp/lpc_chip_43xx/inc/wwdt_18xx_43xx.h" />
|
||||
<folder Name="config_43xx">
|
||||
<file file_name="../../../../../hw/mcu/nxp/lpc_chip_43xx/inc/config_43xx/cmsis_43xx.h" />
|
||||
<file file_name="../../../../../hw/mcu/nxp/lpc_chip_43xx/inc/config_43xx/sys_config.h" />
|
||||
</folder>
|
||||
</folder>
|
||||
<folder Name="src">
|
||||
<file file_name="../../../../../hw/mcu/nxp/lpc_chip_43xx/src/chip_18xx_43xx.c" />
|
||||
<file file_name="../../../../../hw/mcu/nxp/lpc_chip_43xx/src/clock_18xx_43xx.c" />
|
||||
<file file_name="../../../../../hw/mcu/nxp/lpc_chip_43xx/src/fpu_init.c" />
|
||||
<file file_name="../../../../../hw/mcu/nxp/lpc_chip_43xx/src/gpdma_18xx_43xx.c" />
|
||||
<file file_name="../../../../../hw/mcu/nxp/lpc_chip_43xx/src/gpio_18xx_43xx.c" />
|
||||
<file file_name="../../../../../hw/mcu/nxp/lpc_chip_43xx/src/gpiogroup_18xx_43xx.c" />
|
||||
<file file_name="../../../../../hw/mcu/nxp/lpc_chip_43xx/src/i2c_18xx_43xx.c" />
|
||||
<file file_name="../../../../../hw/mcu/nxp/lpc_chip_43xx/src/i2cm_18xx_43xx.c" />
|
||||
<file file_name="../../../../../hw/mcu/nxp/lpc_chip_43xx/src/i2s_18xx_43xx.c" />
|
||||
<file file_name="../../../../../hw/mcu/nxp/lpc_chip_43xx/src/iap_18xx_43xx.c" />
|
||||
<file file_name="../../../../../hw/mcu/nxp/lpc_chip_43xx/src/lcd_18xx_43xx.c" />
|
||||
<file file_name="../../../../../hw/mcu/nxp/lpc_chip_43xx/src/otp_18xx_43xx.c" />
|
||||
<file file_name="../../../../../hw/mcu/nxp/lpc_chip_43xx/src/pinint_18xx_43xx.c" />
|
||||
<file file_name="../../../../../hw/mcu/nxp/lpc_chip_43xx/src/pmc_18xx_43xx.c" />
|
||||
<file file_name="../../../../../hw/mcu/nxp/lpc_chip_43xx/src/ring_buffer.c" />
|
||||
<file file_name="../../../../../hw/mcu/nxp/lpc_chip_43xx/src/ritimer_18xx_43xx.c" />
|
||||
<file file_name="../../../../../hw/mcu/nxp/lpc_chip_43xx/src/rtc_18xx_43xx.c" />
|
||||
<file file_name="../../../../../hw/mcu/nxp/lpc_chip_43xx/src/sct_18xx_43xx.c" />
|
||||
<file file_name="../../../../../hw/mcu/nxp/lpc_chip_43xx/src/sct_pwm_18xx_43xx.c" />
|
||||
<file file_name="../../../../../hw/mcu/nxp/lpc_chip_43xx/src/sdif_18xx_43xx.c" />
|
||||
<file file_name="../../../../../hw/mcu/nxp/lpc_chip_43xx/src/sdio_18xx_43xx.c" />
|
||||
<file file_name="../../../../../hw/mcu/nxp/lpc_chip_43xx/src/sdmmc_18xx_43xx.c" />
|
||||
<file file_name="../../../../../hw/mcu/nxp/lpc_chip_43xx/src/spi_18xx_43xx.c" />
|
||||
<file file_name="../../../../../hw/mcu/nxp/lpc_chip_43xx/src/ssp_18xx_43xx.c" />
|
||||
<file file_name="../../../../../hw/mcu/nxp/lpc_chip_43xx/src/stopwatch_18xx_43xx.c" />
|
||||
<file file_name="../../../../../hw/mcu/nxp/lpc_chip_43xx/src/sysinit_18xx_43xx.c" />
|
||||
<file file_name="../../../../../hw/mcu/nxp/lpc_chip_43xx/src/timer_18xx_43xx.c" />
|
||||
<file file_name="../../../../../hw/mcu/nxp/lpc_chip_43xx/src/uart_18xx_43xx.c" />
|
||||
<file file_name="../../../../../hw/mcu/nxp/lpc_chip_43xx/src/wwdt_18xx_43xx.c" />
|
||||
</folder>
|
||||
</folder>
|
||||
</folder>
|
||||
</folder>
|
||||
|
@ -36,11 +36,13 @@
|
||||
*/
|
||||
/**************************************************************************/
|
||||
|
||||
#include "bsp/board.h"
|
||||
#include "tusb.h"
|
||||
|
||||
#ifdef BOARD_EA4357
|
||||
|
||||
#include "bsp/board.h"
|
||||
#include "pca9532.h"
|
||||
|
||||
#include "tusb.h"
|
||||
|
||||
#define BOARD_UART_PORT LPC_USART0
|
||||
#define BOARD_UART_PIN_PORT 0x0f
|
||||
#define BOARD_UART_PIN_TX 10 // PF.10 : UART0_TXD
|
||||
@ -88,31 +90,77 @@ uint32_t tusb_hal_millis(void)
|
||||
/*------------------------------------------------------------------*/
|
||||
/* BOARD API
|
||||
*------------------------------------------------------------------*/
|
||||
|
||||
/* 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)}, //ENET_REF_CLK
|
||||
{0x0, 1, (SCU_MODE_HIGHSPEEDSLEW_EN | SCU_MODE_INACT | SCU_MODE_ZIF_DIS | SCU_MODE_FUNC6)}, //ENET_TXEN
|
||||
{0x1, 18, (SCU_MODE_HIGHSPEEDSLEW_EN | SCU_MODE_INACT | SCU_MODE_ZIF_DIS | SCU_MODE_FUNC3)}, //ENET_TXD0
|
||||
{0x1, 20, (SCU_MODE_HIGHSPEEDSLEW_EN | SCU_MODE_INACT | SCU_MODE_ZIF_DIS | SCU_MODE_FUNC3)}, //ENET_TXD1
|
||||
{0x1, 17, (SCU_MODE_HIGHSPEEDSLEW_EN | SCU_MODE_INACT | SCU_MODE_INBUFF_EN | SCU_MODE_ZIF_DIS | SCU_MODE_FUNC3)}, //ENET_MDIO
|
||||
{0xC, 1, (SCU_MODE_HIGHSPEEDSLEW_EN | SCU_MODE_INACT | SCU_MODE_ZIF_DIS | SCU_MODE_FUNC3)}, //ENET_MDC
|
||||
{0x1, 16, (SCU_MODE_HIGHSPEEDSLEW_EN | SCU_MODE_INACT | SCU_MODE_INBUFF_EN | SCU_MODE_ZIF_DIS | SCU_MODE_FUNC7)}, //ENET_RX_DV
|
||||
{0x1, 15, (SCU_MODE_HIGHSPEEDSLEW_EN | SCU_MODE_INACT | SCU_MODE_INBUFF_EN | SCU_MODE_ZIF_DIS | SCU_MODE_FUNC3)}, //ENET_RXD0
|
||||
{0x0, 0, (SCU_MODE_HIGHSPEEDSLEW_EN | SCU_MODE_INACT | SCU_MODE_INBUFF_EN | SCU_MODE_ZIF_DIS | SCU_MODE_FUNC2)}, //ENET_RXD1
|
||||
|
||||
/* I2S */
|
||||
{0x3, 0, (SCU_PINIO_FAST | SCU_MODE_FUNC2)}, //I2S0_TX_CLK
|
||||
{0xC, 12, (SCU_PINIO_FAST | SCU_MODE_FUNC6)}, //I2S0_TX_SDA
|
||||
{0xC, 13, (SCU_PINIO_FAST | SCU_MODE_FUNC6)}, //I2S0_TX_WS
|
||||
{0x6, 0, (SCU_PINIO_FAST | SCU_MODE_FUNC4)}, //I2S0_RX_SCK
|
||||
{0x6, 1, (SCU_PINIO_FAST | SCU_MODE_FUNC3)}, //I2S0_RX_WS
|
||||
{0x6, 2, (SCU_PINIO_FAST | SCU_MODE_FUNC3)}, //I2S0_RX_SDA
|
||||
};
|
||||
|
||||
/* 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)},
|
||||
};
|
||||
|
||||
// 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)
|
||||
{
|
||||
CGU_Init();
|
||||
SystemCoreClockUpdate();
|
||||
|
||||
#if CFG_TUSB_OS == OPT_OS_NONE // TODO may move to main.c
|
||||
SysTick_Config(CGU_GetPCLKFrequency(CGU_PERIPHERAL_M4CORE) / BOARD_TICKS_HZ); // 1 msec tick timer
|
||||
#if CFG_TUSB_OS == OPT_OS_NONE
|
||||
SysTick_Config( SystemCoreClock / BOARD_TICKS_HZ );
|
||||
#endif
|
||||
|
||||
//------------- USB -------------//
|
||||
// USB0 Power: EA4357 channel B U20 GPIO26 active low (base board), P2_3 on LPC4357
|
||||
scu_pinmux(0x02, 3, MD_PUP | MD_EZI, FUNC7); // USB0 VBus Power
|
||||
|
||||
#if CFG_TUSB_RHPORT0_MODE & OPT_MODE_DEVICE
|
||||
scu_pinmux(0x09, 5, GPIO_PDN, FUNC4); // P9_5 (GPIO5[18]) (GPIO28 on oem base) as USB connect, active low.
|
||||
GPIO_SetDir(5, BIT_(18), 1);
|
||||
#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
|
||||
Chip_GPIO_Init(LPC_GPIO_PORT);
|
||||
|
||||
//------------- LED -------------//
|
||||
I2C_Init(LPC_I2C0, 100000);
|
||||
I2C_Cmd(LPC_I2C0, ENABLE);
|
||||
/* Init I2C */
|
||||
Chip_SCU_I2C0PinConfig(I2C0_STANDARD_FAST_MODE);
|
||||
Chip_I2C_Init(I2C0);
|
||||
Chip_I2C_SetClockRate(I2C0, 100000);
|
||||
Chip_I2C_SetMasterEventHandler(I2C0, Chip_I2C_EventHandlerPolling);
|
||||
|
||||
pca9532_init();
|
||||
|
||||
#if 0
|
||||
//------------- BUTTON -------------//
|
||||
for(uint8_t i=0; i<BOARD_BUTTON_COUNT; i++)
|
||||
{
|
||||
@ -120,7 +168,6 @@ void board_init(void)
|
||||
GPIO_SetDir(buttons[i].gpio_port, BIT_(buttons[i].gpio_pin), 0);
|
||||
}
|
||||
|
||||
#if 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);
|
||||
@ -134,8 +181,19 @@ void board_init(void)
|
||||
UART_TxCmd(BOARD_UART_PORT, ENABLE); // Enable UART Transmit
|
||||
#endif
|
||||
|
||||
//------------- NAND Flash (K9FXX) Size = 128M, Page Size = 2K, Block Size = 128K, Number of Block = 1024 -------------//
|
||||
// nand_init();
|
||||
#if 0
|
||||
//------------- USB -------------//
|
||||
// USB0 Power: EA4357 channel B U20 GPIO26 active low (base board), P2_3 on LPC4357
|
||||
scu_pinmux(0x02, 3, MD_PUP | MD_EZI, FUNC7); // USB0 VBus Power
|
||||
|
||||
#if CFG_TUSB_RHPORT0_MODE & OPT_MODE_DEVICE
|
||||
scu_pinmux(0x09, 5, GPIO_PDN, FUNC4); // P9_5 (GPIO5[18]) (GPIO28 on oem base) as USB connect, active low.
|
||||
GPIO_SetDir(5, BIT_(18), 1);
|
||||
#endif
|
||||
#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
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------+
|
||||
@ -157,14 +215,14 @@ void board_led_control(bool state)
|
||||
//--------------------------------------------------------------------+
|
||||
static bool button_read(uint8_t id)
|
||||
{
|
||||
return !BIT_TEST_( GPIO_ReadValue(buttons[id].gpio_port), buttons[id].gpio_pin ); // button is active low
|
||||
// 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);
|
||||
// for(uint8_t i=0; i<BOARD_BUTTON_COUNT; i++) result |= (button_read(i) ? BIT_(i) : 0);
|
||||
|
||||
return result;
|
||||
}
|
||||
|
@ -43,15 +43,7 @@
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#include "LPC43xx.h"
|
||||
#include "lpc43xx_scu.h"
|
||||
#include "lpc43xx_cgu.h"
|
||||
#include "lpc43xx_gpio.h"
|
||||
#include "lpc43xx_uart.h"
|
||||
#include "lpc43xx_i2c.h"
|
||||
|
||||
// For LEDs
|
||||
#include "oem_base_board/pca9532.h"
|
||||
#include "chip.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
|
@ -1,349 +0,0 @@
|
||||
/*****************************************************************************
|
||||
*
|
||||
* Copyright(C) 2011, Embedded Artists AB
|
||||
* All rights reserved.
|
||||
*
|
||||
******************************************************************************
|
||||
* Software that is described herein is for illustrative purposes only
|
||||
* which provides customers with programming information regarding the
|
||||
* products. This software is supplied "AS IS" without any warranties.
|
||||
* Embedded Artists AB assumes no responsibility or liability for the
|
||||
* use of the software, conveys no license or title under any patent,
|
||||
* copyright, or mask work right to the product. Embedded Artists AB
|
||||
* reserves the right to make changes in the software without
|
||||
* notification. Embedded Artists AB also make no representation or
|
||||
* warranty that such application will be suitable for the specified
|
||||
* use without further testing or modification.
|
||||
*****************************************************************************/
|
||||
|
||||
/*
|
||||
* NOTE: I2C must have been initialized before calling any functions in this
|
||||
* file.
|
||||
*/
|
||||
|
||||
/******************************************************************************
|
||||
* Includes
|
||||
*****************************************************************************/
|
||||
#include "bsp/board.h"
|
||||
|
||||
#ifdef BOARD_EA4357
|
||||
|
||||
#include "lpc43xx_i2c.h"
|
||||
#include "lpc43xx_cgu.h"
|
||||
#include "lpc_types.h"
|
||||
#include "pca9532.h"
|
||||
|
||||
/******************************************************************************
|
||||
* Defines and typedefs
|
||||
*****************************************************************************/
|
||||
|
||||
#define I2C_PORT (LPC_I2C0)
|
||||
|
||||
#define LS_MODE_ON 0x01
|
||||
#define LS_MODE_BLINK0 0x02
|
||||
#define LS_MODE_BLINK1 0x03
|
||||
|
||||
/******************************************************************************
|
||||
* External global variables
|
||||
*****************************************************************************/
|
||||
|
||||
|
||||
/******************************************************************************
|
||||
* Local variables
|
||||
*****************************************************************************/
|
||||
|
||||
static uint16_t blink0Shadow = 0;
|
||||
static uint16_t blink1Shadow = 0;
|
||||
static uint16_t ledStateShadow = 0;
|
||||
|
||||
/******************************************************************************
|
||||
* Local Functions
|
||||
*****************************************************************************/
|
||||
|
||||
static Status I2CWrite(uint32_t addr, uint8_t* buf, uint32_t len)
|
||||
{
|
||||
I2C_M_SETUP_Type i2cData;
|
||||
|
||||
i2cData.sl_addr7bit = addr;
|
||||
i2cData.tx_data = buf;
|
||||
i2cData.tx_length = len;
|
||||
i2cData.rx_data = NULL;
|
||||
i2cData.rx_length = 0;
|
||||
i2cData.retransmissions_max = 3;
|
||||
|
||||
return I2C_MasterTransferData(I2C_PORT, &i2cData, I2C_TRANSFER_POLLING);
|
||||
}
|
||||
|
||||
static Status I2CRead(uint32_t addr, uint8_t* buf, uint32_t len)
|
||||
{
|
||||
I2C_M_SETUP_Type i2cData;
|
||||
|
||||
i2cData.sl_addr7bit = addr;
|
||||
i2cData.tx_data = NULL;
|
||||
i2cData.tx_length = 0;
|
||||
i2cData.rx_data = buf;
|
||||
i2cData.rx_length = len;
|
||||
i2cData.retransmissions_max = 3;
|
||||
|
||||
return I2C_MasterTransferData(I2C_PORT, &i2cData, I2C_TRANSFER_POLLING);
|
||||
}
|
||||
|
||||
static void setLsStates(uint16_t states, uint8_t* ls, uint8_t mode)
|
||||
{
|
||||
#define IS_LED_SET(bit, x) ( ( ((x) & (bit)) != 0 ) ? 1 : 0 )
|
||||
|
||||
int i = 0;
|
||||
|
||||
for (i = 0; i < 4; i++) {
|
||||
|
||||
ls[i] |= ( (IS_LED_SET(0x0001, states)*mode << 0)
|
||||
| (IS_LED_SET(0x0002, states)*mode << 2)
|
||||
| (IS_LED_SET(0x0004, states)*mode << 4)
|
||||
| (IS_LED_SET(0x0008, states)*mode << 6) );
|
||||
|
||||
states >>= 4;
|
||||
}
|
||||
}
|
||||
|
||||
static void setLeds(void)
|
||||
{
|
||||
uint8_t buf[5];
|
||||
uint8_t ls[4] = {0,0,0,0};
|
||||
uint16_t states = ledStateShadow;
|
||||
|
||||
/* LEDs in On/Off state */
|
||||
setLsStates(states, ls, LS_MODE_ON);
|
||||
|
||||
/* set the LEDs that should blink */
|
||||
setLsStates(blink0Shadow, ls, LS_MODE_BLINK0);
|
||||
setLsStates(blink1Shadow, ls, LS_MODE_BLINK1);
|
||||
|
||||
|
||||
buf[0] = PCA9532_LS0 | PCA9532_AUTO_INC;
|
||||
buf[1] = ls[0];
|
||||
buf[2] = ls[1];
|
||||
buf[3] = ls[2];
|
||||
buf[4] = ls[3];
|
||||
I2CWrite(PCA9532_I2C_ADDR, buf, 5);
|
||||
}
|
||||
|
||||
/******************************************************************************
|
||||
* Public Functions
|
||||
*****************************************************************************/
|
||||
|
||||
/******************************************************************************
|
||||
*
|
||||
* Description:
|
||||
* Initialize the PCA9532 Device
|
||||
*
|
||||
*****************************************************************************/
|
||||
void pca9532_init (void)
|
||||
{
|
||||
/* nothing to initialize */
|
||||
}
|
||||
|
||||
/******************************************************************************
|
||||
*
|
||||
* Description:
|
||||
* Get the LED states
|
||||
*
|
||||
* Params:
|
||||
* [in] shadow - TRUE if the states should be retrieved from the shadow
|
||||
* variables. The shadow variable are updated when any
|
||||
* of setLeds, setBlink0Leds and/or setBlink1Leds are
|
||||
* called.
|
||||
*
|
||||
* FALSE if the state should be retrieved from the PCA9532
|
||||
* device. A blinkin LED may be reported as on or off
|
||||
* depending on the state when calling the function.
|
||||
*
|
||||
* Returns:
|
||||
* A mask where a 1 indicates that a LED is on (or blinking).
|
||||
*
|
||||
*****************************************************************************/
|
||||
uint16_t pca9532_getLedState (uint32_t shadow)
|
||||
{
|
||||
uint8_t buf[2];
|
||||
uint16_t ret = 0;
|
||||
|
||||
if (shadow) {
|
||||
/* a blink LED is reported as on*/
|
||||
ret = (ledStateShadow | blink0Shadow | blink1Shadow);
|
||||
}
|
||||
else {
|
||||
|
||||
/*
|
||||
* A blinking LED may be reported as on or off depending on
|
||||
* its state when reading the Input register.
|
||||
*/
|
||||
|
||||
buf[0] = PCA9532_INPUT0;
|
||||
I2CWrite(PCA9532_I2C_ADDR, buf, 1);
|
||||
|
||||
I2CRead(PCA9532_I2C_ADDR, buf, 1);
|
||||
ret = buf[0];
|
||||
|
||||
|
||||
buf[0] = PCA9532_INPUT1;
|
||||
I2CWrite(PCA9532_I2C_ADDR, buf, 1);
|
||||
|
||||
I2CRead(PCA9532_I2C_ADDR, buf, 1);
|
||||
ret |= (buf[0] << 8);
|
||||
|
||||
|
||||
/* invert since LEDs are active low */
|
||||
ret = ((~ret) & 0xFFFF);
|
||||
}
|
||||
|
||||
return (ret & ~PCA9532_NOT_USED);
|
||||
}
|
||||
|
||||
|
||||
/******************************************************************************
|
||||
*
|
||||
* Description:
|
||||
* Set LED states (on or off).
|
||||
*
|
||||
* Params:
|
||||
* [in] ledOnMask - The LEDs that should be turned on. This mask has
|
||||
* priority over ledOffMask
|
||||
* [in] ledOffMask - The LEDs that should be turned off.
|
||||
*
|
||||
*****************************************************************************/
|
||||
void pca9532_setLeds (uint16_t ledOnMask, uint16_t ledOffMask)
|
||||
{
|
||||
/* turn off leds */
|
||||
ledStateShadow &= (~(ledOffMask) & 0xffff);
|
||||
|
||||
/* ledOnMask has priority over ledOffMask */
|
||||
ledStateShadow |= ledOnMask;
|
||||
|
||||
/* turn off blinking */
|
||||
blink0Shadow &= (~(ledOffMask) & 0xffff);
|
||||
blink1Shadow &= (~(ledOffMask) & 0xffff);
|
||||
|
||||
setLeds();
|
||||
}
|
||||
|
||||
/******************************************************************************
|
||||
*
|
||||
* Description:
|
||||
* Set the blink period for PWM0. Valid values are 0 - 255 where 0
|
||||
* means 152 Hz and 255 means 0.59 Hz. A value of 151 means 1 Hz.
|
||||
*
|
||||
* Params:
|
||||
* [in] period - the period for pwm0
|
||||
*
|
||||
*****************************************************************************/
|
||||
void pca9532_setBlink0Period(uint8_t period)
|
||||
{
|
||||
uint8_t buf[2];
|
||||
|
||||
buf[0] = PCA9532_PSC0;
|
||||
buf[1] = period;
|
||||
I2CWrite(PCA9532_I2C_ADDR, buf, 2);
|
||||
}
|
||||
|
||||
/******************************************************************************
|
||||
*
|
||||
* Description:
|
||||
* Set the duty cycle for PWM0. Valid values are 0 - 100. 25 means the LED
|
||||
* is on 25% of the period.
|
||||
*
|
||||
* Params:
|
||||
* [in] duty - duty cycle
|
||||
*
|
||||
*****************************************************************************/
|
||||
void pca9532_setBlink0Duty(uint8_t duty)
|
||||
{
|
||||
uint8_t buf[2];
|
||||
uint32_t tmp = duty;
|
||||
if (tmp > 100) {
|
||||
tmp = 100;
|
||||
}
|
||||
|
||||
tmp = (256 * tmp)/100;
|
||||
|
||||
buf[0] = PCA9532_PWM0;
|
||||
buf[1] = tmp;
|
||||
I2CWrite(PCA9532_I2C_ADDR, buf, 2);
|
||||
}
|
||||
|
||||
/******************************************************************************
|
||||
*
|
||||
* Description:
|
||||
* Set the LEDs that should blink with rate and duty cycle from PWM0.
|
||||
* Blinking is turned off with pca9532_setLeds.
|
||||
*
|
||||
* Params:
|
||||
* [in] ledMask - LEDs that should blink.
|
||||
*
|
||||
*****************************************************************************/
|
||||
void pca9532_setBlink0Leds(uint16_t ledMask)
|
||||
{
|
||||
blink0Shadow |= ledMask;
|
||||
setLeds();
|
||||
}
|
||||
|
||||
/******************************************************************************
|
||||
*
|
||||
* Description:
|
||||
* Set the blink period for PWM1. Valid values are 0 - 255 where 0
|
||||
* means 152 Hz and 255 means 0.59 Hz. A value of 151 means 1 Hz.
|
||||
*
|
||||
* Params:
|
||||
* [in] period - The period for PWM1
|
||||
*
|
||||
*****************************************************************************/
|
||||
void pca9532_setBlink1Period(uint8_t period)
|
||||
{
|
||||
uint8_t buf[2];
|
||||
|
||||
buf[0] = PCA9532_PSC1;
|
||||
buf[1] = period;
|
||||
I2CWrite(PCA9532_I2C_ADDR, buf, 2);
|
||||
}
|
||||
|
||||
/******************************************************************************
|
||||
*
|
||||
* Description:
|
||||
* Set the duty cycle for PWM1. Valid values are 0 - 100. 25 means the LED
|
||||
* is on 25% of the period.
|
||||
*
|
||||
* Params:
|
||||
* [in] duty - duty cycle.
|
||||
*
|
||||
*****************************************************************************/
|
||||
void pca9532_setBlink1Duty(uint8_t duty)
|
||||
{
|
||||
uint8_t buf[2];
|
||||
|
||||
uint32_t tmp = duty;
|
||||
if (tmp > 100) {
|
||||
tmp = 100;
|
||||
}
|
||||
|
||||
tmp = (256 * tmp)/100;
|
||||
|
||||
buf[0] = PCA9532_PWM1;
|
||||
buf[1] = tmp;
|
||||
I2CWrite(PCA9532_I2C_ADDR, buf, 2);
|
||||
}
|
||||
|
||||
/******************************************************************************
|
||||
*
|
||||
* Description:
|
||||
* Set the LEDs that should blink with rate and duty cycle from PWM1.
|
||||
* Blinking is turned off with pca9532_setLeds.
|
||||
*
|
||||
* Params:
|
||||
* [in] ledMask - LEDs that should blink.
|
||||
*
|
||||
*****************************************************************************/
|
||||
void pca9532_setBlink1Leds(uint16_t ledMask)
|
||||
{
|
||||
blink1Shadow |= ledMask;
|
||||
setLeds();
|
||||
}
|
||||
|
||||
#endif
|
@ -1,94 +0,0 @@
|
||||
/*****************************************************************************
|
||||
*
|
||||
* Copyright(C) 2011, Embedded Artists AB
|
||||
* All rights reserved.
|
||||
*
|
||||
******************************************************************************
|
||||
* Software that is described herein is for illustrative purposes only
|
||||
* which provides customers with programming information regarding the
|
||||
* products. This software is supplied "AS IS" without any warranties.
|
||||
* Embedded Artists AB assumes no responsibility or liability for the
|
||||
* use of the software, conveys no license or title under any patent,
|
||||
* copyright, or mask work right to the product. Embedded Artists AB
|
||||
* reserves the right to make changes in the software without
|
||||
* notification. Embedded Artists AB also make no representation or
|
||||
* warranty that such application will be suitable for the specified
|
||||
* use without further testing or modification.
|
||||
*****************************************************************************/
|
||||
#ifndef __PCA9532C_H
|
||||
#define __PCA9532C_H
|
||||
|
||||
|
||||
#define PCA9532_I2C_ADDR (0x60)
|
||||
|
||||
#define PCA9532_INPUT0 0x00
|
||||
#define PCA9532_INPUT1 0x01
|
||||
#define PCA9532_PSC0 0x02
|
||||
#define PCA9532_PWM0 0x03
|
||||
#define PCA9532_PSC1 0x04
|
||||
#define PCA9532_PWM1 0x05
|
||||
#define PCA9532_LS0 0x06
|
||||
#define PCA9532_LS1 0x07
|
||||
#define PCA9532_LS2 0x08
|
||||
#define PCA9532_LS3 0x09
|
||||
|
||||
#define PCA9532_AUTO_INC 0x10
|
||||
|
||||
|
||||
/*
|
||||
* The Keys on the base board are mapped to LED0 -> LED3 on
|
||||
* the PCA9532.
|
||||
*/
|
||||
|
||||
#define KEY1 0x0001
|
||||
#define KEY2 0x0002
|
||||
#define KEY3 0x0004
|
||||
#define KEY4 0x0008
|
||||
|
||||
#define KEY_MASK 0x000F
|
||||
|
||||
/*
|
||||
* MMC Card Detect and MMC Write Protect are mapped to LED4
|
||||
* and LED5 on the PCA9532. Please note that WP is active low.
|
||||
*/
|
||||
|
||||
#define MMC_CD 0x0010
|
||||
#define MMC_WP 0x0020
|
||||
|
||||
#define MMC_MASK 0x30
|
||||
|
||||
/* NOTE: LED6 and LED7 on PCA9532 are not connected to anything */
|
||||
#define PCA9532_NOT_USED 0xC0
|
||||
|
||||
/*
|
||||
* Below are the LED constants to use when enabling/disabling a LED.
|
||||
* The LED names are the names printed on the base board and not
|
||||
* the names from the PCA9532 device. base_LED1 -> LED8 on PCA9532,
|
||||
* base_LED2 -> LED9, and so on.
|
||||
*/
|
||||
|
||||
#define LED1 0x0100
|
||||
#define LED2 0x0200
|
||||
#define LED3 0x0400
|
||||
#define LED4 0x0800
|
||||
#define LED5 0x1000
|
||||
#define LED6 0x2000
|
||||
#define LED7 0x4000
|
||||
#define LED8 0x8000
|
||||
|
||||
#define LED_MASK 0xFF00
|
||||
|
||||
void pca9532_init (void);
|
||||
uint16_t pca9532_getLedState (uint32_t shadow);
|
||||
void pca9532_setLeds (uint16_t ledOnMask, uint16_t ledOffMask);
|
||||
void pca9532_setBlink0Period(uint8_t period);
|
||||
void pca9532_setBlink0Duty(uint8_t duty);
|
||||
void pca9532_setBlink0Leds(uint16_t ledMask);
|
||||
void pca9532_setBlink1Period(uint8_t period);
|
||||
void pca9532_setBlink1Duty(uint8_t duty);
|
||||
void pca9532_setBlink1Leds(uint16_t ledMask);
|
||||
|
||||
#endif /* end __PCA9532C_H */
|
||||
/****************************************************************************
|
||||
** End Of File
|
||||
*****************************************************************************/
|
@ -40,8 +40,7 @@
|
||||
|
||||
#if CFG_TUSB_MCU == OPT_MCU_LPC43XX
|
||||
|
||||
#include "LPC43xx.h"
|
||||
#include "lpc43xx_cgu.h"
|
||||
#include "chip.h"
|
||||
|
||||
enum {
|
||||
LPC43XX_USBMODE_DEVICE = 2,
|
||||
|
Loading…
x
Reference in New Issue
Block a user