Compare commits
30 Commits
Author | SHA1 | Date | |
---|---|---|---|
799acb2802 | |||
18bc525493 | |||
4edb5a5e8c | |||
3b5fd4cc51 | |||
cd9a430d66 | |||
1b267d4840 | |||
32d03eef90 | |||
f2f2afe13b | |||
3a3ea03b6e | |||
f3afc716cb | |||
e72562fe6f | |||
2b66acf04a | |||
5ac6fe1888 | |||
979ac0d8da | |||
7a89b51018 | |||
2a05d433c9 | |||
1aa40dde46 | |||
2ffb08843b | |||
2a8ccafe6e | |||
1757960b7b | |||
668121bbf8 | |||
483ab88489 | |||
dbbab40981 | |||
20a0fa9209 | |||
2d14d12c74 | |||
0ba352356d | |||
a4fd5e2491 | |||
5e3951b361 | |||
5e4fcfac1c | |||
89ef9de98c |
@ -23,4 +23,4 @@ endif
|
||||
|
||||
# Generate the keymap.c
|
||||
$(KEYBOARD_OUTPUT)/src/keymap.c: $(KEYMAP_JSON)
|
||||
bin/qmk json-keymap --quiet --output $(KEYMAP_C) $(KEYMAP_JSON)
|
||||
bin/qmk json2c --quiet --output $(KEYMAP_C) $(KEYMAP_JSON)
|
||||
|
@ -141,6 +141,10 @@ else
|
||||
SRC += $(PLATFORM_COMMON_DIR)/flash_stm32.c
|
||||
OPT_DEFS += -DEEPROM_EMU_STM32F072xB
|
||||
OPT_DEFS += -DSTM32_EEPROM_ENABLE
|
||||
else ifneq ($(filter $(MCU_SERIES),STM32L0xx STM32L1xx),)
|
||||
OPT_DEFS += -DEEPROM_DRIVER
|
||||
COMMON_VPATH += $(DRIVER_PATH)/eeprom
|
||||
SRC += eeprom_driver.c eeprom_stm32_L0_L1.c
|
||||
else
|
||||
# This will effectively work the same as "transient" if not supported by the chip
|
||||
SRC += $(PLATFORM_COMMON_DIR)/eeprom_teensy.c
|
||||
|
@ -2,7 +2,7 @@
|
||||
|
||||
QMK can leverage the Analog-to-Digital Converter (ADC) on supported MCUs to measure voltages on certain pins. This can be useful for implementing things such as battery level indicators for Bluetooth keyboards, or volume controls using a potentiometer, as opposed to a [rotary encoder](feature_encoders.md).
|
||||
|
||||
This driver is currently AVR-only. The values returned are 10-bit integers (0-1023) mapped between 0V and VCC (usually 5V or 3.3V).
|
||||
This driver currently supports both AVR and a limited selection of ARM devices. On AVR devices, the values returned are 10-bit integers (0-1023) mapped between 0V and VCC (usually 5V or 3.3V). On supported ARM devices, there is more flexibility in control of operation through `#define`s, but by default the values returned are 12-bit integers (0-4095) mapped between 0V and VCC (usually 3.3V).
|
||||
|
||||
## Usage
|
||||
|
||||
@ -20,6 +20,8 @@ Then place this include at the top of your code:
|
||||
|
||||
## Channels
|
||||
|
||||
### AVR
|
||||
|
||||
|Channel|AT90USB64/128|ATmega16/32U4|ATmega32A|ATmega328P|
|
||||
|-------|-------------|-------------|---------|----------|
|
||||
|0 |`F0` |`F0` |`A0` |`C0` |
|
||||
@ -39,8 +41,84 @@ Then place this include at the top of your code:
|
||||
|
||||
<sup>\* The ATmega328P possesses two extra ADC channels; however, they are not present on the DIP pinout, and are not shared with GPIO pins. You can use `adc_read()` directly to gain access to these.</sup>
|
||||
|
||||
### ARM
|
||||
|
||||
Note that some of these pins are doubled-up on ADCs with the same channel. This is because the pins can be used for either ADC.
|
||||
|
||||
Also note that the F0 and F3 use different numbering schemes. The F0 has a single ADC and the channels are 0-based, whereas the F3 has 4 ADCs and the channels are 1 based. This is because the F0 uses the `ADCv1` implementation of the ADC, whereas the F3 uses the `ADCv3` implementation.
|
||||
|
||||
|ADC|Channel|STM32F0XX|STM32F3XX|
|
||||
|---|-------|---------|---------|
|
||||
|1 |0 |`A0` | |
|
||||
|1 |1 |`A1` |`A0` |
|
||||
|1 |2 |`A2` |`A1` |
|
||||
|1 |3 |`A3` |`A2` |
|
||||
|1 |4 |`A4` |`A3` |
|
||||
|1 |5 |`A5` |`F4` |
|
||||
|1 |6 |`A6` |`C0` |
|
||||
|1 |7 |`A7` |`C1` |
|
||||
|1 |8 |`B0` |`C2` |
|
||||
|1 |9 |`B1` |`C3` |
|
||||
|1 |10 |`C0` |`F2` |
|
||||
|1 |11 |`C1` | |
|
||||
|1 |12 |`C2` | |
|
||||
|1 |13 |`C3` | |
|
||||
|1 |14 |`C4` | |
|
||||
|1 |15 |`C5` | |
|
||||
|1 |16 | | |
|
||||
|2 |1 | |`A4` |
|
||||
|2 |2 | |`A5` |
|
||||
|2 |3 | |`A6` |
|
||||
|2 |4 | |`A7` |
|
||||
|2 |5 | |`C4` |
|
||||
|2 |6 | |`C0` |
|
||||
|2 |7 | |`C1` |
|
||||
|2 |8 | |`C2` |
|
||||
|2 |9 | |`C3` |
|
||||
|2 |10 | |`F2` |
|
||||
|2 |11 | |`C5` |
|
||||
|2 |12 | |`B2` |
|
||||
|2 |13 | | |
|
||||
|2 |14 | | |
|
||||
|2 |15 | | |
|
||||
|2 |16 | | |
|
||||
|3 |1 | |`B1` |
|
||||
|3 |2 | |`E9` |
|
||||
|3 |3 | |`E13` |
|
||||
|3 |4 | | |
|
||||
|3 |5 | | |
|
||||
|3 |6 | |`E8` |
|
||||
|3 |7 | |`D10` |
|
||||
|3 |8 | |`D11` |
|
||||
|3 |9 | |`D12` |
|
||||
|3 |10 | |`D13` |
|
||||
|3 |11 | |`D14` |
|
||||
|3 |12 | |`B0` |
|
||||
|3 |13 | |`E7` |
|
||||
|3 |14 | |`E10` |
|
||||
|3 |15 | |`E11` |
|
||||
|3 |16 | |`E12` |
|
||||
|4 |1 | |`E14` |
|
||||
|4 |2 | |`B12` |
|
||||
|4 |3 | |`B13` |
|
||||
|4 |4 | |`B14` |
|
||||
|4 |5 | |`B15` |
|
||||
|4 |6 | |`E8` |
|
||||
|4 |7 | |`D10` |
|
||||
|4 |8 | |`D11` |
|
||||
|4 |9 | |`D12` |
|
||||
|4 |10 | |`D13` |
|
||||
|4 |11 | |`D14` |
|
||||
|4 |12 | |`D8` |
|
||||
|4 |13 | |`D9` |
|
||||
|4 |14 | | |
|
||||
|4 |15 | | |
|
||||
|4 |16 | | |
|
||||
|
||||
## Functions
|
||||
|
||||
### AVR
|
||||
|
||||
|Function |Description |
|
||||
|----------------------------|-------------------------------------------------------------------------------------------------------------------|
|
||||
|`analogReference(mode)` |Sets the analog voltage reference source. Must be one of `ADC_REF_EXTERNAL`, `ADC_REF_POWER` or `ADC_REF_INTERNAL`.|
|
||||
@ -48,3 +126,28 @@ Then place this include at the top of your code:
|
||||
|`analogReadPin(pin)` |Reads the value from the specified QMK pin, eg. `F6` for ADC6 on the ATmega32U4. |
|
||||
|`pinToMux(pin)` |Translates a given QMK pin to a mux value. If an unsupported pin is given, returns the mux value for "0V (GND)". |
|
||||
|`adc_read(mux)` |Reads the value from the ADC according to the specified mux. See your MCU's datasheet for more information. |
|
||||
|
||||
### ARM
|
||||
|
||||
Note that care was taken to match all of the functions used for AVR devices, however complications in the ARM platform prevent that from always being possible. For example, the `STM32` chips do not have assigned Arduino pins. We could use the default pin numbers, but those numbers change based on the package type of the device. For this reason, please specify your target pins with their identifiers (`A0`, `F3`, etc.). Also note that there are some variants of functions that accept the target ADC for the pin. Some pins can be used for multiple ADCs, and this specified can help you pick which ADC will be used to interact with that pin.
|
||||
|
||||
|Function |Description |
|
||||
|----------------------------|--------------------------------------------------------------------------------------------------------------------|
|
||||
|`analogReadPin(pin)` |Reads the value from the specified QMK pin, eg. `A0` for channel 0 on the STM32F0 and ADC1 channel 1 on the STM32F3. Note that if a pin can be used for multiple ADCs, it will pick the lower numbered ADC for this function. eg. `C0` will be channel 6 of ADC 1 when it could be used for ADC 2 as well.|
|
||||
|`analogReadPinAdc(pin, adc)`|Reads the value from the specified QMK pin and ADC, eg. `C0, 1` will read from channel 6, ADC 2 instead of ADC 1. Note that the ADCs are 0-indexed for this function.|
|
||||
|`pinToMux(pin)` |Translates a given QMK pin to a channel and ADC combination. If an unsupported pin is given, returns the mux value for "0V (GND)".|
|
||||
|`adc_read(mux)` |Reads the value from the ADC according to the specified pin and adc combination. See your MCU's datasheet for more information.|
|
||||
|
||||
## Configuration
|
||||
|
||||
## ARM
|
||||
|
||||
The ARM implementation of the ADC has a few additional options that you can override in your own keyboards and keymaps to change how it operates.
|
||||
|
||||
|`#define` |Type |Default |Description|
|
||||
|-------------------|------|---------------------|-----------|
|
||||
|ADC_CIRCULAR_BUFFER|`bool`|`false` |If `TRUE`, then the implementation will use a circular buffer.|
|
||||
|ADC_NUM_CHANNELS |`int` |`1` |Sets the number of channels that will be scanned as part of an ADC operation. The current implementation only supports `1`.|
|
||||
|ADC_BUFFER_DEPTH |`int` |`2` |Sets the depth of each result. Since we are only getting a 12-bit result by default, we set this to `2` bytes so we can contain our one value. This could be set to 1 if you opt for a 8-bit or lower result.|
|
||||
|ADC_SAMPLING_RATE |`int` |`ADC_SMPR_SMP_1P5` |Sets the sampling rate of the ADC. By default, it is set to the fastest setting. Please consult the corresponding `hal_adc_lld.h` in ChibiOS for your specific microcontroller for further documentation on your available options.|
|
||||
|ADC_RESOLUTION |`int` |`ADC_CFGR1_RES_12BIT`|The resolution of your result. We choose 12 bit by default, but you can opt for 12, 10, 8, or 6 bit. Please consult the corresponding `hal_adc_lld.h` in ChibiOS for your specific microcontroller for further documentation on your available options.|
|
||||
|
@ -231,14 +231,14 @@ Check your environment and report problems only:
|
||||
|
||||
qmk doctor -n
|
||||
|
||||
## `qmk json-keymap`
|
||||
## `qmk json2c`
|
||||
|
||||
Creates a keymap.c from a QMK Configurator export.
|
||||
|
||||
**Usage**:
|
||||
|
||||
```
|
||||
qmk json-keymap [-o OUTPUT] filename
|
||||
qmk json2c [-o OUTPUT] filename
|
||||
```
|
||||
|
||||
## `qmk kle2json`
|
||||
|
@ -190,6 +190,8 @@ If you define these options you will enable the associated feature, which may in
|
||||
* pin the DI on the WS2812 is hooked-up to
|
||||
* `#define RGBLIGHT_ANIMATIONS`
|
||||
* run RGB animations
|
||||
* `#define RGBLIGHT_LAYERS`
|
||||
* Lets you define [lighting layers](feature_rgblight.md) that can be toggled on or off. Great for showing the current keyboard layer or caps lock state.
|
||||
* `#define RGBLED_NUM 12`
|
||||
* number of LEDs
|
||||
* `#define RGBLIGHT_SPLIT`
|
||||
|
@ -2,14 +2,16 @@
|
||||
|
||||
The EEPROM driver can be swapped out depending on the needs of the keyboard, or whether extra hardware is present.
|
||||
|
||||
Driver | Description
|
||||
--------------------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
|
||||
`EEPROM_DRIVER = vendor` | Uses the on-chip driver provided by the chip manufacturer. For AVR, this is provided by avr-libc. This is supported on ARM for a subset of chips -- STM32F3xx, STM32F1xx, and STM32F072xB will be emulated by writing to flash. Other chips will generally act as "transient" below.
|
||||
`EEPROM_DRIVER = i2c` | Supports writing to I2C-based 24xx EEPROM chips. See the driver section below.
|
||||
`EEPROM_DRIVER = transient` | Fake EEPROM driver -- supports reading/writing to RAM, and will be discarded when power is lost.
|
||||
Driver | Description
|
||||
-----------------------------------|---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
|
||||
`EEPROM_DRIVER = vendor` (default) | Uses the on-chip driver provided by the chip manufacturer. For AVR, this is provided by avr-libc. This is supported on ARM for a subset of chips -- STM32F3xx, STM32F1xx, and STM32F072xB will be emulated by writing to flash. STM32L0xx and STM32L1xx will use the onboard dedicated true EEPROM. Other chips will generally act as "transient" below.
|
||||
`EEPROM_DRIVER = i2c` | Supports writing to I2C-based 24xx EEPROM chips. See the driver section below.
|
||||
`EEPROM_DRIVER = transient` | Fake EEPROM driver -- supports reading/writing to RAM, and will be discarded when power is lost.
|
||||
|
||||
## Vendor Driver Configuration
|
||||
|
||||
!> Resetting EEPROM using an STM32L0/L1 device takes up to 1 second for every 1kB of internal EEPROM used.
|
||||
|
||||
No configurable options are available.
|
||||
|
||||
## I2C Driver Configuration
|
||||
|
@ -172,6 +172,62 @@ const uint8_t RGBLED_KNIGHT_INTERVALS[] PROGMEM = {127, 63, 31};
|
||||
const uint8_t RGBLED_GRADIENT_RANGES[] PROGMEM = {255, 170, 127, 85, 64};
|
||||
```
|
||||
|
||||
## Lighting Layers
|
||||
|
||||
By including `#define RGBLIGHT_LAYERS` in your `config.h` file you can enable lighting layers. These make
|
||||
it easy to use your underglow LEDs as status indicators to show which keyboard layer is currently active, or the state of caps lock, all without disrupting any animations. [Here's a video](https://youtu.be/uLGE1epbmdY) showing an example of what you can do.
|
||||
|
||||
To define a layer, we modify `keymap.c` to list out LED ranges and the colors we want to overlay on them using an array of `rgblight_segment_t` using the `RGBLIGHT_LAYER_SEGMENTS` macro. We can define multiple layers and enable/disable them independently:
|
||||
|
||||
```c
|
||||
// Light LEDs 6 to 9 and 12 to 15 red when caps lock is active. Hard to ignore!
|
||||
const rgblight_segment_t PROGMEM my_capslock_layer[] = RGBLIGHT_LAYER_SEGMENTS(
|
||||
{6, 4, HSV_RED}, // Light 4 LEDs, starting with LED 6
|
||||
{12, 4, HSV_RED} // Light 4 LEDs, starting with LED 12
|
||||
);
|
||||
// Light LEDs 9 & 10 in cyan when keyboard layer 1 is active
|
||||
const rgblight_segment_t PROGMEM my_layer1_layer[] = RGBLIGHT_LAYER_SEGMENTS(
|
||||
{9, 2, HSV_CYAN}
|
||||
);
|
||||
// Light LEDs 11 & 12 in purple when keyboard layer 2 is active
|
||||
const rgblight_segment_t PROGMEM my_layer2_layer[] = RGBLIGHT_LAYER_SEGMENTS(
|
||||
{11, 2, HSV_PURPLE},
|
||||
);
|
||||
// etc..
|
||||
```
|
||||
|
||||
We combine these layers into an array using the `RGBLIGHT_LAYERS_LIST` macro, and assign it to the `rgblight_layers` variable during keyboard setup. Note that you can only define up to 8 lighting layers. Any extra layers will be ignored. Since the different lighting layers overlap, the order matters in the array, with later layers taking precedence:
|
||||
|
||||
```c
|
||||
// Now define the array of layers. Later layers take precedence
|
||||
const rgblight_segment_t* const PROGMEM my_rgb_layers[] = RGBLIGHT_LAYERS_LIST(
|
||||
my_capslock_layer,
|
||||
my_layer1_layer, // Overrides caps lock layer
|
||||
my_layer2_layer // Overrides other layers
|
||||
);
|
||||
|
||||
void keyboard_post_init_user(void) {
|
||||
// Enable the LED layers
|
||||
rgblight_layers = my_rgb_layers;
|
||||
}
|
||||
```
|
||||
|
||||
Finally, we enable and disable the lighting layers whenever the state of the keyboard changes:
|
||||
|
||||
```c
|
||||
layer_state_t layer_state_set_user(layer_state_t state) {
|
||||
// Both layers will light up if both kb layers are active
|
||||
rgblight_set_layer_state(1, layer_state_cmp(state, 1));
|
||||
rgblight_set_layer_state(2, layer_state_cmp(state, 2));
|
||||
return state;
|
||||
}
|
||||
|
||||
bool led_update_user(led_t led_state) {
|
||||
rgblight_set_layer_state(0, led_state.caps_lock);
|
||||
return true;
|
||||
}
|
||||
```
|
||||
|
||||
## Functions
|
||||
|
||||
If you need to change your RGB lighting in code, for example in a macro to change the color whenever you switch layers, QMK provides a set of functions to assist you. See [`rgblight.h`](https://github.com/qmk/qmk_firmware/blob/master/quantum/rgblight.h) for the full list, but the most commonly used functions include:
|
||||
@ -263,6 +319,12 @@ rgblight_sethsv(HSV_GREEN, 2); // led 2
|
||||
|`rgblight_sethsv(h, s, v)` |Set effect range LEDs to the given HSV value where `h`/`s`/`v` are between 0 and 255 |
|
||||
|`rgblight_sethsv_noeeprom(h, s, v)` |Set effect range LEDs to the given HSV value where `h`/`s`/`v` are between 0 and 255 (not written to EEPROM) |
|
||||
|
||||
#### layer functions
|
||||
|Function |Description |
|
||||
|--------------------------------------------|-------------|
|
||||
|`rgblight_get_layer_state(i)` |Returns `true` if lighting layer `i` is enabled |
|
||||
|`rgblight_set_layer_state(i, is_on)` |Enable or disable lighting layer `i` based on value of `bool is_on` |
|
||||
|
||||
#### query
|
||||
|Function |Description |
|
||||
|-----------------------|-----------------|
|
||||
|
@ -16,7 +16,8 @@
|
||||
<link rel="stylesheet" href="//unpkg.com/docsify/lib/themes/buble.css" title="light">
|
||||
<link rel="stylesheet" href="//unpkg.com/docsify/lib/themes/dark.css" media="(prefers-color-scheme: dark)">
|
||||
<link rel="stylesheet" href="//unpkg.com/docsify-toc@1.0.0/dist/toc.css">
|
||||
<link rel="stylesheet" href="sidebar.css" />
|
||||
<link rel="stylesheet" href="qmk_custom_light.css">
|
||||
<link rel="stylesheet" href="qmk_custom_dark.css" media="(prefers-color-scheme: dark)">
|
||||
</head>
|
||||
<body>
|
||||
<div id="app"></div>
|
||||
|
@ -215,14 +215,14 @@ qmk doctor [-y] [-n]
|
||||
|
||||
qmk doctor -n
|
||||
|
||||
## `qmk json-keymap`
|
||||
## `qmk json2c`
|
||||
|
||||
QMK Configurator からエクスポートしたものから keymap.c を生成します。
|
||||
|
||||
**使用法**:
|
||||
|
||||
```
|
||||
qmk json-keymap [-o OUTPUT] filename
|
||||
qmk json2c [-o OUTPUT] filename
|
||||
```
|
||||
|
||||
## `qmk kle2json`
|
||||
|
29
docs/qmk_custom_dark.css
Normal file
29
docs/qmk_custom_dark.css
Normal file
@ -0,0 +1,29 @@
|
||||
.sidebar li.active {
|
||||
background-color: #555;
|
||||
}
|
||||
|
||||
.markdown-section p.tip,
|
||||
.markdown-section tr:nth-child(2n) {
|
||||
background-color:#444;
|
||||
}
|
||||
|
||||
.markdown-section tr {
|
||||
border-top: 1px solid #555;
|
||||
}
|
||||
|
||||
.markdown-section td, .markdown-section th {
|
||||
border: 1px solid #555;
|
||||
}
|
||||
|
||||
.markdown-section p.tip code {
|
||||
background-color: #555;
|
||||
color: #fff;
|
||||
}
|
||||
|
||||
.page_toc code {
|
||||
background-color: #555;
|
||||
}
|
||||
|
||||
.markdown-section hr, .search {
|
||||
border-bottom: 1px solid #777 !important;
|
||||
}
|
207
drivers/arm/analog.c
Normal file
207
drivers/arm/analog.c
Normal file
@ -0,0 +1,207 @@
|
||||
/* Copyright 2019 Drew Mills
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 2 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#include "analog.h"
|
||||
#include "quantum.h"
|
||||
|
||||
/* User configurable ADC options */
|
||||
#ifndef ADC_CIRCULAR_BUFFER
|
||||
# define ADC_CIRCULAR_BUFFER FALSE
|
||||
#endif
|
||||
|
||||
#ifndef ADC_NUM_CHANNELS
|
||||
# define ADC_NUM_CHANNELS 1
|
||||
#elif ADC_NUM_CHANNELS != 1
|
||||
# error "The ARM ADC implementation currently only supports reading one channel at a time."
|
||||
#endif
|
||||
|
||||
#ifndef ADC_BUFFER_DEPTH
|
||||
# define ADC_BUFFER_DEPTH 2
|
||||
#endif
|
||||
|
||||
// For more sampling rate options, look at hal_adc_lld.h in ChibiOS
|
||||
#ifndef ADC_SAMPLING_RATE
|
||||
# define ADC_SAMPLING_RATE ADC_SMPR_SMP_1P5
|
||||
#endif
|
||||
|
||||
// Options are 12, 10, 8, and 6 bit.
|
||||
#ifndef ADC_RESOLUTION
|
||||
# define ADC_RESOLUTION ADC_CFGR1_RES_12BIT
|
||||
#endif
|
||||
|
||||
static ADCConfig adcCfg = {};
|
||||
static adcsample_t sampleBuffer[ADC_NUM_CHANNELS * ADC_BUFFER_DEPTH];
|
||||
|
||||
// Initialize to max number of ADCs, set to empty object to initialize all to false.
|
||||
#if defined(STM32F0XX)
|
||||
static bool adcInitialized[1] = {};
|
||||
#elif defined(STM32F3XX)
|
||||
static bool adcInitialized[4] = {};
|
||||
#else
|
||||
# error "adcInitialized has not been implemented for this ARM microcontroller."
|
||||
#endif
|
||||
|
||||
static ADCConversionGroup adcConversionGroup = {
|
||||
ADC_CIRCULAR_BUFFER,
|
||||
(uint16_t)(ADC_NUM_CHANNELS),
|
||||
NULL, // No end callback
|
||||
NULL, // No error callback
|
||||
#if defined(STM32F0XX)
|
||||
ADC_CFGR1_CONT | ADC_RESOLUTION,
|
||||
ADC_TR(0, 0).ADC_SAMPLING_RATE,
|
||||
NULL, // Doesn't specify a default channel
|
||||
#elif defined(STM32F3XX)
|
||||
ADC_CFGR_CONT | ADC_RESOLUTION,
|
||||
ADC_TR(0, 4095),
|
||||
{
|
||||
ADC_SAMPLING_RATE,
|
||||
ADC_SAMPLING_RATE,
|
||||
},
|
||||
{
|
||||
0, // Doesn't specify a default channel
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
},
|
||||
#endif
|
||||
};
|
||||
|
||||
static inline ADCDriver* intToADCDriver(uint8_t adcInt) {
|
||||
ADCDriver* target;
|
||||
|
||||
switch (adcInt) {
|
||||
// clang-format off
|
||||
#if STM32_ADC_USE_ADC1
|
||||
case 0: target = &ADCD1; break;
|
||||
#endif
|
||||
#if STM32_ADC_USE_ADC2
|
||||
case 1: target = &ADCD2; break;
|
||||
#endif
|
||||
#if STM32_ADC_USE_ADC3
|
||||
case 2: target = &ADCD3; break;
|
||||
#endif
|
||||
#if STM32_ADC_USE_ADC4
|
||||
case 3: target = &ADCD4; break;
|
||||
#endif
|
||||
default: target = NULL; break;
|
||||
// clang-format on
|
||||
}
|
||||
|
||||
return target;
|
||||
}
|
||||
|
||||
static inline void manageAdcInitializationDriver(uint8_t adc, ADCDriver* adcDriver) {
|
||||
if (!adcInitialized[adc]) {
|
||||
adcStart(adcDriver, &adcCfg);
|
||||
adcInitialized[adc] = true;
|
||||
}
|
||||
}
|
||||
|
||||
static inline void manageAdcInitialization(uint8_t adc) { manageAdcInitializationDriver(adc, intToADCDriver(adc)); }
|
||||
|
||||
pin_and_adc pinToMux(pin_t pin) {
|
||||
switch (pin) {
|
||||
// clang-format off
|
||||
#if defined(STM32F0XX)
|
||||
case A0: return (pin_and_adc){ ADC_CHANNEL_IN0, 0 };
|
||||
case A1: return (pin_and_adc){ ADC_CHANNEL_IN1, 0 };
|
||||
case A2: return (pin_and_adc){ ADC_CHANNEL_IN2, 0 };
|
||||
case A3: return (pin_and_adc){ ADC_CHANNEL_IN3, 0 };
|
||||
case A4: return (pin_and_adc){ ADC_CHANNEL_IN4, 0 };
|
||||
case A5: return (pin_and_adc){ ADC_CHANNEL_IN5, 0 };
|
||||
case A6: return (pin_and_adc){ ADC_CHANNEL_IN6, 0 };
|
||||
case A7: return (pin_and_adc){ ADC_CHANNEL_IN7, 0 };
|
||||
case B0: return (pin_and_adc){ ADC_CHANNEL_IN8, 0 };
|
||||
case B1: return (pin_and_adc){ ADC_CHANNEL_IN9, 0 };
|
||||
case C0: return (pin_and_adc){ ADC_CHANNEL_IN10, 0 };
|
||||
case C1: return (pin_and_adc){ ADC_CHANNEL_IN11, 0 };
|
||||
case C2: return (pin_and_adc){ ADC_CHANNEL_IN12, 0 };
|
||||
case C3: return (pin_and_adc){ ADC_CHANNEL_IN13, 0 };
|
||||
case C4: return (pin_and_adc){ ADC_CHANNEL_IN14, 0 };
|
||||
case C5: return (pin_and_adc){ ADC_CHANNEL_IN15, 0 };
|
||||
#elif defined(STM32F3XX)
|
||||
case A0: return (pin_and_adc){ ADC_CHANNEL_IN1, 0 };
|
||||
case A1: return (pin_and_adc){ ADC_CHANNEL_IN2, 0 };
|
||||
case A2: return (pin_and_adc){ ADC_CHANNEL_IN3, 0 };
|
||||
case A3: return (pin_and_adc){ ADC_CHANNEL_IN4, 0 };
|
||||
case A4: return (pin_and_adc){ ADC_CHANNEL_IN1, 1 };
|
||||
case A5: return (pin_and_adc){ ADC_CHANNEL_IN2, 1 };
|
||||
case A6: return (pin_and_adc){ ADC_CHANNEL_IN3, 1 };
|
||||
case A7: return (pin_and_adc){ ADC_CHANNEL_IN4, 1 };
|
||||
case B0: return (pin_and_adc){ ADC_CHANNEL_IN12, 2 };
|
||||
case B1: return (pin_and_adc){ ADC_CHANNEL_IN1, 2 };
|
||||
case B2: return (pin_and_adc){ ADC_CHANNEL_IN12, 1 };
|
||||
case B12: return (pin_and_adc){ ADC_CHANNEL_IN2, 3 };
|
||||
case B13: return (pin_and_adc){ ADC_CHANNEL_IN3, 3 };
|
||||
case B14: return (pin_and_adc){ ADC_CHANNEL_IN4, 3 };
|
||||
case B15: return (pin_and_adc){ ADC_CHANNEL_IN5, 3 };
|
||||
case C0: return (pin_and_adc){ ADC_CHANNEL_IN6, 0 }; // Can also be ADC2
|
||||
case C1: return (pin_and_adc){ ADC_CHANNEL_IN7, 0 }; // Can also be ADC2
|
||||
case C2: return (pin_and_adc){ ADC_CHANNEL_IN8, 0 }; // Can also be ADC2
|
||||
case C3: return (pin_and_adc){ ADC_CHANNEL_IN9, 0 }; // Can also be ADC2
|
||||
case C4: return (pin_and_adc){ ADC_CHANNEL_IN5, 1 };
|
||||
case C5: return (pin_and_adc){ ADC_CHANNEL_IN11, 1 };
|
||||
case D8: return (pin_and_adc){ ADC_CHANNEL_IN12, 3 };
|
||||
case D9: return (pin_and_adc){ ADC_CHANNEL_IN13, 3 };
|
||||
case D10: return (pin_and_adc){ ADC_CHANNEL_IN7, 2 }; // Can also be ADC4
|
||||
case D11: return (pin_and_adc){ ADC_CHANNEL_IN8, 2 }; // Can also be ADC4
|
||||
case D12: return (pin_and_adc){ ADC_CHANNEL_IN9, 2 }; // Can also be ADC4
|
||||
case D13: return (pin_and_adc){ ADC_CHANNEL_IN10, 2 }; // Can also be ADC4
|
||||
case D14: return (pin_and_adc){ ADC_CHANNEL_IN11, 2 }; // Can also be ADC4
|
||||
case E7: return (pin_and_adc){ ADC_CHANNEL_IN13, 2 };
|
||||
case E8: return (pin_and_adc){ ADC_CHANNEL_IN6, 2 }; // Can also be ADC4
|
||||
case E9: return (pin_and_adc){ ADC_CHANNEL_IN2, 2 };
|
||||
case E10: return (pin_and_adc){ ADC_CHANNEL_IN14, 2 };
|
||||
case E11: return (pin_and_adc){ ADC_CHANNEL_IN15, 2 };
|
||||
case E12: return (pin_and_adc){ ADC_CHANNEL_IN16, 2 };
|
||||
case E13: return (pin_and_adc){ ADC_CHANNEL_IN3, 2 };
|
||||
case E14: return (pin_and_adc){ ADC_CHANNEL_IN1, 3 };
|
||||
case E15: return (pin_and_adc){ ADC_CHANNEL_IN2, 3 };
|
||||
case F2: return (pin_and_adc){ ADC_CHANNEL_IN10, 0 }; // Can also be ADC2
|
||||
case F4: return (pin_and_adc){ ADC_CHANNEL_IN5, 0 };
|
||||
#else
|
||||
#error "An ADC pin-to-mux configuration has not been specified for this microcontroller."
|
||||
#endif
|
||||
default: return (pin_and_adc){ 0, 0 };
|
||||
// clang-format on
|
||||
}
|
||||
}
|
||||
|
||||
adcsample_t analogReadPin(pin_t pin) { return adc_read(pinToMux(pin)); }
|
||||
|
||||
adcsample_t analogReadPinAdc(pin_t pin, uint8_t adc) {
|
||||
pin_and_adc target = pinToMux(pin);
|
||||
target.adc = adc;
|
||||
return adc_read(target);
|
||||
}
|
||||
|
||||
adcsample_t adc_read(pin_and_adc mux) {
|
||||
#if defined(STM32F0XX)
|
||||
adcConversionGroup.sqr = ADC_CHSELR_CHSEL1;
|
||||
#elif defined(STM32F3XX)
|
||||
adcConversionGroup.sqr[0] = ADC_SQR1_SQ1_N(mux.pin);
|
||||
#else
|
||||
# error "adc_read has not been updated to support this ARM microcontroller."
|
||||
#endif
|
||||
|
||||
ADCDriver* targetDriver = intToADCDriver(mux.adc);
|
||||
manageAdcInitializationDriver(mux.adc, targetDriver);
|
||||
|
||||
adcConvert(targetDriver, &adcConversionGroup, &sampleBuffer[0], ADC_BUFFER_DEPTH);
|
||||
adcsample_t* result = sampleBuffer;
|
||||
|
||||
return *result;
|
||||
}
|
57
drivers/arm/analog.h
Normal file
57
drivers/arm/analog.h
Normal file
@ -0,0 +1,57 @@
|
||||
/* Copyright 2019 Drew Mills
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 2 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "quantum.h"
|
||||
#include "ch.h"
|
||||
#include <hal.h>
|
||||
|
||||
#if !defined(STM32F0XX) && !defined(STM32F3XX)
|
||||
# error "Only STM23F0 and STM32F3 devices have ADC support in QMK at this time."
|
||||
#endif
|
||||
|
||||
#if !HAL_USE_ADC
|
||||
# error "You need to set HAL_USE_ADC to TRUE in your halconf.h to use the ADC."
|
||||
#endif
|
||||
|
||||
#if !STM32_ADC_USE_ADC1 && !STM32_ADC_USE_ADC2 && !STM32_ADC_USE_ADC3 && !STM32_ADC_USE_ADC4
|
||||
# error "You need to set one of the 'STM32_ADC_USE_ADCx' settings to TRUE in your mcuconf.h to use the ADC."
|
||||
#endif
|
||||
|
||||
#if STM32_ADC_DUAL_MODE
|
||||
# error "STM32 ADC Dual Mode is not supported at this time."
|
||||
#endif
|
||||
|
||||
#if STM32_ADCV3_OVERSAMPLING
|
||||
# error "STM32 ADCV3 Oversampling is not supported at this time."
|
||||
#endif
|
||||
|
||||
typedef struct {
|
||||
pin_t pin;
|
||||
uint8_t adc;
|
||||
} pin_and_adc;
|
||||
#define PIN_AND_ADC(p, a) \
|
||||
(pin_and_adc) { p, a }
|
||||
|
||||
// analogReference has been left un-defined for ARM devices.
|
||||
// void analogReference(uint8_t mode);
|
||||
|
||||
adcsample_t analogReadPin(pin_t pin);
|
||||
adcsample_t analogReadPinAdc(pin_t pin, uint8_t adc);
|
||||
pin_and_adc pinToMux(pin_t pin);
|
||||
|
||||
adcsample_t adc_read(pin_and_adc mux);
|
96
drivers/eeprom/eeprom_stm32_L0_L1.c
Normal file
96
drivers/eeprom/eeprom_stm32_L0_L1.c
Normal file
@ -0,0 +1,96 @@
|
||||
/* Copyright 2020 Nick Brassel (tzarc)
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 2 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#include <stdint.h>
|
||||
#include <string.h>
|
||||
|
||||
#include "hal.h"
|
||||
#include "eeprom_driver.h"
|
||||
#include "eeprom_stm32_L0_L1.h"
|
||||
|
||||
#define EEPROM_BASE_ADDR 0x08080000
|
||||
#define EEPROM_ADDR(offset) (EEPROM_BASE_ADDR + (offset))
|
||||
#define EEPROM_PTR(offset) ((__IO uint8_t *)EEPROM_ADDR(offset))
|
||||
#define EEPROM_BYTE(location, offset) (*(EEPROM_PTR(((uint32_t)location) + ((uint32_t)offset))))
|
||||
|
||||
#define BUFFER_BYTE(buffer, offset) (*(((uint8_t *)buffer) + offset))
|
||||
|
||||
#define FLASH_PEKEY1 0x89ABCDEF
|
||||
#define FLASH_PEKEY2 0x02030405
|
||||
|
||||
static inline void STM32_L0_L1_EEPROM_WaitNotBusy(void) {
|
||||
while (FLASH->SR & FLASH_SR_BSY) {
|
||||
__WFI();
|
||||
}
|
||||
}
|
||||
|
||||
static inline void STM32_L0_L1_EEPROM_Unlock(void) {
|
||||
STM32_L0_L1_EEPROM_WaitNotBusy();
|
||||
if (FLASH->PECR & FLASH_PECR_PELOCK) {
|
||||
FLASH->PEKEYR = FLASH_PEKEY1;
|
||||
FLASH->PEKEYR = FLASH_PEKEY2;
|
||||
}
|
||||
}
|
||||
|
||||
static inline void STM32_L0_L1_EEPROM_Lock(void) {
|
||||
STM32_L0_L1_EEPROM_WaitNotBusy();
|
||||
FLASH->PECR |= FLASH_PECR_PELOCK;
|
||||
}
|
||||
|
||||
void eeprom_driver_init(void) {}
|
||||
|
||||
void eeprom_driver_erase(void) {
|
||||
STM32_L0_L1_EEPROM_Unlock();
|
||||
|
||||
for (size_t offset = 0; offset < STM32_ONBOARD_EEPROM_SIZE; offset += sizeof(uint32_t)) {
|
||||
FLASH->PECR |= FLASH_PECR_ERASE | FLASH_PECR_DATA;
|
||||
|
||||
*(__IO uint32_t *)EEPROM_ADDR(offset) = (uint32_t)0;
|
||||
|
||||
STM32_L0_L1_EEPROM_WaitNotBusy();
|
||||
FLASH->PECR &= ~(FLASH_PECR_ERASE | FLASH_PECR_DATA);
|
||||
}
|
||||
|
||||
STM32_L0_L1_EEPROM_Lock();
|
||||
}
|
||||
|
||||
void eeprom_read_block(void *buf, const void *addr, size_t len) {
|
||||
for (size_t offset = 0; offset < len; ++offset) {
|
||||
// Drop out if we've hit the limit of the EEPROM
|
||||
if ((((uint32_t)addr) + offset) >= STM32_ONBOARD_EEPROM_SIZE) {
|
||||
break;
|
||||
}
|
||||
|
||||
STM32_L0_L1_EEPROM_WaitNotBusy();
|
||||
BUFFER_BYTE(buf, offset) = EEPROM_BYTE(addr, offset);
|
||||
}
|
||||
}
|
||||
|
||||
void eeprom_write_block(const void *buf, void *addr, size_t len) {
|
||||
STM32_L0_L1_EEPROM_Unlock();
|
||||
|
||||
for (size_t offset = 0; offset < len; ++offset) {
|
||||
// Drop out if we've hit the limit of the EEPROM
|
||||
if ((((uint32_t)addr) + offset) >= STM32_ONBOARD_EEPROM_SIZE) {
|
||||
break;
|
||||
}
|
||||
|
||||
STM32_L0_L1_EEPROM_WaitNotBusy();
|
||||
EEPROM_BYTE(addr, offset) = BUFFER_BYTE(buf, offset);
|
||||
}
|
||||
|
||||
STM32_L0_L1_EEPROM_Lock();
|
||||
}
|
33
drivers/eeprom/eeprom_stm32_L0_L1.h
Normal file
33
drivers/eeprom/eeprom_stm32_L0_L1.h
Normal file
@ -0,0 +1,33 @@
|
||||
/* Copyright 2020 Nick Brassel (tzarc)
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 2 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
/*
|
||||
The size used by the STM32 L0/L1 EEPROM driver.
|
||||
*/
|
||||
#ifndef STM32_ONBOARD_EEPROM_SIZE
|
||||
# ifdef VIA_ENABLE
|
||||
# define STM32_ONBOARD_EEPROM_SIZE 1024
|
||||
# else
|
||||
# include "eeconfig.h"
|
||||
# define STM32_ONBOARD_EEPROM_SIZE (((EECONFIG_SIZE + 3) / 4) * 4) // based off eeconfig's current usage, aligned to 4-byte sizes, to deal with LTO and EEPROM page sizing
|
||||
# endif
|
||||
#endif
|
||||
|
||||
#if STM32_ONBOARD_EEPROM_SIZE > 128
|
||||
# pragma message("Please note: resetting EEPROM using an STM32L0/L1 device takes up to 1 second for every 1kB of internal EEPROM used.")
|
||||
#endif
|
@ -1,49 +0,0 @@
|
||||
/* Copyright 2019 Ryota Goto
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 2 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
#include QMK_KEYBOARD_H
|
||||
/*
|
||||
K000, K001, K002, K003, K004, K005, K006, K007, K008, K009, K010, K011, \
|
||||
K100, K101, K102, K103, K104, K105, K106, K107, K108, K109, K110, K111, \
|
||||
K200, K201, K202, K203, K204, K205, K206, K207, K208, K209, K210, K211, \
|
||||
K300, K301, K302, K304, K306, K308, K309, K310, K311 \
|
||||
*/
|
||||
|
||||
const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = {
|
||||
[0] = LAYOUT_all( /* Base */
|
||||
MO(2), KC_Q, KC_W, KC_E, KC_R, KC_T, KC_Y, KC_U, KC_I, KC_O, KC_P, KC_BSPC,
|
||||
MO(1), KC_A, KC_S, KC_D, KC_F, KC_G, KC_H, KC_J, KC_K, KC_L, KC_SCLN, KC_ENT,
|
||||
KC_LSFT, KC_LSFT, KC_Z, KC_X, KC_C, KC_V, KC_B, KC_N, KC_M, KC_COMM, KC_DOT, KC_RSFT,
|
||||
KC_LCTL, KC_LGUI, KC_LALT, KC_SPC, KC_SPC, KC_SPC, KC_GRV, KC_RGUI, KC_DEL
|
||||
),
|
||||
[1] = LAYOUT_all( /* Extra Keys */
|
||||
_______, _______, KC_PGUP, _______, _______, KC_LBRC, KC_RBRC, _______, KC_UP, _______, _______, _______,
|
||||
_______, KC_HOME, KC_PGDN, KC_END, _______, KC_BSLS, KC_SLSH, KC_LEFT, KC_DOWN, KC_RGHT, _______, _______,
|
||||
_______, _______, _______, _______, _______, KC_PSCR, KC_ESC, KC_QUOT, _______, KC_DOT, _______, _______,
|
||||
_______, _______, _______, _______, _______, _______, _______, _______, _______
|
||||
),
|
||||
[2] = LAYOUT_all( /* Num and FN */
|
||||
_______, KC_1, KC_2, KC_3, KC_4, KC_5, KC_6, KC_7, KC_8, KC_9, KC_0, _______,
|
||||
_______, KC_F1, KC_F2, KC_F3, KC_F4, KC_F5, KC_F6, _______, _______, _______, _______, _______,
|
||||
_______, _______, KC_F7, KC_F8, KC_F9, KC_F10, KC_F11, KC_F12, _______, _______, _______, _______,
|
||||
_______, _______, _______, _______, _______, _______, _______, _______, _______
|
||||
),
|
||||
[3] = LAYOUT_all( /* Other */
|
||||
_______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______,
|
||||
_______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______,
|
||||
_______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______,
|
||||
_______, _______, _______, _______, _______, _______, _______, _______, _______
|
||||
)
|
||||
};
|
@ -1,4 +0,0 @@
|
||||
# The proto via keymap for equinox
|
||||
|
||||
Has the necessary tweaks to run on early prototype PCBs.
|
||||
Not to be used for production run PCBs.
|
@ -1,5 +0,0 @@
|
||||
VIA_ENABLE = yes
|
||||
|
||||
# Fix for prototype missing COL0, COL1, using backlight and RGB underglow I/O pins
|
||||
BACKLIGHT_ENABLE = no # Enable keyboard backlight functionality
|
||||
RGBLIGHT_ENABLE = no # Enable keyboard RGB underglow
|
@ -21,3 +21,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
#undef MATRIX_COL_PINS
|
||||
#define MATRIX_COL_PINS { C4, B7, C6, C7, B6, B5, B4, B3, B2, B1, B0, D6 }
|
||||
|
||||
// This directs backlight code to use a disconnected pin, so the firwmare still has
|
||||
// backlight code and VIA support even though it doesn't do anything.
|
||||
#undef BACKLIGHT_PIN
|
||||
#define BACKLIGHT_PIN D1
|
1
keyboards/ai03/equinox/rev0/rules.mk
Normal file
1
keyboards/ai03/equinox/rev0/rules.mk
Normal file
@ -0,0 +1 @@
|
||||
# Dummy rules.mk, rev0 uses parent rules.mk as is
|
18
keyboards/ai03/equinox/rev1/config.h
Normal file
18
keyboards/ai03/equinox/rev1/config.h
Normal file
@ -0,0 +1,18 @@
|
||||
/*
|
||||
Copyright 2019 Ryota Goto
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 2 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#pragma once
|
1
keyboards/ai03/equinox/rev1/rules.mk
Normal file
1
keyboards/ai03/equinox/rev1/rules.mk
Normal file
@ -0,0 +1 @@
|
||||
# Dummy rules.mk, rev1 uses parent rules.mk as is
|
@ -42,8 +42,6 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
#define RGBLIGHT_ANIMATIONS
|
||||
|
||||
#define NO_UART 1
|
||||
|
||||
/* key combination for magic key command */
|
||||
/* defined by default; to change, uncomment and set to the combination you want */
|
||||
// #define IS_COMMAND() (get_mods() == (MOD_BIT(KC_LSHIFT) | MOD_BIT(KC_RSHIFT)))
|
||||
|
@ -41,5 +41,3 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
#define BACKLIGHT_LEVELS 3
|
||||
|
||||
#define RGBLIGHT_ANIMATIONS
|
||||
|
||||
#define NO_UART 1
|
||||
|
@ -1,268 +0,0 @@
|
||||
/*
|
||||
ChibiOS - Copyright (C) 2006..2018 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"
|
||||
#include "stm32_gpio.h"
|
||||
|
||||
/*===========================================================================*/
|
||||
/* Driver local definitions. */
|
||||
/*===========================================================================*/
|
||||
|
||||
/*===========================================================================*/
|
||||
/* Driver exported variables. */
|
||||
/*===========================================================================*/
|
||||
|
||||
/*===========================================================================*/
|
||||
/* Driver local variables and types. */
|
||||
/*===========================================================================*/
|
||||
|
||||
/**
|
||||
* @brief Type of STM32 GPIO port setup.
|
||||
*/
|
||||
typedef struct {
|
||||
uint32_t moder;
|
||||
uint32_t otyper;
|
||||
uint32_t ospeedr;
|
||||
uint32_t pupdr;
|
||||
uint32_t odr;
|
||||
uint32_t afrl;
|
||||
uint32_t afrh;
|
||||
} gpio_setup_t;
|
||||
|
||||
/**
|
||||
* @brief Type of STM32 GPIO initialization data.
|
||||
*/
|
||||
typedef struct {
|
||||
#if STM32_HAS_GPIOA || defined(__DOXYGEN__)
|
||||
gpio_setup_t PAData;
|
||||
#endif
|
||||
#if STM32_HAS_GPIOB || defined(__DOXYGEN__)
|
||||
gpio_setup_t PBData;
|
||||
#endif
|
||||
#if STM32_HAS_GPIOC || defined(__DOXYGEN__)
|
||||
gpio_setup_t PCData;
|
||||
#endif
|
||||
#if STM32_HAS_GPIOD || defined(__DOXYGEN__)
|
||||
gpio_setup_t PDData;
|
||||
#endif
|
||||
#if STM32_HAS_GPIOE || defined(__DOXYGEN__)
|
||||
gpio_setup_t PEData;
|
||||
#endif
|
||||
#if STM32_HAS_GPIOF || defined(__DOXYGEN__)
|
||||
gpio_setup_t PFData;
|
||||
#endif
|
||||
#if STM32_HAS_GPIOG || defined(__DOXYGEN__)
|
||||
gpio_setup_t PGData;
|
||||
#endif
|
||||
#if STM32_HAS_GPIOH || defined(__DOXYGEN__)
|
||||
gpio_setup_t PHData;
|
||||
#endif
|
||||
#if STM32_HAS_GPIOI || defined(__DOXYGEN__)
|
||||
gpio_setup_t PIData;
|
||||
#endif
|
||||
#if STM32_HAS_GPIOJ || defined(__DOXYGEN__)
|
||||
gpio_setup_t PJData;
|
||||
#endif
|
||||
#if STM32_HAS_GPIOK || defined(__DOXYGEN__)
|
||||
gpio_setup_t PKData;
|
||||
#endif
|
||||
} gpio_config_t;
|
||||
|
||||
/**
|
||||
* @brief STM32 GPIO static initialization data.
|
||||
*/
|
||||
static const gpio_config_t gpio_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
|
||||
#if STM32_HAS_GPIOJ
|
||||
{VAL_GPIOJ_MODER, VAL_GPIOJ_OTYPER, VAL_GPIOJ_OSPEEDR, VAL_GPIOJ_PUPDR,
|
||||
VAL_GPIOJ_ODR, VAL_GPIOJ_AFRL, VAL_GPIOJ_AFRH},
|
||||
#endif
|
||||
#if STM32_HAS_GPIOK
|
||||
{VAL_GPIOK_MODER, VAL_GPIOK_OTYPER, VAL_GPIOK_OSPEEDR, VAL_GPIOK_PUPDR,
|
||||
VAL_GPIOK_ODR, VAL_GPIOK_AFRL, VAL_GPIOK_AFRH}
|
||||
#endif
|
||||
};
|
||||
|
||||
/*===========================================================================*/
|
||||
/* Driver local functions. */
|
||||
/*===========================================================================*/
|
||||
|
||||
static void gpio_init(stm32_gpio_t *gpiop, const gpio_setup_t *config) {
|
||||
|
||||
gpiop->OTYPER = config->otyper;
|
||||
gpiop->OSPEEDR = config->ospeedr;
|
||||
gpiop->PUPDR = config->pupdr;
|
||||
gpiop->ODR = config->odr;
|
||||
gpiop->AFRL = config->afrl;
|
||||
gpiop->AFRH = config->afrh;
|
||||
gpiop->MODER = config->moder;
|
||||
}
|
||||
|
||||
static void stm32_gpio_init(void) {
|
||||
|
||||
/* Enabling GPIO-related clocks, the mask comes from the
|
||||
registry header file.*/
|
||||
rccResetAHB(STM32_GPIO_EN_MASK);
|
||||
rccEnableAHB(STM32_GPIO_EN_MASK, true);
|
||||
|
||||
/* Initializing all the defined GPIO ports.*/
|
||||
#if STM32_HAS_GPIOA
|
||||
gpio_init(GPIOA, &gpio_default_config.PAData);
|
||||
#endif
|
||||
#if STM32_HAS_GPIOB
|
||||
gpio_init(GPIOB, &gpio_default_config.PBData);
|
||||
#endif
|
||||
#if STM32_HAS_GPIOC
|
||||
gpio_init(GPIOC, &gpio_default_config.PCData);
|
||||
#endif
|
||||
#if STM32_HAS_GPIOD
|
||||
gpio_init(GPIOD, &gpio_default_config.PDData);
|
||||
#endif
|
||||
#if STM32_HAS_GPIOE
|
||||
gpio_init(GPIOE, &gpio_default_config.PEData);
|
||||
#endif
|
||||
#if STM32_HAS_GPIOF
|
||||
gpio_init(GPIOF, &gpio_default_config.PFData);
|
||||
#endif
|
||||
#if STM32_HAS_GPIOG
|
||||
gpio_init(GPIOG, &gpio_default_config.PGData);
|
||||
#endif
|
||||
#if STM32_HAS_GPIOH
|
||||
gpio_init(GPIOH, &gpio_default_config.PHData);
|
||||
#endif
|
||||
#if STM32_HAS_GPIOI
|
||||
gpio_init(GPIOI, &gpio_default_config.PIData);
|
||||
#endif
|
||||
#if STM32_HAS_GPIOJ
|
||||
gpio_init(GPIOJ, &gpio_default_config.PJData);
|
||||
#endif
|
||||
#if STM32_HAS_GPIOK
|
||||
gpio_init(GPIOK, &gpio_default_config.PKData);
|
||||
#endif
|
||||
}
|
||||
|
||||
/*===========================================================================*/
|
||||
/* Driver interrupt handlers. */
|
||||
/*===========================================================================*/
|
||||
|
||||
/*===========================================================================*/
|
||||
/* Driver exported functions. */
|
||||
/*===========================================================================*/
|
||||
|
||||
/**
|
||||
* @brief Early initialization code.
|
||||
* @details GPIO ports and system clocks are initialized before everything
|
||||
* else.
|
||||
*/
|
||||
void __early_init(void) {
|
||||
extern void enter_bootloader_mode_if_requested(void);
|
||||
enter_bootloader_mode_if_requested();
|
||||
stm32_gpio_init();
|
||||
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) {
|
||||
SYSCFG->CFGR1 |= SYSCFG_CFGR1_I2C1_DMA_RMP;
|
||||
SYSCFG->CFGR1 &= ~(SYSCFG_CFGR1_SPI2_DMA_RMP);
|
||||
}
|
File diff suppressed because it is too large
Load Diff
@ -1,5 +0,0 @@
|
||||
# List of all the board related files.
|
||||
BOARDSRC = $(BOARD_PATH)/boards/ST_STM32F072B_DISCOVERY/board.c
|
||||
|
||||
# Required include directories
|
||||
BOARDINC = $(BOARD_PATH)/boards/ST_STM32F072B_DISCOVERY
|
@ -6,13 +6,6 @@
|
||||
"height": 4,
|
||||
"layouts": {
|
||||
"LAYOUT": {
|
||||
"layout": [
|
||||
{"label":"Esc", "x":0, "y":0}, {"label":"Q", "x":1, "y":0}, {"label":"W", "x":2, "y":0}, {"label":"E", "x":3, "y":0}, {"label":"R", "x":4, "y":0}, {"label":"T", "x":5, "y":0}, {"label":"Y", "x":6, "y":0}, {"label":"U", "x":7, "y":0}, {"label":"I", "x":8, "y":0}, {"label":"O", "x":9, "y":0}, {"label":"P", "x":10, "y":0}, {"label":"Del", "x":11, "y":0}, {"label":"BkSp", "x":12, "y":0}, {"label":"7", "x":13, "y":0}, {"label":"8", "x":14, "y":0}, {"label":"9", "x":15, "y":0}, {"label":"*", "x":16, "y":0},
|
||||
{"label":"Tab", "x":0, "y":1, "w":1.25}, {"label":"A", "x":1.25, "y":1}, {"label":"S", "x":2.25, "y":1}, {"label":"D", "x":3.25, "y":1}, {"label":"F", "x":4.25, "y":1}, {"label":"G", "x":5.25, "y":1}, {"label":"H", "x":6.25, "y":1}, {"label":"J", "x":7.25, "y":1}, {"label":"K", "x":8.25, "y":1}, {"label":"L", "x":9.25, "y":1}, {"label":":", "x":10.25, "y":1}, {"label":"Enter", "x":11.25, "y":1, "w":1.75}, {"label":"4", "x":13, "y":1}, {"label":"5", "x":14, "y":1}, {"label":"6", "x":15, "y":1}, {"label":"-", "x":16, "y":1},
|
||||
{"label":"Shift", "x":0, "y":2, "w":1.75}, {"label":"Z", "x":1.75, "y":2}, {"label":"X", "x":2.75, "y":2}, {"label":"C", "x":3.75, "y":2}, {"label":"V", "x":4.75, "y":2}, {"label":"B", "x":5.75, "y":2}, {"label":"N", "x":6.75, "y":2}, {"label":"M", "x":7.75, "y":2}, {"label":"<", "x":8.75, "y":2}, {"label":">", "x":9.75, "y":2}, {"label":"Shift", "x":10.75, "y":2, "w":1.25}, {"label":"↑", "x":12, "y":2}, {"label":"1", "x":13, "y":2}, {"label":"2", "x":14, "y":2}, {"label":"3", "x":15, "y":2}, {"label":"+", "x":16, "y":2},
|
||||
{"label":"Ctrl", "x":0, "y":3, "w":1.25}, {"label":"GUI", "x":1.25, "y":3, "w":1.25}, {"label":"Alt", "x":2.5, "y":3, "w":1.25}, {"x":3.75, "y":3, "w":1.75}, {"x":5.5, "y":3, "w":1}, {"label":"Backspace", "x":6.5, "y":3, "w":2.25}, {"label":"Menu", "x":8.75, "y":3, "w":1.25}, {"label":"Fn", "x":10, "y":3}, {"label":"←", "x":11, "y":3}, {"label":"↓", "x":12, "y":3}, {"label":"→", "x":13, "y":3}, {"label":"0", "x":14, "y":3}, {"label":".", "x":15, "y":3}, {"label":"Enter", "x":16, "y":3}]
|
||||
},
|
||||
"LAYOUT_lefty": {
|
||||
"layout": [
|
||||
{"label":"7", "x":0, "y":0}, {"label":"8", "x":1, "y":0}, {"label":"9", "x":2, "y":0}, {"label":"-", "x":3, "y":0}, {"label":"Esc", "x":4, "y":0}, {"label":"Q", "x":5, "y":0}, {"label":"W", "x":6, "y":0}, {"label":"E", "x":7, "y":0}, {"label":"R", "x":8, "y":0}, {"label":"T", "x":9, "y":0}, {"label":"Y", "x":10, "y":0}, {"label":"U", "x":11, "y":0}, {"label":"I", "x":12, "y":0}, {"label":"O", "x":13, "y":0}, {"label":"P", "x":14, "y":0}, {"label":"{", "x":15, "y":0}, {"label":"}", "x":16, "y":0},
|
||||
{"label":"4", "x":0, "y":1}, {"label":"5", "x":1, "y":1}, {"label":"6", "x":2, "y":1}, {"label":"+", "x":3, "y":1}, {"label":"Tab", "x":4, "y":1, "w":1.25}, {"label":"A", "x":5.25, "y":1}, {"label":"S", "x":6.25, "y":1}, {"label":"D", "x":7.25, "y":1}, {"label":"F", "x":8.25, "y":1}, {"label":"G", "x":9.25, "y":1}, {"label":"H", "x":10.25, "y":1}, {"label":"J", "x":11.25, "y":1}, {"label":"K", "x":12.25, "y":1}, {"label":"L", "x":13.25, "y":1}, {"label":":", "x":14.25, "y":1}, {"label":"Enter", "x":15.25, "y":1, "w":1.75},
|
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user