33 lines
599 B
C
33 lines
599 B
C
#include <usb/usb.h>
|
|
#include <hwo/utils.h>
|
|
#include <hwo/events.h>
|
|
#include <hwo/utils.h>
|
|
|
|
#include <avr/io.h>
|
|
#include <avr/interrupt.h>
|
|
|
|
|
|
usb_device_t usb_device;
|
|
|
|
void usb_device_attach(void){
|
|
ATOMIC
|
|
if (usb_device.state.HWEnabled){
|
|
UDCON &= ~_BV(DETACH);
|
|
usb_device.state.Attached = 1;
|
|
};
|
|
};
|
|
|
|
void usb_device_detach(void){
|
|
ATOMIC
|
|
if (usb_device.state.Attached){
|
|
UDCON |= _BV(DETACH);
|
|
usb_device.state = (usb_device_state_t){ HWEnabled: 1 };
|
|
};
|
|
};
|
|
|
|
void usb_device_off(void){
|
|
USBCON &= ~_BV(USBE);
|
|
usb_device.state = (usb_device_state_t){ };
|
|
};
|
|
|