working on nrf52
This commit is contained in:
@@ -114,7 +114,7 @@ void led_blinking_task(void)
|
|||||||
{
|
{
|
||||||
enum { BLINK_INTEVAL = 1000 };
|
enum { BLINK_INTEVAL = 1000 };
|
||||||
|
|
||||||
static uint32_t led_on_mask = 0;
|
static bool led_state = false;
|
||||||
static uint32_t last_blink = 0;
|
static uint32_t last_blink = 0;
|
||||||
|
|
||||||
// not enough time
|
// not enough time
|
||||||
@@ -122,8 +122,8 @@ void led_blinking_task(void)
|
|||||||
|
|
||||||
last_blink += BLINK_INTEVAL;
|
last_blink += BLINK_INTEVAL;
|
||||||
|
|
||||||
board_leds(led_on_mask, 1 - led_on_mask);
|
board_led_control(BOARD_LED0, led_state);
|
||||||
led_on_mask = 1 - led_on_mask; // toggle
|
led_state = 1 - led_state; // toggle
|
||||||
}
|
}
|
||||||
|
|
||||||
//--------------------------------------------------------------------+
|
//--------------------------------------------------------------------+
|
||||||
|
@@ -40,4 +40,24 @@
|
|||||||
<locationURI>PARENT-4-PROJECT_LOC/tinyusb</locationURI>
|
<locationURI>PARENT-4-PROJECT_LOC/tinyusb</locationURI>
|
||||||
</link>
|
</link>
|
||||||
</linkedResources>
|
</linkedResources>
|
||||||
|
<filteredResources>
|
||||||
|
<filter>
|
||||||
|
<id>1520932840443</id>
|
||||||
|
<name></name>
|
||||||
|
<type>22</type>
|
||||||
|
<matcher>
|
||||||
|
<id>org.eclipse.ui.ide.multiFilter</id>
|
||||||
|
<arguments>1.0-name-matches-false-false-*.d</arguments>
|
||||||
|
</matcher>
|
||||||
|
</filter>
|
||||||
|
<filter>
|
||||||
|
<id>1520932840444</id>
|
||||||
|
<name></name>
|
||||||
|
<type>22</type>
|
||||||
|
<matcher>
|
||||||
|
<id>org.eclipse.ui.ide.multiFilter</id>
|
||||||
|
<arguments>1.0-name-matches-false-false-*.o</arguments>
|
||||||
|
</matcher>
|
||||||
|
</filter>
|
||||||
|
</filteredResources>
|
||||||
</projectDescription>
|
</projectDescription>
|
||||||
|
@@ -63,7 +63,7 @@ int main(void)
|
|||||||
board_init();
|
board_init();
|
||||||
print_greeting();
|
print_greeting();
|
||||||
|
|
||||||
//tusb_init();
|
tusb_init();
|
||||||
|
|
||||||
while (1)
|
while (1)
|
||||||
{
|
{
|
||||||
@@ -114,7 +114,7 @@ void led_blinking_task(void)
|
|||||||
{
|
{
|
||||||
enum { BLINK_INTEVAL = 1000 };
|
enum { BLINK_INTEVAL = 1000 };
|
||||||
|
|
||||||
static uint32_t led_on_mask = 0;
|
static bool led_state = false;
|
||||||
static uint32_t last_blink = 0;
|
static uint32_t last_blink = 0;
|
||||||
|
|
||||||
// not enough time
|
// not enough time
|
||||||
@@ -122,8 +122,8 @@ void led_blinking_task(void)
|
|||||||
|
|
||||||
last_blink += BLINK_INTEVAL;
|
last_blink += BLINK_INTEVAL;
|
||||||
|
|
||||||
board_leds(led_on_mask, 1 - led_on_mask);
|
board_led_control(BOARD_LED0, led_state);
|
||||||
led_on_mask = 1 - led_on_mask; // toggle
|
led_state = 1 - led_state; // toggle
|
||||||
}
|
}
|
||||||
|
|
||||||
//--------------------------------------------------------------------+
|
//--------------------------------------------------------------------+
|
||||||
|
@@ -131,13 +131,21 @@
|
|||||||
/// Initialize all required peripherals on board including uart, led, buttons etc ...
|
/// Initialize all required peripherals on board including uart, led, buttons etc ...
|
||||||
void board_init(void);
|
void board_init(void);
|
||||||
|
|
||||||
/** \brief Turns on and off leds on the board
|
|
||||||
* \param[in] on_mask Bitmask for LED's numbers is turning ON
|
#define BOARD_LED0 0
|
||||||
* \param[out] off_mask Bitmask for LED's numbers is turning OFF
|
|
||||||
* \note the \a on_mask is more priority then \a off_mask, if an led's number is present on both.
|
void board_led_control(uint32_t led_id, bool state);
|
||||||
* It will be turned ON.
|
|
||||||
*/
|
static inline void board_led_on(uint32_t led_id)
|
||||||
void board_leds(uint32_t on_mask, uint32_t off_mask);
|
{
|
||||||
|
board_led_control(led_id, true);
|
||||||
|
}
|
||||||
|
|
||||||
|
static inline void board_led_off(uint32_t led_id)
|
||||||
|
{
|
||||||
|
board_led_control(led_id, false);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
/** \brief Get the current state of the buttons on the board
|
/** \brief Get the current state of the buttons on the board
|
||||||
* \return Bitmask where a '1' means active (pressed), a '0' means inactive.
|
* \return Bitmask where a '1' means active (pressed), a '0' means inactive.
|
||||||
@@ -156,19 +164,6 @@ void board_uart_putchar(uint8_t c);
|
|||||||
|
|
||||||
/** @} */
|
/** @} */
|
||||||
|
|
||||||
#if 0
|
|
||||||
//------------- Board Application -------------//
|
|
||||||
void led_blinking_task(void* param);
|
|
||||||
|
|
||||||
/// Initialize the LED blinking task application. The initial blinking rate is 1 Hert (1 per second)
|
|
||||||
void led_blinking_init(void);
|
|
||||||
|
|
||||||
/** \brief Change the blinking rate.
|
|
||||||
* \param[in] ms The interval between on and off.
|
|
||||||
*/
|
|
||||||
void led_blinking_set_interval(uint32_t ms);
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
@@ -116,9 +116,11 @@ void board_init(void)
|
|||||||
//--------------------------------------------------------------------+
|
//--------------------------------------------------------------------+
|
||||||
// LEDS
|
// LEDS
|
||||||
//--------------------------------------------------------------------+
|
//--------------------------------------------------------------------+
|
||||||
void board_leds(uint32_t on_mask, uint32_t off_mask)
|
void board_led_control(uint32_t id, bool state)
|
||||||
{
|
{
|
||||||
pca9532_setLeds( on_mask << 8, off_mask << 8);
|
uint16_t on_mask = state ? (1 << id) : 0;
|
||||||
|
uint16_t off_mask = state ? 0 : (1 << id);
|
||||||
|
pca9532_setLeds( on_mask << 8, off_mask << 8 );
|
||||||
}
|
}
|
||||||
|
|
||||||
//--------------------------------------------------------------------+
|
//--------------------------------------------------------------------+
|
||||||
|
@@ -53,6 +53,8 @@
|
|||||||
|
|
||||||
#include "oem_base_board/pca9532.h" // LEDs
|
#include "oem_base_board/pca9532.h" // LEDs
|
||||||
|
|
||||||
|
#define BOARD_LED_NUM 1
|
||||||
|
|
||||||
|
|
||||||
//#define CFG_PRINTF_TARGET PRINTF_TARGET_SWO
|
//#define CFG_PRINTF_TARGET PRINTF_TARGET_SWO
|
||||||
#define CFG_PRINTF_TARGET PRINTF_TARGET_UART
|
#define CFG_PRINTF_TARGET PRINTF_TARGET_UART
|
||||||
|
@@ -43,6 +43,7 @@
|
|||||||
*------------------------------------------------------------------*/
|
*------------------------------------------------------------------*/
|
||||||
#define LED_1 13
|
#define LED_1 13
|
||||||
#define LED_STATE_ON 0
|
#define LED_STATE_ON 0
|
||||||
|
#define LED_STATE_OFF (1-LED_STATE_ON)
|
||||||
|
|
||||||
|
|
||||||
/*------------------------------------------------------------------*/
|
/*------------------------------------------------------------------*/
|
||||||
@@ -60,17 +61,10 @@ void board_init(void)
|
|||||||
NVIC_EnableIRQ(SysTick_IRQn);
|
NVIC_EnableIRQ(SysTick_IRQn);
|
||||||
}
|
}
|
||||||
|
|
||||||
void board_leds(uint32_t on_mask, uint32_t off_mask)
|
void board_led_control(uint32_t led_id, bool state)
|
||||||
{
|
{
|
||||||
if (on_mask)
|
(void) led_id;
|
||||||
{
|
nrf_gpio_pin_write(LED_1, state ? LED_STATE_ON : LED_STATE_OFF);
|
||||||
nrf_gpio_pin_write(LED_1, LED_STATE_ON);
|
|
||||||
}
|
|
||||||
|
|
||||||
if ( off_mask)
|
|
||||||
{
|
|
||||||
nrf_gpio_pin_write(LED_1, 1-LED_STATE_ON);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
uint32_t board_buttons(void)
|
uint32_t board_buttons(void)
|
||||||
|
@@ -42,6 +42,7 @@
|
|||||||
extern "C" {
|
extern "C" {
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#define BOARD_LED_NUM 1
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
}
|
}
|
||||||
|
67
hw/mcu/nordic/nrf52/tusb_port/dcd_nrf52.c
Normal file
67
hw/mcu/nordic/nrf52/tusb_port/dcd_nrf52.c
Normal file
@@ -0,0 +1,67 @@
|
|||||||
|
/**************************************************************************/
|
||||||
|
/*!
|
||||||
|
@file dcd_nrf52.c
|
||||||
|
@author hathach
|
||||||
|
|
||||||
|
@section LICENSE
|
||||||
|
|
||||||
|
Software License Agreement (BSD License)
|
||||||
|
|
||||||
|
Copyright (c) 2018, hathach (tinyusb.org)
|
||||||
|
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. Neither the name of the copyright holders nor the
|
||||||
|
names of its contributors may be used to endorse or promote products
|
||||||
|
derived from this software without specific prior written permission.
|
||||||
|
|
||||||
|
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ''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 COPYRIGHT HOLDER 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.
|
||||||
|
*/
|
||||||
|
/**************************************************************************/
|
||||||
|
|
||||||
|
// TODO remove
|
||||||
|
#include "nrf.h"
|
||||||
|
#include "nrf_power.h"
|
||||||
|
#include "nrf_drv_usbd.h"
|
||||||
|
|
||||||
|
/*------------------------------------------------------------------*/
|
||||||
|
/* MACRO TYPEDEF CONSTANT ENUM
|
||||||
|
*------------------------------------------------------------------*/
|
||||||
|
|
||||||
|
/*------------------------------------------------------------------*/
|
||||||
|
/* VARIABLE DECLARATION
|
||||||
|
*------------------------------------------------------------------*/
|
||||||
|
|
||||||
|
/*------------------------------------------------------------------*/
|
||||||
|
/* Controller API
|
||||||
|
*------------------------------------------------------------------*/
|
||||||
|
bool tusb_dcd_init (uint8_t port)
|
||||||
|
{
|
||||||
|
// TODO USB power detection
|
||||||
|
nrf_power_int_enable(
|
||||||
|
NRF_POWER_INT_USBDETECTED_MASK |
|
||||||
|
NRF_POWER_INT_USBREMOVED_MASK |
|
||||||
|
NRF_POWER_INT_USBPWRRDY_MASK);
|
||||||
|
|
||||||
|
nrf_drv_usbd_enable();
|
||||||
|
}
|
||||||
|
|
||||||
|
void tusb_dcd_connect (uint8_t port);
|
||||||
|
void tusb_dcd_disconnect (uint8_t port);
|
||||||
|
void tusb_dcd_set_address (uint8_t port, uint8_t dev_addr);
|
||||||
|
void tusb_dcd_set_config (uint8_t port, uint8_t config_num);
|
@@ -1,13 +1,13 @@
|
|||||||
/**************************************************************************/
|
/**************************************************************************/
|
||||||
/*!
|
/*!
|
||||||
@file board.c
|
@file dcd_nrf52.h
|
||||||
@author hathach (tinyusb.org)
|
@author hathach
|
||||||
|
|
||||||
@section LICENSE
|
@section LICENSE
|
||||||
|
|
||||||
Software License Agreement (BSD License)
|
Software License Agreement (BSD License)
|
||||||
|
|
||||||
Copyright (c) 2013, hathach (tinyusb.org)
|
Copyright (c) 2018, hathach (tinyusb.org)
|
||||||
All rights reserved.
|
All rights reserved.
|
||||||
|
|
||||||
Redistribution and use in source and binary forms, with or without
|
Redistribution and use in source and binary forms, with or without
|
||||||
@@ -26,38 +26,25 @@
|
|||||||
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||||
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER BE LIABLE FOR ANY
|
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER BE LIABLE FOR ANY
|
||||||
DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
||||||
INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||||
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION HOWEVER CAUSED AND
|
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
|
||||||
ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
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
|
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||||
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
|
|
||||||
This file is part of the tinyusb stack.
|
|
||||||
*/
|
*/
|
||||||
/**************************************************************************/
|
/**************************************************************************/
|
||||||
|
#ifndef DCD_NRF52_H_
|
||||||
|
#define DCD_NRF52_H_
|
||||||
|
|
||||||
#include "board.h"
|
|
||||||
//#include "app_os_prio.h"
|
|
||||||
|
|
||||||
#if TUSB_CFG_OS == TUSB_OS_NONE
|
|
||||||
|
|
||||||
volatile uint32_t system_ticks = 0;
|
|
||||||
|
|
||||||
void SysTick_Handler (void)
|
|
||||||
{
|
|
||||||
system_ticks++;
|
|
||||||
}
|
|
||||||
|
|
||||||
uint32_t tusb_hal_tick_get(void)
|
|
||||||
{
|
|
||||||
return system_ticks;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
extern "C" {
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
// TODO remove legacy cmsis code
|
|
||||||
void check_failed(uint8_t *file, uint32_t line)
|
#ifdef __cplusplus
|
||||||
{
|
}
|
||||||
(void) file;
|
#endif
|
||||||
(void) line;
|
|
||||||
}
|
#endif /* DCD_NRF52_H_ */
|
@@ -62,16 +62,16 @@ void SysTick_Handler (void)
|
|||||||
|
|
||||||
bool tusb_hal_init(void)
|
bool tusb_hal_init(void)
|
||||||
{
|
{
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
void tusb_hal_init_enable(uint8_t port)
|
void tusb_hal_int_enable(uint8_t port)
|
||||||
{
|
{
|
||||||
(void) port;
|
(void) port;
|
||||||
NVIC_EnableIRQ(USBD_IRQn);
|
NVIC_EnableIRQ(USBD_IRQn);
|
||||||
}
|
}
|
||||||
|
|
||||||
void tusb_hal_init_disable(uint8_t port)
|
void tusb_hal_int_disable(uint8_t port)
|
||||||
{
|
{
|
||||||
(void) port;
|
(void) port;
|
||||||
NVIC_DisableIRQ(USBD_IRQn);
|
NVIC_DisableIRQ(USBD_IRQn);
|
||||||
|
@@ -41,13 +41,13 @@
|
|||||||
|
|
||||||
#if TUSB_CFG_MCU == MCU_LPC11UXX
|
#if TUSB_CFG_MCU == MCU_LPC11UXX
|
||||||
|
|
||||||
void tusb_hal_init_enable(uint8_t port)
|
void tusb_hal_int_enable(uint8_t port)
|
||||||
{
|
{
|
||||||
(void) port; // discard compiler's warning
|
(void) port; // discard compiler's warning
|
||||||
NVIC_EnableIRQ(USB_IRQn);
|
NVIC_EnableIRQ(USB_IRQn);
|
||||||
}
|
}
|
||||||
|
|
||||||
void tusb_hal_init_disable(uint8_t port)
|
void tusb_hal_int_disable(uint8_t port)
|
||||||
{
|
{
|
||||||
(void) port; // discard compiler's warning
|
(void) port; // discard compiler's warning
|
||||||
NVIC_DisableIRQ(USB_IRQn);
|
NVIC_DisableIRQ(USB_IRQn);
|
||||||
|
@@ -41,13 +41,13 @@
|
|||||||
|
|
||||||
#if TUSB_CFG_MCU == MCU_LPC13UXX
|
#if TUSB_CFG_MCU == MCU_LPC13UXX
|
||||||
|
|
||||||
void tusb_hal_init_enable(uint8_t port)
|
void tusb_hal_int_enable(uint8_t port)
|
||||||
{
|
{
|
||||||
(void) port; // discard compiler's warning
|
(void) port; // discard compiler's warning
|
||||||
NVIC_EnableIRQ(USB_IRQ_IRQn);
|
NVIC_EnableIRQ(USB_IRQ_IRQn);
|
||||||
}
|
}
|
||||||
|
|
||||||
void tusb_hal_init_disable(uint8_t port)
|
void tusb_hal_int_disable(uint8_t port)
|
||||||
{
|
{
|
||||||
(void) port; // discard compiler's warning
|
(void) port; // discard compiler's warning
|
||||||
NVIC_DisableIRQ(USB_IRQ_IRQn);
|
NVIC_DisableIRQ(USB_IRQ_IRQn);
|
||||||
|
@@ -41,13 +41,13 @@
|
|||||||
|
|
||||||
#if TUSB_CFG_MCU == MCU_LPC175X_6X
|
#if TUSB_CFG_MCU == MCU_LPC175X_6X
|
||||||
|
|
||||||
void tusb_hal_init_enable(uint8_t port)
|
void tusb_hal_int_enable(uint8_t port)
|
||||||
{
|
{
|
||||||
(void) port; // discard compiler's warning
|
(void) port; // discard compiler's warning
|
||||||
NVIC_EnableIRQ(USB_IRQn);
|
NVIC_EnableIRQ(USB_IRQn);
|
||||||
}
|
}
|
||||||
|
|
||||||
void tusb_hal_init_disable(uint8_t port)
|
void tusb_hal_int_disable(uint8_t port)
|
||||||
{
|
{
|
||||||
(void) port; // discard compiler's warning
|
(void) port; // discard compiler's warning
|
||||||
NVIC_DisableIRQ(USB_IRQn);
|
NVIC_DisableIRQ(USB_IRQn);
|
||||||
@@ -111,4 +111,10 @@ void USB_IRQHandler(void)
|
|||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void check_failed(uint8_t *file, uint32_t line)
|
||||||
|
{
|
||||||
|
(void) file;
|
||||||
|
(void) line;
|
||||||
|
}
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
@@ -160,6 +160,9 @@ bool tusb_dcd_init(uint8_t port)
|
|||||||
lpc_usb->USBCMD_D &= ~0x00FF0000; // Interrupt Threshold Interval = 0
|
lpc_usb->USBCMD_D &= ~0x00FF0000; // Interrupt Threshold Interval = 0
|
||||||
lpc_usb->USBCMD_D |= BIT_(0); // connect
|
lpc_usb->USBCMD_D |= BIT_(0); // connect
|
||||||
|
|
||||||
|
// enable interrupt
|
||||||
|
NVIC_EnableIRQ(port ? USB1_IRQn : USB0_IRQn);
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -53,6 +53,22 @@ enum {
|
|||||||
LPC43XX_USBMODE_VBUS_HIGH = 1
|
LPC43XX_USBMODE_VBUS_HIGH = 1
|
||||||
};
|
};
|
||||||
|
|
||||||
|
#if TUSB_CFG_OS == TUSB_OS_NONE
|
||||||
|
|
||||||
|
volatile uint32_t system_ticks = 0;
|
||||||
|
|
||||||
|
void SysTick_Handler (void)
|
||||||
|
{
|
||||||
|
system_ticks++;
|
||||||
|
}
|
||||||
|
|
||||||
|
uint32_t tusb_hal_tick_get(void)
|
||||||
|
{
|
||||||
|
return system_ticks;
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
||||||
void tusb_hal_dbg_breakpoint(void)
|
void tusb_hal_dbg_breakpoint(void)
|
||||||
{
|
{
|
||||||
// M0 cannot check if debugger is attached or not
|
// M0 cannot check if debugger is attached or not
|
||||||
@@ -65,12 +81,12 @@ void tusb_hal_dbg_breakpoint(void)
|
|||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
void tusb_hal_init_enable(uint8_t port)
|
void tusb_hal_int_enable(uint8_t port)
|
||||||
{
|
{
|
||||||
NVIC_EnableIRQ(port ? USB1_IRQn : USB0_IRQn);
|
NVIC_EnableIRQ(port ? USB1_IRQn : USB0_IRQn);
|
||||||
}
|
}
|
||||||
|
|
||||||
void tusb_hal_init_disable(uint8_t port)
|
void tusb_hal_int_disable(uint8_t port)
|
||||||
{
|
{
|
||||||
NVIC_DisableIRQ(port ? USB1_IRQn : USB0_IRQn);
|
NVIC_DisableIRQ(port ? USB1_IRQn : USB0_IRQn);
|
||||||
}
|
}
|
||||||
@@ -167,4 +183,11 @@ void USB1_IRQHandler(void)
|
|||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
||||||
|
void check_failed(uint8_t *file, uint32_t line)
|
||||||
|
{
|
||||||
|
(void) file;
|
||||||
|
(void) line;
|
||||||
|
}
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
@@ -204,11 +204,11 @@ static inline void osal_queue_flush(osal_queue_t const queue_hdl)
|
|||||||
else\
|
else\
|
||||||
return TUSB_ERROR_OSAL_WAITING;\
|
return TUSB_ERROR_OSAL_WAITING;\
|
||||||
} else{\
|
} else{\
|
||||||
/*TODO mutex lock tusb_hal_init_disable */\
|
/*TODO mutex lock tusb_hal_int_disable */\
|
||||||
memcpy(p_data, queue_hdl->buffer + (queue_hdl->rd_idx * queue_hdl->item_size), queue_hdl->item_size);\
|
memcpy(p_data, queue_hdl->buffer + (queue_hdl->rd_idx * queue_hdl->item_size), queue_hdl->item_size);\
|
||||||
queue_hdl->rd_idx = (queue_hdl->rd_idx + 1) % queue_hdl->depth;\
|
queue_hdl->rd_idx = (queue_hdl->rd_idx + 1) % queue_hdl->depth;\
|
||||||
queue_hdl->count--;\
|
queue_hdl->count--;\
|
||||||
/*TODO mutex unlock tusb_hal_init_enable */\
|
/*TODO mutex unlock tusb_hal_int_enable */\
|
||||||
*(p_error) = TUSB_ERROR_NONE;\
|
*(p_error) = TUSB_ERROR_NONE;\
|
||||||
}\
|
}\
|
||||||
}while(0)
|
}while(0)
|
||||||
@@ -258,7 +258,7 @@ static inline void osal_semaphore_reset(osal_semaphore_t sem_hdl)
|
|||||||
else\
|
else\
|
||||||
return TUSB_ERROR_OSAL_WAITING;\
|
return TUSB_ERROR_OSAL_WAITING;\
|
||||||
} else{\
|
} else{\
|
||||||
if (sem_hdl->count) sem_hdl->count--; /*TODO mutex tusb_hal_init_disable consideration*/\
|
if (sem_hdl->count) sem_hdl->count--; /*TODO mutex tusb_hal_int_disable consideration*/\
|
||||||
*(p_error) = TUSB_ERROR_NONE;\
|
*(p_error) = TUSB_ERROR_NONE;\
|
||||||
}\
|
}\
|
||||||
}while(0)
|
}while(0)
|
||||||
|
@@ -52,14 +52,6 @@ tusb_error_t tusb_init(void)
|
|||||||
ASSERT_STATUS ( usbd_init() ); // device stack init
|
ASSERT_STATUS ( usbd_init() ); // device stack init
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if (TUSB_CFG_CONTROLLER_0_MODE)
|
|
||||||
tusb_hal_init_enable(0);
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#if (TUSB_CFG_CONTROLLER_1_MODE)
|
|
||||||
tusb_hal_init_enable(1);
|
|
||||||
#endif
|
|
||||||
|
|
||||||
return TUSB_ERROR_NONE;
|
return TUSB_ERROR_NONE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -43,8 +43,7 @@
|
|||||||
#ifndef _TUSB_DCD_H_
|
#ifndef _TUSB_DCD_H_
|
||||||
#define _TUSB_DCD_H_
|
#define _TUSB_DCD_H_
|
||||||
|
|
||||||
#include <stdint.h>
|
#include "common/tusb_common.h"
|
||||||
#include <stdbool.h>
|
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
extern "C" {
|
extern "C" {
|
||||||
|
@@ -46,12 +46,7 @@ extern "C" {
|
|||||||
//--------------------------------------------------------------------+
|
//--------------------------------------------------------------------+
|
||||||
// INCLUDES
|
// INCLUDES
|
||||||
//--------------------------------------------------------------------+
|
//--------------------------------------------------------------------+
|
||||||
#include "tusb_option.h"
|
#include "common/tusb_common.h"
|
||||||
#include <stdbool.h>
|
|
||||||
#include <stdint.h>
|
|
||||||
|
|
||||||
#include "common/tusb_errors.h"
|
|
||||||
#include "common/compiler/compiler.h"
|
|
||||||
|
|
||||||
//--------------------------------------------------------------------+
|
//--------------------------------------------------------------------+
|
||||||
// HAL API
|
// HAL API
|
||||||
@@ -73,12 +68,12 @@ bool tusb_hal_init(void);
|
|||||||
/** \brief Enable USB Interrupt on a specific USB Controller
|
/** \brief Enable USB Interrupt on a specific USB Controller
|
||||||
* \param[in] port is a zero-based index to identify USB controller's ID
|
* \param[in] port is a zero-based index to identify USB controller's ID
|
||||||
*/
|
*/
|
||||||
void tusb_hal_init_enable(uint8_t port);
|
void tusb_hal_int_enable(uint8_t port);
|
||||||
|
|
||||||
/** \brief Disable USB Interrupt on a specific USB Controller
|
/** \brief Disable USB Interrupt on a specific USB Controller
|
||||||
* \param[in] port is a zero-based index to identify USB controller's ID
|
* \param[in] port is a zero-based index to identify USB controller's ID
|
||||||
*/
|
*/
|
||||||
void tusb_hal_init_disable(uint8_t port);
|
void tusb_hal_int_disable(uint8_t port);
|
||||||
|
|
||||||
uint32_t tusb_hal_tick_get(void);
|
uint32_t tusb_hal_tick_get(void);
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user