mirror of
https://github.com/qmk/qmk_firmware.git
synced 2025-04-21 22:51:28 +00:00
broke some more shit
This commit is contained in:
parent
feeee4e40d
commit
6ad68e6269
@ -32,6 +32,8 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|||||||
#include "pro_micro.h"
|
#include "pro_micro.h"
|
||||||
#include "config.h"
|
#include "config.h"
|
||||||
#include "timer.h"
|
#include "timer.h"
|
||||||
|
#include "Device.h"
|
||||||
|
#include "pincontrol.h"
|
||||||
|
|
||||||
|
|
||||||
#ifdef USE_I2C
|
#ifdef USE_I2C
|
||||||
@ -41,7 +43,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
// Seconds to keep checking if USB has been enumearted, before settling for being slave half.
|
// Seconds to keep checking if USB has been enumearted, before settling for being slave half.
|
||||||
#define USBTIMEOUT 3
|
volatile bool is_slave = false;
|
||||||
|
|
||||||
#ifndef DEBOUNCING_DELAY
|
#ifndef DEBOUNCING_DELAY
|
||||||
# define DEBOUNCING_DELAY 5
|
# define DEBOUNCING_DELAY 5
|
||||||
@ -131,7 +133,7 @@ uint8_t matrix_cols(void)
|
|||||||
}
|
}
|
||||||
|
|
||||||
bool has_usb(void) {
|
bool has_usb(void) {
|
||||||
return UDADDR & _BV(ADDEN); // This will return true if a USB connection has been established
|
return USB_DeviceState == DEVICE_STATE_Configured;
|
||||||
}
|
}
|
||||||
|
|
||||||
void timer_reset(void) {
|
void timer_reset(void) {
|
||||||
@ -173,7 +175,6 @@ void matrix_init(void)
|
|||||||
matrix_debouncing[i] = 0;
|
matrix_debouncing[i] = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
// initialize as slave
|
|
||||||
timer_init();
|
timer_init();
|
||||||
#ifdef USE_I2C
|
#ifdef USE_I2C
|
||||||
i2c_slave_init(SLAVE_I2C_ADDRESS);
|
i2c_slave_init(SLAVE_I2C_ADDRESS);
|
||||||
@ -181,19 +182,19 @@ void matrix_init(void)
|
|||||||
serial_slave_init();
|
serial_slave_init();
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
while (USB_DeviceState != DEVICE_STATE_Configured && !is_slave) {
|
||||||
|
USB_USBTask();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
sei();
|
sei();
|
||||||
|
|
||||||
matrix_init_quantum();
|
matrix_init_quantum();
|
||||||
|
|
||||||
/* Wait USBTIMEOUT for USB
|
|
||||||
uint32_t timeout_start = timer_count;
|
|
||||||
while(!has_usb() && USBTIMEOUT > timer_count - timeout_start) {
|
|
||||||
matrix_slave_scan();
|
|
||||||
}*/
|
|
||||||
|
|
||||||
// If we have USB, switch to master
|
// If we have USB, switch to master
|
||||||
|
|
||||||
if(has_usb()) {
|
if(has_usb()) {
|
||||||
//timer_reset();
|
timer_reset();
|
||||||
#ifdef USE_I2C
|
#ifdef USE_I2C
|
||||||
i2c_master_init();
|
i2c_master_init();
|
||||||
#else
|
#else
|
||||||
|
@ -122,6 +122,7 @@ void serial_write_byte(uint8_t data) {
|
|||||||
|
|
||||||
// interrupt handle to be used by the slave device
|
// interrupt handle to be used by the slave device
|
||||||
ISR(SERIAL_PIN_INTERRUPT) {
|
ISR(SERIAL_PIN_INTERRUPT) {
|
||||||
|
is_slave = true;
|
||||||
sync_send();
|
sync_send();
|
||||||
|
|
||||||
uint8_t checksum = 0;
|
uint8_t checksum = 0;
|
||||||
|
@ -18,6 +18,9 @@
|
|||||||
extern volatile uint8_t serial_slave_buffer[SERIAL_SLAVE_BUFFER_LENGTH];
|
extern volatile uint8_t serial_slave_buffer[SERIAL_SLAVE_BUFFER_LENGTH];
|
||||||
extern volatile uint8_t serial_master_buffer[SERIAL_MASTER_BUFFER_LENGTH];
|
extern volatile uint8_t serial_master_buffer[SERIAL_MASTER_BUFFER_LENGTH];
|
||||||
|
|
||||||
|
// Variable used to exit whileloop if the half is the slave
|
||||||
|
extern volatile bool is_slave;
|
||||||
|
|
||||||
void serial_master_init(void);
|
void serial_master_init(void);
|
||||||
void serial_slave_init(void);
|
void serial_slave_init(void);
|
||||||
int serial_update_buffers(void);
|
int serial_update_buffers(void);
|
||||||
|
Loading…
Reference in New Issue
Block a user