updates chibios configuration for f303

clueboard_arm
Jack Humbert 7 years ago committed by skullY
parent 95d73bff77
commit ddb8df99a1

@ -6,7 +6,7 @@
# Stack size to be allocated to the Cortex-M process stack. This stack is # Stack size to be allocated to the Cortex-M process stack. This stack is
# the stack used by the main() thread. # the stack used by the main() thread.
ifeq ($(USE_PROCESS_STACKSIZE),) ifeq ($(USE_PROCESS_STACKSIZE),)
USE_PROCESS_STACKSIZE = 0x200 USE_PROCESS_STACKSIZE = 0x8000
endif endif
# Stack size to the allocated to the Cortex-M main/exceptions stack. This # Stack size to the allocated to the Cortex-M main/exceptions stack. This
@ -155,3 +155,6 @@ DFU_UTIL ?= dfu-util
dfu-util: $(BUILD_DIR)/$(TARGET).bin sizeafter dfu-util: $(BUILD_DIR)/$(TARGET).bin sizeafter
$(DFU_UTIL) $(DFU_ARGS) -D $(BUILD_DIR)/$(TARGET).bin $(DFU_UTIL) $(DFU_ARGS) -D $(BUILD_DIR)/$(TARGET).bin
bin: $(BUILD_DIR)/$(TARGET).bin sizeafter
$(COPY) $(BUILD_DIR)/$(TARGET).bin $(TARGET).bin;

@ -49,7 +49,7 @@ void bootloader_jump(void) {
#else /* defined(KIIBOHD_BOOTLOADER) */ #else /* defined(KIIBOHD_BOOTLOADER) */
/* Default for Kinetis - expecting an ARM Teensy */ /* Default for Kinetis - expecting an ARM Teensy */
void bootloader_jump(void) { void bootloader_jump(void) {
chThdSleepMilliseconds(100); wait_ms(100);
__BKPT(0); __BKPT(0);
} }
#endif /* defined(KIIBOHD_BOOTLOADER) */ #endif /* defined(KIIBOHD_BOOTLOADER) */

@ -10,10 +10,11 @@
#include "host.h" #include "host.h"
#include "backlight.h" #include "backlight.h"
#include "suspend.h" #include "suspend.h"
#include "wait.h"
void suspend_idle(uint8_t time) { void suspend_idle(uint8_t time) {
// TODO: this is not used anywhere - what units is 'time' in? // TODO: this is not used anywhere - what units is 'time' in?
chThdSleepMilliseconds(time); wait_ms(time);
} }
void suspend_power_down(void) { void suspend_power_down(void) {
@ -24,7 +25,7 @@ void suspend_power_down(void) {
// on AVR, this enables the watchdog for 15ms (max), and goes to // on AVR, this enables the watchdog for 15ms (max), and goes to
// SLEEP_MODE_PWR_DOWN // SLEEP_MODE_PWR_DOWN
chThdSleepMilliseconds(17); wait_ms(17);
} }
__attribute__ ((weak)) void matrix_power_up(void) {} __attribute__ ((weak)) void matrix_power_up(void) {}

@ -13,8 +13,8 @@ extern "C" {
# define wait_us(us) _delay_us(us) # define wait_us(us) _delay_us(us)
#elif defined(PROTOCOL_CHIBIOS) #elif defined(PROTOCOL_CHIBIOS)
# include "ch.h" # include "ch.h"
# define wait_ms(ms) chThdSleepMilliseconds(ms) # define wait_ms(ms) chSysPolledDelayX(MS2RTC(STM32_HCLK, (ms)))
# define wait_us(us) chThdSleepMicroseconds(us) # define wait_us(us) chSysPolledDelayX(US2RTC(STM32_HCLK, (us)))
#elif defined(__arm__) #elif defined(__arm__)
# include "wait_api.h" # include "wait_api.h"
#else // Unit tests #else // Unit tests

@ -42,7 +42,7 @@
#include "visualizer/visualizer.h" #include "visualizer/visualizer.h"
#endif #endif
#include "suspend.h" #include "suspend.h"
#include "wait.h"
/* ------------------------- /* -------------------------
* TMK host driver defs * TMK host driver defs
@ -70,19 +70,19 @@ host_driver_t chibios_driver = {
* Amber LED blinker thread, times are in milliseconds. * Amber LED blinker thread, times are in milliseconds.
*/ */
/* set this variable to non-zero anywhere to blink once */ /* set this variable to non-zero anywhere to blink once */
// uint8_t blinkLed = 0; // static THD_WORKING_AREA(waThread1, 128);
// static THD_WORKING_AREA(waBlinkerThread, 128); // static THD_FUNCTION(Thread1, arg) {
// static THD_FUNCTION(blinkerThread, arg) {
// (void)arg; // (void)arg;
// chRegSetThreadName("blinkOrange"); // chRegSetThreadName("blinker");
// while(true) { // while (true) {
// if(blinkLed) { // systime_t time;
// blinkLed = 0;
// palSetPad(TEENSY_PIN13_IOPORT, TEENSY_PIN13); // time = USB_DRIVER.state == USB_ACTIVE ? 250 : 500;
// chThdSleepMilliseconds(100); // palClearLine(LINE_CAPS_LOCK);
// palClearPad(TEENSY_PIN13_IOPORT, TEENSY_PIN13); // chSysPolledDelayX(MS2RTC(STM32_HCLK, time));
// } // palSetLine(LINE_CAPS_LOCK);
// chThdSleepMilliseconds(100); // chSysPolledDelayX(MS2RTC(STM32_HCLK, time));
// } // }
// } // }
@ -96,7 +96,7 @@ int main(void) {
chSysInit(); chSysInit();
// TESTING // TESTING
// chThdCreateStatic(waBlinkerThread, sizeof(waBlinkerThread), NORMALPRIO, blinkerThread, NULL); // chThdCreateStatic(waThread1, sizeof(waThread1), NORMALPRIO, Thread1, NULL);
/* Init USB */ /* Init USB */
init_usb_driver(&USB_DRIVER); init_usb_driver(&USB_DRIVER);
@ -128,7 +128,7 @@ int main(void) {
} }
serial_link_update(); serial_link_update();
#endif #endif
chThdSleepMilliseconds(50); wait_ms(50);
} }
/* Do need to wait here! /* Do need to wait here!
@ -136,7 +136,7 @@ int main(void) {
* before the USB is completely ready, which sometimes causes * before the USB is completely ready, which sometimes causes
* HardFaults. * HardFaults.
*/ */
chThdSleepMilliseconds(50); wait_ms(50);
print("USB configured.\n"); print("USB configured.\n");

@ -27,6 +27,7 @@
#include "sleep_led.h" #include "sleep_led.h"
#include "led.h" #include "led.h"
#endif #endif
#include "wait.h"
#ifdef NKRO_ENABLE #ifdef NKRO_ENABLE
#include "keycode_config.h" #include "keycode_config.h"
@ -39,6 +40,14 @@
* --------------------------------------------------------- * ---------------------------------------------------------
*/ */
#ifndef usb_lld_connect_bus
#define usb_lld_connect_bus(usbp)
#endif
#ifndef usb_lld_disconnect_bus
#define usb_lld_disconnect_bus(usbp)
#endif
uint8_t keyboard_idle __attribute__((aligned(2))) = 0; uint8_t keyboard_idle __attribute__((aligned(2))) = 0;
uint8_t keyboard_protocol __attribute__((aligned(2))) = 1; uint8_t keyboard_protocol __attribute__((aligned(2))) = 1;
uint16_t keyboard_led_stats __attribute__((aligned(2))) = 0; uint16_t keyboard_led_stats __attribute__((aligned(2))) = 0;
@ -1017,7 +1026,7 @@ void init_usb_driver(USBDriver *usbp) {
* after a reset. * after a reset.
*/ */
usbDisconnectBus(usbp); usbDisconnectBus(usbp);
chThdSleepMilliseconds(1500); wait_ms(1500);
usbStart(usbp, &usbcfg); usbStart(usbp, &usbcfg);
usbConnectBus(usbp); usbConnectBus(usbp);
@ -1037,12 +1046,12 @@ void send_remote_wakeup(USBDriver *usbp) {
#if defined(K20x) || defined(KL2x) #if defined(K20x) || defined(KL2x)
#if KINETIS_USB_USE_USB0 #if KINETIS_USB_USE_USB0
USB0->CTL |= USBx_CTL_RESUME; USB0->CTL |= USBx_CTL_RESUME;
chThdSleepMilliseconds(15); wait_ms(15);
USB0->CTL &= ~USBx_CTL_RESUME; USB0->CTL &= ~USBx_CTL_RESUME;
#endif /* KINETIS_USB_USE_USB0 */ #endif /* KINETIS_USB_USE_USB0 */
#elif defined(STM32F0XX) || defined(STM32F1XX) || defined(STM32F3XX) /* End K20x || KL2x */ #elif defined(STM32F0XX) || defined(STM32F1XX) || defined(STM32F3XX) /* End K20x || KL2x */
STM32_USB->CNTR |= CNTR_RESUME; STM32_USB->CNTR |= CNTR_RESUME;
chThdSleepMilliseconds(15); wait_ms(15);
STM32_USB->CNTR &= ~CNTR_RESUME; STM32_USB->CNTR &= ~CNTR_RESUME;
#else /* End STM32F0XX || STM32F1XX || STM32F3XX */ #else /* End STM32F0XX || STM32F1XX || STM32F3XX */
#warning Sending remote wakeup packet not implemented for your platform. #warning Sending remote wakeup packet not implemented for your platform.

Loading…
Cancel
Save