diff options
| author | hathach <[email protected]> | 2014-03-07 15:31:41 +0700 |
|---|---|---|
| committer | hathach <[email protected]> | 2014-03-07 15:31:41 +0700 |
| commit | e506f4cae2f3d06b463c28f725692165fec60727 (patch) | |
| tree | 3850cd0959d3c359c14e84d9b808189523673388 | |
| parent | 01760794fe7f90e27fa5d3bfca4f089904f459eb (diff) | |
ported board_buttons API to EA4357 but device is not mounted yet
| -rw-r--r-- | demos/bsp/boards/embedded_artists/ea4357/board_ea4357.c | 49 | ||||
| -rw-r--r-- | demos/bsp/boards/ngx/board_ngx4330.c | 4 | ||||
| -rw-r--r-- | demos/device/device_os_none/.cproject | 107 | ||||
| -rw-r--r-- | demos/device/src/main.c | 6 | ||||
| -rw-r--r-- | demos/device/src/tusb_config.h | 4 |
5 files changed, 125 insertions, 45 deletions
diff --git a/demos/bsp/boards/embedded_artists/ea4357/board_ea4357.c b/demos/bsp/boards/embedded_artists/ea4357/board_ea4357.c index c76b94bda..f65e46b6f 100644 --- a/demos/bsp/boards/embedded_artists/ea4357/board_ea4357.c +++ b/demos/bsp/boards/embedded_artists/ea4357/board_ea4357.c @@ -40,12 +40,31 @@ #if BOARD == BOARD_EA4357 - #define BOARD_UART_PORT LPC_USART0 #define BOARD_UART_PIN_PORT 0x0f #define BOARD_UART_PIN_TX 10 // PF.10 : UART0_TXD #define BOARD_UART_PIN_RX 11 // PF.11 : UART0_RXD +const static struct { + uint8_t mux_port; + uint8_t mux_pin; + + uint8_t gpio_port; + uint8_t gpio_pin; +}buttons[] = +{ + {0x0a, 3, 4, 10 }, // Joystick up + {0x09, 1, 4, 13 }, // Joystick down + {0x0a, 2, 4, 9 }, // Joystick left + {0x09, 0, 4, 12 }, // Joystick right + {0x0a, 1, 4, 8 }, // Joystick press + {0x02, 7, 0, 7 }, // SW6 +}; + +enum { + BOARD_BUTTON_COUNT = sizeof(buttons) / sizeof(buttons[0]) +}; + void board_init(void) { CGU_Init(); @@ -66,7 +85,13 @@ void board_init(void) I2C_Cmd(LPC_I2C0, ENABLE); pca9532_init(); -#if CFG_UART_ENABLE + //------------- 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); @@ -78,7 +103,6 @@ void board_init(void) UART_Init(BOARD_UART_PORT, &UARTConfigStruct); 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(); @@ -115,9 +139,25 @@ void board_leds(uint32_t on_mask, uint32_t off_mask) } //--------------------------------------------------------------------+ +// 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 //--------------------------------------------------------------------+ -#if CFG_UART_ENABLE uint8_t board_uart_getchar(void) { return UART_ReceiveByte(BOARD_UART_PORT); @@ -126,6 +166,5 @@ void board_uart_putchar(uint8_t c) { UART_Send(BOARD_UART_PORT, &c, 1, BLOCKING); } -#endif #endif diff --git a/demos/bsp/boards/ngx/board_ngx4330.c b/demos/bsp/boards/ngx/board_ngx4330.c index 4efd4c915..79f9d78fb 100644 --- a/demos/bsp/boards/ngx/board_ngx4330.c +++ b/demos/bsp/boards/ngx/board_ngx4330.c @@ -73,7 +73,6 @@ void board_init(void) GPIO_SetDir(leds[i].gpio_port, BIT_(leds[i].gpio_pin), 1); // output
}
-#if CFG_UART_ENABLE
//------------- UART init -------------//
scu_pinmux(0x6 ,4, MD_PDN | MD_EZI, FUNC2); // UART0_TXD
scu_pinmux(0x6 ,5, MD_PDN | MD_EZI, FUNC2); // UART0_RXD
@@ -85,8 +84,6 @@ void board_init(void) UART_Init(BOARD_UART_PORT, &UARTConfigStruct);
UART_TxCmd(BOARD_UART_PORT, ENABLE); // Enable UART
-#endif
-
}
//--------------------------------------------------------------------+
@@ -118,4 +115,5 @@ void board_uart_putchar(uint8_t c) {
UART_Send(BOARD_UART_PORT, &c, 1, BLOCKING);
}
+
#endif
diff --git a/demos/device/device_os_none/.cproject b/demos/device/device_os_none/.cproject index cbf0026f5..350f67d2c 100644 --- a/demos/device/device_os_none/.cproject +++ b/demos/device/device_os_none/.cproject @@ -211,7 +211,7 @@ <builder buildPath="${workspace_loc:/device_keyboard/Debug}" enableAutoBuild="false" enabledIncrementalBuild="true" errorParsers="org.eclipse.cdt.core.GmakeErrorParser;org.eclipse.cdt.core.CWDLocator" id="com.crt.advproject.builder.exe.debug.491161730" incrementalBuildTarget="all" keepEnvironmentInBuildfile="false" managedBuildOn="true" name="Gnu Make Builder" superClass="com.crt.advproject.builder.exe.debug"/>
<tool id="com.crt.advproject.cpp.exe.debug.1586184655" name="MCU C++ Compiler" superClass="com.crt.advproject.cpp.exe.debug"/>
<tool command="arm-none-eabi-gcc" commandLinePattern="${COMMAND} ${FLAGS} ${CFLAGS} ${OUTPUT_FLAG}${OUTPUT_PREFIX}${OUTPUT} ${INPUTS}" errorParsers="org.eclipse.cdt.core.GCCErrorParser" id="com.crt.advproject.gcc.exe.debug.1058924021" name="MCU C Compiler" superClass="com.crt.advproject.gcc.exe.debug">
- <option id="com.crt.advproject.gcc.arch.1901283003" name="Architecture" superClass="com.crt.advproject.gcc.arch" value="com.crt.advproject.gcc.target.cm3" valueType="enumerated"/>
+ <option id="com.crt.advproject.gcc.arch.1901283003" name="Architecture" superClass="com.crt.advproject.gcc.arch" value="com.crt.advproject.gcc.target.cm4" valueType="enumerated"/>
<option id="com.crt.advproject.gcc.thumb.1993301691" name="Thumb mode" superClass="com.crt.advproject.gcc.thumb" value="true" valueType="boolean"/>
<option id="gnu.c.compiler.option.preprocessor.def.symbols.211439980" name="Defined symbols (-D)" superClass="gnu.c.compiler.option.preprocessor.def.symbols" valueType="definedSymbols">
<listOptionValue builtIn="false" value="__REDLIB__"/>
@@ -228,7 +228,7 @@ <listOptionValue builtIn="false" value=""${workspace_loc:/${ProjName}/bsp/lpc43xx/CMSIS_LPC43xx_DriverLib/inc}""/>
<listOptionValue builtIn="false" value=""${workspace_loc:/${ProjName}/bsp}""/>
<listOptionValue builtIn="false" value=""${workspace_loc:/${ProjName}/tinyusb}""/>
- <listOptionValue builtIn="false" value=""${workspace_loc:/${ProjName}}""/>
+ <listOptionValue builtIn="false" value=""${workspace_loc:/${ProjName}/src}""/>
</option>
<option id="gnu.c.compiler.option.include.files.1591137801" name="Include files (-include)" superClass="gnu.c.compiler.option.include.files"/>
<option id="com.crt.advproject.c.misc.dialect.1981378188" name="C Dialect" superClass="com.crt.advproject.c.misc.dialect" value="com.crt.advproject.misc.dialect.gnu99" valueType="enumerated"/>
@@ -238,7 +238,7 @@ <inputType id="com.crt.advproject.compiler.input.864372614" superClass="com.crt.advproject.compiler.input"/>
</tool>
<tool command="arm-none-eabi-gcc" commandLinePattern="${COMMAND} ${FLAGS} ${OUTPUT_FLAG}${OUTPUT_PREFIX}${OUTPUT} ${INPUTS}" errorParsers="org.eclipse.cdt.core.GASErrorParser" id="com.crt.advproject.gas.exe.debug.73154126" name="MCU Assembler" superClass="com.crt.advproject.gas.exe.debug">
- <option id="com.crt.advproject.gas.arch.767404687" name="Architecture" superClass="com.crt.advproject.gas.arch" value="com.crt.advproject.gas.target.cm3" valueType="enumerated"/>
+ <option id="com.crt.advproject.gas.arch.767404687" name="Architecture" superClass="com.crt.advproject.gas.arch" value="com.crt.advproject.gas.target.cm4" valueType="enumerated"/>
<option id="com.crt.advproject.gas.thumb.1342467320" name="Thumb mode" superClass="com.crt.advproject.gas.thumb" value="true" valueType="boolean"/>
<option id="gnu.both.asm.option.flags.crt.357381448" name="Assembler flags" superClass="gnu.both.asm.option.flags.crt" value="-c -x assembler-with-cpp -D__REDLIB__ -DDEBUG -D__CODE_RED" valueType="string"/>
<option id="com.crt.advproject.gas.fpu.1588814622" name="Floating point" superClass="com.crt.advproject.gas.fpu" value="com.crt.advproject.gas.fpu.fpv4" valueType="enumerated"/>
@@ -247,7 +247,7 @@ </tool>
<tool id="com.crt.advproject.link.cpp.exe.debug.1716426006" name="MCU C++ Linker" superClass="com.crt.advproject.link.cpp.exe.debug"/>
<tool command="arm-none-eabi-gcc" commandLinePattern="${COMMAND} ${FLAGS} ${OUTPUT_FLAG}${OUTPUT_PREFIX}${OUTPUT} ${INPUTS}" errorParsers="org.eclipse.cdt.core.GLDErrorParser" id="com.crt.advproject.link.exe.debug.2143352384" name="MCU Linker" superClass="com.crt.advproject.link.exe.debug">
- <option id="com.crt.advproject.link.arch.449102543" name="Architecture" superClass="com.crt.advproject.link.arch" value="com.crt.advproject.link.target.cm3" valueType="enumerated"/>
+ <option id="com.crt.advproject.link.arch.449102543" name="Architecture" superClass="com.crt.advproject.link.arch" value="com.crt.advproject.link.target.cm4" valueType="enumerated"/>
<option id="com.crt.advproject.link.thumb.1645494591" name="Thumb mode" superClass="com.crt.advproject.link.thumb" value="true" valueType="boolean"/>
<option id="com.crt.advproject.link.script.1301365456" name="Linker script" superClass="com.crt.advproject.link.script" value=""device_os_none_Board_EA4357.ld"" valueType="string"/>
<option id="com.crt.advproject.link.manage.679369872" name="Manage linker script" superClass="com.crt.advproject.link.manage" value="true" valueType="boolean"/>
@@ -473,49 +473,86 @@ <storageModule moduleId="com.crt.config">
<projectStorage><?xml version="1.0" encoding="UTF-8"?>
<TargetConfig>
-<Properties property_0="" property_3="NXP" property_4="LPC1347" property_count="5" version="1"/>
-<infoList vendor="NXP"><info chip="LPC1347" match_id="0x08020543" name="LPC1347" stub="crt_emu_lpc11_13_nxp"><chip><name>LPC1347</name>
-<family>LPC13xx (12bit ADC)</family>
+<Properties property_0="" property_2="LPC18x7_43x7_2x512_BootA.cfx" property_3="NXP" property_4="LPC4357" property_count="5" version="1"/>
+<infoList vendor="NXP"><info chip="LPC4357" flash_driver="LPC18x7_43x7_2x512_BootA.cfx" match_id="0x0" name="LPC4357" resetscript="LPC18LPC43InternalFLASHBootResetscript.scp" stub="crt_emu_lpc18_43_nxp"><chip><name>LPC4357</name>
+<family>LPC43xx</family>
<vendor>NXP (formerly Philips)</vendor>
<reset board="None" core="Real" sys="Real"/>
-<clock changeable="TRUE" freq="12MHz" is_accurate="TRUE"/>
+<clock changeable="TRUE" freq="20MHz" is_accurate="TRUE"/>
<memory can_program="true" id="Flash" is_ro="true" type="Flash"/>
<memory id="RAM" type="RAM"/>
<memory id="Periph" is_volatile="true" type="Peripheral"/>
-<memoryInstance derived_from="Flash" id="MFlash64" location="0x0" size="0x10000"/>
-<memoryInstance derived_from="RAM" id="RamLoc8" location="0x10000000" size="0x2000"/>
-<memoryInstance derived_from="RAM" id="RamUsb2" location="0x20004000" size="0x800"/>
-<memoryInstance derived_from="RAM" id="RamPeriph2" location="0x20000000" size="0x800"/>
-<prog_flash blocksz="0x1000" location="0x0" maxprgbuff="0x400" progwithcode="TRUE" size="0x10000"/>
+<memoryInstance derived_from="Flash" id="MFlashA512" location="0x1a000000" size="0x80000"/>
+<memoryInstance derived_from="Flash" id="MFlashB512" location="0x1b000000" size="0x80000"/>
+<memoryInstance derived_from="RAM" id="RamLoc32" location="0x10000000" size="0x8000"/>
+<memoryInstance derived_from="RAM" id="RamLoc40" location="0x10080000" size="0xa000"/>
+<memoryInstance derived_from="RAM" id="RamAHB32" location="0x20000000" size="0x8000"/>
+<memoryInstance derived_from="RAM" id="RamAHB16" location="0x20008000" size="0x4000"/>
+<memoryInstance derived_from="RAM" id="RamAHB_ETB16" location="0x2000c000" size="0x4000"/>
+<prog_flash blocksz="0x2000" location="0x1a000000" maxprgbuff="0x400" progwithcode="TRUE" size="0x10000"/>
+<prog_flash blocksz="0x10000" location="0x1a010000" maxprgbuff="0x400" progwithcode="TRUE" size="0x70000"/>
+<prog_flash blocksz="0x2000" location="0x1b000000" maxprgbuff="0x400" progwithcode="TRUE" size="0x10000"/>
+<prog_flash blocksz="0x10000" location="0x1b010000" maxprgbuff="0x400" progwithcode="TRUE" size="0x70000"/>
<peripheralInstance derived_from="V7M_MPU" id="MPU" location="0xe000ed90"/>
<peripheralInstance derived_from="V7M_NVIC" id="NVIC" location="0xe000e000"/>
<peripheralInstance derived_from="V7M_DCR" id="DCR" location="0xe000edf0"/>
<peripheralInstance derived_from="V7M_ITM" id="ITM" location="0xe0000000"/>
-<peripheralInstance derived_from="I2C" id="I2C" location="0x40000000"/>
-<peripheralInstance derived_from="WWDT" id="WWDT" location="0x40004000"/>
-<peripheralInstance derived_from="USART" id="USART" location="0x40008000"/>
-<peripheralInstance derived_from="CT16B0" id="CT16B0" location="0x4000c000"/>
-<peripheralInstance derived_from="CT16B1" id="CT16B1" location="0x40010000"/>
-<peripheralInstance derived_from="CT32B0" id="CT32B0" location="0x40014000"/>
-<peripheralInstance derived_from="CT32B1" id="CT32B1" location="0x40018000"/>
-<peripheralInstance derived_from="ADC" id="ADC" location="0x4001c000"/>
-<peripheralInstance derived_from="PMU" id="PMU" location="0x40038000"/>
-<peripheralInstance derived_from="FLASHCTRL" id="FLASHCTRL" location="0x4003c000"/>
-<peripheralInstance derived_from="SSP0" id="SSP0" location="0x40040000"/>
-<peripheralInstance derived_from="IOCON" id="IOCON" location="0x40044000"/>
-<peripheralInstance derived_from="SYSCON" id="SYSCON" location="0x40048000"/>
-<peripheralInstance derived_from="GPIO-PIN-INT" id="GPIO-PIN-INT" location="0x4004c000"/>
-<peripheralInstance derived_from="SSP1" id="SSP1" location="0x40058000"/>
-<peripheralInstance derived_from="GPIO-GROUP-INT0" id="GPIO-GROUP-INT0" location="0x4005c000"/>
-<peripheralInstance derived_from="GPIO-GROUP-INT1" id="GPIO-GROUP-INT1" location="0x40060000"/>
-<peripheralInstance derived_from="RITIMER" id="RITIMER" location="0x40064000"/>
-<peripheralInstance derived_from="USB" id="USB" location="0x40080000"/>
-<peripheralInstance derived_from="GPIO-PORT" id="GPIO-PORT" location="0x50000000"/>
+<peripheralInstance derived_from="SCT" id="SCT" location="0x40000000"/>
+<peripheralInstance derived_from="GPDMA" id="GPDMA" location="0x40002000"/>
+<peripheralInstance derived_from="SPIFI" id="SPIFI" location="0x40003000"/>
+<peripheralInstance derived_from="SDMMC" id="SDMMC" location="0x40004000"/>
+<peripheralInstance derived_from="EMC" id="EMC" location="0x40005000"/>
+<peripheralInstance derived_from="USB0" id="USB0" location="0x40006000"/>
+<peripheralInstance derived_from="USB1" id="USB1" location="0x40007000"/>
+<peripheralInstance derived_from="LCD" id="LCD" location="0x40008000"/>
+<peripheralInstance derived_from="EEPROM" id="EEPROM" location="0x4000e000"/>
+<peripheralInstance derived_from="ETHERNET" id="ETHERNET" location="0x40010000"/>
+<peripheralInstance derived_from="ATIMER" id="ATIMER" location="0x40040000"/>
+<peripheralInstance derived_from="REGFILE" id="REGFILE" location="0x40041000"/>
+<peripheralInstance derived_from="PMC" id="PMC" location="0x40042000"/>
+<peripheralInstance derived_from="CREG" id="CREG" location="0x40043000"/>
+<peripheralInstance derived_from="EVENTROUTER" id="EVENTROUTER" location="0x40044000"/>
+<peripheralInstance derived_from="RTC" id="RTC" location="0x40046000"/>
+<peripheralInstance derived_from="CGU" id="CGU" location="0x40050000"/>
+<peripheralInstance derived_from="CCU1" id="CCU1" location="0x40051000"/>
+<peripheralInstance derived_from="CCU2" id="CCU2" location="0x40052000"/>
+<peripheralInstance derived_from="RGU" id="RGU" location="0x40053000"/>
+<peripheralInstance derived_from="WWDT" id="WWDT" location="0x40080000"/>
+<peripheralInstance derived_from="USART0" id="USART0" location="0x40081000"/>
+<peripheralInstance derived_from="USART2" id="USART2" location="0x400c1000"/>
+<peripheralInstance derived_from="USART3" id="USART3" location="0x400c2000"/>
+<peripheralInstance derived_from="UART1" id="UART1" location="0x40082000"/>
+<peripheralInstance derived_from="SSP0" id="SSP0" location="0x40083000"/>
+<peripheralInstance derived_from="SSP1" id="SSP1" location="0x400c5000"/>
+<peripheralInstance derived_from="TIMER0" id="TIMER0" location="0x40084000"/>
+<peripheralInstance derived_from="TIMER1" id="TIMER1" location="0x40085000"/>
+<peripheralInstance derived_from="TIMER2" id="TIMER2" location="0x400c3000"/>
+<peripheralInstance derived_from="TIMER3" id="TIMER3" location="0x400c4000"/>
+<peripheralInstance derived_from="SCU" id="SCU" location="0x40086000"/>
+<peripheralInstance derived_from="GPIO-PIN-INT" id="GPIO-PIN-INT" location="0x40087000"/>
+<peripheralInstance derived_from="GPIO-GROUP-INT0" id="GPIO-GROUP-INT0" location="0x40088000"/>
+<peripheralInstance derived_from="GPIO-GROUP-INT1" id="GPIO-GROUP-INT1" location="0x40089000"/>
+<peripheralInstance derived_from="MCPWM" id="MCPWM" location="0x400a0000"/>
+<peripheralInstance derived_from="I2C0" id="I2C0" location="0x400a1000"/>
+<peripheralInstance derived_from="I2C1" id="I2C1" location="0x400e0000"/>
+<peripheralInstance derived_from="I2S0" id="I2S0" location="0x400a2000"/>
+<peripheralInstance derived_from="I2S1" id="I2S1" location="0x400a3000"/>
+<peripheralInstance derived_from="C-CAN1" id="C-CAN1" location="0x400a4000"/>
+<peripheralInstance derived_from="RITIMER" id="RITIMER" location="0x400c0000"/>
+<peripheralInstance derived_from="QEI" id="QEI" location="0x400c6000"/>
+<peripheralInstance derived_from="GIMA" id="GIMA" location="0x400c7000"/>
+<peripheralInstance derived_from="DAC" id="DAC" location="0x400e1000"/>
+<peripheralInstance derived_from="C-CAN0" id="C-CAN0" location="0x400e2000"/>
+<peripheralInstance derived_from="ADC0" id="ADC0" location="0x400e3000"/>
+<peripheralInstance derived_from="ADC1" id="ADC1" location="0x400e4000"/>
+<peripheralInstance derived_from="GPIO-PORT" id="GPIO-PORT" location="0x400f4000"/>
+<peripheralInstance derived_from="SPI" id="SPI" location="0x40100000"/>
+<peripheralInstance derived_from="SGPIO" id="SGPIO" location="0x40101000"/>
</chip>
-<processor><name gcc_name="cortex-m3">Cortex-M3</name>
+<processor><name gcc_name="cortex-m4">Cortex-M4</name>
<family>Cortex-M</family>
</processor>
-<link href="nxp_lpc13Uxx_peripheral.xme" show="embed" type="simple"/>
+<link href="nxp_lpc43xx_peripheral.xme" show="embed" type="simple"/>
</info>
</infoList>
</TargetConfig></projectStorage>
diff --git a/demos/device/src/main.c b/demos/device/src/main.c index c4e1d785e..a69a710f1 100644 --- a/demos/device/src/main.c +++ b/demos/device/src/main.c @@ -133,6 +133,12 @@ OSAL_TASK_FUNCTION( led_blinking_task ) (void* p_task_para) board_leds(led_on_mask, 1 - led_on_mask); led_on_mask = 1 - led_on_mask; // toggle + uint32_t btn_mask = board_buttons(); + for(uint8_t i=0; i<32; i++) + { + if ( BIT_TEST_(btn_mask, i) ) printf("button %d is pressed\n", i); + } + OSAL_TASK_LOOP_END } diff --git a/demos/device/src/tusb_config.h b/demos/device/src/tusb_config.h index e4224aa39..bfc225351 100644 --- a/demos/device/src/tusb_config.h +++ b/demos/device/src/tusb_config.h @@ -82,11 +82,11 @@ #define TUSB_CFG_DEVICE_FULLSPEED 1 // TODO refractor, remove
//------------- CLASS -------------//
-#define TUSB_CFG_DEVICE_HID_KEYBOARD 0
+#define TUSB_CFG_DEVICE_HID_KEYBOARD 1
#define TUSB_CFG_DEVICE_HID_MOUSE 0
#define TUSB_CFG_DEVICE_HID_GENERIC 0
#define TUSB_CFG_DEVICE_MSC 0
-#define TUSB_CFG_DEVICE_CDC 1
+#define TUSB_CFG_DEVICE_CDC 0
//--------------------------------------------------------------------+
// COMMON CONFIGURATION
|
