From 43eda0c15529a16f9fd1a3ad62dc6f8177a8a095 Mon Sep 17 00:00:00 2001 From: Andrew Kannan Date: Wed, 7 Nov 2018 20:35:42 -0500 Subject: [PATCH 01/17] Starting point for blue pill based practice60 --- keyboards/practice60/bluepill/bluepill.c | 1 + keyboards/practice60/bluepill/bluepill.h | 4 + .../practice60/bluepill/bootloader_defs.h | 10 + keyboards/practice60/bluepill/chconf.h | 524 ++++++++++++++++++ keyboards/practice60/bluepill/config.h | 4 + keyboards/practice60/bluepill/flash.sh | 2 + keyboards/practice60/bluepill/halconf.h | 353 ++++++++++++ keyboards/practice60/bluepill/led.c | 29 + keyboards/practice60/bluepill/matrix.c | 209 +++++++ keyboards/practice60/bluepill/mcuconf.h | 209 +++++++ keyboards/practice60/bluepill/readme.md | 3 + keyboards/practice60/bluepill/rules.mk | 37 ++ .../boards/GENERIC_STM32_F103/board.c | 49 ++ .../boards/GENERIC_STM32_F103/board.h | 166 ++++++ .../boards/GENERIC_STM32_F103/board.mk | 5 + keyboards/practice60/config.h | 72 +++ keyboards/practice60/keymaps/default/keymap.c | 48 ++ .../ld/STM32F103x8_stm32duino_bootloader.ld | 88 +++ keyboards/practice60/practice60.c | 1 + keyboards/practice60/practice60.h | 18 + keyboards/practice60/readme.md | 3 + keyboards/practice60/rules.mk | 12 + 22 files changed, 1847 insertions(+) create mode 100644 keyboards/practice60/bluepill/bluepill.c create mode 100644 keyboards/practice60/bluepill/bluepill.h create mode 100644 keyboards/practice60/bluepill/bootloader_defs.h create mode 100644 keyboards/practice60/bluepill/chconf.h create mode 100644 keyboards/practice60/bluepill/config.h create mode 100755 keyboards/practice60/bluepill/flash.sh create mode 100644 keyboards/practice60/bluepill/halconf.h create mode 100644 keyboards/practice60/bluepill/led.c create mode 100644 keyboards/practice60/bluepill/matrix.c create mode 100644 keyboards/practice60/bluepill/mcuconf.h create mode 100644 keyboards/practice60/bluepill/readme.md create mode 100644 keyboards/practice60/bluepill/rules.mk create mode 100644 keyboards/practice60/boards/GENERIC_STM32_F103/board.c create mode 100644 keyboards/practice60/boards/GENERIC_STM32_F103/board.h create mode 100644 keyboards/practice60/boards/GENERIC_STM32_F103/board.mk create mode 100644 keyboards/practice60/config.h create mode 100644 keyboards/practice60/keymaps/default/keymap.c create mode 100644 keyboards/practice60/ld/STM32F103x8_stm32duino_bootloader.ld create mode 100644 keyboards/practice60/practice60.c create mode 100644 keyboards/practice60/practice60.h create mode 100644 keyboards/practice60/readme.md create mode 100644 keyboards/practice60/rules.mk diff --git a/keyboards/practice60/bluepill/bluepill.c b/keyboards/practice60/bluepill/bluepill.c new file mode 100644 index 000000000000..30effbc31dd2 --- /dev/null +++ b/keyboards/practice60/bluepill/bluepill.c @@ -0,0 +1 @@ +#include "bluepill.h" diff --git a/keyboards/practice60/bluepill/bluepill.h b/keyboards/practice60/bluepill/bluepill.h new file mode 100644 index 000000000000..b4a38590b0c1 --- /dev/null +++ b/keyboards/practice60/bluepill/bluepill.h @@ -0,0 +1,4 @@ +#pragma once + +#include "practice60.h" + diff --git a/keyboards/practice60/bluepill/bootloader_defs.h b/keyboards/practice60/bluepill/bootloader_defs.h new file mode 100644 index 000000000000..0f45203cb613 --- /dev/null +++ b/keyboards/practice60/bluepill/bootloader_defs.h @@ -0,0 +1,10 @@ +/* Address for jumping to bootloader on STM32 chips. */ +/* It is chip dependent, the correct number can be looked up here (page 175): + * http://www.st.com/web/en/resource/technical/document/application_note/CD00167594.pdf + * This also requires a patch to chibios: + * /tmk_core/tool/chibios/ch-bootloader-jump.patch + */ + +// STM32F103* does NOT have an USB bootloader in ROM (only serial), +// so setting anything here does not make much sense +// #define STM32_BOOTLOADER_ADDRESS 0x1FFFC800 diff --git a/keyboards/practice60/bluepill/chconf.h b/keyboards/practice60/bluepill/chconf.h new file mode 100644 index 000000000000..dfb1f9dfb9e6 --- /dev/null +++ b/keyboards/practice60/bluepill/chconf.h @@ -0,0 +1,524 @@ +/* + ChibiOS - Copyright (C) 2006..2015 Giovanni Di Sirio + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +/** + * @file templates/chconf.h + * @brief Configuration file template. + * @details A copy of this file must be placed in each project directory, it + * contains the application specific kernel settings. + * + * @addtogroup config + * @details Kernel related settings and hooks. + * @{ + */ + +#ifndef CHCONF_H +#define CHCONF_H + +#define _CHIBIOS_RT_CONF_ + +/*===========================================================================*/ +/** + * @name System timers settings + * @{ + */ +/*===========================================================================*/ + +/** + * @brief System time counter resolution. + * @note Allowed values are 16 or 32 bits. + */ +#define CH_CFG_ST_RESOLUTION 16 + +/** + * @brief System tick frequency. + * @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 2000 + +/** + * @brief Time delta constant for the tick-less mode. + * @note If this value is zero then the system uses the classic + * periodic tick. This value represents the minimum number + * of ticks that is safe to specify in a timeout directive. + * The value one is not valid, timeouts are rounded up to + * this value. + */ +#define CH_CFG_ST_TIMEDELTA 2 + +/** @} */ + +/*===========================================================================*/ +/** + * @name Kernel parameters and options + * @{ + */ +/*===========================================================================*/ + +/** + * @brief Round robin interval. + * @details This constant is the number of system ticks allowed for the + * threads before preemption occurs. Setting this value to zero + * disables the preemption for threads with equal priority and the + * round robin becomes cooperative. Note that higher priority + * threads can still preempt, the kernel is always preemptive. + * @note Disabling the round robin preemption makes the kernel more compact + * and generally faster. + * @note The round robin preemption is not supported in tickless mode and + * must be set to zero in that case. + */ +#define CH_CFG_TIME_QUANTUM 0 + +/** + * @brief Managed RAM size. + * @details Size of the RAM area to be managed by the OS. If set to zero + * then the whole available RAM is used. The core memory is made + * available to the heap allocator and/or can be used directly through + * the simplified core memory allocator. + * + * @note In order to let the OS manage the whole RAM the linker script must + * provide the @p __heap_base__ and @p __heap_end__ symbols. + * @note Requires @p CH_CFG_USE_MEMCORE. + */ +#define CH_CFG_MEMCORE_SIZE 0 + +/** + * @brief Idle thread automatic spawn suppression. + * @details When this option is activated the function @p chSysInit() + * does not spawn the idle thread. The application @p main() + * function becomes the idle thread and must implement an + * infinite loop. + */ +#define CH_CFG_NO_IDLE_THREAD FALSE + +/* Use __WFI in the idle thread for waiting. Does lower the power + * consumption. */ +#define CORTEX_ENABLE_WFI_IDLE TRUE + +/** @} */ + +/*===========================================================================*/ +/** + * @name Performance options + * @{ + */ +/*===========================================================================*/ + +/** + * @brief OS optimization. + * @details If enabled then time efficient rather than space efficient code + * is used when two possible implementations exist. + * + * @note This is not related to the compiler optimization options. + * @note The default is @p TRUE. + */ +#define CH_CFG_OPTIMIZE_SPEED TRUE + +/** @} */ + +/*===========================================================================*/ +/** + * @name Subsystem options + * @{ + */ +/*===========================================================================*/ + +/** + * @brief Time Measurement APIs. + * @details If enabled then the time measurement APIs are included in + * the kernel. + * + * @note The default is @p TRUE. + */ +#define CH_CFG_USE_TM FALSE + +/** + * @brief Threads registry APIs. + * @details If enabled then the registry APIs are included in the kernel. + * + * @note The default is @p TRUE. + */ +#define CH_CFG_USE_REGISTRY TRUE + +/** + * @brief Threads synchronization APIs. + * @details If enabled then the @p chThdWait() function is included in + * the kernel. + * + * @note The default is @p TRUE. + */ +#define CH_CFG_USE_WAITEXIT TRUE + +/** + * @brief Semaphores APIs. + * @details If enabled then the Semaphores APIs are included in the kernel. + * + * @note The default is @p TRUE. + */ +#define CH_CFG_USE_SEMAPHORES TRUE + +/** + * @brief Semaphores queuing mode. + * @details If enabled then the threads are enqueued on semaphores by + * priority rather than in FIFO order. + * + * @note The default is @p FALSE. Enable this if you have special + * requirements. + * @note Requires @p CH_CFG_USE_SEMAPHORES. + */ +#define CH_CFG_USE_SEMAPHORES_PRIORITY FALSE + +/** + * @brief Mutexes APIs. + * @details If enabled then the mutexes APIs are included in the kernel. + * + * @note The default is @p TRUE. + */ +#define CH_CFG_USE_MUTEXES TRUE + +/** + * @brief Enables recursive behavior on mutexes. + * @note Recursive mutexes are heavier and have an increased + * memory footprint. + * + * @note The default is @p FALSE. + * @note Requires @p CH_CFG_USE_MUTEXES. + */ +#define CH_CFG_USE_MUTEXES_RECURSIVE FALSE + +/** + * @brief Conditional Variables APIs. + * @details If enabled then the conditional variables APIs are included + * in the kernel. + * + * @note The default is @p TRUE. + * @note Requires @p CH_CFG_USE_MUTEXES. + */ +#define CH_CFG_USE_CONDVARS TRUE + +/** + * @brief Conditional Variables APIs with timeout. + * @details If enabled then the conditional variables APIs with timeout + * specification are included in the kernel. + * + * @note The default is @p TRUE. + * @note Requires @p CH_CFG_USE_CONDVARS. + */ +#define CH_CFG_USE_CONDVARS_TIMEOUT FALSE + +/** + * @brief Events Flags APIs. + * @details If enabled then the event flags APIs are included in the kernel. + * + * @note The default is @p TRUE. + */ +#define CH_CFG_USE_EVENTS TRUE + +/** + * @brief Events Flags APIs with timeout. + * @details If enabled then the events APIs with timeout specification + * are included in the kernel. + * + * @note The default is @p TRUE. + * @note Requires @p CH_CFG_USE_EVENTS. + */ +#define CH_CFG_USE_EVENTS_TIMEOUT TRUE + +/** + * @brief Synchronous Messages APIs. + * @details If enabled then the synchronous messages APIs are included + * in the kernel. + * + * @note The default is @p TRUE. + */ +#define CH_CFG_USE_MESSAGES TRUE + +/** + * @brief Synchronous Messages queuing mode. + * @details If enabled then messages are served by priority rather than in + * FIFO order. + * + * @note The default is @p FALSE. Enable this if you have special + * requirements. + * @note Requires @p CH_CFG_USE_MESSAGES. + */ +#define CH_CFG_USE_MESSAGES_PRIORITY FALSE + +/** + * @brief Mailboxes APIs. + * @details If enabled then the asynchronous messages (mailboxes) APIs are + * included in the kernel. + * + * @note The default is @p TRUE. + * @note Requires @p CH_CFG_USE_SEMAPHORES. + */ +#define CH_CFG_USE_MAILBOXES TRUE + +/** + * @brief Core Memory Manager APIs. + * @details If enabled then the core memory manager APIs are included + * in the kernel. + * + * @note The default is @p TRUE. + */ +#define CH_CFG_USE_MEMCORE TRUE + +/** + * @brief Heap Allocator APIs. + * @details If enabled then the memory heap allocator APIs are included + * in the kernel. + * + * @note The default is @p TRUE. + * @note Requires @p CH_CFG_USE_MEMCORE and either @p CH_CFG_USE_MUTEXES or + * @p CH_CFG_USE_SEMAPHORES. + * @note Mutexes are recommended. + */ +#define CH_CFG_USE_HEAP TRUE + +/** + * @brief Memory Pools Allocator APIs. + * @details If enabled then the memory pools allocator APIs are included + * in the kernel. + * + * @note The default is @p TRUE. + */ +#define CH_CFG_USE_MEMPOOLS FALSE + +/** + * @brief Dynamic Threads APIs. + * @details If enabled then the dynamic threads creation APIs are included + * in the kernel. + * + * @note The default is @p TRUE. + * @note Requires @p CH_CFG_USE_WAITEXIT. + * @note Requires @p CH_CFG_USE_HEAP and/or @p CH_CFG_USE_MEMPOOLS. + */ +#define CH_CFG_USE_DYNAMIC FALSE + +/** @} */ + +/*===========================================================================*/ +/** + * @name Debug options + * @{ + */ +/*===========================================================================*/ + +/** + * @brief Debug option, kernel statistics. + * + * @note The default is @p FALSE. + */ +#define CH_DBG_STATISTICS FALSE + +/** + * @brief Debug option, system state check. + * @details If enabled the correct call protocol for system APIs is checked + * at runtime. + * + * @note The default is @p FALSE. + */ +#define CH_DBG_SYSTEM_STATE_CHECK FALSE + +/** + * @brief Debug option, parameters checks. + * @details If enabled then the checks on the API functions input + * parameters are activated. + * + * @note The default is @p FALSE. + */ +#define CH_DBG_ENABLE_CHECKS FALSE + +/** + * @brief Debug option, consistency checks. + * @details If enabled then all the assertions in the kernel code are + * activated. This includes consistency checks inside the kernel, + * runtime anomalies and port-defined checks. + * + * @note The default is @p FALSE. + */ +#define CH_DBG_ENABLE_ASSERTS FALSE + +/** + * @brief Debug option, trace buffer. + * @details If enabled then the trace buffer is activated. + * + * @note The default is @p CH_DBG_TRACE_MASK_DISABLED. + */ +#define CH_DBG_TRACE_MASK CH_DBG_TRACE_MASK_DISABLED + +/** + * @brief Trace buffer entries. + * @note The trace buffer is only allocated if @p CH_DBG_TRACE_MASK is + * different from @p CH_DBG_TRACE_MASK_DISABLED. + */ +#define CH_DBG_TRACE_BUFFER_SIZE 128 + +/** + * @brief Debug option, stack checks. + * @details If enabled then a runtime stack check is performed. + * + * @note The default is @p FALSE. + * @note The stack check is performed in a architecture/port dependent way. + * It may not be implemented or some ports. + * @note The default failure mode is to halt the system with the global + * @p panic_msg variable set to @p NULL. + */ +#define CH_DBG_ENABLE_STACK_CHECK FALSE + +/** + * @brief Debug option, stacks initialization. + * @details If enabled then the threads working area is filled with a byte + * value when a thread is created. This can be useful for the + * runtime measurement of the used stack. + * + * @note The default is @p FALSE. + */ +#define CH_DBG_FILL_THREADS FALSE + +/** + * @brief Debug option, threads profiling. + * @details If enabled then a field is added to the @p thread_t structure that + * counts the system ticks occurred while executing the thread. + * + * @note The default is @p FALSE. + * @note This debug option is not currently compatible with the + * tickless mode. + */ +#define CH_DBG_THREADS_PROFILING FALSE + +/** @} */ + +/*===========================================================================*/ +/** + * @name Kernel hooks + * @{ + */ +/*===========================================================================*/ + +/** + * @brief Threads descriptor structure extension. + * @details User fields added to the end of the @p thread_t structure. + */ +#define CH_CFG_THREAD_EXTRA_FIELDS \ + /* Add threads custom fields here.*/ + +/** + * @brief Threads initialization hook. + * @details User initialization code added to the @p chThdInit() API. + * + * @note It is invoked from within @p chThdInit() and implicitly from all + * the threads creation APIs. + */ +#define CH_CFG_THREAD_INIT_HOOK(tp) { \ + /* Add threads initialization code here.*/ \ +} + +/** + * @brief Threads finalization hook. + * @details User finalization code added to the @p chThdExit() API. + */ +#define CH_CFG_THREAD_EXIT_HOOK(tp) { \ + /* Add threads finalization code here.*/ \ +} + +/** + * @brief Context switch hook. + * @details This hook is invoked just before switching between threads. + */ +#define CH_CFG_CONTEXT_SWITCH_HOOK(ntp, otp) { \ + /* Context switch code here.*/ \ +} + +/** + * @brief ISR enter hook. + */ +#define CH_CFG_IRQ_PROLOGUE_HOOK() { \ + /* IRQ prologue code here.*/ \ +} + +/** + * @brief ISR exit hook. + */ +#define CH_CFG_IRQ_EPILOGUE_HOOK() { \ + /* IRQ epilogue code here.*/ \ +} + +/** + * @brief Idle thread enter hook. + * @note This hook is invoked within a critical zone, no OS functions + * should be invoked from here. + * @note This macro can be used to activate a power saving mode. + */ +#define CH_CFG_IDLE_ENTER_HOOK() { \ + /* Idle-enter code here.*/ \ +} + +/** + * @brief Idle thread leave hook. + * @note This hook is invoked within a critical zone, no OS functions + * should be invoked from here. + * @note This macro can be used to deactivate a power saving mode. + */ +#define CH_CFG_IDLE_LEAVE_HOOK() { \ + /* Idle-leave code here.*/ \ +} + +/** + * @brief Idle Loop hook. + * @details This hook is continuously invoked by the idle thread loop. + */ +#define CH_CFG_IDLE_LOOP_HOOK() { \ + /* Idle loop code here.*/ \ +} + +/** + * @brief System tick event hook. + * @details This hook is invoked in the system tick handler immediately + * after processing the virtual timers queue. + */ +#define CH_CFG_SYSTEM_TICK_HOOK() { \ + /* System tick event code here.*/ \ +} + +/** + * @brief System halt hook. + * @details This hook is invoked in case to a system halting error before + * the system is halted. + */ +#define CH_CFG_SYSTEM_HALT_HOOK(reason) { \ + /* System halt code here.*/ \ +} + +/** + * @brief Trace hook. + * @details This hook is invoked each time a new record is written in the + * trace buffer. + */ +#define CH_CFG_TRACE_HOOK(tep) { \ + /* Trace code here.*/ \ +} + +/** @} */ + +/*===========================================================================*/ +/* Port-specific settings (override port settings defaulted in chcore.h). */ +/*===========================================================================*/ + +#endif /* CHCONF_H */ + +/** @} */ diff --git a/keyboards/practice60/bluepill/config.h b/keyboards/practice60/bluepill/config.h new file mode 100644 index 000000000000..5a3486be8da3 --- /dev/null +++ b/keyboards/practice60/bluepill/config.h @@ -0,0 +1,4 @@ +#pragma once + +#include "../config.h" + diff --git a/keyboards/practice60/bluepill/flash.sh b/keyboards/practice60/bluepill/flash.sh new file mode 100755 index 000000000000..15501dfa573d --- /dev/null +++ b/keyboards/practice60/bluepill/flash.sh @@ -0,0 +1,2 @@ +#!/bin/bash +Arduino_STM32_usb_hid/tools/linux/maple_upload ttyACM0 2 1EAF:0003 build/ch.bin diff --git a/keyboards/practice60/bluepill/halconf.h b/keyboards/practice60/bluepill/halconf.h new file mode 100644 index 000000000000..8b9724b1a30e --- /dev/null +++ b/keyboards/practice60/bluepill/halconf.h @@ -0,0 +1,353 @@ +/* + ChibiOS - Copyright (C) 2006..2015 Giovanni Di Sirio + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +/** + * @file templates/halconf.h + * @brief HAL configuration header. + * @details HAL configuration file, this file allows to enable or disable the + * various device drivers from your application. You may also use + * this file in order to override the device drivers default settings. + * + * @addtogroup HAL_CONF + * @{ + */ + +#ifndef _HALCONF_H_ +#define _HALCONF_H_ + +#include "mcuconf.h" + +/** + * @brief Enables the PAL subsystem. + */ +#if !defined(HAL_USE_PAL) || defined(__DOXYGEN__) +#define HAL_USE_PAL TRUE +#endif + +/** + * @brief Enables the ADC subsystem. + */ +#if !defined(HAL_USE_ADC) || defined(__DOXYGEN__) +#define HAL_USE_ADC FALSE +#endif + +/** + * @brief Enables the CAN subsystem. + */ +#if !defined(HAL_USE_CAN) || defined(__DOXYGEN__) +#define HAL_USE_CAN FALSE +#endif + +/** + * @brief Enables the DAC subsystem. + */ +#if !defined(HAL_USE_DAC) || defined(__DOXYGEN__) +#define HAL_USE_DAC FALSE +#endif + +/** + * @brief Enables the EXT subsystem. + */ +#if !defined(HAL_USE_EXT) || defined(__DOXYGEN__) +#define HAL_USE_EXT FALSE +#endif + +/** + * @brief Enables the GPT subsystem. + */ +#if !defined(HAL_USE_GPT) || defined(__DOXYGEN__) +#define HAL_USE_GPT FALSE +#endif + +/** + * @brief Enables the I2C subsystem. + */ +#if !defined(HAL_USE_I2C) || defined(__DOXYGEN__) +#define HAL_USE_I2C FALSE +#endif + +/** + * @brief Enables the I2S subsystem. + */ +#if !defined(HAL_USE_I2S) || defined(__DOXYGEN__) +#define HAL_USE_I2S FALSE +#endif + +/** + * @brief Enables the ICU subsystem. + */ +#if !defined(HAL_USE_ICU) || defined(__DOXYGEN__) +#define HAL_USE_ICU FALSE +#endif + +/** + * @brief Enables the MAC subsystem. + */ +#if !defined(HAL_USE_MAC) || defined(__DOXYGEN__) +#define HAL_USE_MAC FALSE +#endif + +/** + * @brief Enables the MMC_SPI subsystem. + */ +#if !defined(HAL_USE_MMC_SPI) || defined(__DOXYGEN__) +#define HAL_USE_MMC_SPI FALSE +#endif + +/** + * @brief Enables the PWM subsystem. + */ +#if !defined(HAL_USE_PWM) || defined(__DOXYGEN__) +#define HAL_USE_PWM FALSE +#endif + +/** + * @brief Enables the RTC subsystem. + */ +#if !defined(HAL_USE_RTC) || defined(__DOXYGEN__) +#define HAL_USE_RTC FALSE +#endif + +/** + * @brief Enables the SDC subsystem. + */ +#if !defined(HAL_USE_SDC) || defined(__DOXYGEN__) +#define HAL_USE_SDC FALSE +#endif + +/** + * @brief Enables the SERIAL subsystem. + */ +#if !defined(HAL_USE_SERIAL) || defined(__DOXYGEN__) +#define HAL_USE_SERIAL FALSE +#endif + +/** + * @brief Enables the SERIAL over USB subsystem. + */ +#if !defined(HAL_USE_SERIAL_USB) || defined(__DOXYGEN__) +#define HAL_USE_SERIAL_USB FALSE +#endif + +/** + * @brief Enables the SPI subsystem. + */ +#if !defined(HAL_USE_SPI) || defined(__DOXYGEN__) +#define HAL_USE_SPI FALSE +#endif + +/** + * @brief Enables the UART subsystem. + */ +#if !defined(HAL_USE_UART) || defined(__DOXYGEN__) +#define HAL_USE_UART FALSE +#endif + +/** + * @brief Enables the USB subsystem. + */ +#if !defined(HAL_USE_USB) || defined(__DOXYGEN__) +#define HAL_USE_USB TRUE +#endif + +/** + * @brief Enables the WDG subsystem. + */ +#if !defined(HAL_USE_WDG) || defined(__DOXYGEN__) +#define HAL_USE_WDG FALSE +#endif + +/*===========================================================================*/ +/* ADC driver related settings. */ +/*===========================================================================*/ + +/** + * @brief Enables synchronous APIs. + * @note Disabling this option saves both code and data space. + */ +#if !defined(ADC_USE_WAIT) || defined(__DOXYGEN__) +#define ADC_USE_WAIT TRUE +#endif + +/** + * @brief Enables the @p adcAcquireBus() and @p adcReleaseBus() APIs. + * @note Disabling this option saves both code and data space. + */ +#if !defined(ADC_USE_MUTUAL_EXCLUSION) || defined(__DOXYGEN__) +#define ADC_USE_MUTUAL_EXCLUSION TRUE +#endif + +/*===========================================================================*/ +/* CAN driver related settings. */ +/*===========================================================================*/ + +/** + * @brief Sleep mode related APIs inclusion switch. + */ +#if !defined(CAN_USE_SLEEP_MODE) || defined(__DOXYGEN__) +#define CAN_USE_SLEEP_MODE TRUE +#endif + +/*===========================================================================*/ +/* I2C driver related settings. */ +/*===========================================================================*/ + +/** + * @brief Enables the mutual exclusion APIs on the I2C bus. + */ +#if !defined(I2C_USE_MUTUAL_EXCLUSION) || defined(__DOXYGEN__) +#define I2C_USE_MUTUAL_EXCLUSION TRUE +#endif + +/*===========================================================================*/ +/* MAC driver related settings. */ +/*===========================================================================*/ + +/** + * @brief Enables an event sources for incoming packets. + */ +#if !defined(MAC_USE_ZERO_COPY) || defined(__DOXYGEN__) +#define MAC_USE_ZERO_COPY FALSE +#endif + +/** + * @brief Enables an event sources for incoming packets. + */ +#if !defined(MAC_USE_EVENTS) || defined(__DOXYGEN__) +#define MAC_USE_EVENTS TRUE +#endif + +/*===========================================================================*/ +/* MMC_SPI driver related settings. */ +/*===========================================================================*/ + +/** + * @brief Delays insertions. + * @details If enabled this options inserts delays into the MMC waiting + * routines releasing some extra CPU time for the threads with + * lower priority, this may slow down the driver a bit however. + * This option is recommended also if the SPI driver does not + * use a DMA channel and heavily loads the CPU. + */ +#if !defined(MMC_NICE_WAITING) || defined(__DOXYGEN__) +#define MMC_NICE_WAITING TRUE +#endif + +/*===========================================================================*/ +/* SDC driver related settings. */ +/*===========================================================================*/ + +/** + * @brief Number of initialization attempts before rejecting the card. + * @note Attempts are performed at 10mS intervals. + */ +#if !defined(SDC_INIT_RETRY) || defined(__DOXYGEN__) +#define SDC_INIT_RETRY 100 +#endif + +/** + * @brief Include support for MMC cards. + * @note MMC support is not yet implemented so this option must be kept + * at @p FALSE. + */ +#if !defined(SDC_MMC_SUPPORT) || defined(__DOXYGEN__) +#define SDC_MMC_SUPPORT FALSE +#endif + +/** + * @brief Delays insertions. + * @details If enabled this options inserts delays into the MMC waiting + * routines releasing some extra CPU time for the threads with + * lower priority, this may slow down the driver a bit however. + */ +#if !defined(SDC_NICE_WAITING) || defined(__DOXYGEN__) +#define SDC_NICE_WAITING TRUE +#endif + +/*===========================================================================*/ +/* SERIAL driver related settings. */ +/*===========================================================================*/ + +/** + * @brief Default bit rate. + * @details Configuration parameter, this is the baud rate selected for the + * default configuration. + */ +#if !defined(SERIAL_DEFAULT_BITRATE) || defined(__DOXYGEN__) +#define SERIAL_DEFAULT_BITRATE 38400 +#endif + +/** + * @brief Serial buffers size. + * @details Configuration parameter, you can change the depth of the queue + * buffers depending on the requirements of your application. + * @note The default is 64 bytes for both the transmission and receive + * buffers. + */ +#if !defined(SERIAL_BUFFERS_SIZE) || defined(__DOXYGEN__) +#define SERIAL_BUFFERS_SIZE 16 +#endif + +/*===========================================================================*/ +/* SERIAL_USB driver related setting. */ +/*===========================================================================*/ + +/** + * @brief Serial over USB buffers size. + * @details Configuration parameter, the buffer size must be a multiple of + * the USB data endpoint maximum packet size. + * @note The default is 64 bytes for both the transmission and receive + * buffers. + */ +#if !defined(SERIAL_USB_BUFFERS_SIZE) || defined(__DOXYGEN__) +#define SERIAL_USB_BUFFERS_SIZE 1 +#endif + +/*===========================================================================*/ +/* SPI driver related settings. */ +/*===========================================================================*/ + +/** + * @brief Enables synchronous APIs. + * @note Disabling this option saves both code and data space. + */ +#if !defined(SPI_USE_WAIT) || defined(__DOXYGEN__) +#define SPI_USE_WAIT TRUE +#endif + +/** + * @brief Enables the @p spiAcquireBus() and @p spiReleaseBus() APIs. + * @note Disabling this option saves both code and data space. + */ +#if !defined(SPI_USE_MUTUAL_EXCLUSION) || defined(__DOXYGEN__) +#define SPI_USE_MUTUAL_EXCLUSION TRUE +#endif + +/*===========================================================================*/ +/* USB driver related settings. */ +/*===========================================================================*/ + +/** + * @brief Enables synchronous APIs. + * @note Disabling this option saves both code and data space. + */ +#if !defined(USB_USE_WAIT) || defined(__DOXYGEN__) +#define USB_USE_WAIT TRUE +#endif + +#endif /* _HALCONF_H_ */ + +/** @} */ diff --git a/keyboards/practice60/bluepill/led.c b/keyboards/practice60/bluepill/led.c new file mode 100644 index 000000000000..3580ba58d079 --- /dev/null +++ b/keyboards/practice60/bluepill/led.c @@ -0,0 +1,29 @@ +/* +Copyright 2012 Jun Wako + +This program is free software: you can redistribute it and/or modify +it under the terms of the GNU General Public License as published by +the Free Software Foundation, either version 2 of the License, or +(at your option) any later version. + +This program is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU General Public License for more details. + +You should have received a copy of the GNU General Public License +along with this program. If not, see . +*/ + +#include "hal.h" +#include "led.h" + + +void led_set(uint8_t usb_led) +{ + if (usb_led & (1< + +This program is free software: you can redistribute it and/or modify +it under the terms of the GNU General Public License as published by +the Free Software Foundation, either version 2 of the License, or +(at your option) any later version. + +This program is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU General Public License for more details. + +You should have received a copy of the GNU General Public License +along with this program. If not, see . +*/ + +#include "ch.h" +#include "hal.h" + +/* + * scan matrix + */ +#include "print.h" +#include "debug.h" +#include "util.h" +#include "matrix.h" +#include "wait.h" + +#ifndef DEBOUNCE +# define DEBOUNCE 5 +#endif +static uint8_t debouncing = DEBOUNCE; + +/* matrix state(1:on, 0:off) */ +static matrix_row_t matrix[MATRIX_ROWS]; +static matrix_row_t matrix_debouncing[MATRIX_ROWS]; + +static matrix_row_t read_cols(void); +static void init_cols(void); +static void unselect_rows(void); +static void select_row(uint8_t row); + + +inline +uint8_t matrix_rows(void) +{ + return MATRIX_ROWS; +} + +inline +uint8_t matrix_cols(void) +{ + return MATRIX_COLS; +} + +/* generic STM32F103C8T6 board */ +#ifdef BOARD_GENERIC_STM32_F103 +#define LED_ON() do { palClearPad(GPIOA, GPIOA_LED) ;} while (0) +#define LED_OFF() do { palSetPad(GPIOA, GPIOA_LED); } while (0) +#define LED_TGL() do { palTogglePad(GPIOA, GPIOA_LED); } while (0) +#endif + + +void matrix_init(void) +{ + // initialize row and col + unselect_rows(); + init_cols(); + + // initialize matrix state: all keys off + for (uint8_t i=0; i < MATRIX_ROWS; i++) { + matrix[i] = 0; + matrix_debouncing[i] = 0; + } + + //debug + debug_matrix = true; + LED_ON(); + wait_ms(500); + LED_OFF(); +} + +uint8_t matrix_scan(void) +{ + for (uint8_t i = 0; i < MATRIX_ROWS; i++) { + select_row(i); + wait_us(30); // without this wait read unstable value. + matrix_row_t cols = read_cols(); + if (matrix_debouncing[i] != cols) { + matrix_debouncing[i] = cols; + if (debouncing) { + debug("bounce!: "); debug_hex(debouncing); debug("\n"); + } + debouncing = DEBOUNCE; + } + unselect_rows(); + } + + if (debouncing) { + if (--debouncing) { + wait_ms(1); + } else { + for (uint8_t i = 0; i < MATRIX_ROWS; i++) { + matrix[i] = matrix_debouncing[i]; + } + } + } + + return 1; +} + +inline +bool matrix_is_on(uint8_t row, uint8_t col) +{ + return (matrix[row] & ((matrix_row_t)1</os/hal/ports/$(MCU_FAMILY)/$(MCU_SERIES) +MCU_FAMILY = STM32 +MCU_SERIES = STM32F1xx +# linker script to use +# it should exist either in /os/common/ports/ARMCMx/compilers/GCC/ld/ +# or /ld/ +# startup code to use +# is should exist in /os/common/ports/ARMCMx/compilers/GCC/mk/ +MCU_STARTUP = stm32f1xx +# it should exist either in /os/hal/boards/ +# or /boards +# Cortex version +# Teensy LC is cortex-m0; Teensy 3.x are cortex-m4 +MCU = cortex-m3 +# ARM version, CORTEX-M0/M1 are 6, CORTEX-M3/M4/M7 are 7 +ARMV = 7 +# If you want to be able to jump to bootloader from firmware on STM32 MCUs, +# set the correct BOOTLOADER_ADDRESS. Either set it here, or define it in +# ./bootloader_defs.h or in ./boards//bootloader_defs.h (if you have +# a custom board definition that you plan to reuse). +# If you're not setting it here, leave it commented out. +# It is chip dependent, the correct number can be looked up here (page 175): +# http://www.st.com/web/en/resource/technical/document/application_note/CD00167594.pdf +# This also requires a patch to chibios: +# /tmk_core/tool/chibios/ch-bootloader-jump.patch +#STM32_BOOTLOADER_ADDRESS = 0x1FFFC800 \ No newline at end of file diff --git a/keyboards/practice60/boards/GENERIC_STM32_F103/board.c b/keyboards/practice60/boards/GENERIC_STM32_F103/board.c new file mode 100644 index 000000000000..2809c9d184ed --- /dev/null +++ b/keyboards/practice60/boards/GENERIC_STM32_F103/board.c @@ -0,0 +1,49 @@ +/* + ChibiOS - Copyright (C) 2006..2015 Giovanni Di Sirio + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#include "hal.h" + +/** + * @brief PAL setup. + * @details Digital I/O ports static configuration as defined in @p board.h. + * This variable is used by the HAL when initializing the PAL driver. + */ +#if HAL_USE_PAL || defined(__DOXYGEN__) +const PALConfig pal_default_config = +{ + {VAL_GPIOAODR, VAL_GPIOACRL, VAL_GPIOACRH}, + {VAL_GPIOBODR, VAL_GPIOBCRL, VAL_GPIOBCRH}, + {VAL_GPIOCODR, VAL_GPIOCCRL, VAL_GPIOCCRH}, + {VAL_GPIODODR, VAL_GPIODCRL, VAL_GPIODCRH}, + {VAL_GPIOEODR, VAL_GPIOECRL, VAL_GPIOECRH}, +}; +#endif + +/* + * Early initialization code. + * This initialization must be performed just after stack setup and before + * any other initialization. + */ +void __early_init(void) { + + stm32_clock_init(); +} + +/* + * Board-specific initialization code. + */ +void boardInit(void) { +} diff --git a/keyboards/practice60/boards/GENERIC_STM32_F103/board.h b/keyboards/practice60/boards/GENERIC_STM32_F103/board.h new file mode 100644 index 000000000000..adf81a25e196 --- /dev/null +++ b/keyboards/practice60/boards/GENERIC_STM32_F103/board.h @@ -0,0 +1,166 @@ +/* + ChibiOS - Copyright (C) 2006..2015 Giovanni Di Sirio + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#ifndef _BOARD_H_ +#define _BOARD_H_ + +/* + * Setup for a Generic STM32F103 board. + */ + +/* + * Board identifier. + */ +#define BOARD_GENERIC_STM32_F103 +#define BOARD_NAME "Practice60" + +/* + * Board frequencies. + */ +#define STM32_LSECLK 32768 +#define STM32_HSECLK 8000000 + +/* + * MCU type, supported types are defined in ./os/hal/platforms/hal_lld.h. + */ +#define STM32F103xB + +/* + * IO pins assignments + */ + +/* on-board */ + +#define GPIOA_LED 8 +#define GPIOD_OSC_IN 0 +#define GPIOD_OSC_OUT 1 + +/* In case your board has a "USB enable" hardware + controlled by a pin, define it here. (It could be just + a 1.5k resistor connected to D+ line.) +*/ +/* +#define GPIOB_USB_DISC 10 +*/ + +/* + * I/O ports initial setup, this configuration is established soon after reset + * in the initialization code. + * + * The digits have the following meaning: + * 0 - Analog input. + * 1 - Push Pull output 10MHz. + * 2 - Push Pull output 2MHz. + * 3 - Push Pull output 50MHz. + * 4 - Digital input. + * 5 - Open Drain output 10MHz. + * 6 - Open Drain output 2MHz. + * 7 - Open Drain output 50MHz. + * 8 - Digital input with PullUp or PullDown resistor depending on ODR. + * 9 - Alternate Push Pull output 10MHz. + * A - Alternate Push Pull output 2MHz. + * B - Alternate Push Pull output 50MHz. + * C - Reserved. + * D - Alternate Open Drain output 10MHz. + * E - Alternate Open Drain output 2MHz. + * F - Alternate Open Drain output 50MHz. + * Please refer to the STM32 Reference Manual for details. + */ + +/* + * Port A setup. + * Everything input with pull-up except: + * PA2 - Alternate output (USART2 TX). + * PA3 - Normal input (USART2 RX). + * PA9 - Alternate output (USART1 TX). + * PA10 - Normal input (USART1 RX). + */ +#define VAL_GPIOACRL 0x88884B88 /* PA7...PA0 */ +#define VAL_GPIOACRH 0x888884B8 /* PA15...PA8 */ +#define VAL_GPIOAODR 0xFFFFFFFF + +/* + * Port B setup. + * Everything input with pull-up except: + * PB10 - Push Pull output (USB switch). + */ +#define VAL_GPIOBCRL 0x88888888 /* PB7...PB0 */ +#define VAL_GPIOBCRH 0x88888388 /* PB15...PB8 */ +#define VAL_GPIOBODR 0xFFFFFFFF + +/* + * Port C setup. + * Everything input with pull-up except: + * PC13 - Push Pull output (LED). + */ +#define VAL_GPIOCCRL 0x88888888 /* PC7...PC0 */ +#define VAL_GPIOCCRH 0x88388888 /* PC15...PC8 */ +#define VAL_GPIOCODR 0xFFFFFFFF + +/* + * Port D setup. + * Everything input with pull-up except: + * PD0 - Normal input (XTAL). + * PD1 - Normal input (XTAL). + */ +#define VAL_GPIODCRL 0x88888844 /* PD7...PD0 */ +#define VAL_GPIODCRH 0x88888888 /* PD15...PD8 */ +#define VAL_GPIODODR 0xFFFFFFFF + +/* + * Port E setup. + * Everything input with pull-up except: + */ +#define VAL_GPIOECRL 0x88888888 /* PE7...PE0 */ +#define VAL_GPIOECRH 0x88888888 /* PE15...PE8 */ +#define VAL_GPIOEODR 0xFFFFFFFF + +/* + * USB bus activation macro, required by the USB driver. + */ +/* The point is that most of the generic STM32F103* boards + have a 1.5k resistor connected on one end to the D+ line + and on the other end to some pin. Or even a slightly more + complicated "USB enable" circuit, controlled by a pin. + That should go here. + + However on some boards (e.g. one that I have), there's no + such hardware. In which case it's better to not do anything. +*/ +/* +#define usb_lld_connect_bus(usbp) palClearPad(GPIOB, GPIOB_USB_DISC) +*/ +#define usb_lld_connect_bus(usbp) palSetPadMode(GPIOA, 12, PAL_MODE_INPUT); + +/* + * USB bus de-activation macro, required by the USB driver. + */ +/* +#define usb_lld_disconnect_bus(usbp) palSetPad(GPIOB, GPIOB_USB_DISC) +*/ +#define usb_lld_disconnect_bus(usbp) palSetPadMode(GPIOA, 12, PAL_MODE_OUTPUT_PUSHPULL); palClearPad(GPIOA, 12); + +#if !defined(_FROM_ASM_) +#ifdef __cplusplus +extern "C" { +#endif + void boardInit(void); +#ifdef __cplusplus +} +#endif +#endif /* _FROM_ASM_ */ + +#endif /* _BOARD_H_ */ diff --git a/keyboards/practice60/boards/GENERIC_STM32_F103/board.mk b/keyboards/practice60/boards/GENERIC_STM32_F103/board.mk new file mode 100644 index 000000000000..6b8b312fd9fd --- /dev/null +++ b/keyboards/practice60/boards/GENERIC_STM32_F103/board.mk @@ -0,0 +1,5 @@ +# List of all the board related files. +BOARDSRC = $(BOARD_PATH)/boards/GENERIC_STM32_F103/board.c + +# Required include directories +BOARDINC = $(BOARD_PATH)/boards/GENERIC_STM32_F103 diff --git a/keyboards/practice60/config.h b/keyboards/practice60/config.h new file mode 100644 index 000000000000..45b54902af86 --- /dev/null +++ b/keyboards/practice60/config.h @@ -0,0 +1,72 @@ +/* +Copyright 2015 Jun Wako + +This program is free software: you can redistribute it and/or modify +it under the terms of the GNU General Public License as published by +the Free Software Foundation, either version 2 of the License, or +(at your option) any later version. + +This program is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU General Public License for more details. + +You should have received a copy of the GNU General Public License +along with this program. If not, see . +*/ + +#ifndef CONFIG_H +#define CONFIG_H + +/* USB Device descriptor parameter */ +#define VENDOR_ID 0xFEED +#define PRODUCT_ID 0x6464 +#define DEVICE_VER 0x0001 +/* in python2: list(u"whatever".encode('utf-16-le')) */ +/* at most 32 characters or the ugly hack in usb_main.c borks */ +#define MANUFACTURER QMK +#define PRODUCT Practice 60 +#define DESCRIPTION Practice 60 keyboard powered by QMK for ChibiOS + +/* key matrix size */ +#define MATRIX_ROWS 5 +#define MATRIX_COLS 14 +#define DIODE_DIRECTION COL2ROW + +/* define if matrix has ghost */ +//#define MATRIX_HAS_GHOST + +/* Set 0 if debouncing isn't needed */ +#define DEBOUNCE 5 + +/* Mechanical locking support. Use KC_LCAP, KC_LNUM or KC_LSCR instead in keymap */ +#define LOCKING_SUPPORT_ENABLE +/* Locking resynchronize hack */ +#define LOCKING_RESYNC_ENABLE + +/* key combination for command */ +#define IS_COMMAND() ( \ + keyboard_report->mods == (MOD_BIT(KC_LSHIFT) | MOD_BIT(KC_RSHIFT)) \ +) + + + +/* + * Feature disable options + * These options are also useful to firmware size reduction. + */ + +/* disable debug print */ +//#define NO_DEBUG + +/* disable print */ +//#define NO_PRINT + +/* disable action features */ +//#define NO_ACTION_LAYER +//#define NO_ACTION_TAPPING +//#define NO_ACTION_ONESHOT +//#define NO_ACTION_MACRO +//#define NO_ACTION_FUNCTION + +#endif diff --git a/keyboards/practice60/keymaps/default/keymap.c b/keyboards/practice60/keymaps/default/keymap.c new file mode 100644 index 000000000000..e15cd223077b --- /dev/null +++ b/keyboards/practice60/keymaps/default/keymap.c @@ -0,0 +1,48 @@ +/* +Copyright 2012,2013 Jun Wako + +This program is free software: you can redistribute it and/or modify +it under the terms of the GNU General Public License as published by +the Free Software Foundation, either version 2 of the License, or +(at your option) any later version. + +This program is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU General Public License for more details. + +You should have received a copy of the GNU General Public License +along with this program. If not, see . +*/ +#include QMK_KEYBOARD_H + +extern keymap_config_t keymap_config; + +// Each layer gets a name for readability, which is then used in the keymap matrix below. +// The underscores don't mean anything - you can have a layer called STUFF or any other name. +// Layer names don't all need to be of the same length, obviously, and you can also skip them +// entirely and just use numbers. +#define _BASE 0 +#define _FN1 1 + +enum custom_keycodes { + QWERTY = SAFE_RANGE, +}; + +const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = { + [_BASE] = LAYOUT_60_ansi( + KC_GESC, KC_1, KC_2, KC_3, KC_4, KC_5, KC_6, KC_7, KC_8, KC_9, KC_0, KC_MINS, KC_EQL, KC_BSPC, \ + KC_TAB, KC_Q, KC_W, KC_E, KC_R, KC_T, KC_Y, KC_U, KC_I, KC_O, KC_P, KC_LBRC, KC_RBRC, KC_BSLS, \ + KC_CAPS, KC_A, KC_S, KC_D, KC_F, KC_G, KC_H, KC_J, KC_K, KC_L, KC_SCLN, KC_QUOT, KC_ENT, \ + KC_LSFT, KC_Z, KC_X, KC_C, KC_V, KC_B, KC_N, KC_M, KC_COMM, KC_DOT, KC_SLSH, KC_RSFT, \ + KC_LCTL , KC_LGUI , KC_LALT , KC_SPC , KC_RALT , KC_RGUI , MO(_FN1) , KC_RCTL + ), + + [_FN1] = LAYOUT_60_ansi( + KC_GESC, KC_F1, KC_F2, KC_F3, KC_F4, KC_F5, KC_F6, KC_F7, KC_F8, KC_F9, KC_F10, KC_F11, KC_F12, KC_BSPC, \ + RGB_TOG, RGB_MOD, KC_UP, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, \ + _______, KC_LEFT, KC_DOWN, KC_RGHT, _______, _______, _______, _______, _______, _______, _______, _______, _______,\ + BL_INC, BL_DEC, BL_TOGG, _______, _______, _______, _______, _______, _______, _______, _______, _______, \ + KC_GRV, _______, _______, _______, _______, _______, _______, _______ + ) +}; diff --git a/keyboards/practice60/ld/STM32F103x8_stm32duino_bootloader.ld b/keyboards/practice60/ld/STM32F103x8_stm32duino_bootloader.ld new file mode 100644 index 000000000000..f9bfe9c00527 --- /dev/null +++ b/keyboards/practice60/ld/STM32F103x8_stm32duino_bootloader.ld @@ -0,0 +1,88 @@ +/* + ChibiOS - Copyright (C) 2006..2016 Giovanni Di Sirio + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +/* + * ST32F103xB memory setup for use with the maplemini bootloader. + * You will have to + * #define CORTEX_VTOR_INIT 0x5000 + * in your projects chconf.h + */ +MEMORY +{ + flash0 : org = 0x08002000, len = 128k - 0x2000 + flash1 : org = 0x00000000, len = 0 + flash2 : org = 0x00000000, len = 0 + flash3 : org = 0x00000000, len = 0 + flash4 : org = 0x00000000, len = 0 + flash5 : org = 0x00000000, len = 0 + flash6 : org = 0x00000000, len = 0 + flash7 : org = 0x00000000, len = 0 + ram0 : org = 0x20000000, len = 20k + ram1 : org = 0x00000000, len = 0 + ram2 : org = 0x00000000, len = 0 + ram3 : org = 0x00000000, len = 0 + ram4 : org = 0x00000000, len = 0 + ram5 : org = 0x00000000, len = 0 + ram6 : org = 0x00000000, len = 0 + ram7 : org = 0x00000000, len = 0 +} + +/* For each data/text section two region are defined, a virtual region + and a load region (_LMA suffix).*/ + +/* Flash region to be used for exception vectors.*/ +REGION_ALIAS("VECTORS_FLASH", flash0); +REGION_ALIAS("VECTORS_FLASH_LMA", flash0); + +/* Flash region to be used for constructors and destructors.*/ +REGION_ALIAS("XTORS_FLASH", flash0); +REGION_ALIAS("XTORS_FLASH_LMA", flash0); + +/* Flash region to be used for code text.*/ +REGION_ALIAS("TEXT_FLASH", flash0); +REGION_ALIAS("TEXT_FLASH_LMA", flash0); + +/* Flash region to be used for read only data.*/ +REGION_ALIAS("RODATA_FLASH", flash0); +REGION_ALIAS("RODATA_FLASH_LMA", flash0); + +/* Flash region to be used for various.*/ +REGION_ALIAS("VARIOUS_FLASH", flash0); +REGION_ALIAS("VARIOUS_FLASH_LMA", flash0); + +/* Flash region to be used for RAM(n) initialization data.*/ +REGION_ALIAS("RAM_INIT_FLASH_LMA", flash0); + +/* RAM region to be used for Main stack. This stack accommodates the processing + of all exceptions and interrupts.*/ +REGION_ALIAS("MAIN_STACK_RAM", ram0); + +/* RAM region to be used for the process stack. This is the stack used by + the main() function.*/ +REGION_ALIAS("PROCESS_STACK_RAM", ram0); + +/* RAM region to be used for data segment.*/ +REGION_ALIAS("DATA_RAM", ram0); +REGION_ALIAS("DATA_RAM_LMA", flash0); + +/* RAM region to be used for BSS segment.*/ +REGION_ALIAS("BSS_RAM", ram0); + +/* RAM region to be used for the default heap.*/ +REGION_ALIAS("HEAP_RAM", ram0); + +/* Generic rules inclusion.*/ +INCLUDE rules.ld diff --git a/keyboards/practice60/practice60.c b/keyboards/practice60/practice60.c new file mode 100644 index 000000000000..d76d6c47a2f0 --- /dev/null +++ b/keyboards/practice60/practice60.c @@ -0,0 +1 @@ +#include "practice60.h" diff --git a/keyboards/practice60/practice60.h b/keyboards/practice60/practice60.h new file mode 100644 index 000000000000..d3235db67315 --- /dev/null +++ b/keyboards/practice60/practice60.h @@ -0,0 +1,18 @@ +#pragma once + +#include "quantum.h" + +#define LAYOUT_60_ansi( \ + K00, K01, K02, K03, K04, K05, K06, K07, K08, K09, K0A, K0B, K0C, K0D, \ + K10, K11, K12, K13, K14, K15, K16, K17, K18, K19, K1A, K1B, K1C, K1D, \ + K20, K21, K22, K23, K24, K25, K26, K27, K28, K29, K2A, K2B, K2C, \ + K30, K31, K32, K33, K34, K35, K36, K37, K38, K39, K3A, K3B, \ + K40, K41, K42, K43, K49, K4A, K4B, K4C \ +) { \ + { K00, K01, K02, K03, K04, K05, K06, K07, K08, K09, K0A, K0B, K0C, K0D }, \ + { K10, K11, K12, K13, K14, K15, K16, K17, K18, K19, K1A, K1B, K1C, K1D }, \ + { K20, K21, K22, K23, K24, K25, K26, K27, K28, K29, K2A, K2B, K2C }, \ + { K30, K31, K32, K33, K34, K35, K36, K37, K38, K39, K3A, K3B }, \ + { K40, K41, K42, K43, K49, K4A, K4B, K4C }, \ +} + diff --git a/keyboards/practice60/readme.md b/keyboards/practice60/readme.md new file mode 100644 index 000000000000..b23d7de6922a --- /dev/null +++ b/keyboards/practice60/readme.md @@ -0,0 +1,3 @@ +# Practice 60 + +Blue Pill STM32F103C8T6 based 60% board \ No newline at end of file diff --git a/keyboards/practice60/rules.mk b/keyboards/practice60/rules.mk new file mode 100644 index 000000000000..7f0f3d3ee3fa --- /dev/null +++ b/keyboards/practice60/rules.mk @@ -0,0 +1,12 @@ +#BOOTMAGIC_ENABLE = yes # Virtual DIP switch configuration +MOUSEKEY_ENABLE = yes # Mouse keys +EXTRAKEY_ENABLE = yes # Audio control and System control +CONSOLE_ENABLE = yes # Console for debug +COMMAND_ENABLE = yes # Commands for debug and configuration +SLEEP_LED_ENABLE = yes # Breathing sleep LED during USB suspend +NKRO_ENABLE = yes # USB Nkey Rollover +CUSTOM_MATRIX = yes # Custom matrix file + +LAYOUTS = 60_ansi + +DEFAULT_FOLDER = practice60/bluepill \ No newline at end of file From 05e5cf526fbdd8293a0a355d65b959b2d5441e7a Mon Sep 17 00:00:00 2001 From: Andrew Kannan Date: Wed, 7 Nov 2018 21:29:21 -0500 Subject: [PATCH 02/17] Changes --- keyboards/practice60/bluepill/flash.sh | 2 -- keyboards/practice60/bluepill/rules.mk | 6 +++++- keyboards/practice60/boards/GENERIC_STM32_F103/board.h | 2 +- keyboards/practice60/config.h | 2 +- 4 files changed, 7 insertions(+), 5 deletions(-) delete mode 100755 keyboards/practice60/bluepill/flash.sh diff --git a/keyboards/practice60/bluepill/flash.sh b/keyboards/practice60/bluepill/flash.sh deleted file mode 100755 index 15501dfa573d..000000000000 --- a/keyboards/practice60/bluepill/flash.sh +++ /dev/null @@ -1,2 +0,0 @@ -#!/bin/bash -Arduino_STM32_usb_hid/tools/linux/maple_upload ttyACM0 2 1EAF:0003 build/ch.bin diff --git a/keyboards/practice60/bluepill/rules.mk b/keyboards/practice60/bluepill/rules.mk index a1f69b49acd2..3a9e47c9e245 100644 --- a/keyboards/practice60/bluepill/rules.mk +++ b/keyboards/practice60/bluepill/rules.mk @@ -7,6 +7,10 @@ OPT_DEFS = -DCORTEX_VTOR_INIT=0x2000 MCU_LDSCRIPT = STM32F103x8_stm32duino_bootloader BOARD = GENERIC_STM32_F103 +# OPT_DEFS = +# MCU_LDSCRIPT = STM32F103x8 +# BOARD = GENERIC_STM32_F103 + ## chip/board settings # the next two should match the directories in # /os/hal/ports/$(MCU_FAMILY)/$(MCU_SERIES) @@ -34,4 +38,4 @@ ARMV = 7 # http://www.st.com/web/en/resource/technical/document/application_note/CD00167594.pdf # This also requires a patch to chibios: # /tmk_core/tool/chibios/ch-bootloader-jump.patch -#STM32_BOOTLOADER_ADDRESS = 0x1FFFC800 \ No newline at end of file +#STM32_BOOTLOADER_ADDRESS = 0x1FFFC800 diff --git a/keyboards/practice60/boards/GENERIC_STM32_F103/board.h b/keyboards/practice60/boards/GENERIC_STM32_F103/board.h index adf81a25e196..9427adabf11d 100644 --- a/keyboards/practice60/boards/GENERIC_STM32_F103/board.h +++ b/keyboards/practice60/boards/GENERIC_STM32_F103/board.h @@ -25,7 +25,7 @@ * Board identifier. */ #define BOARD_GENERIC_STM32_F103 -#define BOARD_NAME "Practice60" +#define BOARD_NAME "Generic STM32F103x board" /* * Board frequencies. diff --git a/keyboards/practice60/config.h b/keyboards/practice60/config.h index 45b54902af86..03df31d760e4 100644 --- a/keyboards/practice60/config.h +++ b/keyboards/practice60/config.h @@ -26,7 +26,7 @@ along with this program. If not, see . /* at most 32 characters or the ugly hack in usb_main.c borks */ #define MANUFACTURER QMK #define PRODUCT Practice 60 -#define DESCRIPTION Practice 60 keyboard powered by QMK for ChibiOS +#define DESCRIPTION Practice 60 /* key matrix size */ #define MATRIX_ROWS 5 From 3b75a4b025ceb5348a2574e4143fe0c3514a9626 Mon Sep 17 00:00:00 2001 From: Andrew Kannan Date: Wed, 7 Nov 2018 21:29:48 -0500 Subject: [PATCH 03/17] add --- keyboards/practice60/ld/MKL26Z64.ld | 105 ++++++++++++++++++++++++++++ 1 file changed, 105 insertions(+) create mode 100644 keyboards/practice60/ld/MKL26Z64.ld diff --git a/keyboards/practice60/ld/MKL26Z64.ld b/keyboards/practice60/ld/MKL26Z64.ld new file mode 100644 index 000000000000..c4ca8b874cca --- /dev/null +++ b/keyboards/practice60/ld/MKL26Z64.ld @@ -0,0 +1,105 @@ +/* + * Copyright (C) 2013-2016 Fabio Utzig, http://fabioutzig.com + * (C) 2016 flabbergast + * + * Permission is hereby granted, free of charge, to any person obtaining + * a copy of this software and associated documentation files (the "Software"), + * to deal in the Software without restriction, including without limitation + * the rights to use, copy, modify, merge, publish, distribute, sublicense, + * and/or sell copies of the Software, and to permit persons to whom the + * Software is furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS + * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ + +/* + * KL26Z64 memory setup. + */ +MEMORY +{ + flash0 : org = 0x00000000, len = 0x100 + flash1 : org = 0x00000400, len = 0x10 + flash2 : org = 0x00000410, len = 62k - 0x410 + flash3 : org = 0x0000F800, len = 2k + flash4 : org = 0x00000000, len = 0 + flash5 : org = 0x00000000, len = 0 + flash6 : org = 0x00000000, len = 0 + flash7 : org = 0x00000000, len = 0 + ram0 : org = 0x1FFFF800, len = 8k + ram1 : org = 0x00000000, len = 0 + ram2 : org = 0x00000000, len = 0 + ram3 : org = 0x00000000, len = 0 + ram4 : org = 0x00000000, len = 0 + ram5 : org = 0x00000000, len = 0 + ram6 : org = 0x00000000, len = 0 + ram7 : org = 0x00000000, len = 0 +} + +/* Flash region for the configuration bytes.*/ +SECTIONS +{ + .cfmprotect : ALIGN(4) SUBALIGN(4) + { + KEEP(*(.cfmconfig)) + } > flash1 +} + +/* For each data/text section two region are defined, a virtual region + and a load region (_LMA suffix).*/ + +/* Flash region to be used for exception vectors.*/ +REGION_ALIAS("VECTORS_FLASH", flash0); +REGION_ALIAS("VECTORS_FLASH_LMA", flash0); + +/* Flash region to be used for constructors and destructors.*/ +REGION_ALIAS("XTORS_FLASH", flash2); +REGION_ALIAS("XTORS_FLASH_LMA", flash2); + +/* Flash region to be used for code text.*/ +REGION_ALIAS("TEXT_FLASH", flash2); +REGION_ALIAS("TEXT_FLASH_LMA", flash2); + +/* Flash region to be used for read only data.*/ +REGION_ALIAS("RODATA_FLASH", flash2); +REGION_ALIAS("RODATA_FLASH_LMA", flash2); + +/* Flash region to be used for various.*/ +REGION_ALIAS("VARIOUS_FLASH", flash2); +REGION_ALIAS("VARIOUS_FLASH_LMA", flash2); + +/* Flash region to be used for RAM(n) initialization data.*/ +REGION_ALIAS("RAM_INIT_FLASH_LMA", flash2); + +/* RAM region to be used for Main stack. This stack accommodates the processing + of all exceptions and interrupts.*/ +REGION_ALIAS("MAIN_STACK_RAM", ram0); + +/* RAM region to be used for the process stack. This is the stack used by + the main() function.*/ +REGION_ALIAS("PROCESS_STACK_RAM", ram0); + +/* RAM region to be used for data segment.*/ +REGION_ALIAS("DATA_RAM", ram0); +REGION_ALIAS("DATA_RAM_LMA", flash2); + +/* RAM region to be used for BSS segment.*/ +REGION_ALIAS("BSS_RAM", ram0); + +/* RAM region to be used for the default heap.*/ +REGION_ALIAS("HEAP_RAM", ram0); + +__eeprom_workarea_start__ = ORIGIN(flash3); +__eeprom_workarea_size__ = LENGTH(flash3); +__eeprom_workarea_end__ = __eeprom_workarea_start__ + __eeprom_workarea_size__; + +/* Generic rules inclusion.*/ +INCLUDE rules.ld From 5ee30cc24c9ecf15073999cfe6aabcd73ba9faa2 Mon Sep 17 00:00:00 2001 From: Andrew Kannan Date: Wed, 7 Nov 2018 22:56:27 -0500 Subject: [PATCH 04/17] try raw bin no botloader --- .../ld/STM32F103x8_stm32duino_bootloader.ld | 2 +- keyboards/chibios_test/rules.mk | 2 +- keyboards/chibios_test/stm32_f103_onekey/matrix.c | 6 +++--- keyboards/chibios_test/stm32_f103_onekey/rules.mk | 12 ++++++------ keyboards/practice60/bluepill/rules.mk | 12 ++++++------ .../ld/STM32F103x8_stm32duino_bootloader.ld | 2 +- 6 files changed, 18 insertions(+), 18 deletions(-) diff --git a/keyboards/chibios_test/ld/STM32F103x8_stm32duino_bootloader.ld b/keyboards/chibios_test/ld/STM32F103x8_stm32duino_bootloader.ld index f9bfe9c00527..d0688ef60164 100644 --- a/keyboards/chibios_test/ld/STM32F103x8_stm32duino_bootloader.ld +++ b/keyboards/chibios_test/ld/STM32F103x8_stm32duino_bootloader.ld @@ -22,7 +22,7 @@ */ MEMORY { - flash0 : org = 0x08002000, len = 128k - 0x2000 + flash0 : org = 0x08002000, len = 64k - 0x2000 flash1 : org = 0x00000000, len = 0 flash2 : org = 0x00000000, len = 0 flash3 : org = 0x00000000, len = 0 diff --git a/keyboards/chibios_test/rules.mk b/keyboards/chibios_test/rules.mk index 45f03be02080..2826ba2aa03e 100644 --- a/keyboards/chibios_test/rules.mk +++ b/keyboards/chibios_test/rules.mk @@ -7,4 +7,4 @@ SLEEP_LED_ENABLE = yes # Breathing sleep LED during USB suspend NKRO_ENABLE = yes # USB Nkey Rollover CUSTOM_MATRIX = yes # Custom matrix file -DEFAULT_FOLDER = chibios_test/stm32_f072_onekey \ No newline at end of file +DEFAULT_FOLDER = chibios_test/stm32_f103_onekey \ No newline at end of file diff --git a/keyboards/chibios_test/stm32_f103_onekey/matrix.c b/keyboards/chibios_test/stm32_f103_onekey/matrix.c index ea9d8d057b1c..577fa6eeb3b4 100644 --- a/keyboards/chibios_test/stm32_f103_onekey/matrix.c +++ b/keyboards/chibios_test/stm32_f103_onekey/matrix.c @@ -144,16 +144,16 @@ 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); + palSetPadMode(GPIOB, 10, PAL_MODE_INPUT); #else - palSetPadMode(GPIOB, 8, PAL_MODE_INPUT_PULLDOWN); + palSetPadMode(GPIOB, 10, PAL_MODE_INPUT_PULLDOWN); #endif } /* Returns status of switches(1:on, 0:off) */ static matrix_row_t read_cols(void) { - return ((palReadPad(GPIOB, 8)==PAL_LOW) ? 0 : (1<<0)); + return ((palReadPad(GPIOB, 10)==PAL_LOW) ? 0 : (1<<0)); // | ((palReadPad(...)==PAL_HIGH) ? 0 : (1<<1)) } diff --git a/keyboards/chibios_test/stm32_f103_onekey/rules.mk b/keyboards/chibios_test/stm32_f103_onekey/rules.mk index c75738338ab4..c8a77f902d95 100644 --- a/keyboards/chibios_test/stm32_f103_onekey/rules.mk +++ b/keyboards/chibios_test/stm32_f103_onekey/rules.mk @@ -3,14 +3,14 @@ SRC = matrix.c \ led.c # GENERIC STM32F103C8T6 board - stm32duino bootloader -OPT_DEFS = -DCORTEX_VTOR_INIT=0x2000 -MCU_LDSCRIPT = STM32F103x8_stm32duino_bootloader -BOARD = GENERIC_STM32_F103 +# OPT_DEFS = -DCORTEX_VTOR_INIT=0x2000 +# MCU_LDSCRIPT = STM32F103x8_stm32duino_bootloader +# 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 diff --git a/keyboards/practice60/bluepill/rules.mk b/keyboards/practice60/bluepill/rules.mk index 3a9e47c9e245..46910c6b3c7a 100644 --- a/keyboards/practice60/bluepill/rules.mk +++ b/keyboards/practice60/bluepill/rules.mk @@ -3,14 +3,14 @@ SRC = matrix.c \ led.c # GENERIC STM32F103C8T6 board - stm32duino bootloader -OPT_DEFS = -DCORTEX_VTOR_INIT=0x2000 -MCU_LDSCRIPT = STM32F103x8_stm32duino_bootloader -BOARD = GENERIC_STM32_F103 - -# OPT_DEFS = -# MCU_LDSCRIPT = STM32F103x8 +# OPT_DEFS = -DCORTEX_VTOR_INIT=0x2000 +# MCU_LDSCRIPT = STM32F103x8_stm32duino_bootloader # BOARD = GENERIC_STM32_F103 +OPT_DEFS = +MCU_LDSCRIPT = STM32F103x8 +BOARD = GENERIC_STM32_F103 + ## chip/board settings # the next two should match the directories in # /os/hal/ports/$(MCU_FAMILY)/$(MCU_SERIES) diff --git a/keyboards/practice60/ld/STM32F103x8_stm32duino_bootloader.ld b/keyboards/practice60/ld/STM32F103x8_stm32duino_bootloader.ld index f9bfe9c00527..d0688ef60164 100644 --- a/keyboards/practice60/ld/STM32F103x8_stm32duino_bootloader.ld +++ b/keyboards/practice60/ld/STM32F103x8_stm32duino_bootloader.ld @@ -22,7 +22,7 @@ */ MEMORY { - flash0 : org = 0x08002000, len = 128k - 0x2000 + flash0 : org = 0x08002000, len = 64k - 0x2000 flash1 : org = 0x00000000, len = 0 flash2 : org = 0x00000000, len = 0 flash3 : org = 0x00000000, len = 0 From e53ac8527176004cd493752a89b3edccb2c80731 Mon Sep 17 00:00:00 2001 From: Andrew Kannan Date: Wed, 7 Nov 2018 23:02:20 -0500 Subject: [PATCH 05/17] swap back to bootloader version --- keyboards/practice60/bluepill/rules.mk | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/keyboards/practice60/bluepill/rules.mk b/keyboards/practice60/bluepill/rules.mk index 46910c6b3c7a..3a9e47c9e245 100644 --- a/keyboards/practice60/bluepill/rules.mk +++ b/keyboards/practice60/bluepill/rules.mk @@ -3,14 +3,14 @@ SRC = matrix.c \ led.c # GENERIC STM32F103C8T6 board - stm32duino bootloader -# OPT_DEFS = -DCORTEX_VTOR_INIT=0x2000 -# MCU_LDSCRIPT = STM32F103x8_stm32duino_bootloader -# BOARD = GENERIC_STM32_F103 - -OPT_DEFS = -MCU_LDSCRIPT = STM32F103x8 +OPT_DEFS = -DCORTEX_VTOR_INIT=0x2000 +MCU_LDSCRIPT = STM32F103x8_stm32duino_bootloader BOARD = GENERIC_STM32_F103 +# OPT_DEFS = +# MCU_LDSCRIPT = STM32F103x8 +# BOARD = GENERIC_STM32_F103 + ## chip/board settings # the next two should match the directories in # /os/hal/ports/$(MCU_FAMILY)/$(MCU_SERIES) From f596e24ec60b423ce338065c008f8a703906f264 Mon Sep 17 00:00:00 2001 From: Andrew Kannan Date: Wed, 7 Nov 2018 23:26:20 -0500 Subject: [PATCH 06/17] edit --- keyboards/practice60/bluepill/matrix.c | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/keyboards/practice60/bluepill/matrix.c b/keyboards/practice60/bluepill/matrix.c index a549e1efc035..7a106164dc4c 100644 --- a/keyboards/practice60/bluepill/matrix.c +++ b/keyboards/practice60/bluepill/matrix.c @@ -56,9 +56,9 @@ uint8_t matrix_cols(void) /* generic STM32F103C8T6 board */ #ifdef BOARD_GENERIC_STM32_F103 -#define LED_ON() do { palClearPad(GPIOA, GPIOA_LED) ;} while (0) -#define LED_OFF() do { palSetPad(GPIOA, GPIOA_LED); } while (0) -#define LED_TGL() do { palTogglePad(GPIOA, GPIOA_LED); } while (0) +#define LED_ON() do { palClearPad(GPIOC, 13) ;} while (0) +#define LED_OFF() do { palSetPad(GPIOC, 13); } while (0) +#define LED_TGL() do { palTogglePad(GPIOC, 13); } while (0) #endif @@ -107,6 +107,11 @@ uint8_t matrix_scan(void) } } + palSetPad(GPIOC, 13); + chThdSleepMilliseconds(1000); + palClearPad(GPIOC, 13); + chThdSleepMilliseconds(1000); + return 1; } From c317ebd569675ccea524786435c6ce04c02b09b4 Mon Sep 17 00:00:00 2001 From: Andrew Kannan Date: Thu, 8 Nov 2018 21:39:40 -0500 Subject: [PATCH 07/17] Remove debug LED flash --- keyboards/practice60/bluepill/matrix.c | 5 ----- 1 file changed, 5 deletions(-) diff --git a/keyboards/practice60/bluepill/matrix.c b/keyboards/practice60/bluepill/matrix.c index 7a106164dc4c..3880b024d3a6 100644 --- a/keyboards/practice60/bluepill/matrix.c +++ b/keyboards/practice60/bluepill/matrix.c @@ -107,11 +107,6 @@ uint8_t matrix_scan(void) } } - palSetPad(GPIOC, 13); - chThdSleepMilliseconds(1000); - palClearPad(GPIOC, 13); - chThdSleepMilliseconds(1000); - return 1; } From 943c698b395a645d459069818adf3b8f6f575005 Mon Sep 17 00:00:00 2001 From: Andrew Kannan Date: Thu, 8 Nov 2018 23:54:15 -0500 Subject: [PATCH 08/17] Disable JTAG to open up B3 and B4 --- keyboards/practice60/bluepill/matrix.c | 21 ++++++++++++++++++- .../boards/GENERIC_STM32_F103/board.c | 2 ++ 2 files changed, 22 insertions(+), 1 deletion(-) diff --git a/keyboards/practice60/bluepill/matrix.c b/keyboards/practice60/bluepill/matrix.c index 3880b024d3a6..3aa6bf5dd2b6 100644 --- a/keyboards/practice60/bluepill/matrix.c +++ b/keyboards/practice60/bluepill/matrix.c @@ -61,6 +61,23 @@ uint8_t matrix_cols(void) #define LED_TGL() do { palTogglePad(GPIOC, 13); } while (0) #endif +__attribute__ ((weak)) +void matrix_init_kb(void) { + matrix_init_user(); +} + +__attribute__ ((weak)) +void matrix_scan_kb(void) { + matrix_scan_user(); +} + +__attribute__ ((weak)) +void matrix_init_user(void) { +} + +__attribute__ ((weak)) +void matrix_scan_user(void) { +} void matrix_init(void) { @@ -79,6 +96,8 @@ void matrix_init(void) LED_ON(); wait_ms(500); LED_OFF(); + + matrix_init_quantum(); } uint8_t matrix_scan(void) @@ -175,7 +194,7 @@ static matrix_row_t read_cols(void) */ static void unselect_rows(void) { -palSetPadMode(GPIOB, 3, PAL_MODE_INPUT); + palSetPadMode(GPIOB, 3, PAL_MODE_INPUT); palSetPadMode(GPIOB, 4, PAL_MODE_INPUT); palSetPadMode(GPIOB, 5, PAL_MODE_INPUT); palSetPadMode(GPIOB, 6, PAL_MODE_INPUT); diff --git a/keyboards/practice60/boards/GENERIC_STM32_F103/board.c b/keyboards/practice60/boards/GENERIC_STM32_F103/board.c index 2809c9d184ed..33f69c19a030 100644 --- a/keyboards/practice60/boards/GENERIC_STM32_F103/board.c +++ b/keyboards/practice60/boards/GENERIC_STM32_F103/board.c @@ -46,4 +46,6 @@ void __early_init(void) { * Board-specific initialization code. */ void boardInit(void) { + //JTAG-DP Disabled and SW-DP Enabled + AFIO->MAPR |= AFIO_MAPR_SWJ_CFG_JTAGDISABLE; } From 47a4318c97e6e6506d185c25cec9d33832cfe1a8 Mon Sep 17 00:00:00 2001 From: Andrew Kannan Date: Fri, 9 Nov 2018 00:41:20 -0500 Subject: [PATCH 09/17] Add led backlight support (no breathing yet) --- keyboards/practice60/bluepill/led.c | 22 ++++++++++++++++++++++ keyboards/practice60/bluepill/matrix.c | 2 ++ keyboards/practice60/config.h | 2 ++ keyboards/practice60/rules.mk | 1 + 4 files changed, 27 insertions(+) diff --git a/keyboards/practice60/bluepill/led.c b/keyboards/practice60/bluepill/led.c index 3580ba58d079..f15baed169d4 100644 --- a/keyboards/practice60/bluepill/led.c +++ b/keyboards/practice60/bluepill/led.c @@ -16,8 +16,30 @@ along with this program. If not, see . */ #include "hal.h" +#include "backlight.h" #include "led.h" +#include "printf.h" +void backlight_init_ports(void) { + printf("backlight_init_ports()\n"); + #ifdef BACKLIGHT_ENABLE + palSetPadMode(GPIOA, 8, PAL_MODE_OUTPUT_PUSHPULL); + palSetPad(GPIOA, 8); + #endif +} + +void backlight_set(uint8_t level) { + printf("backlight_set(%d)\n", level); + #ifdef BACKLIGHT_ENABLE + if (level == 0) { + // Turn backlight off + palSetPad(GPIOA, 8); + } else { + // Turn backlight on + palClearPad(GPIOA, 8); + } + #endif +} void led_set(uint8_t usb_led) { diff --git a/keyboards/practice60/bluepill/matrix.c b/keyboards/practice60/bluepill/matrix.c index 3aa6bf5dd2b6..3aec4e6dfd62 100644 --- a/keyboards/practice60/bluepill/matrix.c +++ b/keyboards/practice60/bluepill/matrix.c @@ -94,7 +94,9 @@ void matrix_init(void) //debug debug_matrix = true; LED_ON(); + palSetPad(GPIOA, 8); wait_ms(500); + palClearPad(GPIOA, 8); LED_OFF(); matrix_init_quantum(); diff --git a/keyboards/practice60/config.h b/keyboards/practice60/config.h index 03df31d760e4..46e421effe1e 100644 --- a/keyboards/practice60/config.h +++ b/keyboards/practice60/config.h @@ -33,6 +33,8 @@ along with this program. If not, see . #define MATRIX_COLS 14 #define DIODE_DIRECTION COL2ROW +#define BACKLIGHT_LEVELS 1 + /* define if matrix has ghost */ //#define MATRIX_HAS_GHOST diff --git a/keyboards/practice60/rules.mk b/keyboards/practice60/rules.mk index 7f0f3d3ee3fa..9ab1f8eaefdd 100644 --- a/keyboards/practice60/rules.mk +++ b/keyboards/practice60/rules.mk @@ -6,6 +6,7 @@ COMMAND_ENABLE = yes # Commands for debug and configuration SLEEP_LED_ENABLE = yes # Breathing sleep LED during USB suspend NKRO_ENABLE = yes # USB Nkey Rollover CUSTOM_MATRIX = yes # Custom matrix file +BACKLIGHT_ENABLE = yes LAYOUTS = 60_ansi From c167917b390b43fca1d41bc6dd375e09ff6bd2a0 Mon Sep 17 00:00:00 2001 From: Andrew Kannan Date: Fri, 9 Nov 2018 00:52:20 -0500 Subject: [PATCH 10/17] Update matrix for correctness --- keyboards/practice60/practice60.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/keyboards/practice60/practice60.h b/keyboards/practice60/practice60.h index d3235db67315..ffcf5061439c 100644 --- a/keyboards/practice60/practice60.h +++ b/keyboards/practice60/practice60.h @@ -13,6 +13,6 @@ { K10, K11, K12, K13, K14, K15, K16, K17, K18, K19, K1A, K1B, K1C, K1D }, \ { K20, K21, K22, K23, K24, K25, K26, K27, K28, K29, K2A, K2B, K2C }, \ { K30, K31, K32, K33, K34, K35, K36, K37, K38, K39, K3A, K3B }, \ - { K40, K41, K42, K43, K49, K4A, K4B, K4C }, \ + { K40, K41, K42, K43, KC_NO, KC_NO, KC_NO, KC_NO, KC_NO, K49, K4A, K4B, K4C }, \ } From ad3e0c7521948ee07c7f8bf7ece552d196271e76 Mon Sep 17 00:00:00 2001 From: Andrew Kannan Date: Sat, 10 Nov 2018 09:09:07 -0500 Subject: [PATCH 11/17] RGB Underglow working in a very simple state --- keyboards/practice60/bluepill/halconf.h | 2 +- keyboards/practice60/bluepill/hsv2rgb.c | 80 +++++++++ keyboards/practice60/bluepill/hsv2rgb.h | 23 +++ keyboards/practice60/bluepill/matrix.c | 6 + keyboards/practice60/bluepill/mcuconf.h | 2 +- keyboards/practice60/bluepill/rules.mk | 4 +- keyboards/practice60/bluepill/underglow.c | 157 ++++++++++++++++++ keyboards/practice60/bluepill/underglow.h | 10 ++ .../boards/GENERIC_STM32_F103/board.c | 5 + 9 files changed, 286 insertions(+), 3 deletions(-) create mode 100644 keyboards/practice60/bluepill/hsv2rgb.c create mode 100644 keyboards/practice60/bluepill/hsv2rgb.h create mode 100644 keyboards/practice60/bluepill/underglow.c create mode 100644 keyboards/practice60/bluepill/underglow.h diff --git a/keyboards/practice60/bluepill/halconf.h b/keyboards/practice60/bluepill/halconf.h index 8b9724b1a30e..5fba285a380d 100644 --- a/keyboards/practice60/bluepill/halconf.h +++ b/keyboards/practice60/bluepill/halconf.h @@ -146,7 +146,7 @@ * @brief Enables the SPI subsystem. */ #if !defined(HAL_USE_SPI) || defined(__DOXYGEN__) -#define HAL_USE_SPI FALSE +#define HAL_USE_SPI TRUE #endif /** diff --git a/keyboards/practice60/bluepill/hsv2rgb.c b/keyboards/practice60/bluepill/hsv2rgb.c new file mode 100644 index 000000000000..adb7af8fa57e --- /dev/null +++ b/keyboards/practice60/bluepill/hsv2rgb.c @@ -0,0 +1,80 @@ +/* hsv2rgb.c + * Integer only conversion functions between HSV and RGB + */ + +#include "hsv2rgb.h" + +// TODO fix these buggy macros +#define max(x,y) ((x>y) ? x:y) +#define min(x,y) ((x>y) ? y:x) +#define min3(x,y,z) (min(min(x,y),z)) +#define max3(x,y,z) (max(max(x,y),z)) + + +rgb_color hsv2rgb(hsv_color hsv) +{ + // From : http://qscribble.blogspot.fr/2008/06/integer-conversion-from-hsl-to-rgb.html + int h = hsv.h; + int s = hsv.s; + int v = hsv.v; + rgb_color rgb = {0, 0, 0}; + + if (v == 0) + return rgb; + + // sextant = 0 .. 5 + int sextant = (h*6)/256; + // f = 0 .. 42 + int f = h - (sextant*256)/6; + + int p = (v * (256 - s))/256; + int q = (v * (256*43 - s*f))/(256*43); + int t = (v * (256*43 - s*(43-f)))/(256*43); + + // Corrige les erreurs dues aux arrondis + p = max(min(p, 255), 0); + q = max(min(q, 255), 0); + t = max(min(t, 255), 0); + + switch(sextant){ + case 0: rgb.r = v; rgb.g = t; rgb.b = p; break; + case 1: rgb.r = q; rgb.g = v; rgb.b = p; break; + case 2: rgb.r = p; rgb.g = v; rgb.b = t; break; + case 3: rgb.r = p; rgb.g = q; rgb.b = v; break; + case 4: rgb.r = t; rgb.g = p; rgb.b = v; break; + default:rgb.r = v; rgb.g = p; rgb.b = q; break; + } + return rgb; +} + + +hsv_color rgb2hsv(rgb_color rgb) +{ + // From : http://www.ruinelli.ch/rgb-to-hsv + hsv_color hsv = {0, 0, 0}; + int min, max, delta; + + min = min3(rgb.r, rgb.g, rgb.b); + max = max3(rgb.r, rgb.g, rgb.b); + + if(max==0) { + hsv.h = 0; + hsv.s = 0; + hsv.v = 0; + return hsv; + } + + hsv.v = max; + delta = max - min; + + hsv.s = (delta)*255 / max; + + if(rgb.r == max) + hsv.h = (rgb.g - rgb.b)*42/delta; // between yellow & magenta + else if(rgb.g == max) + hsv.h = 120 + (rgb.b - rgb.r)*42/delta; // between cyan & yellow + else + hsv.h = 240 + (rgb.r - rgb.g)*42/delta; // between magenta & cyan + + return hsv; +} \ No newline at end of file diff --git a/keyboards/practice60/bluepill/hsv2rgb.h b/keyboards/practice60/bluepill/hsv2rgb.h new file mode 100644 index 000000000000..99566c32c07e --- /dev/null +++ b/keyboards/practice60/bluepill/hsv2rgb.h @@ -0,0 +1,23 @@ +/* hsv2rgb.h + * Convert Hue Saturation Value to Red Green Blue + * + * Programme de convertion d'une information HSV en RGB + */ +#ifndef HSV2RGB_H +#define HSV2RGB_H + +typedef struct { + unsigned char h; + unsigned char s; + unsigned char v; +} hsv_color; + +typedef struct { + unsigned char r; + unsigned char g; + unsigned char b; +} rgb_color; + +rgb_color hsv2rgb(hsv_color hsv); + +#endif \ No newline at end of file diff --git a/keyboards/practice60/bluepill/matrix.c b/keyboards/practice60/bluepill/matrix.c index 3aec4e6dfd62..73179c0a9bda 100644 --- a/keyboards/practice60/bluepill/matrix.c +++ b/keyboards/practice60/bluepill/matrix.c @@ -26,6 +26,7 @@ along with this program. If not, see . #include "util.h" #include "matrix.h" #include "wait.h" +#include "underglow.h" #ifndef DEBOUNCE # define DEBOUNCE 5 @@ -85,6 +86,9 @@ void matrix_init(void) unselect_rows(); init_cols(); + /* MOSI pin*/ + palSetPadMode(GPIOB, 15, PAL_MODE_STM32_ALTERNATE_PUSHPULL); + // initialize matrix state: all keys off for (uint8_t i=0; i < MATRIX_ROWS; i++) { matrix[i] = 0; @@ -99,6 +103,8 @@ void matrix_init(void) palClearPad(GPIOA, 8); LED_OFF(); + leds_init(); + matrix_init_quantum(); } diff --git a/keyboards/practice60/bluepill/mcuconf.h b/keyboards/practice60/bluepill/mcuconf.h index 276829216ee8..9945e7408d12 100644 --- a/keyboards/practice60/bluepill/mcuconf.h +++ b/keyboards/practice60/bluepill/mcuconf.h @@ -168,7 +168,7 @@ * SPI driver system settings. */ #define STM32_SPI_USE_SPI1 FALSE -#define STM32_SPI_USE_SPI2 FALSE +#define STM32_SPI_USE_SPI2 TRUE #define STM32_SPI_USE_SPI3 FALSE #define STM32_SPI_SPI1_DMA_PRIORITY 1 #define STM32_SPI_SPI2_DMA_PRIORITY 1 diff --git a/keyboards/practice60/bluepill/rules.mk b/keyboards/practice60/bluepill/rules.mk index 3a9e47c9e245..7ba127085838 100644 --- a/keyboards/practice60/bluepill/rules.mk +++ b/keyboards/practice60/bluepill/rules.mk @@ -1,6 +1,8 @@ # project specific files SRC = matrix.c \ - led.c + led.c \ + underglow.c \ + hsv2rgb.c # GENERIC STM32F103C8T6 board - stm32duino bootloader OPT_DEFS = -DCORTEX_VTOR_INIT=0x2000 diff --git a/keyboards/practice60/bluepill/underglow.c b/keyboards/practice60/bluepill/underglow.c new file mode 100644 index 000000000000..125ba7a7c33f --- /dev/null +++ b/keyboards/practice60/bluepill/underglow.c @@ -0,0 +1,157 @@ +#include "ch.h" +#include "hal.h" + +#include "hsv2rgb.h" +#include "underglow.h" + +#define BYTES_FOR_LED_BYTE 4 +#define NB_COLORS 3 +#define BYTES_FOR_LED BYTES_FOR_LED_BYTE*NB_COLORS +#define DATA_SIZE BYTES_FOR_LED*NB_LEDS +#define RESET_SIZE 200 +#define PREAMBLE_SIZE 4 + +// Define the spi your LEDs are plugged to here +#define LEDS_SPI SPID2 +// Define the number of LEDs you wish to control in your LED strip +#define NB_LEDS 8 + +#define LED_SPIRAL 1 + +static uint8_t txbuf[PREAMBLE_SIZE + DATA_SIZE + RESET_SIZE]; +static uint8_t get_protocol_eq(uint8_t data, int pos); + +/* + * This lib is meant to be used asynchronously, thus the colors contained in + * the txbuf will be sent in loop, so that the colors are always the ones you + * put in the table (the user thus have less to worry about) + * + * Since the data are sent via DMA, and the call to spiSend is a blocking one, + * the processor ressources are not used to much, if you see your program being + * too slow, simply add a: + * chThdSleepMilliseconds(x); + * after the spiSend, where you increment x untill you are satisfied with your + * program speed, another trick may be to lower this thread priority : your call + */ +static THD_WORKING_AREA(LEDS_THREAD_WA, 128); +static THD_FUNCTION(ledsThread, arg) { + (void) arg; + while(1){ + spiSend(&LEDS_SPI, PREAMBLE_SIZE + DATA_SIZE + RESET_SIZE, txbuf); + } +} + +#if LED_SPIRAL +/* + * 'Led spiral' is a simple demo in which we put all the leds to the same + * color, where this color does all the hsv circle in loop. + * If you want to launch the thread that will chage the led colors to the + * appropriate value, simply set LED_SPIRAL to 1. + */ +static THD_WORKING_AREA(HSVTRANS_WA, 128); +static THD_FUNCTION(hsv_transThread, arg){ + (void) arg; + hsv_color color = {0, 255, 255}; + while(1){ + color.h += 1; + color.h %= 256; + set_leds_color_hsv(color); + chThdSleepMilliseconds(50); + } +} +#endif + +static const SPIConfig spicfg = { + NULL, + GPIOB, + 15, + SPI_CR1_BR_1|SPI_CR1_BR_0 // baudrate : fpclk / 8 => 1tick is 0.32us +}; + +/* + * Function used to initialize the driver. + * + * Starts by shutting off all the LEDs. + * Then gets access on the LED_SPI driver. + * May eventually launch an animation on the LEDs (e.g. a thread setting the + * txbuff values) + */ +void leds_init(void){ + for(int i = 0; i < RESET_SIZE; i++) + txbuf[DATA_SIZE+i] = 0x00; + for (int i=0; iMAPR |= AFIO_MAPR_SWJ_CFG_JTAGDISABLE; + //Set backup register DR10 to enter bootloader on reset + BKP->DR10 = RTC_BOOTLOADER_FLAG; } From 5061803414373af417b1c5b3ffbbdd315721510c Mon Sep 17 00:00:00 2001 From: Andrew Kannan Date: Sat, 10 Nov 2018 12:17:09 -0500 Subject: [PATCH 12/17] not as bright --- keyboards/practice60/bluepill/underglow.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/keyboards/practice60/bluepill/underglow.c b/keyboards/practice60/bluepill/underglow.c index 125ba7a7c33f..1383af18985f 100644 --- a/keyboards/practice60/bluepill/underglow.c +++ b/keyboards/practice60/bluepill/underglow.c @@ -51,7 +51,7 @@ static THD_FUNCTION(ledsThread, arg) { static THD_WORKING_AREA(HSVTRANS_WA, 128); static THD_FUNCTION(hsv_transThread, arg){ (void) arg; - hsv_color color = {0, 255, 255}; + hsv_color color = {0, 255, 127}; while(1){ color.h += 1; color.h %= 256; From 7c32513988f3e7195f28c573bfda7cae52982ed8 Mon Sep 17 00:00:00 2001 From: Andrew Kannan Date: Sat, 10 Nov 2018 22:29:20 -0500 Subject: [PATCH 13/17] Move to handwired --- keyboards/{ => handwired}/practice60/bluepill/bluepill.c | 0 keyboards/{ => handwired}/practice60/bluepill/bluepill.h | 0 keyboards/{ => handwired}/practice60/bluepill/bootloader_defs.h | 0 keyboards/{ => handwired}/practice60/bluepill/chconf.h | 0 keyboards/{ => handwired}/practice60/bluepill/config.h | 0 keyboards/{ => handwired}/practice60/bluepill/halconf.h | 0 keyboards/{ => handwired}/practice60/bluepill/hsv2rgb.c | 0 keyboards/{ => handwired}/practice60/bluepill/hsv2rgb.h | 0 keyboards/{ => handwired}/practice60/bluepill/led.c | 0 keyboards/{ => handwired}/practice60/bluepill/matrix.c | 0 keyboards/{ => handwired}/practice60/bluepill/mcuconf.h | 0 keyboards/{ => handwired}/practice60/bluepill/readme.md | 0 keyboards/{ => handwired}/practice60/bluepill/rules.mk | 0 keyboards/{ => handwired}/practice60/bluepill/underglow.c | 0 keyboards/{ => handwired}/practice60/bluepill/underglow.h | 0 .../{ => handwired}/practice60/boards/GENERIC_STM32_F103/board.c | 0 .../{ => handwired}/practice60/boards/GENERIC_STM32_F103/board.h | 0 .../{ => handwired}/practice60/boards/GENERIC_STM32_F103/board.mk | 0 keyboards/{ => handwired}/practice60/config.h | 0 keyboards/{ => handwired}/practice60/keymaps/default/keymap.c | 0 keyboards/{ => handwired}/practice60/ld/MKL26Z64.ld | 0 .../practice60/ld/STM32F103x8_stm32duino_bootloader.ld | 0 keyboards/{ => handwired}/practice60/practice60.c | 0 keyboards/{ => handwired}/practice60/practice60.h | 0 keyboards/{ => handwired}/practice60/readme.md | 0 keyboards/{ => handwired}/practice60/rules.mk | 0 26 files changed, 0 insertions(+), 0 deletions(-) rename keyboards/{ => handwired}/practice60/bluepill/bluepill.c (100%) rename keyboards/{ => handwired}/practice60/bluepill/bluepill.h (100%) rename keyboards/{ => handwired}/practice60/bluepill/bootloader_defs.h (100%) rename keyboards/{ => handwired}/practice60/bluepill/chconf.h (100%) rename keyboards/{ => handwired}/practice60/bluepill/config.h (100%) rename keyboards/{ => handwired}/practice60/bluepill/halconf.h (100%) rename keyboards/{ => handwired}/practice60/bluepill/hsv2rgb.c (100%) rename keyboards/{ => handwired}/practice60/bluepill/hsv2rgb.h (100%) rename keyboards/{ => handwired}/practice60/bluepill/led.c (100%) rename keyboards/{ => handwired}/practice60/bluepill/matrix.c (100%) rename keyboards/{ => handwired}/practice60/bluepill/mcuconf.h (100%) rename keyboards/{ => handwired}/practice60/bluepill/readme.md (100%) rename keyboards/{ => handwired}/practice60/bluepill/rules.mk (100%) rename keyboards/{ => handwired}/practice60/bluepill/underglow.c (100%) rename keyboards/{ => handwired}/practice60/bluepill/underglow.h (100%) rename keyboards/{ => handwired}/practice60/boards/GENERIC_STM32_F103/board.c (100%) rename keyboards/{ => handwired}/practice60/boards/GENERIC_STM32_F103/board.h (100%) rename keyboards/{ => handwired}/practice60/boards/GENERIC_STM32_F103/board.mk (100%) rename keyboards/{ => handwired}/practice60/config.h (100%) rename keyboards/{ => handwired}/practice60/keymaps/default/keymap.c (100%) rename keyboards/{ => handwired}/practice60/ld/MKL26Z64.ld (100%) rename keyboards/{ => handwired}/practice60/ld/STM32F103x8_stm32duino_bootloader.ld (100%) rename keyboards/{ => handwired}/practice60/practice60.c (100%) rename keyboards/{ => handwired}/practice60/practice60.h (100%) rename keyboards/{ => handwired}/practice60/readme.md (100%) rename keyboards/{ => handwired}/practice60/rules.mk (100%) diff --git a/keyboards/practice60/bluepill/bluepill.c b/keyboards/handwired/practice60/bluepill/bluepill.c similarity index 100% rename from keyboards/practice60/bluepill/bluepill.c rename to keyboards/handwired/practice60/bluepill/bluepill.c diff --git a/keyboards/practice60/bluepill/bluepill.h b/keyboards/handwired/practice60/bluepill/bluepill.h similarity index 100% rename from keyboards/practice60/bluepill/bluepill.h rename to keyboards/handwired/practice60/bluepill/bluepill.h diff --git a/keyboards/practice60/bluepill/bootloader_defs.h b/keyboards/handwired/practice60/bluepill/bootloader_defs.h similarity index 100% rename from keyboards/practice60/bluepill/bootloader_defs.h rename to keyboards/handwired/practice60/bluepill/bootloader_defs.h diff --git a/keyboards/practice60/bluepill/chconf.h b/keyboards/handwired/practice60/bluepill/chconf.h similarity index 100% rename from keyboards/practice60/bluepill/chconf.h rename to keyboards/handwired/practice60/bluepill/chconf.h diff --git a/keyboards/practice60/bluepill/config.h b/keyboards/handwired/practice60/bluepill/config.h similarity index 100% rename from keyboards/practice60/bluepill/config.h rename to keyboards/handwired/practice60/bluepill/config.h diff --git a/keyboards/practice60/bluepill/halconf.h b/keyboards/handwired/practice60/bluepill/halconf.h similarity index 100% rename from keyboards/practice60/bluepill/halconf.h rename to keyboards/handwired/practice60/bluepill/halconf.h diff --git a/keyboards/practice60/bluepill/hsv2rgb.c b/keyboards/handwired/practice60/bluepill/hsv2rgb.c similarity index 100% rename from keyboards/practice60/bluepill/hsv2rgb.c rename to keyboards/handwired/practice60/bluepill/hsv2rgb.c diff --git a/keyboards/practice60/bluepill/hsv2rgb.h b/keyboards/handwired/practice60/bluepill/hsv2rgb.h similarity index 100% rename from keyboards/practice60/bluepill/hsv2rgb.h rename to keyboards/handwired/practice60/bluepill/hsv2rgb.h diff --git a/keyboards/practice60/bluepill/led.c b/keyboards/handwired/practice60/bluepill/led.c similarity index 100% rename from keyboards/practice60/bluepill/led.c rename to keyboards/handwired/practice60/bluepill/led.c diff --git a/keyboards/practice60/bluepill/matrix.c b/keyboards/handwired/practice60/bluepill/matrix.c similarity index 100% rename from keyboards/practice60/bluepill/matrix.c rename to keyboards/handwired/practice60/bluepill/matrix.c diff --git a/keyboards/practice60/bluepill/mcuconf.h b/keyboards/handwired/practice60/bluepill/mcuconf.h similarity index 100% rename from keyboards/practice60/bluepill/mcuconf.h rename to keyboards/handwired/practice60/bluepill/mcuconf.h diff --git a/keyboards/practice60/bluepill/readme.md b/keyboards/handwired/practice60/bluepill/readme.md similarity index 100% rename from keyboards/practice60/bluepill/readme.md rename to keyboards/handwired/practice60/bluepill/readme.md diff --git a/keyboards/practice60/bluepill/rules.mk b/keyboards/handwired/practice60/bluepill/rules.mk similarity index 100% rename from keyboards/practice60/bluepill/rules.mk rename to keyboards/handwired/practice60/bluepill/rules.mk diff --git a/keyboards/practice60/bluepill/underglow.c b/keyboards/handwired/practice60/bluepill/underglow.c similarity index 100% rename from keyboards/practice60/bluepill/underglow.c rename to keyboards/handwired/practice60/bluepill/underglow.c diff --git a/keyboards/practice60/bluepill/underglow.h b/keyboards/handwired/practice60/bluepill/underglow.h similarity index 100% rename from keyboards/practice60/bluepill/underglow.h rename to keyboards/handwired/practice60/bluepill/underglow.h diff --git a/keyboards/practice60/boards/GENERIC_STM32_F103/board.c b/keyboards/handwired/practice60/boards/GENERIC_STM32_F103/board.c similarity index 100% rename from keyboards/practice60/boards/GENERIC_STM32_F103/board.c rename to keyboards/handwired/practice60/boards/GENERIC_STM32_F103/board.c diff --git a/keyboards/practice60/boards/GENERIC_STM32_F103/board.h b/keyboards/handwired/practice60/boards/GENERIC_STM32_F103/board.h similarity index 100% rename from keyboards/practice60/boards/GENERIC_STM32_F103/board.h rename to keyboards/handwired/practice60/boards/GENERIC_STM32_F103/board.h diff --git a/keyboards/practice60/boards/GENERIC_STM32_F103/board.mk b/keyboards/handwired/practice60/boards/GENERIC_STM32_F103/board.mk similarity index 100% rename from keyboards/practice60/boards/GENERIC_STM32_F103/board.mk rename to keyboards/handwired/practice60/boards/GENERIC_STM32_F103/board.mk diff --git a/keyboards/practice60/config.h b/keyboards/handwired/practice60/config.h similarity index 100% rename from keyboards/practice60/config.h rename to keyboards/handwired/practice60/config.h diff --git a/keyboards/practice60/keymaps/default/keymap.c b/keyboards/handwired/practice60/keymaps/default/keymap.c similarity index 100% rename from keyboards/practice60/keymaps/default/keymap.c rename to keyboards/handwired/practice60/keymaps/default/keymap.c diff --git a/keyboards/practice60/ld/MKL26Z64.ld b/keyboards/handwired/practice60/ld/MKL26Z64.ld similarity index 100% rename from keyboards/practice60/ld/MKL26Z64.ld rename to keyboards/handwired/practice60/ld/MKL26Z64.ld diff --git a/keyboards/practice60/ld/STM32F103x8_stm32duino_bootloader.ld b/keyboards/handwired/practice60/ld/STM32F103x8_stm32duino_bootloader.ld similarity index 100% rename from keyboards/practice60/ld/STM32F103x8_stm32duino_bootloader.ld rename to keyboards/handwired/practice60/ld/STM32F103x8_stm32duino_bootloader.ld diff --git a/keyboards/practice60/practice60.c b/keyboards/handwired/practice60/practice60.c similarity index 100% rename from keyboards/practice60/practice60.c rename to keyboards/handwired/practice60/practice60.c diff --git a/keyboards/practice60/practice60.h b/keyboards/handwired/practice60/practice60.h similarity index 100% rename from keyboards/practice60/practice60.h rename to keyboards/handwired/practice60/practice60.h diff --git a/keyboards/practice60/readme.md b/keyboards/handwired/practice60/readme.md similarity index 100% rename from keyboards/practice60/readme.md rename to keyboards/handwired/practice60/readme.md diff --git a/keyboards/practice60/rules.mk b/keyboards/handwired/practice60/rules.mk similarity index 100% rename from keyboards/practice60/rules.mk rename to keyboards/handwired/practice60/rules.mk From 86e1ad16a0473b63bd2e3a0e81fd084021faae24 Mon Sep 17 00:00:00 2001 From: Andrew Kannan Date: Sat, 10 Nov 2018 22:31:48 -0500 Subject: [PATCH 14/17] revert ChibiOS_Test changes --- .../ld/STM32F103x8_stm32duino_bootloader.ld | 2 +- keyboards/chibios_test/rules.mk | 2 +- keyboards/chibios_test/stm32_f103_onekey/matrix.c | 6 +++--- keyboards/chibios_test/stm32_f103_onekey/rules.mk | 12 ++++++------ 4 files changed, 11 insertions(+), 11 deletions(-) diff --git a/keyboards/chibios_test/ld/STM32F103x8_stm32duino_bootloader.ld b/keyboards/chibios_test/ld/STM32F103x8_stm32duino_bootloader.ld index d0688ef60164..f9bfe9c00527 100644 --- a/keyboards/chibios_test/ld/STM32F103x8_stm32duino_bootloader.ld +++ b/keyboards/chibios_test/ld/STM32F103x8_stm32duino_bootloader.ld @@ -22,7 +22,7 @@ */ MEMORY { - flash0 : org = 0x08002000, len = 64k - 0x2000 + flash0 : org = 0x08002000, len = 128k - 0x2000 flash1 : org = 0x00000000, len = 0 flash2 : org = 0x00000000, len = 0 flash3 : org = 0x00000000, len = 0 diff --git a/keyboards/chibios_test/rules.mk b/keyboards/chibios_test/rules.mk index 2826ba2aa03e..45f03be02080 100644 --- a/keyboards/chibios_test/rules.mk +++ b/keyboards/chibios_test/rules.mk @@ -7,4 +7,4 @@ SLEEP_LED_ENABLE = yes # Breathing sleep LED during USB suspend NKRO_ENABLE = yes # USB Nkey Rollover CUSTOM_MATRIX = yes # Custom matrix file -DEFAULT_FOLDER = chibios_test/stm32_f103_onekey \ No newline at end of file +DEFAULT_FOLDER = chibios_test/stm32_f072_onekey \ No newline at end of file diff --git a/keyboards/chibios_test/stm32_f103_onekey/matrix.c b/keyboards/chibios_test/stm32_f103_onekey/matrix.c index 577fa6eeb3b4..ea9d8d057b1c 100644 --- a/keyboards/chibios_test/stm32_f103_onekey/matrix.c +++ b/keyboards/chibios_test/stm32_f103_onekey/matrix.c @@ -144,16 +144,16 @@ static void init_cols(void) { #ifdef BOARD_MAPLEMINI_STM32_F103 // don't need pullup/down, since it's pulled down in hardware - palSetPadMode(GPIOB, 10, PAL_MODE_INPUT); + palSetPadMode(GPIOB, 8, PAL_MODE_INPUT); #else - palSetPadMode(GPIOB, 10, PAL_MODE_INPUT_PULLDOWN); + palSetPadMode(GPIOB, 8, PAL_MODE_INPUT_PULLDOWN); #endif } /* Returns status of switches(1:on, 0:off) */ static matrix_row_t read_cols(void) { - return ((palReadPad(GPIOB, 10)==PAL_LOW) ? 0 : (1<<0)); + return ((palReadPad(GPIOB, 8)==PAL_LOW) ? 0 : (1<<0)); // | ((palReadPad(...)==PAL_HIGH) ? 0 : (1<<1)) } diff --git a/keyboards/chibios_test/stm32_f103_onekey/rules.mk b/keyboards/chibios_test/stm32_f103_onekey/rules.mk index c8a77f902d95..c75738338ab4 100644 --- a/keyboards/chibios_test/stm32_f103_onekey/rules.mk +++ b/keyboards/chibios_test/stm32_f103_onekey/rules.mk @@ -3,14 +3,14 @@ SRC = matrix.c \ led.c # GENERIC STM32F103C8T6 board - stm32duino bootloader -# OPT_DEFS = -DCORTEX_VTOR_INIT=0x2000 -# MCU_LDSCRIPT = STM32F103x8_stm32duino_bootloader -# BOARD = GENERIC_STM32_F103 +OPT_DEFS = -DCORTEX_VTOR_INIT=0x2000 +MCU_LDSCRIPT = STM32F103x8_stm32duino_bootloader +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 From c4e9d215bd0708c73a5ed5e356b65a7701d107c7 Mon Sep 17 00:00:00 2001 From: Andrew Kannan Date: Sun, 11 Nov 2018 18:32:01 -0500 Subject: [PATCH 15/17] Changes based on PR comments --- keyboards/handwired/practice60/bluepill/config.h | 2 -- keyboards/handwired/practice60/bluepill/readme.md | 4 ++-- keyboards/handwired/practice60/config.h | 5 +---- keyboards/handwired/practice60/rules.mk | 2 +- 4 files changed, 4 insertions(+), 9 deletions(-) diff --git a/keyboards/handwired/practice60/bluepill/config.h b/keyboards/handwired/practice60/bluepill/config.h index 5a3486be8da3..3f59c932d39b 100644 --- a/keyboards/handwired/practice60/bluepill/config.h +++ b/keyboards/handwired/practice60/bluepill/config.h @@ -1,4 +1,2 @@ #pragma once -#include "../config.h" - diff --git a/keyboards/handwired/practice60/bluepill/readme.md b/keyboards/handwired/practice60/bluepill/readme.md index d375ef7d84bf..15bd6d44cc0d 100644 --- a/keyboards/handwired/practice60/bluepill/readme.md +++ b/keyboards/handwired/practice60/bluepill/readme.md @@ -1,3 +1,3 @@ -# ChibiOS Test +# Bluepill Based Practice 60 Board -Test code for the stm32_f103 one key keyboard \ No newline at end of file +BluePill code for the practice 60 diff --git a/keyboards/handwired/practice60/config.h b/keyboards/handwired/practice60/config.h index 46e421effe1e..2eb95bcee579 100644 --- a/keyboards/handwired/practice60/config.h +++ b/keyboards/handwired/practice60/config.h @@ -15,8 +15,7 @@ You should have received a copy of the GNU General Public License along with this program. If not, see . */ -#ifndef CONFIG_H -#define CONFIG_H +#pragma once /* USB Device descriptor parameter */ #define VENDOR_ID 0xFEED @@ -70,5 +69,3 @@ along with this program. If not, see . //#define NO_ACTION_ONESHOT //#define NO_ACTION_MACRO //#define NO_ACTION_FUNCTION - -#endif diff --git a/keyboards/handwired/practice60/rules.mk b/keyboards/handwired/practice60/rules.mk index 9ab1f8eaefdd..c6c08a91acc1 100644 --- a/keyboards/handwired/practice60/rules.mk +++ b/keyboards/handwired/practice60/rules.mk @@ -10,4 +10,4 @@ BACKLIGHT_ENABLE = yes LAYOUTS = 60_ansi -DEFAULT_FOLDER = practice60/bluepill \ No newline at end of file +DEFAULT_FOLDER = handwired/practice60/bluepill From ba300272b456e62d553c25a7fd16b24beab5686f Mon Sep 17 00:00:00 2001 From: Andrew Kannan Date: Mon, 12 Nov 2018 19:07:56 -0500 Subject: [PATCH 16/17] Address PR comments v2 --- .../handwired/practice60/bluepill/bluepill.c | 1 - .../handwired/practice60/bluepill/bluepill.h | 4 - .../practice60/bluepill/bootloader_defs.h | 10 - .../handwired/practice60/bluepill/chconf.h | 524 ------------------ .../handwired/practice60/bluepill/config.h | 2 - .../handwired/practice60/bluepill/halconf.h | 353 ------------ .../handwired/practice60/bluepill/hsv2rgb.c | 80 --- .../handwired/practice60/bluepill/hsv2rgb.h | 23 - keyboards/handwired/practice60/bluepill/led.c | 51 -- .../handwired/practice60/bluepill/matrix.c | 236 -------- .../handwired/practice60/bluepill/mcuconf.h | 209 ------- .../handwired/practice60/bluepill/readme.md | 3 - .../handwired/practice60/bluepill/rules.mk | 43 -- .../handwired/practice60/bluepill/underglow.c | 157 ------ .../handwired/practice60/bluepill/underglow.h | 10 - keyboards/handwired/practice60/config.h | 3 + keyboards/handwired/practice60/practice60.c | 31 ++ keyboards/handwired/practice60/rules.mk | 47 +- 18 files changed, 79 insertions(+), 1708 deletions(-) delete mode 100644 keyboards/handwired/practice60/bluepill/bluepill.c delete mode 100644 keyboards/handwired/practice60/bluepill/bluepill.h delete mode 100644 keyboards/handwired/practice60/bluepill/bootloader_defs.h delete mode 100644 keyboards/handwired/practice60/bluepill/chconf.h delete mode 100644 keyboards/handwired/practice60/bluepill/config.h delete mode 100644 keyboards/handwired/practice60/bluepill/halconf.h delete mode 100644 keyboards/handwired/practice60/bluepill/hsv2rgb.c delete mode 100644 keyboards/handwired/practice60/bluepill/hsv2rgb.h delete mode 100644 keyboards/handwired/practice60/bluepill/led.c delete mode 100644 keyboards/handwired/practice60/bluepill/matrix.c delete mode 100644 keyboards/handwired/practice60/bluepill/mcuconf.h delete mode 100644 keyboards/handwired/practice60/bluepill/readme.md delete mode 100644 keyboards/handwired/practice60/bluepill/rules.mk delete mode 100644 keyboards/handwired/practice60/bluepill/underglow.c delete mode 100644 keyboards/handwired/practice60/bluepill/underglow.h diff --git a/keyboards/handwired/practice60/bluepill/bluepill.c b/keyboards/handwired/practice60/bluepill/bluepill.c deleted file mode 100644 index 30effbc31dd2..000000000000 --- a/keyboards/handwired/practice60/bluepill/bluepill.c +++ /dev/null @@ -1 +0,0 @@ -#include "bluepill.h" diff --git a/keyboards/handwired/practice60/bluepill/bluepill.h b/keyboards/handwired/practice60/bluepill/bluepill.h deleted file mode 100644 index b4a38590b0c1..000000000000 --- a/keyboards/handwired/practice60/bluepill/bluepill.h +++ /dev/null @@ -1,4 +0,0 @@ -#pragma once - -#include "practice60.h" - diff --git a/keyboards/handwired/practice60/bluepill/bootloader_defs.h b/keyboards/handwired/practice60/bluepill/bootloader_defs.h deleted file mode 100644 index 0f45203cb613..000000000000 --- a/keyboards/handwired/practice60/bluepill/bootloader_defs.h +++ /dev/null @@ -1,10 +0,0 @@ -/* Address for jumping to bootloader on STM32 chips. */ -/* It is chip dependent, the correct number can be looked up here (page 175): - * http://www.st.com/web/en/resource/technical/document/application_note/CD00167594.pdf - * This also requires a patch to chibios: - * /tmk_core/tool/chibios/ch-bootloader-jump.patch - */ - -// STM32F103* does NOT have an USB bootloader in ROM (only serial), -// so setting anything here does not make much sense -// #define STM32_BOOTLOADER_ADDRESS 0x1FFFC800 diff --git a/keyboards/handwired/practice60/bluepill/chconf.h b/keyboards/handwired/practice60/bluepill/chconf.h deleted file mode 100644 index dfb1f9dfb9e6..000000000000 --- a/keyboards/handwired/practice60/bluepill/chconf.h +++ /dev/null @@ -1,524 +0,0 @@ -/* - ChibiOS - Copyright (C) 2006..2015 Giovanni Di Sirio - - Licensed under the Apache License, Version 2.0 (the "License"); - you may not use this file except in compliance with the License. - You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - - Unless required by applicable law or agreed to in writing, software - distributed under the License is distributed on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - See the License for the specific language governing permissions and - limitations under the License. -*/ - -/** - * @file templates/chconf.h - * @brief Configuration file template. - * @details A copy of this file must be placed in each project directory, it - * contains the application specific kernel settings. - * - * @addtogroup config - * @details Kernel related settings and hooks. - * @{ - */ - -#ifndef CHCONF_H -#define CHCONF_H - -#define _CHIBIOS_RT_CONF_ - -/*===========================================================================*/ -/** - * @name System timers settings - * @{ - */ -/*===========================================================================*/ - -/** - * @brief System time counter resolution. - * @note Allowed values are 16 or 32 bits. - */ -#define CH_CFG_ST_RESOLUTION 16 - -/** - * @brief System tick frequency. - * @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 2000 - -/** - * @brief Time delta constant for the tick-less mode. - * @note If this value is zero then the system uses the classic - * periodic tick. This value represents the minimum number - * of ticks that is safe to specify in a timeout directive. - * The value one is not valid, timeouts are rounded up to - * this value. - */ -#define CH_CFG_ST_TIMEDELTA 2 - -/** @} */ - -/*===========================================================================*/ -/** - * @name Kernel parameters and options - * @{ - */ -/*===========================================================================*/ - -/** - * @brief Round robin interval. - * @details This constant is the number of system ticks allowed for the - * threads before preemption occurs. Setting this value to zero - * disables the preemption for threads with equal priority and the - * round robin becomes cooperative. Note that higher priority - * threads can still preempt, the kernel is always preemptive. - * @note Disabling the round robin preemption makes the kernel more compact - * and generally faster. - * @note The round robin preemption is not supported in tickless mode and - * must be set to zero in that case. - */ -#define CH_CFG_TIME_QUANTUM 0 - -/** - * @brief Managed RAM size. - * @details Size of the RAM area to be managed by the OS. If set to zero - * then the whole available RAM is used. The core memory is made - * available to the heap allocator and/or can be used directly through - * the simplified core memory allocator. - * - * @note In order to let the OS manage the whole RAM the linker script must - * provide the @p __heap_base__ and @p __heap_end__ symbols. - * @note Requires @p CH_CFG_USE_MEMCORE. - */ -#define CH_CFG_MEMCORE_SIZE 0 - -/** - * @brief Idle thread automatic spawn suppression. - * @details When this option is activated the function @p chSysInit() - * does not spawn the idle thread. The application @p main() - * function becomes the idle thread and must implement an - * infinite loop. - */ -#define CH_CFG_NO_IDLE_THREAD FALSE - -/* Use __WFI in the idle thread for waiting. Does lower the power - * consumption. */ -#define CORTEX_ENABLE_WFI_IDLE TRUE - -/** @} */ - -/*===========================================================================*/ -/** - * @name Performance options - * @{ - */ -/*===========================================================================*/ - -/** - * @brief OS optimization. - * @details If enabled then time efficient rather than space efficient code - * is used when two possible implementations exist. - * - * @note This is not related to the compiler optimization options. - * @note The default is @p TRUE. - */ -#define CH_CFG_OPTIMIZE_SPEED TRUE - -/** @} */ - -/*===========================================================================*/ -/** - * @name Subsystem options - * @{ - */ -/*===========================================================================*/ - -/** - * @brief Time Measurement APIs. - * @details If enabled then the time measurement APIs are included in - * the kernel. - * - * @note The default is @p TRUE. - */ -#define CH_CFG_USE_TM FALSE - -/** - * @brief Threads registry APIs. - * @details If enabled then the registry APIs are included in the kernel. - * - * @note The default is @p TRUE. - */ -#define CH_CFG_USE_REGISTRY TRUE - -/** - * @brief Threads synchronization APIs. - * @details If enabled then the @p chThdWait() function is included in - * the kernel. - * - * @note The default is @p TRUE. - */ -#define CH_CFG_USE_WAITEXIT TRUE - -/** - * @brief Semaphores APIs. - * @details If enabled then the Semaphores APIs are included in the kernel. - * - * @note The default is @p TRUE. - */ -#define CH_CFG_USE_SEMAPHORES TRUE - -/** - * @brief Semaphores queuing mode. - * @details If enabled then the threads are enqueued on semaphores by - * priority rather than in FIFO order. - * - * @note The default is @p FALSE. Enable this if you have special - * requirements. - * @note Requires @p CH_CFG_USE_SEMAPHORES. - */ -#define CH_CFG_USE_SEMAPHORES_PRIORITY FALSE - -/** - * @brief Mutexes APIs. - * @details If enabled then the mutexes APIs are included in the kernel. - * - * @note The default is @p TRUE. - */ -#define CH_CFG_USE_MUTEXES TRUE - -/** - * @brief Enables recursive behavior on mutexes. - * @note Recursive mutexes are heavier and have an increased - * memory footprint. - * - * @note The default is @p FALSE. - * @note Requires @p CH_CFG_USE_MUTEXES. - */ -#define CH_CFG_USE_MUTEXES_RECURSIVE FALSE - -/** - * @brief Conditional Variables APIs. - * @details If enabled then the conditional variables APIs are included - * in the kernel. - * - * @note The default is @p TRUE. - * @note Requires @p CH_CFG_USE_MUTEXES. - */ -#define CH_CFG_USE_CONDVARS TRUE - -/** - * @brief Conditional Variables APIs with timeout. - * @details If enabled then the conditional variables APIs with timeout - * specification are included in the kernel. - * - * @note The default is @p TRUE. - * @note Requires @p CH_CFG_USE_CONDVARS. - */ -#define CH_CFG_USE_CONDVARS_TIMEOUT FALSE - -/** - * @brief Events Flags APIs. - * @details If enabled then the event flags APIs are included in the kernel. - * - * @note The default is @p TRUE. - */ -#define CH_CFG_USE_EVENTS TRUE - -/** - * @brief Events Flags APIs with timeout. - * @details If enabled then the events APIs with timeout specification - * are included in the kernel. - * - * @note The default is @p TRUE. - * @note Requires @p CH_CFG_USE_EVENTS. - */ -#define CH_CFG_USE_EVENTS_TIMEOUT TRUE - -/** - * @brief Synchronous Messages APIs. - * @details If enabled then the synchronous messages APIs are included - * in the kernel. - * - * @note The default is @p TRUE. - */ -#define CH_CFG_USE_MESSAGES TRUE - -/** - * @brief Synchronous Messages queuing mode. - * @details If enabled then messages are served by priority rather than in - * FIFO order. - * - * @note The default is @p FALSE. Enable this if you have special - * requirements. - * @note Requires @p CH_CFG_USE_MESSAGES. - */ -#define CH_CFG_USE_MESSAGES_PRIORITY FALSE - -/** - * @brief Mailboxes APIs. - * @details If enabled then the asynchronous messages (mailboxes) APIs are - * included in the kernel. - * - * @note The default is @p TRUE. - * @note Requires @p CH_CFG_USE_SEMAPHORES. - */ -#define CH_CFG_USE_MAILBOXES TRUE - -/** - * @brief Core Memory Manager APIs. - * @details If enabled then the core memory manager APIs are included - * in the kernel. - * - * @note The default is @p TRUE. - */ -#define CH_CFG_USE_MEMCORE TRUE - -/** - * @brief Heap Allocator APIs. - * @details If enabled then the memory heap allocator APIs are included - * in the kernel. - * - * @note The default is @p TRUE. - * @note Requires @p CH_CFG_USE_MEMCORE and either @p CH_CFG_USE_MUTEXES or - * @p CH_CFG_USE_SEMAPHORES. - * @note Mutexes are recommended. - */ -#define CH_CFG_USE_HEAP TRUE - -/** - * @brief Memory Pools Allocator APIs. - * @details If enabled then the memory pools allocator APIs are included - * in the kernel. - * - * @note The default is @p TRUE. - */ -#define CH_CFG_USE_MEMPOOLS FALSE - -/** - * @brief Dynamic Threads APIs. - * @details If enabled then the dynamic threads creation APIs are included - * in the kernel. - * - * @note The default is @p TRUE. - * @note Requires @p CH_CFG_USE_WAITEXIT. - * @note Requires @p CH_CFG_USE_HEAP and/or @p CH_CFG_USE_MEMPOOLS. - */ -#define CH_CFG_USE_DYNAMIC FALSE - -/** @} */ - -/*===========================================================================*/ -/** - * @name Debug options - * @{ - */ -/*===========================================================================*/ - -/** - * @brief Debug option, kernel statistics. - * - * @note The default is @p FALSE. - */ -#define CH_DBG_STATISTICS FALSE - -/** - * @brief Debug option, system state check. - * @details If enabled the correct call protocol for system APIs is checked - * at runtime. - * - * @note The default is @p FALSE. - */ -#define CH_DBG_SYSTEM_STATE_CHECK FALSE - -/** - * @brief Debug option, parameters checks. - * @details If enabled then the checks on the API functions input - * parameters are activated. - * - * @note The default is @p FALSE. - */ -#define CH_DBG_ENABLE_CHECKS FALSE - -/** - * @brief Debug option, consistency checks. - * @details If enabled then all the assertions in the kernel code are - * activated. This includes consistency checks inside the kernel, - * runtime anomalies and port-defined checks. - * - * @note The default is @p FALSE. - */ -#define CH_DBG_ENABLE_ASSERTS FALSE - -/** - * @brief Debug option, trace buffer. - * @details If enabled then the trace buffer is activated. - * - * @note The default is @p CH_DBG_TRACE_MASK_DISABLED. - */ -#define CH_DBG_TRACE_MASK CH_DBG_TRACE_MASK_DISABLED - -/** - * @brief Trace buffer entries. - * @note The trace buffer is only allocated if @p CH_DBG_TRACE_MASK is - * different from @p CH_DBG_TRACE_MASK_DISABLED. - */ -#define CH_DBG_TRACE_BUFFER_SIZE 128 - -/** - * @brief Debug option, stack checks. - * @details If enabled then a runtime stack check is performed. - * - * @note The default is @p FALSE. - * @note The stack check is performed in a architecture/port dependent way. - * It may not be implemented or some ports. - * @note The default failure mode is to halt the system with the global - * @p panic_msg variable set to @p NULL. - */ -#define CH_DBG_ENABLE_STACK_CHECK FALSE - -/** - * @brief Debug option, stacks initialization. - * @details If enabled then the threads working area is filled with a byte - * value when a thread is created. This can be useful for the - * runtime measurement of the used stack. - * - * @note The default is @p FALSE. - */ -#define CH_DBG_FILL_THREADS FALSE - -/** - * @brief Debug option, threads profiling. - * @details If enabled then a field is added to the @p thread_t structure that - * counts the system ticks occurred while executing the thread. - * - * @note The default is @p FALSE. - * @note This debug option is not currently compatible with the - * tickless mode. - */ -#define CH_DBG_THREADS_PROFILING FALSE - -/** @} */ - -/*===========================================================================*/ -/** - * @name Kernel hooks - * @{ - */ -/*===========================================================================*/ - -/** - * @brief Threads descriptor structure extension. - * @details User fields added to the end of the @p thread_t structure. - */ -#define CH_CFG_THREAD_EXTRA_FIELDS \ - /* Add threads custom fields here.*/ - -/** - * @brief Threads initialization hook. - * @details User initialization code added to the @p chThdInit() API. - * - * @note It is invoked from within @p chThdInit() and implicitly from all - * the threads creation APIs. - */ -#define CH_CFG_THREAD_INIT_HOOK(tp) { \ - /* Add threads initialization code here.*/ \ -} - -/** - * @brief Threads finalization hook. - * @details User finalization code added to the @p chThdExit() API. - */ -#define CH_CFG_THREAD_EXIT_HOOK(tp) { \ - /* Add threads finalization code here.*/ \ -} - -/** - * @brief Context switch hook. - * @details This hook is invoked just before switching between threads. - */ -#define CH_CFG_CONTEXT_SWITCH_HOOK(ntp, otp) { \ - /* Context switch code here.*/ \ -} - -/** - * @brief ISR enter hook. - */ -#define CH_CFG_IRQ_PROLOGUE_HOOK() { \ - /* IRQ prologue code here.*/ \ -} - -/** - * @brief ISR exit hook. - */ -#define CH_CFG_IRQ_EPILOGUE_HOOK() { \ - /* IRQ epilogue code here.*/ \ -} - -/** - * @brief Idle thread enter hook. - * @note This hook is invoked within a critical zone, no OS functions - * should be invoked from here. - * @note This macro can be used to activate a power saving mode. - */ -#define CH_CFG_IDLE_ENTER_HOOK() { \ - /* Idle-enter code here.*/ \ -} - -/** - * @brief Idle thread leave hook. - * @note This hook is invoked within a critical zone, no OS functions - * should be invoked from here. - * @note This macro can be used to deactivate a power saving mode. - */ -#define CH_CFG_IDLE_LEAVE_HOOK() { \ - /* Idle-leave code here.*/ \ -} - -/** - * @brief Idle Loop hook. - * @details This hook is continuously invoked by the idle thread loop. - */ -#define CH_CFG_IDLE_LOOP_HOOK() { \ - /* Idle loop code here.*/ \ -} - -/** - * @brief System tick event hook. - * @details This hook is invoked in the system tick handler immediately - * after processing the virtual timers queue. - */ -#define CH_CFG_SYSTEM_TICK_HOOK() { \ - /* System tick event code here.*/ \ -} - -/** - * @brief System halt hook. - * @details This hook is invoked in case to a system halting error before - * the system is halted. - */ -#define CH_CFG_SYSTEM_HALT_HOOK(reason) { \ - /* System halt code here.*/ \ -} - -/** - * @brief Trace hook. - * @details This hook is invoked each time a new record is written in the - * trace buffer. - */ -#define CH_CFG_TRACE_HOOK(tep) { \ - /* Trace code here.*/ \ -} - -/** @} */ - -/*===========================================================================*/ -/* Port-specific settings (override port settings defaulted in chcore.h). */ -/*===========================================================================*/ - -#endif /* CHCONF_H */ - -/** @} */ diff --git a/keyboards/handwired/practice60/bluepill/config.h b/keyboards/handwired/practice60/bluepill/config.h deleted file mode 100644 index 3f59c932d39b..000000000000 --- a/keyboards/handwired/practice60/bluepill/config.h +++ /dev/null @@ -1,2 +0,0 @@ -#pragma once - diff --git a/keyboards/handwired/practice60/bluepill/halconf.h b/keyboards/handwired/practice60/bluepill/halconf.h deleted file mode 100644 index 5fba285a380d..000000000000 --- a/keyboards/handwired/practice60/bluepill/halconf.h +++ /dev/null @@ -1,353 +0,0 @@ -/* - ChibiOS - Copyright (C) 2006..2015 Giovanni Di Sirio - - Licensed under the Apache License, Version 2.0 (the "License"); - you may not use this file except in compliance with the License. - You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - - Unless required by applicable law or agreed to in writing, software - distributed under the License is distributed on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - See the License for the specific language governing permissions and - limitations under the License. -*/ - -/** - * @file templates/halconf.h - * @brief HAL configuration header. - * @details HAL configuration file, this file allows to enable or disable the - * various device drivers from your application. You may also use - * this file in order to override the device drivers default settings. - * - * @addtogroup HAL_CONF - * @{ - */ - -#ifndef _HALCONF_H_ -#define _HALCONF_H_ - -#include "mcuconf.h" - -/** - * @brief Enables the PAL subsystem. - */ -#if !defined(HAL_USE_PAL) || defined(__DOXYGEN__) -#define HAL_USE_PAL TRUE -#endif - -/** - * @brief Enables the ADC subsystem. - */ -#if !defined(HAL_USE_ADC) || defined(__DOXYGEN__) -#define HAL_USE_ADC FALSE -#endif - -/** - * @brief Enables the CAN subsystem. - */ -#if !defined(HAL_USE_CAN) || defined(__DOXYGEN__) -#define HAL_USE_CAN FALSE -#endif - -/** - * @brief Enables the DAC subsystem. - */ -#if !defined(HAL_USE_DAC) || defined(__DOXYGEN__) -#define HAL_USE_DAC FALSE -#endif - -/** - * @brief Enables the EXT subsystem. - */ -#if !defined(HAL_USE_EXT) || defined(__DOXYGEN__) -#define HAL_USE_EXT FALSE -#endif - -/** - * @brief Enables the GPT subsystem. - */ -#if !defined(HAL_USE_GPT) || defined(__DOXYGEN__) -#define HAL_USE_GPT FALSE -#endif - -/** - * @brief Enables the I2C subsystem. - */ -#if !defined(HAL_USE_I2C) || defined(__DOXYGEN__) -#define HAL_USE_I2C FALSE -#endif - -/** - * @brief Enables the I2S subsystem. - */ -#if !defined(HAL_USE_I2S) || defined(__DOXYGEN__) -#define HAL_USE_I2S FALSE -#endif - -/** - * @brief Enables the ICU subsystem. - */ -#if !defined(HAL_USE_ICU) || defined(__DOXYGEN__) -#define HAL_USE_ICU FALSE -#endif - -/** - * @brief Enables the MAC subsystem. - */ -#if !defined(HAL_USE_MAC) || defined(__DOXYGEN__) -#define HAL_USE_MAC FALSE -#endif - -/** - * @brief Enables the MMC_SPI subsystem. - */ -#if !defined(HAL_USE_MMC_SPI) || defined(__DOXYGEN__) -#define HAL_USE_MMC_SPI FALSE -#endif - -/** - * @brief Enables the PWM subsystem. - */ -#if !defined(HAL_USE_PWM) || defined(__DOXYGEN__) -#define HAL_USE_PWM FALSE -#endif - -/** - * @brief Enables the RTC subsystem. - */ -#if !defined(HAL_USE_RTC) || defined(__DOXYGEN__) -#define HAL_USE_RTC FALSE -#endif - -/** - * @brief Enables the SDC subsystem. - */ -#if !defined(HAL_USE_SDC) || defined(__DOXYGEN__) -#define HAL_USE_SDC FALSE -#endif - -/** - * @brief Enables the SERIAL subsystem. - */ -#if !defined(HAL_USE_SERIAL) || defined(__DOXYGEN__) -#define HAL_USE_SERIAL FALSE -#endif - -/** - * @brief Enables the SERIAL over USB subsystem. - */ -#if !defined(HAL_USE_SERIAL_USB) || defined(__DOXYGEN__) -#define HAL_USE_SERIAL_USB FALSE -#endif - -/** - * @brief Enables the SPI subsystem. - */ -#if !defined(HAL_USE_SPI) || defined(__DOXYGEN__) -#define HAL_USE_SPI TRUE -#endif - -/** - * @brief Enables the UART subsystem. - */ -#if !defined(HAL_USE_UART) || defined(__DOXYGEN__) -#define HAL_USE_UART FALSE -#endif - -/** - * @brief Enables the USB subsystem. - */ -#if !defined(HAL_USE_USB) || defined(__DOXYGEN__) -#define HAL_USE_USB TRUE -#endif - -/** - * @brief Enables the WDG subsystem. - */ -#if !defined(HAL_USE_WDG) || defined(__DOXYGEN__) -#define HAL_USE_WDG FALSE -#endif - -/*===========================================================================*/ -/* ADC driver related settings. */ -/*===========================================================================*/ - -/** - * @brief Enables synchronous APIs. - * @note Disabling this option saves both code and data space. - */ -#if !defined(ADC_USE_WAIT) || defined(__DOXYGEN__) -#define ADC_USE_WAIT TRUE -#endif - -/** - * @brief Enables the @p adcAcquireBus() and @p adcReleaseBus() APIs. - * @note Disabling this option saves both code and data space. - */ -#if !defined(ADC_USE_MUTUAL_EXCLUSION) || defined(__DOXYGEN__) -#define ADC_USE_MUTUAL_EXCLUSION TRUE -#endif - -/*===========================================================================*/ -/* CAN driver related settings. */ -/*===========================================================================*/ - -/** - * @brief Sleep mode related APIs inclusion switch. - */ -#if !defined(CAN_USE_SLEEP_MODE) || defined(__DOXYGEN__) -#define CAN_USE_SLEEP_MODE TRUE -#endif - -/*===========================================================================*/ -/* I2C driver related settings. */ -/*===========================================================================*/ - -/** - * @brief Enables the mutual exclusion APIs on the I2C bus. - */ -#if !defined(I2C_USE_MUTUAL_EXCLUSION) || defined(__DOXYGEN__) -#define I2C_USE_MUTUAL_EXCLUSION TRUE -#endif - -/*===========================================================================*/ -/* MAC driver related settings. */ -/*===========================================================================*/ - -/** - * @brief Enables an event sources for incoming packets. - */ -#if !defined(MAC_USE_ZERO_COPY) || defined(__DOXYGEN__) -#define MAC_USE_ZERO_COPY FALSE -#endif - -/** - * @brief Enables an event sources for incoming packets. - */ -#if !defined(MAC_USE_EVENTS) || defined(__DOXYGEN__) -#define MAC_USE_EVENTS TRUE -#endif - -/*===========================================================================*/ -/* MMC_SPI driver related settings. */ -/*===========================================================================*/ - -/** - * @brief Delays insertions. - * @details If enabled this options inserts delays into the MMC waiting - * routines releasing some extra CPU time for the threads with - * lower priority, this may slow down the driver a bit however. - * This option is recommended also if the SPI driver does not - * use a DMA channel and heavily loads the CPU. - */ -#if !defined(MMC_NICE_WAITING) || defined(__DOXYGEN__) -#define MMC_NICE_WAITING TRUE -#endif - -/*===========================================================================*/ -/* SDC driver related settings. */ -/*===========================================================================*/ - -/** - * @brief Number of initialization attempts before rejecting the card. - * @note Attempts are performed at 10mS intervals. - */ -#if !defined(SDC_INIT_RETRY) || defined(__DOXYGEN__) -#define SDC_INIT_RETRY 100 -#endif - -/** - * @brief Include support for MMC cards. - * @note MMC support is not yet implemented so this option must be kept - * at @p FALSE. - */ -#if !defined(SDC_MMC_SUPPORT) || defined(__DOXYGEN__) -#define SDC_MMC_SUPPORT FALSE -#endif - -/** - * @brief Delays insertions. - * @details If enabled this options inserts delays into the MMC waiting - * routines releasing some extra CPU time for the threads with - * lower priority, this may slow down the driver a bit however. - */ -#if !defined(SDC_NICE_WAITING) || defined(__DOXYGEN__) -#define SDC_NICE_WAITING TRUE -#endif - -/*===========================================================================*/ -/* SERIAL driver related settings. */ -/*===========================================================================*/ - -/** - * @brief Default bit rate. - * @details Configuration parameter, this is the baud rate selected for the - * default configuration. - */ -#if !defined(SERIAL_DEFAULT_BITRATE) || defined(__DOXYGEN__) -#define SERIAL_DEFAULT_BITRATE 38400 -#endif - -/** - * @brief Serial buffers size. - * @details Configuration parameter, you can change the depth of the queue - * buffers depending on the requirements of your application. - * @note The default is 64 bytes for both the transmission and receive - * buffers. - */ -#if !defined(SERIAL_BUFFERS_SIZE) || defined(__DOXYGEN__) -#define SERIAL_BUFFERS_SIZE 16 -#endif - -/*===========================================================================*/ -/* SERIAL_USB driver related setting. */ -/*===========================================================================*/ - -/** - * @brief Serial over USB buffers size. - * @details Configuration parameter, the buffer size must be a multiple of - * the USB data endpoint maximum packet size. - * @note The default is 64 bytes for both the transmission and receive - * buffers. - */ -#if !defined(SERIAL_USB_BUFFERS_SIZE) || defined(__DOXYGEN__) -#define SERIAL_USB_BUFFERS_SIZE 1 -#endif - -/*===========================================================================*/ -/* SPI driver related settings. */ -/*===========================================================================*/ - -/** - * @brief Enables synchronous APIs. - * @note Disabling this option saves both code and data space. - */ -#if !defined(SPI_USE_WAIT) || defined(__DOXYGEN__) -#define SPI_USE_WAIT TRUE -#endif - -/** - * @brief Enables the @p spiAcquireBus() and @p spiReleaseBus() APIs. - * @note Disabling this option saves both code and data space. - */ -#if !defined(SPI_USE_MUTUAL_EXCLUSION) || defined(__DOXYGEN__) -#define SPI_USE_MUTUAL_EXCLUSION TRUE -#endif - -/*===========================================================================*/ -/* USB driver related settings. */ -/*===========================================================================*/ - -/** - * @brief Enables synchronous APIs. - * @note Disabling this option saves both code and data space. - */ -#if !defined(USB_USE_WAIT) || defined(__DOXYGEN__) -#define USB_USE_WAIT TRUE -#endif - -#endif /* _HALCONF_H_ */ - -/** @} */ diff --git a/keyboards/handwired/practice60/bluepill/hsv2rgb.c b/keyboards/handwired/practice60/bluepill/hsv2rgb.c deleted file mode 100644 index adb7af8fa57e..000000000000 --- a/keyboards/handwired/practice60/bluepill/hsv2rgb.c +++ /dev/null @@ -1,80 +0,0 @@ -/* hsv2rgb.c - * Integer only conversion functions between HSV and RGB - */ - -#include "hsv2rgb.h" - -// TODO fix these buggy macros -#define max(x,y) ((x>y) ? x:y) -#define min(x,y) ((x>y) ? y:x) -#define min3(x,y,z) (min(min(x,y),z)) -#define max3(x,y,z) (max(max(x,y),z)) - - -rgb_color hsv2rgb(hsv_color hsv) -{ - // From : http://qscribble.blogspot.fr/2008/06/integer-conversion-from-hsl-to-rgb.html - int h = hsv.h; - int s = hsv.s; - int v = hsv.v; - rgb_color rgb = {0, 0, 0}; - - if (v == 0) - return rgb; - - // sextant = 0 .. 5 - int sextant = (h*6)/256; - // f = 0 .. 42 - int f = h - (sextant*256)/6; - - int p = (v * (256 - s))/256; - int q = (v * (256*43 - s*f))/(256*43); - int t = (v * (256*43 - s*(43-f)))/(256*43); - - // Corrige les erreurs dues aux arrondis - p = max(min(p, 255), 0); - q = max(min(q, 255), 0); - t = max(min(t, 255), 0); - - switch(sextant){ - case 0: rgb.r = v; rgb.g = t; rgb.b = p; break; - case 1: rgb.r = q; rgb.g = v; rgb.b = p; break; - case 2: rgb.r = p; rgb.g = v; rgb.b = t; break; - case 3: rgb.r = p; rgb.g = q; rgb.b = v; break; - case 4: rgb.r = t; rgb.g = p; rgb.b = v; break; - default:rgb.r = v; rgb.g = p; rgb.b = q; break; - } - return rgb; -} - - -hsv_color rgb2hsv(rgb_color rgb) -{ - // From : http://www.ruinelli.ch/rgb-to-hsv - hsv_color hsv = {0, 0, 0}; - int min, max, delta; - - min = min3(rgb.r, rgb.g, rgb.b); - max = max3(rgb.r, rgb.g, rgb.b); - - if(max==0) { - hsv.h = 0; - hsv.s = 0; - hsv.v = 0; - return hsv; - } - - hsv.v = max; - delta = max - min; - - hsv.s = (delta)*255 / max; - - if(rgb.r == max) - hsv.h = (rgb.g - rgb.b)*42/delta; // between yellow & magenta - else if(rgb.g == max) - hsv.h = 120 + (rgb.b - rgb.r)*42/delta; // between cyan & yellow - else - hsv.h = 240 + (rgb.r - rgb.g)*42/delta; // between magenta & cyan - - return hsv; -} \ No newline at end of file diff --git a/keyboards/handwired/practice60/bluepill/hsv2rgb.h b/keyboards/handwired/practice60/bluepill/hsv2rgb.h deleted file mode 100644 index 99566c32c07e..000000000000 --- a/keyboards/handwired/practice60/bluepill/hsv2rgb.h +++ /dev/null @@ -1,23 +0,0 @@ -/* hsv2rgb.h - * Convert Hue Saturation Value to Red Green Blue - * - * Programme de convertion d'une information HSV en RGB - */ -#ifndef HSV2RGB_H -#define HSV2RGB_H - -typedef struct { - unsigned char h; - unsigned char s; - unsigned char v; -} hsv_color; - -typedef struct { - unsigned char r; - unsigned char g; - unsigned char b; -} rgb_color; - -rgb_color hsv2rgb(hsv_color hsv); - -#endif \ No newline at end of file diff --git a/keyboards/handwired/practice60/bluepill/led.c b/keyboards/handwired/practice60/bluepill/led.c deleted file mode 100644 index f15baed169d4..000000000000 --- a/keyboards/handwired/practice60/bluepill/led.c +++ /dev/null @@ -1,51 +0,0 @@ -/* -Copyright 2012 Jun Wako - -This program is free software: you can redistribute it and/or modify -it under the terms of the GNU General Public License as published by -the Free Software Foundation, either version 2 of the License, or -(at your option) any later version. - -This program is distributed in the hope that it will be useful, -but WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -GNU General Public License for more details. - -You should have received a copy of the GNU General Public License -along with this program. If not, see . -*/ - -#include "hal.h" -#include "backlight.h" -#include "led.h" -#include "printf.h" - -void backlight_init_ports(void) { - printf("backlight_init_ports()\n"); - #ifdef BACKLIGHT_ENABLE - palSetPadMode(GPIOA, 8, PAL_MODE_OUTPUT_PUSHPULL); - palSetPad(GPIOA, 8); - #endif -} - -void backlight_set(uint8_t level) { - printf("backlight_set(%d)\n", level); - #ifdef BACKLIGHT_ENABLE - if (level == 0) { - // Turn backlight off - palSetPad(GPIOA, 8); - } else { - // Turn backlight on - palClearPad(GPIOA, 8); - } - #endif -} - -void led_set(uint8_t usb_led) -{ - if (usb_led & (1< - -This program is free software: you can redistribute it and/or modify -it under the terms of the GNU General Public License as published by -the Free Software Foundation, either version 2 of the License, or -(at your option) any later version. - -This program is distributed in the hope that it will be useful, -but WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -GNU General Public License for more details. - -You should have received a copy of the GNU General Public License -along with this program. If not, see . -*/ - -#include "ch.h" -#include "hal.h" - -/* - * scan matrix - */ -#include "print.h" -#include "debug.h" -#include "util.h" -#include "matrix.h" -#include "wait.h" -#include "underglow.h" - -#ifndef DEBOUNCE -# define DEBOUNCE 5 -#endif -static uint8_t debouncing = DEBOUNCE; - -/* matrix state(1:on, 0:off) */ -static matrix_row_t matrix[MATRIX_ROWS]; -static matrix_row_t matrix_debouncing[MATRIX_ROWS]; - -static matrix_row_t read_cols(void); -static void init_cols(void); -static void unselect_rows(void); -static void select_row(uint8_t row); - - -inline -uint8_t matrix_rows(void) -{ - return MATRIX_ROWS; -} - -inline -uint8_t matrix_cols(void) -{ - return MATRIX_COLS; -} - -/* generic STM32F103C8T6 board */ -#ifdef BOARD_GENERIC_STM32_F103 -#define LED_ON() do { palClearPad(GPIOC, 13) ;} while (0) -#define LED_OFF() do { palSetPad(GPIOC, 13); } while (0) -#define LED_TGL() do { palTogglePad(GPIOC, 13); } while (0) -#endif - -__attribute__ ((weak)) -void matrix_init_kb(void) { - matrix_init_user(); -} - -__attribute__ ((weak)) -void matrix_scan_kb(void) { - matrix_scan_user(); -} - -__attribute__ ((weak)) -void matrix_init_user(void) { -} - -__attribute__ ((weak)) -void matrix_scan_user(void) { -} - -void matrix_init(void) -{ - // initialize row and col - unselect_rows(); - init_cols(); - - /* MOSI pin*/ - palSetPadMode(GPIOB, 15, PAL_MODE_STM32_ALTERNATE_PUSHPULL); - - // initialize matrix state: all keys off - for (uint8_t i=0; i < MATRIX_ROWS; i++) { - matrix[i] = 0; - matrix_debouncing[i] = 0; - } - - //debug - debug_matrix = true; - LED_ON(); - palSetPad(GPIOA, 8); - wait_ms(500); - palClearPad(GPIOA, 8); - LED_OFF(); - - leds_init(); - - matrix_init_quantum(); -} - -uint8_t matrix_scan(void) -{ - for (uint8_t i = 0; i < MATRIX_ROWS; i++) { - select_row(i); - wait_us(30); // without this wait read unstable value. - matrix_row_t cols = read_cols(); - if (matrix_debouncing[i] != cols) { - matrix_debouncing[i] = cols; - if (debouncing) { - debug("bounce!: "); debug_hex(debouncing); debug("\n"); - } - debouncing = DEBOUNCE; - } - unselect_rows(); - } - - if (debouncing) { - if (--debouncing) { - wait_ms(1); - } else { - for (uint8_t i = 0; i < MATRIX_ROWS; i++) { - matrix[i] = matrix_debouncing[i]; - } - } - } - - return 1; -} - -inline -bool matrix_is_on(uint8_t row, uint8_t col) -{ - return (matrix[row] & ((matrix_row_t)1</os/hal/ports/$(MCU_FAMILY)/$(MCU_SERIES) -MCU_FAMILY = STM32 -MCU_SERIES = STM32F1xx -# linker script to use -# it should exist either in /os/common/ports/ARMCMx/compilers/GCC/ld/ -# or /ld/ -# startup code to use -# is should exist in /os/common/ports/ARMCMx/compilers/GCC/mk/ -MCU_STARTUP = stm32f1xx -# it should exist either in /os/hal/boards/ -# or /boards -# Cortex version -# Teensy LC is cortex-m0; Teensy 3.x are cortex-m4 -MCU = cortex-m3 -# ARM version, CORTEX-M0/M1 are 6, CORTEX-M3/M4/M7 are 7 -ARMV = 7 -# If you want to be able to jump to bootloader from firmware on STM32 MCUs, -# set the correct BOOTLOADER_ADDRESS. Either set it here, or define it in -# ./bootloader_defs.h or in ./boards//bootloader_defs.h (if you have -# a custom board definition that you plan to reuse). -# If you're not setting it here, leave it commented out. -# It is chip dependent, the correct number can be looked up here (page 175): -# http://www.st.com/web/en/resource/technical/document/application_note/CD00167594.pdf -# This also requires a patch to chibios: -# /tmk_core/tool/chibios/ch-bootloader-jump.patch -#STM32_BOOTLOADER_ADDRESS = 0x1FFFC800 diff --git a/keyboards/handwired/practice60/bluepill/underglow.c b/keyboards/handwired/practice60/bluepill/underglow.c deleted file mode 100644 index 1383af18985f..000000000000 --- a/keyboards/handwired/practice60/bluepill/underglow.c +++ /dev/null @@ -1,157 +0,0 @@ -#include "ch.h" -#include "hal.h" - -#include "hsv2rgb.h" -#include "underglow.h" - -#define BYTES_FOR_LED_BYTE 4 -#define NB_COLORS 3 -#define BYTES_FOR_LED BYTES_FOR_LED_BYTE*NB_COLORS -#define DATA_SIZE BYTES_FOR_LED*NB_LEDS -#define RESET_SIZE 200 -#define PREAMBLE_SIZE 4 - -// Define the spi your LEDs are plugged to here -#define LEDS_SPI SPID2 -// Define the number of LEDs you wish to control in your LED strip -#define NB_LEDS 8 - -#define LED_SPIRAL 1 - -static uint8_t txbuf[PREAMBLE_SIZE + DATA_SIZE + RESET_SIZE]; -static uint8_t get_protocol_eq(uint8_t data, int pos); - -/* - * This lib is meant to be used asynchronously, thus the colors contained in - * the txbuf will be sent in loop, so that the colors are always the ones you - * put in the table (the user thus have less to worry about) - * - * Since the data are sent via DMA, and the call to spiSend is a blocking one, - * the processor ressources are not used to much, if you see your program being - * too slow, simply add a: - * chThdSleepMilliseconds(x); - * after the spiSend, where you increment x untill you are satisfied with your - * program speed, another trick may be to lower this thread priority : your call - */ -static THD_WORKING_AREA(LEDS_THREAD_WA, 128); -static THD_FUNCTION(ledsThread, arg) { - (void) arg; - while(1){ - spiSend(&LEDS_SPI, PREAMBLE_SIZE + DATA_SIZE + RESET_SIZE, txbuf); - } -} - -#if LED_SPIRAL -/* - * 'Led spiral' is a simple demo in which we put all the leds to the same - * color, where this color does all the hsv circle in loop. - * If you want to launch the thread that will chage the led colors to the - * appropriate value, simply set LED_SPIRAL to 1. - */ -static THD_WORKING_AREA(HSVTRANS_WA, 128); -static THD_FUNCTION(hsv_transThread, arg){ - (void) arg; - hsv_color color = {0, 255, 127}; - while(1){ - color.h += 1; - color.h %= 256; - set_leds_color_hsv(color); - chThdSleepMilliseconds(50); - } -} -#endif - -static const SPIConfig spicfg = { - NULL, - GPIOB, - 15, - SPI_CR1_BR_1|SPI_CR1_BR_0 // baudrate : fpclk / 8 => 1tick is 0.32us -}; - -/* - * Function used to initialize the driver. - * - * Starts by shutting off all the LEDs. - * Then gets access on the LED_SPI driver. - * May eventually launch an animation on the LEDs (e.g. a thread setting the - * txbuff values) - */ -void leds_init(void){ - for(int i = 0; i < RESET_SIZE; i++) - txbuf[DATA_SIZE+i] = 0x00; - for (int i=0; i. /* key matrix size */ #define MATRIX_ROWS 5 #define MATRIX_COLS 14 + +#define MATRIX_COL_PINS { B11, B10, B1, B0, A7, A6, A5, A4, A3, A2, A1, A0, C15, C14 } +#define MATRIX_ROW_PINS { B3, B4, B5, B6, B7 } #define DIODE_DIRECTION COL2ROW #define BACKLIGHT_LEVELS 1 diff --git a/keyboards/handwired/practice60/practice60.c b/keyboards/handwired/practice60/practice60.c index d76d6c47a2f0..5d0fffbd09ee 100644 --- a/keyboards/handwired/practice60/practice60.c +++ b/keyboards/handwired/practice60/practice60.c @@ -1 +1,32 @@ + #include "practice60.h" + +#include "ch.h" +#include "hal.h" + +#include "underglow.h" +#include "print.h" +#include "debug.h" +#include "util.h" + +/* generic STM32F103C8T6 board */ +#ifdef BOARD_GENERIC_STM32_F103 +#define LED_ON() do { palClearPad(GPIOC, 13) ;} while (0) +#define LED_OFF() do { palSetPad(GPIOC, 13); } while (0) +#define LED_TGL() do { palTogglePad(GPIOC, 13); } while (0) +#endif + +void matrix_init_kb(void){ + /* MOSI pin*/ + palSetPadMode(GPIOB, 15, PAL_MODE_STM32_ALTERNATE_PUSHPULL); + + LED_ON(); + palSetPad(GPIOA, 8); + wait_ms(500); + palClearPad(GPIOA, 8); + LED_OFF(); + + leds_init(); + + +} diff --git a/keyboards/handwired/practice60/rules.mk b/keyboards/handwired/practice60/rules.mk index c6c08a91acc1..915b07320c33 100644 --- a/keyboards/handwired/practice60/rules.mk +++ b/keyboards/handwired/practice60/rules.mk @@ -1,3 +1,47 @@ +# project specific files +SRC = led.c \ + underglow.c \ + hsv2rgb.c + +# GENERIC STM32F103C8T6 board - stm32duino bootloader +OPT_DEFS = -DCORTEX_VTOR_INIT=0x2000 +MCU_LDSCRIPT = STM32F103x8_stm32duino_bootloader +BOARD = GENERIC_STM32_F103 + +# OPT_DEFS = +# MCU_LDSCRIPT = STM32F103x8 +# BOARD = GENERIC_STM32_F103 + +## chip/board settings +# the next two should match the directories in +# /os/hal/ports/$(MCU_FAMILY)/$(MCU_SERIES) +MCU_FAMILY = STM32 +MCU_SERIES = STM32F1xx +# linker script to use +# it should exist either in /os/common/ports/ARMCMx/compilers/GCC/ld/ +# or /ld/ +# startup code to use +# is should exist in /os/common/ports/ARMCMx/compilers/GCC/mk/ +MCU_STARTUP = stm32f1xx +# it should exist either in /os/hal/boards/ +# or /boards +# Cortex version +# Teensy LC is cortex-m0; Teensy 3.x are cortex-m4 +MCU = cortex-m3 +# ARM version, CORTEX-M0/M1 are 6, CORTEX-M3/M4/M7 are 7 +ARMV = 7 +# If you want to be able to jump to bootloader from firmware on STM32 MCUs, +# set the correct BOOTLOADER_ADDRESS. Either set it here, or define it in +# ./bootloader_defs.h or in ./boards//bootloader_defs.h (if you have +# a custom board definition that you plan to reuse). +# If you're not setting it here, leave it commented out. +# It is chip dependent, the correct number can be looked up here (page 175): +# http://www.st.com/web/en/resource/technical/document/application_note/CD00167594.pdf +# This also requires a patch to chibios: +# /tmk_core/tool/chibios/ch-bootloader-jump.patch +#STM32_BOOTLOADER_ADDRESS = 0x1FFFC800 + + #BOOTMAGIC_ENABLE = yes # Virtual DIP switch configuration MOUSEKEY_ENABLE = yes # Mouse keys EXTRAKEY_ENABLE = yes # Audio control and System control @@ -5,9 +49,8 @@ CONSOLE_ENABLE = yes # Console for debug COMMAND_ENABLE = yes # Commands for debug and configuration SLEEP_LED_ENABLE = yes # Breathing sleep LED during USB suspend NKRO_ENABLE = yes # USB Nkey Rollover -CUSTOM_MATRIX = yes # Custom matrix file BACKLIGHT_ENABLE = yes LAYOUTS = 60_ansi -DEFAULT_FOLDER = handwired/practice60/bluepill +DEFAULT_FOLDER = handwired/practice60 From b1c017d3a1697cda5665310d82e181e6f3e3d937 Mon Sep 17 00:00:00 2001 From: Andrew Kannan Date: Mon, 12 Nov 2018 19:09:15 -0500 Subject: [PATCH 17/17] Move files --- .../handwired/practice60/bootloader_defs.h | 10 + keyboards/handwired/practice60/chconf.h | 524 ++++++++++++++++++ keyboards/handwired/practice60/halconf.h | 353 ++++++++++++ keyboards/handwired/practice60/hsv2rgb.c | 80 +++ keyboards/handwired/practice60/hsv2rgb.h | 23 + keyboards/handwired/practice60/led.c | 51 ++ keyboards/handwired/practice60/mcuconf.h | 209 +++++++ keyboards/handwired/practice60/underglow.c | 157 ++++++ keyboards/handwired/practice60/underglow.h | 10 + 9 files changed, 1417 insertions(+) create mode 100644 keyboards/handwired/practice60/bootloader_defs.h create mode 100644 keyboards/handwired/practice60/chconf.h create mode 100644 keyboards/handwired/practice60/halconf.h create mode 100644 keyboards/handwired/practice60/hsv2rgb.c create mode 100644 keyboards/handwired/practice60/hsv2rgb.h create mode 100644 keyboards/handwired/practice60/led.c create mode 100644 keyboards/handwired/practice60/mcuconf.h create mode 100644 keyboards/handwired/practice60/underglow.c create mode 100644 keyboards/handwired/practice60/underglow.h diff --git a/keyboards/handwired/practice60/bootloader_defs.h b/keyboards/handwired/practice60/bootloader_defs.h new file mode 100644 index 000000000000..0f45203cb613 --- /dev/null +++ b/keyboards/handwired/practice60/bootloader_defs.h @@ -0,0 +1,10 @@ +/* Address for jumping to bootloader on STM32 chips. */ +/* It is chip dependent, the correct number can be looked up here (page 175): + * http://www.st.com/web/en/resource/technical/document/application_note/CD00167594.pdf + * This also requires a patch to chibios: + * /tmk_core/tool/chibios/ch-bootloader-jump.patch + */ + +// STM32F103* does NOT have an USB bootloader in ROM (only serial), +// so setting anything here does not make much sense +// #define STM32_BOOTLOADER_ADDRESS 0x1FFFC800 diff --git a/keyboards/handwired/practice60/chconf.h b/keyboards/handwired/practice60/chconf.h new file mode 100644 index 000000000000..dfb1f9dfb9e6 --- /dev/null +++ b/keyboards/handwired/practice60/chconf.h @@ -0,0 +1,524 @@ +/* + ChibiOS - Copyright (C) 2006..2015 Giovanni Di Sirio + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +/** + * @file templates/chconf.h + * @brief Configuration file template. + * @details A copy of this file must be placed in each project directory, it + * contains the application specific kernel settings. + * + * @addtogroup config + * @details Kernel related settings and hooks. + * @{ + */ + +#ifndef CHCONF_H +#define CHCONF_H + +#define _CHIBIOS_RT_CONF_ + +/*===========================================================================*/ +/** + * @name System timers settings + * @{ + */ +/*===========================================================================*/ + +/** + * @brief System time counter resolution. + * @note Allowed values are 16 or 32 bits. + */ +#define CH_CFG_ST_RESOLUTION 16 + +/** + * @brief System tick frequency. + * @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 2000 + +/** + * @brief Time delta constant for the tick-less mode. + * @note If this value is zero then the system uses the classic + * periodic tick. This value represents the minimum number + * of ticks that is safe to specify in a timeout directive. + * The value one is not valid, timeouts are rounded up to + * this value. + */ +#define CH_CFG_ST_TIMEDELTA 2 + +/** @} */ + +/*===========================================================================*/ +/** + * @name Kernel parameters and options + * @{ + */ +/*===========================================================================*/ + +/** + * @brief Round robin interval. + * @details This constant is the number of system ticks allowed for the + * threads before preemption occurs. Setting this value to zero + * disables the preemption for threads with equal priority and the + * round robin becomes cooperative. Note that higher priority + * threads can still preempt, the kernel is always preemptive. + * @note Disabling the round robin preemption makes the kernel more compact + * and generally faster. + * @note The round robin preemption is not supported in tickless mode and + * must be set to zero in that case. + */ +#define CH_CFG_TIME_QUANTUM 0 + +/** + * @brief Managed RAM size. + * @details Size of the RAM area to be managed by the OS. If set to zero + * then the whole available RAM is used. The core memory is made + * available to the heap allocator and/or can be used directly through + * the simplified core memory allocator. + * + * @note In order to let the OS manage the whole RAM the linker script must + * provide the @p __heap_base__ and @p __heap_end__ symbols. + * @note Requires @p CH_CFG_USE_MEMCORE. + */ +#define CH_CFG_MEMCORE_SIZE 0 + +/** + * @brief Idle thread automatic spawn suppression. + * @details When this option is activated the function @p chSysInit() + * does not spawn the idle thread. The application @p main() + * function becomes the idle thread and must implement an + * infinite loop. + */ +#define CH_CFG_NO_IDLE_THREAD FALSE + +/* Use __WFI in the idle thread for waiting. Does lower the power + * consumption. */ +#define CORTEX_ENABLE_WFI_IDLE TRUE + +/** @} */ + +/*===========================================================================*/ +/** + * @name Performance options + * @{ + */ +/*===========================================================================*/ + +/** + * @brief OS optimization. + * @details If enabled then time efficient rather than space efficient code + * is used when two possible implementations exist. + * + * @note This is not related to the compiler optimization options. + * @note The default is @p TRUE. + */ +#define CH_CFG_OPTIMIZE_SPEED TRUE + +/** @} */ + +/*===========================================================================*/ +/** + * @name Subsystem options + * @{ + */ +/*===========================================================================*/ + +/** + * @brief Time Measurement APIs. + * @details If enabled then the time measurement APIs are included in + * the kernel. + * + * @note The default is @p TRUE. + */ +#define CH_CFG_USE_TM FALSE + +/** + * @brief Threads registry APIs. + * @details If enabled then the registry APIs are included in the kernel. + * + * @note The default is @p TRUE. + */ +#define CH_CFG_USE_REGISTRY TRUE + +/** + * @brief Threads synchronization APIs. + * @details If enabled then the @p chThdWait() function is included in + * the kernel. + * + * @note The default is @p TRUE. + */ +#define CH_CFG_USE_WAITEXIT TRUE + +/** + * @brief Semaphores APIs. + * @details If enabled then the Semaphores APIs are included in the kernel. + * + * @note The default is @p TRUE. + */ +#define CH_CFG_USE_SEMAPHORES TRUE + +/** + * @brief Semaphores queuing mode. + * @details If enabled then the threads are enqueued on semaphores by + * priority rather than in FIFO order. + * + * @note The default is @p FALSE. Enable this if you have special + * requirements. + * @note Requires @p CH_CFG_USE_SEMAPHORES. + */ +#define CH_CFG_USE_SEMAPHORES_PRIORITY FALSE + +/** + * @brief Mutexes APIs. + * @details If enabled then the mutexes APIs are included in the kernel. + * + * @note The default is @p TRUE. + */ +#define CH_CFG_USE_MUTEXES TRUE + +/** + * @brief Enables recursive behavior on mutexes. + * @note Recursive mutexes are heavier and have an increased + * memory footprint. + * + * @note The default is @p FALSE. + * @note Requires @p CH_CFG_USE_MUTEXES. + */ +#define CH_CFG_USE_MUTEXES_RECURSIVE FALSE + +/** + * @brief Conditional Variables APIs. + * @details If enabled then the conditional variables APIs are included + * in the kernel. + * + * @note The default is @p TRUE. + * @note Requires @p CH_CFG_USE_MUTEXES. + */ +#define CH_CFG_USE_CONDVARS TRUE + +/** + * @brief Conditional Variables APIs with timeout. + * @details If enabled then the conditional variables APIs with timeout + * specification are included in the kernel. + * + * @note The default is @p TRUE. + * @note Requires @p CH_CFG_USE_CONDVARS. + */ +#define CH_CFG_USE_CONDVARS_TIMEOUT FALSE + +/** + * @brief Events Flags APIs. + * @details If enabled then the event flags APIs are included in the kernel. + * + * @note The default is @p TRUE. + */ +#define CH_CFG_USE_EVENTS TRUE + +/** + * @brief Events Flags APIs with timeout. + * @details If enabled then the events APIs with timeout specification + * are included in the kernel. + * + * @note The default is @p TRUE. + * @note Requires @p CH_CFG_USE_EVENTS. + */ +#define CH_CFG_USE_EVENTS_TIMEOUT TRUE + +/** + * @brief Synchronous Messages APIs. + * @details If enabled then the synchronous messages APIs are included + * in the kernel. + * + * @note The default is @p TRUE. + */ +#define CH_CFG_USE_MESSAGES TRUE + +/** + * @brief Synchronous Messages queuing mode. + * @details If enabled then messages are served by priority rather than in + * FIFO order. + * + * @note The default is @p FALSE. Enable this if you have special + * requirements. + * @note Requires @p CH_CFG_USE_MESSAGES. + */ +#define CH_CFG_USE_MESSAGES_PRIORITY FALSE + +/** + * @brief Mailboxes APIs. + * @details If enabled then the asynchronous messages (mailboxes) APIs are + * included in the kernel. + * + * @note The default is @p TRUE. + * @note Requires @p CH_CFG_USE_SEMAPHORES. + */ +#define CH_CFG_USE_MAILBOXES TRUE + +/** + * @brief Core Memory Manager APIs. + * @details If enabled then the core memory manager APIs are included + * in the kernel. + * + * @note The default is @p TRUE. + */ +#define CH_CFG_USE_MEMCORE TRUE + +/** + * @brief Heap Allocator APIs. + * @details If enabled then the memory heap allocator APIs are included + * in the kernel. + * + * @note The default is @p TRUE. + * @note Requires @p CH_CFG_USE_MEMCORE and either @p CH_CFG_USE_MUTEXES or + * @p CH_CFG_USE_SEMAPHORES. + * @note Mutexes are recommended. + */ +#define CH_CFG_USE_HEAP TRUE + +/** + * @brief Memory Pools Allocator APIs. + * @details If enabled then the memory pools allocator APIs are included + * in the kernel. + * + * @note The default is @p TRUE. + */ +#define CH_CFG_USE_MEMPOOLS FALSE + +/** + * @brief Dynamic Threads APIs. + * @details If enabled then the dynamic threads creation APIs are included + * in the kernel. + * + * @note The default is @p TRUE. + * @note Requires @p CH_CFG_USE_WAITEXIT. + * @note Requires @p CH_CFG_USE_HEAP and/or @p CH_CFG_USE_MEMPOOLS. + */ +#define CH_CFG_USE_DYNAMIC FALSE + +/** @} */ + +/*===========================================================================*/ +/** + * @name Debug options + * @{ + */ +/*===========================================================================*/ + +/** + * @brief Debug option, kernel statistics. + * + * @note The default is @p FALSE. + */ +#define CH_DBG_STATISTICS FALSE + +/** + * @brief Debug option, system state check. + * @details If enabled the correct call protocol for system APIs is checked + * at runtime. + * + * @note The default is @p FALSE. + */ +#define CH_DBG_SYSTEM_STATE_CHECK FALSE + +/** + * @brief Debug option, parameters checks. + * @details If enabled then the checks on the API functions input + * parameters are activated. + * + * @note The default is @p FALSE. + */ +#define CH_DBG_ENABLE_CHECKS FALSE + +/** + * @brief Debug option, consistency checks. + * @details If enabled then all the assertions in the kernel code are + * activated. This includes consistency checks inside the kernel, + * runtime anomalies and port-defined checks. + * + * @note The default is @p FALSE. + */ +#define CH_DBG_ENABLE_ASSERTS FALSE + +/** + * @brief Debug option, trace buffer. + * @details If enabled then the trace buffer is activated. + * + * @note The default is @p CH_DBG_TRACE_MASK_DISABLED. + */ +#define CH_DBG_TRACE_MASK CH_DBG_TRACE_MASK_DISABLED + +/** + * @brief Trace buffer entries. + * @note The trace buffer is only allocated if @p CH_DBG_TRACE_MASK is + * different from @p CH_DBG_TRACE_MASK_DISABLED. + */ +#define CH_DBG_TRACE_BUFFER_SIZE 128 + +/** + * @brief Debug option, stack checks. + * @details If enabled then a runtime stack check is performed. + * + * @note The default is @p FALSE. + * @note The stack check is performed in a architecture/port dependent way. + * It may not be implemented or some ports. + * @note The default failure mode is to halt the system with the global + * @p panic_msg variable set to @p NULL. + */ +#define CH_DBG_ENABLE_STACK_CHECK FALSE + +/** + * @brief Debug option, stacks initialization. + * @details If enabled then the threads working area is filled with a byte + * value when a thread is created. This can be useful for the + * runtime measurement of the used stack. + * + * @note The default is @p FALSE. + */ +#define CH_DBG_FILL_THREADS FALSE + +/** + * @brief Debug option, threads profiling. + * @details If enabled then a field is added to the @p thread_t structure that + * counts the system ticks occurred while executing the thread. + * + * @note The default is @p FALSE. + * @note This debug option is not currently compatible with the + * tickless mode. + */ +#define CH_DBG_THREADS_PROFILING FALSE + +/** @} */ + +/*===========================================================================*/ +/** + * @name Kernel hooks + * @{ + */ +/*===========================================================================*/ + +/** + * @brief Threads descriptor structure extension. + * @details User fields added to the end of the @p thread_t structure. + */ +#define CH_CFG_THREAD_EXTRA_FIELDS \ + /* Add threads custom fields here.*/ + +/** + * @brief Threads initialization hook. + * @details User initialization code added to the @p chThdInit() API. + * + * @note It is invoked from within @p chThdInit() and implicitly from all + * the threads creation APIs. + */ +#define CH_CFG_THREAD_INIT_HOOK(tp) { \ + /* Add threads initialization code here.*/ \ +} + +/** + * @brief Threads finalization hook. + * @details User finalization code added to the @p chThdExit() API. + */ +#define CH_CFG_THREAD_EXIT_HOOK(tp) { \ + /* Add threads finalization code here.*/ \ +} + +/** + * @brief Context switch hook. + * @details This hook is invoked just before switching between threads. + */ +#define CH_CFG_CONTEXT_SWITCH_HOOK(ntp, otp) { \ + /* Context switch code here.*/ \ +} + +/** + * @brief ISR enter hook. + */ +#define CH_CFG_IRQ_PROLOGUE_HOOK() { \ + /* IRQ prologue code here.*/ \ +} + +/** + * @brief ISR exit hook. + */ +#define CH_CFG_IRQ_EPILOGUE_HOOK() { \ + /* IRQ epilogue code here.*/ \ +} + +/** + * @brief Idle thread enter hook. + * @note This hook is invoked within a critical zone, no OS functions + * should be invoked from here. + * @note This macro can be used to activate a power saving mode. + */ +#define CH_CFG_IDLE_ENTER_HOOK() { \ + /* Idle-enter code here.*/ \ +} + +/** + * @brief Idle thread leave hook. + * @note This hook is invoked within a critical zone, no OS functions + * should be invoked from here. + * @note This macro can be used to deactivate a power saving mode. + */ +#define CH_CFG_IDLE_LEAVE_HOOK() { \ + /* Idle-leave code here.*/ \ +} + +/** + * @brief Idle Loop hook. + * @details This hook is continuously invoked by the idle thread loop. + */ +#define CH_CFG_IDLE_LOOP_HOOK() { \ + /* Idle loop code here.*/ \ +} + +/** + * @brief System tick event hook. + * @details This hook is invoked in the system tick handler immediately + * after processing the virtual timers queue. + */ +#define CH_CFG_SYSTEM_TICK_HOOK() { \ + /* System tick event code here.*/ \ +} + +/** + * @brief System halt hook. + * @details This hook is invoked in case to a system halting error before + * the system is halted. + */ +#define CH_CFG_SYSTEM_HALT_HOOK(reason) { \ + /* System halt code here.*/ \ +} + +/** + * @brief Trace hook. + * @details This hook is invoked each time a new record is written in the + * trace buffer. + */ +#define CH_CFG_TRACE_HOOK(tep) { \ + /* Trace code here.*/ \ +} + +/** @} */ + +/*===========================================================================*/ +/* Port-specific settings (override port settings defaulted in chcore.h). */ +/*===========================================================================*/ + +#endif /* CHCONF_H */ + +/** @} */ diff --git a/keyboards/handwired/practice60/halconf.h b/keyboards/handwired/practice60/halconf.h new file mode 100644 index 000000000000..5fba285a380d --- /dev/null +++ b/keyboards/handwired/practice60/halconf.h @@ -0,0 +1,353 @@ +/* + ChibiOS - Copyright (C) 2006..2015 Giovanni Di Sirio + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +/** + * @file templates/halconf.h + * @brief HAL configuration header. + * @details HAL configuration file, this file allows to enable or disable the + * various device drivers from your application. You may also use + * this file in order to override the device drivers default settings. + * + * @addtogroup HAL_CONF + * @{ + */ + +#ifndef _HALCONF_H_ +#define _HALCONF_H_ + +#include "mcuconf.h" + +/** + * @brief Enables the PAL subsystem. + */ +#if !defined(HAL_USE_PAL) || defined(__DOXYGEN__) +#define HAL_USE_PAL TRUE +#endif + +/** + * @brief Enables the ADC subsystem. + */ +#if !defined(HAL_USE_ADC) || defined(__DOXYGEN__) +#define HAL_USE_ADC FALSE +#endif + +/** + * @brief Enables the CAN subsystem. + */ +#if !defined(HAL_USE_CAN) || defined(__DOXYGEN__) +#define HAL_USE_CAN FALSE +#endif + +/** + * @brief Enables the DAC subsystem. + */ +#if !defined(HAL_USE_DAC) || defined(__DOXYGEN__) +#define HAL_USE_DAC FALSE +#endif + +/** + * @brief Enables the EXT subsystem. + */ +#if !defined(HAL_USE_EXT) || defined(__DOXYGEN__) +#define HAL_USE_EXT FALSE +#endif + +/** + * @brief Enables the GPT subsystem. + */ +#if !defined(HAL_USE_GPT) || defined(__DOXYGEN__) +#define HAL_USE_GPT FALSE +#endif + +/** + * @brief Enables the I2C subsystem. + */ +#if !defined(HAL_USE_I2C) || defined(__DOXYGEN__) +#define HAL_USE_I2C FALSE +#endif + +/** + * @brief Enables the I2S subsystem. + */ +#if !defined(HAL_USE_I2S) || defined(__DOXYGEN__) +#define HAL_USE_I2S FALSE +#endif + +/** + * @brief Enables the ICU subsystem. + */ +#if !defined(HAL_USE_ICU) || defined(__DOXYGEN__) +#define HAL_USE_ICU FALSE +#endif + +/** + * @brief Enables the MAC subsystem. + */ +#if !defined(HAL_USE_MAC) || defined(__DOXYGEN__) +#define HAL_USE_MAC FALSE +#endif + +/** + * @brief Enables the MMC_SPI subsystem. + */ +#if !defined(HAL_USE_MMC_SPI) || defined(__DOXYGEN__) +#define HAL_USE_MMC_SPI FALSE +#endif + +/** + * @brief Enables the PWM subsystem. + */ +#if !defined(HAL_USE_PWM) || defined(__DOXYGEN__) +#define HAL_USE_PWM FALSE +#endif + +/** + * @brief Enables the RTC subsystem. + */ +#if !defined(HAL_USE_RTC) || defined(__DOXYGEN__) +#define HAL_USE_RTC FALSE +#endif + +/** + * @brief Enables the SDC subsystem. + */ +#if !defined(HAL_USE_SDC) || defined(__DOXYGEN__) +#define HAL_USE_SDC FALSE +#endif + +/** + * @brief Enables the SERIAL subsystem. + */ +#if !defined(HAL_USE_SERIAL) || defined(__DOXYGEN__) +#define HAL_USE_SERIAL FALSE +#endif + +/** + * @brief Enables the SERIAL over USB subsystem. + */ +#if !defined(HAL_USE_SERIAL_USB) || defined(__DOXYGEN__) +#define HAL_USE_SERIAL_USB FALSE +#endif + +/** + * @brief Enables the SPI subsystem. + */ +#if !defined(HAL_USE_SPI) || defined(__DOXYGEN__) +#define HAL_USE_SPI TRUE +#endif + +/** + * @brief Enables the UART subsystem. + */ +#if !defined(HAL_USE_UART) || defined(__DOXYGEN__) +#define HAL_USE_UART FALSE +#endif + +/** + * @brief Enables the USB subsystem. + */ +#if !defined(HAL_USE_USB) || defined(__DOXYGEN__) +#define HAL_USE_USB TRUE +#endif + +/** + * @brief Enables the WDG subsystem. + */ +#if !defined(HAL_USE_WDG) || defined(__DOXYGEN__) +#define HAL_USE_WDG FALSE +#endif + +/*===========================================================================*/ +/* ADC driver related settings. */ +/*===========================================================================*/ + +/** + * @brief Enables synchronous APIs. + * @note Disabling this option saves both code and data space. + */ +#if !defined(ADC_USE_WAIT) || defined(__DOXYGEN__) +#define ADC_USE_WAIT TRUE +#endif + +/** + * @brief Enables the @p adcAcquireBus() and @p adcReleaseBus() APIs. + * @note Disabling this option saves both code and data space. + */ +#if !defined(ADC_USE_MUTUAL_EXCLUSION) || defined(__DOXYGEN__) +#define ADC_USE_MUTUAL_EXCLUSION TRUE +#endif + +/*===========================================================================*/ +/* CAN driver related settings. */ +/*===========================================================================*/ + +/** + * @brief Sleep mode related APIs inclusion switch. + */ +#if !defined(CAN_USE_SLEEP_MODE) || defined(__DOXYGEN__) +#define CAN_USE_SLEEP_MODE TRUE +#endif + +/*===========================================================================*/ +/* I2C driver related settings. */ +/*===========================================================================*/ + +/** + * @brief Enables the mutual exclusion APIs on the I2C bus. + */ +#if !defined(I2C_USE_MUTUAL_EXCLUSION) || defined(__DOXYGEN__) +#define I2C_USE_MUTUAL_EXCLUSION TRUE +#endif + +/*===========================================================================*/ +/* MAC driver related settings. */ +/*===========================================================================*/ + +/** + * @brief Enables an event sources for incoming packets. + */ +#if !defined(MAC_USE_ZERO_COPY) || defined(__DOXYGEN__) +#define MAC_USE_ZERO_COPY FALSE +#endif + +/** + * @brief Enables an event sources for incoming packets. + */ +#if !defined(MAC_USE_EVENTS) || defined(__DOXYGEN__) +#define MAC_USE_EVENTS TRUE +#endif + +/*===========================================================================*/ +/* MMC_SPI driver related settings. */ +/*===========================================================================*/ + +/** + * @brief Delays insertions. + * @details If enabled this options inserts delays into the MMC waiting + * routines releasing some extra CPU time for the threads with + * lower priority, this may slow down the driver a bit however. + * This option is recommended also if the SPI driver does not + * use a DMA channel and heavily loads the CPU. + */ +#if !defined(MMC_NICE_WAITING) || defined(__DOXYGEN__) +#define MMC_NICE_WAITING TRUE +#endif + +/*===========================================================================*/ +/* SDC driver related settings. */ +/*===========================================================================*/ + +/** + * @brief Number of initialization attempts before rejecting the card. + * @note Attempts are performed at 10mS intervals. + */ +#if !defined(SDC_INIT_RETRY) || defined(__DOXYGEN__) +#define SDC_INIT_RETRY 100 +#endif + +/** + * @brief Include support for MMC cards. + * @note MMC support is not yet implemented so this option must be kept + * at @p FALSE. + */ +#if !defined(SDC_MMC_SUPPORT) || defined(__DOXYGEN__) +#define SDC_MMC_SUPPORT FALSE +#endif + +/** + * @brief Delays insertions. + * @details If enabled this options inserts delays into the MMC waiting + * routines releasing some extra CPU time for the threads with + * lower priority, this may slow down the driver a bit however. + */ +#if !defined(SDC_NICE_WAITING) || defined(__DOXYGEN__) +#define SDC_NICE_WAITING TRUE +#endif + +/*===========================================================================*/ +/* SERIAL driver related settings. */ +/*===========================================================================*/ + +/** + * @brief Default bit rate. + * @details Configuration parameter, this is the baud rate selected for the + * default configuration. + */ +#if !defined(SERIAL_DEFAULT_BITRATE) || defined(__DOXYGEN__) +#define SERIAL_DEFAULT_BITRATE 38400 +#endif + +/** + * @brief Serial buffers size. + * @details Configuration parameter, you can change the depth of the queue + * buffers depending on the requirements of your application. + * @note The default is 64 bytes for both the transmission and receive + * buffers. + */ +#if !defined(SERIAL_BUFFERS_SIZE) || defined(__DOXYGEN__) +#define SERIAL_BUFFERS_SIZE 16 +#endif + +/*===========================================================================*/ +/* SERIAL_USB driver related setting. */ +/*===========================================================================*/ + +/** + * @brief Serial over USB buffers size. + * @details Configuration parameter, the buffer size must be a multiple of + * the USB data endpoint maximum packet size. + * @note The default is 64 bytes for both the transmission and receive + * buffers. + */ +#if !defined(SERIAL_USB_BUFFERS_SIZE) || defined(__DOXYGEN__) +#define SERIAL_USB_BUFFERS_SIZE 1 +#endif + +/*===========================================================================*/ +/* SPI driver related settings. */ +/*===========================================================================*/ + +/** + * @brief Enables synchronous APIs. + * @note Disabling this option saves both code and data space. + */ +#if !defined(SPI_USE_WAIT) || defined(__DOXYGEN__) +#define SPI_USE_WAIT TRUE +#endif + +/** + * @brief Enables the @p spiAcquireBus() and @p spiReleaseBus() APIs. + * @note Disabling this option saves both code and data space. + */ +#if !defined(SPI_USE_MUTUAL_EXCLUSION) || defined(__DOXYGEN__) +#define SPI_USE_MUTUAL_EXCLUSION TRUE +#endif + +/*===========================================================================*/ +/* USB driver related settings. */ +/*===========================================================================*/ + +/** + * @brief Enables synchronous APIs. + * @note Disabling this option saves both code and data space. + */ +#if !defined(USB_USE_WAIT) || defined(__DOXYGEN__) +#define USB_USE_WAIT TRUE +#endif + +#endif /* _HALCONF_H_ */ + +/** @} */ diff --git a/keyboards/handwired/practice60/hsv2rgb.c b/keyboards/handwired/practice60/hsv2rgb.c new file mode 100644 index 000000000000..adb7af8fa57e --- /dev/null +++ b/keyboards/handwired/practice60/hsv2rgb.c @@ -0,0 +1,80 @@ +/* hsv2rgb.c + * Integer only conversion functions between HSV and RGB + */ + +#include "hsv2rgb.h" + +// TODO fix these buggy macros +#define max(x,y) ((x>y) ? x:y) +#define min(x,y) ((x>y) ? y:x) +#define min3(x,y,z) (min(min(x,y),z)) +#define max3(x,y,z) (max(max(x,y),z)) + + +rgb_color hsv2rgb(hsv_color hsv) +{ + // From : http://qscribble.blogspot.fr/2008/06/integer-conversion-from-hsl-to-rgb.html + int h = hsv.h; + int s = hsv.s; + int v = hsv.v; + rgb_color rgb = {0, 0, 0}; + + if (v == 0) + return rgb; + + // sextant = 0 .. 5 + int sextant = (h*6)/256; + // f = 0 .. 42 + int f = h - (sextant*256)/6; + + int p = (v * (256 - s))/256; + int q = (v * (256*43 - s*f))/(256*43); + int t = (v * (256*43 - s*(43-f)))/(256*43); + + // Corrige les erreurs dues aux arrondis + p = max(min(p, 255), 0); + q = max(min(q, 255), 0); + t = max(min(t, 255), 0); + + switch(sextant){ + case 0: rgb.r = v; rgb.g = t; rgb.b = p; break; + case 1: rgb.r = q; rgb.g = v; rgb.b = p; break; + case 2: rgb.r = p; rgb.g = v; rgb.b = t; break; + case 3: rgb.r = p; rgb.g = q; rgb.b = v; break; + case 4: rgb.r = t; rgb.g = p; rgb.b = v; break; + default:rgb.r = v; rgb.g = p; rgb.b = q; break; + } + return rgb; +} + + +hsv_color rgb2hsv(rgb_color rgb) +{ + // From : http://www.ruinelli.ch/rgb-to-hsv + hsv_color hsv = {0, 0, 0}; + int min, max, delta; + + min = min3(rgb.r, rgb.g, rgb.b); + max = max3(rgb.r, rgb.g, rgb.b); + + if(max==0) { + hsv.h = 0; + hsv.s = 0; + hsv.v = 0; + return hsv; + } + + hsv.v = max; + delta = max - min; + + hsv.s = (delta)*255 / max; + + if(rgb.r == max) + hsv.h = (rgb.g - rgb.b)*42/delta; // between yellow & magenta + else if(rgb.g == max) + hsv.h = 120 + (rgb.b - rgb.r)*42/delta; // between cyan & yellow + else + hsv.h = 240 + (rgb.r - rgb.g)*42/delta; // between magenta & cyan + + return hsv; +} \ No newline at end of file diff --git a/keyboards/handwired/practice60/hsv2rgb.h b/keyboards/handwired/practice60/hsv2rgb.h new file mode 100644 index 000000000000..99566c32c07e --- /dev/null +++ b/keyboards/handwired/practice60/hsv2rgb.h @@ -0,0 +1,23 @@ +/* hsv2rgb.h + * Convert Hue Saturation Value to Red Green Blue + * + * Programme de convertion d'une information HSV en RGB + */ +#ifndef HSV2RGB_H +#define HSV2RGB_H + +typedef struct { + unsigned char h; + unsigned char s; + unsigned char v; +} hsv_color; + +typedef struct { + unsigned char r; + unsigned char g; + unsigned char b; +} rgb_color; + +rgb_color hsv2rgb(hsv_color hsv); + +#endif \ No newline at end of file diff --git a/keyboards/handwired/practice60/led.c b/keyboards/handwired/practice60/led.c new file mode 100644 index 000000000000..f15baed169d4 --- /dev/null +++ b/keyboards/handwired/practice60/led.c @@ -0,0 +1,51 @@ +/* +Copyright 2012 Jun Wako + +This program is free software: you can redistribute it and/or modify +it under the terms of the GNU General Public License as published by +the Free Software Foundation, either version 2 of the License, or +(at your option) any later version. + +This program is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU General Public License for more details. + +You should have received a copy of the GNU General Public License +along with this program. If not, see . +*/ + +#include "hal.h" +#include "backlight.h" +#include "led.h" +#include "printf.h" + +void backlight_init_ports(void) { + printf("backlight_init_ports()\n"); + #ifdef BACKLIGHT_ENABLE + palSetPadMode(GPIOA, 8, PAL_MODE_OUTPUT_PUSHPULL); + palSetPad(GPIOA, 8); + #endif +} + +void backlight_set(uint8_t level) { + printf("backlight_set(%d)\n", level); + #ifdef BACKLIGHT_ENABLE + if (level == 0) { + // Turn backlight off + palSetPad(GPIOA, 8); + } else { + // Turn backlight on + palClearPad(GPIOA, 8); + } + #endif +} + +void led_set(uint8_t usb_led) +{ + if (usb_led & (1< 1tick is 0.32us +}; + +/* + * Function used to initialize the driver. + * + * Starts by shutting off all the LEDs. + * Then gets access on the LED_SPI driver. + * May eventually launch an animation on the LEDs (e.g. a thread setting the + * txbuff values) + */ +void leds_init(void){ + for(int i = 0; i < RESET_SIZE; i++) + txbuf[DATA_SIZE+i] = 0x00; + for (int i=0; i