updates chibios configuration for f303

This commit is contained in:
Jack Humbert 2017-07-20 00:35:54 -04:00 committed by skullY
parent 95d73bff77
commit ddb8df99a1
6 changed files with 38 additions and 25 deletions

View File

@ -6,7 +6,7 @@
# Stack size to be allocated to the Cortex-M process stack. This stack is
# the stack used by the main() thread.
ifeq ($(USE_PROCESS_STACKSIZE),)
USE_PROCESS_STACKSIZE = 0x200
USE_PROCESS_STACKSIZE = 0x8000
endif
# 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) $(DFU_ARGS) -D $(BUILD_DIR)/$(TARGET).bin
bin: $(BUILD_DIR)/$(TARGET).bin sizeafter
$(COPY) $(BUILD_DIR)/$(TARGET).bin $(TARGET).bin;

View File

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

View File

@ -10,10 +10,11 @@
#include "host.h"
#include "backlight.h"
#include "suspend.h"
#include "wait.h"
void suspend_idle(uint8_t time) {
// TODO: this is not used anywhere - what units is 'time' in?
chThdSleepMilliseconds(time);
wait_ms(time);
}
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
// SLEEP_MODE_PWR_DOWN
chThdSleepMilliseconds(17);
wait_ms(17);
}
__attribute__ ((weak)) void matrix_power_up(void) {}

View File

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

View File

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

View File

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