mirror of
https://github.com/hathach/tinyusb.git
synced 2025-03-14 04:18:56 +00:00
work with lpc11u37 (lpc11uxx) on kevin's board
This commit is contained in:
parent
cc45f35d70
commit
cd74f4f0ed
66
demos/bsp/boards/board_at86rf2xx_11uxx.c
Normal file
66
demos/bsp/boards/board_at86rf2xx_11uxx.c
Normal file
@ -0,0 +1,66 @@
|
||||
/*
|
||||
* board_at86rf2xx_11uxx.c
|
||||
*
|
||||
* Created on: Dec 7, 2012
|
||||
* Author: hathach
|
||||
*/
|
||||
|
||||
/*
|
||||
* Software License Agreement (BSD License)
|
||||
* Copyright (c) 2012, hathach (tinyusb.net)
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without modification,
|
||||
* are permitted provided that the following conditions are met:
|
||||
*
|
||||
* 1. Redistributions of source code must retain the above copyright notice,
|
||||
* this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright notice,
|
||||
* this list of conditions and the following disclaimer in the documentation
|
||||
* and/or other materials provided with the distribution.
|
||||
* 3. The name of the author may not be used to endorse or promote products
|
||||
* derived from this software without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED
|
||||
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
|
||||
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT
|
||||
* SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
|
||||
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT
|
||||
* OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
||||
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
||||
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
|
||||
* IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY
|
||||
* OF SUCH DAMAGE.
|
||||
*
|
||||
* This file is part of the tiny usb stack.
|
||||
*/
|
||||
|
||||
#include "board.h"
|
||||
|
||||
#if BOARD == BOARD_AT86RF2XX_11UXX
|
||||
|
||||
#include "LPC11Uxx.h"
|
||||
#include "gpio.h"
|
||||
|
||||
#define CFG_LED_PORT (1)
|
||||
#define CFG_LED_PIN (31)
|
||||
#define CFG_LED_ON (0)
|
||||
#define CFG_LED_OFF (1)
|
||||
|
||||
void board_init(void)
|
||||
{
|
||||
SystemInit();
|
||||
SysTick_Config(SystemCoreClock / TICKS_PER_SECOND); // 1 msec tick timer
|
||||
GPIOInit();
|
||||
|
||||
// GPIOSetDir(CFG_LED_PORT, CFG_LED_PIN, 1);
|
||||
board_leds(0x01, 0); // turn off the led first
|
||||
}
|
||||
|
||||
void board_leds(uint32_t mask, uint32_t state)
|
||||
{
|
||||
// if (mask)
|
||||
// GPIOSetBitValue(CFG_LED_PORT, CFG_LED_PIN, mask & state ? CFG_LED_ON : CFG_LED_OFF);
|
||||
}
|
||||
|
||||
#endif
|
64
demos/bsp/lpc11uxx/inc/gpio.h
Normal file
64
demos/bsp/lpc11uxx/inc/gpio.h
Normal file
@ -0,0 +1,64 @@
|
||||
/****************************************************************************
|
||||
* $Id:: gpio.h 6172 2011-01-13 18:22:51Z usb00423 $
|
||||
* Project: NXP LPC11Uxx software example
|
||||
*
|
||||
* Description:
|
||||
* This file contains definition and prototype for GPIO.
|
||||
*
|
||||
****************************************************************************
|
||||
* 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.
|
||||
* NXP Semiconductors 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. NXP Semiconductors
|
||||
* reserves the right to make changes in the software without
|
||||
* notification. NXP Semiconductors also make no representation or
|
||||
* warranty that such application will be suitable for the specified
|
||||
* use without further testing or modification.
|
||||
****************************************************************************/
|
||||
#ifndef __GPIO_H
|
||||
#define __GPIO_H
|
||||
|
||||
#define CHANNEL0 0
|
||||
#define CHANNEL1 1
|
||||
#define CHANNEL2 2
|
||||
#define CHANNEL3 3
|
||||
#define CHANNEL4 4
|
||||
#define CHANNEL5 5
|
||||
#define CHANNEL6 6
|
||||
#define CHANNEL7 7
|
||||
|
||||
#define PORT0 0
|
||||
#define PORT1 1
|
||||
|
||||
#define GROUP0 0
|
||||
#define GROUP1 1
|
||||
|
||||
void FLEX_INT0_IRQHandler(void);
|
||||
void FLEX_INT1_IRQHandler(void);
|
||||
void FLEX_INT2_IRQHandler(void);
|
||||
void FLEX_INT3_IRQHandler(void);
|
||||
void FLEX_INT4_IRQHandler(void);
|
||||
void FLEX_INT5_IRQHandler(void);
|
||||
void FLEX_INT6_IRQHandler(void);
|
||||
void FLEX_INT7_IRQHandler(void);
|
||||
void GINT0_IRQHandler(void);
|
||||
void GINT1_IRQHandler(void);
|
||||
void GPIOInit( void );
|
||||
void GPIOSetFlexInterrupt( uint32_t channelNum, uint32_t portNum, uint32_t bitPosi,
|
||||
uint32_t sense, uint32_t event );
|
||||
void GPIOFlexIntEnable( uint32_t channelNum, uint32_t event );
|
||||
void GPIOFlexIntDisable( uint32_t channelNum, uint32_t event );
|
||||
uint32_t GPIOFlexIntStatus( uint32_t channelNum );
|
||||
void GPIOFlexIntClear( uint32_t channelNum );
|
||||
void GPIOSetGroupedInterrupt( uint32_t groupNum, uint32_t *bitPattern, uint32_t logic,
|
||||
uint32_t sense, uint32_t *eventPattern );
|
||||
uint32_t GPIOGetPinValue( uint32_t portNum, uint32_t bitPosi );
|
||||
void GPIOSetBitValue( uint32_t portNum, uint32_t bitPosi, uint32_t bitVal );
|
||||
void GPIOSetDir( uint32_t portNum, uint32_t bitPosi, uint32_t dir );
|
||||
|
||||
#endif /* end __GPIO_H */
|
||||
/*****************************************************************************
|
||||
** End Of File
|
||||
******************************************************************************/
|
819
demos/bsp/lpc11uxx/src/gpio.c
Normal file
819
demos/bsp/lpc11uxx/src/gpio.c
Normal file
@ -0,0 +1,819 @@
|
||||
/****************************************************************************
|
||||
* $Id:: gpio.c 6172 2011-01-13 18:22:51Z usb00423 $
|
||||
* Project: NXP LPC11Uxx GPIO example
|
||||
*
|
||||
* Description:
|
||||
* This file contains GPIO code example which include GPIO
|
||||
* initialization, GPIO interrupt handler, and related APIs for
|
||||
* GPIO access.
|
||||
*
|
||||
****************************************************************************
|
||||
* 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.
|
||||
* NXP Semiconductors 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. NXP Semiconductors
|
||||
* reserves the right to make changes in the software without
|
||||
* notification. NXP Semiconductors also make no representation or
|
||||
* warranty that such application will be suitable for the specified
|
||||
* use without further testing or modification.
|
||||
****************************************************************************/
|
||||
#include "LPC11Uxx.h" /* LPC11Uxx Peripheral Registers */
|
||||
#include "gpio.h"
|
||||
|
||||
volatile uint32_t flex_int0_counter = 0;
|
||||
volatile uint32_t flex_int1_counter = 0;
|
||||
volatile uint32_t flex_int2_counter = 0;
|
||||
volatile uint32_t flex_int3_counter = 0;
|
||||
volatile uint32_t flex_int4_counter = 0;
|
||||
volatile uint32_t flex_int5_counter = 0;
|
||||
volatile uint32_t flex_int6_counter = 0;
|
||||
volatile uint32_t flex_int7_counter = 0;
|
||||
volatile uint32_t gint0_counter = 0;
|
||||
volatile uint32_t gint1_counter = 0;
|
||||
volatile uint32_t flex_int0_level_counter = 0;
|
||||
volatile uint32_t flex_int0_rising_edge_counter = 0;
|
||||
volatile uint32_t flex_int0_falling_edge_counter = 0;
|
||||
volatile uint32_t flex_int1_level_counter = 0;
|
||||
volatile uint32_t flex_int1_rising_edge_counter = 0;
|
||||
volatile uint32_t flex_int1_falling_edge_counter = 0;
|
||||
volatile uint32_t flex_int2_level_counter = 0;
|
||||
volatile uint32_t flex_int2_rising_edge_counter = 0;
|
||||
volatile uint32_t flex_int2_falling_edge_counter = 0;
|
||||
volatile uint32_t flex_int3_level_counter = 0;
|
||||
volatile uint32_t flex_int3_rising_edge_counter = 0;
|
||||
volatile uint32_t flex_int3_falling_edge_counter = 0;
|
||||
volatile uint32_t flex_int4_level_counter = 0;
|
||||
volatile uint32_t flex_int4_rising_edge_counter = 0;
|
||||
volatile uint32_t flex_int4_falling_edge_counter = 0;
|
||||
volatile uint32_t flex_int5_level_counter = 0;
|
||||
volatile uint32_t flex_int5_rising_edge_counter = 0;
|
||||
volatile uint32_t flex_int5_falling_edge_counter = 0;
|
||||
volatile uint32_t flex_int6_level_counter = 0;
|
||||
volatile uint32_t flex_int6_rising_edge_counter = 0;
|
||||
volatile uint32_t flex_int6_falling_edge_counter = 0;
|
||||
volatile uint32_t flex_int7_level_counter = 0;
|
||||
volatile uint32_t flex_int7_rising_edge_counter = 0;
|
||||
volatile uint32_t flex_int7_falling_edge_counter = 0;
|
||||
volatile uint32_t gint0_level_counter = 0;
|
||||
volatile uint32_t gint0_edge_counter = 0;
|
||||
volatile uint32_t gint1_level_counter = 0;
|
||||
volatile uint32_t gint1_edge_counter = 0;
|
||||
|
||||
/*****************************************************************************
|
||||
** Function name: FLEX_INT0_IRQHandler
|
||||
**
|
||||
** Descriptions: Use one GPIO pin as interrupt source
|
||||
**
|
||||
** parameters: None
|
||||
**
|
||||
** Returned value: None
|
||||
**
|
||||
*****************************************************************************/
|
||||
void FLEX_INT0_IRQHandler(void)
|
||||
{
|
||||
flex_int0_counter++;
|
||||
if ( LPC_GPIO_PIN_INT->IST & (0x1<<0) )
|
||||
{
|
||||
if ( LPC_GPIO_PIN_INT->ISEL & (0x1<<0) )
|
||||
{
|
||||
flex_int0_level_counter++;
|
||||
}
|
||||
else
|
||||
{
|
||||
if ( LPC_GPIO_PIN_INT->RISE & (0x1<<0) )
|
||||
{
|
||||
flex_int0_rising_edge_counter++;
|
||||
LPC_GPIO_PIN_INT->RISE = 0x1<<0;
|
||||
}
|
||||
else if ( LPC_GPIO_PIN_INT->FALL & (0x1<<0) )
|
||||
{
|
||||
flex_int0_falling_edge_counter++;
|
||||
LPC_GPIO_PIN_INT->FALL = 0x1<<0;
|
||||
}
|
||||
LPC_GPIO_PIN_INT->IST = 0x1<<0;
|
||||
}
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
/*****************************************************************************
|
||||
** Function name: FLEX_INT1_IRQHandler
|
||||
**
|
||||
** Descriptions: Use one GPIO pin as interrupt source
|
||||
**
|
||||
** parameters: None
|
||||
**
|
||||
** Returned value: None
|
||||
**
|
||||
*****************************************************************************/
|
||||
void FLEX_INT1_IRQHandler(void)
|
||||
{
|
||||
flex_int1_counter++;
|
||||
if ( LPC_GPIO_PIN_INT->IST & (0x1<<1) )
|
||||
{
|
||||
if ( LPC_GPIO_PIN_INT->ISEL & (0x1<<1) )
|
||||
{
|
||||
flex_int1_level_counter++;
|
||||
}
|
||||
else
|
||||
{
|
||||
if ( LPC_GPIO_PIN_INT->RISE & (0x1<<1) )
|
||||
{
|
||||
flex_int1_rising_edge_counter++;
|
||||
LPC_GPIO_PIN_INT->RISE = 0x1<<1;
|
||||
}
|
||||
else if ( LPC_GPIO_PIN_INT->FALL & (0x1<<1) )
|
||||
{
|
||||
flex_int1_falling_edge_counter++;
|
||||
LPC_GPIO_PIN_INT->FALL = 0x1<<1;
|
||||
}
|
||||
LPC_GPIO_PIN_INT->IST = 0x1<<1;
|
||||
}
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
/*****************************************************************************
|
||||
** Function name: FLEX_INT2_IRQHandler
|
||||
**
|
||||
** Descriptions: Use one GPIO pin as interrupt source
|
||||
**
|
||||
** parameters: None
|
||||
**
|
||||
** Returned value: None
|
||||
**
|
||||
*****************************************************************************/
|
||||
void FLEX_INT2_IRQHandler(void)
|
||||
{
|
||||
flex_int2_counter++;
|
||||
if ( LPC_GPIO_PIN_INT->IST & (0x1<<2) )
|
||||
{
|
||||
if ( LPC_GPIO_PIN_INT->ISEL & (0x1<<2) )
|
||||
{
|
||||
flex_int2_level_counter++;
|
||||
}
|
||||
else
|
||||
{
|
||||
if ( LPC_GPIO_PIN_INT->RISE & (0x1<<2) )
|
||||
{
|
||||
flex_int2_rising_edge_counter++;
|
||||
LPC_GPIO_PIN_INT->RISE = 0x1<<2;
|
||||
}
|
||||
else if ( LPC_GPIO_PIN_INT->FALL & (0x1<<2) )
|
||||
{
|
||||
flex_int2_falling_edge_counter++;
|
||||
LPC_GPIO_PIN_INT->FALL = 0x1<<2;
|
||||
}
|
||||
LPC_GPIO_PIN_INT->IST = 0x1<<2;
|
||||
}
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
/*****************************************************************************
|
||||
** Function name: FLEX_INT3_IRQHandler
|
||||
**
|
||||
** Descriptions: Use one GPIO pin as interrupt source
|
||||
**
|
||||
** parameters: None
|
||||
**
|
||||
** Returned value: None
|
||||
**
|
||||
*****************************************************************************/
|
||||
void FLEX_INT3_IRQHandler(void)
|
||||
{
|
||||
flex_int3_counter++;
|
||||
if ( LPC_GPIO_PIN_INT->IST & (0x1<<3) )
|
||||
{
|
||||
if ( LPC_GPIO_PIN_INT->ISEL & (0x1<<3) )
|
||||
{
|
||||
flex_int3_level_counter++;
|
||||
}
|
||||
else
|
||||
{
|
||||
if ( LPC_GPIO_PIN_INT->RISE & (0x1<<3) )
|
||||
{
|
||||
flex_int3_rising_edge_counter++;
|
||||
LPC_GPIO_PIN_INT->RISE = 0x1<<3;
|
||||
}
|
||||
else if ( LPC_GPIO_PIN_INT->FALL & (0x1<<3) )
|
||||
{
|
||||
flex_int3_falling_edge_counter++;
|
||||
LPC_GPIO_PIN_INT->FALL = 0x1<<3;
|
||||
}
|
||||
LPC_GPIO_PIN_INT->IST = 0x1<<3;
|
||||
}
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
/*****************************************************************************
|
||||
** Function name: FLEX_INT4_IRQHandler
|
||||
**
|
||||
** Descriptions: Use one GPIO pin as interrupt source
|
||||
**
|
||||
** parameters: None
|
||||
**
|
||||
** Returned value: None
|
||||
**
|
||||
*****************************************************************************/
|
||||
void FLEX_INT4_IRQHandler(void)
|
||||
{
|
||||
flex_int4_counter++;
|
||||
if ( LPC_GPIO_PIN_INT->IST & (0x1<<4) )
|
||||
{
|
||||
if ( LPC_GPIO_PIN_INT->ISEL & (0x1<<4) )
|
||||
{
|
||||
flex_int4_level_counter++;
|
||||
}
|
||||
else
|
||||
{
|
||||
if ( LPC_GPIO_PIN_INT->RISE & (0x1<<4) )
|
||||
{
|
||||
flex_int4_rising_edge_counter++;
|
||||
LPC_GPIO_PIN_INT->RISE = 0x1<<4;
|
||||
}
|
||||
else if ( LPC_GPIO_PIN_INT->FALL & (0x1<<4) )
|
||||
{
|
||||
flex_int4_falling_edge_counter++;
|
||||
LPC_GPIO_PIN_INT->FALL = 0x1<<4;
|
||||
}
|
||||
LPC_GPIO_PIN_INT->IST = 0x1<<4;
|
||||
}
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
/*****************************************************************************
|
||||
** Function name: FLEX_INT5_IRQHandler
|
||||
**
|
||||
** Descriptions: Use one GPIO pin as interrupt source
|
||||
**
|
||||
** parameters: None
|
||||
**
|
||||
** Returned value: None
|
||||
**
|
||||
*****************************************************************************/
|
||||
void FLEX_INT5_IRQHandler(void)
|
||||
{
|
||||
flex_int5_counter++;
|
||||
if ( LPC_GPIO_PIN_INT->IST & (0x1<<5) )
|
||||
{
|
||||
if ( LPC_GPIO_PIN_INT->ISEL & (0x1<<5) )
|
||||
{
|
||||
flex_int5_level_counter++;
|
||||
}
|
||||
else
|
||||
{
|
||||
if ( LPC_GPIO_PIN_INT->RISE & (0x1<<5) )
|
||||
{
|
||||
flex_int5_rising_edge_counter++;
|
||||
LPC_GPIO_PIN_INT->RISE = 0x1<<5;
|
||||
}
|
||||
else if ( LPC_GPIO_PIN_INT->FALL & (0x1<<5) )
|
||||
{
|
||||
flex_int5_falling_edge_counter++;
|
||||
LPC_GPIO_PIN_INT->FALL = 0x1<<5;
|
||||
}
|
||||
LPC_GPIO_PIN_INT->IST = 0x1<<5;
|
||||
}
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
/*****************************************************************************
|
||||
** Function name: FLEX_INT6_IRQHandler
|
||||
**
|
||||
** Descriptions: Use one GPIO pin as interrupt source
|
||||
**
|
||||
** parameters: None
|
||||
**
|
||||
** Returned value: None
|
||||
**
|
||||
*****************************************************************************/
|
||||
void FLEX_INT6_IRQHandler(void)
|
||||
{
|
||||
flex_int6_counter++;
|
||||
if ( LPC_GPIO_PIN_INT->IST & (0x1<<6) )
|
||||
{
|
||||
if ( LPC_GPIO_PIN_INT->ISEL & (0x1<<6) )
|
||||
{
|
||||
flex_int6_level_counter++;
|
||||
}
|
||||
else
|
||||
{
|
||||
if ( LPC_GPIO_PIN_INT->RISE & (0x1<<6) )
|
||||
{
|
||||
flex_int6_rising_edge_counter++;
|
||||
LPC_GPIO_PIN_INT->RISE = 0x1<<6;
|
||||
}
|
||||
else if ( LPC_GPIO_PIN_INT->FALL & (0x1<<6) )
|
||||
{
|
||||
flex_int6_falling_edge_counter++;
|
||||
LPC_GPIO_PIN_INT->FALL = 0x1<<6;
|
||||
}
|
||||
LPC_GPIO_PIN_INT->IST = 0x1<<6;
|
||||
}
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
/*****************************************************************************
|
||||
** Function name: FLEX_INT7_IRQHandler
|
||||
**
|
||||
** Descriptions: Use one GPIO pin as interrupt source
|
||||
**
|
||||
** parameters: None
|
||||
**
|
||||
** Returned value: None
|
||||
**
|
||||
*****************************************************************************/
|
||||
void FLEX_INT7_IRQHandler(void)
|
||||
{
|
||||
flex_int7_counter++;
|
||||
if ( LPC_GPIO_PIN_INT->IST & (0x1<<7) )
|
||||
{
|
||||
if ( LPC_GPIO_PIN_INT->ISEL & (0x1<<7) )
|
||||
{
|
||||
flex_int7_level_counter++;
|
||||
}
|
||||
else
|
||||
{
|
||||
if ( LPC_GPIO_PIN_INT->RISE & (0x1<<7) )
|
||||
{
|
||||
flex_int7_rising_edge_counter++;
|
||||
LPC_GPIO_PIN_INT->RISE = 0x1<<7;
|
||||
}
|
||||
else if ( LPC_GPIO_PIN_INT->FALL & (0x1<<7) )
|
||||
{
|
||||
flex_int7_falling_edge_counter++;
|
||||
LPC_GPIO_PIN_INT->FALL = 0x1<<7;
|
||||
}
|
||||
LPC_GPIO_PIN_INT->IST = 0x1<<7;
|
||||
}
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
/*****************************************************************************
|
||||
** Function name: GINT0_IRQHandler
|
||||
**
|
||||
** Descriptions: Use one GPIO pin as interrupt source
|
||||
**
|
||||
** parameters: None
|
||||
**
|
||||
** Returned value: None
|
||||
**
|
||||
*****************************************************************************/
|
||||
void GINT0_IRQHandler(void)
|
||||
{
|
||||
gint0_counter++;
|
||||
if ( LPC_GPIO_GROUP_INT0->CTRL & 0x1 )
|
||||
{
|
||||
if ( LPC_GPIO_GROUP_INT0->CTRL & (0x1<<4) )
|
||||
{
|
||||
gint0_level_counter++;
|
||||
}
|
||||
else
|
||||
{
|
||||
gint0_edge_counter++;
|
||||
}
|
||||
LPC_GPIO_GROUP_INT0->CTRL |= 0x1;
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
/*****************************************************************************
|
||||
** Function name: GINT1_IRQHandler
|
||||
**
|
||||
** Descriptions: Use one GPIO pin as interrupt source
|
||||
**
|
||||
** parameters: None
|
||||
**
|
||||
** Returned value: None
|
||||
**
|
||||
*****************************************************************************/
|
||||
void GINT1_IRQHandler(void)
|
||||
{
|
||||
gint1_counter++;
|
||||
if ( LPC_GPIO_GROUP_INT1->CTRL & 0x1 )
|
||||
{
|
||||
if ( LPC_GPIO_GROUP_INT1->CTRL & (0x1<<4) )
|
||||
{
|
||||
gint1_level_counter++;
|
||||
}
|
||||
else
|
||||
{
|
||||
gint1_edge_counter++;
|
||||
}
|
||||
LPC_GPIO_GROUP_INT1->CTRL |= 0x1;
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
/*****************************************************************************
|
||||
** Function name: GPIOInit
|
||||
**
|
||||
** Descriptions: Initialize GPIO, install the
|
||||
** GPIO interrupt handler
|
||||
**
|
||||
** parameters: None
|
||||
**
|
||||
** Returned value: true or false, return false if the VIC table
|
||||
** is full and GPIO interrupt handler can be
|
||||
** installed.
|
||||
**
|
||||
*****************************************************************************/
|
||||
void GPIOInit( void )
|
||||
{
|
||||
/* Enable AHB clock to the GPIO domain. */
|
||||
LPC_SYSCON->SYSAHBCLKCTRL |= (1<<6);
|
||||
|
||||
/* Enable AHB clock to the FlexInt, GroupedInt domain. */
|
||||
LPC_SYSCON->SYSAHBCLKCTRL |= ((1<<19) | (1<<23) | (1<<24));
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
/*****************************************************************************
|
||||
** Function name: GPIOSetFlexInterrupt
|
||||
**
|
||||
** Descriptions: Set interrupt sense, event, etc.
|
||||
** sense: edge or level, 0 is edge, 1 is level
|
||||
** event/polarity: 0 is active low/falling, 1 is high/rising.
|
||||
**
|
||||
** parameters: channel #, port #, bit position, sense, event(polarity)
|
||||
**
|
||||
** Returned value: None
|
||||
**
|
||||
*****************************************************************************/
|
||||
void GPIOSetFlexInterrupt( uint32_t channelNum, uint32_t portNum, uint32_t bitPosi,
|
||||
uint32_t sense, uint32_t event )
|
||||
{
|
||||
switch ( channelNum )
|
||||
{
|
||||
case CHANNEL0:
|
||||
if ( portNum )
|
||||
{
|
||||
LPC_SYSCON->PINTSEL[0] = bitPosi + 24;
|
||||
}
|
||||
else
|
||||
{
|
||||
LPC_SYSCON->PINTSEL[0] = bitPosi;
|
||||
}
|
||||
NVIC_EnableIRQ(FLEX_INT0_IRQn);
|
||||
break;
|
||||
case CHANNEL1:
|
||||
if ( portNum )
|
||||
{
|
||||
LPC_SYSCON->PINTSEL[1] = bitPosi + 24;
|
||||
}
|
||||
else
|
||||
{
|
||||
LPC_SYSCON->PINTSEL[1] = bitPosi;
|
||||
}
|
||||
NVIC_EnableIRQ(FLEX_INT1_IRQn);
|
||||
break;
|
||||
case CHANNEL2:
|
||||
if ( portNum )
|
||||
{
|
||||
LPC_SYSCON->PINTSEL[2] = bitPosi + 24;
|
||||
}
|
||||
else
|
||||
{
|
||||
LPC_SYSCON->PINTSEL[2] = bitPosi;
|
||||
}
|
||||
NVIC_EnableIRQ(FLEX_INT2_IRQn);
|
||||
break;
|
||||
case CHANNEL3:
|
||||
if ( portNum )
|
||||
{
|
||||
LPC_SYSCON->PINTSEL[3] = bitPosi + 24;
|
||||
}
|
||||
else
|
||||
{
|
||||
LPC_SYSCON->PINTSEL[3] = bitPosi;
|
||||
}
|
||||
NVIC_EnableIRQ(FLEX_INT3_IRQn);
|
||||
break;
|
||||
case CHANNEL4:
|
||||
if ( portNum )
|
||||
{
|
||||
LPC_SYSCON->PINTSEL[4] = bitPosi + 24;
|
||||
}
|
||||
else
|
||||
{
|
||||
LPC_SYSCON->PINTSEL[4] = bitPosi;
|
||||
}
|
||||
NVIC_EnableIRQ(FLEX_INT4_IRQn);
|
||||
break;
|
||||
case CHANNEL5:
|
||||
if ( portNum )
|
||||
{
|
||||
LPC_SYSCON->PINTSEL[5] = bitPosi + 24;
|
||||
}
|
||||
else
|
||||
{
|
||||
LPC_SYSCON->PINTSEL[5] = bitPosi;
|
||||
}
|
||||
NVIC_EnableIRQ(FLEX_INT5_IRQn);
|
||||
break;
|
||||
case CHANNEL6:
|
||||
if ( portNum )
|
||||
{
|
||||
LPC_SYSCON->PINTSEL[6] = bitPosi + 24;
|
||||
}
|
||||
else
|
||||
{
|
||||
LPC_SYSCON->PINTSEL[6] = bitPosi;
|
||||
}
|
||||
NVIC_EnableIRQ(FLEX_INT6_IRQn);
|
||||
break;
|
||||
case CHANNEL7:
|
||||
if ( portNum )
|
||||
{
|
||||
LPC_SYSCON->PINTSEL[7] = bitPosi + 24;
|
||||
}
|
||||
else
|
||||
{
|
||||
LPC_SYSCON->PINTSEL[7] = bitPosi;
|
||||
}
|
||||
NVIC_EnableIRQ(FLEX_INT7_IRQn);
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
if ( sense == 0 )
|
||||
{
|
||||
LPC_GPIO_PIN_INT->ISEL &= ~(0x1<<channelNum); /* Edge trigger */
|
||||
if ( event == 0 )
|
||||
{
|
||||
LPC_GPIO_PIN_INT->IENF |= (0x1<<channelNum); /* faling edge */
|
||||
}
|
||||
else
|
||||
{
|
||||
LPC_GPIO_PIN_INT->IENR |= (0x1<<channelNum); /* Rising edge */
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
LPC_GPIO_PIN_INT->ISEL |= (0x1<<channelNum); /* Level trigger. */
|
||||
LPC_GPIO_PIN_INT->IENR |= (0x1<<channelNum); /* Level enable */
|
||||
if ( event == 0 )
|
||||
{
|
||||
LPC_GPIO_PIN_INT->IENF &= ~(0x1<<channelNum); /* active-low */
|
||||
}
|
||||
else
|
||||
{
|
||||
LPC_GPIO_PIN_INT->IENF |= (0x1<<channelNum); /* active-high */
|
||||
}
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
/*****************************************************************************
|
||||
** Function name: GPIOFlexIntEnable
|
||||
**
|
||||
** Descriptions: Enable Interrupt
|
||||
**
|
||||
** parameters: channel num, event(0 is falling edge, 1 is rising edge)
|
||||
** Returned value: None
|
||||
**
|
||||
*****************************************************************************/
|
||||
void GPIOFlexIntEnable( uint32_t channelNum, uint32_t event )
|
||||
{
|
||||
if ( !( LPC_GPIO_PIN_INT->ISEL & (0x1<<channelNum) ) )
|
||||
{
|
||||
if ( event == 0 )
|
||||
{
|
||||
LPC_GPIO_PIN_INT->SIENF |= (0x1<<channelNum); /* faling edge */
|
||||
}
|
||||
else
|
||||
{
|
||||
LPC_GPIO_PIN_INT->SIENR |= (0x1<<channelNum); /* Rising edge */
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
LPC_GPIO_PIN_INT->SIENR |= (0x1<<channelNum); /* Level */
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
/*****************************************************************************
|
||||
** Function name: GPIOFlexIntDisable
|
||||
**
|
||||
** Descriptions: Disable Interrupt
|
||||
**
|
||||
** parameters: channel num, event(0 is falling edge, 1 is rising edge)
|
||||
**
|
||||
** Returned value: None
|
||||
**
|
||||
*****************************************************************************/
|
||||
void GPIOFlexIntDisable( uint32_t channelNum, uint32_t event )
|
||||
{
|
||||
if ( !( LPC_GPIO_PIN_INT->ISEL & (0x1<<channelNum) ) )
|
||||
{
|
||||
if ( event == 0 )
|
||||
{
|
||||
LPC_GPIO_PIN_INT->CIENF |= (0x1<<channelNum); /* faling edge */
|
||||
}
|
||||
else
|
||||
{
|
||||
LPC_GPIO_PIN_INT->CIENR |= (0x1<<channelNum); /* Rising edge */
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
LPC_GPIO_PIN_INT->CIENR |= (0x1<<channelNum); /* Level */
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
/*****************************************************************************
|
||||
** Function name: GPIOFlexIntStatus
|
||||
**
|
||||
** Descriptions: Get Interrupt status
|
||||
**
|
||||
** parameters: channel num
|
||||
**
|
||||
** Returned value: None
|
||||
**
|
||||
*****************************************************************************/
|
||||
uint32_t GPIOFlexIntStatus( uint32_t channelNum )
|
||||
{
|
||||
if ( LPC_GPIO_PIN_INT->IST & (0x1<<channelNum) )
|
||||
{
|
||||
return( 1 );
|
||||
}
|
||||
else
|
||||
{
|
||||
return( 0 );
|
||||
}
|
||||
}
|
||||
|
||||
/*****************************************************************************
|
||||
** Function name: GPIOFlexIntClear
|
||||
**
|
||||
** Descriptions: Clear Interrupt
|
||||
**
|
||||
** parameters: channel num
|
||||
**
|
||||
** Returned value: None
|
||||
**
|
||||
*****************************************************************************/
|
||||
void GPIOFlexIntClear( uint32_t channelNum )
|
||||
{
|
||||
if ( !( LPC_GPIO_PIN_INT->ISEL & (0x1<<channelNum) ) )
|
||||
{
|
||||
LPC_GPIO_PIN_INT->IST = (1<<channelNum);
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
/*****************************************************************************
|
||||
** Function name: GPIOSetGroupedInterrupt
|
||||
**
|
||||
** Descriptions: Set interrupt logic, sense, eventPattern, etc.
|
||||
** logic: AND or OR, 0 is OR, 1 is AND
|
||||
** sensePattern: edge or level, 0 is edge, 1 is level
|
||||
** event/polarity: 0 is active low/falling, 1 is high/rising.
|
||||
**
|
||||
** parameters: group #, bit pattern, logic, sense, event(polarity) pattern
|
||||
**
|
||||
** Returned value: None
|
||||
**
|
||||
*****************************************************************************/
|
||||
void GPIOSetGroupedInterrupt( uint32_t groupNum, uint32_t *bitPattern, uint32_t logic,
|
||||
uint32_t sense, uint32_t *eventPattern )
|
||||
{
|
||||
switch ( groupNum )
|
||||
{
|
||||
case GROUP0:
|
||||
if ( sense == 0 )
|
||||
{
|
||||
LPC_GPIO_GROUP_INT0->CTRL &= ~(0x1<<2); /* Edge trigger */
|
||||
}
|
||||
else
|
||||
{
|
||||
LPC_GPIO_GROUP_INT0->CTRL |= (0x1<<2); /* Level trigger. */
|
||||
}
|
||||
LPC_GPIO_GROUP_INT0->CTRL |= (logic<<1);
|
||||
LPC_GPIO_GROUP_INT0->PORT_POL[0] = *((uint32_t *)(eventPattern + 0));
|
||||
LPC_GPIO_GROUP_INT0->PORT_POL[1] = *((uint32_t *)(eventPattern + 1));
|
||||
LPC_GPIO_GROUP_INT0->PORT_ENA[0] = *((uint32_t *)(bitPattern + 0));
|
||||
LPC_GPIO_GROUP_INT0->PORT_ENA[1] = *((uint32_t *)(bitPattern + 1));
|
||||
/* as soon as enabled, an edge may be generated */
|
||||
/* clear interrupt flag and NVIC pending interrupt to */
|
||||
/* workaround the potential edge generated as enabled */
|
||||
LPC_GPIO_GROUP_INT0->CTRL |= (1<<0);
|
||||
NVIC_ClearPendingIRQ(GINT0_IRQn);
|
||||
NVIC_EnableIRQ(GINT0_IRQn);
|
||||
break;
|
||||
case GROUP1:
|
||||
if ( sense == 0 )
|
||||
{
|
||||
LPC_GPIO_GROUP_INT1->CTRL &= ~(0x1<<2); /* Edge trigger */
|
||||
}
|
||||
else
|
||||
{
|
||||
LPC_GPIO_GROUP_INT1->CTRL |= (0x1<<2); /* Level trigger. */
|
||||
}
|
||||
LPC_GPIO_GROUP_INT1->CTRL |= (logic<<1);
|
||||
LPC_GPIO_GROUP_INT1->PORT_POL[0] = *((uint32_t *)(eventPattern + 0));
|
||||
LPC_GPIO_GROUP_INT1->PORT_POL[1] = *((uint32_t *)(eventPattern + 1));
|
||||
LPC_GPIO_GROUP_INT1->PORT_ENA[0] = *((uint32_t *)(bitPattern + 0));
|
||||
LPC_GPIO_GROUP_INT1->PORT_ENA[1] = *((uint32_t *)(bitPattern + 1));
|
||||
/* as soon as enabled, an edge may be generated */
|
||||
/* clear interrupt flag and NVIC pending interrupt to */
|
||||
/* workaround the potential edge generated as enabled */
|
||||
LPC_GPIO_GROUP_INT1->CTRL |= (1<<0);
|
||||
NVIC_ClearPendingIRQ(GINT1_IRQn);
|
||||
NVIC_EnableIRQ(GINT1_IRQn);
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
/*****************************************************************************
|
||||
** Function name: GPIOGetPinValue
|
||||
**
|
||||
** Descriptions: Read Current state of port pin, PIN register value
|
||||
**
|
||||
** parameters: port num, bit position
|
||||
** Returned value: None
|
||||
**
|
||||
*****************************************************************************/
|
||||
uint32_t GPIOGetPinValue( uint32_t portNum, uint32_t bitPosi )
|
||||
{
|
||||
uint32_t regVal = 0;
|
||||
|
||||
if( bitPosi < 0x20 )
|
||||
{
|
||||
if ( LPC_GPIO->PIN[portNum] & (0x1<<bitPosi) )
|
||||
{
|
||||
regVal = 1;
|
||||
}
|
||||
}
|
||||
else if( bitPosi == 0xFF )
|
||||
{
|
||||
regVal = LPC_GPIO->PIN[portNum];
|
||||
}
|
||||
return ( regVal );
|
||||
}
|
||||
|
||||
/*****************************************************************************
|
||||
** Function name: GPIOSetBitValue
|
||||
**
|
||||
** Descriptions: Set/clear a bit in a specific position
|
||||
**
|
||||
** parameters: port num, bit position, bit value
|
||||
**
|
||||
** Returned value: None
|
||||
**
|
||||
*****************************************************************************/
|
||||
void GPIOSetBitValue( uint32_t portNum, uint32_t bitPosi, uint32_t bitVal )
|
||||
{
|
||||
if ( bitVal )
|
||||
{
|
||||
LPC_GPIO->SET[portNum] = 1<<bitPosi;
|
||||
}
|
||||
else
|
||||
{
|
||||
LPC_GPIO->CLR[portNum] = 1<<bitPosi;
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
/*****************************************************************************
|
||||
** Function name: GPIOSetDir
|
||||
**
|
||||
** Descriptions: Set the direction in GPIO port
|
||||
**
|
||||
** parameters: portNum, bit position, direction (1 out, 0 input)
|
||||
**
|
||||
** Returned value: None
|
||||
**
|
||||
*****************************************************************************/
|
||||
void GPIOSetDir( uint32_t portNum, uint32_t bitPosi, uint32_t dir )
|
||||
{
|
||||
if( dir )
|
||||
{
|
||||
LPC_GPIO->DIR[portNum] |= (1<<bitPosi);
|
||||
}
|
||||
else
|
||||
{
|
||||
LPC_GPIO->DIR[portNum] &= ~(1<<bitPosi);
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
/******************************************************************************
|
||||
** End Of File
|
||||
******************************************************************************/
|
@ -31,7 +31,7 @@
|
||||
<builder buildPath="${workspace_loc:/tinyusb/Debug}" id="com.crt.advproject.builder.lib.debug.635723021" keepEnvironmentInBuildfile="false" managedBuildOn="true" name="Gnu Make Builder" superClass="com.crt.advproject.builder.lib.debug"/>
|
||||
<tool id="com.crt.advproject.cpp.lib.debug.2024209898" name="MCU C++ Compiler" superClass="com.crt.advproject.cpp.lib.debug"/>
|
||||
<tool id="com.crt.advproject.gcc.lib.debug.945784121" name="MCU C Compiler" superClass="com.crt.advproject.gcc.lib.debug">
|
||||
<option id="com.crt.advproject.gcc.arch.1721006216" name="Architecture" superClass="com.crt.advproject.gcc.arch" value="com.crt.advproject.gcc.target.cm3" valueType="enumerated"/>
|
||||
<option id="com.crt.advproject.gcc.arch.1721006216" name="Architecture" superClass="com.crt.advproject.gcc.arch" value="com.crt.advproject.gcc.target.cm0" valueType="enumerated"/>
|
||||
<option id="com.crt.advproject.gcc.thumb.161386546" name="Thumb mode" superClass="com.crt.advproject.gcc.thumb" value="true" valueType="boolean"/>
|
||||
<option id="gnu.c.compiler.option.preprocessor.def.symbols.216263139" name="Defined symbols (-D)" superClass="gnu.c.compiler.option.preprocessor.def.symbols" valueType="definedSymbols">
|
||||
<listOptionValue builtIn="false" value="__REDLIB__"/>
|
||||
@ -40,9 +40,7 @@
|
||||
</option>
|
||||
<option id="gnu.c.compiler.option.misc.other.905582730" name="Other flags" superClass="gnu.c.compiler.option.misc.other" value="-c -fmessage-length=0 -fno-builtin -ffunction-sections -fdata-sections $(CFLAGS)" valueType="string"/>
|
||||
<option id="gnu.c.compiler.option.include.paths.676739297" name="Include paths (-I)" superClass="gnu.c.compiler.option.include.paths" valueType="includePath">
|
||||
<listOptionValue builtIn="false" value=""${workspace_loc:/CMSISv2p10_LPC13Uxx/inc}""/>
|
||||
<listOptionValue builtIn="false" value=""${workspace_loc:/${ProjName}}""/>
|
||||
<listOptionValue builtIn="false" value=""${workspace_loc:/CMSISv2p00_LPC11Uxx/inc}""/>
|
||||
<listOptionValue builtIn="false" value=""${workspace_loc:/device_keyboard}""/>
|
||||
</option>
|
||||
<inputType id="com.crt.advproject.compiler.input.1916733927" superClass="com.crt.advproject.compiler.input"/>
|
||||
@ -354,40 +352,43 @@
|
||||
<storageModule moduleId="com.crt.config">
|
||||
<projectStorage><?xml version="1.0" encoding="UTF-8"?>
|
||||
<TargetConfig>
|
||||
<Properties property_0="" property_3="NXP" property_4="LPC1343" property_count="5" version="1"/>
|
||||
<infoList vendor="NXP"><info chip="LPC1343" match_id="0x3d00002b" name="LPC1343" stub="crt_emu_lpc11_13_nxp"><chip><name>LPC1343</name>
|
||||
<family>LPC13xx</family>
|
||||
<Properties property_0="" property_3="NXP" property_4="LPC11U37/501" property_count="5" version="1"/>
|
||||
<infoList vendor="NXP"><info chip="LPC11U37/501" match_id="0x00007C40" name="LPC11U37/501" stub="crt_emu_lpc11_13_nxp"><chip><name>LPC11U37/501</name>
|
||||
<family>LPC11Uxx</family>
|
||||
<vendor>NXP (formerly Philips)</vendor>
|
||||
<reset board="None" core="Real" sys="Real"/>
|
||||
<clock changeable="TRUE" freq="12MHz" 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="MFlash32" location="0x0" size="0x8000"/>
|
||||
<memoryInstance derived_from="Flash" id="MFlash128" location="0x0" size="0x20000"/>
|
||||
<memoryInstance derived_from="RAM" id="RamLoc8" location="0x10000000" size="0x2000"/>
|
||||
<prog_flash blocksz="0x1000" location="0x0" maxprgbuff="0x400" progwithcode="TRUE" size="0x8000"/>
|
||||
<peripheralInstance derived_from="LPC11_13_I2C" id="I2C0" location="0x40000000"/>
|
||||
<peripheralInstance derived_from="LPC11_13_WDT" id="WDT" location="0x40004000"/>
|
||||
<peripheralInstance derived_from="LPC1xxx_UART_MODEM" id="UART0" location="0x40008000"/>
|
||||
<peripheralInstance derived_from="LPC11_13_ADC" id="ADC" location="0x4001c000"/>
|
||||
<peripheralInstance derived_from="LPC11_13_TIMER16" id="TMR160" location="0x4000c000"/>
|
||||
<peripheralInstance derived_from="LPC11_13_TIMER16" id="TMR161" location="0x40010000"/>
|
||||
<peripheralInstance derived_from="LPC11_13_TIMER32" id="TIMER0" location="0x40014000"/>
|
||||
<peripheralInstance derived_from="LPC11_13_TIMER32" id="TIMER1" location="0x40018000"/>
|
||||
<peripheralInstance derived_from="LPC11_13_USBDEV" id="USB" location="0x40020000"/>
|
||||
<peripheralInstance derived_from="LPC11_13_PMU" id="PMU" location="0x40038000"/>
|
||||
<peripheralInstance derived_from="LPC11_13_SSP" id="SSP0" location="0x40040000"/>
|
||||
<peripheralInstance derived_from="LPC11_13_IOCON" id="IOCON" location="0x40044000"/>
|
||||
<peripheralInstance derived_from="LPC13_SYSCTL" id="SYSCTL" location="0x40048000"/>
|
||||
<peripheralInstance derived_from="LPC11_13_GPIO" id="GPIO0" location="0x50000000"/>
|
||||
<peripheralInstance derived_from="LPC11_13_GPIO" id="GPIO1" location="0x50010000"/>
|
||||
<peripheralInstance derived_from="LPC11_13_GPIO" id="GPIO2" location="0x50020000"/>
|
||||
<peripheralInstance derived_from="LPC11_13_GPIO" id="GPIO3" location="0x50030000"/>
|
||||
<peripheralInstance derived_from="LPC17_NVIC" id="NVIC" location="0xe000e000"/>
|
||||
<peripheralInstance derived_from="CM3_DCR" id="DCR" location="0xe000edf0"/>
|
||||
<memoryInstance derived_from="RAM" id="RamUsb2" location="0x20004000" size="0x800"/>
|
||||
<memoryInstance derived_from="RAM" id="SRAM1_2" location="0x20000000" size="0x800"/>
|
||||
<prog_flash blocksz="0x1000" location="0x0" maxprgbuff="0x400" progwithcode="TRUE" size="0x20000"/>
|
||||
<peripheralInstance derived_from="CM0_NVIC" id="NVIC" location="0xe000e000"/>
|
||||
<peripheralInstance derived_from="LPC11U_GPIO" id="GPIO" location="0x50000000"/>
|
||||
<peripheralInstance derived_from="LPC11U_USBDEV" id="USB" location="0x40080000"/>
|
||||
<peripheralInstance derived_from="CM0_DCR" id="DCR" location="0xe000edf0"/>
|
||||
<peripheralInstance derived_from="LPC11U_GPIO_GROUP_INT" id="GPIOGROUP0INT" location="0x40060000"/>
|
||||
<peripheralInstance derived_from="LPC11U_GPIO_GROUP_INT" id="GPIOGROUP1INT" location="0x4005c000"/>
|
||||
<peripheralInstance derived_from="LPC11U_GPIO_INT" id="GPIOINT" location="0x4004c000"/>
|
||||
<peripheralInstance derived_from="LPC11_13_SSP" id="SSP1" location="0x40058000"/>
|
||||
<peripheralInstance derived_from="LPC11U_FMC" id="FMC" location="0x4003c000"/>
|
||||
<peripheralInstance derived_from="LPC11U_SYSCTL" id="SYSCTL" location="0x40048000"/>
|
||||
<peripheralInstance derived_from="LPC11U_IOCON" id="IOCON" location="0x40044000"/>
|
||||
<peripheralInstance derived_from="LPC11_13_SSP" id="SSP0" location="0x40040000"/>
|
||||
<peripheralInstance derived_from="LPC11_13_PMU" id="PMU" location="0x40038000"/>
|
||||
<peripheralInstance derived_from="LPC11_13_ADC" id="ADC" location="0x4001c000"/>
|
||||
<peripheralInstance derived_from="LPC11_13_TIMER32" id="TIMER1" location="0x40018000"/>
|
||||
<peripheralInstance derived_from="LPC11_13_TIMER32" id="TIMER0" location="0x40014000"/>
|
||||
<peripheralInstance derived_from="LPC11_13_TIMER16" id="TMR161" location="0x40010000"/>
|
||||
<peripheralInstance derived_from="LPC11_13_TIMER16" id="TMR160" location="0x4000c000"/>
|
||||
<peripheralInstance derived_from="LPC1xxx_UART_MODEM" id="UART0" location="0x40008000"/>
|
||||
<peripheralInstance derived_from="LPC11_13_WDT" id="WDT" location="0x40004000"/>
|
||||
<peripheralInstance derived_from="LPC11_13_I2C" id="I2C0" location="0x40000000"/>
|
||||
</chip>
|
||||
<processor><name gcc_name="cortex-m3">Cortex-M3</name>
|
||||
<processor><name gcc_name="cortex-m0">Cortex-M0</name>
|
||||
<family>Cortex-M</family>
|
||||
</processor>
|
||||
<link href="nxp_lpc11_13_peripheral.xme" show="embed" type="simple"/>
|
||||
|
@ -309,15 +309,16 @@ TUSB_Error_t tusb_cdc_configured(USBD_HANDLE_T hUsb)
|
||||
uint8_t dummy=0;
|
||||
USBD_API->hw->WriteEP(hUsb, CDC_DATA_EP_IN, &dummy, 1); // initial packet for IN endpoint, will not work if omitted
|
||||
|
||||
// #if defined CFG_MCU_FAMILY_LPC11UXX
|
||||
// fifo_init (&ffTX, qBuffer[0], CDC_BUFFER_SIZE, false, USB_IRQn); // TX is non-overwritable
|
||||
// fifo_init (&ffRX, qBuffer[1], CDC_BUFFER_SIZE, true, USB_IRQn); // RX is overwritable
|
||||
// #elif defined CFG_MCU_FAMILY_LPC13UXX
|
||||
// FIXME abstract to hal
|
||||
#if MCU == MCU_LPC11UXX
|
||||
fifo_init (&ffTX, qBuffer[0], CDC_BUFFER_SIZE, false, USB_IRQn); // TX is non-overwritable
|
||||
fifo_init (&ffRX, qBuffer[1], CDC_BUFFER_SIZE, true, USB_IRQn); // RX is overwritable
|
||||
#elif MCU == MCU_LPC13UXX
|
||||
fifo_init (&ffTX, qBuffer[0], CDC_BUFFER_SIZE, false, USB_IRQ_IRQn); // TX is non-overwritable
|
||||
fifo_init (&ffRX, qBuffer[1], CDC_BUFFER_SIZE, true, USB_IRQ_IRQn); // RX is overwritable
|
||||
// #else
|
||||
// #error "usb_cdc.c: No MCU defined"
|
||||
// #endif
|
||||
#else
|
||||
#error "usb_cdc.c: No MCU defined"
|
||||
#endif
|
||||
|
||||
return tERROR_NONE;
|
||||
}
|
||||
|
@ -85,7 +85,7 @@
|
||||
/// The nonnull attribute specifies that some function parameters should be non-null pointers. f the compiler determines that a null pointer is passed in an argument slot marked as non-null, and the -Wnonnull option is enabled, a warning is issued. All pointer arguments are marked as non-null
|
||||
#define ATTR_NON_NULL __attribute__ ((nonull))
|
||||
|
||||
/// Many functions have no effects except the return value and their return value depends only on the parameters and/or global variables. Such a function can be subject to common subexpression elimination and loop optimization just as an arithmetic operator would be. These functions should be declared with the attribute pur
|
||||
/// Many functions have no effects except the return value and their return value depends only on the parameters and/or global variables. Such a function can be subject to common subexpression elimination and loop optimization just as an arithmetic operator would be. These functions should be declared with the attribute pure
|
||||
#define ATTR_PURE __attribute__ ((pure))
|
||||
|
||||
/// Many functions do not examine any values except their arguments, and have no effects except the return value. Basically this is just slightly more strict class than the pure attribute below, since function is not allowed to read global memory.
|
||||
|
@ -51,7 +51,9 @@
|
||||
#ifndef _TUSB_MCU_H_
|
||||
#define _TUSB_MCU_H_
|
||||
|
||||
//#define MCU MCU_LPC43XX
|
||||
#ifndef MCU // elcipse view
|
||||
#define MCU MCU_LPC11UXX
|
||||
#endif
|
||||
|
||||
#define MCU_LPC13UXX 1
|
||||
#define MCU_LPC11UXX 2
|
||||
@ -65,7 +67,7 @@
|
||||
#elif MCU == MCU_LPC43XX
|
||||
#include "mcu_lpc43xx.h"
|
||||
#elif MCU == MCU_LPC11UXX
|
||||
#include "mcu_lpc11xx.h"
|
||||
#include "mcu_lpc11uxx.h"
|
||||
#else
|
||||
#error MCU is not defined or supported yet
|
||||
#endif
|
||||
|
@ -46,13 +46,13 @@
|
||||
* @{
|
||||
*/
|
||||
|
||||
#ifndef MCU_LPC11XX_H_
|
||||
#define MCU_LPC11XX_H_
|
||||
#ifndef _TUSB_MCU_LPC11UXX_H_
|
||||
#define _TUSB_MCU_LPC11UXX_H_
|
||||
|
||||
#include "LPC11Uxx.h"
|
||||
|
||||
#define DEVICE_ROMDRIVER
|
||||
|
||||
#endif /* MCU_LPC11XX_H_ */
|
||||
#endif /* _TUSB_MCU_LPC11UXX_H_ */
|
||||
|
||||
/** @} */
|
@ -135,9 +135,13 @@ TUSB_Error_t dcd_init(uint8_t coreid)
|
||||
&membase , &memsize) );
|
||||
#endif
|
||||
|
||||
// FIXME abstract to hal
|
||||
/* Enable the USB interrupt */
|
||||
#if MCU == MCU_LPC13UXX
|
||||
NVIC_EnableIRQ(USB_IRQ_IRQn);
|
||||
|
||||
#elif MCU == MCU_LPC11UXX
|
||||
NVIC_EnableIRQ(USB_IRQn);
|
||||
#endif
|
||||
/* Perform USB soft connect */
|
||||
USBD_API->hw->Connect(g_hUsb, 1);
|
||||
#endif
|
||||
|
58
tinyusb/hal/hal_lpc11uxx.c
Normal file
58
tinyusb/hal/hal_lpc11uxx.c
Normal file
@ -0,0 +1,58 @@
|
||||
/*
|
||||
* hal_lpc11uxx.c
|
||||
*
|
||||
* Created on: Dec 7, 2012
|
||||
* Author: hathach
|
||||
*/
|
||||
|
||||
/*
|
||||
* Software License Agreement (BSD License)
|
||||
* Copyright (c) 2012, hathach (tinyusb.net)
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without modification,
|
||||
* are permitted provided that the following conditions are met:
|
||||
*
|
||||
* 1. Redistributions of source code must retain the above copyright notice,
|
||||
* this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright notice,
|
||||
* this list of conditions and the following disclaimer in the documentation
|
||||
* and/or other materials provided with the distribution.
|
||||
* 3. The name of the author may not be used to endorse or promote products
|
||||
* derived from this software without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED
|
||||
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
|
||||
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT
|
||||
* SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
|
||||
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT
|
||||
* OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
||||
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
||||
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
|
||||
* IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY
|
||||
* OF SUCH DAMAGE.
|
||||
*
|
||||
* This file is part of the tiny usb stack.
|
||||
*/
|
||||
|
||||
#include "common/common.h"
|
||||
|
||||
#if MCU == MCU_LPC11UXX
|
||||
|
||||
TUSB_Error_t hal_init()
|
||||
{
|
||||
// TODO remove magic number
|
||||
/* Enable AHB clock to the USB block and USB RAM. */
|
||||
LPC_SYSCON->SYSAHBCLKCTRL |= ((0x1<<14) | (0x1<<27));
|
||||
|
||||
/* Pull-down is needed, or internally, VBUS will be floating. This is to
|
||||
address the wrong status in VBUSDebouncing bit in CmdStatus register. */
|
||||
LPC_IOCON->PIO0_3 &= ~0x1F;
|
||||
LPC_IOCON->PIO0_3 |= (0x01<<0); /* Secondary function VBUS */
|
||||
LPC_IOCON->PIO0_6 &= ~0x07;
|
||||
LPC_IOCON->PIO0_6 |= (0x01<<0); /* Secondary function SoftConn */
|
||||
|
||||
return tERROR_NONE;
|
||||
}
|
||||
|
||||
#endif
|
Loading…
x
Reference in New Issue
Block a user