forked from forks/qmk_firmware
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 "config.h"
|
||||
#include "timer.h"
|
||||
#include "Device.h"
|
||||
#include "pincontrol.h"
|
||||
|
||||
|
||||
#ifdef USE_I2C
|
||||
|
@ -41,7 +43,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|||
#endif
|
||||
|
||||
// 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
|
||||
# define DEBOUNCING_DELAY 5
|
||||
|
@ -131,7 +133,7 @@ uint8_t matrix_cols(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) {
|
||||
|
@ -150,20 +152,20 @@ void timer_reset(void) {
|
|||
|
||||
void matrix_init(void)
|
||||
{
|
||||
#ifdef DISABLE_JTAG
|
||||
// JTAG disable for PORT F. write JTD bit twice within four cycles.
|
||||
MCUCR |= (1<<JTD);
|
||||
MCUCR |= (1<<JTD);
|
||||
#endif
|
||||
#ifdef DISABLE_JTAG
|
||||
// JTAG disable for PORT F. write JTD bit twice within four cycles.
|
||||
MCUCR |= (1<<JTD);
|
||||
MCUCR |= (1<<JTD);
|
||||
#endif
|
||||
|
||||
// initialize row and col
|
||||
#if (DIODE_DIRECTION == COL2ROW)
|
||||
// initialize row and col
|
||||
#if (DIODE_DIRECTION == COL2ROW)
|
||||
unselect_rows();
|
||||
init_cols();
|
||||
#elif (DIODE_DIRECTION == ROW2COL)
|
||||
#elif (DIODE_DIRECTION == ROW2COL)
|
||||
unselect_cols();
|
||||
init_rows();
|
||||
#endif
|
||||
#endif
|
||||
|
||||
TX_RX_LED_INIT;
|
||||
|
||||
|
@ -173,7 +175,6 @@ void matrix_init(void)
|
|||
matrix_debouncing[i] = 0;
|
||||
}
|
||||
|
||||
// initialize as slave
|
||||
timer_init();
|
||||
#ifdef USE_I2C
|
||||
i2c_slave_init(SLAVE_I2C_ADDRESS);
|
||||
|
@ -181,26 +182,26 @@ void matrix_init(void)
|
|||
serial_slave_init();
|
||||
#endif
|
||||
|
||||
while (USB_DeviceState != DEVICE_STATE_Configured && !is_slave) {
|
||||
USB_USBTask();
|
||||
}
|
||||
|
||||
|
||||
sei();
|
||||
|
||||
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(has_usb()) {
|
||||
//timer_reset();
|
||||
timer_reset();
|
||||
#ifdef USE_I2C
|
||||
i2c_master_init();
|
||||
#else
|
||||
serial_master_init();
|
||||
#endif
|
||||
}
|
||||
else{
|
||||
else {
|
||||
while (1) {
|
||||
matrix_slave_scan();
|
||||
}
|
||||
|
|
|
@ -122,6 +122,7 @@ void serial_write_byte(uint8_t data) {
|
|||
|
||||
// interrupt handle to be used by the slave device
|
||||
ISR(SERIAL_PIN_INTERRUPT) {
|
||||
is_slave = true;
|
||||
sync_send();
|
||||
|
||||
uint8_t checksum = 0;
|
||||
|
|
|
@ -18,6 +18,9 @@
|
|||
extern volatile uint8_t serial_slave_buffer[SERIAL_SLAVE_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_slave_init(void);
|
||||
int serial_update_buffers(void);
|
||||
|
|
Loading…
Reference in a new issue