예제 #1
0
파일: board.c 프로젝트: FEDEVEL/openrex-lpc
/* Initializes board Button(s) */
static void Board_BTN_Init(void)
{
    pinmux_t buttons[] = { ONBOARD_BTNS };
    Chip_GPIO_Init(LPC_GPIO_PORT);
    for (int i = 0; i < (sizeof(buttons)/sizeof(buttons[0])); i++)
    {
        Chip_GPIO_SetPinDIRInput(LPC_GPIO_PORT, TO_PORT(buttons[i]), TO_PIN(buttons[i]));
    }
}
예제 #2
0
파일: board.c 프로젝트: FEDEVEL/openrex-lpc
/* Initializes board LED(s) */
static void Board_LED_Init(void)
{
    pinmux_t leds[] = { ONBOARD_LEDS };
    Chip_GPIO_Init(LPC_GPIO_PORT);
    for (int i = 0; i < (sizeof(leds)/sizeof(leds[0])); i++)
    {
        Chip_GPIO_SetPinDIROutput(LPC_GPIO_PORT, TO_PORT(leds[i]), TO_PIN(leds[i]));
    }
}
예제 #3
0
파일: board.c 프로젝트: FEDEVEL/openrex-lpc
void BOARD_assert(const char *file, const int line)
{
    /* NOTE: If LED 24 (the one next to power supply connector) blinks, 
     * it means that your application has some serious issues */

    /* IOCON and GPIO doesn't have to be enabled at this point */
    Chip_Clock_EnablePeriphClock(SYSCTL_CLOCK_IOCON);
    Chip_GPIO_Init(LPC_GPIO_PORT);
    /* set mux and output direction */
    Chip_IOCON_PinMuxSet(LPC_IOCON, TO_PORT(ONBOARD_ASSERT_LED), TO_PIN(ONBOARD_ASSERT_LED), ONBOARDCFG_ASSERT_LED);
    Chip_GPIO_SetPinDIROutput(LPC_GPIO_PORT, TO_PORT(ONBOARD_ASSERT_LED), TO_PIN(ONBOARD_ASSERT_LED));
    /* blink forever. the speed depends on core clock settings */
    for (volatile int i = 1; i; )
    {
        Board_LED_SetLevel(ONBOARD_ASSERT_LED, true);
        for (volatile int k = 500000; k; k--) __asm("nop");
        Board_LED_SetLevel(ONBOARD_ASSERT_LED, false);
        for (volatile int k = 500000; k; k--) __asm("nop");
    }
}
예제 #4
0
파일: board.c 프로젝트: FEDEVEL/openrex-lpc
/* Get the GPIO level of board Button */
bool Board_BTN_GetLevel(pinmux_t pinmux)
{
    return Chip_GPIO_ReadPortBit(LPC_GPIO_PORT, TO_PORT(pinmux), TO_PIN(pinmux));
}
예제 #5
0
파일: board.c 프로젝트: FEDEVEL/openrex-lpc
/* Set the GPIO level of board LED */
void Board_LED_SetLevel(pinmux_t pinmux, bool high)
{
    Chip_GPIO_WriteDirBit(LPC_GPIO_PORT, TO_PORT(pinmux), TO_PIN(pinmux), high);
}
예제 #6
0
int gpio_get(int pin)
{
	return MAP_GPIOPinRead(TO_BASE(pin), TO_PIN(pin));
}
예제 #7
0
void gpio_set(int pin, int value)
{
	value = !!value;

	MAP_GPIOPinWrite(TO_BASE(pin), TO_PIN(pin), (value << TO_PIN(pin)));
}