Skip to content

Commit

Permalink
add tlsr dcd and board file
Browse files Browse the repository at this point in the history
  • Loading branch information
tyustli committed Mar 19, 2024
1 parent 7c66f9b commit 74330d8
Show file tree
Hide file tree
Showing 6 changed files with 517 additions and 0 deletions.
3 changes: 3 additions & 0 deletions hw/bsp/board_mcu.h
Expand Up @@ -170,6 +170,9 @@
#elif TU_CHECK_MCU(OPT_MCU_BCM2711, OPT_MCU_BCM2835, OPT_MCU_BCM2837)
// no header needed

#elif CFG_TUSB_MCU == OPT_MCU_TLSR
#include "driver.h"

#else
#error "Missing MCU header"
#endif
Expand Down
46 changes: 46 additions & 0 deletions hw/bsp/telink/board.h
@@ -0,0 +1,46 @@
/*
* The MIT License (MIT)
*
* Copyright (c) 2019 Ha Thach (tinyusb.org)
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
* THE SOFTWARE.
*
* This file is part of the TinyUSB stack.
*/

#ifndef _BOARD_H_
#define _BOARD_H_

#include "driver.h"
#include "common.h"

// LED
#define LED_PIN GPIO_PD0
#define LED_STATE_ON 1

// Button
#define BUTTON_PIN GPIO_PD2
#define BUTTON_STATE_ACTIVE 1

// UART
#define UART_DEV UART0
#define UART_TX_PIN GPIO_FC_PB1
#define UART_RX_PIN GPIO_FC_PB2

#endif
99 changes: 99 additions & 0 deletions hw/bsp/telink/family.c
@@ -0,0 +1,99 @@
/*
* The MIT License (MIT)
*
* Copyright (c) 2019 Ha Thach (tinyusb.org)
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
* THE SOFTWARE.
*
* This file is part of the TinyUSB stack.
*/
#include "board.h"
#include "bsp/board_api.h"

void board_init(void)
{
PLATFORM_INIT;
CLOCK_INIT;

#if (MCU_CORE_B91 || MCU_CORE_B92)
// LED
gpio_function_en(LED_PIN);
gpio_output_en(LED_PIN);
gpio_input_dis(LED_PIN);

// BUTTON
gpio_function_en(BUTTON_PIN);
gpio_output_dis(BUTTON_PIN);
gpio_input_en(BUTTON_PIN);
#elif (MCU_CORE_B80 || MCU_CORE_B85 || MCU_CORE_B87)
// TODO
#endif
board_led_write(false);
}

//--------------------------------------------------------------------+
// Board porting API
//--------------------------------------------------------------------+

void board_led_write(bool state)
{
#if (MCU_CORE_B91 || MCU_CORE_B92)
if (state == LED_STATE_ON)
{
gpio_set_high_level(LED_PIN);
}
else
{
gpio_set_low_level(LED_PIN);
}
#elif (MCU_CORE_B80 || MCU_CORE_B85 || MCU_CORE_B87)
// TODO
#endif
}

uint32_t board_button_read(void)
{
#if (MCU_CORE_B91 || MCU_CORE_B92)
return gpio_get_level(BUTTON_PIN);
#elif (MCU_CORE_B80 || MCU_CORE_B85 || MCU_CORE_B87)
// TODO
return true;
#endif
}

int board_uart_read(uint8_t *buf, int len)
{
(void)buf;
(void)len;

return len;
}

int board_uart_write(void const *buf, int len)
{
(void)buf;
(void)len;

return len;
}

uint32_t board_millis(void)
{
return reg_system_tick / SYSTEM_TIMER_TICK_1MS;
}
2 changes: 2 additions & 0 deletions src/common/tusb_mcu.h
Expand Up @@ -397,6 +397,8 @@
#elif TU_CHECK_MCU(OPT_MCU_CH32F20X)
#define TUP_DCD_ENDPOINT_MAX 16
#define TUP_RHPORT_HIGHSPEED 1
#elif TU_CHECK_MCU(OPT_MCU_TLSR)
#define TUP_DCD_ENDPOINT_MAX 9
#endif


Expand Down

0 comments on commit 74330d8

Please sign in to comment.