AD-APARD32690-SL Support and Cleanup
- Added BSP for AD-APARD32690-SL board (apard32690) - Ran clang-formatting on previously committed code - Removed LOG messages from dcd_max32.c
This commit is contained in:
1
hw/bsp/max32690/boards/apard32690/board.cmake
Normal file
1
hw/bsp/max32690/boards/apard32690/board.cmake
Normal file
@@ -0,0 +1 @@
|
||||
# Nothing to be done at the board level
|
56
hw/bsp/max32690/boards/apard32690/board.h
Normal file
56
hw/bsp/max32690/boards/apard32690/board.h
Normal file
@@ -0,0 +1,56 @@
|
||||
/*
|
||||
* The MIT License (MIT)
|
||||
*
|
||||
* Copyright (c) 2024, Brent Kowal (Analog Devices, Inc)
|
||||
*
|
||||
* 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 "gpio.h"
|
||||
#include "mxc_sys.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
// LED
|
||||
#define LED_PORT MXC_GPIO2
|
||||
#define LED_PIN MXC_GPIO_PIN_1
|
||||
#define LED_VDDIO MXC_GPIO_VSSEL_VDDIOH
|
||||
#define LED_STATE_ON 1
|
||||
|
||||
// Button
|
||||
#define BUTTON_PORT MXC_GPIO1
|
||||
#define BUTTON_PIN MXC_GPIO_PIN_27
|
||||
#define BUTTON_PULL MXC_GPIO_PAD_NONE
|
||||
#define BUTTON_STATE_ACTIVE 1
|
||||
|
||||
// UART Enable for UART on ARM SWD Connector
|
||||
#define UART_NUM 0
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* BOARD_H_ */
|
1
hw/bsp/max32690/boards/apard32690/board.mk
Normal file
1
hw/bsp/max32690/boards/apard32690/board.mk
Normal file
@@ -0,0 +1 @@
|
||||
# No specific build requirements for the board.
|
@@ -24,12 +24,12 @@
|
||||
* This file is part of the TinyUSB stack.
|
||||
*/
|
||||
|
||||
#include "bsp/board_api.h"
|
||||
#include "board.h"
|
||||
#include "mxc_device.h"
|
||||
#include "mcr_regs.h"
|
||||
#include "uart.h"
|
||||
#include "bsp/board_api.h"
|
||||
#include "gpio.h"
|
||||
#include "mcr_regs.h"
|
||||
#include "mxc_device.h"
|
||||
#include "uart.h"
|
||||
|
||||
//--------------------------------------------------------------------+
|
||||
// Forward USB interrupt events to TinyUSB IRQ Handler
|
||||
|
@@ -57,8 +57,7 @@ typedef union {
|
||||
uint32_t u32;
|
||||
} hw_fifo_t;
|
||||
|
||||
typedef struct TU_ATTR_PACKED
|
||||
{
|
||||
typedef struct TU_ATTR_PACKED {
|
||||
void *buf; /* the start address of a transfer data buffer */
|
||||
uint16_t length; /* the number of bytes in the buffer */
|
||||
uint16_t remaining; /* the number of bytes remaining in the buffer */
|
||||
@@ -80,8 +79,7 @@ typedef struct
|
||||
static dcd_data_t _dcd;
|
||||
|
||||
|
||||
static volatile void* edpt_get_fifo_ptr(unsigned epnum)
|
||||
{
|
||||
static volatile void *edpt_get_fifo_ptr(unsigned epnum) {
|
||||
volatile uint32_t *ptr;
|
||||
|
||||
ptr = &MXC_USBHS->fifo0;
|
||||
@@ -90,8 +88,7 @@ static volatile void* edpt_get_fifo_ptr(unsigned epnum)
|
||||
return (volatile void *) ptr;
|
||||
}
|
||||
|
||||
static void pipe_write_packet(void *buf, volatile void *fifo, unsigned len)
|
||||
{
|
||||
static void pipe_write_packet(void *buf, volatile void *fifo, unsigned len) {
|
||||
volatile hw_fifo_t *reg = (volatile hw_fifo_t *) fifo;
|
||||
uintptr_t addr = (uintptr_t) buf;
|
||||
while (len >= 4) {
|
||||
@@ -109,8 +106,7 @@ static void pipe_write_packet(void *buf, volatile void *fifo, unsigned len)
|
||||
}
|
||||
}
|
||||
|
||||
static void pipe_read_packet(void *buf, volatile void *fifo, unsigned len)
|
||||
{
|
||||
static void pipe_read_packet(void *buf, volatile void *fifo, unsigned len) {
|
||||
volatile hw_fifo_t *reg = (volatile hw_fifo_t *) fifo;
|
||||
uintptr_t addr = (uintptr_t) buf;
|
||||
while (len >= 4) {
|
||||
@@ -128,8 +124,7 @@ static void pipe_read_packet(void *buf, volatile void *fifo, unsigned len)
|
||||
}
|
||||
}
|
||||
|
||||
static void pipe_read_write_packet_ff(tu_fifo_t *f, volatile void *fifo, unsigned len, unsigned dir)
|
||||
{
|
||||
static void pipe_read_write_packet_ff(tu_fifo_t *f, volatile void *fifo, unsigned len, unsigned dir) {
|
||||
static const struct {
|
||||
void (*tu_fifo_get_info)(tu_fifo_t *f, tu_fifo_buffer_info_t *info);
|
||||
void (*tu_fifo_advance)(tu_fifo_t *f, uint16_t n);
|
||||
@@ -152,8 +147,7 @@ static void pipe_read_write_packet_ff(tu_fifo_t *f, volatile void *fifo, unsigne
|
||||
ops[dir].tu_fifo_advance(f, total_len - rem);
|
||||
}
|
||||
|
||||
static void process_setup_packet(uint8_t rhport)
|
||||
{
|
||||
static void process_setup_packet(uint8_t rhport) {
|
||||
uint32_t *p = (void *) &_dcd.setup_packet;
|
||||
p[0] = MXC_USBHS->fifo0;
|
||||
p[1] = MXC_USBHS->fifo0;
|
||||
@@ -173,8 +167,7 @@ static void process_setup_packet(uint8_t rhport)
|
||||
}
|
||||
}
|
||||
|
||||
static bool handle_xfer_in(uint_fast8_t ep_addr)
|
||||
{
|
||||
static bool handle_xfer_in(uint_fast8_t ep_addr) {
|
||||
unsigned epnum = tu_edpt_number(ep_addr);
|
||||
unsigned epnum_minus1 = epnum - 1;
|
||||
pipe_state_t *pipe = &_dcd.pipe[tu_edpt_dir(ep_addr)][epnum_minus1];
|
||||
@@ -193,7 +186,6 @@ static bool handle_xfer_in(uint_fast8_t ep_addr)
|
||||
const unsigned len = TU_MIN(mps, rem);
|
||||
void *buf = pipe->buf;
|
||||
volatile void *fifo_ptr = edpt_get_fifo_ptr(epnum);
|
||||
// TU_LOG1(" %p mps %d len %d rem %d\r\n", buf, mps, len, rem);
|
||||
if (len) {
|
||||
if (_dcd.pipe_buf_is_fifo[TUSB_DIR_IN] & TU_BIT(epnum_minus1)) {
|
||||
pipe_read_write_packet_ff(buf, fifo_ptr, len, TUSB_DIR_IN);
|
||||
@@ -208,8 +200,7 @@ static bool handle_xfer_in(uint_fast8_t ep_addr)
|
||||
return false;
|
||||
}
|
||||
|
||||
static bool handle_xfer_out(uint_fast8_t ep_addr)
|
||||
{
|
||||
static bool handle_xfer_out(uint_fast8_t ep_addr) {
|
||||
unsigned epnum = tu_edpt_number(ep_addr);
|
||||
unsigned epnum_minus1 = epnum - 1;
|
||||
pipe_state_t *pipe = &_dcd.pipe[tu_edpt_dir(ep_addr)][epnum_minus1];
|
||||
@@ -244,8 +235,7 @@ static bool handle_xfer_out(uint_fast8_t ep_addr)
|
||||
return false;
|
||||
}
|
||||
|
||||
static bool edpt_n_xfer(uint8_t rhport, uint8_t ep_addr, uint8_t *buffer, uint16_t total_bytes)
|
||||
{
|
||||
static bool edpt_n_xfer(uint8_t rhport, uint8_t ep_addr, uint8_t *buffer, uint16_t total_bytes) {
|
||||
(void) rhport;
|
||||
|
||||
unsigned epnum = tu_edpt_number(ep_addr);
|
||||
@@ -268,8 +258,7 @@ static bool edpt_n_xfer(uint8_t rhport, uint8_t ep_addr, uint8_t *buffer, uint16
|
||||
return true;
|
||||
}
|
||||
|
||||
static bool edpt0_xfer(uint8_t rhport, uint8_t ep_addr, uint8_t *buffer, uint16_t total_bytes)
|
||||
{
|
||||
static bool edpt0_xfer(uint8_t rhport, uint8_t ep_addr, uint8_t *buffer, uint16_t total_bytes) {
|
||||
(void) rhport;
|
||||
TU_ASSERT(total_bytes <= 64); /* Current implementation supports for only up to 64 bytes. */
|
||||
|
||||
@@ -332,8 +321,7 @@ static bool edpt0_xfer(uint8_t rhport, uint8_t ep_addr, uint8_t *buffer, uint16_
|
||||
return true;
|
||||
}
|
||||
|
||||
static void process_ep0(uint8_t rhport)
|
||||
{
|
||||
static void process_ep0(uint8_t rhport) {
|
||||
MXC_USBHS->index = 0;
|
||||
uint_fast8_t csrl = MXC_USBHS->csr0;
|
||||
|
||||
@@ -413,8 +401,7 @@ static void process_ep0(uint8_t rhport)
|
||||
}
|
||||
}
|
||||
|
||||
static void process_edpt_n(uint8_t rhport, uint_fast8_t ep_addr)
|
||||
{
|
||||
static void process_edpt_n(uint8_t rhport, uint_fast8_t ep_addr) {
|
||||
bool completed;
|
||||
const unsigned dir_in = tu_edpt_dir(ep_addr);
|
||||
const unsigned epnum = tu_edpt_number(ep_addr);
|
||||
@@ -443,10 +430,8 @@ static void process_edpt_n(uint8_t rhport, uint_fast8_t ep_addr)
|
||||
}
|
||||
}
|
||||
|
||||
static void process_bus_reset(uint8_t rhport)
|
||||
{
|
||||
static void process_bus_reset(uint8_t rhport) {
|
||||
(void) rhport;
|
||||
TU_LOG0("------Bus Reset\r\n");
|
||||
/* When bmRequestType is REQUEST_TYPE_INVALID(0xFF),
|
||||
* a control transfer state is SETUP or STATUS stage. */
|
||||
_dcd.setup_packet.bmRequestType = REQUEST_TYPE_INVALID;
|
||||
@@ -478,8 +463,7 @@ static void process_bus_reset(uint8_t rhport)
|
||||
* Device API
|
||||
*------------------------------------------------------------------*/
|
||||
|
||||
void dcd_init(uint8_t rhport)
|
||||
{
|
||||
void dcd_init(uint8_t rhport) {
|
||||
(void) rhport;
|
||||
MXC_USBHS->intrusben |= MXC_F_USBHS_INTRUSBEN_SUSPEND_INT_EN;
|
||||
|
||||
@@ -524,21 +508,18 @@ void dcd_init(uint8_t rhport)
|
||||
dcd_connect(rhport);
|
||||
}
|
||||
|
||||
void dcd_int_enable(uint8_t rhport)
|
||||
{
|
||||
void dcd_int_enable(uint8_t rhport) {
|
||||
(void) rhport;
|
||||
NVIC_EnableIRQ(USB_IRQn);
|
||||
}
|
||||
|
||||
void dcd_int_disable(uint8_t rhport)
|
||||
{
|
||||
void dcd_int_disable(uint8_t rhport) {
|
||||
(void) rhport;
|
||||
NVIC_DisableIRQ(USB_IRQn);
|
||||
}
|
||||
|
||||
// Receive Set Address request, mcu port must also include status IN response
|
||||
void dcd_set_address(uint8_t rhport, uint8_t dev_addr)
|
||||
{
|
||||
void dcd_set_address(uint8_t rhport, uint8_t dev_addr) {
|
||||
(void) rhport;
|
||||
(void) dev_addr;
|
||||
_dcd.pipe0.buf = NULL;
|
||||
@@ -550,8 +531,7 @@ void dcd_set_address(uint8_t rhport, uint8_t dev_addr)
|
||||
}
|
||||
|
||||
// Wake up host
|
||||
void dcd_remote_wakeup(uint8_t rhport)
|
||||
{
|
||||
void dcd_remote_wakeup(uint8_t rhport) {
|
||||
(void) rhport;
|
||||
MXC_USBHS->power |= MXC_F_USBHS_POWER_RESUME;
|
||||
|
||||
@@ -565,22 +545,19 @@ void dcd_remote_wakeup(uint8_t rhport)
|
||||
}
|
||||
|
||||
// Connect by enabling internal pull-up resistor on D+/D-
|
||||
void dcd_connect(uint8_t rhport)
|
||||
{
|
||||
void dcd_connect(uint8_t rhport) {
|
||||
(void) rhport;
|
||||
MXC_USBHS->power |= TUD_OPT_HIGH_SPEED ? MXC_F_USBHS_POWER_HS_ENABLE : 0;
|
||||
MXC_USBHS->power |= MXC_F_USBHS_POWER_SOFTCONN;
|
||||
}
|
||||
|
||||
// Disconnect by disabling internal pull-up resistor on D+/D-
|
||||
void dcd_disconnect(uint8_t rhport)
|
||||
{
|
||||
void dcd_disconnect(uint8_t rhport) {
|
||||
(void) rhport;
|
||||
MXC_USBHS->power &= ~MXC_F_USBHS_POWER_SOFTCONN;
|
||||
}
|
||||
|
||||
void dcd_sof_enable(uint8_t rhport, bool en)
|
||||
{
|
||||
void dcd_sof_enable(uint8_t rhport, bool en) {
|
||||
(void) rhport;
|
||||
(void) en;
|
||||
|
||||
@@ -592,8 +569,7 @@ void dcd_sof_enable(uint8_t rhport, bool en)
|
||||
//--------------------------------------------------------------------+
|
||||
|
||||
// Configure endpoint's registers according to descriptor
|
||||
bool dcd_edpt_open(uint8_t rhport, tusb_desc_endpoint_t const * ep_desc)
|
||||
{
|
||||
bool dcd_edpt_open(uint8_t rhport, tusb_desc_endpoint_t const *ep_desc) {
|
||||
(void) rhport;
|
||||
|
||||
const unsigned ep_addr = ep_desc->bEndpointAddress;
|
||||
@@ -634,8 +610,7 @@ bool dcd_edpt_open(uint8_t rhport, tusb_desc_endpoint_t const * ep_desc)
|
||||
return true;
|
||||
}
|
||||
|
||||
void dcd_edpt_close_all(uint8_t rhport)
|
||||
{
|
||||
void dcd_edpt_close_all(uint8_t rhport) {
|
||||
(void) rhport;
|
||||
|
||||
MXC_SYS_Crit_Enter();
|
||||
@@ -665,8 +640,7 @@ void dcd_edpt_close_all(uint8_t rhport)
|
||||
MXC_SYS_Crit_Exit();
|
||||
}
|
||||
|
||||
void dcd_edpt_close(uint8_t rhport, uint8_t ep_addr)
|
||||
{
|
||||
void dcd_edpt_close(uint8_t rhport, uint8_t ep_addr) {
|
||||
(void) rhport;
|
||||
unsigned const epn = tu_edpt_number(ep_addr);
|
||||
unsigned const dir_in = tu_edpt_dir(ep_addr);
|
||||
@@ -696,8 +670,7 @@ void dcd_edpt_close(uint8_t rhport, uint8_t ep_addr)
|
||||
}
|
||||
|
||||
// Submit a transfer, When complete dcd_event_xfer_complete() is invoked to notify the stack
|
||||
bool dcd_edpt_xfer(uint8_t rhport, uint8_t ep_addr, uint8_t * buffer, uint16_t total_bytes)
|
||||
{
|
||||
bool dcd_edpt_xfer(uint8_t rhport, uint8_t ep_addr, uint8_t *buffer, uint16_t total_bytes) {
|
||||
(void) rhport;
|
||||
bool ret;
|
||||
unsigned const epnum = tu_edpt_number(ep_addr);
|
||||
@@ -712,8 +685,7 @@ bool dcd_edpt_xfer(uint8_t rhport, uint8_t ep_addr, uint8_t * buffer, uint16_t t
|
||||
}
|
||||
|
||||
// Submit a transfer where is managed by FIFO, When complete dcd_event_xfer_complete() is invoked to notify the stack - optional, however, must be listed in usbd.c
|
||||
bool dcd_edpt_xfer_fifo(uint8_t rhport, uint8_t ep_addr, tu_fifo_t * ff, uint16_t total_bytes)
|
||||
{
|
||||
bool dcd_edpt_xfer_fifo(uint8_t rhport, uint8_t ep_addr, tu_fifo_t *ff, uint16_t total_bytes) {
|
||||
(void) rhport;
|
||||
bool ret;
|
||||
unsigned const epnum = tu_edpt_number(ep_addr);
|
||||
@@ -726,8 +698,7 @@ bool dcd_edpt_xfer_fifo(uint8_t rhport, uint8_t ep_addr, tu_fifo_t * ff, uint16_
|
||||
}
|
||||
|
||||
// Stall endpoint
|
||||
void dcd_edpt_stall(uint8_t rhport, uint8_t ep_addr)
|
||||
{
|
||||
void dcd_edpt_stall(uint8_t rhport, uint8_t ep_addr) {
|
||||
(void) rhport;
|
||||
unsigned const epn = tu_edpt_number(ep_addr);
|
||||
MXC_SYS_Crit_Enter();
|
||||
@@ -750,8 +721,7 @@ void dcd_edpt_stall(uint8_t rhport, uint8_t ep_addr)
|
||||
}
|
||||
|
||||
// clear stall, data toggle is also reset to DATA0
|
||||
void dcd_edpt_clear_stall(uint8_t rhport, uint8_t ep_addr)
|
||||
{
|
||||
void dcd_edpt_clear_stall(uint8_t rhport, uint8_t ep_addr) {
|
||||
(void) rhport;
|
||||
unsigned const epn = tu_edpt_number(ep_addr);
|
||||
MXC_SYS_Crit_Enter();
|
||||
@@ -779,8 +749,7 @@ void dcd_edpt_clear_stall(uint8_t rhport, uint8_t ep_addr)
|
||||
/*-------------------------------------------------------------------
|
||||
* ISR
|
||||
*-------------------------------------------------------------------*/
|
||||
void dcd_int_handler(uint8_t rhport)
|
||||
{
|
||||
void dcd_int_handler(uint8_t rhport) {
|
||||
uint_fast8_t is, txis, rxis;
|
||||
uint32_t mxm_int, mxm_int_en, mxm_is;
|
||||
uint32_t saved_index;
|
||||
|
Reference in New Issue
Block a user