예제 #1
0
void keyboard_slave_loop(void) {
   matrix_init();

   while (1) {
      matrix_slave_scan();
   }
}
예제 #2
0
void keyboard_slave_loop(void) {
   matrix_init();

   //Init RGB
   #ifdef RGBLIGHT_ENABLE
      rgblight_init();
   #endif

   while (1) {
    // Matrix Slave Scan
    matrix_slave_scan();

    // Read Backlight Info
    #ifdef BACKLIGHT_ENABLE
        #ifdef USE_I2C
            if (BACKLIT_DIRTY) {
                backlight_set(i2c_slave_buffer[I2C_BACKLIT_START]);
                BACKLIT_DIRTY = false;
            }
        #else // USE_SERIAL
            backlight_set(serial_m2s_buffer.backlight_level);
        #endif
    #endif
    // Read RGB Info
    #ifdef RGBLIGHT_ENABLE
        #ifdef USE_I2C
            if (RGB_DIRTY) {
                // Disable interupts (RGB data is big)
                cli();
                // Create new DWORD for RGB data
                uint32_t dword;

                // Fill the new DWORD with the data that was sent over
                uint8_t *dword_dat = (uint8_t *)(&dword);
                for (int i = 0; i < 4; i++) {
                    dword_dat[i] = i2c_slave_buffer[I2C_RGB_START+i];
                }

                // Update the RGB now with the new data and set RGB_DIRTY to false
                rgblight_update_dword(dword);
                RGB_DIRTY = false;
                // Re-enable interupts now that RGB is set
                sei();
            }
        #else // USE_SERIAL
          #ifdef RGBLIGHT_SPLIT
            // Add serial implementation for RGB here
          #endif
        #endif
    #endif
   }
}
예제 #3
0
int main(void)
{
    setup_hardware();
    setup_set_handedness();
    sei();

    /* wait for USB startup to get ready for debug output */
    uint8_t timeout = 200;  // timeout when USB is not available
    while (timeout-- && USB_DeviceState != DEVICE_STATE_Configured) {
        wait_ms(5);
#if defined(INTERRUPT_CONTROL_ENDPOINT)
        ;
#else
        USB_USBTask();
#endif
    }

    /* if (USB_DeviceState != DEVICE_STATE_Configured) { */
    if (!has_usb()) {
        // USB failed to connect, so run this device in slave mode.
        matrix_init();
        serial_slave_init();

        while (1) {
            matrix_slave_scan();
        }
    }

    /* init modules */
    keyboard_init();
    host_set_driver(&lufa_driver);

#ifdef SLEEP_LED_ENABLE
    sleep_led_init();
#endif

    while (1) {
        keyboard_task();

#if !defined(INTERRUPT_CONTROL_ENDPOINT)
        USB_USBTask();
#endif
    }
}