Skip to content

Commit

Permalink
2020 February 29 Breaking Changes Update (qmk#8064)
Browse files Browse the repository at this point in the history
  • Loading branch information
noroadsleft authored and fdidron committed Jun 12, 2020
1 parent ae86417 commit f01c45e
Show file tree
Hide file tree
Showing 45 changed files with 1,466 additions and 559 deletions.
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -64,3 +64,6 @@ id_rsa_*

# python things
__pycache__

# prerequisites for updating ChibiOS
/util/fmpp*
1 change: 0 additions & 1 deletion .gitmodules
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
[submodule "lib/chibios-contrib"]
path = lib/chibios-contrib
url = https://github.com/qmk/ChibiOS-Contrib
branch = k-type-fix
[submodule "lib/ugfx"]
path = lib/ugfx
url = https://github.com/qmk/uGFX
Expand Down
6 changes: 6 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -618,13 +618,19 @@ endif
# Generate the version.h file
ifndef SKIP_GIT
GIT_VERSION := $(shell git describe --abbrev=6 --dirty --always --tags 2>/dev/null || date +"%Y-%m-%d-%H:%M:%S")
CHIBIOS_VERSION := $(shell cd lib/chibios && git describe --abbrev=6 --dirty --always --tags 2>/dev/null || date +"%Y-%m-%d-%H:%M:%S")
CHIBIOS_CONTRIB_VERSION := $(shell cd lib/chibios-contrib && git describe --abbrev=6 --dirty --always --tags 2>/dev/null || date +"%Y-%m-%d-%H:%M:%S")
else
GIT_VERSION := NA
CHIBIOS_VERSION := NA
CHIBIOS_CONTRIB_VERSION := NA
endif
ifndef SKIP_VERSION
BUILD_DATE := $(shell date +"%Y-%m-%d-%H:%M:%S")
$(shell echo '#define QMK_VERSION "$(GIT_VERSION)"' > $(ROOT_DIR)/quantum/version.h)
$(shell echo '#define QMK_BUILDDATE "$(BUILD_DATE)"' >> $(ROOT_DIR)/quantum/version.h)
$(shell echo '#define CHIBIOS_VERSION "$(CHIBIOS_VERSION)"' >> $(ROOT_DIR)/quantum/version.h)
$(shell echo '#define CHIBIOS_CONTRIB_VERSION "$(CHIBIOS_CONTRIB_VERSION)"' >> $(ROOT_DIR)/quantum/version.h)
else
BUILD_DATE := NA
endif
Expand Down
1 change: 1 addition & 0 deletions common_features.mk
Original file line number Diff line number Diff line change
Expand Up @@ -298,6 +298,7 @@ VALID_BACKLIGHT_TYPES := pwm software custom
BACKLIGHT_ENABLE ?= no
BACKLIGHT_DRIVER ?= pwm
ifeq ($(strip $(BACKLIGHT_ENABLE)), yes)
SRC += $(QUANTUM_DIR)/process_keycode/process_backlight.c
ifeq ($(filter $(BACKLIGHT_DRIVER),$(VALID_BACKLIGHT_TYPES)),)
$(error BACKLIGHT_DRIVER="$(BACKLIGHT_DRIVER)" is not a valid backlight type)
endif
Expand Down
71 changes: 14 additions & 57 deletions drivers/arm/i2c_master.c
Original file line number Diff line number Diff line change
Expand Up @@ -29,12 +29,16 @@
#include <string.h>
#include <hal.h>

static uint8_t i2c_address;

static const I2CConfig i2cconfig = {
#ifdef USE_I2CV1
I2C1_OPMODE,
I2C1_CLOCK_SPEED,
I2C1_DUTY_CYCLE,
#else
// This configures the I2C clock to 400khz assuming a 72Mhz clock
// For more info : https://www.st.com/en/embedded-software/stsw-stm32126.html
STM32_TIMINGR_PRESC(I2C1_TIMINGR_PRESC) | STM32_TIMINGR_SCLDEL(I2C1_TIMINGR_SCLDEL) | STM32_TIMINGR_SDADEL(I2C1_TIMINGR_SDADEL) | STM32_TIMINGR_SCLH(I2C1_TIMINGR_SCLH) | STM32_TIMINGR_SCLL(I2C1_TIMINGR_SCLL), 0, 0
#endif
};
Expand Down Expand Up @@ -64,58 +68,30 @@ __attribute__((weak)) void i2c_init(void) {
palSetPadMode(I2C1_SCL_BANK, I2C1_SCL, PAL_MODE_ALTERNATE(I2C1_SCL_PAL_MODE) | PAL_STM32_OTYPE_OPENDRAIN);
palSetPadMode(I2C1_SDA_BANK, I2C1_SDA, PAL_MODE_ALTERNATE(I2C1_SDA_PAL_MODE) | PAL_STM32_OTYPE_OPENDRAIN);
#endif

// i2cInit(); //This is invoked by halInit() so no need to redo it.
}

i2c_status_t i2c_start(uint8_t address) {
#if I2C_USE_MUTUAL_EXCLUSION
i2cAcquireBus(&I2C_DRIVER);
#endif

i2c_address = address;
i2cStart(&I2C_DRIVER, &i2cconfig);
return I2C_STATUS_SUCCESS;
}

i2c_status_t i2c_transmit(uint8_t address, const uint8_t* data, uint16_t length, uint16_t timeout) {
#if I2C_USE_MUTUAL_EXCLUSION
i2cAcquireBus(&I2C_DRIVER);
#endif

i2c_address = address;
i2cStart(&I2C_DRIVER, &i2cconfig);
msg_t status = i2cMasterTransmitTimeout(&I2C_DRIVER, (address >> 1), data, length, 0, 0, MS2ST(timeout));

#if I2C_USE_MUTUAL_EXCLUSION
i2cReleaseBus(&I2C_DRIVER);
#endif

msg_t status = i2cMasterTransmitTimeout(&I2C_DRIVER, (i2c_address >> 1), data, length, 0, 0, TIME_MS2I(timeout));
return chibios_to_qmk(&status);
}

i2c_status_t i2c_receive(uint8_t address, uint8_t* data, uint16_t length, uint16_t timeout) {
#if I2C_USE_MUTUAL_EXCLUSION
i2cAcquireBus(&I2C_DRIVER);
#endif

i2c_address = address;
i2cStart(&I2C_DRIVER, &i2cconfig);
msg_t status = i2cMasterReceiveTimeout(&I2C_DRIVER, (address >> 1), data, length, MS2ST(timeout));

#if I2C_USE_MUTUAL_EXCLUSION
i2cReleaseBus(&I2C_DRIVER);
#endif

msg_t status = i2cMasterReceiveTimeout(&I2C_DRIVER, (i2c_address >> 1), data, length, TIME_MS2I(timeout));
return chibios_to_qmk(&status);
}

i2c_status_t i2c_transmit_receive(uint8_t address, uint8_t * tx_body, uint16_t tx_length, uint8_t * rx_body, uint16_t rx_length) {
return i2cMasterTransmitTimeout(&I2C_DRIVER, address/2, tx_body, tx_length, rx_body, rx_length, MS2ST(100));
}

i2c_status_t i2c_writeReg(uint8_t devaddr, uint8_t regaddr, const uint8_t* data, uint16_t length, uint16_t timeout) {
#if I2C_USE_MUTUAL_EXCLUSION
i2cAcquireBus(&I2C_DRIVER);
#endif

i2c_address = devaddr;
i2cStart(&I2C_DRIVER, &i2cconfig);

uint8_t complete_packet[length + 1];
Expand All @@ -124,34 +100,15 @@ i2c_status_t i2c_writeReg(uint8_t devaddr, uint8_t regaddr, const uint8_t* data,
}
complete_packet[0] = regaddr;

msg_t status = i2cMasterTransmitTimeout(&I2C_DRIVER, (devaddr >> 1), complete_packet, length + 1, 0, 0, MS2ST(timeout));

#if I2C_USE_MUTUAL_EXCLUSION
i2cReleaseBus(&I2C_DRIVER);
#endif

msg_t status = i2cMasterTransmitTimeout(&I2C_DRIVER, (i2c_address >> 1), complete_packet, length + 1, 0, 0, TIME_MS2I(timeout));
return chibios_to_qmk(&status);
}

i2c_status_t i2c_readReg(uint8_t devaddr, uint8_t regaddr, uint8_t* data, uint16_t length, uint16_t timeout) {
#if I2C_USE_MUTUAL_EXCLUSION
i2cAcquireBus(&I2C_DRIVER);
#endif

i2c_address = devaddr;
i2cStart(&I2C_DRIVER, &i2cconfig);
msg_t status = i2cMasterTransmitTimeout(&I2C_DRIVER, (devaddr >> 1), &regaddr, 1, data, length, MS2ST(timeout));

#if I2C_USE_MUTUAL_EXCLUSION
i2cReleaseBus(&I2C_DRIVER);
#endif

msg_t status = i2cMasterTransmitTimeout(&I2C_DRIVER, (i2c_address >> 1), &regaddr, 1, data, length, TIME_MS2I(timeout));
return chibios_to_qmk(&status);
}

void i2c_stop(void) {
i2cStop(&I2C_DRIVER);

#if I2C_USE_MUTUAL_EXCLUSION
i2cReleaseBus(&I2C_DRIVER);
#endif
}
void i2c_stop(void) { i2cStop(&I2C_DRIVER); }
2 changes: 1 addition & 1 deletion drivers/arm/ws2812_spi.c
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ void ws2812_init(void) {

// TODO: more dynamic baudrate
static const SPIConfig spicfg = {
NULL, PAL_PORT(RGB_DI_PIN), PAL_PAD(RGB_DI_PIN),
0, NULL, PAL_PORT(RGB_DI_PIN), PAL_PAD(RGB_DI_PIN),
SPI_CR1_BR_1 | SPI_CR1_BR_0 // baudrate : fpclk / 8 => 1tick is 0.32us (2.25 MHz)
};

Expand Down
Loading

0 comments on commit f01c45e

Please sign in to comment.