clean up lpc13

This commit is contained in:
hathach 2018-12-03 19:02:35 +07:00
parent f8ea10dc9a
commit cea9abd4d0
No known key found for this signature in database
GPG Key ID: 2FA891220FBFD581
6 changed files with 28 additions and 52 deletions

View File

@ -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" />

View File

@ -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
}

View File

@ -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
}

View File

@ -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;

View File

@ -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);
}
//--------------------------------------------------------------------+

View File

@ -45,8 +45,6 @@
#include "chip.h"
#define BOARD_LED0 7
#ifdef __cplusplus
}
#endif