]> git.friedersdorff.com Git - max/tmk_keyboard.git/commitdiff
Add maple mini code.
authorflabbergast <s3+flabbergast@sdfeu.org>
Thu, 3 Dec 2015 08:49:55 +0000 (08:49 +0000)
committerflabbergast <s3+flabbergast@sdfeu.org>
Thu, 3 Dec 2015 08:49:55 +0000 (08:49 +0000)
keyboard/stm32_f103_onekey/Makefile
keyboard/stm32_f103_onekey/chconf.h
keyboard/stm32_f103_onekey/led.c
keyboard/stm32_f103_onekey/matrix.c
keyboard/stm32_f103_onekey/mcuconf.h
tmk_core/protocol/chibios/usb_main.c

index ea2ee08b392d32d013bdf02f7eaec65ca5b7a515..89e58144fb7343382bd4e1107865211381e77041 100644 (file)
@@ -1,6 +1,5 @@
 # Target file name (without extension).
 PROJECT = ch
-TARGET = alps64
 
 # Directory common source files exist
 TMK_DIR = ../../tmk_core
@@ -26,14 +25,14 @@ CONFIG_H = config.h
 # BOARD = GENERIC_STM32_F103
 
 # GENERIC STM32F103C8T6 board - no bootloader (programmer over serial or SWD)
-OPT_DEFS =
-MCU_LDSCRIPT = STM32F103x8
-BOARD = GENERIC_STM32_F103
+OPT_DEFS =
+MCU_LDSCRIPT = STM32F103x8
+BOARD = GENERIC_STM32_F103
 
 # MAPLE MINI
-OPT_DEFS = -DCORTEX_VTOR_INIT=0x5000
-# MCU_LDSCRIPT = STM32F103xE_maplemini_bootloader.ld
-BOARD = MAPLEMINI_STM32_F103
+OPT_DEFS = -DCORTEX_VTOR_INIT=0x5000
+MCU_LDSCRIPT = STM32F103xE_maplemini_bootloader
+BOARD = MAPLEMINI_STM32_F103
 
 ## chip/board settings
 # the next two should match the directories in
@@ -71,7 +70,7 @@ ARMV = 7
 ## BOOTMAGIC is not supported on STM32 chips yet.
 MOUSEKEY_ENABLE = yes  # Mouse keys
 EXTRAKEY_ENABLE = yes  # Audio control and System control
-CONSOLE_ENABLE = yes   # Console for debug
+# CONSOLE_ENABLE = yes # Console for debug
 COMMAND_ENABLE = yes    # Commands for debug and configuration
 SLEEP_LED_ENABLE = no   # Breathing sleep LED during USB suspend
 NKRO_ENABLE = yes          # USB Nkey Rollover
index 689d4b3991efdcf06b9424bb39c051a288d7578d..acce6a1f329493f97518f25b6e1789bc2f2fc16c 100644 (file)
@@ -46,7 +46,7 @@
  * @details Frequency of the system timer that drives the system ticks. This
  *          setting also defines the system tick time unit.
  */
-#define CH_CFG_ST_FREQUENCY                 10000
+#define CH_CFG_ST_FREQUENCY                 2000
 
 /**
  * @brief   Time delta constant for the tick-less mode.
  * @note    This is not related to the compiler optimization options.
  * @note    The default is @p TRUE.
  */
-#define CH_CFG_OPTIMIZE_SPEED               FALSE
+#define CH_CFG_OPTIMIZE_SPEED               TRUE
 
 /** @} */
 
  *
  * @note    The default is @p TRUE.
  */
-#define CH_CFG_USE_MEMCORE                  FALSE
+#define CH_CFG_USE_MEMCORE                  TRUE
 
 /**
  * @brief   Heap Allocator APIs.
  *          @p CH_CFG_USE_SEMAPHORES.
  * @note    Mutexes are recommended.
  */
-#define CH_CFG_USE_HEAP                     FALSE
+#define CH_CFG_USE_HEAP                     TRUE
 
 /**
  * @brief   Memory Pools Allocator APIs.
index ddacfd8c75c384d6c83359b1973df1e8980053ff..3c86963c98070d3ec5b155f621a80c5bd34d1208 100644 (file)
@@ -22,11 +22,25 @@ along with this program.  If not, see <http://www.gnu.org/licenses/>.
 void led_set(uint8_t usb_led)
 {
     if (usb_led & (1<<USB_LED_CAPS_LOCK)) {
-        // output high
+       /* generic STM32F103C8T6 board */
+#ifdef BOARD_GENERIC_STM32_F103
         palSetPadMode(GPIOC, 13, PAL_MODE_OUTPUT_PUSHPULL);
         palClearPad(GPIOC, 13);
+#endif
+        /* Maple Mini */
+#ifdef BOARD_MAPLEMINI_STM32_F103
+        palSetPadMode(GPIOB, 1, PAL_MODE_OUTPUT_PUSHPULL);
+        palSetPad(GPIOB, 1);
+#endif
     } else {
         // Hi-Z
+       /* generic STM32F103C8T6 board */
+#ifdef BOARD_GENERIC_STM32_F103
         palSetPadMode(GPIOC, 13, PAL_MODE_INPUT);
+#endif
+        /* Maple Mini */
+#ifdef BOARD_MAPLEMINI_STM32_F103
+        palSetPadMode(GPIOB, 1, PAL_MODE_INPUT);
+#endif
     }
 }
index 30151c421ca97a176860c37cff11f48196b6043f..d7a9cc3a5ca7ef24b762e0137403aa14558313e9 100644 (file)
@@ -54,9 +54,19 @@ uint8_t matrix_cols(void)
     return MATRIX_COLS;
 }
 
+/* generic STM32F103C8T6 board */
+#ifdef BOARD_GENERIC_STM32_F103
 #define LED_ON()    do { palClearPad(GPIOC, GPIOC_LED) ;} while (0)
 #define LED_OFF()   do { palSetPad(GPIOC, GPIOC_LED); } while (0)
 #define LED_TGL()   do { palTogglePad(GPIOC, GPIOC_LED); } while (0)
+#endif
+
+/* Maple Mini */
+#ifdef BOARD_MAPLEMINI_STM32_F103
+#define LED_ON()    do { palClearPad(GPIOB, 1) ;} while (0)
+#define LED_OFF()   do { palSetPad(GPIOB, 1); } while (0)
+#define LED_TGL()   do { palTogglePad(GPIOB, 1); } while (0)
+#endif
 
 void matrix_init(void)
 {
@@ -132,8 +142,12 @@ void matrix_print(void)
  */
 static void  init_cols(void)
 {
+#ifdef BOARD_MAPLEMINI_STM32_F103
     // don't need pullup/down, since it's pulled down in hardware
+    palSetPadMode(GPIOB, 8, PAL_MODE_INPUT);
+#else
     palSetPadMode(GPIOB, 8, PAL_MODE_INPUT_PULLDOWN);
+#endif
 }
 
 /* Returns status of switches(1:on, 0:off) */
index 4d29c4ae96d1f4ff6d037915b545d553607ff36a..626332a6aa28bf10f4d299428cbbeb7c190ad86b 100644 (file)
 #ifndef _MCUCONF_H_\r
 #define _MCUCONF_H_\r
 \r
+#define STM32F103_MCUCONF\r
+\r
 /*\r
- * STM32F0xx drivers configuration.\r
+ * STM32F103 drivers configuration.\r
  * The following settings override the default settings present in\r
  * the various device driver implementation headers.\r
  * Note that the settings for each driver only have effect if the whole\r
  * driver is enabled in halconf.h.\r
  *\r
  * IRQ priorities:\r
- * 3...0       Lowest...Highest.\r
+ * 15...0       Lowest...Highest.\r
  *\r
  * DMA priorities:\r
  * 0...3        Lowest...Highest.\r
  */\r
 \r
-#define STM32F103_MCUCONF\r
-\r
 /*\r
  * HAL driver system settings.\r
  */\r
 #define STM32_NO_INIT                       FALSE\r
-#define STM32_PVD_ENABLE                    FALSE\r
-#define STM32_PLS                           STM32_PLS_LEV0\r
 #define STM32_HSI_ENABLED                   TRUE\r
-#define STM32_HSI14_ENABLED                 TRUE\r
-#define STM32_HSI48_ENABLED                 FALSE\r
-#define STM32_LSI_ENABLED                   TRUE\r
-#define STM32_HSE_ENABLED                   FALSE\r
+#define STM32_LSI_ENABLED                   FALSE\r
+#define STM32_HSE_ENABLED                   TRUE\r
 #define STM32_LSE_ENABLED                   FALSE\r
 #define STM32_SW                            STM32_SW_PLL\r
-#define STM32_PLLSRC                        STM32_PLLSRC_HSI\r
-#define STM32_PREDIV_VALUE                  2\r
-#define STM32_PLLMUL_VALUE                  12\r
-#define STM32_USBPRE                       STM32_USBPRE_DIV1\r
+#define STM32_PLLSRC                        STM32_PLLSRC_HSE\r
+#define STM32_PLLXTPRE                      STM32_PLLXTPRE_DIV1\r
+#define STM32_PLLMUL_VALUE                  9\r
 #define STM32_HPRE                          STM32_HPRE_DIV1\r
-#define STM32_PPRE                          STM32_PPRE_DIV1\r
-#define STM32_ADCSW                         STM32_ADCSW_HSI14\r
+#define STM32_PPRE1                         STM32_PPRE1_DIV2\r
+#define STM32_PPRE2                         STM32_PPRE2_DIV2\r
 #define STM32_ADCPRE                        STM32_ADCPRE_DIV4\r
+#define STM32_USB_CLOCK_REQUIRED            TRUE\r
+#define STM32_USBPRE                        STM32_USBPRE_DIV1P5\r
 #define STM32_MCOSEL                        STM32_MCOSEL_NOCLOCK\r
-#define STM32_ADCPRE                        STM32_ADCPRE_DIV4\r
-#define STM32_ADCSW                         STM32_ADCSW_HSI14\r
-#define STM32_USBSW                         STM32_USBSW_HSI48\r
-#define STM32_CECSW                         STM32_CECSW_HSI\r
-#define STM32_I2C1SW                        STM32_I2C1SW_HSI\r
-#define STM32_USART1SW                      STM32_USART1SW_PCLK\r
-#define STM32_RTCSEL                        STM32_RTCSEL_LSI\r
+#define STM32_RTCSEL                        STM32_RTCSEL_HSEDIV\r
+#define STM32_PVD_ENABLE                    FALSE\r
+#define STM32_PLS                           STM32_PLS_LEV0\r
 \r
 /*\r
  * ADC driver system settings.\r
  */\r
 #define STM32_ADC_USE_ADC1                  FALSE\r
 #define STM32_ADC_ADC1_DMA_PRIORITY         2\r
-#define STM32_ADC_IRQ_PRIORITY              2\r
-#define STM32_ADC_ADC1_DMA_IRQ_PRIORITY     2\r
+#define STM32_ADC_ADC1_IRQ_PRIORITY         6\r
+\r
+/*\r
+ * CAN driver system settings.\r
+ */\r
+#define STM32_CAN_USE_CAN1                  FALSE\r
+#define STM32_CAN_CAN1_IRQ_PRIORITY         11\r
 \r
 /*\r
  * EXT driver system settings.\r
  */\r
-#define STM32_EXT_EXTI0_1_IRQ_PRIORITY      3\r
-#define STM32_EXT_EXTI2_3_IRQ_PRIORITY      3\r
-#define STM32_EXT_EXTI4_15_IRQ_PRIORITY     3\r
-#define STM32_EXT_EXTI16_IRQ_PRIORITY       3\r
-#define STM32_EXT_EXTI17_IRQ_PRIORITY       3\r
+#define STM32_EXT_EXTI0_IRQ_PRIORITY        6\r
+#define STM32_EXT_EXTI1_IRQ_PRIORITY        6\r
+#define STM32_EXT_EXTI2_IRQ_PRIORITY        6\r
+#define STM32_EXT_EXTI3_IRQ_PRIORITY        6\r
+#define STM32_EXT_EXTI4_IRQ_PRIORITY        6\r
+#define STM32_EXT_EXTI5_9_IRQ_PRIORITY      6\r
+#define STM32_EXT_EXTI10_15_IRQ_PRIORITY    6\r
+#define STM32_EXT_EXTI16_IRQ_PRIORITY       6\r
+#define STM32_EXT_EXTI17_IRQ_PRIORITY       6\r
+#define STM32_EXT_EXTI18_IRQ_PRIORITY       6\r
+#define STM32_EXT_EXTI19_IRQ_PRIORITY       6\r
 \r
 /*\r
  * GPT driver system settings.\r
 #define STM32_GPT_USE_TIM1                  FALSE\r
 #define STM32_GPT_USE_TIM2                  FALSE\r
 #define STM32_GPT_USE_TIM3                  FALSE\r
-#define STM32_GPT_USE_TIM14                 FALSE\r
-#define STM32_GPT_TIM1_IRQ_PRIORITY         2\r
-#define STM32_GPT_TIM2_IRQ_PRIORITY         2\r
-#define STM32_GPT_TIM3_IRQ_PRIORITY         2\r
-#define STM32_GPT_TIM14_IRQ_PRIORITY        2\r
+#define STM32_GPT_USE_TIM4                  FALSE\r
+#define STM32_GPT_USE_TIM5                  FALSE\r
+#define STM32_GPT_USE_TIM8                  FALSE\r
+#define STM32_GPT_TIM1_IRQ_PRIORITY         7\r
+#define STM32_GPT_TIM2_IRQ_PRIORITY         7\r
+#define STM32_GPT_TIM3_IRQ_PRIORITY         7\r
+#define STM32_GPT_TIM4_IRQ_PRIORITY         7\r
+#define STM32_GPT_TIM5_IRQ_PRIORITY         7\r
+#define STM32_GPT_TIM8_IRQ_PRIORITY         7\r
 \r
 /*\r
  * I2C driver system settings.\r
 #define STM32_I2C_USE_I2C1                  FALSE\r
 #define STM32_I2C_USE_I2C2                  FALSE\r
 #define STM32_I2C_BUSY_TIMEOUT              50\r
-#define STM32_I2C_I2C1_IRQ_PRIORITY         3\r
-#define STM32_I2C_I2C2_IRQ_PRIORITY         3\r
-#define STM32_I2C_USE_DMA                   TRUE\r
-#define STM32_I2C_I2C1_DMA_PRIORITY         1\r
-#define STM32_I2C_I2C2_DMA_PRIORITY         1\r
+#define STM32_I2C_I2C1_IRQ_PRIORITY         5\r
+#define STM32_I2C_I2C2_IRQ_PRIORITY         5\r
+#define STM32_I2C_I2C1_DMA_PRIORITY         3\r
+#define STM32_I2C_I2C2_DMA_PRIORITY         3\r
 #define STM32_I2C_DMA_ERROR_HOOK(i2cp)      osalSysHalt("DMA failure")\r
 \r
 /*\r
 #define STM32_ICU_USE_TIM1                  FALSE\r
 #define STM32_ICU_USE_TIM2                  FALSE\r
 #define STM32_ICU_USE_TIM3                  FALSE\r
-#define STM32_ICU_TIM1_IRQ_PRIORITY         3\r
-#define STM32_ICU_TIM2_IRQ_PRIORITY         3\r
-#define STM32_ICU_TIM3_IRQ_PRIORITY         3\r
+#define STM32_ICU_USE_TIM4                  FALSE\r
+#define STM32_ICU_USE_TIM5                  FALSE\r
+#define STM32_ICU_USE_TIM8                  FALSE\r
+#define STM32_ICU_TIM1_IRQ_PRIORITY         7\r
+#define STM32_ICU_TIM2_IRQ_PRIORITY         7\r
+#define STM32_ICU_TIM3_IRQ_PRIORITY         7\r
+#define STM32_ICU_TIM4_IRQ_PRIORITY         7\r
+#define STM32_ICU_TIM5_IRQ_PRIORITY         7\r
+#define STM32_ICU_TIM8_IRQ_PRIORITY         7\r
 \r
 /*\r
  * PWM driver system settings.\r
 #define STM32_PWM_USE_TIM1                  FALSE\r
 #define STM32_PWM_USE_TIM2                  FALSE\r
 #define STM32_PWM_USE_TIM3                  FALSE\r
-#define STM32_PWM_TIM1_IRQ_PRIORITY         3\r
-#define STM32_PWM_TIM2_IRQ_PRIORITY         3\r
-#define STM32_PWM_TIM3_IRQ_PRIORITY         3\r
+#define STM32_PWM_USE_TIM4                  FALSE\r
+#define STM32_PWM_USE_TIM5                  FALSE\r
+#define STM32_PWM_USE_TIM8                  FALSE\r
+#define STM32_PWM_TIM1_IRQ_PRIORITY         7\r
+#define STM32_PWM_TIM2_IRQ_PRIORITY         7\r
+#define STM32_PWM_TIM3_IRQ_PRIORITY         7\r
+#define STM32_PWM_TIM4_IRQ_PRIORITY         7\r
+#define STM32_PWM_TIM5_IRQ_PRIORITY         7\r
+#define STM32_PWM_TIM8_IRQ_PRIORITY         7\r
+\r
+/*\r
+ * RTC driver system settings.\r
+ */\r
+#define STM32_RTC_IRQ_PRIORITY              15\r
 \r
 /*\r
  * SERIAL driver system settings.\r
  */\r
 #define STM32_SERIAL_USE_USART1             FALSE\r
 #define STM32_SERIAL_USE_USART2             FALSE\r
-#define STM32_SERIAL_USART1_PRIORITY        3\r
-#define STM32_SERIAL_USART2_PRIORITY        3\r
+#define STM32_SERIAL_USE_USART3             FALSE\r
+#define STM32_SERIAL_USE_UART4              FALSE\r
+#define STM32_SERIAL_USE_UART5              FALSE\r
+#define STM32_SERIAL_USART1_PRIORITY        12\r
+#define STM32_SERIAL_USART2_PRIORITY        12\r
+#define STM32_SERIAL_USART3_PRIORITY        12\r
+#define STM32_SERIAL_UART4_PRIORITY         12\r
+#define STM32_SERIAL_UART5_PRIORITY         12\r
 \r
 /*\r
  * SPI driver system settings.\r
  */\r
 #define STM32_SPI_USE_SPI1                  FALSE\r
 #define STM32_SPI_USE_SPI2                  FALSE\r
+#define STM32_SPI_USE_SPI3                  FALSE\r
 #define STM32_SPI_SPI1_DMA_PRIORITY         1\r
 #define STM32_SPI_SPI2_DMA_PRIORITY         1\r
-#define STM32_SPI_SPI1_IRQ_PRIORITY         2\r
-#define STM32_SPI_SPI2_IRQ_PRIORITY         2\r
+#define STM32_SPI_SPI3_DMA_PRIORITY         1\r
+#define STM32_SPI_SPI1_IRQ_PRIORITY         10\r
+#define STM32_SPI_SPI2_IRQ_PRIORITY         10\r
+#define STM32_SPI_SPI3_IRQ_PRIORITY         10\r
 #define STM32_SPI_DMA_ERROR_HOOK(spip)      osalSysHalt("DMA failure")\r
 \r
 /*\r
  * ST driver system settings.\r
  */\r
-#define STM32_ST_IRQ_PRIORITY               2\r
+#define STM32_ST_IRQ_PRIORITY               8\r
 #define STM32_ST_USE_TIMER                  2\r
 \r
 /*\r
  */\r
 #define STM32_UART_USE_USART1               FALSE\r
 #define STM32_UART_USE_USART2               FALSE\r
-#define STM32_UART_USART1_IRQ_PRIORITY      3\r
-#define STM32_UART_USART2_IRQ_PRIORITY      3\r
+#define STM32_UART_USE_USART3               FALSE\r
+#define STM32_UART_USART1_IRQ_PRIORITY      12\r
+#define STM32_UART_USART2_IRQ_PRIORITY      12\r
+#define STM32_UART_USART3_IRQ_PRIORITY      12\r
 #define STM32_UART_USART1_DMA_PRIORITY      0\r
 #define STM32_UART_USART2_DMA_PRIORITY      0\r
+#define STM32_UART_USART3_DMA_PRIORITY      0\r
 #define STM32_UART_DMA_ERROR_HOOK(uartp)    osalSysHalt("DMA failure")\r
 \r
 /*\r
  */\r
 #define STM32_USB_USE_USB1                  TRUE\r
 #define STM32_USB_LOW_POWER_ON_SUSPEND      FALSE\r
-#define STM32_USB_USB1_LP_IRQ_PRIORITY      3\r
+#define STM32_USB_USB1_HP_IRQ_PRIORITY      13\r
+#define STM32_USB_USB1_LP_IRQ_PRIORITY      14\r
 \r
 #endif /* _MCUCONF_H_ */\r
index 1ce5b4aedaffb33aa5b7a555b8086d7764d0971f..85548fbb2750dd9ed9b8c7451baa32b8ebf4090e 100644 (file)
@@ -1036,11 +1036,11 @@ void send_remote_wakeup(USBDriver *usbp) {
   chThdSleepMilliseconds(15);
   USB0->CTL &= ~USBx_CTL_RESUME;
 #endif /* KINETIS_USB_USE_USB0 */
-#elif defined(STM32F0XX) /* K20x || KL2x */
+#elif defined(STM32F0XX) || defined(STM32F1XX) /* K20x || KL2x */
   STM32_USB->CNTR |= CNTR_RESUME;
   chThdSleepMilliseconds(15);
   STM32_USB->CNTR &= ~CNTR_RESUME;
-#else /* STM32F0XX */
+#else /* STM32F0XX || STM32F1XX */
 #warning Sending remote wakeup packet not implemented for your platform.
 #endif /* K20x || KL2x */
 }