link_phy_t link_phy_open(const char * name, int baudrate){ link_phy_t fd; uint32_t pinmask; #ifdef __PHY_USB fd = link_phy_usb_open(); if( fd < 0){ led_error(); return -1; } #else uart_attr_t attr; fd = open("/dev/uart0", O_RDWR); if( fd < 0){ return -1; } attr.baudrate = 460800; attr.parity = UART_PARITY_EVEN; attr.pin_assign = 0; attr.start = UART_ATTR_START_BITS_1; attr.stop = UART_ATTR_STOP_BITS_2; attr.width = 8; if( ioctl(fd, I_UART_SETATTR, &attr) < 0 ){ return -1; } #endif pinmask = (1<<18); hwpl_core_privcall(led_priv_on, &pinmask); usleep(50*1000); hwpl_core_privcall(led_priv_off, &pinmask); pinmask = (1<<20); hwpl_core_privcall(led_priv_on, &pinmask); usleep(75*1000); hwpl_core_privcall(led_priv_off, &pinmask); pinmask = (1<<21); hwpl_core_privcall(led_priv_on, &pinmask); usleep(100*1000); hwpl_core_privcall(led_priv_off, &pinmask); pinmask = (1<<23); hwpl_core_privcall(led_priv_on, &pinmask); usleep(200*1000); hwpl_core_privcall(led_priv_off, &pinmask); link_phy_flush(fd); #ifdef XIVELY init_devices(); #endif return fd; }
void EVENT_USB_Device_ConfigurationChanged(void) { bool success = true; success &= MS_Device_ConfigureEndpoints(&ms_device); success &= HID_Device_ConfigureEndpoints(&keyboard_device); // success &= CDC_Device_ConfigureEndpoints(&serial_device); USB_Device_EnableSOFEvents(); if (!success) { led_error(USB_ERROR); } }
/* Systick interrupt handler */ void SysTick_Handler(void) { ticks++; static int warmup = 0; static uint16_t sdch_state = 0; static uint16_t reset_state = 0; sdch_state = (sdch_state << 1) | SDCARD_DETECT | 0xe000; if(warmup > WARMUP_TICKS && ((sdch_state == 0xf000) || (sdch_state == 0xefff))) { sd_changed = 1; } reset_state = (reset_state << 1) | get_snes_reset() | 0xe000; if((reset_state == 0xf000) || (reset_state == 0xefff)) { reset_pressed = (reset_state == 0xf000); reset_changed = 1; } led_error(); sdn_changed(); SysTick_Hook(); if(warmup <= WARMUP_TICKS) warmup++; }