mirror of
https://github.com/qmk/qmk_firmware
synced 2024-11-18 09:55:48 +00:00
adding noah keyboard (#7432)
* adding noah keyboard * Update keyboards/matrix/noah/config.h Co-Authored-By: Drashna Jaelre <drashna@live.com> * Update keyboards/matrix/noah/noah.c Co-Authored-By: Drashna Jaelre <drashna@live.com>
This commit is contained in:
parent
2b318ba01b
commit
265c415f5e
21 changed files with 5464 additions and 0 deletions
131
keyboards/matrix/noah/boards/noah_bd/board.c
Normal file
131
keyboards/matrix/noah/boards/noah_bd/board.c
Normal file
|
@ -0,0 +1,131 @@
|
|||
/*
|
||||
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.
|
||||
*/
|
||||
|
||||
/*
|
||||
* This file has been automatically generated using ChibiStudio board
|
||||
* generator plugin. Do not edit manually.
|
||||
*/
|
||||
|
||||
#include "hal.h"
|
||||
|
||||
#if HAL_USE_PAL || defined(__DOXYGEN__)
|
||||
/**
|
||||
* @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.
|
||||
*/
|
||||
const PALConfig pal_default_config = {
|
||||
#if STM32_HAS_GPIOA
|
||||
{VAL_GPIOA_MODER, VAL_GPIOA_OTYPER, VAL_GPIOA_OSPEEDR, VAL_GPIOA_PUPDR,
|
||||
VAL_GPIOA_ODR, VAL_GPIOA_AFRL, VAL_GPIOA_AFRH},
|
||||
#endif
|
||||
#if STM32_HAS_GPIOB
|
||||
{VAL_GPIOB_MODER, VAL_GPIOB_OTYPER, VAL_GPIOB_OSPEEDR, VAL_GPIOB_PUPDR,
|
||||
VAL_GPIOB_ODR, VAL_GPIOB_AFRL, VAL_GPIOB_AFRH},
|
||||
#endif
|
||||
#if STM32_HAS_GPIOC
|
||||
{VAL_GPIOC_MODER, VAL_GPIOC_OTYPER, VAL_GPIOC_OSPEEDR, VAL_GPIOC_PUPDR,
|
||||
VAL_GPIOC_ODR, VAL_GPIOC_AFRL, VAL_GPIOC_AFRH},
|
||||
#endif
|
||||
#if STM32_HAS_GPIOD
|
||||
{VAL_GPIOD_MODER, VAL_GPIOD_OTYPER, VAL_GPIOD_OSPEEDR, VAL_GPIOD_PUPDR,
|
||||
VAL_GPIOD_ODR, VAL_GPIOD_AFRL, VAL_GPIOD_AFRH},
|
||||
#endif
|
||||
#if STM32_HAS_GPIOE
|
||||
{VAL_GPIOE_MODER, VAL_GPIOE_OTYPER, VAL_GPIOE_OSPEEDR, VAL_GPIOE_PUPDR,
|
||||
VAL_GPIOE_ODR, VAL_GPIOE_AFRL, VAL_GPIOE_AFRH},
|
||||
#endif
|
||||
#if STM32_HAS_GPIOF
|
||||
{VAL_GPIOF_MODER, VAL_GPIOF_OTYPER, VAL_GPIOF_OSPEEDR, VAL_GPIOF_PUPDR,
|
||||
VAL_GPIOF_ODR, VAL_GPIOF_AFRL, VAL_GPIOF_AFRH},
|
||||
#endif
|
||||
#if STM32_HAS_GPIOG
|
||||
{VAL_GPIOG_MODER, VAL_GPIOG_OTYPER, VAL_GPIOG_OSPEEDR, VAL_GPIOG_PUPDR,
|
||||
VAL_GPIOG_ODR, VAL_GPIOG_AFRL, VAL_GPIOG_AFRH},
|
||||
#endif
|
||||
#if STM32_HAS_GPIOH
|
||||
{VAL_GPIOH_MODER, VAL_GPIOH_OTYPER, VAL_GPIOH_OSPEEDR, VAL_GPIOH_PUPDR,
|
||||
VAL_GPIOH_ODR, VAL_GPIOH_AFRL, VAL_GPIOH_AFRH},
|
||||
#endif
|
||||
#if STM32_HAS_GPIOI
|
||||
{VAL_GPIOI_MODER, VAL_GPIOI_OTYPER, VAL_GPIOI_OSPEEDR, VAL_GPIOI_PUPDR,
|
||||
VAL_GPIOI_ODR, VAL_GPIOI_AFRL, VAL_GPIOI_AFRH}
|
||||
#endif
|
||||
};
|
||||
#endif
|
||||
|
||||
void enter_bootloader_mode_if_requested(void);
|
||||
|
||||
/**
|
||||
* @brief Early initialization code.
|
||||
* @details This initialization must be performed just after stack setup
|
||||
* and before any other initialization.
|
||||
*/
|
||||
void __early_init(void) {
|
||||
enter_bootloader_mode_if_requested();
|
||||
stm32_clock_init();
|
||||
}
|
||||
|
||||
#if HAL_USE_SDC || defined(__DOXYGEN__)
|
||||
/**
|
||||
* @brief SDC card detection.
|
||||
*/
|
||||
bool sdc_lld_is_card_inserted(SDCDriver *sdcp) {
|
||||
|
||||
(void)sdcp;
|
||||
/* TODO: Fill the implementation.*/
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief SDC card write protection detection.
|
||||
*/
|
||||
bool sdc_lld_is_write_protected(SDCDriver *sdcp) {
|
||||
|
||||
(void)sdcp;
|
||||
/* TODO: Fill the implementation.*/
|
||||
return false;
|
||||
}
|
||||
#endif /* HAL_USE_SDC */
|
||||
|
||||
#if HAL_USE_MMC_SPI || defined(__DOXYGEN__)
|
||||
/**
|
||||
* @brief MMC_SPI card detection.
|
||||
*/
|
||||
bool mmc_lld_is_card_inserted(MMCDriver *mmcp) {
|
||||
|
||||
(void)mmcp;
|
||||
/* TODO: Fill the implementation.*/
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief MMC_SPI card write protection detection.
|
||||
*/
|
||||
bool mmc_lld_is_write_protected(MMCDriver *mmcp) {
|
||||
|
||||
(void)mmcp;
|
||||
/* TODO: Fill the implementation.*/
|
||||
return false;
|
||||
}
|
||||
#endif
|
||||
|
||||
/**
|
||||
* @brief Board-specific initialization code.
|
||||
* @todo Add your board-specific code, if any.
|
||||
*/
|
||||
void boardInit(void) {
|
||||
}
|
1336
keyboards/matrix/noah/boards/noah_bd/board.h
Normal file
1336
keyboards/matrix/noah/boards/noah_bd/board.h
Normal file
File diff suppressed because it is too large
Load diff
5
keyboards/matrix/noah/boards/noah_bd/board.mk
Normal file
5
keyboards/matrix/noah/boards/noah_bd/board.mk
Normal file
|
@ -0,0 +1,5 @@
|
|||
# List of all the board related files.
|
||||
BOARDSRC = $(BOARD_PATH)/boards/noah_bd/board.c
|
||||
|
||||
# Required include directories
|
||||
BOARDINC = $(BOARD_PATH)/boards/noah_bd
|
7
keyboards/matrix/noah/bootloader_defs.h
Normal file
7
keyboards/matrix/noah/bootloader_defs.h
Normal file
|
@ -0,0 +1,7 @@
|
|||
/* Address for jumping to bootloader on STM32 chips. */
|
||||
/* It is chip dependent, the correct number can be looked up here:
|
||||
* http://www.st.com/web/en/resource/technical/document/application_note/CD00167594.pdf
|
||||
* This also requires a patch to chibios:
|
||||
* <tmk_dir>/tmk_core/tool/chibios/ch-bootloader-jump.patch
|
||||
*/
|
||||
#define STM32_BOOTLOADER_ADDRESS 0x1FFF0000
|
527
keyboards/matrix/noah/chconf.h
Normal file
527
keyboards/matrix/noah/chconf.h
Normal file
|
@ -0,0 +1,527 @@
|
|||
/*
|
||||
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.
|
||||
*/
|
||||
|
||||
/**
|
||||
* @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 32
|
||||
|
||||
/**
|
||||
* @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 10000
|
||||
|
||||
/**
|
||||
* @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 TRUE
|
||||
|
||||
/**
|
||||
* @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 TRUE
|
||||
|
||||
/**
|
||||
* @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 TRUE
|
||||
|
||||
/**
|
||||
* @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 TRUE
|
||||
|
||||
/** @} */
|
||||
|
||||
/*===========================================================================*/
|
||||
/**
|
||||
* @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.*/ \
|
||||
}
|
||||
|
||||
#define ARM_WFI_IMPL __WFI
|
||||
|
||||
/**
|
||||
* @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 */
|
||||
|
||||
/** @} */
|
54
keyboards/matrix/noah/config.h
Normal file
54
keyboards/matrix/noah/config.h
Normal file
|
@ -0,0 +1,54 @@
|
|||
/**
|
||||
* config.h
|
||||
*
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
/* USB Device descriptor parameter */
|
||||
#define VENDOR_ID 0x4D58 // MX
|
||||
#define PRODUCT_ID 0x0065 // noah 65
|
||||
#define DEVICE_VER 0x0001
|
||||
#define MANUFACTURER matrix
|
||||
#define PRODUCT NOAH
|
||||
#define DESCRIPTION 65% keybaord of the Matrix abel family
|
||||
|
||||
/* key matrix size */
|
||||
#define MATRIX_ROWS 5
|
||||
#define MATRIX_COLS 15
|
||||
|
||||
#define DIODE_DIRECTION COL2ROW
|
||||
#define DEBOUNCING_DELAY 5
|
||||
|
||||
// i2c setting
|
||||
#define USE_I2CV1
|
||||
#define I2C1_SCL 8
|
||||
#define I2C1_SDA 9
|
||||
#define I2C1_CLOCK_SPEED 400000
|
||||
#define I2C1_DUTY_CYCLE FAST_DUTY_CYCLE_2
|
||||
#define PAL_MODE_STM32_ALTERNATE_OPENDRAIN (PAL_MODE_ALTERNATE(4) | PAL_STM32_OTYPE_OPENDRAIN)
|
||||
|
||||
// rgb matrix setting
|
||||
#define DRIVER_ADDR_1 0b1110100
|
||||
#define DRIVER_ADDR_2 0b1110110
|
||||
#define DRIVER_COUNT 2
|
||||
#define DRIVER_1_LED_TOTAL 36
|
||||
#define DRIVER_2_LED_TOTAL 36
|
||||
#define DRIVER_LED_TOTAL (DRIVER_1_LED_TOTAL + DRIVER_2_LED_TOTAL)
|
||||
|
||||
/* indicator rgb */
|
||||
#define WS2812_LED_N 7
|
||||
#define RGBLED_NUM WS2812_LED_N
|
||||
#define WS2812_TIM_N 3
|
||||
#define WS2812_TIM_CH 3
|
||||
#define PORT_WS2812 GPIOB
|
||||
#define PIN_WS2812 1
|
||||
#define WS2812_DMA_STREAM STM32_DMA1_STREAM2 // DMA stream for TIMx_UP (look up in reference manual under DMA Channel selection)
|
||||
#define WS2812_DMA_CHANNEL 5 // DMA channel for TIMx_UP
|
||||
#define RGBLIGHT_ANIMATIONS
|
||||
//#define WS2812_EXTERNAL_PULLUP
|
||||
|
||||
// tapping setting
|
||||
#define TAPPING_TERM 200
|
||||
#define RETRO_TAPPING
|
||||
#define PERMISSIVE_HOLD
|
822
keyboards/matrix/noah/eeprom_f4.c
Normal file
822
keyboards/matrix/noah/eeprom_f4.c
Normal file
|
@ -0,0 +1,822 @@
|
|||
/**
|
||||
******************************************************************************
|
||||
* @file EEPROM/EEPROM_Emulation/src/eeprom.c
|
||||
* @author MCD Application Team
|
||||
* @brief This file provides all the EEPROM emulation firmware functions.
|
||||
******************************************************************************
|
||||
* @attention
|
||||
*
|
||||
* <h2><center>© Copyright <EFBFBD> 2017 STMicroelectronics International N.V.
|
||||
* All rights reserved.</center></h2>
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted, provided that the following conditions are met:
|
||||
*
|
||||
* 1. Redistribution of source code must retain the above copyright notice,
|
||||
* this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright notice,
|
||||
* this list of conditions and the following disclaimer in the documentation
|
||||
* and/or other materials provided with the distribution.
|
||||
* 3. Neither the name of STMicroelectronics nor the names of other
|
||||
* contributors to this software may be used to endorse or promote products
|
||||
* derived from this software without specific written permission.
|
||||
* 4. This software, including modifications and/or derivative works of this
|
||||
* software, must execute solely and exclusively on microcontroller or
|
||||
* microprocessor devices manufactured by or for STMicroelectronics.
|
||||
* 5. Redistribution and use of this software other than as permitted under
|
||||
* this license is void and will automatically terminate your rights under
|
||||
* this license.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY STMICROELECTRONICS AND CONTRIBUTORS "AS IS"
|
||||
* AND ANY EXPRESS, IMPLIED OR STATUTORY WARRANTIES, INCLUDING, BUT NOT
|
||||
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS FOR A
|
||||
* PARTICULAR PURPOSE AND NON-INFRINGEMENT OF THIRD PARTY INTELLECTUAL PROPERTY
|
||||
* RIGHTS ARE DISCLAIMED TO THE FULLEST EXTENT PERMITTED BY LAW. IN NO EVENT
|
||||
* SHALL STMICROELECTRONICS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
|
||||
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
||||
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA,
|
||||
* OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
|
||||
* LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
|
||||
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
|
||||
* EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
******************************************************************************
|
||||
*/
|
||||
/** @addtogroup EEPROM_Emulation
|
||||
* @{
|
||||
*/
|
||||
|
||||
/* Includes ------------------------------------------------------------------*/
|
||||
#include "eeprom_f4.h"
|
||||
|
||||
/* Private typedef -----------------------------------------------------------*/
|
||||
/* Private define ------------------------------------------------------------*/
|
||||
/* Private macro -------------------------------------------------------------*/
|
||||
/* Private variables ---------------------------------------------------------*/
|
||||
|
||||
/* Global variable used to store variable value in read sequence */
|
||||
uint16_t DataVar = 0;
|
||||
|
||||
/* Virtual address defined by the user: 0xFFFF value is prohibited */
|
||||
extern uint16_t VirtAddVarTab[NB_OF_VAR];
|
||||
|
||||
/* Private function prototypes -----------------------------------------------*/
|
||||
/* Private functions ---------------------------------------------------------*/
|
||||
static HAL_StatusTypeDef EE_Format(void);
|
||||
static uint16_t EE_FindValidPage(uint8_t Operation);
|
||||
static uint16_t EE_VerifyPageFullWriteVariable(uint16_t VirtAddress, uint16_t Data);
|
||||
static uint16_t EE_PageTransfer(uint16_t VirtAddress, uint16_t Data);
|
||||
static uint16_t EE_VerifyPageFullyErased(uint32_t Address);
|
||||
|
||||
/**
|
||||
* @brief Restore the pages to a known good state in case of page's status
|
||||
* corruption after a power loss.
|
||||
* @param None.
|
||||
* @retval - Flash error code: on write Flash error
|
||||
* - FLASH_COMPLETE: on success
|
||||
*/
|
||||
uint16_t EE_Init(void)
|
||||
{
|
||||
uint16_t PageStatus0 = 6, PageStatus1 = 6;
|
||||
uint16_t VarIdx = 0;
|
||||
uint16_t EepromStatus = 0, ReadStatus = 0;
|
||||
int16_t x = -1;
|
||||
HAL_StatusTypeDef FlashStatus;
|
||||
|
||||
FLASH_UnlockF4();
|
||||
|
||||
/* Get Page0 status */
|
||||
PageStatus0 = (*(__IO uint16_t*)PAGE0_BASE_ADDRESS);
|
||||
/* Get Page1 status */
|
||||
PageStatus1 = (*(__IO uint16_t*)PAGE1_BASE_ADDRESS);
|
||||
|
||||
/* Check for invalid header states and repair if necessary */
|
||||
switch (PageStatus0)
|
||||
{
|
||||
case ERASED:
|
||||
if (PageStatus1 == VALID_PAGE) /* Page0 erased, Page1 valid */
|
||||
{
|
||||
/* Erase Page0 */
|
||||
if(!EE_VerifyPageFullyErased(PAGE0_BASE_ADDRESS))
|
||||
{
|
||||
FlashStatus = FLASH_EraseSectorF4(PAGE0_ID);
|
||||
/* If erase operation was failed, a Flash error code is returned */
|
||||
if (FlashStatus != HAL_OK)
|
||||
{
|
||||
return FlashStatus;
|
||||
}
|
||||
}
|
||||
}
|
||||
else if (PageStatus1 == RECEIVE_DATA) /* Page0 erased, Page1 receive */
|
||||
{
|
||||
/* Erase Page0 */
|
||||
if(!EE_VerifyPageFullyErased(PAGE0_BASE_ADDRESS))
|
||||
{
|
||||
FlashStatus = FLASH_EraseSectorF4(PAGE1_ID);
|
||||
/* If erase operation was failed, a Flash error code is returned */
|
||||
if (FlashStatus != HAL_OK)
|
||||
{
|
||||
return FlashStatus;
|
||||
}
|
||||
}
|
||||
/* Mark Page1 as valid */
|
||||
FlashStatus = FLASH_ProgramHalfWordF4(PAGE1_BASE_ADDRESS, VALID_PAGE);
|
||||
/* If program operation was failed, a Flash error code is returned */
|
||||
if (FlashStatus != HAL_OK)
|
||||
{
|
||||
return FlashStatus;
|
||||
}
|
||||
}
|
||||
else /* First EEPROM access (Page0&1 are erased) or invalid state -> format EEPROM */
|
||||
{
|
||||
/* Erase both Page0 and Page1 and set Page0 as valid page */
|
||||
FlashStatus = EE_Format();
|
||||
/* If erase/program operation was failed, a Flash error code is returned */
|
||||
if (FlashStatus != HAL_OK)
|
||||
{
|
||||
return FlashStatus;
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
||||
case RECEIVE_DATA:
|
||||
if (PageStatus1 == VALID_PAGE) /* Page0 receive, Page1 valid */
|
||||
{
|
||||
/* Transfer data from Page1 to Page0 */
|
||||
for (VarIdx = 0; VarIdx < NB_OF_VAR; VarIdx++)
|
||||
{
|
||||
if (( *(__IO uint16_t*)(PAGE0_BASE_ADDRESS + 6)) == VirtAddVarTab[VarIdx])
|
||||
{
|
||||
x = VarIdx;
|
||||
}
|
||||
if (VarIdx != x)
|
||||
{
|
||||
/* Read the last variables' updates */
|
||||
ReadStatus = EE_ReadVariable(VirtAddVarTab[VarIdx], &DataVar);
|
||||
/* In case variable corresponding to the virtual address was found */
|
||||
if (ReadStatus != 0x1)
|
||||
{
|
||||
/* Transfer the variable to the Page0 */
|
||||
EepromStatus = EE_VerifyPageFullWriteVariable(VirtAddVarTab[VarIdx], DataVar);
|
||||
/* If program operation was failed, a Flash error code is returned */
|
||||
if (EepromStatus != HAL_OK)
|
||||
{
|
||||
return EepromStatus;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
/* Mark Page0 as valid */
|
||||
FlashStatus = FLASH_ProgramHalfWordF4(PAGE0_BASE_ADDRESS, VALID_PAGE);
|
||||
/* If program operation was failed, a Flash error code is returned */
|
||||
if (FlashStatus != HAL_OK)
|
||||
{
|
||||
return FlashStatus;
|
||||
}
|
||||
/* Erase Page1 */
|
||||
if(!EE_VerifyPageFullyErased(PAGE1_BASE_ADDRESS))
|
||||
{
|
||||
FlashStatus = FLASH_EraseSectorF4(PAGE1_ID);
|
||||
/* If erase operation was failed, a Flash error code is returned */
|
||||
if (FlashStatus != HAL_OK)
|
||||
{
|
||||
return FlashStatus;
|
||||
}
|
||||
}
|
||||
}
|
||||
else if (PageStatus1 == ERASED) /* Page0 receive, Page1 erased */
|
||||
{
|
||||
/* Erase Page1 */
|
||||
if(!EE_VerifyPageFullyErased(PAGE1_BASE_ADDRESS))
|
||||
{
|
||||
FlashStatus = FLASH_EraseSectorF4(PAGE1_ID);
|
||||
/* If erase operation was failed, a Flash error code is returned */
|
||||
if (FlashStatus != HAL_OK)
|
||||
{
|
||||
return FlashStatus;
|
||||
}
|
||||
}
|
||||
/* Mark Page0 as valid */
|
||||
FlashStatus = FLASH_ProgramHalfWordF4(PAGE0_BASE_ADDRESS, VALID_PAGE);
|
||||
/* If program operation was failed, a Flash error code is returned */
|
||||
if (FlashStatus != HAL_OK)
|
||||
{
|
||||
return FlashStatus;
|
||||
}
|
||||
}
|
||||
else /* Invalid state -> format eeprom */
|
||||
{
|
||||
/* Erase both Page0 and Page1 and set Page0 as valid page */
|
||||
FlashStatus = EE_Format();
|
||||
/* If erase/program operation was failed, a Flash error code is returned */
|
||||
if (FlashStatus != HAL_OK)
|
||||
{
|
||||
return FlashStatus;
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
||||
case VALID_PAGE:
|
||||
if (PageStatus1 == VALID_PAGE) /* Invalid state -> format eeprom */
|
||||
{
|
||||
/* Erase both Page0 and Page1 and set Page0 as valid page */
|
||||
FlashStatus = EE_Format();
|
||||
/* If erase/program operation was failed, a Flash error code is returned */
|
||||
if (FlashStatus != HAL_OK)
|
||||
{
|
||||
return FlashStatus;
|
||||
}
|
||||
}
|
||||
else if (PageStatus1 == ERASED) /* Page0 valid, Page1 erased */
|
||||
{
|
||||
/* Erase Page1 */
|
||||
if(!EE_VerifyPageFullyErased(PAGE1_BASE_ADDRESS))
|
||||
{
|
||||
FlashStatus = FLASH_EraseSectorF4(PAGE1_ID);
|
||||
/* If erase operation was failed, a Flash error code is returned */
|
||||
if (FlashStatus != HAL_OK)
|
||||
{
|
||||
return FlashStatus;
|
||||
}
|
||||
}
|
||||
}
|
||||
else /* Page0 valid, Page1 receive */
|
||||
{
|
||||
/* Transfer data from Page0 to Page1 */
|
||||
for (VarIdx = 0; VarIdx < NB_OF_VAR; VarIdx++)
|
||||
{
|
||||
if ((*(__IO uint16_t*)(PAGE1_BASE_ADDRESS + 6)) == VirtAddVarTab[VarIdx])
|
||||
{
|
||||
x = VarIdx;
|
||||
}
|
||||
if (VarIdx != x)
|
||||
{
|
||||
/* Read the last variables' updates */
|
||||
ReadStatus = EE_ReadVariable(VirtAddVarTab[VarIdx], &DataVar);
|
||||
/* In case variable corresponding to the virtual address was found */
|
||||
if (ReadStatus != 0x1)
|
||||
{
|
||||
/* Transfer the variable to the Page1 */
|
||||
EepromStatus = EE_VerifyPageFullWriteVariable(VirtAddVarTab[VarIdx], DataVar);
|
||||
/* If program operation was failed, a Flash error code is returned */
|
||||
if (EepromStatus != HAL_OK)
|
||||
{
|
||||
return EepromStatus;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
/* Mark Page1 as valid */
|
||||
FlashStatus = FLASH_ProgramHalfWordF4(PAGE1_BASE_ADDRESS, VALID_PAGE);
|
||||
/* If program operation was failed, a Flash error code is returned */
|
||||
if (FlashStatus != HAL_OK)
|
||||
{
|
||||
return FlashStatus;
|
||||
}
|
||||
/* Erase Page0 */
|
||||
if(!EE_VerifyPageFullyErased(PAGE0_BASE_ADDRESS))
|
||||
{
|
||||
FlashStatus = FLASH_EraseSectorF4(PAGE0_ID);
|
||||
/* If erase operation was failed, a Flash error code is returned */
|
||||
if (FlashStatus != HAL_OK)
|
||||
{
|
||||
return FlashStatus;
|
||||
}
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
||||
default: /* Any other state -> format eeprom */
|
||||
/* Erase both Page0 and Page1 and set Page0 as valid page */
|
||||
FlashStatus = EE_Format();
|
||||
/* If erase/program operation was failed, a Flash error code is returned */
|
||||
if (FlashStatus != HAL_OK)
|
||||
{
|
||||
return FlashStatus;
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
return HAL_OK;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Verify if specified page is fully erased.
|
||||
* @param Address: page address
|
||||
* This parameter can be one of the following values:
|
||||
* @arg PAGE0_BASE_ADDRESS: Page0 base address
|
||||
* @arg PAGE1_BASE_ADDRESS: Page1 base address
|
||||
* @retval page fully erased status:
|
||||
* - 0: if Page not erased
|
||||
* - 1: if Page erased
|
||||
*/
|
||||
uint16_t EE_VerifyPageFullyErased(uint32_t Address)
|
||||
{
|
||||
uint32_t ReadStatus = 1;
|
||||
uint16_t AddressValue = 0x5555;
|
||||
|
||||
/* Check each active page address starting from end */
|
||||
while (Address <= PAGE0_END_ADDRESS)
|
||||
{
|
||||
/* Get the current location content to be compared with virtual address */
|
||||
AddressValue = (*(__IO uint16_t*)Address);
|
||||
|
||||
/* Compare the read address with the virtual address */
|
||||
if (AddressValue != ERASED)
|
||||
{
|
||||
|
||||
/* In case variable value is read, reset ReadStatus flag */
|
||||
ReadStatus = 0;
|
||||
|
||||
break;
|
||||
}
|
||||
/* Next address location */
|
||||
Address = Address + 4;
|
||||
}
|
||||
|
||||
/* Return ReadStatus value: (0: Page not erased, 1: Sector erased) */
|
||||
return ReadStatus;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Returns the last stored variable data, if found, which correspond to
|
||||
* the passed virtual address
|
||||
* @param VirtAddress: Variable virtual address
|
||||
* @param Data: Global variable contains the read variable value
|
||||
* @retval Success or error status:
|
||||
* - 0: if variable was found
|
||||
* - 1: if the variable was not found
|
||||
* - NO_VALID_PAGE: if no valid page was found.
|
||||
*/
|
||||
uint16_t EE_ReadVariable(uint16_t VirtAddress, uint16_t* Data)
|
||||
{
|
||||
uint16_t ValidPage = PAGE0;
|
||||
uint16_t AddressValue = 0x5555, ReadStatus = 1;
|
||||
uint32_t Address = EEPROM_START_ADDRESS, PageStartAddress = EEPROM_START_ADDRESS;
|
||||
|
||||
/* Get active Page for read operation */
|
||||
ValidPage = EE_FindValidPage(READ_FROM_VALID_PAGE);
|
||||
|
||||
/* Check if there is no valid page */
|
||||
if (ValidPage == NO_VALID_PAGE)
|
||||
{
|
||||
return NO_VALID_PAGE;
|
||||
}
|
||||
|
||||
/* Get the valid Page start Address */
|
||||
PageStartAddress = (uint32_t)(EEPROM_START_ADDRESS + (uint32_t)(ValidPage * PAGE_SIZE));
|
||||
|
||||
/* Get the valid Page end Address */
|
||||
Address = (uint32_t)((EEPROM_START_ADDRESS - 2) + (uint32_t)((1 + ValidPage) * PAGE_SIZE));
|
||||
|
||||
/* Check each active page address starting from end */
|
||||
while (Address > (PageStartAddress + 2))
|
||||
{
|
||||
/* Get the current location content to be compared with virtual address */
|
||||
AddressValue = (*(__IO uint16_t*)Address);
|
||||
|
||||
/* Compare the read address with the virtual address */
|
||||
if (AddressValue == VirtAddress)
|
||||
{
|
||||
/* Get content of Address-2 which is variable value */
|
||||
*Data = (*(__IO uint16_t*)(Address - 2));
|
||||
|
||||
/* In case variable value is read, reset ReadStatus flag */
|
||||
ReadStatus = 0;
|
||||
|
||||
break;
|
||||
}
|
||||
else
|
||||
{
|
||||
/* Next address location */
|
||||
Address = Address - 4;
|
||||
}
|
||||
}
|
||||
|
||||
/* Return ReadStatus value: (0: variable exist, 1: variable doesn't exist) */
|
||||
return ReadStatus;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Writes/upadtes variable data in EEPROM.
|
||||
* @param VirtAddress: Variable virtual address
|
||||
* @param Data: 16 bit data to be written
|
||||
* @retval Success or error status:
|
||||
* - FLASH_COMPLETE: on success
|
||||
* - PAGE_FULL: if valid page is full
|
||||
* - NO_VALID_PAGE: if no valid page was found
|
||||
* - Flash error code: on write Flash error
|
||||
*/
|
||||
uint16_t EE_WriteVariable(uint16_t VirtAddress, uint16_t Data)
|
||||
{
|
||||
uint16_t Status = 0;
|
||||
|
||||
/* Write the variable virtual address and value in the EEPROM */
|
||||
Status = EE_VerifyPageFullWriteVariable(VirtAddress, Data);
|
||||
|
||||
/* In case the EEPROM active page is full */
|
||||
if (Status == PAGE_FULL)
|
||||
{
|
||||
/* Perform Page transfer */
|
||||
Status = EE_PageTransfer(VirtAddress, Data);
|
||||
}
|
||||
|
||||
/* Return last operation status */
|
||||
return Status;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Erases PAGE and PAGE1 and writes VALID_PAGE header to PAGE
|
||||
* @param None
|
||||
* @retval Status of the last operation (Flash write or erase) done during
|
||||
* EEPROM formating
|
||||
*/
|
||||
static HAL_StatusTypeDef EE_Format(void)
|
||||
{
|
||||
HAL_StatusTypeDef FlashStatus = HAL_OK;
|
||||
|
||||
/* Erase Page0 */
|
||||
if(!EE_VerifyPageFullyErased(PAGE0_BASE_ADDRESS))
|
||||
{
|
||||
FlashStatus = FLASH_EraseSectorF4(PAGE0_ID);
|
||||
/* If erase operation was failed, a Flash error code is returned */
|
||||
if (FlashStatus != HAL_OK)
|
||||
{
|
||||
return FlashStatus;
|
||||
}
|
||||
}
|
||||
/* Set Page0 as valid page: Write VALID_PAGE at Page0 base address */
|
||||
FlashStatus = FLASH_ProgramHalfWordF4(PAGE0_BASE_ADDRESS, VALID_PAGE);
|
||||
/* If program operation was failed, a Flash error code is returned */
|
||||
if (FlashStatus != HAL_OK)
|
||||
{
|
||||
return FlashStatus;
|
||||
}
|
||||
|
||||
/* Erase Page1 */
|
||||
if(!EE_VerifyPageFullyErased(PAGE1_BASE_ADDRESS))
|
||||
{
|
||||
FlashStatus = FLASH_EraseSectorF4(PAGE1_ID);
|
||||
/* If erase operation was failed, a Flash error code is returned */
|
||||
if (FlashStatus != HAL_OK)
|
||||
{
|
||||
return FlashStatus;
|
||||
}
|
||||
}
|
||||
|
||||
return HAL_OK;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Find valid Page for write or read operation
|
||||
* @param Operation: operation to achieve on the valid page.
|
||||
* This parameter can be one of the following values:
|
||||
* @arg READ_FROM_VALID_PAGE: read operation from valid page
|
||||
* @arg WRITE_IN_VALID_PAGE: write operation from valid page
|
||||
* @retval Valid page number (PAGE or PAGE1) or NO_VALID_PAGE in case
|
||||
* of no valid page was found
|
||||
*/
|
||||
static uint16_t EE_FindValidPage(uint8_t Operation)
|
||||
{
|
||||
uint16_t PageStatus0 = 6, PageStatus1 = 6;
|
||||
|
||||
/* Get Page0 actual status */
|
||||
PageStatus0 = (*(__IO uint16_t*)PAGE0_BASE_ADDRESS);
|
||||
|
||||
/* Get Page1 actual status */
|
||||
PageStatus1 = (*(__IO uint16_t*)PAGE1_BASE_ADDRESS);
|
||||
|
||||
/* Write or read operation */
|
||||
switch (Operation)
|
||||
{
|
||||
case WRITE_IN_VALID_PAGE: /* ---- Write operation ---- */
|
||||
if (PageStatus1 == VALID_PAGE)
|
||||
{
|
||||
/* Page0 receiving data */
|
||||
if (PageStatus0 == RECEIVE_DATA)
|
||||
{
|
||||
return PAGE0; /* Page0 valid */
|
||||
}
|
||||
else
|
||||
{
|
||||
return PAGE1; /* Page1 valid */
|
||||
}
|
||||
}
|
||||
else if (PageStatus0 == VALID_PAGE)
|
||||
{
|
||||
/* Page1 receiving data */
|
||||
if (PageStatus1 == RECEIVE_DATA)
|
||||
{
|
||||
return PAGE1; /* Page1 valid */
|
||||
}
|
||||
else
|
||||
{
|
||||
return PAGE0; /* Page0 valid */
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
return NO_VALID_PAGE; /* No valid Page */
|
||||
}
|
||||
|
||||
case READ_FROM_VALID_PAGE: /* ---- Read operation ---- */
|
||||
if (PageStatus0 == VALID_PAGE)
|
||||
{
|
||||
return PAGE0; /* Page0 valid */
|
||||
}
|
||||
else if (PageStatus1 == VALID_PAGE)
|
||||
{
|
||||
return PAGE1; /* Page1 valid */
|
||||
}
|
||||
else
|
||||
{
|
||||
return NO_VALID_PAGE ; /* No valid Page */
|
||||
}
|
||||
|
||||
default:
|
||||
return PAGE0; /* Page0 valid */
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Verify if active page is full and Writes variable in EEPROM.
|
||||
* @param VirtAddress: 16 bit virtual address of the variable
|
||||
* @param Data: 16 bit data to be written as variable value
|
||||
* @retval Success or error status:
|
||||
* - FLASH_COMPLETE: on success
|
||||
* - PAGE_FULL: if valid page is full
|
||||
* - NO_VALID_PAGE: if no valid page was found
|
||||
* - Flash error code: on write Flash error
|
||||
*/
|
||||
static uint16_t EE_VerifyPageFullWriteVariable(uint16_t VirtAddress, uint16_t Data)
|
||||
{
|
||||
HAL_StatusTypeDef FlashStatus = HAL_OK;
|
||||
uint16_t ValidPage = PAGE0;
|
||||
uint32_t Address = EEPROM_START_ADDRESS, PageEndAddress = EEPROM_START_ADDRESS+PAGE_SIZE;
|
||||
|
||||
/* Get valid Page for write operation */
|
||||
ValidPage = EE_FindValidPage(WRITE_IN_VALID_PAGE);
|
||||
|
||||
/* Check if there is no valid page */
|
||||
if (ValidPage == NO_VALID_PAGE)
|
||||
{
|
||||
return NO_VALID_PAGE;
|
||||
}
|
||||
|
||||
/* Get the valid Page start Address */
|
||||
Address = (uint32_t)(EEPROM_START_ADDRESS + (uint32_t)(ValidPage * PAGE_SIZE));
|
||||
|
||||
/* Get the valid Page end Address */
|
||||
PageEndAddress = (uint32_t)((EEPROM_START_ADDRESS - 1) + (uint32_t)((ValidPage + 1) * PAGE_SIZE));
|
||||
|
||||
/* Check each active page address starting from begining */
|
||||
while (Address < PageEndAddress)
|
||||
{
|
||||
/* Verify if Address and Address+2 contents are 0xFFFFFFFF */
|
||||
if ((*(__IO uint32_t*)Address) == 0xFFFFFFFF)
|
||||
{
|
||||
/* Set variable data */
|
||||
FlashStatus = FLASH_ProgramHalfWordF4(Address, Data);
|
||||
/* If program operation was failed, a Flash error code is returned */
|
||||
if (FlashStatus != HAL_OK)
|
||||
{
|
||||
return FlashStatus;
|
||||
}
|
||||
/* Set variable virtual address */
|
||||
FlashStatus = FLASH_ProgramHalfWordF4(Address + 2, VirtAddress);
|
||||
/* Return program operation status */
|
||||
return FlashStatus;
|
||||
}
|
||||
else
|
||||
{
|
||||
/* Next address location */
|
||||
Address = Address + 4;
|
||||
}
|
||||
}
|
||||
|
||||
/* Return PAGE_FULL in case the valid page is full */
|
||||
return PAGE_FULL;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Transfers last updated variables data from the full Page to
|
||||
* an empty one.
|
||||
* @param VirtAddress: 16 bit virtual address of the variable
|
||||
* @param Data: 16 bit data to be written as variable value
|
||||
* @retval Success or error status:
|
||||
* - FLASH_COMPLETE: on success
|
||||
* - PAGE_FULL: if valid page is full
|
||||
* - NO_VALID_PAGE: if no valid page was found
|
||||
* - Flash error code: on write Flash error
|
||||
*/
|
||||
static uint16_t EE_PageTransfer(uint16_t VirtAddress, uint16_t Data)
|
||||
{
|
||||
HAL_StatusTypeDef FlashStatus = HAL_OK;
|
||||
uint32_t NewPageAddress = EEPROM_START_ADDRESS;
|
||||
uint16_t OldPageId=0;
|
||||
uint16_t ValidPage = PAGE0, VarIdx = 0;
|
||||
uint16_t EepromStatus = 0, ReadStatus = 0;
|
||||
|
||||
/* Get active Page for read operation */
|
||||
ValidPage = EE_FindValidPage(READ_FROM_VALID_PAGE);
|
||||
|
||||
if (ValidPage == PAGE1) /* Page1 valid */
|
||||
{
|
||||
/* New page address where variable will be moved to */
|
||||
NewPageAddress = PAGE0_BASE_ADDRESS;
|
||||
|
||||
/* Old page ID where variable will be taken from */
|
||||
OldPageId = PAGE1_ID;
|
||||
}
|
||||
else if (ValidPage == PAGE0) /* Page0 valid */
|
||||
{
|
||||
/* New page address where variable will be moved to */
|
||||
NewPageAddress = PAGE1_BASE_ADDRESS;
|
||||
|
||||
/* Old page ID where variable will be taken from */
|
||||
OldPageId = PAGE0_ID;
|
||||
}
|
||||
else
|
||||
{
|
||||
return NO_VALID_PAGE; /* No valid Page */
|
||||
}
|
||||
|
||||
/* Set the new Page status to RECEIVE_DATA status */
|
||||
FlashStatus = FLASH_ProgramHalfWordF4(NewPageAddress, RECEIVE_DATA);
|
||||
/* If program operation was failed, a Flash error code is returned */
|
||||
if (FlashStatus != HAL_OK)
|
||||
{
|
||||
return FlashStatus;
|
||||
}
|
||||
|
||||
/* Write the variable passed as parameter in the new active page */
|
||||
EepromStatus = EE_VerifyPageFullWriteVariable(VirtAddress, Data);
|
||||
/* If program operation was failed, a Flash error code is returned */
|
||||
if (EepromStatus != HAL_OK)
|
||||
{
|
||||
return EepromStatus;
|
||||
}
|
||||
|
||||
/* Transfer process: transfer variables from old to the new active page */
|
||||
for (VarIdx = 0; VarIdx < NB_OF_VAR; VarIdx++)
|
||||
{
|
||||
if (VirtAddVarTab[VarIdx] != VirtAddress) /* Check each variable except the one passed as parameter */
|
||||
{
|
||||
/* Read the other last variable updates */
|
||||
ReadStatus = EE_ReadVariable(VirtAddVarTab[VarIdx], &DataVar);
|
||||
/* In case variable corresponding to the virtual address was found */
|
||||
if (ReadStatus != 0x1)
|
||||
{
|
||||
/* Transfer the variable to the new active page */
|
||||
EepromStatus = EE_VerifyPageFullWriteVariable(VirtAddVarTab[VarIdx], DataVar);
|
||||
/* If program operation was failed, a Flash error code is returned */
|
||||
if (EepromStatus != HAL_OK)
|
||||
{
|
||||
return EepromStatus;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/* Erase the old Page: Set old Page status to ERASED status */
|
||||
FlashStatus = FLASH_EraseSectorF4(OldPageId);
|
||||
/* If erase operation was failed, a Flash error code is returned */
|
||||
if (FlashStatus != HAL_OK)
|
||||
{
|
||||
return FlashStatus;
|
||||
}
|
||||
|
||||
/* Set new Page status to VALID_PAGE status */
|
||||
FlashStatus = FLASH_ProgramHalfWordF4(NewPageAddress, VALID_PAGE);
|
||||
/* If program operation was failed, a Flash error code is returned */
|
||||
if (FlashStatus != HAL_OK)
|
||||
{
|
||||
return FlashStatus;
|
||||
}
|
||||
|
||||
/* Return last operation flash status */
|
||||
return FlashStatus;
|
||||
}
|
||||
|
||||
/* flash operation */
|
||||
|
||||
#define EraseTimeout ((uint32_t)0x00000FFF)
|
||||
#define ProgramTimeout ((uint32_t)0x0000001F)
|
||||
|
||||
#define FLASH_PSIZE_BYTE 0
|
||||
#define FLASH_PSIZE_HFWORD FLASH_CR_PSIZE_0
|
||||
#define FLASH_PSIZE_WORD FLASH_CR_PSIZE_1
|
||||
#define FLASH_CR_SNB_Pos 3
|
||||
#define FLASH_KEY1_F4 0x45670123
|
||||
#define FLASH_KEY2_F4 0xCDEF89AB
|
||||
|
||||
#define ASSERT(exp) (void)((0))
|
||||
|
||||
static void Flash_Delay(void)
|
||||
{
|
||||
__IO uint32_t i = 0;
|
||||
for(i = 0xFF; i != 0; i--) { }
|
||||
}
|
||||
|
||||
static HAL_StatusTypeDef FLASH_GetStatus(void)
|
||||
{
|
||||
if ((FLASH->SR & FLASH_SR_BSY) == FLASH_SR_BSY)
|
||||
return HAL_BUSY;
|
||||
|
||||
if ((FLASH->SR & (FLASH_SR_PGSERR|FLASH_SR_PGPERR|FLASH_SR_PGAERR)) != 0)
|
||||
return HAL_ERROR;
|
||||
|
||||
if ((FLASH->SR & FLASH_SR_WRPERR) != 0 )
|
||||
return HAL_ERROR;
|
||||
|
||||
if ((FLASH->SR & FLASH_SR_SOP) != 0 )
|
||||
return HAL_ERROR;
|
||||
|
||||
return HAL_OK;
|
||||
}
|
||||
|
||||
static HAL_StatusTypeDef FLASH_WaitForLastOperation(uint32_t timeout)
|
||||
{
|
||||
/* Check for the Flash Status */
|
||||
HAL_StatusTypeDef status = FLASH_GetStatus();
|
||||
/* Wait for a Flash operation to complete or a TIMEOUT to occur */
|
||||
while ((status == HAL_BUSY) && (timeout != 0x00))
|
||||
{
|
||||
Flash_Delay();
|
||||
status = FLASH_GetStatus();
|
||||
timeout--;
|
||||
}
|
||||
if (timeout == 0)
|
||||
status = HAL_TIMEOUT;
|
||||
|
||||
return status;
|
||||
}
|
||||
HAL_StatusTypeDef FLASH_UnlockF4(void)
|
||||
{
|
||||
FLASH->KEYR = FLASH_KEY1_F4;
|
||||
FLASH->KEYR = FLASH_KEY2_F4;
|
||||
return HAL_OK;
|
||||
}
|
||||
|
||||
HAL_StatusTypeDef FLASH_EraseSectorF4(uint32_t sector)
|
||||
{
|
||||
HAL_StatusTypeDef status = HAL_OK;
|
||||
/* Wait for last operation to be completed */
|
||||
status = FLASH_WaitForLastOperation(EraseTimeout);
|
||||
|
||||
if(status == HAL_OK) {
|
||||
/* if the previous operation is completed, proceed to erase the page */
|
||||
CLEAR_BIT(FLASH->CR, FLASH_CR_PSIZE);
|
||||
FLASH->CR |= FLASH_PSIZE_WORD;
|
||||
CLEAR_BIT(FLASH->CR, FLASH_CR_SNB);
|
||||
FLASH->CR |= FLASH_CR_SER | (sector << FLASH_CR_SNB_Pos);
|
||||
FLASH->CR |= FLASH_CR_STRT;
|
||||
|
||||
/* Wait for last operation to be completed */
|
||||
status = FLASH_WaitForLastOperation(EraseTimeout);
|
||||
if(status != HAL_TIMEOUT)
|
||||
{
|
||||
/* if the erase operation is completed, disable the PER Bit */
|
||||
FLASH->CR &= ~FLASH_CR_SNB;
|
||||
FLASH->CR &= ~FLASH_CR_SER;
|
||||
}
|
||||
|
||||
FLASH->SR = (FLASH_SR_EOP | FLASH_SR_SOP | FLASH_SR_WRPERR);
|
||||
}
|
||||
/* Return the Erase Status */
|
||||
return status;
|
||||
}
|
||||
|
||||
HAL_StatusTypeDef FLASH_ProgramHalfWordF4(uint32_t address, uint16_t data)
|
||||
{
|
||||
HAL_StatusTypeDef status = HAL_ERROR;
|
||||
|
||||
if (IS_FLASH_ADDRESS(address))
|
||||
{
|
||||
/* Wait for last operation to be completed */
|
||||
status = FLASH_WaitForLastOperation(ProgramTimeout);
|
||||
if(status == HAL_OK) {
|
||||
// set size to byte
|
||||
FLASH->CR &= ~FLASH_CR_PSIZE;
|
||||
FLASH->CR |= FLASH_PSIZE_HFWORD;
|
||||
FLASH->CR |= FLASH_CR_PG;
|
||||
|
||||
*(__IO uint16_t*)address = data;
|
||||
/* Wait for last operation to be completed */
|
||||
status = FLASH_WaitForLastOperation(ProgramTimeout);
|
||||
if(status != HAL_TIMEOUT)
|
||||
{
|
||||
/* if the program operation is completed, disable the PG Bit */
|
||||
FLASH->CR &= ~FLASH_CR_PG;
|
||||
}
|
||||
FLASH->SR = (FLASH_SR_EOP | FLASH_SR_SOP | FLASH_SR_PGSERR | FLASH_SR_PGPERR | FLASH_SR_PGAERR | FLASH_SR_WRPERR);
|
||||
}
|
||||
}
|
||||
return status;
|
||||
}
|
||||
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
/******************* (C) COPYRIGHT 2017 STMicroelectronics *****END OF FILE****/
|
130
keyboards/matrix/noah/eeprom_f4.h
Normal file
130
keyboards/matrix/noah/eeprom_f4.h
Normal file
|
@ -0,0 +1,130 @@
|
|||
/**
|
||||
******************************************************************************
|
||||
* @file EEPROM/EEPROM_Emulation/inc/eeprom.h
|
||||
* @author MCD Application Team
|
||||
* @brief This file contains all the functions prototypes for the EEPROM
|
||||
* emulation firmware library.
|
||||
******************************************************************************
|
||||
* @attention
|
||||
*
|
||||
* <h2><center>© Copyright <EFBFBD> 2017 STMicroelectronics International N.V.
|
||||
* All rights reserved.</center></h2>
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted, provided that the following conditions are met:
|
||||
*
|
||||
* 1. Redistribution of source code must retain the above copyright notice,
|
||||
* this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright notice,
|
||||
* this list of conditions and the following disclaimer in the documentation
|
||||
* and/or other materials provided with the distribution.
|
||||
* 3. Neither the name of STMicroelectronics nor the names of other
|
||||
* contributors to this software may be used to endorse or promote products
|
||||
* derived from this software without specific written permission.
|
||||
* 4. This software, including modifications and/or derivative works of this
|
||||
* software, must execute solely and exclusively on microcontroller or
|
||||
* microprocessor devices manufactured by or for STMicroelectronics.
|
||||
* 5. Redistribution and use of this software other than as permitted under
|
||||
* this license is void and will automatically terminate your rights under
|
||||
* this license.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY STMICROELECTRONICS AND CONTRIBUTORS "AS IS"
|
||||
* AND ANY EXPRESS, IMPLIED OR STATUTORY WARRANTIES, INCLUDING, BUT NOT
|
||||
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS FOR A
|
||||
* PARTICULAR PURPOSE AND NON-INFRINGEMENT OF THIRD PARTY INTELLECTUAL PROPERTY
|
||||
* RIGHTS ARE DISCLAIMED TO THE FULLEST EXTENT PERMITTED BY LAW. IN NO EVENT
|
||||
* SHALL STMICROELECTRONICS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
|
||||
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
||||
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA,
|
||||
* OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
|
||||
* LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
|
||||
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
|
||||
* EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
******************************************************************************
|
||||
*/
|
||||
|
||||
/* Define to prevent recursive inclusion -------------------------------------*/
|
||||
#ifndef __EEPROM_H
|
||||
#define __EEPROM_H
|
||||
|
||||
|
||||
/* Includes ------------------------------------------------------------------*/
|
||||
#include "hal.h"
|
||||
|
||||
typedef enum
|
||||
{
|
||||
HAL_OK = 0x00U,
|
||||
HAL_ERROR = 0x01U,
|
||||
HAL_BUSY = 0x02U,
|
||||
HAL_TIMEOUT = 0x03U
|
||||
} HAL_StatusTypeDef;
|
||||
|
||||
/* Exported constants --------------------------------------------------------*/
|
||||
/* EEPROM emulation firmware error codes */
|
||||
#define EE_OK (uint32_t)HAL_OK
|
||||
#define EE_ERROR (uint32_t)HAL_ERROR
|
||||
#define EE_BUSY (uint32_t)HAL_BUSY
|
||||
#define EE_TIMEOUT (uint32_t)HAL_TIMEOUT
|
||||
|
||||
/* Define the size of the sectors to be used */
|
||||
#define PAGE_SIZE (uint32_t)0x4000 /* Page size = 16KByte */
|
||||
|
||||
/* Device voltage range supposed to be [2.7V to 3.6V], the operation will
|
||||
be done by word */
|
||||
#define VOLTAGE_RANGE (uint8_t)VOLTAGE_RANGE_3
|
||||
|
||||
/* EEPROM start address in Flash */
|
||||
#define EEPROM_START_ADDRESS ((uint32_t)0x08008000) /* EEPROM emulation start address:
|
||||
from sector2 : after 16KByte of used
|
||||
Flash memory */
|
||||
|
||||
/* Pages 0 and 1 base and end addresses */
|
||||
#define PAGE0_BASE_ADDRESS ((uint32_t)(EEPROM_START_ADDRESS + 0x0000))
|
||||
#define PAGE0_END_ADDRESS ((uint32_t)(EEPROM_START_ADDRESS + (PAGE_SIZE - 1)))
|
||||
#define PAGE0_ID 2//FLASH_SECTOR_2
|
||||
|
||||
#define PAGE1_BASE_ADDRESS ((uint32_t)(EEPROM_START_ADDRESS + 0x4000))
|
||||
#define PAGE1_END_ADDRESS ((uint32_t)(EEPROM_START_ADDRESS + (2 * PAGE_SIZE - 1)))
|
||||
#define PAGE1_ID 3//FLASH_SECTOR_3
|
||||
|
||||
/* Used Flash pages for EEPROM emulation */
|
||||
#define PAGE0 ((uint16_t)0x0000)
|
||||
#define PAGE1 ((uint16_t)0x0001) /* Page nb between PAGE0_BASE_ADDRESS & PAGE1_BASE_ADDRESS*/
|
||||
|
||||
/* No valid page define */
|
||||
#define NO_VALID_PAGE ((uint16_t)0x00AB)
|
||||
|
||||
/* Page status definitions */
|
||||
#define ERASED ((uint16_t)0xFFFF) /* Page is empty */
|
||||
#define RECEIVE_DATA ((uint16_t)0xEEEE) /* Page is marked to receive data */
|
||||
#define VALID_PAGE ((uint16_t)0x0000) /* Page containing valid data */
|
||||
|
||||
/* Valid pages in read and write defines */
|
||||
#define READ_FROM_VALID_PAGE ((uint8_t)0x00)
|
||||
#define WRITE_IN_VALID_PAGE ((uint8_t)0x01)
|
||||
|
||||
/* Page full define */
|
||||
#define PAGE_FULL ((uint8_t)0x80)
|
||||
|
||||
/* Variables' number */
|
||||
#define NB_OF_VAR ((uint8_t)0x16)
|
||||
|
||||
/* Exported types ------------------------------------------------------------*/
|
||||
/* Exported macro ------------------------------------------------------------*/
|
||||
/* Exported functions ------------------------------------------------------- */
|
||||
|
||||
HAL_StatusTypeDef FLASH_UnlockF4(void);
|
||||
HAL_StatusTypeDef FLASH_EraseSectorF4(uint32_t sector);
|
||||
HAL_StatusTypeDef FLASH_ProgramHalfWordF4(uint32_t address, uint16_t data);
|
||||
|
||||
uint16_t EE_Init(void);
|
||||
uint16_t EE_ReadVariable(uint16_t VirtAddress, uint16_t* Data);
|
||||
uint16_t EE_WriteVariable(uint16_t VirtAddress, uint16_t Data);
|
||||
|
||||
#define IS_FLASH_ADDRESS(ADDRESS) (((ADDRESS) >= EEPROM_START_ADDRESS) && ((ADDRESS) < PAGE1_END_ADDRESS))
|
||||
#define IS_FLASH_SECTOR(SECTOR) (((SECTOR) >= PAGE0_ID) && ((SECTOR) <= PAGE1_ID))
|
||||
|
||||
#endif /* __EEPROM_H */
|
||||
|
||||
/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/
|
388
keyboards/matrix/noah/halconf.h
Normal file
388
keyboards/matrix/noah/halconf.h
Normal file
|
@ -0,0 +1,388 @@
|
|||
/*
|
||||
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.
|
||||
*/
|
||||
|
||||
/**
|
||||
* @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 TRUE
|
||||
#endif
|
||||
|
||||
/**
|
||||
* @brief Enables the I2C subsystem.
|
||||
*/
|
||||
#if !defined(HAL_USE_I2C) || defined(__DOXYGEN__)
|
||||
#define HAL_USE_I2C TRUE
|
||||
#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 TRUE
|
||||
#endif
|
||||
|
||||
/**
|
||||
* @brief Enables the QSPI subsystem.
|
||||
*/
|
||||
#if !defined(HAL_USE_QSPI) || defined(__DOXYGEN__)
|
||||
#define HAL_USE_QSPI 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 16 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 256 bytes for both the transmission and receive
|
||||
* buffers.
|
||||
*/
|
||||
#if !defined(SERIAL_USB_BUFFERS_SIZE) || defined(__DOXYGEN__)
|
||||
#define SERIAL_USB_BUFFERS_SIZE 256
|
||||
#endif
|
||||
|
||||
/**
|
||||
* @brief Serial over USB number of buffers.
|
||||
* @note The default is 2 buffers.
|
||||
*/
|
||||
#if !defined(SERIAL_USB_BUFFERS_NUMBER) || defined(__DOXYGEN__)
|
||||
#define SERIAL_USB_BUFFERS_NUMBER 2
|
||||
#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 FALSE
|
||||
#endif
|
||||
|
||||
/*===========================================================================*/
|
||||
/* UART driver related settings. */
|
||||
/*===========================================================================*/
|
||||
|
||||
/**
|
||||
* @brief Enables synchronous APIs.
|
||||
* @note Disabling this option saves both code and data space.
|
||||
*/
|
||||
#if !defined(UART_USE_WAIT) || defined(__DOXYGEN__)
|
||||
#define UART_USE_WAIT FALSE
|
||||
#endif
|
||||
|
||||
/**
|
||||
* @brief Enables the @p uartAcquireBus() and @p uartReleaseBus() APIs.
|
||||
* @note Disabling this option saves both code and data space.
|
||||
*/
|
||||
#if !defined(UART_USE_MUTUAL_EXCLUSION) || defined(__DOXYGEN__)
|
||||
#define UART_USE_MUTUAL_EXCLUSION FALSE
|
||||
#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 */
|
||||
|
||||
/** @} */
|
721
keyboards/matrix/noah/info.json
Normal file
721
keyboards/matrix/noah/info.json
Normal file
|
@ -0,0 +1,721 @@
|
|||
{
|
||||
"keyboard_name": "NOAH",
|
||||
"url": "",
|
||||
"maintainer": "astro",
|
||||
"width": 16,
|
||||
"height": 5,
|
||||
"layouts": {
|
||||
"LAYOUT_default": {
|
||||
"key_count": 68,
|
||||
"layout": [
|
||||
{
|
||||
"label": "~",
|
||||
"x": 0,
|
||||
"y": 0
|
||||
},
|
||||
{
|
||||
"label": "!",
|
||||
"x": 1,
|
||||
"y": 0
|
||||
},
|
||||
{
|
||||
"label": "@",
|
||||
"x": 2,
|
||||
"y": 0
|
||||
},
|
||||
{
|
||||
"label": "#",
|
||||
"x": 3,
|
||||
"y": 0
|
||||
},
|
||||
{
|
||||
"label": "$",
|
||||
"x": 4,
|
||||
"y": 0
|
||||
},
|
||||
{
|
||||
"label": "%",
|
||||
"x": 5,
|
||||
"y": 0
|
||||
},
|
||||
{
|
||||
"label": "^",
|
||||
"x": 6,
|
||||
"y": 0
|
||||
},
|
||||
{
|
||||
"label": "&",
|
||||
"x": 7,
|
||||
"y": 0
|
||||
},
|
||||
{
|
||||
"label": "*",
|
||||
"x": 8,
|
||||
"y": 0
|
||||
},
|
||||
{
|
||||
"label": "(",
|
||||
"x": 9,
|
||||
"y": 0
|
||||
},
|
||||
{
|
||||
"label": ")",
|
||||
"x": 10,
|
||||
"y": 0
|
||||
},
|
||||
{
|
||||
"label": "_",
|
||||
"x": 11,
|
||||
"y": 0
|
||||
},
|
||||
{
|
||||
"label": "+",
|
||||
"x": 12,
|
||||
"y": 0
|
||||
},
|
||||
{
|
||||
"label": "|",
|
||||
"x": 13,
|
||||
"y": 0
|
||||
},
|
||||
{
|
||||
"label":"Backspace",
|
||||
"x": 14,
|
||||
"y": 0
|
||||
},
|
||||
{
|
||||
"label":"Print Screen",
|
||||
"x": 15,
|
||||
"y": 0
|
||||
},
|
||||
{
|
||||
"label": "Tab",
|
||||
"x": 0,
|
||||
"y": 1,
|
||||
"w": 1.5
|
||||
},
|
||||
{
|
||||
"label": "Q",
|
||||
"x": 1.5,
|
||||
"y": 1
|
||||
},
|
||||
{
|
||||
"label": "W",
|
||||
"x": 2.5,
|
||||
"y": 1
|
||||
},
|
||||
{
|
||||
"label": "E",
|
||||
"x": 3.5,
|
||||
"y": 1
|
||||
},
|
||||
{
|
||||
"label": "R",
|
||||
"x": 4.5,
|
||||
"y": 1
|
||||
},
|
||||
{
|
||||
"label": "T",
|
||||
"x": 5.5,
|
||||
"y": 1
|
||||
},
|
||||
{
|
||||
"label": "Y",
|
||||
"x": 6.5,
|
||||
"y": 1
|
||||
},
|
||||
{
|
||||
"label": "U",
|
||||
"x": 7.5,
|
||||
"y": 1
|
||||
},
|
||||
{
|
||||
"label": "I",
|
||||
"x": 8.5,
|
||||
"y": 1
|
||||
},
|
||||
{
|
||||
"label": "O",
|
||||
"x": 9.5,
|
||||
"y": 1
|
||||
},
|
||||
{
|
||||
"label": "P",
|
||||
"x": 10.5,
|
||||
"y": 1
|
||||
},
|
||||
{
|
||||
"label": "{",
|
||||
"x": 11.5,
|
||||
"y": 1
|
||||
},
|
||||
{
|
||||
"label": "}",
|
||||
"x": 12.5,
|
||||
"y": 1
|
||||
},
|
||||
{
|
||||
"label": "|",
|
||||
"x": 13.5,
|
||||
"y": 1,
|
||||
"w": 1.5
|
||||
},
|
||||
{ "label": "Page Up",
|
||||
"x": 15,
|
||||
"y": 1
|
||||
},
|
||||
{
|
||||
"label": "Caps Lock",
|
||||
"x": 0,
|
||||
"y": 2,
|
||||
"w": 1.75
|
||||
},
|
||||
{
|
||||
"label": "A",
|
||||
"x": 1.75,
|
||||
"y": 2
|
||||
},
|
||||
{
|
||||
"label": "S",
|
||||
"x": 2.75,
|
||||
"y": 2
|
||||
},
|
||||
{
|
||||
"label": "D",
|
||||
"x": 3.75,
|
||||
"y": 2
|
||||
},
|
||||
{
|
||||
"label": "F",
|
||||
"x": 4.75,
|
||||
"y": 2
|
||||
},
|
||||
{
|
||||
"label": "G",
|
||||
"x": 5.75,
|
||||
"y": 2
|
||||
},
|
||||
{
|
||||
"label": "H",
|
||||
"x": 6.75,
|
||||
"y": 2
|
||||
},
|
||||
{
|
||||
"label": "J",
|
||||
"x": 7.75,
|
||||
"y": 2
|
||||
},
|
||||
{
|
||||
"label": "K",
|
||||
"x": 8.75,
|
||||
"y": 2
|
||||
},
|
||||
{
|
||||
"label": "L",
|
||||
"x": 9.75,
|
||||
"y": 2
|
||||
},
|
||||
{
|
||||
"label": ":",
|
||||
"x": 10.75,
|
||||
"y": 2
|
||||
},
|
||||
{
|
||||
"label": "\"",
|
||||
"x": 11.75,
|
||||
"y": 2
|
||||
},
|
||||
{
|
||||
"label": "Enter",
|
||||
"x": 12.75,
|
||||
"y": 2,
|
||||
"w": 2.25
|
||||
},
|
||||
{
|
||||
"label": "Page Down",
|
||||
"x": 15,
|
||||
"y": 2
|
||||
},
|
||||
{
|
||||
"label": "Shift",
|
||||
"x": 0,
|
||||
"y": 3,
|
||||
"w": 2.25
|
||||
},
|
||||
{
|
||||
"label": "Z",
|
||||
"x": 2.25,
|
||||
"y": 3
|
||||
},
|
||||
{
|
||||
"label": "X",
|
||||
"x": 3.25,
|
||||
"y": 3
|
||||
},
|
||||
{
|
||||
"label": "C",
|
||||
"x": 4.25,
|
||||
"y": 3
|
||||
},
|
||||
{
|
||||
"label": "V",
|
||||
"x": 5.25,
|
||||
"y": 3
|
||||
},
|
||||
{
|
||||
"label": "B",
|
||||
"x": 6.25,
|
||||
"y": 3
|
||||
},
|
||||
{
|
||||
"label": "N",
|
||||
"x": 7.25,
|
||||
"y": 3
|
||||
},
|
||||
{
|
||||
"label": "M",
|
||||
"x": 8.25,
|
||||
"y": 3
|
||||
},
|
||||
{
|
||||
"label": "<",
|
||||
"x": 9.25,
|
||||
"y": 3
|
||||
},
|
||||
{
|
||||
"label": ">",
|
||||
"x": 10.25,
|
||||
"y": 3
|
||||
},
|
||||
{
|
||||
"label": "?",
|
||||
"x": 11.25,
|
||||
"y": 3
|
||||
},
|
||||
{
|
||||
"label": "Shift",
|
||||
"x": 12.25,
|
||||
"y": 3,
|
||||
"w": 1.75
|
||||
},
|
||||
{
|
||||
"label": "Up",
|
||||
"x": 14,
|
||||
"y": 3
|
||||
},
|
||||
{
|
||||
"label": "End"
|
||||
"x": 15,
|
||||
"y": 3
|
||||
},
|
||||
{
|
||||
"label": "Ctrl",
|
||||
"x": 0,
|
||||
"y": 4,
|
||||
"w": 1.25
|
||||
},
|
||||
{
|
||||
"label": "Win",
|
||||
"x": 1.25,
|
||||
"y": 4,
|
||||
"w": 1.25
|
||||
},
|
||||
{
|
||||
"label": "Alt",
|
||||
"x": 2.5,
|
||||
"y": 4,
|
||||
"w": 1.25
|
||||
},
|
||||
{
|
||||
"x": 3.75,
|
||||
"y": 4,
|
||||
"w": 6.25
|
||||
},
|
||||
{
|
||||
"label": "Alt",
|
||||
"x": 10,
|
||||
"y": 4,
|
||||
"w": 1.25
|
||||
},
|
||||
{
|
||||
"label": "Win",
|
||||
"x": 11.25,
|
||||
"y": 4,
|
||||
"w": 1.25
|
||||
},
|
||||
{
|
||||
"label": "Left",
|
||||
"x": 13,
|
||||
"y": 4
|
||||
},
|
||||
{
|
||||
"label": "Down",
|
||||
"x": 14,
|
||||
"y": 4
|
||||
},
|
||||
{
|
||||
"label": "Right",
|
||||
"x": 15,
|
||||
"y": 4
|
||||
}
|
||||
]
|
||||
},
|
||||
"LAYOUT_iso": {
|
||||
"key_count": 68,
|
||||
"layout": [
|
||||
{
|
||||
"label": "~",
|
||||
"x": 0,
|
||||
"y": 0
|
||||
},
|
||||
{
|
||||
"label": "!",
|
||||
"x": 1,
|
||||
"y": 0
|
||||
},
|
||||
{
|
||||
"label": "@",
|
||||
"x": 2,
|
||||
"y": 0
|
||||
},
|
||||
{
|
||||
"label": "#",
|
||||
"x": 3,
|
||||
"y": 0
|
||||
},
|
||||
{
|
||||
"label": "$",
|
||||
"x": 4,
|
||||
"y": 0
|
||||
},
|
||||
{
|
||||
"label": "%",
|
||||
"x": 5,
|
||||
"y": 0
|
||||
},
|
||||
{
|
||||
"label": "^",
|
||||
"x": 6,
|
||||
"y": 0
|
||||
},
|
||||
{
|
||||
"label": "&",
|
||||
"x": 7,
|
||||
"y": 0
|
||||
},
|
||||
{
|
||||
"label": "*",
|
||||
"x": 8,
|
||||
"y": 0
|
||||
},
|
||||
{
|
||||
"label": "(",
|
||||
"x": 9,
|
||||
"y": 0
|
||||
},
|
||||
{
|
||||
"label": ")",
|
||||
"x": 10,
|
||||
"y": 0
|
||||
},
|
||||
{
|
||||
"label": "_",
|
||||
"x": 11,
|
||||
"y": 0
|
||||
},
|
||||
{
|
||||
"label": "+",
|
||||
"x": 12,
|
||||
"y": 0
|
||||
},
|
||||
{
|
||||
"label": "Backspace",
|
||||
"x": 13,
|
||||
"y": 0,
|
||||
"w": 2
|
||||
},
|
||||
{
|
||||
"label": "Print Screen",
|
||||
"x": 15,
|
||||
"y": 0
|
||||
},
|
||||
{
|
||||
"label": "Tab",
|
||||
"x": 0,
|
||||
"y": 1,
|
||||
"w": 1.5
|
||||
},
|
||||
{
|
||||
"label": "Q",
|
||||
"x": 1.5,
|
||||
"y": 1
|
||||
},
|
||||
{
|
||||
"label": "W",
|
||||
"x": 2.5,
|
||||
"y": 1
|
||||
},
|
||||
{
|
||||
"label": "E",
|
||||
"x": 3.5,
|
||||
"y": 1
|
||||
},
|
||||
{
|
||||
"label": "R",
|
||||
"x": 4.5,
|
||||
"y": 1
|
||||
},
|
||||
{
|
||||
"label": "T",
|
||||
"x": 5.5,
|
||||
"y": 1
|
||||
},
|
||||
{
|
||||
"label": "Y",
|
||||
"x": 6.5,
|
||||
"y": 1
|
||||
},
|
||||
{
|
||||
"label": "U",
|
||||
"x": 7.5,
|
||||
"y": 1
|
||||
},
|
||||
{
|
||||
"label": "I",
|
||||
"x": 8.5,
|
||||
"y": 1
|
||||
},
|
||||
{
|
||||
"label": "O",
|
||||
"x": 9.5,
|
||||
"y": 1
|
||||
},
|
||||
{
|
||||
"label": "P",
|
||||
"x": 10.5,
|
||||
"y": 1
|
||||
},
|
||||
{
|
||||
"label": "{",
|
||||
"x": 11.5,
|
||||
"y": 1
|
||||
},
|
||||
{
|
||||
"label": "}",
|
||||
"x": 12.5,
|
||||
"y": 1
|
||||
},
|
||||
{
|
||||
"label": "Enter",
|
||||
"x": 13.75,
|
||||
"y": 1,
|
||||
"w": 1.25,
|
||||
"h": 2
|
||||
},
|
||||
{
|
||||
"label": "Page Up",
|
||||
"x": 15,
|
||||
"y": 1
|
||||
},
|
||||
{
|
||||
"label": "Caps Lock",
|
||||
"x": 0,
|
||||
"y": 2,
|
||||
"w": 1.75
|
||||
},
|
||||
{
|
||||
"label": "A",
|
||||
"x": 1.75,
|
||||
"y": 2
|
||||
},
|
||||
{
|
||||
"label": "S",
|
||||
"x": 2.75,
|
||||
"y": 2
|
||||
},
|
||||
{
|
||||
"label": "D",
|
||||
"x": 3.75,
|
||||
"y": 2
|
||||
},
|
||||
{
|
||||
"label": "F",
|
||||
"x": 4.75,
|
||||
"y": 2
|
||||
},
|
||||
{
|
||||
"label": "G",
|
||||
"x": 5.75,
|
||||
"y": 2
|
||||
},
|
||||
{
|
||||
"label": "H",
|
||||
"x": 6.75,
|
||||
"y": 2
|
||||
},
|
||||
{
|
||||
"label": "J",
|
||||
"x": 7.75,
|
||||
"y": 2
|
||||
},
|
||||
{
|
||||
"label": "K",
|
||||
"x": 8.75,
|
||||
"y": 2
|
||||
},
|
||||
{
|
||||
"label": "L",
|
||||
"x": 9.75,
|
||||
"y": 2
|
||||
},
|
||||
{
|
||||
"label": ":",
|
||||
"x": 10.75,
|
||||
"y": 2
|
||||
},
|
||||
{
|
||||
"label": "\"",
|
||||
"x": 11.75,
|
||||
"y": 2
|
||||
},
|
||||
{
|
||||
"label": "|",
|
||||
"x": 12.75,
|
||||
"y": 2
|
||||
},
|
||||
{
|
||||
"label": "Page Down",
|
||||
"x": 15,
|
||||
"y": 2
|
||||
},
|
||||
{
|
||||
"label": "Shift",
|
||||
"x": 0,
|
||||
"y": 3,
|
||||
"w": 1.25
|
||||
},
|
||||
{
|
||||
"label":"Win",
|
||||
"x": 1.25,
|
||||
"y": 3
|
||||
},
|
||||
{
|
||||
"label": "Z",
|
||||
"x": 2.25,
|
||||
"y": 3
|
||||
},
|
||||
{
|
||||
"label": "X",
|
||||
"x": 3.25,
|
||||
"y": 3
|
||||
},
|
||||
{
|
||||
"label": "C",
|
||||
"x": 4.25,
|
||||
"y": 3
|
||||
},
|
||||
{
|
||||
"label": "V",
|
||||
"x": 5.25,
|
||||
"y": 3
|
||||
},
|
||||
{
|
||||
"label": "B",
|
||||
"x": 6.25,
|
||||
"y": 3
|
||||
},
|
||||
{
|
||||
"label": "N",
|
||||
"x": 7.25,
|
||||
"y": 3
|
||||
},
|
||||
{
|
||||
"label": "M",
|
||||
"x": 8.25,
|
||||
"y": 3
|
||||
},
|
||||
{
|
||||
"label": "<",
|
||||
"x": 9.25,
|
||||
"y": 3
|
||||
},
|
||||
{
|
||||
"label": ">",
|
||||
"x": 10.25,
|
||||
"y": 3
|
||||
},
|
||||
{
|
||||
"label": "?",
|
||||
"x": 11.25,
|
||||
"y": 3
|
||||
},
|
||||
{
|
||||
"label": "Shift",
|
||||
"x": 12.25,
|
||||
"y": 3,
|
||||
"w": 1.75
|
||||
},
|
||||
{
|
||||
"label": "Up",
|
||||
"x": 14,
|
||||
"y": 3
|
||||
},
|
||||
{
|
||||
"label": "End",
|
||||
"x": 15,
|
||||
"y": 3
|
||||
},
|
||||
{
|
||||
"label": "Ctrl",
|
||||
"x": 0,
|
||||
"y": 4,
|
||||
"w": 1.25
|
||||
},
|
||||
{
|
||||
"label": "Win",
|
||||
"x": 1.25,
|
||||
"y": 4,
|
||||
"w": 1.25
|
||||
},
|
||||
{
|
||||
"label": "Alt",
|
||||
"x": 2.5,
|
||||
"y": 4,
|
||||
"w": 1.25
|
||||
},
|
||||
{
|
||||
"x": 3.75,
|
||||
"y": 4,
|
||||
"w": 6.25
|
||||
},
|
||||
{
|
||||
"label": "Alt",
|
||||
"x": 10,
|
||||
"y": 4,
|
||||
"w": 1.25
|
||||
},
|
||||
{
|
||||
"label": "Win",
|
||||
"x": 11.25,
|
||||
"y": 4,
|
||||
"w": 1.25
|
||||
},
|
||||
{
|
||||
"label": "Left",
|
||||
"x": 13,
|
||||
"y": 4
|
||||
},
|
||||
{
|
||||
"label": "Down",
|
||||
"x": 14,
|
||||
"y": 4
|
||||
},
|
||||
{
|
||||
"label": "Right",
|
||||
"x": 15,
|
||||
"y": 4
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
}
|
20
keyboards/matrix/noah/keymaps/default/keymap.c
Normal file
20
keyboards/matrix/noah/keymaps/default/keymap.c
Normal file
|
@ -0,0 +1,20 @@
|
|||
/**
|
||||
* keymap.c
|
||||
*/
|
||||
|
||||
#include QMK_KEYBOARD_H
|
||||
|
||||
const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = {
|
||||
[0] = LAYOUT_default(
|
||||
KC_ESC, 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_BSLS, KC_GRV, KC_PSCR,
|
||||
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_BSPC, KC_PGUP,
|
||||
KC_LCTRL, 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_PGDN,
|
||||
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_UP, KC_END,
|
||||
KC_CAPS, KC_LGUI, KC_LALT, KC_SPC, KC_RALT, MO(1), KC_LEFT, KC_DOWN, KC_RIGHT),
|
||||
[1] = LAYOUT_default(
|
||||
KC_BSLS, KC_F1, KC_F2, KC_F3, KC_F4, KC_F5, KC_F6, KC_F7, KC_F8, KC_F9, KC_F10, KC_F11, KC_F12, _______, _______, _______,
|
||||
RESET, RGB_TOG, RGB_MOD, _______, KC_F13, KC_F14, KC_F24, _______, _______, _______, _______, _______, _______, _______, _______,
|
||||
_______, _______, _______, _______, _______, _______, KC_LEFT, KC_DOWN, KC_UP,KC_RIGHT, _______, _______, _______, _______,
|
||||
_______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______,
|
||||
_______, _______, _______, _______, _______,_______, _______, _______, _______),
|
||||
};
|
20
keyboards/matrix/noah/keymaps/splitspace/keymap.c
Normal file
20
keyboards/matrix/noah/keymaps/splitspace/keymap.c
Normal file
|
@ -0,0 +1,20 @@
|
|||
/**
|
||||
* keymap.c
|
||||
*/
|
||||
|
||||
#include QMK_KEYBOARD_H
|
||||
|
||||
const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = {
|
||||
[0] = LAYOUT_default_splitspace(
|
||||
KC_ESC, 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_BSLS, KC_GRV, KC_PSCR,
|
||||
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_BSPC, KC_PGUP,
|
||||
KC_LCTRL, 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_PGDN,
|
||||
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_UP, KC_END,
|
||||
KC_CAPS, KC_LGUI, KC_LALT, KC_SPC, KC_SPC, KC_SPC, KC_RALT, MO(1), KC_LEFT, KC_DOWN, KC_RIGHT),
|
||||
[1] = LAYOUT_default_splitspace(
|
||||
KC_BSLS, KC_F1, KC_F2, KC_F3, KC_F4, KC_F5, KC_F6, KC_F7, KC_F8, KC_F9, KC_F10, KC_F11, KC_F12, _______, _______, _______,
|
||||
RESET, RGB_TOG, RGB_MOD, _______, KC_F13, KC_F14, KC_F24, _______, _______, _______, _______, _______, _______, _______, _______,
|
||||
_______, _______, _______, _______, _______, _______, KC_LEFT, KC_DOWN, KC_UP,KC_RIGHT, _______, _______, _______, _______,
|
||||
_______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______,
|
||||
_______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______),
|
||||
};
|
85
keyboards/matrix/noah/ld/noah_boot.ld
Normal file
85
keyboards/matrix/noah/ld/noah_boot.ld
Normal file
|
@ -0,0 +1,85 @@
|
|||
/*
|
||||
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.
|
||||
*/
|
||||
|
||||
/*
|
||||
* STM32F411xE memory setup.
|
||||
*/
|
||||
MEMORY
|
||||
{
|
||||
flash0 : org = 0x08020000, len = 512k-128k
|
||||
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 = 128k
|
||||
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
|
166
keyboards/matrix/noah/matrix.c
Normal file
166
keyboards/matrix/noah/matrix.c
Normal file
|
@ -0,0 +1,166 @@
|
|||
/**
|
||||
* matrix.c
|
||||
*/
|
||||
|
||||
#include <stdint.h>
|
||||
#include <stdbool.h>
|
||||
#include <string.h>
|
||||
#include "hal.h"
|
||||
#include "quantum.h"
|
||||
#include "timer.h"
|
||||
#include "wait.h"
|
||||
#include "printf.h"
|
||||
#include "matrix.h"
|
||||
|
||||
/**
|
||||
*
|
||||
* Row pins are input with internal pull-down.
|
||||
* Column pins are output and strobe with high.
|
||||
* Key is high or 1 when it turns on.
|
||||
*
|
||||
*/
|
||||
/* matrix state(1:on, 0:off) */
|
||||
static matrix_row_t matrix[MATRIX_ROWS];
|
||||
static matrix_row_t matrix_debouncing[MATRIX_COLS];
|
||||
static bool debouncing = false;
|
||||
static uint16_t debouncing_time = 0;
|
||||
|
||||
void matrix_init(void)
|
||||
{
|
||||
//debug_enable = true;
|
||||
palSetLineMode(LINE_COL_1, PAL_MODE_OUTPUT_PUSHPULL);
|
||||
palSetLineMode(LINE_COL_2, PAL_MODE_OUTPUT_PUSHPULL);
|
||||
palSetLineMode(LINE_COL_3, PAL_MODE_OUTPUT_PUSHPULL);
|
||||
palSetLineMode(LINE_COL_4, PAL_MODE_OUTPUT_PUSHPULL);
|
||||
palSetLineMode(LINE_COL_5, PAL_MODE_OUTPUT_PUSHPULL);
|
||||
palSetLineMode(LINE_COL_6, PAL_MODE_OUTPUT_PUSHPULL);
|
||||
palSetLineMode(LINE_COL_7, PAL_MODE_OUTPUT_PUSHPULL);
|
||||
palSetLineMode(LINE_COL_8, PAL_MODE_OUTPUT_PUSHPULL);
|
||||
palSetLineMode(LINE_COL_9, PAL_MODE_OUTPUT_PUSHPULL);
|
||||
palSetLineMode(LINE_COL_10, PAL_MODE_OUTPUT_PUSHPULL);
|
||||
palSetLineMode(LINE_COL_11, PAL_MODE_OUTPUT_PUSHPULL);
|
||||
palSetLineMode(LINE_COL_12, PAL_MODE_OUTPUT_PUSHPULL);
|
||||
palSetLineMode(LINE_COL_13, PAL_MODE_OUTPUT_PUSHPULL);
|
||||
palSetLineMode(LINE_COL_14, PAL_MODE_OUTPUT_PUSHPULL);
|
||||
palSetLineMode(LINE_COL_15, PAL_MODE_OUTPUT_PUSHPULL);
|
||||
|
||||
palSetLineMode(LINE_ROW_1, PAL_MODE_INPUT_PULLDOWN);
|
||||
palSetLineMode(LINE_ROW_2, PAL_MODE_INPUT_PULLDOWN);
|
||||
palSetLineMode(LINE_ROW_3, PAL_MODE_INPUT_PULLDOWN);
|
||||
palSetLineMode(LINE_ROW_4, PAL_MODE_INPUT_PULLDOWN);
|
||||
palSetLineMode(LINE_ROW_5, PAL_MODE_INPUT_PULLDOWN);
|
||||
|
||||
palClearLine(LINE_COL_1);
|
||||
palClearLine(LINE_COL_2);
|
||||
palClearLine(LINE_COL_3);
|
||||
palClearLine(LINE_COL_4);
|
||||
palClearLine(LINE_COL_5);
|
||||
palClearLine(LINE_COL_6);
|
||||
palClearLine(LINE_COL_7);
|
||||
palClearLine(LINE_COL_8);
|
||||
palClearLine(LINE_COL_9);
|
||||
palClearLine(LINE_COL_10);
|
||||
palClearLine(LINE_COL_11);
|
||||
palClearLine(LINE_COL_12);
|
||||
palClearLine(LINE_COL_13);
|
||||
palClearLine(LINE_COL_14);
|
||||
palClearLine(LINE_COL_15);
|
||||
|
||||
memset(matrix, 0, MATRIX_ROWS * sizeof(matrix_row_t));
|
||||
memset(matrix_debouncing, 0, MATRIX_COLS * sizeof(matrix_row_t));
|
||||
|
||||
matrix_init_quantum();
|
||||
}
|
||||
|
||||
uint8_t matrix_scan(void)
|
||||
{
|
||||
for (int col = 0; col < MATRIX_COLS; col++) {
|
||||
matrix_row_t data = 0;
|
||||
switch (col) {
|
||||
case 0: palSetLine(LINE_COL_1); break;
|
||||
case 1: palSetLine(LINE_COL_2); break;
|
||||
case 2: palSetLine(LINE_COL_3); break;
|
||||
case 3: palSetLine(LINE_COL_4); break;
|
||||
case 4: palSetLine(LINE_COL_5); break;
|
||||
case 5: palSetLine(LINE_COL_6); break;
|
||||
case 6: palSetLine(LINE_COL_7); break;
|
||||
case 7: palSetLine(LINE_COL_8); break;
|
||||
case 8: palSetLine(LINE_COL_9); break;
|
||||
case 9: palSetLine(LINE_COL_10); break;
|
||||
case 10: palSetLine(LINE_COL_11); break;
|
||||
case 11: palSetLine(LINE_COL_12); break;
|
||||
case 12: palSetLine(LINE_COL_13); break;
|
||||
case 13: palSetLine(LINE_COL_14); break;
|
||||
case 14: palSetLine(LINE_COL_15); break;
|
||||
}
|
||||
|
||||
// need wait to settle pin state
|
||||
wait_us(20);
|
||||
|
||||
data = (
|
||||
(palReadLine(LINE_ROW_1) << 0 ) |
|
||||
(palReadLine(LINE_ROW_2) << 1 ) |
|
||||
(palReadLine(LINE_ROW_3) << 2 ) |
|
||||
(palReadLine(LINE_ROW_4) << 3 ) |
|
||||
(palReadLine(LINE_ROW_5) << 4 )
|
||||
);
|
||||
|
||||
switch (col) {
|
||||
case 0: palClearLine(LINE_COL_1); break;
|
||||
case 1: palClearLine(LINE_COL_2); break;
|
||||
case 2: palClearLine(LINE_COL_3); break;
|
||||
case 3: palClearLine(LINE_COL_4); break;
|
||||
case 4: palClearLine(LINE_COL_5); break;
|
||||
case 5: palClearLine(LINE_COL_6); break;
|
||||
case 6: palClearLine(LINE_COL_7); break;
|
||||
case 7: palClearLine(LINE_COL_8); break;
|
||||
case 8: palClearLine(LINE_COL_9); break;
|
||||
case 9: palClearLine(LINE_COL_10); break;
|
||||
case 10: palClearLine(LINE_COL_11); break;
|
||||
case 11: palClearLine(LINE_COL_12); break;
|
||||
case 12: palClearLine(LINE_COL_13); break;
|
||||
case 13: palClearLine(LINE_COL_14); break;
|
||||
case 14: palClearLine(LINE_COL_15); break;
|
||||
}
|
||||
|
||||
if (matrix_debouncing[col] != data) {
|
||||
matrix_debouncing[col] = data;
|
||||
debouncing = true;
|
||||
debouncing_time = timer_read();
|
||||
}
|
||||
}
|
||||
|
||||
if (debouncing && timer_elapsed(debouncing_time) > DEBOUNCING_DELAY) {
|
||||
for (int row = 0; row < MATRIX_ROWS; row++) {
|
||||
matrix[row] = 0;
|
||||
for (int col = 0; col < MATRIX_COLS; col++) {
|
||||
matrix[row] |= ((matrix_debouncing[col] & (1 << row) ? 1 : 0) << col);
|
||||
}
|
||||
}
|
||||
debouncing = false;
|
||||
}
|
||||
|
||||
matrix_scan_quantum();
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
bool matrix_is_on(uint8_t row, uint8_t col) { return (matrix[row] & (1<<col)); }
|
||||
|
||||
matrix_row_t matrix_get_row(uint8_t row) { return matrix[row]; }
|
||||
|
||||
void matrix_print(void)
|
||||
{
|
||||
printf("\nr/c 01234567\n");
|
||||
for (uint8_t row = 0; row < MATRIX_ROWS; row++) {
|
||||
printf("%X0: ", row);
|
||||
matrix_row_t data = matrix_get_row(row);
|
||||
for (int col = 0; col < MATRIX_COLS; col++) {
|
||||
if (data & (1<<col))
|
||||
printf("1");
|
||||
else
|
||||
printf("0");
|
||||
}
|
||||
printf("\n");
|
||||
}
|
||||
}
|
268
keyboards/matrix/noah/mcuconf.h
Normal file
268
keyboards/matrix/noah/mcuconf.h
Normal file
|
@ -0,0 +1,268 @@
|
|||
/*
|
||||
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.
|
||||
*/
|
||||
|
||||
#ifndef MCUCONF_H
|
||||
#define MCUCONF_H
|
||||
|
||||
/*
|
||||
* STM32F4xx drivers configuration.
|
||||
* The following settings override the default settings present in
|
||||
* the various device driver implementation headers.
|
||||
* Note that the settings for each driver only have effect if the whole
|
||||
* driver is enabled in halconf.h.
|
||||
*
|
||||
* IRQ priorities:
|
||||
* 15...0 Lowest...Highest.
|
||||
*
|
||||
* DMA priorities:
|
||||
* 0...3 Lowest...Highest.
|
||||
*/
|
||||
|
||||
#define STM32F4xx_MCUCONF
|
||||
|
||||
/*
|
||||
* HAL driver system settings.
|
||||
*/
|
||||
#define STM32_NO_INIT FALSE
|
||||
#define STM32_HSI_ENABLED TRUE
|
||||
#define STM32_LSI_ENABLED TRUE
|
||||
#define STM32_HSE_ENABLED TRUE
|
||||
#define STM32_LSE_ENABLED FALSE
|
||||
#define STM32_CLOCK48_REQUIRED TRUE
|
||||
#define STM32_SW STM32_SW_PLL
|
||||
#define STM32_PLLSRC STM32_PLLSRC_HSE
|
||||
#define STM32_PLLM_VALUE 8
|
||||
#define STM32_PLLN_VALUE 192
|
||||
#define STM32_PLLP_VALUE 2
|
||||
#define STM32_PLLQ_VALUE 4
|
||||
#define STM32_HPRE STM32_HPRE_DIV1
|
||||
#define STM32_PPRE1 STM32_PPRE1_DIV2
|
||||
#define STM32_PPRE2 STM32_PPRE2_DIV2
|
||||
#define STM32_RTCSEL STM32_RTCSEL_LSI
|
||||
#define STM32_RTCPRE_VALUE 8
|
||||
#define STM32_MCO1SEL STM32_MCO1SEL_HSI
|
||||
#define STM32_MCO1PRE STM32_MCO1PRE_DIV1
|
||||
#define STM32_MCO2SEL STM32_MCO2SEL_SYSCLK
|
||||
#define STM32_MCO2PRE STM32_MCO2PRE_DIV5
|
||||
#define STM32_I2SSRC STM32_I2SSRC_PLLI2S
|
||||
#define STM32_PLLI2SN_VALUE 192
|
||||
#define STM32_PLLI2SR_VALUE 2
|
||||
#define STM32_PVD_ENABLE FALSE
|
||||
#define STM32_PLS STM32_PLS_LEV0
|
||||
#define STM32_BKPRAM_ENABLE FALSE
|
||||
|
||||
/*
|
||||
* ADC driver system settings.
|
||||
*/
|
||||
#define STM32_ADC_ADCPRE ADC_CCR_ADCPRE_DIV4
|
||||
#define STM32_ADC_USE_ADC1 FALSE
|
||||
#define STM32_ADC_ADC1_DMA_STREAM STM32_DMA_STREAM_ID(2, 4)
|
||||
#define STM32_ADC_ADC1_DMA_PRIORITY 2
|
||||
#define STM32_ADC_IRQ_PRIORITY 6
|
||||
#define STM32_ADC_ADC1_DMA_IRQ_PRIORITY 6
|
||||
|
||||
/*
|
||||
* EXT driver system settings.
|
||||
*/
|
||||
#define STM32_EXT_EXTI0_IRQ_PRIORITY 6
|
||||
#define STM32_EXT_EXTI1_IRQ_PRIORITY 6
|
||||
#define STM32_EXT_EXTI2_IRQ_PRIORITY 6
|
||||
#define STM32_EXT_EXTI3_IRQ_PRIORITY 6
|
||||
#define STM32_EXT_EXTI4_IRQ_PRIORITY 6
|
||||
#define STM32_EXT_EXTI5_9_IRQ_PRIORITY 6
|
||||
#define STM32_EXT_EXTI10_15_IRQ_PRIORITY 6
|
||||
#define STM32_EXT_EXTI16_IRQ_PRIORITY 6
|
||||
#define STM32_EXT_EXTI17_IRQ_PRIORITY 15
|
||||
#define STM32_EXT_EXTI18_IRQ_PRIORITY 6
|
||||
#define STM32_EXT_EXTI19_IRQ_PRIORITY 6
|
||||
#define STM32_EXT_EXTI22_IRQ_PRIORITY 15
|
||||
|
||||
/*
|
||||
* GPT driver system settings.
|
||||
*/
|
||||
#define STM32_GPT_USE_TIM1 FALSE
|
||||
#define STM32_GPT_USE_TIM2 FALSE
|
||||
#define STM32_GPT_USE_TIM3 FALSE
|
||||
#define STM32_GPT_USE_TIM4 TRUE
|
||||
#define STM32_GPT_USE_TIM5 FALSE
|
||||
#define STM32_GPT_USE_TIM9 FALSE
|
||||
#define STM32_GPT_USE_TIM11 FALSE
|
||||
#define STM32_GPT_TIM1_IRQ_PRIORITY 7
|
||||
#define STM32_GPT_TIM2_IRQ_PRIORITY 7
|
||||
#define STM32_GPT_TIM3_IRQ_PRIORITY 7
|
||||
#define STM32_GPT_TIM4_IRQ_PRIORITY 7
|
||||
#define STM32_GPT_TIM5_IRQ_PRIORITY 7
|
||||
#define STM32_GPT_TIM9_IRQ_PRIORITY 7
|
||||
#define STM32_GPT_TIM11_IRQ_PRIORITY 7
|
||||
|
||||
/*
|
||||
* I2C driver system settings.
|
||||
*/
|
||||
#define STM32_I2C_USE_I2C1 TRUE
|
||||
#define STM32_I2C_USE_I2C2 FALSE
|
||||
#define STM32_I2C_USE_I2C3 FALSE
|
||||
#define STM32_I2C_BUSY_TIMEOUT 50
|
||||
#define STM32_I2C_I2C1_RX_DMA_STREAM STM32_DMA_STREAM_ID(1, 0)
|
||||
#define STM32_I2C_I2C1_TX_DMA_STREAM STM32_DMA_STREAM_ID(1, 6)
|
||||
#define STM32_I2C_I2C2_RX_DMA_STREAM STM32_DMA_STREAM_ID(1, 2)
|
||||
#define STM32_I2C_I2C2_TX_DMA_STREAM STM32_DMA_STREAM_ID(1, 7)
|
||||
#define STM32_I2C_I2C3_RX_DMA_STREAM STM32_DMA_STREAM_ID(1, 2)
|
||||
#define STM32_I2C_I2C3_TX_DMA_STREAM STM32_DMA_STREAM_ID(1, 4)
|
||||
#define STM32_I2C_I2C1_IRQ_PRIORITY 5
|
||||
#define STM32_I2C_I2C2_IRQ_PRIORITY 5
|
||||
#define STM32_I2C_I2C3_IRQ_PRIORITY 5
|
||||
#define STM32_I2C_I2C1_DMA_PRIORITY 3
|
||||
#define STM32_I2C_I2C2_DMA_PRIORITY 3
|
||||
#define STM32_I2C_I2C3_DMA_PRIORITY 3
|
||||
#define STM32_I2C_DMA_ERROR_HOOK(i2cp) osalSysHalt("DMA failure")
|
||||
|
||||
/*
|
||||
* I2S driver system settings.
|
||||
*/
|
||||
#define STM32_I2S_USE_SPI2 FALSE
|
||||
#define STM32_I2S_USE_SPI3 FALSE
|
||||
#define STM32_I2S_SPI2_IRQ_PRIORITY 10
|
||||
#define STM32_I2S_SPI3_IRQ_PRIORITY 10
|
||||
#define STM32_I2S_SPI2_DMA_PRIORITY 1
|
||||
#define STM32_I2S_SPI3_DMA_PRIORITY 1
|
||||
#define STM32_I2S_SPI2_RX_DMA_STREAM STM32_DMA_STREAM_ID(1, 3)
|
||||
#define STM32_I2S_SPI2_TX_DMA_STREAM STM32_DMA_STREAM_ID(1, 4)
|
||||
#define STM32_I2S_SPI3_RX_DMA_STREAM STM32_DMA_STREAM_ID(1, 0)
|
||||
#define STM32_I2S_SPI3_TX_DMA_STREAM STM32_DMA_STREAM_ID(1, 7)
|
||||
#define STM32_I2S_DMA_ERROR_HOOK(i2sp) osalSysHalt("DMA failure")
|
||||
|
||||
/*
|
||||
* ICU driver system settings.
|
||||
*/
|
||||
#define STM32_ICU_USE_TIM1 FALSE
|
||||
#define STM32_ICU_USE_TIM2 FALSE
|
||||
#define STM32_ICU_USE_TIM3 FALSE
|
||||
#define STM32_ICU_USE_TIM4 FALSE
|
||||
#define STM32_ICU_USE_TIM5 FALSE
|
||||
#define STM32_ICU_USE_TIM9 FALSE
|
||||
#define STM32_ICU_TIM1_IRQ_PRIORITY 7
|
||||
#define STM32_ICU_TIM2_IRQ_PRIORITY 7
|
||||
#define STM32_ICU_TIM3_IRQ_PRIORITY 7
|
||||
#define STM32_ICU_TIM4_IRQ_PRIORITY 7
|
||||
#define STM32_ICU_TIM5_IRQ_PRIORITY 7
|
||||
#define STM32_ICU_TIM9_IRQ_PRIORITY 7
|
||||
|
||||
/*
|
||||
* PWM driver system settings.
|
||||
*/
|
||||
#define STM32_PWM_USE_ADVANCED FALSE
|
||||
#define STM32_PWM_USE_TIM1 TRUE
|
||||
#define STM32_PWM_USE_TIM2 FALSE
|
||||
#define STM32_PWM_USE_TIM3 TRUE
|
||||
#define STM32_PWM_USE_TIM4 FALSE
|
||||
#define STM32_PWM_USE_TIM5 FALSE
|
||||
#define STM32_PWM_USE_TIM9 FALSE
|
||||
#define STM32_PWM_TIM1_IRQ_PRIORITY 7
|
||||
#define STM32_PWM_TIM2_IRQ_PRIORITY 7
|
||||
#define STM32_PWM_TIM3_IRQ_PRIORITY 7
|
||||
#define STM32_PWM_TIM4_IRQ_PRIORITY 7
|
||||
#define STM32_PWM_TIM5_IRQ_PRIORITY 7
|
||||
#define STM32_PWM_TIM9_IRQ_PRIORITY 7
|
||||
|
||||
/*
|
||||
* SERIAL driver system settings.
|
||||
*/
|
||||
#define STM32_SERIAL_USE_USART1 FALSE
|
||||
#define STM32_SERIAL_USE_USART2 FALSE
|
||||
#define STM32_SERIAL_USE_USART3 FALSE
|
||||
#define STM32_SERIAL_USE_USART6 FALSE
|
||||
#define STM32_SERIAL_USART1_PRIORITY 12
|
||||
#define STM32_SERIAL_USART2_PRIORITY 12
|
||||
#define STM32_SERIAL_USART3_PRIORITY 12
|
||||
#define STM32_SERIAL_USART6_PRIORITY 12
|
||||
|
||||
/*
|
||||
* SPI driver system settings.
|
||||
*/
|
||||
#define STM32_SPI_USE_SPI1 TRUE
|
||||
#define STM32_SPI_USE_SPI2 FALSE
|
||||
#define STM32_SPI_USE_SPI3 FALSE
|
||||
#define STM32_SPI_USE_SPI4 FALSE
|
||||
#define STM32_SPI_USE_SPI5 FALSE
|
||||
#define STM32_SPI_SPI1_RX_DMA_STREAM STM32_DMA_STREAM_ID(2, 0)
|
||||
#define STM32_SPI_SPI1_TX_DMA_STREAM STM32_DMA_STREAM_ID(2, 3)
|
||||
#define STM32_SPI_SPI2_RX_DMA_STREAM STM32_DMA_STREAM_ID(1, 3)
|
||||
#define STM32_SPI_SPI2_TX_DMA_STREAM STM32_DMA_STREAM_ID(1, 4)
|
||||
#define STM32_SPI_SPI3_RX_DMA_STREAM STM32_DMA_STREAM_ID(1, 0)
|
||||
#define STM32_SPI_SPI3_TX_DMA_STREAM STM32_DMA_STREAM_ID(1, 7)
|
||||
#define STM32_SPI_SPI4_RX_DMA_STREAM STM32_DMA_STREAM_ID(2, 4)
|
||||
#define STM32_SPI_SPI4_TX_DMA_STREAM STM32_DMA_STREAM_ID(2, 1)
|
||||
#define STM32_SPI_SPI5_RX_DMA_STREAM STM32_DMA_STREAM_ID(2, 5)
|
||||
#define STM32_SPI_SPI5_TX_DMA_STREAM STM32_DMA_STREAM_ID(2, 6)
|
||||
#define STM32_SPI_SPI1_DMA_PRIORITY 1
|
||||
#define STM32_SPI_SPI2_DMA_PRIORITY 1
|
||||
#define STM32_SPI_SPI3_DMA_PRIORITY 1
|
||||
#define STM32_SPI_SPI4_DMA_PRIORITY 1
|
||||
#define STM32_SPI_SPI5_DMA_PRIORITY 1
|
||||
#define STM32_SPI_SPI1_IRQ_PRIORITY 10
|
||||
#define STM32_SPI_SPI2_IRQ_PRIORITY 10
|
||||
#define STM32_SPI_SPI3_IRQ_PRIORITY 10
|
||||
#define STM32_SPI_SPI4_IRQ_PRIORITY 10
|
||||
#define STM32_SPI_SPI5_IRQ_PRIORITY 10
|
||||
#define STM32_SPI_DMA_ERROR_HOOK(spip) osalSysHalt("DMA failure")
|
||||
|
||||
/*
|
||||
* ST driver system settings.
|
||||
*/
|
||||
#define STM32_ST_IRQ_PRIORITY 8
|
||||
#define STM32_ST_USE_TIMER 2
|
||||
|
||||
/*
|
||||
* UART driver system settings.
|
||||
*/
|
||||
#define STM32_UART_USE_USART1 FALSE
|
||||
#define STM32_UART_USE_USART2 FALSE
|
||||
#define STM32_UART_USE_USART3 FALSE
|
||||
#define STM32_UART_USE_USART6 FALSE
|
||||
#define STM32_UART_USART1_RX_DMA_STREAM STM32_DMA_STREAM_ID(2, 5)
|
||||
#define STM32_UART_USART1_TX_DMA_STREAM STM32_DMA_STREAM_ID(2, 7)
|
||||
#define STM32_UART_USART2_RX_DMA_STREAM STM32_DMA_STREAM_ID(1, 5)
|
||||
#define STM32_UART_USART2_TX_DMA_STREAM STM32_DMA_STREAM_ID(1, 6)
|
||||
#define STM32_UART_USART3_RX_DMA_STREAM STM32_DMA_STREAM_ID(1, 1)
|
||||
#define STM32_UART_USART3_TX_DMA_STREAM STM32_DMA_STREAM_ID(1, 3)
|
||||
#define STM32_UART_USART6_RX_DMA_STREAM STM32_DMA_STREAM_ID(2, 2)
|
||||
#define STM32_UART_USART6_TX_DMA_STREAM STM32_DMA_STREAM_ID(2, 7)
|
||||
#define STM32_UART_USART1_IRQ_PRIORITY 12
|
||||
#define STM32_UART_USART2_IRQ_PRIORITY 12
|
||||
#define STM32_UART_USART3_IRQ_PRIORITY 12
|
||||
#define STM32_UART_USART6_IRQ_PRIORITY 12
|
||||
#define STM32_UART_USART1_DMA_PRIORITY 0
|
||||
#define STM32_UART_USART2_DMA_PRIORITY 0
|
||||
#define STM32_UART_USART3_DMA_PRIORITY 0
|
||||
#define STM32_UART_USART6_DMA_PRIORITY 0
|
||||
#define STM32_UART_DMA_ERROR_HOOK(uartp) osalSysHalt("DMA failure")
|
||||
|
||||
/*
|
||||
* USB driver system settings.
|
||||
*/
|
||||
#define STM32_USB_USE_OTG1 TRUE
|
||||
#define STM32_USB_OTG1_IRQ_PRIORITY 14
|
||||
#define STM32_USB_OTG1_RX_FIFO_SIZE 512
|
||||
#define STM32_USB_OTG_THREAD_PRIO LOWPRIO
|
||||
#define STM32_USB_OTG_THREAD_STACK_SIZE 128
|
||||
#define STM32_USB_OTGFIFO_FILL_BASEPRI 0
|
||||
|
||||
/*
|
||||
* WDG driver system settings.
|
||||
*/
|
||||
#define STM32_WDG_USE_IWDG FALSE
|
||||
|
||||
#endif /* MCUCONF_H */
|
243
keyboards/matrix/noah/noah.c
Normal file
243
keyboards/matrix/noah/noah.c
Normal file
|
@ -0,0 +1,243 @@
|
|||
/**
|
||||
* noah.c
|
||||
*/
|
||||
|
||||
#include "noah.h"
|
||||
|
||||
#ifdef RGBLIGHT_ENABLE
|
||||
#include <string.h>
|
||||
#include "rgblight.h"
|
||||
#include "ws2812_f4.h"
|
||||
extern rgblight_config_t rgblight_config;
|
||||
|
||||
// led 0 for caps lock, led 1 for scroll lock, led 3 for num lock
|
||||
// led 4 for layer 1, led 5 for layer 2, led 6 for layer 3, led 7 for layer 4
|
||||
#if RGBLED_NUM < 7
|
||||
#error "MUST set the RGBLED_NUM bigger than 7"
|
||||
#endif
|
||||
LED_TYPE noah_leds[RGBLED_NUM];
|
||||
static bool noah_led_mode = false;
|
||||
void rgblight_set(void) {
|
||||
memset(&noah_leds[0], 0, sizeof(noah_leds));
|
||||
if (!rgblight_config.enable) {
|
||||
for (uint8_t i = 0; i < RGBLED_NUM; i++) {
|
||||
led[i].r = 0;
|
||||
led[i].g = 0;
|
||||
led[i].b = 0;
|
||||
}
|
||||
}
|
||||
if (noah_led_mode) {
|
||||
uint8_t ind_led = host_keyboard_leds();
|
||||
if (IS_LED_ON(ind_led, USB_LED_CAPS_LOCK)) {
|
||||
noah_leds[0] = led[0];
|
||||
}
|
||||
if (IS_LED_ON(ind_led, USB_LED_SCROLL_LOCK)) {
|
||||
noah_leds[1] = led[1];
|
||||
}
|
||||
if (IS_LED_ON(ind_led, USB_LED_NUM_LOCK)) {
|
||||
noah_leds[2] = led[2];
|
||||
}
|
||||
for (int32_t i = 0; i < 4; i++) {
|
||||
if(layer_state_is(i+1)) {
|
||||
noah_leds[i + 3] = led[i + 3];
|
||||
}
|
||||
}
|
||||
} else {
|
||||
memcpy(&noah_leds[0], &led[0], sizeof(noah_leds));
|
||||
}
|
||||
|
||||
ws2812_setleds(noah_leds, RGBLED_NUM);
|
||||
}
|
||||
#endif
|
||||
|
||||
void matrix_scan_kb(void) { matrix_scan_user(); }
|
||||
|
||||
void matrix_init_kb(void) {
|
||||
matrix_init_user();
|
||||
}
|
||||
__attribute__((weak))
|
||||
void matrix_init_user(void) {
|
||||
#ifdef RGBLIGHT_ENABLE
|
||||
ws2812_init();
|
||||
rgblight_enable();
|
||||
#endif
|
||||
|
||||
#ifdef RGB_MATRIX_ENABLE
|
||||
rgb_matrix_disable();
|
||||
#endif
|
||||
}
|
||||
|
||||
__attribute__((weak))
|
||||
void matrix_scan_user(void) {
|
||||
#ifdef RGBLIGHT_ENABLE
|
||||
rgblight_task();
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
#ifdef RGB_MATRIX_ENABLE
|
||||
const is31_led g_is31_leds[DRIVER_LED_TOTAL] = {
|
||||
/* Refer to IS31 manual for these locations
|
||||
* driver
|
||||
* | R location
|
||||
* | | G location
|
||||
* | | | B location
|
||||
* | | | | */
|
||||
|
||||
// left CB
|
||||
{0, C1_9, C3_10, C4_10},
|
||||
{0, C1_10, C2_10, C4_11},
|
||||
{0, C1_11, C2_11, C3_11},
|
||||
{0, C1_12, C2_12, C3_12},
|
||||
{0, C1_13, C2_13, C3_13},
|
||||
{0, C1_14, C2_14, C3_14},
|
||||
{0, C1_15, C2_15, C3_15},
|
||||
{0, C1_16, C2_16, C3_16},
|
||||
|
||||
{0, C5_9, C4_9, C6_9},
|
||||
{0, C5_16, C4_16, C6_16},
|
||||
|
||||
{0, C9_9, C8_9, C7_9},
|
||||
{0, C9_10, C8_10, C7_10},
|
||||
{0, C9_11, C8_11, C7_11},
|
||||
{0, C9_12, C8_12, C7_12},
|
||||
{0, C9_13, C8_13, C7_13},
|
||||
{0, C9_14, C8_14, C7_14},
|
||||
{0, C9_15, C8_15, C6_14},
|
||||
{0, C9_16, C7_15, C6_15},
|
||||
|
||||
// left CA
|
||||
{0, C1_1, C3_2, C4_2},
|
||||
{0, C1_2, C2_2, C4_3},
|
||||
{0, C1_3, C2_3, C3_3},
|
||||
{0, C1_4, C2_4, C3_4},
|
||||
{0, C1_5, C2_5, C3_5},
|
||||
{0, C1_6, C2_6, C3_6},
|
||||
{0, C1_7, C2_7, C3_7},
|
||||
{0, C1_8, C2_8, C3_8},
|
||||
|
||||
{0, C5_1, C4_1, C6_1},
|
||||
{0, C5_8, C4_8, C6_8},
|
||||
|
||||
{0, C9_1, C8_1, C7_1},
|
||||
{0, C9_2, C8_2, C7_2},
|
||||
{0, C9_3, C8_3, C7_3},
|
||||
{0, C9_4, C8_4, C7_4},
|
||||
{0, C9_5, C8_5, C7_5},
|
||||
{0, C9_6, C8_6, C7_6},
|
||||
{0, C9_7, C8_7, C6_6},
|
||||
{0, C9_8, C7_7, C6_7},
|
||||
|
||||
// right CA
|
||||
{1, C1_1, C3_2, C4_2},
|
||||
{1, C1_2, C2_2, C4_3},
|
||||
{1, C1_3, C2_3, C3_3},
|
||||
{1, C1_4, C2_4, C3_4},
|
||||
{1, C1_5, C2_5, C3_5},
|
||||
{1, C1_6, C2_6, C3_6},
|
||||
{1, C1_7, C2_7, C3_7},
|
||||
{1, C1_8, C2_8, C3_8},
|
||||
|
||||
{1, C5_1, C4_1, C6_1},
|
||||
{1, C5_8, C4_8, C6_8},
|
||||
|
||||
{1, C9_1, C8_1, C7_1},
|
||||
{1, C9_2, C8_2, C7_2},
|
||||
{1, C9_3, C8_3, C7_3},
|
||||
{1, C9_4, C8_4, C7_4},
|
||||
{1, C9_5, C8_5, C7_5},
|
||||
{1, C9_6, C8_6, C7_6},
|
||||
{1, C9_7, C8_7, C6_6},
|
||||
{1, C9_8, C7_7, C6_7},
|
||||
// right CB
|
||||
{1, C1_9, C3_10, C4_10},
|
||||
{1, C1_10, C2_10, C4_11},
|
||||
{1, C1_11, C2_11, C3_11},
|
||||
{1, C1_12, C2_12, C3_12},
|
||||
{1, C1_13, C2_13, C3_13},
|
||||
{1, C1_14, C2_14, C3_14},
|
||||
{1, C1_15, C2_15, C3_15},
|
||||
{1, C1_16, C2_16, C3_16},
|
||||
|
||||
{1, C5_9, C4_9, C6_9},
|
||||
{1, C5_16, C4_16, C6_16},
|
||||
|
||||
{1, C9_9, C8_9, C7_9},
|
||||
{1, C9_10, C8_10, C7_10},
|
||||
{1, C9_11, C8_11, C7_11},
|
||||
{1, C9_12, C8_12, C7_12},
|
||||
{1, C9_13, C8_13, C7_13},
|
||||
{1, C9_14, C8_14, C7_14},
|
||||
{1, C9_15, C8_15, C6_14},
|
||||
{1, C9_16, C7_15, C6_15},
|
||||
};
|
||||
|
||||
led_config_t g_led_config = {
|
||||
{
|
||||
{ 1, 2, 3, 4, 5, 6, 7, 36, 37, 38, 39, 40, NO_LED, 41},
|
||||
{ 0, 8, 10, 11, 12, 13, 14, 44, 46, 47, 48, 49, 50, 51},
|
||||
{ 30, 18, 26, 9, 19, 15, 16, 17, 55, 56, 57, 58, 59, 60},
|
||||
{ 29, 31, 32, 33, 20, 21, 23, 22, 54, 62, 64, 65, 66, 63},
|
||||
{ 34, 35, 27, 25, 67, 68, 69, 70, 71, 61, 53, 45, 42, 43},
|
||||
},
|
||||
{
|
||||
{ 0, 16},{ 0, 0},{ 15, 0},{ 30, 0},{ 45, 0},{ 60, 0},{ 75, 0},{ 90, 0},
|
||||
{ 20, 16},{ 42, 32},
|
||||
{ 45, 16},{ 50, 16},{ 65, 16},{ 80, 16},{ 95, 16},{ 70, 32},{ 84, 32},{ 98, 32},
|
||||
|
||||
{ 14, 32},{ 56, 32},{ 50, 48},{ 80, 48},{110, 48},{ 95, 48},{100, 64},{112, 64},
|
||||
{ 42, 32},{ 38, 64},
|
||||
{ 0, 32},{ 10, 48},{ 0, 48},{ 20, 48},{ 35, 48},{ 65, 48},{ 0, 64},{ 19, 64},
|
||||
|
||||
{105, 0},{120, 0},{135, 0},{150, 0},{165, 0},{180, 0},{202, 0},{224, 0},
|
||||
{110, 16},{224, 16},
|
||||
{125, 16},{140, 16},{155, 16},{172, 16},{187, 16},{202, 16},{210, 32},{224, 32},
|
||||
|
||||
{125, 48},{112, 32},{126, 32},{140, 32},{154, 32},{168, 32},{182, 32},{224, 48},
|
||||
{140, 48},{200, 48},
|
||||
{155, 48},{170, 48},{185, 48},{150, 64},{173, 64},{195, 64},{210, 64},{224, 64}
|
||||
},
|
||||
{
|
||||
1, 1, 4, 4, 4, 4, 4, 4,
|
||||
4, 4,
|
||||
4, 4, 4, 4, 4, 4, 4, 4,
|
||||
|
||||
4, 4, 4, 4, 4, 4, 4, 4,
|
||||
4, 4,
|
||||
1, 1, 1, 4, 4, 4, 1, 1,
|
||||
|
||||
4, 4, 4, 4, 4, 4, 1, 1,
|
||||
4, 1,
|
||||
4, 4, 4, 4, 4, 4, 4, 1,
|
||||
|
||||
4, 4, 4, 4, 4, 4, 4, 1,
|
||||
4, 4,
|
||||
4, 4, 4, 1, 1, 1, 1, 1,
|
||||
}
|
||||
};
|
||||
|
||||
#endif
|
||||
|
||||
bool process_record_kb(uint16_t keycode, keyrecord_t *record) {
|
||||
if (record->event.pressed) {
|
||||
switch(keycode) {
|
||||
#ifdef RGBLIGHT_ENABLE
|
||||
case KC_F24: // switch the led mode on or off
|
||||
noah_led_mode = !noah_led_mode;
|
||||
return false;
|
||||
|
||||
#ifdef RGB_MATRIX_ENABLE
|
||||
case KC_F13: // toggle rgb matrix
|
||||
rgb_matrix_toggle();
|
||||
return false;
|
||||
case KC_F14:
|
||||
rgb_matrix_step();
|
||||
return false;
|
||||
#endif
|
||||
#endif
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
91
keyboards/matrix/noah/noah.h
Normal file
91
keyboards/matrix/noah/noah.h
Normal file
|
@ -0,0 +1,91 @@
|
|||
/**
|
||||
* noah.h
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "quantum.h"
|
||||
|
||||
#define LAYOUT_default( \
|
||||
k00, k01, k02, k03, k04, k05, k06, k07, k08, k09, k0a, k0b, k0c, k0d, k0e, k0f, \
|
||||
k10, k11, k12, k13, k14, k15, k16, k17, k18, k19, k1a, k1b, k1c, k1d, k1e, \
|
||||
k20, k21, k22, k23, k24, k25, k26, k27, k28, k29, k2a, k2b, k2d, k2e, \
|
||||
k30, k32, k33, k34, k35, k36, k37, k38, k39, k3a, k3b, k3c, k3d, k3e, \
|
||||
k40, k41, k42, k43, k44, k45, k46, k47, k48) \
|
||||
{ \
|
||||
{k00, k01, k02, k03, k04, k05, k06, k07, k08, k09, k0a, k0b, k0c, k0d, k0e}, \
|
||||
{k10, k11, k12, k13, k14, k15, k16, k17, k18, k19, k1a, k1b, k1c, k1d, KC_NO}, \
|
||||
{k20, k21, k22, k23, k24, k25, k26, k27, k28, k29, k2a, k2b,KC_NO,k2d, KC_NO}, \
|
||||
{k30,KC_NO,k32, k33, k34, k35, k36, k37, k38, k39, k3a, k3b, k3c, k3d, KC_NO}, \
|
||||
{k40, k41, k42,KC_NO,k43,KC_NO,k44, k45, k46, k47, k48, k1e, k2e, k3e, k0f} \
|
||||
}
|
||||
|
||||
#define LAYOUT_wkl( \
|
||||
k00, k01, k02, k03, k04, k05, k06, k07, k08, k09, k0a, k0b, k0c, k0d, k0e, k0f, \
|
||||
k10, k11, k12, k13, k14, k15, k16, k17, k18, k19, k1a, k1b, k1c, k1d, k1e, \
|
||||
k20, k21, k22, k23, k24, k25, k26, k27, k28, k29, k2a, k2b, k2d, k2e, \
|
||||
k30, k32, k33, k34, k35, k36, k37, k38, k39, k3a, k3b, k3c, k3d, k3e, \
|
||||
k40, k41, k42, k43, k45, k46, k47, k48 \
|
||||
) { \
|
||||
{k00, k01, k02, k03, k04, k05, k06, k07, k08, k09, k0a, k0b, k0c, k0d, k0e}, \
|
||||
{k10, k11, k12, k13, k14, k15, k16, k17, k18, k19, k1a, k1b, k1c, k1d, KC_NO}, \
|
||||
{k20, k21, k22, k23, k24, k25, k26, k27, k28, k29, k2a, k2b,KC_NO,k2d, KC_NO}, \
|
||||
{k30,KC_NO,k32, k33, k34, k35, k36, k37, k38, k39, k3a, k3b, k3c, k3d, KC_NO}, \
|
||||
{k40, k41, k42,KC_NO,k43,KC_NO,KC_NO, k45, k46, k47, k48, k1e, k2e, k3e, k0f} \
|
||||
}
|
||||
|
||||
#define LAYOUT_iso( \
|
||||
k00, k01, k02, k03, k04, k05, k06, k07, k08, k09, k0a, k0b, k0c, k0e, k0f, \
|
||||
k10, k11, k12, k13, k14, k15, k16, k17, k18, k19, k1a, k1b, k1c, k1e, \
|
||||
k20, k21, k22, k23, k24, k25, k26, k27, k28, k29, k2a, k2b, k2c, k2d, k2e, \
|
||||
k30, k31, k32, k33, k34, k35, k36, k37, k38, k39, k3a, k3b, k3c, k3d, k3e, \
|
||||
k40, k41, k42, k43, k45, k46, k47, k48 \
|
||||
) { \
|
||||
{k00, k01, k02, k03, k04, k05, k06, k07, k08, k09, k0a, k0b, k0c, k0d, k0e}, \
|
||||
{k10, k11, k12, k13, k14, k15, k16, k17, k18, k19, k1a, k1b, k1c, k1d, KC_NO}, \
|
||||
{k20, k21, k22, k23, k24, k25, k26, k27, k28, k29, k2a, k2b, k2c, k2d, KC_NO}, \
|
||||
{k30, k31, k32, k33, k34, k35, k36, k37, k38, k39, k3a, k3b, k3c, k3d, KC_NO}, \
|
||||
{k40, k41, k42,KC_NO,k43,KC_NO,KC_NO, k45, k46, k47, k48, k1e, k2e, k3e, k0f} \
|
||||
}
|
||||
|
||||
#define LAYOUT_default_splitspace( \
|
||||
k00, k01, k02, k03, k04, k05, k06, k07, k08, k09, k0a, k0b, k0c, k0d, k0e, k0f, \
|
||||
k10, k11, k12, k13, k14, k15, k16, k17, k18, k19, k1a, k1b, k1c, k1d, k1e, \
|
||||
k20, k21, k22, k23, k24, k25, k26, k27, k28, k29, k2a, k2b, k2d, k2e, \
|
||||
k30, k32, k33, k34, k35, k36, k37, k38, k39, k3a, k3b, k3c, k3d, k3e, \
|
||||
k40, k41, k42, k43, k44, k45, k46, k47, k48, k49, k4a \
|
||||
) { \
|
||||
{k00, k01, k02, k03, k04, k05, k06, k07, k08, k09, k0a, k0b, k0c, k0d, k0e}, \
|
||||
{k10, k11, k12, k13, k14, k15, k16, k17, k18, k19, k1a, k1b, k1c, k1d, KC_NO}, \
|
||||
{k20, k21, k22, k23, k24, k25, k26, k27, k28, k29, k2a, k2b,KC_NO,k2d, KC_NO}, \
|
||||
{k30,KC_NO,k32, k33, k34, k35, k36, k37, k38, k39, k3a, k3b, k3c, k3d, KC_NO}, \
|
||||
{k40, k41, k42, k43, k44, k45, k46, k47, k48, k49, k4a, k1e, k2e, k3e, k0f} \
|
||||
}
|
||||
|
||||
#define LAYOUT_wkl_splitspace( \
|
||||
k00, k01, k02, k03, k04, k05, k06, k07, k08, k09, k0a, k0b, k0c, k0d, k0e, k0f, \
|
||||
k10, k11, k12, k13, k14, k15, k16, k17, k18, k19, k1a, k1b, k1c, k1d, k1e, \
|
||||
k20, k21, k22, k23, k24, k25, k26, k27, k28, k29, k2a, k2b, k2d, k2e, \
|
||||
k30, k32, k33, k34, k35, k36, k37, k38, k39, k3a, k3b, k3c, k3d, k3e, \
|
||||
k40, k41, k42, k43, k45, k46, k47, k48, k49, k4a \
|
||||
) { \
|
||||
{k00, k01, k02, k03, k04, k05, k06, k07, k08, k09, k0a, k0b, k0c, k0d, k0e}, \
|
||||
{k10, k11, k12, k13, k14, k15, k16, k17, k18, k19, k1a, k1b, k1c, k1d, KC_NO}, \
|
||||
{k20, k21, k22, k23, k24, k25, k26, k27, k28, k29, k2a, k2b,KC_NO,k2d, KC_NO}, \
|
||||
{k30,KC_NO,k32, k33, k34, k35, k36, k37, k38, k39, k3a, k3b, k3c, k3d, KC_NO}, \
|
||||
{k40, k41, k42, k43, k45,KC_NO,k46, k47, k48, k49, k4a, k1e, k2e, k3e, k0f} \
|
||||
}
|
||||
|
||||
#define LAYOUT_iso_splitspace( \
|
||||
k00, k01, k02, k03, k04, k05, k06, k07, k08, k09, k0a, k0b, k0c, k0e, k0f, \
|
||||
k10, k11, k12, k13, k14, k15, k16, k17, k18, k19, k1a, k1b, k1c, k1e, \
|
||||
k20, k21, k22, k23, k24, k25, k26, k27, k28, k29, k2a, k2b, k2c, k2d, k2e, \
|
||||
k30, k31, k32, k33, k34, k35, k36, k37, k38, k39, k3a, k3b, k3c, k3d, k3e, \
|
||||
k40, k41, k42, k43, k45, k46, k47, k48, k49, k4a \
|
||||
) { \
|
||||
{k00, k01, k02, k03, k04, k05, k06, k07, k08, k09, k0a, k0b, k0c, k0d, k0e}, \
|
||||
{k10, k11, k12, k13, k14, k15, k16, k17, k18, k19, k1a, k1b, k1c, k1d, KC_NO}, \
|
||||
{k20, k21, k22, k23, k24, k25, k26, k27, k28, k29, k2a, k2b, k2c, k2d, KC_NO}, \
|
||||
{k30, k31, k32, k33, k34, k35, k36, k37, k38, k39, k3a, k3b, k3c, k3d, KC_NO}, \
|
||||
{k40, k41, k42, k43, k45,KC_NO,k46, k47, k48, k49, k4a, k1e, k2e, k3e, k0f} \
|
||||
}
|
19
keyboards/matrix/noah/readme.md
Normal file
19
keyboards/matrix/noah/readme.md
Normal file
|
@ -0,0 +1,19 @@
|
|||
# NOAH 65 keyboard
|
||||
|
||||
![NOAH](https://raw.githubusercontent.com/yulei/qmk_webusb_tool/master/public/noah.jpg)
|
||||
This was the first 65% keyboard made by the Matrix team, it had the following features:
|
||||
|
||||
- per key rgb led
|
||||
- 7 RGB led for caps, scroll , num lock and layer state indicator, or just play light animation effects
|
||||
- ansi and iso layouts, and split spacebar supported
|
||||
- pre-programmed bootloader which emulated usb stick to ease firmware updating
|
||||
|
||||
Keyboard Maintainer: [astro](https://github.com/yulei)
|
||||
Hardware Supported: Matrix NOAH keyboard
|
||||
Hardware Availability: [NOAH Keybaord](https://geekhack.org/index.php?topic=102300.0)
|
||||
|
||||
Make example for this keyboard (after setting up your build environment):
|
||||
|
||||
make matrix/noah:default
|
||||
|
||||
See the [build environment setup](https://docs.qmk.fm/#/getting_started_build_tools) and the [make instructions](https://docs.qmk.fm/#/getting_started_make_guide) for more information. Brand new to QMK? Start with our [Complete Newbs Guide](https://docs.qmk.fm/#/newbs).
|
57
keyboards/matrix/noah/rules.mk
Normal file
57
keyboards/matrix/noah/rules.mk
Normal file
|
@ -0,0 +1,57 @@
|
|||
## chip/board settings
|
||||
# - the next two should match the directories in
|
||||
# <chibios>/os/hal/ports/$(MCU_FAMILY)/$(MCU_SERIES)
|
||||
MCU_FAMILY = STM32
|
||||
MCU_SERIES = STM32F4xx
|
||||
|
||||
# Linker script to use
|
||||
# - it should exist either in <chibios>/os/common/ports/ARMCMx/compilers/GCC/ld/
|
||||
# or <this_dir>/ld/
|
||||
MCU_LDSCRIPT = noah_boot
|
||||
|
||||
# Startup code to use
|
||||
# - it should exist in <chibios>/os/common/startup/ARMCMx/compilers/GCC/mk/
|
||||
MCU_STARTUP = stm32f4xx
|
||||
|
||||
# Board: it should exist either in <chibios>/os/hal/boards/
|
||||
# or <this_dir>/boards
|
||||
BOARD = noah_bd
|
||||
|
||||
# Cortex version
|
||||
MCU = cortex-m4
|
||||
|
||||
# ARM version, CORTEX-M0/M1 are 6, CORTEX-M3/M4/M7 are 7
|
||||
ARMV = 7
|
||||
|
||||
USE_FPU = yes
|
||||
|
||||
# Vector table for application
|
||||
# 0x00000000-0x00001000 area is occupied by bootlaoder.*/
|
||||
OPT_DEFS =
|
||||
|
||||
# Options to pass to dfu-util when flashing
|
||||
#DFU_ARGS = -d 0483:df11 -a 0 -s 0x08000000:leave
|
||||
#DFU_SUFFIX_ARGS = -p DF11 -v 0483
|
||||
|
||||
# Build Options
|
||||
# comment out to disable the options.
|
||||
#
|
||||
BOOTMAGIC_ENABLE = yes # Virtual DIP switch configuration
|
||||
MOUSEKEY_ENABLE = no # Mouse keys
|
||||
EXTRAKEY_ENABLE = yes # Audio control and System control
|
||||
CONSOLE_ENABLE = no # Console for debug
|
||||
COMMAND_ENABLE = no # Commands for debug and configuration
|
||||
NKRO_ENABLE = no # USB Nkey Rollover
|
||||
NO_USB_STARTUP_CHECK = yes # Disable initialization only when usb is plugged in
|
||||
|
||||
CUSTOM_MATRIX = yes
|
||||
RGB_MATRIX_ENABLE = yes
|
||||
|
||||
RGBLIGHT_ENABLE = yes
|
||||
RGBLIGHT_CUSTOM_DRIVER = yes
|
||||
|
||||
# project specific files
|
||||
SRC += \
|
||||
matrix.c \
|
||||
ws2812_f4.c \
|
||||
eeprom_f4.c
|
272
keyboards/matrix/noah/ws2812_f4.c
Normal file
272
keyboards/matrix/noah/ws2812_f4.c
Normal file
|
@ -0,0 +1,272 @@
|
|||
/**
|
||||
* @file ws2812.c
|
||||
* @author Austin Glaser <austin.glaser@gmail.com>, Joerg Wangemann <joerg.wangemann@gmail.com>
|
||||
* @brief WS2812 LED driver
|
||||
*
|
||||
* Copyright (C) 2016 Austin Glaser, 2017 Joerg Wangemann
|
||||
*
|
||||
* This software may be modified and distributed under the terms
|
||||
* of the MIT license. See the LICENSE file for details.
|
||||
*
|
||||
* @todo Put in names and descriptions of variables which need to be defined to use this file
|
||||
*
|
||||
* @addtogroup WS2812
|
||||
* @{
|
||||
*/
|
||||
|
||||
/* --- PRIVATE DEPENDENCIES ------------------------------------------------- */
|
||||
|
||||
// This Driver
|
||||
#include "ws2812_f4.h"
|
||||
|
||||
// Standard
|
||||
#include <stdint.h>
|
||||
|
||||
// ChibiOS
|
||||
#include "ch.h"
|
||||
#include "hal.h"
|
||||
|
||||
#include "wait.h"
|
||||
// Application
|
||||
//#include "board.h"
|
||||
|
||||
// TODO: Add these #define's to the headers of your project.
|
||||
// Pin, timer and dma are all connected, check them all if you change one.
|
||||
// Tested with STM32F4, working at 144 or 168 MHz.
|
||||
//#define WS2812_LED_N 2 // Number of LEDs
|
||||
//#define PORT_WS2812 GPIOB
|
||||
//#define PIN_WS2812 9
|
||||
//#define WS2812_TIM_N 4 // timer, 1-11
|
||||
//#define WS2812_TIM_CH 3 // timer channel, 0-3
|
||||
//#define WS2812_DMA_STREAM STM32_DMA1_STREAM2 // DMA stream for TIMx_UP (look up in reference manual under DMA Channel selection)
|
||||
//#define WS2812_DMA_CHANNEL 6 // DMA channel for TIMx_UP
|
||||
// The WS2812 expects 5V signal level (or at least 0.7 * VDD). Sometimes it works
|
||||
// with a 3V signal level, otherwise the easiest way to get the signal level to 5V
|
||||
// is to add an external pullup resistor from the DI pin to 5V (10k will do) and
|
||||
// configure the pin as open drain.
|
||||
// (An SMD resistor is easily solders on the connections of a light strip)
|
||||
// Uncomment the next line if an external pullup resistor is used.
|
||||
//#define WS2812_EXTERNAL_PULLUP
|
||||
|
||||
/* --- CONFIGURATION CHECK -------------------------------------------------- */
|
||||
|
||||
#if !defined(WS2812_LED_N)
|
||||
#error WS2812 LED chain length not specified
|
||||
#elif WS2812_LED_N <= 0
|
||||
#error WS2812 LED chain length set to invalid value
|
||||
#endif
|
||||
|
||||
#if !defined(WS2812_TIM_N)
|
||||
#error WS2812 timer not specified
|
||||
#endif
|
||||
#if defined(STM32F2XX) || defined(STM32F4XX) || defined(STM32F7XX)
|
||||
#if WS2812_TIM_N <= 2
|
||||
#define WS2812_AF 1
|
||||
#elif WS2812_TIM_N <= 5
|
||||
#define WS2812_AF 2
|
||||
#elif WS2812_TIM_N <= 11
|
||||
#define WS2812_AF 3
|
||||
#endif
|
||||
#elif !defined(WS2812_AF)
|
||||
#error WS2812_AF timer alternate function not specified
|
||||
#endif
|
||||
|
||||
#if !defined(WS2812_TIM_CH)
|
||||
#error WS2812 timer channel not specified
|
||||
#elif WS2812_TIM_CH >= 4
|
||||
#error WS2812 timer channel set to invalid value
|
||||
#endif
|
||||
|
||||
/* --- PRIVATE CONSTANTS ---------------------------------------------------- */
|
||||
|
||||
#define WS2812_PWM_FREQUENCY (STM32_SYSCLK/2) /**< Clock frequency of PWM, must be valid with respect to system clock! */
|
||||
#define WS2812_PWM_PERIOD (WS2812_PWM_FREQUENCY/800000) /**< Clock period in ticks. 1 / 800kHz = 1.25 uS (as per datasheet) */
|
||||
|
||||
/**
|
||||
* @brief Number of bit-periods to hold the data line low at the end of a frame
|
||||
*
|
||||
* The reset period for each frame must be at least 50 uS; so we add in 50 bit-times
|
||||
* of zeroes at the end. (50 bits)*(1.25 uS/bit) = 62.5 uS, which gives us some
|
||||
* slack in the timing requirements
|
||||
*/
|
||||
#define WS2812_RESET_BIT_N (50)
|
||||
#define WS2812_COLOR_BIT_N (WS2812_LED_N*24) /**< Number of data bits */
|
||||
#define WS2812_BIT_N (WS2812_COLOR_BIT_N + WS2812_RESET_BIT_N) /**< Total number of bits in a frame */
|
||||
|
||||
/**
|
||||
* @brief High period for a zero, in ticks
|
||||
*
|
||||
* Per the datasheet:
|
||||
* WS2812:
|
||||
* - T0H: 200 nS to 500 nS, inclusive
|
||||
* - T0L: 650 nS to 950 nS, inclusive
|
||||
* WS2812B:
|
||||
* - T0H: 200 nS to 500 nS, inclusive
|
||||
* - T0L: 750 nS to 1050 nS, inclusive
|
||||
*
|
||||
* The duty cycle is calculated for a high period of 350 nS.
|
||||
*/
|
||||
#define WS2812_DUTYCYCLE_0 (WS2812_PWM_FREQUENCY/(1000000000/450))
|
||||
|
||||
/**
|
||||
* @brief High period for a one, in ticks
|
||||
*
|
||||
* Per the datasheet:
|
||||
* WS2812:
|
||||
* - T1H: 550 nS to 850 nS, inclusive
|
||||
* - T1L: 450 nS to 750 nS, inclusive
|
||||
* WS2812B:
|
||||
* - T1H: 750 nS to 1050 nS, inclusive
|
||||
* - T1L: 200 nS to 500 nS, inclusive
|
||||
*
|
||||
* The duty cycle is calculated for a high period of 800 nS.
|
||||
* This is in the middle of the specifications of the WS2812 and WS2812B.
|
||||
*/
|
||||
#define WS2812_DUTYCYCLE_1 (WS2812_PWM_FREQUENCY/(1000000000/900))
|
||||
|
||||
/* --- PRIVATE MACROS ------------------------------------------------------- */
|
||||
|
||||
/**
|
||||
* @brief Generates a reference to a numbered PWM driver
|
||||
*
|
||||
* @param[in] n: The driver (timer) number
|
||||
*
|
||||
* @return A reference to the driver
|
||||
*/
|
||||
#define PWMD(n) CONCAT_EXPANDED_SYMBOLS(PWMD, n)
|
||||
|
||||
#define WS2812_PWMD PWMD(WS2812_TIM_N) /**< The PWM driver to use for the LED chain */
|
||||
|
||||
/**
|
||||
* @brief Determine the index in @ref ws2812_frame_buffer "the frame buffer" of a given bit
|
||||
*
|
||||
* @param[in] led: The led index [0, @ref WS2812_LED_N)
|
||||
* @param[in] byte: The byte number [0, 2]
|
||||
* @param[in] bit: The bit number [0, 7]
|
||||
*
|
||||
* @return The bit index
|
||||
*/
|
||||
#define WS2812_BIT(led, byte, bit) (24*(led) + 8*(byte) + (7 - (bit)))
|
||||
|
||||
/**
|
||||
* @brief Determine the index in @ref ws2812_frame_buffer "the frame buffer" of a given red bit
|
||||
*
|
||||
* @note The red byte is the middle byte in the color packet
|
||||
*
|
||||
* @param[in] led: The led index [0, @ref WS2812_LED_N)
|
||||
* @param[in] bit: The bit number [0, 7]
|
||||
*
|
||||
* @return The bit index
|
||||
*/
|
||||
#define WS2812_RED_BIT(led, bit) WS2812_BIT((led), 1, (bit))
|
||||
|
||||
/**
|
||||
* @brief Determine the index in @ref ws2812_frame_buffer "the frame buffer" of a given green bit
|
||||
*
|
||||
* @note The green byte is the first byte in the color packet
|
||||
*
|
||||
* @param[in] led: The led index [0, @ref WS2812_LED_N)
|
||||
* @param[in] bit: The bit number [0, 7]
|
||||
*
|
||||
* @return The bit index
|
||||
*/
|
||||
#define WS2812_GREEN_BIT(led, bit) WS2812_BIT((led), 0, (bit))
|
||||
|
||||
/**
|
||||
* @brief Determine the index in @ref ws2812_frame_buffer "the frame buffer" of a given blue bit
|
||||
*
|
||||
* @note The blue byte is the last byte in the color packet
|
||||
*
|
||||
* @param[in] led: The led index [0, @ref WS2812_LED_N)
|
||||
* @param[in] bit: The bit index [0, 7]
|
||||
*
|
||||
* @return The bit index
|
||||
*/
|
||||
#define WS2812_BLUE_BIT(led, bit) WS2812_BIT((led), 2, (bit))
|
||||
|
||||
/* --- PRIVATE VARIABLES ---------------------------------------------------- */
|
||||
|
||||
static uint32_t ws2812_frame_buffer[WS2812_BIT_N + 1]; /**< Buffer for a frame */
|
||||
|
||||
/* --- PUBLIC FUNCTIONS ----------------------------------------------------- */
|
||||
/*
|
||||
* Gedanke: Double-buffer type transactions: double buffer transfers using two memory pointers for
|
||||
the memory (while the DMA is reading/writing from/to a buffer, the application can
|
||||
write/read to/from the other buffer).
|
||||
*/
|
||||
|
||||
void ws2812_init(void)
|
||||
{
|
||||
// Initialize led frame buffer
|
||||
uint32_t i;
|
||||
for (i = 0; i < WS2812_COLOR_BIT_N; i++) ws2812_frame_buffer[i] = WS2812_DUTYCYCLE_0; // All color bits are zero duty cycle
|
||||
for (i = 0; i < WS2812_RESET_BIT_N; i++) ws2812_frame_buffer[i + WS2812_COLOR_BIT_N] = 0; // All reset bits are zero
|
||||
// Configure pin as AF output. If there's an external pull up resistor the signal level is brought to 5V using open drain mode.
|
||||
#ifdef WS2812_EXTERNAL_PULLUP
|
||||
palSetPadMode(PORT_WS2812, PIN_WS2812, PAL_MODE_ALTERNATE(WS2812_AF) | PAL_STM32_OTYPE_OPENDRAIN);
|
||||
#else
|
||||
palSetPadMode(PORT_WS2812, PIN_WS2812, PAL_MODE_ALTERNATE(WS2812_AF) | PAL_STM32_OTYPE_PUSHPULL); //PAL_MODE_STM32_ALTERNATE_PUSHPULL);
|
||||
#endif
|
||||
//palClearPad(PORT_WS2812, PIN_WS2812);
|
||||
//wait_ms(1);
|
||||
// PWM Configuration
|
||||
#pragma GCC diagnostic ignored "-Woverride-init" // Turn off override-init warning for this struct. We use the overriding ability to set a "default" channel config
|
||||
static const PWMConfig ws2812_pwm_config = {
|
||||
.frequency = WS2812_PWM_FREQUENCY,
|
||||
.period = WS2812_PWM_PERIOD, //Mit dieser Periode wird UDE-Event erzeugt und ein neuer Wert (Länge WS2812_BIT_N) vom DMA ins CCR geschrieben
|
||||
.callback = NULL,
|
||||
.channels = {
|
||||
[0 ... 3] = {.mode = PWM_OUTPUT_DISABLED, .callback = NULL}, // Channels default to disabled
|
||||
[WS2812_TIM_CH] = {.mode = PWM_OUTPUT_ACTIVE_HIGH, .callback = NULL}, // Turn on the channel we care about
|
||||
},
|
||||
.cr2 = 0,
|
||||
.dier = TIM_DIER_UDE, // DMA on update event for next period
|
||||
};
|
||||
#pragma GCC diagnostic pop // Restore command-line warning options
|
||||
|
||||
// Configure DMA
|
||||
//dmaInit(); // Joe added this
|
||||
dmaStreamAllocate(WS2812_DMA_STREAM, 10, NULL, NULL);
|
||||
dmaStreamSetPeripheral(WS2812_DMA_STREAM, &(WS2812_PWMD.tim->CCR[WS2812_TIM_CH])); // Ziel ist der An-Zeit im Cap-Comp-Register
|
||||
dmaStreamSetMemory0(WS2812_DMA_STREAM, ws2812_frame_buffer);
|
||||
dmaStreamSetTransactionSize(WS2812_DMA_STREAM, WS2812_BIT_N);
|
||||
dmaStreamSetMode(WS2812_DMA_STREAM,
|
||||
STM32_DMA_CR_CHSEL(WS2812_DMA_CHANNEL) | STM32_DMA_CR_DIR_M2P | STM32_DMA_CR_PSIZE_WORD | STM32_DMA_CR_MSIZE_WORD |
|
||||
STM32_DMA_CR_MINC | STM32_DMA_CR_CIRC | STM32_DMA_CR_PL(3));
|
||||
// M2P: Memory 2 Periph; PL: Priority Level
|
||||
|
||||
// Start DMA
|
||||
dmaStreamEnable(WS2812_DMA_STREAM);
|
||||
|
||||
// Configure PWM
|
||||
// NOTE: It's required that preload be enabled on the timer channel CCR register. This is currently enabled in the
|
||||
// ChibiOS driver code, so we don't have to do anything special to the timer. If we did, we'd have to start the timer,
|
||||
// disable counting, enable the channel, and then make whatever configuration changes we need.
|
||||
pwmStart(&WS2812_PWMD, &ws2812_pwm_config);
|
||||
pwmEnableChannel(&WS2812_PWMD, WS2812_TIM_CH, 0); // Initial period is 0; output will be low until first duty cycle is DMA'd in
|
||||
}
|
||||
|
||||
ws2812_err_t ws2812_write_led(uint32_t led_number, uint8_t r, uint8_t g, uint8_t b)
|
||||
{
|
||||
// Check for valid LED
|
||||
if (led_number > WS2812_LED_N) return WS2812_LED_INVALID;
|
||||
|
||||
// Write color to frame buffer
|
||||
for (uint32_t bit = 0; bit < 8; bit++) {
|
||||
ws2812_frame_buffer[WS2812_RED_BIT(led_number, bit)] = ((r >> bit) & 0x01) ? WS2812_DUTYCYCLE_1 : WS2812_DUTYCYCLE_0;
|
||||
ws2812_frame_buffer[WS2812_GREEN_BIT(led_number, bit)] = ((g >> bit) & 0x01) ? WS2812_DUTYCYCLE_1 : WS2812_DUTYCYCLE_0;
|
||||
ws2812_frame_buffer[WS2812_BLUE_BIT(led_number, bit)] = ((b >> bit) & 0x01) ? WS2812_DUTYCYCLE_1 : WS2812_DUTYCYCLE_0;
|
||||
}
|
||||
|
||||
// Success
|
||||
return WS2812_SUCCESS;
|
||||
}
|
||||
|
||||
void ws2812_setleds(LED_TYPE *ledarray, uint16_t number_of_leds)
|
||||
{
|
||||
for(int i = 0; i < number_of_leds; i++) {
|
||||
ws2812_write_led(i, ledarray[i].r, ledarray[i].g, ledarray[i].b);
|
||||
}
|
||||
}
|
||||
|
||||
/** @} addtogroup WS2812 */
|
102
keyboards/matrix/noah/ws2812_f4.h
Normal file
102
keyboards/matrix/noah/ws2812_f4.h
Normal file
|
@ -0,0 +1,102 @@
|
|||
/**
|
||||
* @file ws2812.h
|
||||
* @author Austin Glaser <austin.glaser@gmail.com>
|
||||
* @brief Interface to WS2812 LED driver
|
||||
*
|
||||
* Copyright (C) 2016 Austin Glaser
|
||||
*
|
||||
* This software may be modified and distributed under the terms
|
||||
* of the MIT license. See the LICENSE file for details.
|
||||
*
|
||||
* @todo Put in names and descriptions of variables which need to be defined to use this file
|
||||
*/
|
||||
|
||||
#ifndef WS2812_H_
|
||||
#define WS2812_H_
|
||||
|
||||
/**
|
||||
* @defgroup WS2812 WS2812 Driver
|
||||
* @{
|
||||
*
|
||||
* @brief DMA-based WS2812 LED driver
|
||||
*
|
||||
* A driver for WS2812 LEDs
|
||||
*/
|
||||
|
||||
/* --- PUBLIC DEPENDENCIES -------------------------------------------------- */
|
||||
|
||||
// Standard
|
||||
#include <stdint.h>
|
||||
#include "color.h"
|
||||
|
||||
/* --- PUBLIC MACROS -------------------------------------------------------- */
|
||||
|
||||
/**
|
||||
* @brief Concatenates two symbols s1 and s2 exactly, without expanding either
|
||||
*
|
||||
* @param[in] s1: The first symbol to concatenate
|
||||
* @param[in] s2: The second symbol to concatenate
|
||||
*
|
||||
* @return A single symbol containing s1 and s2 concatenated without expansion
|
||||
*/
|
||||
#define CONCAT_SYMBOLS(s1, s2) s1##s2
|
||||
|
||||
/**
|
||||
* @brief Concatenate the symbols s1 and s2, expanding both of them
|
||||
*
|
||||
* This is important because simply applying s1##s2 doesn't expand them if they're
|
||||
* preprocessor tokens themselves
|
||||
*
|
||||
* @param[in] s1: The first symbol to concatenate
|
||||
* @param[in] s2: The second symbol to concatenate
|
||||
*
|
||||
* @return A single symbol containing s1 expanded followed by s2 expanded
|
||||
*/
|
||||
#define CONCAT_EXPANDED_SYMBOLS(s1, s2) CONCAT_SYMBOLS(s1, s2)
|
||||
|
||||
/* --- PUBLIC CONSTANTS ----------------------------------------------------- */
|
||||
|
||||
/**
|
||||
* @brief Return codes from ws2812 interface functions
|
||||
*/
|
||||
typedef enum {
|
||||
WS2812_SUCCESS = 0x00, /**< Operation completeed successfully */
|
||||
WS2812_LED_INVALID, /**< Attempted to index an invalid LED (@ref WS2812_N_LEDS) */
|
||||
MAX_WS2812_ERR, /**< Total number of possible error codes */
|
||||
WS2812_ERR_INVALID /**< Invalid error value */
|
||||
} ws2812_err_t;
|
||||
|
||||
/* --- PUBLIC FUNCTIONS ----------------------------------------------------- */
|
||||
|
||||
/**
|
||||
* @brief Initialize the driver
|
||||
*
|
||||
* After this function is called, all necessary background tasks will be started.
|
||||
* The frame is initially dark.
|
||||
*/
|
||||
void ws2812_init(void);
|
||||
|
||||
/**
|
||||
* @brief Write the value of a single LED in the chain
|
||||
*
|
||||
* The color value is written to a frame buffer, and will not
|
||||
* be updated until the next frame is written. Frames are written
|
||||
* at the maximum possible speed -- the longest latency between a
|
||||
* call to this function and the value being displayed is
|
||||
* 1.25uS*(24*@ref WS2812_LED_N + 50)
|
||||
*
|
||||
* @param[in] led_number: The index of the LED to be written. Must be strictly less than
|
||||
* @ref WS2812_N_LEDS
|
||||
* @param[in] r: The red level of the LED
|
||||
* @param[in] g: The green level of the LED
|
||||
* @param[in] b: The blue level of the LED
|
||||
*
|
||||
* @retval WS2812_SUCCESS: The write was successful
|
||||
* @retval WS2812_LED_INVALID: The write was to an invalid LED index
|
||||
*/
|
||||
ws2812_err_t ws2812_write_led(uint32_t led_number, uint8_t r, uint8_t g, uint8_t b);
|
||||
|
||||
void ws2812_setleds(LED_TYPE *ledarray, uint16_t number_of_leds);
|
||||
/** @} defgroup WS2812 */
|
||||
|
||||
#endif // ifndef WS2812_H_
|
Loading…
Reference in a new issue