Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <asf.h>
- void vbus_event(bool b_high);
- void usb_init(void);
- int main (void)
- {
- // Insert system clock initialization code here (sysclk_init()).
- sysclk_init();
- irq_initialize_vectors();
- cpu_irq_enable();
- board_init();
- udc_start();
- vbus_event(true);
- while(42) {
- }
- // Insert application code here, after the board has been initialized.
- }
- void vbus_event(bool b_high)
- {
- if (b_high) {
- // Attach USB Device
- udc_attach();
- } else {
- // VBUS not present
- udc_detach();
- }
- }
- void usb_init(void)
- {
- udc_start();
- }
- static bool my_flag_autorize_generic_events = false;
- bool my_callback_generic_enable(void)
- {
- my_flag_autorize_generic_events = true;
- return true;
- }
- void my_callback_generic_disable(void)
- {
- my_flag_autorize_generic_events = false;
- }
- void my_button_press_event(void)
- {
- if (!my_flag_autorize_generic_events) {
- return;
- }
- uint8_t report[] = {0x00,0x01,0x02};
- udi_hid_generic_send_report_in(report);
- }
- void my_callback_generic_report_out(uint8_t *report)
- {
- /*if ((report[0] == MY_VALUE_0)
- (report[1] == MY_VALUE_1)) {
- // The report is correct
- }*/
- }
- void my_callback_generic_set_feature(uint8_t *report_feature)
- {
- /*
- if ((report_feature[0] == MY_VALUE_0)
- (report_feature[1] == MY_VALUE_1)) {
- // The report feature is correct
- }*/
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement