abstract usb enable/disable interrupt to hal layer
This commit is contained in:
parent
b52b3b1cef
commit
3eb7465e5e
|
@ -60,8 +60,8 @@
|
||||||
#define TICKS_PER_SECOND 1000
|
#define TICKS_PER_SECOND 1000
|
||||||
|
|
||||||
/// n-th Bit
|
/// n-th Bit
|
||||||
#ifndef BIT
|
#ifndef BIT_
|
||||||
#define BIT(n) (1 << (n))
|
#define BIT_(n) (1 << (n))
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#define BOARD_NGX43XX 1
|
#define BOARD_NGX43XX 1
|
||||||
|
|
|
@ -59,7 +59,9 @@ void board_init(void)
|
||||||
void board_leds(uint32_t mask, uint32_t state)
|
void board_leds(uint32_t mask, uint32_t state)
|
||||||
{
|
{
|
||||||
if (mask)
|
if (mask)
|
||||||
GPIOSetBitValue(CFG_LED_PORT, CFG_LED_PIN, mask & state);
|
{
|
||||||
|
GPIOSetBitValue(CFG_LED_PORT, CFG_LED_PIN, mask & state ? CFG_LED_ON : CFG_LED_OFF);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -76,7 +76,7 @@ void board_init(void)
|
||||||
for (i=0; i<BOARD_MAX_LEDS; i++)
|
for (i=0; i<BOARD_MAX_LEDS; i++)
|
||||||
{
|
{
|
||||||
scu_pinmux(leds[i].port, leds[i].pin, MD_PUP|MD_EZI|MD_ZI, FUNC0);
|
scu_pinmux(leds[i].port, leds[i].pin, MD_PUP|MD_EZI|MD_ZI, FUNC0);
|
||||||
GPIO_SetDir(leds[i].port, BIT(leds[i].pin), 1); // output
|
GPIO_SetDir(leds[i].port, BIT_(leds[i].pin), 1); // output
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -85,8 +85,10 @@ void board_leds(uint32_t mask, uint32_t state)
|
||||||
uint8_t i;
|
uint8_t i;
|
||||||
for(i=0; i<BOARD_MAX_LEDS; i++)
|
for(i=0; i<BOARD_MAX_LEDS; i++)
|
||||||
{
|
{
|
||||||
if ( mask & BIT(i) )
|
if ( mask & BIT_(i) )
|
||||||
(mask & state) ? GPIO_SetValue(leds[i].port, BIT(leds[i].pin)) : GPIO_ClearValue(leds[i].port, BIT(leds[i].pin)) ;
|
{
|
||||||
|
(mask & state) ? GPIO_SetValue(leds[i].port, BIT_(leds[i].pin)) : GPIO_ClearValue(leds[i].port, BIT_(leds[i].pin)) ;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -71,29 +71,42 @@
|
||||||
#include "core/std_descriptors.h"
|
#include "core/std_descriptors.h"
|
||||||
|
|
||||||
/// min value
|
/// min value
|
||||||
#ifndef MIN
|
#define MIN_(x, y) (((x) < (y)) ? (x) : (y))
|
||||||
#define MIN(x, y) (((x) < (y)) ? (x) : (y))
|
|
||||||
#endif
|
|
||||||
|
|
||||||
/// max value
|
/// max value
|
||||||
#ifndef MAX
|
#define MAX_(x, y) (((x) > (y)) ? (x) : (y))
|
||||||
#define MAX(x, y) (((x) > (y)) ? (x) : (y))
|
|
||||||
#endif
|
|
||||||
|
|
||||||
/// n-th Bit
|
/// n-th Bit
|
||||||
#ifndef BIT
|
#define BIT_(n) (1 << (n))
|
||||||
#define BIT(n) (1 << (n))
|
|
||||||
#endif
|
|
||||||
|
|
||||||
/// set n-th bit of x to 1
|
/// set n-th bit of x to 1
|
||||||
#ifndef BIT_SET
|
#define BIT_SET_(x, n) ( (x) | BIT_(n) )
|
||||||
#define BIT_SET(x, n) ( (x) | BIT(n) )
|
|
||||||
#endif
|
|
||||||
|
|
||||||
/// clear n-th bit of x
|
/// clear n-th bit of x
|
||||||
#ifndef BIT_CLR
|
#define BIT_CLR_(x, n) ( (x) & (~BIT_(n)) )
|
||||||
#define BIT_CLR(x, n) ( (x) & (~BIT(n)) )
|
|
||||||
#endif
|
/// add hex represenation
|
||||||
|
#define HEX_(n) 0x##n##LU
|
||||||
|
|
||||||
|
// internal macro of B8, B16, B32
|
||||||
|
#define _B8__(x) ((x&0x0000000FLU)?1:0) \
|
||||||
|
+((x&0x000000F0LU)?2:0) \
|
||||||
|
+((x&0x00000F00LU)?4:0) \
|
||||||
|
+((x&0x0000F000LU)?8:0) \
|
||||||
|
+((x&0x000F0000LU)?16:0) \
|
||||||
|
+((x&0x00F00000LU)?32:0) \
|
||||||
|
+((x&0x0F000000LU)?64:0) \
|
||||||
|
+((x&0xF0000000LU)?128:0)
|
||||||
|
|
||||||
|
#define B8_(d) ((unsigned char)_B8__(HEX_(d)))
|
||||||
|
#define B16_(dmsb,dlsb) (((unsigned short)B8(dmsb)<<8) + B8(dlsb))
|
||||||
|
#define B32_(dmsb,db2,db3,dlsb) \
|
||||||
|
(((unsigned long)B8(dmsb)<<24) \
|
||||||
|
+ ((unsigned long)B8(db2)<<16) \
|
||||||
|
+ ((unsigned long)B8(db3)<<8) \
|
||||||
|
+ B8(dlsb))
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
//#if ( defined CFG_PRINTF_UART || defined CFG_PRINTF_USBCDC || defined CFG_PRINTF_DEBUG )
|
//#if ( defined CFG_PRINTF_UART || defined CFG_PRINTF_USBCDC || defined CFG_PRINTF_DEBUG )
|
||||||
#if CFG_TUSB_DEBUG_LEVEL
|
#if CFG_TUSB_DEBUG_LEVEL
|
||||||
|
|
|
@ -74,7 +74,7 @@ void fifo_init(fifo_t* f, uint8_t* buffer, uint16_t size, bool overwritable, IRQ
|
||||||
bool fifo_write(fifo_t* f, uint8_t data);
|
bool fifo_write(fifo_t* f, uint8_t data);
|
||||||
bool fifo_read(fifo_t* f, uint8_t *data);
|
bool fifo_read(fifo_t* f, uint8_t *data);
|
||||||
uint16_t fifo_readArray(fifo_t* f, uint8_t * rx, uint16_t maxlen);
|
uint16_t fifo_readArray(fifo_t* f, uint8_t * rx, uint16_t maxlen);
|
||||||
void fifo_clear(fifo_t*);
|
void fifo_clear(fifo_t *f);
|
||||||
|
|
||||||
static inline bool fifo_isEmpty(fifo_t* f)
|
static inline bool fifo_isEmpty(fifo_t* f)
|
||||||
{
|
{
|
||||||
|
|
|
@ -135,13 +135,8 @@ TUSB_Error_t dcd_init(uint8_t coreid)
|
||||||
&membase , &memsize) );
|
&membase , &memsize) );
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
// FIXME abstract to hal
|
hal_interrupt_enable(); /* Enable the USB interrupt */
|
||||||
/* 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 */
|
/* Perform USB soft connect */
|
||||||
USBD_API->hw->Connect(g_hUsb, 1);
|
USBD_API->hw->Connect(g_hUsb, 1);
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -55,6 +55,7 @@
|
||||||
extern "C" {
|
extern "C" {
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#include "common/compiler/compiler.h"
|
||||||
#include "common/errors.h"
|
#include "common/errors.h"
|
||||||
|
|
||||||
/** \brief USB hardware init
|
/** \brief USB hardware init
|
||||||
|
@ -66,6 +67,23 @@
|
||||||
*/
|
*/
|
||||||
TUSB_Error_t hal_init();
|
TUSB_Error_t hal_init();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Enable USB Interrupt
|
||||||
|
*/
|
||||||
|
static inline void hal_interrupt_enable() ATTR_ALWAYS_INLINE;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Disable USB Interrupt
|
||||||
|
*/
|
||||||
|
static inline void hal_interrupt_disable() ATTR_ALWAYS_INLINE;
|
||||||
|
|
||||||
|
#if MCU == MCU_LPC11UXX
|
||||||
|
#include "hal_lpc11uxx.h"
|
||||||
|
#elif MCU == MCU_LPC13UXX
|
||||||
|
#include "hal_lpc13uxx.h"
|
||||||
|
#elif MCU == MCU_LPC43XX
|
||||||
|
|
||||||
|
#endif
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -0,0 +1,80 @@
|
||||||
|
/*
|
||||||
|
* hal_lpc11uxx.h
|
||||||
|
*
|
||||||
|
* Created on: Dec 10, 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.
|
||||||
|
*/
|
||||||
|
|
||||||
|
/** \file
|
||||||
|
* \brief TBD
|
||||||
|
*
|
||||||
|
* \note TBD
|
||||||
|
*/
|
||||||
|
|
||||||
|
/** \ingroup TBD
|
||||||
|
* \defgroup TBD
|
||||||
|
* \brief TBD
|
||||||
|
*
|
||||||
|
* @{
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef _TUSB_HAL_LPC11UXX_H_
|
||||||
|
#define _TUSB_HAL_LPC11UXX_H_
|
||||||
|
|
||||||
|
#include "common/mcu/mcu.h"
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
extern "C" {
|
||||||
|
#endif
|
||||||
|
|
||||||
|
|
||||||
|
static inline void hal_interrupt_enable()
|
||||||
|
{
|
||||||
|
NVIC_EnableIRQ(USB_IRQn);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Disable USB Interrupt
|
||||||
|
*/
|
||||||
|
static inline void hal_interrupt_disable()
|
||||||
|
{
|
||||||
|
NVIC_DisableIRQ(USB_IRQn);
|
||||||
|
}
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#endif /* _TUSB_HAL_LPC11UXX_H_ */
|
||||||
|
|
||||||
|
/** @} */
|
|
@ -0,0 +1,79 @@
|
||||||
|
/*
|
||||||
|
* hal_lpc13uxx.h
|
||||||
|
*
|
||||||
|
* Created on: Dec 10, 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.
|
||||||
|
*/
|
||||||
|
|
||||||
|
/** \file
|
||||||
|
* \brief TBD
|
||||||
|
*
|
||||||
|
* \note TBD
|
||||||
|
*/
|
||||||
|
|
||||||
|
/** \ingroup TBD
|
||||||
|
* \defgroup TBD
|
||||||
|
* \brief TBD
|
||||||
|
*
|
||||||
|
* @{
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef _TUSB_HAL_LPC13UXX_H_
|
||||||
|
#define _TUSB_HAL_LPC13UXX_H_
|
||||||
|
|
||||||
|
#include "common/mcu/mcu.h"
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
extern "C" {
|
||||||
|
#endif
|
||||||
|
|
||||||
|
static inline void hal_interrupt_enable()
|
||||||
|
{
|
||||||
|
NVIC_EnableIRQ(USB_IRQ_IRQn);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Disable USB Interrupt
|
||||||
|
*/
|
||||||
|
static inline void hal_interrupt_disable()
|
||||||
|
{
|
||||||
|
NVIC_DisableIRQ(USB_IRQ_IRQn);
|
||||||
|
}
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#endif /* _TUSB_HAL_LPC13UXX_H_ */
|
||||||
|
|
||||||
|
/** @} */
|
Loading…
Reference in New Issue