diff options
| author | hathach <[email protected]> | 2018-12-03 19:02:35 +0700 |
|---|---|---|
| committer | hathach <[email protected]> | 2018-12-03 19:02:35 +0700 |
| commit | cea9abd4d0554e6969ee5b6edece806edb3ccd13 (patch) | |
| tree | 2f44e09cb23b333c05b079f13befe4a4f0f27680 | |
| parent | f8ea10dc9aaa0cc704c113d9259e6b8c0b3bc56f (diff) | |
clean up lpc13
| -rw-r--r-- | examples/device/cdc_msc_hid/ses/lpc13xx/lpc13xx.emProject | 17 | ||||
| -rw-r--r-- | examples/device/cdc_msc_hid/src/main.c | 2 | ||||
| -rw-r--r-- | examples/device/cdc_msc_hid_freertos/src/main.c | 2 | ||||
| -rw-r--r-- | examples/obsolete/device/src/main.c | 2 | ||||
| -rw-r--r-- | hw/bsp/lpcxpresso1347/board_lpcxpresso1347.c | 55 | ||||
| -rw-r--r-- | hw/bsp/lpcxpresso1347/board_lpcxpresso1347.h | 2 |
6 files changed, 28 insertions, 52 deletions
diff --git a/examples/device/cdc_msc_hid/ses/lpc13xx/lpc13xx.emProject b/examples/device/cdc_msc_hid/ses/lpc13xx/lpc13xx.emProject index 57e97c2da..1826a9220 100644 --- a/examples/device/cdc_msc_hid/ses/lpc13xx/lpc13xx.emProject +++ b/examples/device/cdc_msc_hid/ses/lpc13xx/lpc13xx.emProject @@ -59,7 +59,6 @@ <folder Name="nxp"> <folder Name="lpc_chip_13xx"> <folder Name="inc"> - <file file_name="../../../../../hw/mcu/nxp/lpc_chip_13xx/inc/adc_13xx.h" /> <file file_name="../../../../../hw/mcu/nxp/lpc_chip_13xx/inc/chip.h" /> <file file_name="../../../../../hw/mcu/nxp/lpc_chip_13xx/inc/clock_13xx.h" /> <file file_name="../../../../../hw/mcu/nxp/lpc_chip_13xx/inc/cmsis.h" /> @@ -67,29 +66,13 @@ <file file_name="../../../../../hw/mcu/nxp/lpc_chip_13xx/inc/core_cm3.h" /> <file file_name="../../../../../hw/mcu/nxp/lpc_chip_13xx/inc/core_cmFunc.h" /> <file file_name="../../../../../hw/mcu/nxp/lpc_chip_13xx/inc/core_cmInstr.h" /> - <file file_name="../../../../../hw/mcu/nxp/lpc_chip_13xx/inc/error.h" /> - <file file_name="../../../../../hw/mcu/nxp/lpc_chip_13xx/inc/flash_13xx.h" /> - <file file_name="../../../../../hw/mcu/nxp/lpc_chip_13xx/inc/fmc_13xx.h" /> <file file_name="../../../../../hw/mcu/nxp/lpc_chip_13xx/inc/gpio_13xx_1.h" /> <file file_name="../../../../../hw/mcu/nxp/lpc_chip_13xx/inc/gpio_13xx_2.h" /> - <file file_name="../../../../../hw/mcu/nxp/lpc_chip_13xx/inc/gpiogroup_13xx.h" /> - <file file_name="../../../../../hw/mcu/nxp/lpc_chip_13xx/inc/i2c_13xx.h" /> - <file file_name="../../../../../hw/mcu/nxp/lpc_chip_13xx/inc/i2cm_13xx.h" /> <file file_name="../../../../../hw/mcu/nxp/lpc_chip_13xx/inc/iocon_13xx.h" /> <file file_name="../../../../../hw/mcu/nxp/lpc_chip_13xx/inc/lpc_types.h" /> - <file file_name="../../../../../hw/mcu/nxp/lpc_chip_13xx/inc/pinint_13xx.h" /> - <file file_name="../../../../../hw/mcu/nxp/lpc_chip_13xx/inc/pmu_13xx.h" /> - <file file_name="../../../../../hw/mcu/nxp/lpc_chip_13xx/inc/ring_buffer.h" /> - <file file_name="../../../../../hw/mcu/nxp/lpc_chip_13xx/inc/ritimer_13xx.h" /> - <file file_name="../../../../../hw/mcu/nxp/lpc_chip_13xx/inc/romapi_13xx.h" /> - <file file_name="../../../../../hw/mcu/nxp/lpc_chip_13xx/inc/ssp_13xx.h" /> - <file file_name="../../../../../hw/mcu/nxp/lpc_chip_13xx/inc/stopwatch.h" /> <file file_name="../../../../../hw/mcu/nxp/lpc_chip_13xx/inc/sys_config.h" /> <file file_name="../../../../../hw/mcu/nxp/lpc_chip_13xx/inc/sysctl_13xx.h" /> - <file file_name="../../../../../hw/mcu/nxp/lpc_chip_13xx/inc/timer_13xx.h" /> <file file_name="../../../../../hw/mcu/nxp/lpc_chip_13xx/inc/uart_13xx.h" /> - <file file_name="../../../../../hw/mcu/nxp/lpc_chip_13xx/inc/usbd_13xx.h" /> - <file file_name="../../../../../hw/mcu/nxp/lpc_chip_13xx/inc/wwdt_13xx.h" /> </folder> <folder Name="src"> <file file_name="../../../../../hw/mcu/nxp/lpc_chip_13xx/src/chip_13xx.c" /> diff --git a/examples/device/cdc_msc_hid/src/main.c b/examples/device/cdc_msc_hid/src/main.c index 03bc8a879..d88bd3726 100644 --- a/examples/device/cdc_msc_hid/src/main.c +++ b/examples/device/cdc_msc_hid/src/main.c @@ -201,7 +201,7 @@ void led_blinking_task(void) if ( !tu_timeout_expired(&tm) ) return; // not enough time tu_timeout_reset(&tm); - board_led_control(BOARD_LED0, led_state); + board_led_control(led_state); led_state = 1 - led_state; // toggle } diff --git a/examples/device/cdc_msc_hid_freertos/src/main.c b/examples/device/cdc_msc_hid_freertos/src/main.c index d5a5d0c2c..fbe1ec93e 100644 --- a/examples/device/cdc_msc_hid_freertos/src/main.c +++ b/examples/device/cdc_msc_hid_freertos/src/main.c @@ -216,7 +216,7 @@ void led_blinky_cb(TimerHandle_t xTimer) (void) xTimer; static bool led_state = false; - board_led_control(BOARD_LED0, led_state); + board_led_control(led_state); led_state = 1 - led_state; // toggle } diff --git a/examples/obsolete/device/src/main.c b/examples/obsolete/device/src/main.c index 00633335a..7de6fd32b 100644 --- a/examples/obsolete/device/src/main.c +++ b/examples/obsolete/device/src/main.c @@ -163,7 +163,7 @@ tusb_error_t led_blinking_subtask(void) osal_task_delay(led_blink_interval_ms); - board_led_control(BOARD_LED0, led_state); + board_led_control(led_state); led_state = 1 - led_state; // toggle // uint32_t btn_mask; diff --git a/hw/bsp/lpcxpresso1347/board_lpcxpresso1347.c b/hw/bsp/lpcxpresso1347/board_lpcxpresso1347.c index c17005c34..1ae21efab 100644 --- a/hw/bsp/lpcxpresso1347/board_lpcxpresso1347.c +++ b/hw/bsp/lpcxpresso1347/board_lpcxpresso1347.c @@ -40,10 +40,8 @@ #include "../board.h" -#define LED_PORT (0) -#define LED_PIN (7) -#define LED_ON (1) -#define LED_OFF (0) +#define LED_PORT 0 +#define LED_PIN 7 const static struct { uint8_t port; @@ -63,38 +61,41 @@ enum { BOARD_BUTTON_COUNT = sizeof(buttons) / sizeof(buttons[0]) }; -// required by lpcopen chip layer +/* System oscillator rate and RTC oscillator rate */ const uint32_t OscRateIn = 12000000; const uint32_t ExtRateIn = 0; /* Pin muxing table, only items that need changing from their default pin state are in this table. */ -static const PINMUX_GRP_T pinmuxing[] = { - {0, 1, (IOCON_FUNC1 | IOCON_RESERVED_BIT_7 | IOCON_MODE_INACT)}, /* PIO0_1 used for CLKOUT */ - {0, 2, (IOCON_FUNC1 | IOCON_RESERVED_BIT_7 | IOCON_MODE_PULLUP)}, /* PIO0_2 used for SSEL */ - {0, 3, (IOCON_FUNC1 | IOCON_RESERVED_BIT_7 | IOCON_MODE_INACT)}, /* PIO0_3 used for USB_VBUS */ - {0, 4, (IOCON_FUNC1 | IOCON_FASTI2C_EN)}, /* PIO0_4 used for SCL */ - {0, 5, (IOCON_FUNC1 | IOCON_FASTI2C_EN)}, /* PIO0_5 used for SDA */ - {0, 6, (IOCON_FUNC1 | IOCON_RESERVED_BIT_7 | IOCON_MODE_INACT)}, /* PIO0_6 used for USB_CONNECT */ - {0, 8, (IOCON_FUNC1 | IOCON_RESERVED_BIT_7 | IOCON_MODE_INACT)}, /* PIO0_8 used for MISO0 */ - {0, 9, (IOCON_FUNC1 | IOCON_RESERVED_BIT_7 | IOCON_MODE_INACT)}, /* PIO0_9 used for MOSI0 */ - {0, 11, (IOCON_FUNC2 | IOCON_ADMODE_EN | IOCON_FILT_DIS)}, /* PIO0_11 used for AD0 */ - {0, 18, (IOCON_FUNC1 | IOCON_RESERVED_BIT_7 | IOCON_MODE_INACT)}, /* PIO0_18 used for RXD */ - {0, 19, (IOCON_FUNC1 | IOCON_RESERVED_BIT_7 | IOCON_MODE_INACT)}, /* PIO0_19 used for TXD */ - {1, 29, (IOCON_FUNC1 | IOCON_RESERVED_BIT_7 | IOCON_MODE_INACT)}, /* PIO1_29 used for SCK0 */ +static const PINMUX_GRP_T pinmuxing[] = +{ + {0, 1, (IOCON_FUNC1 | IOCON_RESERVED_BIT_7 | IOCON_MODE_INACT)}, /* PIO0_1 used for CLKOUT */ + {0, 2, (IOCON_FUNC1 | IOCON_RESERVED_BIT_7 | IOCON_MODE_PULLUP)}, /* PIO0_2 used for SSEL */ + {0, 3, (IOCON_FUNC1 | IOCON_RESERVED_BIT_7 | IOCON_MODE_INACT)}, /* PIO0_3 used for USB_VBUS */ + {0, 4, (IOCON_FUNC1 | IOCON_FASTI2C_EN)}, /* PIO0_4 used for SCL */ + {0, 5, (IOCON_FUNC1 | IOCON_FASTI2C_EN)}, /* PIO0_5 used for SDA */ + {0, 6, (IOCON_FUNC1 | IOCON_RESERVED_BIT_7 | IOCON_MODE_INACT)}, /* PIO0_6 used for USB_CONNECT */ + {0, 8, (IOCON_FUNC1 | IOCON_RESERVED_BIT_7 | IOCON_MODE_INACT)}, /* PIO0_8 used for MISO0 */ + {0, 9, (IOCON_FUNC1 | IOCON_RESERVED_BIT_7 | IOCON_MODE_INACT)}, /* PIO0_9 used for MOSI0 */ + {0, 11, (IOCON_FUNC2 | IOCON_ADMODE_EN | IOCON_FILT_DIS)}, /* PIO0_11 used for AD0 */ + {0, 18, (IOCON_FUNC1 | IOCON_RESERVED_BIT_7 | IOCON_MODE_INACT)}, /* PIO0_18 used for RXD */ + {0, 19, (IOCON_FUNC1 | IOCON_RESERVED_BIT_7 | IOCON_MODE_INACT)}, /* PIO0_19 used for TXD */ + {1, 29, (IOCON_FUNC1 | IOCON_RESERVED_BIT_7 | IOCON_MODE_INACT)}, /* PIO1_29 used for SCK0 */ }; // Invoked by startup code void SystemInit(void) { - /* Enable IOCON clock */ - Chip_Clock_EnablePeriphClock(SYSCTL_CLOCK_IOCON); - Chip_IOCON_SetPinMuxing(LPC_IOCON, pinmuxing, sizeof(pinmuxing) / sizeof(PINMUX_GRP_T)); + /* Enable IOCON clock */ + Chip_Clock_EnablePeriphClock(SYSCTL_CLOCK_IOCON); + Chip_IOCON_SetPinMuxing(LPC_IOCON, pinmuxing, sizeof(pinmuxing) / sizeof(PINMUX_GRP_T)); Chip_SetupXtalClocking(); } void board_init(void) { + SystemCoreClockUpdate(); + #if CFG_TUSB_OS == OPT_OS_NONE SysTick_Config(SystemCoreClock / BOARD_TICKS_HZ); // 1 msec tick timer #endif @@ -102,7 +103,7 @@ void board_init(void) Chip_GPIO_Init(LPC_GPIO_PORT); //------------- LED -------------// - Chip_GPIO_SetPinDIROutput(LPC_GPIO_PORT, 0, BOARD_LED0); + Chip_GPIO_SetPinDIROutput(LPC_GPIO_PORT, LED_PORT, LED_PIN); //------------- BUTTON -------------// // for(uint8_t i=0; i<BOARD_BUTTON_COUNT; i++) GPIOSetDir(buttons[i].port, BIT_(buttons[i].pin), 0); @@ -134,15 +135,9 @@ uint32_t tusb_hal_millis(void) //--------------------------------------------------------------------+ // LEDS //--------------------------------------------------------------------+ -void board_led_control(uint32_t id, bool state) +void board_led_control(bool state) { - if (state) - { - Chip_GPIO_SetValue(LPC_GPIO_PORT, 0, 1 << id); - }else - { - Chip_GPIO_ClearValue(LPC_GPIO_PORT, 0, 1 << id); - } + Chip_GPIO_SetPinState(LPC_GPIO_PORT, LED_PORT, LED_PIN, state); } //--------------------------------------------------------------------+ diff --git a/hw/bsp/lpcxpresso1347/board_lpcxpresso1347.h b/hw/bsp/lpcxpresso1347/board_lpcxpresso1347.h index 8fc4bbe03..81a631fb5 100644 --- a/hw/bsp/lpcxpresso1347/board_lpcxpresso1347.h +++ b/hw/bsp/lpcxpresso1347/board_lpcxpresso1347.h @@ -45,8 +45,6 @@ #include "chip.h" -#define BOARD_LED0 7 - #ifdef __cplusplus } #endif |
