rev2 working
This commit is contained in:
parent
874f5a5c07
commit
274283420d
@ -82,7 +82,8 @@ void IS31FL3731_write_register( uint8_t addr, uint8_t reg, uint8_t data )
|
||||
g_twi_transfer_buffer[1] = data;
|
||||
|
||||
//Transmit data until succesful
|
||||
while(twi2c_transmit(addr << 1, g_twi_transfer_buffer,2) != 0);
|
||||
//while(twi2c_transmit(addr << 1, g_twi_transfer_buffer,2) != 0);
|
||||
twi2c_transmit(addr << 1, g_twi_transfer_buffer,2);
|
||||
}
|
||||
|
||||
void IS31FL3731_write_pwm_buffer( uint8_t addr, uint8_t *pwm_buffer )
|
||||
@ -106,7 +107,8 @@ void IS31FL3731_write_pwm_buffer( uint8_t addr, uint8_t *pwm_buffer )
|
||||
}
|
||||
|
||||
//Transmit buffer until succesful
|
||||
while(twi2c_transmit(addr << 1, g_twi_transfer_buffer,17) != 0);
|
||||
//while(twi2c_transmit(addr << 1, g_twi_transfer_buffer,17) != 0);
|
||||
twi2c_transmit(addr << 1, g_twi_transfer_buffer,17);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -46,13 +46,12 @@ I2CSlaveMsgCB twi2c_slave_message_process, catchError, clearAfterSend;
|
||||
|
||||
static uint8_t twi2c_address;
|
||||
|
||||
static const I2CConfig I2CConfig = {
|
||||
static const I2CConfig i2cconfig = {
|
||||
STM32_TIMINGR_PRESC(15U) |
|
||||
STM32_TIMINGR_SCLDEL(4U) | STM32_TIMINGR_SDADEL(2U) |
|
||||
STM32_TIMINGR_SCLH(15U) | STM32_TIMINGR_SCLL(21U),
|
||||
0,
|
||||
0,
|
||||
NULL
|
||||
0
|
||||
};
|
||||
|
||||
char initialReplyBody[50] = "Initial reply"; // 'Status' response if read without preceding write
|
||||
@ -182,7 +181,7 @@ void twi2c_slave_init(void) {
|
||||
twi2c_init();
|
||||
|
||||
|
||||
i2cStart(&I2C_DRIVER, &I2CConfig);
|
||||
i2cStart(&I2C_DRIVER, &i2cconfig);
|
||||
#if HAL_USE_I2C_SLAVE
|
||||
I2C_DRIVER.slaveTimeout = MS2ST(100); // Time for complete message
|
||||
#endif
|
||||
@ -213,15 +212,16 @@ void twi2c_slave_task(void) {
|
||||
|
||||
uint8_t twi2c_start(uint8_t address) {
|
||||
twi2c_address = address;
|
||||
i2cStart(&I2C_DRIVER, &I2CConfig);
|
||||
i2cStart(&I2C_DRIVER, &i2cconfig);
|
||||
return 0;
|
||||
}
|
||||
|
||||
void twi2c_init(void) {
|
||||
palSetGroupMode(GPIOB,8,9, PAL_MODE_INPUT); // Try releasing special pins for a short time
|
||||
palSetGroupMode(GPIOB,6,7, PAL_MODE_INPUT); // Try releasing special pins for a short time
|
||||
chThdSleepMilliseconds(10);
|
||||
|
||||
palSetPadMode(GPIOB, 9, PAL_MODE_ALTERNATE(4) | PAL_STM32_OTYPE_OPENDRAIN | PAL_STM32_PUPDR_PULLUP);
|
||||
palSetPadMode(GPIOB, 8, PAL_MODE_ALTERNATE(4) | PAL_STM32_OTYPE_OPENDRAIN | PAL_STM32_PUPDR_PULLUP);
|
||||
palSetPadMode(GPIOB, 6, PAL_MODE_ALTERNATE(4) | PAL_STM32_OTYPE_OPENDRAIN | PAL_STM32_PUPDR_PULLUP);
|
||||
palSetPadMode(GPIOB, 7, PAL_MODE_ALTERNATE(4) | PAL_STM32_OTYPE_OPENDRAIN | PAL_STM32_PUPDR_PULLUP);
|
||||
|
||||
// try high drive (from kiibohd)
|
||||
// I2C_DRIVER.i2c->C2 |= I2Cx_C2_HDRS;
|
||||
@ -229,14 +229,12 @@ void twi2c_init(void) {
|
||||
// I2C_DRIVER.i2c->FLT = 4;
|
||||
}
|
||||
|
||||
uint8_t buffer[1] = {0};
|
||||
|
||||
uint8_t twi2c_write(uint8_t data) {
|
||||
return i2cMasterTransmitTimeout(&I2C_DRIVER, twi2c_address/2, &data, 1, buffer, 1, MS2ST(100));
|
||||
return i2cMasterTransmitTimeout(&I2C_DRIVER, twi2c_address/2, &data, 1, 0, 0, MS2ST(100));
|
||||
}
|
||||
|
||||
uint8_t twi2c_transmit(uint8_t address, uint8_t* data, uint16_t length) {
|
||||
twi2c_address = address;
|
||||
i2cStart(&I2C_DRIVER, &I2CConfig);
|
||||
return i2cMasterTransmitTimeout(&I2C_DRIVER, twi2c_address/2, data, length, buffer, 1, MS2ST(100));
|
||||
i2cStart(&I2C_DRIVER, &i2cconfig);
|
||||
return i2cMasterTransmitTimeout(&I2C_DRIVER, twi2c_address/2, data, length, 0, 0, MS2ST(100));
|
||||
}
|
||||
|
@ -41,7 +41,7 @@
|
||||
* @brief System time counter resolution.
|
||||
* @note Allowed values are 16 or 32 bits.
|
||||
*/
|
||||
#define CH_CFG_ST_RESOLUTION 16
|
||||
#define CH_CFG_ST_RESOLUTION 32
|
||||
|
||||
/**
|
||||
* @brief System tick frequency.
|
||||
|
@ -19,13 +19,17 @@
|
||||
#define REV6_CONFIG_H
|
||||
|
||||
/* USB Device descriptor parameter */
|
||||
#define DEVICE_VER 0x0006
|
||||
#undef PRODUCT
|
||||
#define PRODUCT Planck Light
|
||||
#undef PRODUCT_ID
|
||||
#define PRODUCT_ID 0x6065
|
||||
#define DEVICE_VER 0x0002
|
||||
|
||||
#undef MATRIX_ROWS
|
||||
#undef MATRIX_COLS
|
||||
/* key matrix size */
|
||||
#define MATRIX_ROWS 8
|
||||
#define MATRIX_COLS 6
|
||||
#define MATRIX_ROWS 4
|
||||
#define MATRIX_COLS 12
|
||||
|
||||
/*
|
||||
* Keyboard Matrix Assignments
|
||||
|
@ -111,7 +111,7 @@
|
||||
* @brief Enables the PWM subsystem.
|
||||
*/
|
||||
#if !defined(HAL_USE_PWM) || defined(__DOXYGEN__)
|
||||
#define HAL_USE_PWM TRUE
|
||||
#define HAL_USE_PWM FALSE
|
||||
#endif
|
||||
|
||||
/**
|
||||
|
@ -12,8 +12,8 @@
|
||||
#include <string.h>
|
||||
|
||||
/*
|
||||
* col: { B11, B10, B2, B1, A7, B0 }
|
||||
* row: { A10, A9, A8, B15, C13, C14, C15, A2 }
|
||||
* col: { A10, B2, A15, A0, A1, A2, B0, B1, C13, A6, A7, A3 }
|
||||
* row: { B5, B10, A9, A8 }
|
||||
*/
|
||||
/* matrix state(1:on, 0:off) */
|
||||
static matrix_row_t matrix[MATRIX_ROWS];
|
||||
@ -45,12 +45,6 @@ void matrix_init(void) {
|
||||
printf("matrix init\n");
|
||||
//debug_matrix = true;
|
||||
|
||||
// dip switch setup
|
||||
palSetPadMode(GPIOB, 14, PAL_MODE_INPUT_PULLUP);
|
||||
palSetPadMode(GPIOA, 15, PAL_MODE_INPUT_PULLUP);
|
||||
palSetPadMode(GPIOA, 10, PAL_MODE_INPUT_PULLUP);
|
||||
palSetPadMode(GPIOB, 9, PAL_MODE_INPUT_PULLUP);
|
||||
|
||||
// encoder setup
|
||||
palSetPadMode(GPIOB, 12, PAL_MODE_INPUT_PULLUP);
|
||||
palSetPadMode(GPIOB, 13, PAL_MODE_INPUT_PULLUP);
|
||||
@ -58,21 +52,23 @@ void matrix_init(void) {
|
||||
encoder_state = (palReadPad(GPIOB, 12) << 0) | (palReadPad(GPIOB, 13) << 1);
|
||||
|
||||
// actual matrix setup
|
||||
palSetPadMode(GPIOB, 11, PAL_MODE_OUTPUT_PUSHPULL);
|
||||
palSetPadMode(GPIOB, 10, PAL_MODE_OUTPUT_PUSHPULL);
|
||||
palSetPadMode(GPIOA, 10, PAL_MODE_OUTPUT_PUSHPULL);
|
||||
palSetPadMode(GPIOB, 2, PAL_MODE_OUTPUT_PUSHPULL);
|
||||
palSetPadMode(GPIOB, 1, PAL_MODE_OUTPUT_PUSHPULL);
|
||||
palSetPadMode(GPIOA, 7, PAL_MODE_OUTPUT_PUSHPULL);
|
||||
palSetPadMode(GPIOA, 15, PAL_MODE_OUTPUT_PUSHPULL);
|
||||
palSetPadMode(GPIOA, 0, PAL_MODE_OUTPUT_PUSHPULL);
|
||||
palSetPadMode(GPIOA, 1, PAL_MODE_OUTPUT_PUSHPULL);
|
||||
palSetPadMode(GPIOA, 2, PAL_MODE_OUTPUT_PUSHPULL);
|
||||
palSetPadMode(GPIOB, 0, PAL_MODE_OUTPUT_PUSHPULL);
|
||||
palSetPadMode(GPIOB, 1, PAL_MODE_OUTPUT_PUSHPULL);
|
||||
palSetPadMode(GPIOC, 13, PAL_MODE_OUTPUT_PUSHPULL);
|
||||
palSetPadMode(GPIOA, 6, PAL_MODE_OUTPUT_PUSHPULL);
|
||||
palSetPadMode(GPIOA, 7, PAL_MODE_OUTPUT_PUSHPULL);
|
||||
palSetPadMode(GPIOA, 3, PAL_MODE_OUTPUT_PUSHPULL);
|
||||
|
||||
palSetPadMode(GPIOA, 10, PAL_MODE_INPUT_PULLDOWN);
|
||||
palSetPadMode(GPIOB, 5, PAL_MODE_INPUT_PULLDOWN);
|
||||
palSetPadMode(GPIOB, 10, PAL_MODE_INPUT_PULLDOWN);
|
||||
palSetPadMode(GPIOA, 9, PAL_MODE_INPUT_PULLDOWN);
|
||||
palSetPadMode(GPIOA, 8, PAL_MODE_INPUT_PULLDOWN);
|
||||
palSetPadMode(GPIOB, 15, PAL_MODE_INPUT_PULLDOWN);
|
||||
palSetPadMode(GPIOC, 13, PAL_MODE_INPUT_PULLDOWN);
|
||||
palSetPadMode(GPIOC, 14, PAL_MODE_INPUT_PULLDOWN);
|
||||
palSetPadMode(GPIOC, 15, PAL_MODE_INPUT_PULLDOWN);
|
||||
palSetPadMode(GPIOA, 2, PAL_MODE_INPUT_PULLDOWN);
|
||||
|
||||
|
||||
memset(matrix, 0, MATRIX_ROWS * sizeof(matrix_row_t));
|
||||
@ -110,39 +106,47 @@ uint8_t matrix_scan(void) {
|
||||
for (int col = 0; col < MATRIX_COLS; col++) {
|
||||
matrix_row_t data = 0;
|
||||
|
||||
// strobe col { B11, B10, B2, B1, A7, B0 }
|
||||
// strobe col { A10, B2, A15, A0, A1, A2, B0, B1, C13, A6, A7, A3 }
|
||||
switch (col) {
|
||||
case 0: palSetPad(GPIOB, 11); break;
|
||||
case 1: palSetPad(GPIOB, 10); break;
|
||||
case 2: palSetPad(GPIOB, 2); break;
|
||||
case 3: palSetPad(GPIOB, 1); break;
|
||||
case 4: palSetPad(GPIOA, 7); break;
|
||||
case 5: palSetPad(GPIOB, 0); break;
|
||||
case 0: palSetPad(GPIOA, 10); break;
|
||||
case 1: palSetPad(GPIOB, 2); break;
|
||||
case 2: palSetPad(GPIOA, 15); break;
|
||||
case 3: palSetPad(GPIOA, 0); break;
|
||||
case 4: palSetPad(GPIOA, 1); break;
|
||||
case 5: palSetPad(GPIOA, 2); break;
|
||||
case 6: palSetPad(GPIOB, 0); break;
|
||||
case 7: palSetPad(GPIOB, 1); break;
|
||||
case 8: palSetPad(GPIOC, 13); break;
|
||||
case 9: palSetPad(GPIOA, 6); break;
|
||||
case 10: palSetPad(GPIOA, 7); break;
|
||||
case 11: palSetPad(GPIOA, 3); break;
|
||||
}
|
||||
|
||||
// need wait to settle pin state
|
||||
wait_us(20);
|
||||
|
||||
// read row data { A10, A9, A8, B15, C13, C14, C15, A2 }
|
||||
// read row data { B5, B10, A9, A8 }
|
||||
data = (
|
||||
(palReadPad(GPIOA, 10) << 0 ) |
|
||||
(palReadPad(GPIOA, 9) << 1 ) |
|
||||
(palReadPad(GPIOA, 8) << 2 ) |
|
||||
(palReadPad(GPIOB, 15) << 3 ) |
|
||||
(palReadPad(GPIOC, 13) << 4 ) |
|
||||
(palReadPad(GPIOC, 14) << 5 ) |
|
||||
(palReadPad(GPIOC, 15) << 6 ) |
|
||||
(palReadPad(GPIOA, 2) << 7 )
|
||||
(palReadPad(GPIOB, 5) << 0 ) |
|
||||
(palReadPad(GPIOB, 10) << 1 ) |
|
||||
(palReadPad(GPIOA, 9) << 2 ) |
|
||||
(palReadPad(GPIOA, 8) << 3 )
|
||||
);
|
||||
|
||||
// unstrobe col { B11, B10, B2, B1, A7, B0 }
|
||||
switch (col) {
|
||||
case 0: palClearPad(GPIOB, 11); break;
|
||||
case 1: palClearPad(GPIOB, 10); break;
|
||||
case 2: palClearPad(GPIOB, 2); break;
|
||||
case 3: palClearPad(GPIOB, 1); break;
|
||||
case 4: palClearPad(GPIOA, 7); break;
|
||||
case 5: palClearPad(GPIOB, 0); break;
|
||||
case 0: palClearPad(GPIOA, 10); break;
|
||||
case 1: palClearPad(GPIOB, 2); break;
|
||||
case 2: palClearPad(GPIOA, 15); break;
|
||||
case 3: palClearPad(GPIOA, 0); break;
|
||||
case 4: palClearPad(GPIOA, 1); break;
|
||||
case 5: palClearPad(GPIOA, 2); break;
|
||||
case 6: palClearPad(GPIOB, 0); break;
|
||||
case 7: palClearPad(GPIOB, 1); break;
|
||||
case 8: palClearPad(GPIOC, 13); break;
|
||||
case 9: palClearPad(GPIOA, 6); break;
|
||||
case 10: palClearPad(GPIOA, 7); break;
|
||||
case 11: palClearPad(GPIOA, 3); break;
|
||||
}
|
||||
|
||||
if (matrix_debouncing[col] != data) {
|
||||
|
@ -183,8 +183,8 @@
|
||||
*/
|
||||
#define STM32_PWM_USE_ADVANCED FALSE
|
||||
#define STM32_PWM_USE_TIM1 FALSE
|
||||
#define STM32_PWM_USE_TIM2 TRUE
|
||||
#define STM32_PWM_USE_TIM3 TRUE
|
||||
#define STM32_PWM_USE_TIM2 FALSE
|
||||
#define STM32_PWM_USE_TIM3 FALSE
|
||||
#define STM32_PWM_USE_TIM4 FALSE
|
||||
#define STM32_PWM_USE_TIM8 FALSE
|
||||
#define STM32_PWM_TIM1_IRQ_PRIORITY 7
|
||||
@ -225,7 +225,7 @@
|
||||
* ST driver system settings.
|
||||
*/
|
||||
#define STM32_ST_IRQ_PRIORITY 8
|
||||
#define STM32_ST_USE_TIMER 4
|
||||
#define STM32_ST_USE_TIMER 2
|
||||
|
||||
/*
|
||||
* UART driver system settings.
|
||||
|
@ -14,11 +14,3 @@
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
#include "rev2.h"
|
||||
|
||||
void matrix_init_kb(void) {
|
||||
matrix_init_user();
|
||||
}
|
||||
|
||||
void matrix_scan_kb(void) {
|
||||
matrix_scan_user();
|
||||
}
|
||||
|
@ -3,7 +3,7 @@
|
||||
|
||||
#include "quantum.h"
|
||||
|
||||
#ifdef __AVR__
|
||||
#if defined(__AVR__) || defined (KEYBOARD_planck_light_rev2)
|
||||
#define LAYOUT_planck_mit( \
|
||||
k00, k01, k02, k03, k04, k05, k06, k07, k08, k09, k0a, k0b, \
|
||||
k10, k11, k12, k13, k14, k15, k16, k17, k18, k19, k1a, k1b, \
|
||||
|
@ -121,6 +121,11 @@ extern uint32_t default_layer_state;
|
||||
#include "process_terminal_nop.h"
|
||||
#endif
|
||||
|
||||
#ifndef MIN
|
||||
#define MAX(x, y) (((x) > (y)) ? (x) : (y))
|
||||
#define MIN(x, y) (((x) < (y)) ? (x) : (y))
|
||||
#endif
|
||||
|
||||
#define STRINGIZE(z) #z
|
||||
#define ADD_SLASH_X(y) STRINGIZE(\x ## y)
|
||||
#define SYMBOL_STR(x) ADD_SLASH_X(x)
|
||||
|
@ -17,14 +17,14 @@
|
||||
|
||||
|
||||
#include "rgb_matrix.h"
|
||||
#include <avr/io.h>
|
||||
#include "i2c_master.h"
|
||||
#include <util/delay.h>
|
||||
#include <avr/interrupt.h>
|
||||
//#include <avr/io.h>
|
||||
#include "twi2c.h"
|
||||
#include "wait.h"
|
||||
//#include <avr/interrupt.h>
|
||||
#include "progmem.h"
|
||||
#include "config.h"
|
||||
#include "eeprom.h"
|
||||
#include "lufa.h"
|
||||
//#include "lufa.h"
|
||||
#include <math.h>
|
||||
|
||||
rgb_config_t rgb_matrix_config;
|
||||
@ -723,7 +723,7 @@ void rgb_matrix_indicators_user(void) {}
|
||||
|
||||
void rgb_matrix_init_drivers(void) {
|
||||
// Initialize TWI
|
||||
i2c_init();
|
||||
twi2c_init();
|
||||
IS31FL3731_init( DRIVER_ADDR_1 );
|
||||
IS31FL3731_init( DRIVER_ADDR_2 );
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user