Compare commits

...

2 Commits

Author SHA1 Message Date
Ryan
16a15c1cfc QMK-ify some GPIO macros (#8315) 2020-04-30 16:24:47 +10:00
Ryan
37a4b53c4f BACKLIGHT_ON_STATE config.h fixes (#8862) 2020-04-30 16:24:13 +10:00
22 changed files with 37 additions and 106 deletions

View File

@@ -30,8 +30,8 @@
void inline apa102_setleds(LED_TYPE *ledarray, uint16_t leds) { apa102_setleds_pin(ledarray, leds, _BV(RGB_DI_PIN & 0xF), _BV(RGB_CLK_PIN & 0xF)); }
void static inline apa102_setleds_pin(LED_TYPE *ledarray, uint16_t leds, uint8_t pinmask_DI, uint8_t pinmask_CLK) {
pinMode(RGB_DI_PIN, PinDirectionOutput);
pinMode(RGB_CLK_PIN, PinDirectionOutput);
setPinOutput(RGB_DI_PIN);
setPinOutput(RGB_CLK_PIN);
apa102_send_array((uint8_t *)ledarray, leds)
}
@@ -90,7 +90,7 @@ void apa102_end_frame(uint16_t leds) {
void apa102_send_byte(uint8_t byte) {
uint8_t i;
for (i = 0; i < 8; i++) {
digitalWrite(RGB_DI_PIN, !!(byte & (1 << (7-i)));
digitalWrite(RGB_CLK_PIN, PinLevelHigh);
writePin(RGB_DI_PIN, !!(byte & (1 << (7 - i))));
writePinHigh(RGB_CLK_PIN);
}
}

View File

@@ -3,7 +3,6 @@
#include <stdbool.h>
#include <stdio.h>
#include "pincontrol.h"
#include "config.h"
enum ssd1306_cmds {

View File

@@ -1,7 +1,6 @@
#include "drashna.h"
#include "analog.h"
#include "pointing_device.h"
#include "pincontrol.h"
#define KC_X0 LT(_FN, KC_ESC)

View File

@@ -43,7 +43,6 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
#define BACKLIGHT_LEVELS 3
#define BACKLIGHT_BREATHING
#define BREATHING_PERIOD 6
#define BACKLIGHT_ON_STATE 1
/* Debounce reduces chatter (unintended double-presses) - set 0 if debouncing is not needed */
#define DEBOUNCE 5

View File

@@ -2,7 +2,6 @@
#include <stdbool.h>
#include <stdio.h>
#include "pincontrol.h"
#include "action.h"
enum ssd1306_cmds {
@@ -88,4 +87,4 @@ void matrix_write_ln(struct CharacterMatrix *matrix, const char *data);
void matrix_write_P(struct CharacterMatrix *matrix, const char *data);
void matrix_render(struct CharacterMatrix *matrix);
bool process_record_gfx(uint16_t keycode, keyrecord_t *record);
bool process_record_gfx(uint16_t keycode, keyrecord_t *record);

View File

@@ -2,7 +2,6 @@
#include <stdbool.h>
#include <stdio.h>
#include "pincontrol.h"
#include "action.h"
enum ssd1306_cmds {
@@ -88,4 +87,4 @@ void matrix_write_ln(struct CharacterMatrix *matrix, const char *data);
void matrix_write_P(struct CharacterMatrix *matrix, const char *data);
void matrix_render(struct CharacterMatrix *matrix);
bool process_record_gfx(uint16_t keycode, keyrecord_t *record);
bool process_record_gfx(uint16_t keycode, keyrecord_t *record);

View File

@@ -20,7 +20,6 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
#include QMK_KEYBOARD_H
#include "protocol/serial.h"
#include "timer.h"
#include "pincontrol.h"
/*
@@ -96,27 +95,27 @@ void pins_init(void) {
// set pins for pullups, Rts , power &etc.
//print ("pins setup\n");
pinMode(VCC_PIN, PinDirectionOutput);
digitalWrite(VCC_PIN, PinLevelLow);
setPinOutput(VCC_PIN);
writePinLow(VCC_PIN);
#if ( HANDSPRING == 0)
#ifdef CY835
pinMode(GND_PIN, PinDirectionOutput);
digitalWrite(GND_PIN, PinLevelLow);
setPinOutput(GND_PIN);
writePinLow(GND_PIN);
pinMode(PULLDOWN_PIN, PinDirectionOutput);
digitalWrite(PULLDOWN_PIN, PinLevelLow);
setPinOutput(PULLDOWN_PIN);
writePinLow(PULLDOWN_PIN);
#endif
pinMode(DCD_PIN, PinDirectionInput);
pinMode(RTS_PIN, PinDirectionInput);
setPinInput(DCD_PIN);
setPinInput(RTS_PIN);
#endif
/* check that the other side isn't powered up.
test=digitalRead(DCD_PIN);
test=readPin(DCD_PIN);
xprintf("b%02X:", test);
test=digitalRead(RTS_PIN);
test=readPin(RTS_PIN);
xprintf("%02X\n", test);
*/
@@ -129,20 +128,20 @@ uint8_t rts_reset(void) {
// On boot, we keep rts as input, then switch roles here
// on leaving sleep, we toggle the same way
firstread=digitalRead(RTS_PIN);
firstread=readPin(RTS_PIN);
// printf("r%02X:", firstread);
pinMode(RTS_PIN, PinDirectionOutput);
setPinOutput(RTS_PIN);
if (firstread == PinLevelHigh) {
digitalWrite(RTS_PIN, PinLevelLow);
if (firstread) {
writePinLow(RTS_PIN);
}
_delay_ms(10);
digitalWrite(RTS_PIN, PinLevelHigh);
writePinHigh(RTS_PIN);
/* the future is Arm
if (palReadPad(RTS_PIN_IOPRT) == PinLevelLow)
if (!palReadPad(RTS_PIN_IOPRT))
{
_delay_ms(10);
palSetPadMode(RTS_PINn_IOPORT, PinDirectionOutput_PUSHPULL);
@@ -224,9 +223,9 @@ uint8_t handspring_handshake(void) {
}
uint8_t handspring_reset(void) {
digitalWrite(VCC_PIN, PinLevelLow);
writePinLow(VCC_PIN);
_delay_ms(5);
digitalWrite(VCC_PIN, PinLevelHigh);
writePinHigh(VCC_PIN);
if ( handspring_handshake() ) {
last_activity = timer_read();
@@ -250,7 +249,7 @@ void matrix_init(void)
#endif
print("power up\n");
digitalWrite(VCC_PIN, PinLevelHigh);
writePinHigh(VCC_PIN);
// wait for DCD strobe from keyboard - it will do this
// up to 3 times, then the board needs the RTS toggled to try again
@@ -265,7 +264,7 @@ void matrix_init(void)
}
#else /// Palm / HP device with DCD
while( digitalRead(DCD_PIN) != PinLevelHigh ) {;}
while( !readPin(DCD_PIN) ) {;}
print("dcd\n");
rts_reset(); // at this point the keyboard should think all is well.

View File

@@ -2,7 +2,6 @@
#include <stdbool.h>
#include <stdio.h>
#include "pincontrol.h"
#include "action.h"
enum ssd1306_cmds {
@@ -88,4 +87,4 @@ void matrix_write_ln(struct CharacterMatrix *matrix, const char *data);
void matrix_write_P(struct CharacterMatrix *matrix, const char *data);
void matrix_render(struct CharacterMatrix *matrix);
bool process_record_gfx(uint16_t keycode, keyrecord_t *record);
bool process_record_gfx(uint16_t keycode, keyrecord_t *record);

View File

@@ -43,7 +43,6 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
#define BACKLIGHT_PINS { B1, B2, B3, E6 }
#define BACKLIGHT_LED_COUNT 4
#define BACKLIGHT_LEVELS 10
#define BACKLIGHT_ON_STATE 1
#define RGBLIGHT_ANIMATIONS
#define RGB_DI_PIN D6

View File

@@ -52,6 +52,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
* https://docs.qmk.fm/#/feature_backlight?id=timer-assisted-pwm-implementation
*/
#define BACKLIGHT_PIN D4
#define BACKLIGHT_ON_STATE 0
#define RGB_DI_PIN B2
#ifdef RGB_DI_PIN

View File

@@ -39,7 +39,3 @@ After putting your COD67 in bootloader mode, it will show up as a drive.
* Drag and drop your new `COD67.BIN` to the drive.
* Wait a few seconds for it to write. The caps lock LED flashes rapidly while writing.
* Press the `Esc` key or eject the drive in Finder to reset the board. You are now ready to type!
## Notes
The backlight pin is attached to a non PWM pin `D4` so the backlight is only on/off.

View File

@@ -27,9 +27,6 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
#define PRODUCT AEK64
#define DESCRIPTION QMK keyboard firmware for AEK64 handwired
/* Define the backlight */
/*#define BACKLIGHT_ON_STATE 1*/
/* key matrix size */
#define MATRIX_ROWS 5
#define MATRIX_COLS 14

View File

@@ -41,7 +41,6 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
#define BACKLIGHT_PIN F6
// #define BACKLIGHT_BREATHING
#define BACKLIGHT_LEVELS 5
#define BACKLIGHT_ON_STATE 1
/* Debounce reduces chatter (unintended double-presses) - set 0 if debouncing is not needed */
#define DEBOUNCE 5

View File

@@ -3,7 +3,6 @@
#include <stdbool.h>
#include <stdio.h>
#include "pincontrol.h"
#include "action.h"
enum ssd1306_cmds {

View File

@@ -2,7 +2,6 @@
#include <stdbool.h>
#include <stdio.h>
#include "pincontrol.h"
#include "action.h"
enum ssd1306_cmds {
@@ -88,4 +87,4 @@ void matrix_write_ln(struct CharacterMatrix *matrix, const char *data);
void matrix_write_P(struct CharacterMatrix *matrix, const char *data);
void matrix_render(struct CharacterMatrix *matrix);
bool process_record_gfx(uint16_t keycode, keyrecord_t *record);
bool process_record_gfx(uint16_t keycode, keyrecord_t *record);

View File

@@ -65,7 +65,6 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
#define BACKLIGHT_PINS { C2, C7, D5, D6, B0 }
#define BACKLIGHT_LED_COUNT 5
#define BACKLIGHT_LEVELS 10
#define BACKLIGHT_ON_STATE 1
/* Set 0 if debouncing isn't needed */
#define DEBOUNCE 5

View File

@@ -18,7 +18,6 @@
#define BACKLIGHT_PIN B7
#ifdef BACKLIGHT_PIN
#define BACKLIGHT_LEVELS 6
//#define BACKLIGHT_ON_STATE 1
#endif
/* COL2ROW or ROW2COL */

View File

@@ -52,6 +52,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
#define BACKLIGHT_LEVELS 6
#define BACKLIGHT_BREATHING
#define BREATHING_PERIOD 6
#define BACKLIGHT_ON_STATE 0
/* Debounce reduces chatter (unintended double-presses) - set 0 if debouncing is not needed */
#define DEBOUNCE 5

View File

@@ -51,6 +51,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
#define BACKLIGHT_PIN F5
#define BACKLIGHT_LEVELS 6
#define BACKLIGHT_ON_STATE 0
/* Debounce reduces chatter (unintended double-presses) - set 0 if debouncing is not needed */
#define DEBOUNCE 5

View File

@@ -2,7 +2,6 @@
#include <stdbool.h>
#include <stdio.h>
#include "pincontrol.h"
#include "action.h"
enum ssd1306_cmds {
@@ -93,4 +92,4 @@ void matrix_write_ln(struct CharacterMatrix *matrix, const char *data);
void matrix_write_P(struct CharacterMatrix *matrix, const char *data);
void matrix_render(struct CharacterMatrix *matrix);
bool process_record_gfx(uint16_t keycode, keyrecord_t *record);
bool process_record_gfx(uint16_t keycode, keyrecord_t *record);

View File

@@ -1,50 +0,0 @@
/* Copyright 2016 Wez Furlong
*
* 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
// Some helpers for controlling gpio pins
#include <avr/io.h>
enum {
PinDirectionInput = 0,
PinDirectionOutput = 1,
PinLevelHigh = 1,
PinLevelLow = 0,
};
// ex: pinMode(B0, PinDirectionOutput);
static inline void pinMode(uint8_t pin, int mode) {
uint8_t bv = _BV(pin & 0xf);
if (mode == PinDirectionOutput) {
_SFR_IO8((pin >> 4) + 1) |= bv;
} else {
_SFR_IO8((pin >> 4) + 1) &= ~bv;
_SFR_IO8((pin >> 4) + 2) &= ~bv;
}
}
// ex: digitalWrite(B0, PinLevelHigh);
static inline void digitalWrite(uint8_t pin, int mode) {
uint8_t bv = _BV(pin & 0xf);
if (mode == PinLevelHigh) {
_SFR_IO8((pin >> 4) + 2) |= bv;
} else {
_SFR_IO8((pin >> 4) + 2) &= ~bv;
}
}
// Return true if the pin is HIGH
// digitalRead(B0)
static inline bool digitalRead(uint8_t pin) { return _SFR_IO8(pin >> 4) & _BV(pin & 0xf); }

View File

@@ -2,7 +2,6 @@
#define SOLENOID_H
#include <timer.h>
#include "pincontrol.h"
#define SOLENOID_DEFAULT_DWELL 12
@@ -45,7 +44,7 @@ void solenoid_toggle(void) {
}
void solenoid_stop(void) {
digitalWrite(SOLENOID_PIN, PinLevelLow);
writePinLow(SOLENOID_PIN);
solenoid_on = false;
solenoid_buzzing = false;
}
@@ -59,7 +58,7 @@ void solenoid_fire(void) {
solenoid_on = true;
solenoid_buzzing = true;
solenoid_start = timer_read();
digitalWrite(SOLENOID_PIN, PinLevelHigh);
writePinHigh(SOLENOID_PIN);
}
void solenoid_check(void) {
@@ -80,20 +79,20 @@ void solenoid_check(void) {
if (elapsed / SOLENOID_MIN_DWELL % 2 == 0){
if (!solenoid_buzzing) {
solenoid_buzzing = true;
digitalWrite(SOLENOID_PIN, PinLevelHigh);
writePinHigh(SOLENOID_PIN);
}
}
else {
if (solenoid_buzzing) {
solenoid_buzzing = false;
digitalWrite(SOLENOID_PIN, PinLevelLow);
writePinLow(SOLENOID_PIN);
}
}
}
}
void solenoid_setup(void) {
pinMode(SOLENOID_PIN, PinDirectionOutput);
setPinOutput(SOLENOID_PIN);
}
#endif