Skip to content

Commit e748f09

Browse files
committed
Moved USB ISR handler in startup.c
1 parent fe4d51f commit e748f09

File tree

6 files changed

+22
-38
lines changed

6 files changed

+22
-38
lines changed

Diff for: cores/arduino/USB/USBCore.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -294,7 +294,7 @@ void USBDeviceClass::init()
294294
while (GCLK->STATUS.bit.SYNCBUSY)
295295
;
296296

297-
UHD_SetStack(&UDD_Handler);
297+
USB_SetHandler(&UDD_Handler);
298298

299299
// Reset USB Device
300300
usbd.reset();

Diff for: cores/arduino/USB/USB_host.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ typedef enum {
4848

4949
extern void UHD_Init(void);
5050
extern void UHD_Handler(void);
51-
extern void UHD_SetStack(void (*pf_isr)(void));
51+
extern void USB_SetHandler(void (*pf_isr)(void));
5252
extern uhd_vbus_state_t UHD_GetVBUSState(void);
5353
extern uint32_t UHD_Pipe0_Alloc(uint32_t ul_add, uint32_t ul_ep_size);
5454
extern uint32_t UHD_Pipe_Alloc(uint32_t ul_dev_addr, uint32_t ul_dev_ep, uint32_t ul_type, uint32_t ul_dir, uint32_t ul_maxsize, uint32_t ul_interval, uint32_t ul_nb_bank);

Diff for: cores/arduino/USB/USB_interrupt.c

-30
This file was deleted.

Diff for: cores/arduino/USB/samd21_host.c

+1-1
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ void UHD_Init(void)
6363
uint32_t pad_trim;
6464
uint32_t i;
6565

66-
UHD_SetStack(&UHD_Handler);
66+
USB_SetHandler(&UHD_Handler);
6767

6868
/* Enable USB clock */
6969
PM->APBBMASK.reg |= PM_APBBMASK_USB;

Diff for: cores/arduino/cortex_handlers.c

+17-4
Original file line numberDiff line numberDiff line change
@@ -16,16 +16,16 @@
1616
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
1717
*/
1818

19-
#include "sam.h"
20-
#include "variant.h"
19+
#include <sam.h>
20+
#include <variant.h>
21+
#include <stdio.h>
2122

2223
/* RTOS Hooks */
2324
extern void svcHook(void);
2425
extern void pendSVHook(void);
2526
extern int sysTickHook(void);
2627

2728
/* Default empty handler */
28-
2929
void Dummy_Handler(void)
3030
{
3131
#if defined DEBUG
@@ -50,7 +50,7 @@ void RTC_Handler (void) __attribute__ ((weak, alias("Dummy_Handler")));
5050
void EIC_Handler (void) __attribute__ ((weak, alias("Dummy_Handler")));
5151
void NVMCTRL_Handler (void) __attribute__ ((weak, alias("Dummy_Handler")));
5252
void DMAC_Handler (void) __attribute__ ((weak, alias("Dummy_Handler")));
53-
void USB_Handler (void) __attribute__ ((weak, alias("Dummy_Handler")));
53+
void USB_Handler (void) __attribute__ ((weak));
5454
void EVSYS_Handler (void) __attribute__ ((weak, alias("Dummy_Handler")));
5555
void SERCOM0_Handler (void) __attribute__ ((weak, alias("Dummy_Handler")));
5656
void SERCOM1_Handler (void) __attribute__ ((weak, alias("Dummy_Handler")));
@@ -176,3 +176,16 @@ void SysTick_Handler(void)
176176
return;
177177
SysTick_DefaultHandler();
178178
}
179+
180+
static void (*usb_isr)(void) = NULL;
181+
182+
void USB_Handler(void)
183+
{
184+
if (usb_isr)
185+
usb_isr();
186+
}
187+
188+
void USB_SetHandler(void (*new_usb_isr)(void))
189+
{
190+
usb_isr = new_usb_isr;
191+
}

Diff for: cores/arduino/startup.c

+2-1
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,8 @@
1919
#include "sam.h"
2020
#include "variant.h"
2121

22+
#include <stdio.h>
23+
2224
/**
2325
* \brief SystemInit() configures the needed clocks and according Flash Read Wait States.
2426
* At reset:
@@ -222,4 +224,3 @@ void SystemInit( void )
222224

223225
ADC->CALIB.reg = ADC_CALIB_BIAS_CAL(bias) | ADC_CALIB_LINEARITY_CAL(linearity);
224226
}
225-

0 commit comments

Comments
 (0)